Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+70 -31
+4
drivers/soc/actions/Kconfig
··· 1 1 if ARCH_ACTIONS || COMPILE_TEST 2 2 3 + config OWL_PM_DOMAINS_HELPER 4 + bool 5 + 3 6 config OWL_PM_DOMAINS 4 7 bool "Actions Semi SPS power domains" 5 8 depends on PM 9 + select OWL_PM_DOMAINS_HELPER 6 10 select PM_GENERIC_DOMAINS 7 11 help 8 12 Say 'y' here to enable support for Smart Power System (SPS)
+1
drivers/soc/actions/Makefile
··· 1 + obj-$(CONFIG_OWL_PM_DOMAINS_HELPER) += owl-sps-helper.o 1 2 obj-$(CONFIG_OWL_PM_DOMAINS) += owl-sps.o
+51
drivers/soc/actions/owl-sps-helper.c
··· 1 + /* 2 + * Actions Semi Owl Smart Power System (SPS) shared helpers 3 + * 4 + * Copyright 2012 Actions Semi Inc. 5 + * Author: Actions Semi, Inc. 6 + * 7 + * Copyright (c) 2017 Andreas Färber 8 + * 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License as published by the 11 + * Free Software Foundation; either version 2 of the License, or (at your 12 + * option) any later version. 13 + */ 14 + 15 + #include <linux/delay.h> 16 + #include <linux/io.h> 17 + 18 + #define OWL_SPS_PG_CTL 0x0 19 + 20 + int owl_sps_set_pg(void __iomem *base, u32 pwr_mask, u32 ack_mask, bool enable) 21 + { 22 + u32 val; 23 + bool ack; 24 + int timeout; 25 + 26 + val = readl(base + OWL_SPS_PG_CTL); 27 + ack = val & ack_mask; 28 + if (ack == enable) 29 + return 0; 30 + 31 + if (enable) 32 + val |= pwr_mask; 33 + else 34 + val &= ~pwr_mask; 35 + 36 + writel(val, base + OWL_SPS_PG_CTL); 37 + 38 + for (timeout = 5000; timeout > 0; timeout -= 50) { 39 + val = readl(base + OWL_SPS_PG_CTL); 40 + if ((val & ack_mask) == (enable ? ack_mask : 0)) 41 + break; 42 + udelay(50); 43 + } 44 + if (timeout <= 0) 45 + return -ETIMEDOUT; 46 + 47 + udelay(10); 48 + 49 + return 0; 50 + } 51 + EXPORT_SYMBOL_GPL(owl_sps_set_pg);
+3 -31
drivers/soc/actions/owl-sps.c
··· 12 12 * option) any later version. 13 13 */ 14 14 15 - #include <linux/delay.h> 16 - #include <linux/io.h> 17 15 #include <linux/of_address.h> 18 16 #include <linux/of_platform.h> 19 17 #include <linux/pm_domain.h> 18 + #include <linux/soc/actions/owl-sps.h> 20 19 #include <dt-bindings/power/owl-s500-powergate.h> 21 - 22 - #define OWL_SPS_PG_CTL 0x0 23 20 24 21 struct owl_sps_domain_info { 25 22 const char *name; ··· 48 51 49 52 static int owl_sps_set_power(struct owl_sps_domain *pd, bool enable) 50 53 { 51 - u32 val, pwr_mask, ack_mask; 52 - int timeout; 53 - bool ack; 54 + u32 pwr_mask, ack_mask; 54 55 55 56 ack_mask = BIT(pd->info->ack_bit); 56 57 pwr_mask = BIT(pd->info->pwr_bit); 57 - val = readl(pd->sps->base + OWL_SPS_PG_CTL); 58 - ack = val & ack_mask; 59 58 60 - if (ack == enable) 61 - return 0; 62 - 63 - if (enable) 64 - val |= pwr_mask; 65 - else 66 - val &= ~pwr_mask; 67 - 68 - writel(val, pd->sps->base + OWL_SPS_PG_CTL); 69 - 70 - for (timeout = 5000; timeout > 0; timeout -= 50) { 71 - val = readl(pd->sps->base + OWL_SPS_PG_CTL); 72 - if ((val & ack_mask) == (enable ? ack_mask : 0)) 73 - break; 74 - udelay(50); 75 - } 76 - if (timeout <= 0) 77 - return -ETIMEDOUT; 78 - 79 - udelay(10); 80 - 81 - return 0; 59 + return owl_sps_set_pg(pd->sps->base, pwr_mask, ack_mask, enable); 82 60 } 83 61 84 62 static int owl_sps_power_on(struct generic_pm_domain *domain)
+11
include/linux/soc/actions/owl-sps.h
··· 1 + /* 2 + * Copyright (c) 2017 Andreas Färber 3 + * 4 + * SPDX-License-Identifier: GPL-2.0+ 5 + */ 6 + #ifndef SOC_ACTIONS_OWL_SPS_H 7 + #define SOC_ACTIONS_OWL_SPS_H 8 + 9 + int owl_sps_set_pg(void __iomem *base, u32 pwr_mask, u32 ack_mask, bool enable); 10 + 11 + #endif