From b39ce179da9818c98616da20f3a1b0667c559179 Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Thu, 6 Apr 2017 10:38:13 +0530 Subject: [PATCH] drivers: firmware: psci: Set ARM32 cpuidle ops ARM64 uses cpu enable-method property as "psci" whereas for ARM32 this needs to be "arm,psci". Use "psci" as enable-method for ARM32 and initialize cpuidle ops to be used by LPM driver for ARM32. Change-Id: I1bafc2460b3f62c6d7688d5bb7aa9cffa03bf917 Signed-off-by: Maulik Shah --- .../devicetree/bindings/arm/cpus.txt | 1 + drivers/cpuidle/lpm-levels.c | 26 +++++++++++++++++++ drivers/firmware/psci.c | 13 +++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt index 9a9c045dbf6a..0d7034e20d8d 100644 --- a/Documentation/devicetree/bindings/arm/cpus.txt +++ b/Documentation/devicetree/bindings/arm/cpus.txt @@ -190,6 +190,7 @@ nodes to be present and contain the properties described below. "allwinner,sun6i-a31" "allwinner,sun8i-a23" "arm,psci" + "psci" "brcm,brahma-b15" "marvell,armada-375-smp" "marvell,armada-380-smp" diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c index 4224b594f1b8..b69e59eeeae1 100644 --- a/drivers/cpuidle/lpm-levels.c +++ b/drivers/cpuidle/lpm-levels.c @@ -363,6 +363,24 @@ static int lpm_cpu_callback(struct notifier_block *cpu_nb, return NOTIFY_OK; } +#ifdef CONFIG_ARM_PSCI + +static int __init set_cpuidle_ops(void) +{ + int ret = 0, cpu; + + for_each_possible_cpu(cpu) { + ret = arm_cpuidle_init(cpu); + if (ret) + goto exit; + } + +exit: + return ret; +} + +#endif + static enum hrtimer_restart lpm_hrtimer_cb(struct hrtimer *h) { return HRTIMER_NORESTART; @@ -1954,6 +1972,14 @@ static int __init lpm_levels_module_init(void) goto fail; } +#ifdef CONFIG_ARM_PSCI + rc = set_cpuidle_ops(); + if (rc) { + pr_err("%s(): Failed to set cpuidle ops\n", __func__); + goto fail; + } +#endif + fail: return rc; } diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index af0060d6a22a..d652f3b53635 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -230,6 +230,13 @@ static int __init psci_features(u32 psci_func_id) #ifdef CONFIG_CPU_IDLE static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); +#ifdef CONFIG_ARM_PSCI +static int psci_cpu_init(struct device_node *cpu_node, int cpu) +{ + return 0; +} +#endif + static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) { int i, ret, count = 0; @@ -333,10 +340,14 @@ int psci_cpu_suspend_enter(unsigned long state_id) #ifdef CONFIG_ARM static struct cpuidle_ops psci_cpuidle_ops __initdata = { .suspend = psci_cpu_suspend_enter, +#ifdef CONFIG_ARM_PSCI + .init = psci_cpu_init, +#else .init = psci_dt_cpu_init_idle, +#endif }; -CPUIDLE_METHOD_OF_DECLARE(psci, "arm,psci", &psci_cpuidle_ops); +CPUIDLE_METHOD_OF_DECLARE(psci, "psci", &psci_cpuidle_ops); #endif #endif