diff options
author | Andreas Färber <afaerber@suse.de> | 2017-06-05 22:04:21 +0300 |
---|---|---|
committer | Andreas Färber <afaerber@suse.de> | 2017-06-23 18:43:27 +0300 |
commit | 6932ec60cc0a71689150b16b71427cfdc6575602 (patch) | |
tree | 27942772c2ef4d35444d6c4ef7c48e36663d9855 /drivers/soc/actions/owl-sps-helper.c | |
parent | aa9f800ded78d530bb07104a4745e95af723abf6 (diff) | |
download | linux-6932ec60cc0a71689150b16b71427cfdc6575602.tar.xz |
soc: actions: owl-sps: Factor out owl_sps_set_pg() for power-gating
Allow the SMP code to reuse PM domain code for CPU2/CPU3 wakeup.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'drivers/soc/actions/owl-sps-helper.c')
-rw-r--r-- | drivers/soc/actions/owl-sps-helper.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/soc/actions/owl-sps-helper.c b/drivers/soc/actions/owl-sps-helper.c new file mode 100644 index 000000000000..9d7a2c2b44ec --- /dev/null +++ b/drivers/soc/actions/owl-sps-helper.c @@ -0,0 +1,51 @@ +/* + * Actions Semi Owl Smart Power System (SPS) shared helpers + * + * Copyright 2012 Actions Semi Inc. + * Author: Actions Semi, Inc. + * + * Copyright (c) 2017 Andreas Färber + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/delay.h> +#include <linux/io.h> + +#define OWL_SPS_PG_CTL 0x0 + +int owl_sps_set_pg(void __iomem *base, u32 pwr_mask, u32 ack_mask, bool enable) +{ + u32 val; + bool ack; + int timeout; + + val = readl(base + OWL_SPS_PG_CTL); + ack = val & ack_mask; + if (ack == enable) + return 0; + + if (enable) + val |= pwr_mask; + else + val &= ~pwr_mask; + + writel(val, base + OWL_SPS_PG_CTL); + + for (timeout = 5000; timeout > 0; timeout -= 50) { + val = readl(base + OWL_SPS_PG_CTL); + if ((val & ack_mask) == (enable ? ack_mask : 0)) + break; + udelay(50); + } + if (timeout <= 0) + return -ETIMEDOUT; + + udelay(10); + + return 0; +} +EXPORT_SYMBOL_GPL(owl_sps_set_pg); |