ARM: qcom: cpuidle support for 8064, 8074, 8084
Subsystems (5)
v15 cover ARM: qcom: cpuidle support for 8064, 8074, 8084
Hi,
I was able to use Daniel's series for the cpuidle_ops [5] and test it on QCOM SOCs. This alleviates the concerns raised in the previous revision of the QCOM cpuidle driver.
The previous revision of the QCOM cpuidle driver [1], creates cpuidle device after a successful probe of the SPM device for the CPU. There was a concern regarding the initialization of unnecesary devices on a multi-v7 configuration [2]. The solutions proposed to solve this problem didnt turn up elegant either because of the restriction with the existing cpuidle framework.
With Daniel's patches [5], I was able to address the concerns with the cpuidle driver and devices intialization. Please take a look at this series. The crux of the difference from the previous series [1] is in the spm_drv_probe() and registering of the cpuidle_ops and use of ARM generic cpuidle driver.
Changes since v14:
- Support for cpuidle_ops
- SPM probe changes to register cpuidle
- Rebase on top of 4.0-rc1
- Remove SCM patches from series. Rebased on top of Kumar's tree[4]
- Removed cpuidle-qcom.c in favor of ARM generic cpuidle driver
- Included Daniel's change for supporting creating cpuidle devices by platform
Tested on: 8074, 8084.
Thanks,
Lina
[1]. http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/308118.html
[2]. http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/308465.html
[3]. http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/311071.html
[4]. http://www.spinics.net/lists/linux-arm-msm/msg13630.html
[5]. https://lkml.org/lkml/2015/3/3/271
Daniel Lezcano (1):
ARM: cpuidle: Register per cpuidle device
Lina Iyer (10):
ARM: qcom: Add Subsystem Power Manager (SPM) driver
ARM: cpuidle: qcom: Add documentation for qcom cpuidle states.
ARM: cpuidle: Register cpuidle_ops for QCOM cpus
ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs
ARM: dts: qcom: Add power-controller device node for 8084 Krait CPUs
ARM: dts: qcom: Update power-controller device node for 8064 Krait
CPUs
ARM: dts: qcom: Add idle states device nodes for 8074
ARM: dts: qcom: Add idle states device nodes for 8084
ARM: dts: qcom: Add idle state device nodes for 8064
ARM: qcom: Update defconfig
.../bindings/arm/msm/qcom,idle-state.txt | 81 ++++ .../devicetree/bindings/arm/msm/qcom,saw2.txt | 31 +- arch/arm/boot/dts/qcom-apq8064.dtsi | 38 +- arch/arm/boot/dts/qcom-apq8084.dtsi | 48 ++- arch/arm/boot/dts/qcom-msm8974.dtsi | 48 ++- arch/arm/configs/qcom_defconfig | 2 + arch/arm/include/asm/cpuidle_ops.h | 5 + drivers/cpuidle/cpuidle-arm.c | 34 +- drivers/soc/qcom/Kconfig | 7 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/spm.c | 422 +++++++++++++++++++++ 11 files changed, 700 insertions(+), 17 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt create mode 100644 drivers/soc/qcom/spm.c
Signature · 1 line
2.1.0
RFC PATCH v15 1/11 ARM: cpuidle: Register per cpuidle device
From: Daniel Lezcano <[email protected]>
Some architectures have some cpus which does not support idle states.
Let the underlying low level code to return -ENOSYS when it is not possible to set an idle state.
--- drivers/cpuidle/cpuidle-arm.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/cpuidle/cpuidle-arm.c +33 -1
@@ -17,11 +17,14 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/slab.h> #include <asm/cpuidle.h> #include "dt_idle_states.h" +static DEFINE_PER_CPU(struct cpuidle_device, *cpuidle_arm_dev); +/* * arm_enter_idle_state - Programs CPU to enter the specified state *
@@ -93,6 +96,7 @@ static const struct of_device_id arm_idle_state_match[] __initconst = {static int __init arm_idle_init (void ) {int cpu, ret; +struct cpuidle_device *dev;struct cpuidle_driver *drv = &arm_idle_driver;/*
@@ -105,18 +109,46 @@ static int __init arm_idle_init(void)if (ret <=0 )return ret ? : -ENODEV ; + + ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("Failed to register cpuidle driver\n" ); +return ret; + } +/* * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ for_each_possible_cpu (cpu) { + ret =arm_cpuidle_init (cpu); +/* +* This cpu does not support any idle states +*/ +if (ret == -ENOSYS ) +continue ; +if (ret) {pr_err ("CPU %d failed to init idle CPU ops\n" , cpu);return ret; } + + dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (!dev) +return -ENOMEM ; + + dev->cpu = cpu; + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("Failed to register cpuidle device for CPU %d\n" , + cpu); +return ret; + } + +per_cpu (cpuidle_arm_dev, cpu) = dev; } -return cpuidle_register (drv,NULL ); +return 0 ; }device_initcall (arm_idle_init);
Signature · 1 line
2.1.0
RFC PATCH v15 1/11 ARM: cpuidle: Register per cpuidle device
Quoted 61 lines · Lina Iyer
From: Daniel Lezcano <[email protected]>
Some architectures have some cpus which does not support idle states.
Let the underlying low level code to return
-ENOSYSwhen it is not possible to set an idle state.Signed-off-by Daniel Lezcano <[email protected]>Signed-off-by Lina Iyer <[email protected]>[Minor clean ups and fixes of the per-cpu variable]--- drivers/cpuidle/cpuidle-arm.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-arm.c +14
-0@@ -17,11 +17,14 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/slab.h> #include <asm/cpuidle.h> #include "dt_idle_states.h" +static DEFINE_PER_CPU(struct cpuidle_device, *cpuidle_arm_dev); +/* * arm_enter_idle_state - Programs CPU to enter the specified state * @@ -93,6 +96,7 @@ static const struct of_device_id arm_idle_state_match[] __initconst = {static int __init arm_idle_init (void ) {int cpu, ret; +struct cpuidle_device *dev;struct cpuidle_driver *drv = &arm_idle_driver;/* @@ -105,18 +109,46 @@ static int __init arm_idle_init(void)if (ret <=0 )return ret ? : -ENODEV ; + + ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("Failed to register cpuidle driver\n" ); +return ret; + } +/* * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ for_each_possible_cpu (cpu) { + ret =arm_cpuidle_init (cpu); +/* +* This cpu does not support any idle states
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 137
Quoted 10 lines
drivers/cpuidle/cpuidle-arm.c +6
-0+*/ +if (ret == -ENOSYS ) +continue ; +if (ret) {pr_err ("CPU %d failed to init idle CPU ops\n" , cpu);return ret; } + + dev =kzalloc (sizeof (*dev),GFP_KERNEL );
devm_kzalloc? Otherwise, failures could lead to lost memory.
Quoted 25 lines
drivers/cpuidle/cpuidle-arm.c +13
-1+if (!dev) +return -ENOMEM ; + + dev->cpu = cpu; + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("Failed to register cpuidle device for CPU %d\n" , + cpu); +return ret; + } + +per_cpu (cpuidle_arm_dev, cpu) = dev; } -return cpuidle_register (drv,NULL ); +return 0 ; }device_initcall (arm_idle_init);Signature · 6 lines
2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 1/11 ARM: cpuidle: Register per cpuidle device
Quoted 66 lines · Andy Gross
Quoted 65 lines · Lina Iyer
From: Daniel Lezcano <[email protected]>
Some architectures have some cpus which does not support idle states.
Let the underlying low level code to return
-ENOSYSwhen it is not possible to set an idle state.Signed-off-by Daniel Lezcano <[email protected]>Signed-off-by Lina Iyer <[email protected]>[Minor clean ups and fixes of the per-cpu variable]--- drivers/cpuidle/cpuidle-arm.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)drivers/cpuidle/cpuidle-arm.c +18
-0@@ -17,11 +17,14 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/slab.h> #include <asm/cpuidle.h> #include "dt_idle_states.h" +static DEFINE_PER_CPU(struct cpuidle_device, *cpuidle_arm_dev); +/* * arm_enter_idle_state - Programs CPU to enter the specified state * @@ -93,6 +96,7 @@ static const struct of_device_id arm_idle_state_match[] __initconst = {static int __init arm_idle_init (void ) {int cpu, ret; +struct cpuidle_device *dev;struct cpuidle_driver *drv = &arm_idle_driver;/* @@ -105,18 +109,46 @@ static int __init arm_idle_init(void)if (ret <=0 )return ret ? : -ENODEV ; + + ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("Failed to register cpuidle driver\n" ); +return ret; + } +/* * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ for_each_possible_cpu (cpu) { + ret =arm_cpuidle_init (cpu); +/* +* This cpu does not support any idle states +*/ +if (ret == -ENOSYS ) +continue ; +
Quoted 9 lines
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 137
Quoted 6 lines
drivers/cpuidle/cpuidle-arm.c +2
-0if (ret) {pr_err ("CPU %d failed to init idle CPU ops\n" , cpu);return ret; } + + dev =kzalloc (sizeof (*dev),GFP_KERNEL );
devm_kzalloc? Otherwise, failures could lead to lost memory.
I dont have a local device to work with for allocation. May be I can get the cpu device node and the device therefore for allocation. Thoughts?
Quoted 31 lines
Quoted 25 lines
drivers/cpuidle/cpuidle-arm.c +13
-2+if (!dev) +return -ENOMEM ; + + dev->cpu = cpu; + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("Failed to register cpuidle device for CPU %d\n" , + cpu); +return ret; + } + +per_cpu (cpuidle_arm_dev, cpu) = dev; } -return cpuidle_register (drv,NULL ); +return 0 ; }device_initcall (arm_idle_init); --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 1/11 ARM: cpuidle: Register per cpuidle device
On Mon, Mar 09, 2015 at 03:40:06PM -0600, Lina Iyer wrote:
<snip>
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
for_each_possible_cpu(cpu) { + ret = arm_cpuidle_init(cpu);drivers/cpuidle/cpuidle-arm.c +6
-0+/* +* This cpu does not support any idle states +*/ +if (ret == -ENOSYS ) +continue ; +Quoted 9 lines
Review
Quoted 6 lines
if (ret) { pr_err("CPU %d failed to init idle CPU ops\n", cpu); return ret; }(quoted diff) +2
-0+ + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
devm_kzalloc? Otherwise, failures could lead to lost memory.
Quoted 2 lines
I dont have a local device to work with for allocation. May be I can get the cpu device node and the device therefore for allocation. Thoughts?
Ah, well the cpu device node could be used. My only concern is that dev cannot be referenced after the cpu is removed.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/cpuidle/cpuidle-arm.c +8
-0+if (!dev) +return -ENOMEM ; + + dev->cpu = cpu; + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("Failed to register cpuidle device for CPU %d\n" , + cpu);
<snip>
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 1/11 ARM: cpuidle: Register per cpuidle device
In reply to Lina Iyerdrivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 112
Quoted 5 lines · Lina Iyer
drivers/cpuidle/cpuidle-arm.c +1
-0@@ -105,18 +109,46 @@ static int __init arm_idle_init(void)if (ret <=0 )return ret ? : -ENODEV ; +
A bit better formatting would be nice - you don't need the extra blank line here.
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 124
Quoted 12 lines
drivers/cpuidle/cpuidle-arm.c +7
-0+ ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("Failed to register cpuidle driver\n" ); +return ret; + } +/* * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ for_each_possible_cpu (cpu) { +
This blank line is not necessary either.
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 125
Quoted 1 line
drivers/cpuidle/cpuidle-arm.c +0
-0ret =arm_cpuidle_init (cpu);
However, a blank line here would be a good thing.
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 128
Quoted 3 lines
drivers/cpuidle/cpuidle-arm.c +3
-0+/* +* This cpu does not support any idle states +*/
Also, formatting this as /* This cpu does not support any idle states */ is acceptable too, and doesn't waste as many lines.
Quoted 8 lines
drivers/cpuidle/cpuidle-arm.c +4
-0+if (ret == -ENOSYS ) +continue ; +if (ret) {pr_err ("CPU %d failed to init idle CPU ops\n" , cpu);return ret; } +
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 146
Quoted 10 lines
drivers/cpuidle/cpuidle-arm.c +10
-0+ dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (!dev) +return -ENOMEM ; + + dev->cpu = cpu; + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("Failed to register cpuidle device for CPU %d\n" , + cpu); +return ret;
It looks like we leak the 'dev' allocation here.
Also, other error paths, it looks like we leave the previously registered cpuidle devices in place. That may be acceptable if the intention is to initialise as many CPUs as possible - but we then miss the cpuidle_register() call below, which seems to make the registered devices useless. It's a little inconsistent.
Also, it's useful to report why something fails - printing the error code can help debugging if it isn't already printed elsewhere.
Quoted 9 lines
drivers/cpuidle/cpuidle-arm.c +4
-1+ } + +per_cpu (cpuidle_arm_dev, cpu) = dev; } -return cpuidle_register (drv,NULL ); +return 0 ; }device_initcall (arm_idle_init);
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
RFC PATCH v15 1/11 ARM: cpuidle: Register per cpuidle device
Quoted 25 lines · Russell King - ARM Linux
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 112
Quoted 5 lines · Lina Iyer
drivers/cpuidle/cpuidle-arm.c +1
-0@@ -105,18 +109,46 @@ static int __init arm_idle_init(void)if (ret <=0 )return ret ? : -ENODEV ; +A bit better formatting would be nice - you don't need the extra blank line here.
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 124
Quoted 12 lines
drivers/cpuidle/cpuidle-arm.c +7
-0+ ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("Failed to register cpuidle driver\n" ); +return ret; + } +/* * Call arch CPU operations in order to initialize * idle states suspend back-end specific data */ for_each_possible_cpu (cpu) { +This blank line is not necessary either.
Quoted 4 lines
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 125
Quoted 1 line
drivers/cpuidle/cpuidle-arm.c +0
-0ret =arm_cpuidle_init (cpu);However, a blank line here would be a good thing.
Sure.
Quoted 7 lines
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 128
Quoted 3 lines
drivers/cpuidle/cpuidle-arm.c +3
-0+/* +* This cpu does not support any idle states +*/ Also, formatting this as /* This cpu does not support any idle states */ is acceptable too, and doesn't waste as many lines.
Will fix.
Quoted 12 lines
Quoted 12 lines
drivers/cpuidle/cpuidle-arm.c +8
-0+if (ret == -ENOSYS ) +continue ; +if (ret) {pr_err ("CPU %d failed to init idle CPU ops\n" , cpu);return ret; } + + dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (!dev) +return -ENOMEM ; +
Quoted 9 lines
drivers/cpuidle/cpuidle-arm.c static int __init arm_idle_init(void) · line 146
Quoted 6 lines
drivers/cpuidle/cpuidle-arm.c +6
-0+ dev->cpu = cpu; + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("Failed to register cpuidle device for CPU %d\n" , + cpu); +return ret;It looks like we leak the 'dev' allocation here.
True, I will amend that.
Quoted 9 lines
Also, other error paths, it looks like we leave the previously registered cpuidle devices in place. That may be acceptable if the intention is to initialise as many CPUs as possible - but we then miss the
cpuidle_register()call below, which seems to make the registered devices useless. It's a little inconsistent.Also, it's useful to report why something fails - printing the error code can help debugging if it isn't already printed elsewhere.
Fair point.
Quoted 13 lines
Quoted 9 lines
drivers/cpuidle/cpuidle-arm.c +4
-1+ } + +per_cpu (cpuidle_arm_dev, cpu) = dev; } -return cpuidle_register (drv,NULL ); +return 0 ; }device_initcall (arm_idle_init);Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
RFC PATCH v15 2/11 ARM: qcom: Add Subsystem Power Manager (SPM) driver
In reply to Lina IyerSPM is a hardware block that controls the peripheral logic surrounding the application cores (cpu/l$). When the core executes WFI instruction, the SPM takes over the putting the core in low power state as configured. The wake up for the SPM is an interrupt at the GIC, which then completes the rest of low power mode sequence and brings the core out of low power mode.
The SPM has a set of control registers that configure the SPMs individually based on the type of the core and the runtime conditions. SPM is a finite state machine block to which a sequence is provided and it interprets the bytes and executes them in sequence. Each low power mode that the core can enter into is provided to the SPM as a sequence.
Configure the SPM to set the core (cpu or L2) into its low power mode, the index of the first command in the sequence is set in the SPM_CTL register. When the core executes ARM wfi instruction, it triggers the SPM state machine to start executing from that index. The SPM state machine waits until the interrupt occurs and starts executing the rest of the sequence until it hits the end of the sequence. The end of the sequence jumps the core out of its low power mode.
Add support for an idle driver to set up the SPM to place the core in Standby or Standalone power collapse mode when the core is idle.
Based on work by: Mahesh Sivasubramanian <[email protected]>, Ai Li <[email protected]>, Praveen Chidambaram <[email protected]> Original tree available at -git://codeaurora.org/quic/la/kernel/msm-3.10.git
--- .../devicetree/bindings/arm/msm/qcom,saw2.txt | 31 +- drivers/soc/qcom/Kconfig | 7 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/spm.c | 422 +++++++++++++++++++++ 4 files changed, 455 insertions(+), 6 deletions(-) create mode 100644 drivers/soc/qcom/spm.c
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +25 -6
@@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2) The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable -micro-controller that transitions a piece of hardware (like a processor or +power-controller that transitions a piece of hardware (like a processor or subsystem) into and out of low power modes via a direct connection to the PMIC. It can also be wired up to interact with other processors in the system, notifying them when a low power state is entered or exited. +Multiple revisions of the SAW hardware are supported using these Device Nodes. +SAW2 revisions differ in the register offset and configuration data. Also, the +same revision of the SAW in different SoCs may have different configuration +data due the the differences in hardware capabilities. Hence the SoC name, the +version of the SAW hardware in that SoC and the distinction between cpu (big +or Little) or cache, may be needed to uniquely identify the SAW register +configuration and initialization data. The compatible string is used to +indicate this parameter. + PROPERTIES - compatible:
@@ -14,10 +23,13 @@ PROPERTIES Value type: <string> Definition: shall contain "qcom,saw2". A more specific value should be one of: - "qcom,saw2-v1" - "qcom,saw2-v1.1" - "qcom,saw2-v2" - "qcom,saw2-v2.1" + "qcom,saw2-v1" + "qcom,saw2-v1.1" + "qcom,saw2-v2" + "qcom,saw2-v2.1" + "qcom,apq8064-saw2-v1.1-cpu" + "qcom,msm8974-saw2-v2.1-cpu" + "qcom,apq8084-saw2-v2.1-cpu" - reg: Usage: required
@@ -26,10 +38,17 @@ PROPERTIES the register region. An optional second element specifies the base address and size of the alias register region. +- regulator: + Usage: optional + Value type: boolean + Definition: Indicates that this SPM device acts as a regulator device + device for the core (CPU or Cache) the SPM is attached + to. Example: - regulator at 2099000 { + power-controller at 2099000 { compatible = "qcom,saw2"; reg = <0x02099000 0x1000>, <0x02009000 0x1000>; + regulator; };
drivers/soc/qcom/Kconfig +7 -0
@@ -9,3 +9,10 @@ config QCOM_GSBI functions for connecting the underlying serial UART, SPI, and I2C devices to the output pins. +config QCOM_PM + bool "Qualcomm Power Management" + depends on ARCH_QCOM + help + QCOM Platform specific power driver to manage cores and L2 low power + modes. It interface with various system drivers to put the cores in + low power modes.
drivers/soc/qcom/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o +obj-$(CONFIG_QCOM_PM) += spm.o
drivers/soc/qcom/spm.c new file +422 -0
422 lines not on this page · raw message
Signature · 1 line
2.1.0
RFC PATCH v15 2/11 ARM: qcom: Add Subsystem Power Manager (SPM) driver
Quoted 74 lines · Lina Iyer
SPM is a hardware block that controls the peripheral logic surrounding the application cores (cpu/l$). When the core executes WFI instruction, the SPM takes over the putting the core in low power state as configured. The wake up for the SPM is an interrupt at the GIC, which then completes the rest of low power mode sequence and brings the core out of low power mode.
The SPM has a set of control registers that configure the SPMs individually based on the type of the core and the runtime conditions. SPM is a finite state machine block to which a sequence is provided and it interprets the bytes and executes them in sequence. Each low power mode that the core can enter into is provided to the SPM as a sequence.
Configure the SPM to set the core (cpu or L2) into its low power mode, the index of the first command in the sequence is set in the
SPM_CTLregister. When the core executes ARM wfi instruction, it triggers the SPM state machine to start executing from that index. The SPM state machine waits until the interrupt occurs and starts executing the rest of the sequence until it hits the end of the sequence. The end of the sequence jumps the core out of its low power mode.Add support for an idle driver to set up the SPM to place the core in Standby or Standalone power collapse mode when the core is idle.
Based on work by: Mahesh Sivasubramanian <[email protected]>, Ai Li <[email protected]>, Praveen Chidambaram <[email protected]> Original tree available at -
git://codeaurora.org/quic/la/kernel/msm-3.10.gitCc Stephen Boyd <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kevin Hilman <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Lina Iyer <[email protected]>---
.../devicetree/bindings/arm/msm/qcom,saw2.txt | 31 +- drivers/soc/qcom/Kconfig | 7 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/spm.c | 422 +++++++++++++++++++++ 4 files changed, 455 insertions(+), 6 deletions(-)create mode 100644
drivers/soc/qcom/spm.cDocumentation/devicetree/bindings/arm/msm/qcom,saw2.txt +0
-0@@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +1
-1-micro-controller that transitions a piece of hardware (like a processor or +power-controller that transitions a piece of hardware (like a processor orsubsystem) into and out of low power modes via a direct connection to the PMIC. It can also be wired up to interact with other processors in the system, notifying them when a low power state is entered or exited.
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +9
-0+Multiple revisions of the SAW hardware are supported using these Device Nodes. +SAW2 revisions differ in the register offset and configuration data. Also, the +same revision of the SAW in different SoCs may have different configuration +data due the the differences in hardware capabilities. Hence the SoC name, the +version of the SAW hardware in that SoC and the distinction between cpu (big +or Little) or cache, may be needed to uniquely identify the SAW register +configuration and initialization data. The compatible string is used to +indicate this parameter. +PROPERTIES
- compatible:
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +0
-2@@ -14,10 +23,13 @@ PROPERTIES Value type: <string> Definition: shall contain "qcom,saw2". A more specific value should be one of: - "qcom,saw2-v1" - "qcom,saw2-v1.1"
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt PROPERTIES · line 33
Quoted 10 lines
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +7
-2- "qcom,saw2-v2" - "qcom,saw2-v2.1" + "qcom,saw2-v1" + "qcom,saw2-v1.1" + "qcom,saw2-v2" + "qcom,saw2-v2.1" + "qcom,apq8064-saw2-v1.1-cpu" + "qcom,msm8974-saw2-v2.1-cpu" + "qcom,apq8084-saw2-v2.1-cpu?
We don?t seem to use the "qcom,saw2-v1*? variants so should we just drop them?
Quoted 20 lines
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +6
-1- reg: Usage: required@@ -26,10 +38,17 @@ PROPERTIES the register region. An optional second element specifies the base address and size of the alias register region. +- regulator: + Usage: optional + Value type: boolean + Definition: Indicates that this SPM device acts as a regulator device + device for the core (CPU or Cache) the SPM is attached + to.Example:
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +1
-1- regulator at 2099000 { + power-controller at 2099000 {compatible = "qcom,saw2"; reg = <0x02099000 0x1000>, <0x02009000 0x1000>;Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +1
-0+ regulator;
Quoted 1 line
};
- k
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 2/11 ARM: qcom: Add Subsystem Power Manager (SPM) driver
Quoted 81 lines · Kumar Gala
Quoted 78 lines · Lina Iyer
SPM is a hardware block that controls the peripheral logic surrounding the application cores (cpu/l$). When the core executes WFI instruction, the SPM takes over the putting the core in low power state as configured. The wake up for the SPM is an interrupt at the GIC, which then completes the rest of low power mode sequence and brings the core out of low power mode.
The SPM has a set of control registers that configure the SPMs individually based on the type of the core and the runtime conditions. SPM is a finite state machine block to which a sequence is provided and it interprets the bytes and executes them in sequence. Each low power mode that the core can enter into is provided to the SPM as a sequence.
Configure the SPM to set the core (cpu or L2) into its low power mode, the index of the first command in the sequence is set in the
SPM_CTLregister. When the core executes ARM wfi instruction, it triggers the SPM state machine to start executing from that index. The SPM state machine waits until the interrupt occurs and starts executing the rest of the sequence until it hits the end of the sequence. The end of the sequence jumps the core out of its low power mode.Add support for an idle driver to set up the SPM to place the core in Standby or Standalone power collapse mode when the core is idle.
Based on work by: Mahesh Sivasubramanian <[email protected]>, Ai Li <[email protected]>, Praveen Chidambaram <[email protected]> Original tree available at -
git://codeaurora.org/quic/la/kernel/msm-3.10.gitCc Stephen Boyd <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kevin Hilman <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Lina Iyer <[email protected]>---
.../devicetree/bindings/arm/msm/qcom,saw2.txt | 31 +- drivers/soc/qcom/Kconfig | 7 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/spm.c | 422 +++++++++++++++++++++ 4 files changed, 455 insertions(+), 6 deletions(-)create mode 100644
drivers/soc/qcom/spm.cDocumentation/devicetree/bindings/arm/msm/qcom,saw2.txt +0
-0@@ -2,11 +2,20 @@ SPM AVS Wrapper 2 (SAW2)The SAW2 is a wrapper around the Subsystem Power Manager (SPM) and the Adaptive Voltage Scaling (AVS) hardware. The SPM is a programmable
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +1
-1-micro-controller that transitions a piece of hardware (like a processor or +power-controller that transitions a piece of hardware (like a processor orsubsystem) into and out of low power modes via a direct connection to the PMIC. It can also be wired up to interact with other processors in the system, notifying them when a low power state is entered or exited.
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +9
-0+Multiple revisions of the SAW hardware are supported using these Device Nodes. +SAW2 revisions differ in the register offset and configuration data. Also, the +same revision of the SAW in different SoCs may have different configuration +data due the the differences in hardware capabilities. Hence the SoC name, the +version of the SAW hardware in that SoC and the distinction between cpu (big +or Little) or cache, may be needed to uniquely identify the SAW register +configuration and initialization data. The compatible string is used to +indicate this parameter. +PROPERTIES
- compatible:
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +2
-4@@ -14,10 +23,13 @@ PROPERTIES Value type: <string> Definition: shall contain "qcom,saw2". A more specific value should be one of: - "qcom,saw2-v1" - "qcom,saw2-v1.1" - "qcom,saw2-v2" - "qcom,saw2-v2.1" + "qcom,saw2-v1" + "qcom,saw2-v1.1"
Quoted 8 lines
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt PROPERTIES · line 33
Quoted 6 lines
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +5
-0+ "qcom,saw2-v2" + "qcom,saw2-v2.1" + "qcom,apq8064-saw2-v1.1-cpu" + "qcom,msm8974-saw2-v2.1-cpu" + "qcom,apq8084-saw2-v2.1-cpu?We don?t seem to use the "qcom,saw2-v1*? variants so should we just drop them?
Sure. Will fix in the next.
Quoted 31 lines
Quoted 22 lines
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +6
-1- reg: Usage: required@@ -26,10 +38,17 @@ PROPERTIES the register region. An optional second element specifies the base address and size of the alias register region. +- regulator: + Usage: optional + Value type: boolean + Definition: Indicates that this SPM device acts as a regulator device + device for the core (CPU or Cache) the SPM is attached + to.Example:
Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +1
-1- regulator at 2099000 { + power-controller at 2099000 {compatible = "qcom,saw2"; reg = <0x02099000 0x1000>, <0x02009000 0x1000>;Documentation/devicetree/bindings/arm/msm/qcom,saw2.txt +1
-0+ regulator;Quoted 1 line
};- k
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 2/11 ARM: qcom: Add Subsystem Power Manager (SPM) driver
In reply to Lina IyerOn Mon, Mar 09 2015 at 09:17 -0600, Lina Iyer wrote:
[...]
drivers/soc/qcom/spm.c line 174
Quoted 3 lines
drivers/soc/qcom/spm.c new file +3
-0+static int qcom_pm_collapse (unsigned long int unused) +{ +qcom_scm_cpu_power_down (QCOM_SCM_L2_ON );
Rebase against latest SCM patches. Change to QCOM_SCM_CPU_PWR_DOWN_L2_ON.
Quoted 12 lines
drivers/soc/qcom/spm.c new file +12
-0+ +/* +* Returns here only if there was a pending interrupt and we did not +* power down as a result. +*/ +return -1 ; +} + +static int qcom_cpu_standby (int cpuarg) +{ +spm_set_low_power_mode (PM_SLEEP_MODE_STBY ); +cpu_do_idle ();
drivers/soc/qcom/spm.c line 196
Quoted 10 lines
drivers/soc/qcom/spm.c new file +10
-0+ +return 0 ; +} + +static int qcom_cpu_spc (int cpu) +{ +int ret; + +spm_set_low_power_mode (PM_SLEEP_MODE_SPC ); +cpu_pm_enter ();
Remove this. This is now done by cpuidle driver.
drivers/soc/qcom/spm.c line 208
Quoted 12 lines
drivers/soc/qcom/spm.c new file +12
-0+ ret =cpu_suspend (0 , qcom_pm_collapse); +/* +* ARM common code may execute WFI, and if the SPM mode is not reset, +* then we may accidently do power down state. +* SPM is configured to reset to do STBY, but that relies on the +* SPM state machine to be executed. When an interrupt is pending as we +* enter idle state, SPM would not execute its state machine, so the +* SPM may remain configured to do power down state. +* Reset the state back to standby. +*/ +spm_set_low_power_mode (PM_SLEEP_MODE_STBY ); +cpu_pm_exit ();
And this..
RFC PATCH v15 2/11 ARM: qcom: Add Subsystem Power Manager (SPM) driver
In reply to Lina Iyerdrivers/soc/qcom/spm.c line 216
Quoted 5 lines · Lina Iyer
drivers/soc/qcom/spm.c new file +5
-0+ +static int qcom_idle_enter (int cpu,unsigned long index) +{ +if (!per_cpu (qcom_idle_ops, cpu)[index]) +return -EOPNOTSUPP ;
Is this case still happening?
drivers/soc/qcom/spm.c line 221
Quoted 5 lines
drivers/soc/qcom/spm.c new file +5
-0+ +return per_cpu (qcom_idle_ops, cpu)[index](cpu); +} + +const struct of_device_id qcom_idle_state_match[]__initconst = {
static?
Quoted 35 lines
drivers/soc/qcom/spm.c new file +35
-0+ { .compatible = "qcom,idle-state-stby", .data = qcom_cpu_standby }, + { .compatible = "qcom,idle-state-spc", .data = qcom_cpu_spc }, + { }, +}; + +static int __init qcom_cpuidle_init (struct device_node *cpu_node,int cpu) +{ +const struct of_device_id *match_id; +struct device_node *state_node; +int i; +int state_count =0 ; +idle_fn idle_fns[CPUIDLE_STATE_MAX ]; +idle_fn *fns; +cpumask_t mask; +bool use_scm_power_down = false; + +for (i =0 ; ; i++) { + state_node =of_parse_phandle (cpu_node,"cpu-idle-states" , i); +if (!state_node) +break ; + +if (!of_device_is_available (state_node)) +continue ; + +if (i ==CPUIDLE_STATE_MAX ) { +pr_warn ("%s: cpuidle states reached max possible\n" , + __func__); +break ; + } + + match_id =of_match_node (qcom_idle_state_match, state_node); +if (!match_id) +return -ENODEV ; + + idle_fns[state_count] = match_id->data;
drivers/soc/qcom/spm.c line 266
Quoted 10 lines
drivers/soc/qcom/spm.c new file +10
-0+ +/* Check if any of the states allow power down */ +if (match_id->data == qcom_cpu_spc) + use_scm_power_down = true; + + state_count++; + } + +if (!state_count) { +pr_warn ("No idle ops founds for cpu %d\n" , cpu);
Maybe pr_debug? It's not the end of the world that we don't have cpuidle.
drivers/soc/qcom/spm.c line 278
Quoted 12 lines
drivers/soc/qcom/spm.c new file +12
-0+return -ENODEV ; + } + + fns =kcalloc (state_count,sizeof (*fns),GFP_KERNEL ); +if (!fns) +return -ENOMEM ; + +for (i =0 ; i < state_count; i++) + fns[i] = idle_fns[i]; + +if (use_scm_power_down) { +/* We have atlease one power down mode */
s/atlease/at least/
Quoted 22 lines
drivers/soc/qcom/spm.c new file +21
-0+cpumask_clear (&mask); +cpumask_set_cpu (cpu, &mask); +qcom_scm_set_warm_boot_addr (cpu_resume, &mask); + } + +per_cpu (qcom_idle_ops, cpu) = fns; + +/* +* Condition: cpuidle_driver_register() needs to happen before +* cpuidle_register_device(). +* Check if the SPM probe has happened - +* - If SPM probed successfully before arm_idle_init(), then defer +* the registration of cpuidle_device back to arm_idle_init() +* - If the SPM probe happens in the future, then let the SPM probe +* register the cpuidle device, return -ENOSYS. +*/ +return per_cpu (cpu_spm_drv, cpu) ?0 : -ENOSYS ; +} + +struct cpuidle_ops qcom_kpss_v1_cpuidle_ops__initdata = { + .name ="qcom,kpss-acc-v1" ,
drivers/soc/qcom/spm.c line 309
Quoted 10 lines
drivers/soc/qcom/spm.c new file +10
-0+ .suspend = qcom_idle_enter, + .init = qcom_cpuidle_init, +}; + +struct cpuidle_ops qcom_kpss_v2_cpuidle_ops__initdata = { + .name ="qcom,kpss-acc-v2" , + .suspend = qcom_idle_enter, + .init = qcom_cpuidle_init, +}; +
This just looks weird because of the macro magic in Daniel's series. Any reason we can't use the linker instead of doing preprocessor magic so that it looks like these structures are actually used?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 2/11 ARM: qcom: Add Subsystem Power Manager (SPM) driver
Quoted 9 lines · Stephen Boyd
drivers/soc/qcom/spm.c line 216
Quoted 5 lines · Lina Iyer
drivers/soc/qcom/spm.c new file +5
-0+ +static int qcom_idle_enter (int cpu,unsigned long index) +{ +if (!per_cpu (qcom_idle_ops, cpu)[index]) +return -EOPNOTSUPP ;Is this case still happening?
I think, I can remove it safely now.
Quoted 8 lines
drivers/soc/qcom/spm.c line 221
Quoted 5 lines
drivers/soc/qcom/spm.c new file +5
-0+ +return per_cpu (qcom_idle_ops, cpu)[index](cpu); +} + +const struct of_device_id qcom_idle_state_match[]__initconst = {static?
Ok
Quoted 39 lines
Quoted 39 lines
drivers/soc/qcom/spm.c new file +39
-0+ { .compatible = "qcom,idle-state-stby", .data = qcom_cpu_standby }, + { .compatible = "qcom,idle-state-spc", .data = qcom_cpu_spc }, + { }, +}; + +static int __init qcom_cpuidle_init (struct device_node *cpu_node,int cpu) +{ +const struct of_device_id *match_id; +struct device_node *state_node; +int i; +int state_count =0 ; +idle_fn idle_fns[CPUIDLE_STATE_MAX ]; +idle_fn *fns; +cpumask_t mask; +bool use_scm_power_down = false; + +for (i =0 ; ; i++) { + state_node =of_parse_phandle (cpu_node,"cpu-idle-states" , i); +if (!state_node) +break ; + +if (!of_device_is_available (state_node)) +continue ; + +if (i ==CPUIDLE_STATE_MAX ) { +pr_warn ("%s: cpuidle states reached max possible\n" , + __func__); +break ; + } + + match_id =of_match_node (qcom_idle_state_match, state_node); +if (!match_id) +return -ENODEV ; + + idle_fns[state_count] = match_id->data; + +/* Check if any of the states allow power down */ +if (match_id->data == qcom_cpu_spc) + use_scm_power_down = true;
Quoted 9 lines
drivers/soc/qcom/spm.c line 266
Quoted 6 lines
drivers/soc/qcom/spm.c new file +6
-0+ + state_count++; + } + +if (!state_count) { +pr_warn ("No idle ops founds for cpu %d\n" , cpu);Maybe
pr_debug? It's not the end of the world that we don't have cpuidle.
Sure.
Quoted 6 lines
Quoted 6 lines
drivers/soc/qcom/spm.c new file +6
-0+return -ENODEV ; + } + + fns =kcalloc (state_count,sizeof (*fns),GFP_KERNEL ); +if (!fns) +return -ENOMEM ;
Quoted 9 lines
drivers/soc/qcom/spm.c line 278
Quoted 6 lines
drivers/soc/qcom/spm.c new file +6
-0+ +for (i =0 ; i < state_count; i++) + fns[i] = idle_fns[i]; + +if (use_scm_power_down) { +/* We have atlease one power down mode */ s/atlease/at least/
Thanks!
Quoted 28 lines
Quoted 28 lines
drivers/soc/qcom/spm.c new file +28
-0+cpumask_clear (&mask); +cpumask_set_cpu (cpu, &mask); +qcom_scm_set_warm_boot_addr (cpu_resume, &mask); + } + +per_cpu (qcom_idle_ops, cpu) = fns; + +/* +* Condition: cpuidle_driver_register() needs to happen before +* cpuidle_register_device(). +* Check if the SPM probe has happened - +* - If SPM probed successfully before arm_idle_init(), then defer +* the registration of cpuidle_device back to arm_idle_init() +* - If the SPM probe happens in the future, then let the SPM probe +* register the cpuidle device, return -ENOSYS. +*/ +return per_cpu (cpu_spm_drv, cpu) ?0 : -ENOSYS ; +} + +struct cpuidle_ops qcom_kpss_v1_cpuidle_ops__initdata = { + .name ="qcom,kpss-acc-v1" , + .suspend = qcom_idle_enter, + .init = qcom_cpuidle_init, +}; + +struct cpuidle_ops qcom_kpss_v2_cpuidle_ops__initdata = { + .name ="qcom,kpss-acc-v2" , + .suspend = qcom_idle_enter,
Quoted 9 lines
drivers/soc/qcom/spm.c line 303
Quoted 4 lines
drivers/soc/qcom/spm.c new file +3
-0+ .init = qcom_cpuidle_init, +}; +This just looks weird because of the macro magic in Daniel's series. Any reason we can't use the linker instead of doing preprocessor magic so that it looks like these structures are actually used?
Hmm.. Will wait on Daniel's response to your other mail.
Quoted 4 lines
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v15 3/11 ARM: cpuidle: qcom: Add documentation for qcom cpuidle states.
In reply to Lina IyerAdd documentation for cpuidle states of QCOM cpus. In addition to arm-idle-state compatible string, the ARM idle state definition must define one of the following compatible strings -
"qcom,idle-state-stby", "qcom,idle-state-ret", "qcom,idle-state-spc", "qcom,idle-state-pc",
The compatibles helps the SPM platform driver to use the correct idle function when the index to the idle state is passed to the platform driver.
--- .../bindings/arm/msm/qcom,idle-state.txt | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt
Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt new file +81 -0
@@ -0,0 +1,81 @@ +QCOM Idle States for cpuidle driver + +ARM provides idle-state node to define the cpuidle states, as defined in [1]. +cpuidle-qcom is the cpuidle driver for Qualcomm SoCs and uses these idle +states. Idle states have different enter/exit latency and residency values. +The idle states supported by the QCOM SoC are defined as - + + * Standby + * Retention + * Standalone Power Collapse (Standalone PC or SPC) + * Power Collapse (PC) + +Standby: Standby does a little more in addition to architectural clock gating. +When the WFI instruction is executed the ARM core would gate its internal +clocks. In addition to gating the clocks, QCOM cpus use this instruction as a +trigger to execute the SPM state machine. The SPM state machine waits for the +interrupt to trigger the core back in to active. This triggers the cache +hierarchy to enter standby states, when all cpus are idle. An interrupt brings +the SPM state machine out of its wait, the next step is to ensure that the +cache hierarchy is also out of standby, and then the cpu is allowed to resume +execution. + +Retention: Retention is a low power state where the core is clock gated and +the memory and the registers associated with the core are retained. The +voltage may be reduced to the minimum value needed to keep the processor +registers active. The SPM should be configured to execute the retention +sequence and would wait for interrupt, before restoring the cpu to execution +state. Retention may have a slightly higher latency than Standby. + +Standalone PC: A cpu can power down and warmboot if there is a sufficient time +between the time it enters idle and the next known wake up. SPC mode is used +to indicate a core entering a power down state without consulting any other +cpu or the system resources. This helps save power only on that core. The SPM +sequence for this idle state is programmed to power down the supply to the +core, wait for the interrupt, restore power to the core, and ensure the +system state including cache hierarchy is ready before allowing core to +resume. Applying power and resetting the core causes the core to warmboot +back into Elevation Level (EL) which trampolines the control back to the +kernel. Entering a power down state for the cpu, needs to be done by trapping +into a EL. Failing to do so, would result in a crash enforced by the warm boot +code in the EL for the SoC. On SoCs with write-back L1 cache, the cache has to +be flushed in s/w, before powering down the core. + +Power Collapse: This state is similar to the SPC mode, but distinguishes +itself in that the cpu acknowledges and permits the SoC to enter deeper sleep +modes. In a hierarchical power domain SoC, this means L2 and other caches can +be flushed, system bus, clocks - lowered, and SoC main XO clock gated and +voltages reduced, provided all cpus enter this state. Since the span of low +power modes possible at this state is vast, the exit latency and the residency +of this low power mode would be considered high even though at a cpu level, +this essentially is cpu power down. The SPM in this state also may handshake +with the Resource power manager processor in the SoC to indicate a complete +application processor subsystem shut down. + +The idle-state for QCOM SoCs are distinguished by the compatible property of +the idle-states device node. +The devicetree representation of the idle state should be - + +Required properties: + +- compatible: Must be one of - + "qcom,idle-state-stby", + "qcom,idle-state-ret", + "qcom,idle-state-spc", + "qcom,idle-state-pc", + and "arm,idle-state". + +Other required and optional properties are specified in [1]. + +Example: + + idle-states { + CPU_SPC: spc { + compatible = "qcom,idle-state-spc", "arm,idle-state"; + entry-latency-us = <150>; + exit-latency-us = <200>; + min-residency-us = <2000>; + }; + }; + +[1]. Documentation/devicetree/bindings/arm/idle-states.txt
Signature · 1 line
2.1.0
RFC PATCH v15 4/11 ARM: cpuidle: Register cpuidle_ops for QCOM cpus
In reply to Lina IyerRegister cpuidle ops for Krait Processor Sub-System. Supports v1 and v2 versions of KPSS.
--- arch/arm/include/asm/cpuidle_ops.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/include/asm/cpuidle_ops.h +5 -0
@@ -1,3 +1,8 @@/* * List of cpuidle operations */ + +#if IS_ENABLED (CONFIG_QCOM_PM ) +CPUIDLE_OPS(qcom_kpss_v1) +CPUIDLE_OPS(qcom_kpss_v2) +#endif
Signature · 1 line
2.1.0
RFC PATCH v15 4/11 ARM: cpuidle: Register cpuidle_ops for QCOM cpus
Quoted 17 lines · Lina Iyer
Register cpuidle ops for Krait Processor Sub-System. Supports v1 and v2 versions of KPSS.
Cc Stephen Boyd <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kevin Hilman <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Lina Iyer <[email protected]>--- arch/arm/include/asm/cpuidle_ops.h | 5 +++++ 1 file changed, 5 insertions(+)arch/arm/include/asm/cpuidle_ops.h +0
-0
arch/arm/include/asm/cpuidle_ops.h line 5
Quoted 5 lines
arch/arm/include/asm/cpuidle_ops.h +2
-0@@ -1,3 +1,8 @@/* * List of cpuidle operations */ + +#if IS_ENABLED (CONFIG_QCOM_PM )
Why not #ifdef CONFIG_QCOM_PM? I thought IS_ENABLED was for C code where you want to put it in an if () statement.
Quoted 3 lines
arch/arm/include/asm/cpuidle_ops.h +3
-0+CPUIDLE_OPS(qcom_kpss_v1) +CPUIDLE_OPS(qcom_kpss_v2) +#endif
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH v15 4/11 ARM: cpuidle: Register cpuidle_ops for QCOM cpus
Quoted 13 lines · Stephen Boyd
Quoted 12 lines · Lina Iyer
Register cpuidle ops for Krait Processor Sub-System. Supports v1 and v2 versions of KPSS.
Cc Stephen Boyd <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Kevin Hilman <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Lina Iyer <[email protected]>--- arch/arm/include/asm/cpuidle_ops.h | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 13 lines
arch/arm/include/asm/cpuidle_ops.h line 5
Quoted 10 lines
arch/arm/include/asm/cpuidle_ops.h +2
-0@@ -1,3 +1,8 @@/* * List of cpuidle operations */ + +#if IS_ENABLED (CONFIG_QCOM_PM )Why not #ifdef
CONFIG_QCOM_PM? I thoughtIS_ENABLEDwas for C code where you want to put it in an if () statement.
This is right. But the IS_ENABLED is also valid.
It seems the current trend is to replace #ifdef with #if IS_ENABLED. It is supposed to prevent to create or'ed conditional with the module support.
eg:
#if defined(CONFIG_FOO) || defined(CONFIG_FOO_MODULE)
is replaced by:
#if IS_ENABLED(CONFIG_FOO)
Lina: By the way, it would be preferable to use the CONFIG_ARM_QCOM_CPUIDLE where IS_ENABLED makes more sense even the drivers are not modules (who knows if they are converted as module again hence #ifdef will be invalid).
Quoted 5 lines
Quoted 3 lines
arch/arm/include/asm/cpuidle_ops.h +3
-0+CPUIDLE_OPS(qcom_kpss_v1) +CPUIDLE_OPS(qcom_kpss_v2) +#endif
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
RFC PATCH v15 4/11 ARM: cpuidle: Register cpuidle_ops for QCOM cpus
Quoted 2 lines · Daniel Lezcano
Quoted 1 line · Stephen Boyd
On 03/09/15 08:16, Lina Iyer wrote:
[...]
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
+#if
IS_ENABLED(CONFIG_QCOM_PM)Why not #ifdef
CONFIG_QCOM_PM? I thoughtIS_ENABLEDwas for C code where you want to put it in an if () statement.This is right. But the
IS_ENABLEDis also valid.It seems the current trend is to replace #ifdef with #if
IS_ENABLED. It is supposed to prevent to create or'ed conditional with the module support.eg:
Quoted 8 lines
#if
defined(CONFIG_FOO)||defined(CONFIG_FOO_MODULE)is replaced by:
#if
IS_ENABLED(CONFIG_FOO)Lina: By the way, it would be preferable to use the
CONFIG_ARM_QCOM_CPUIDLEwhereIS_ENABLEDmakes more sense even the
Daniel: I dont have CONFIG_ARM_QCOM_CPUIDLE defined anymore. By moving to generic ARM cpuidle, i removed all changes to drivers/cpuidle/. So I used the config item that defineds these items.
Also, having two indpendent CONFIG_ items provides a chance that the declaration is not matched with the definition or vice versa.
Quoted 8 lines
drivers are not modules (who knows if they are converted as module again hence #ifdef will be invalid).
Quoted 3 lines
Quoted 3 lines
arch/arm/include/asm/cpuidle_ops.h +3
-0+CPUIDLE_OPS(qcom_kpss_v1) +CPUIDLE_OPS(qcom_kpss_v2) +#endif
RFC PATCH v15 4/11 ARM: cpuidle: Register cpuidle_ops for QCOM cpus
Quoted 28 lines · Lina Iyer
Quoted 2 lines · Daniel Lezcano
Quoted 1 line · Stephen Boyd
On 03/09/15 08:16, Lina Iyer wrote:
[...]
Quoted 13 lines
Quoted 4 lines
Quoted 1 line
+#if
IS_ENABLED(CONFIG_QCOM_PM)Why not #ifdef
CONFIG_QCOM_PM? I thoughtIS_ENABLEDwas for C code where you want to put it in an if () statement.This is right. But the
IS_ENABLEDis also valid.It seems the current trend is to replace #ifdef with #if
IS_ENABLED. It is supposed to prevent to create or'ed conditional with the module support.eg:
Quoted 8 lines
#if
defined(CONFIG_FOO)||defined(CONFIG_FOO_MODULE)is replaced by:
#if
IS_ENABLED(CONFIG_FOO)Lina: By the way, it would be preferable to use the
CONFIG_ARM_QCOM_CPUIDLEwhereIS_ENABLEDmakes more sense even the
Quoted 6 lines
Daniel: I dont have
CONFIG_ARM_QCOM_CPUIDLEdefined anymore. By moving to generic ARM cpuidle, i removed all changes todrivers/cpuidle/. So I used the config item that defineds these items.Also, having two indpendent
CONFIG_items provides a chance that the declaration is not matched with the definition or vice versa.
I think CONFIG_ARM_QCOM_CPUIDLE should be defined as a bool in the Kconfig.arm in drivers/cpuidle.
We may want to disable the different cpuidle drivers even if they rely on the generic cpuidle driver.
Quoted 9 lines
Quoted 8 lines
drivers are not modules (who knows if they are converted as module again hence #ifdef will be invalid).
Quoted 3 lines
Quoted 3 lines
arch/arm/include/asm/cpuidle_ops.h +3
-0+CPUIDLE_OPS(qcom_kpss_v1) +CPUIDLE_OPS(qcom_kpss_v2) +#endif
Signature · 5 lines
<http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH v15 5/11 ARM: dts: qcom: Add power-controller device node for 8074 Krait CPUs
In reply to Lina IyerEach Krait CPU in the QCOM 8074/8974 SoC has an SAW power controller to regulate the power to the cpu and aide the core in entering idle states. Reference the SAW instance and associate the instance with the CPU core.
--- arch/arm/boot/dts/qcom-msm8974.dtsi | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
arch/arm/boot/dts/qcom-msm8974.dtsi +25 -1
@@ -21,6 +21,7 @@ reg = <0>; next-level-cache = <&L2>; qcom,acc = <&acc0>; + qcom,saw = <&saw0>; }; cpu at 1 {
@@ -30,6 +31,7 @@ reg = <1>; next-level-cache = <&L2>; qcom,acc = <&acc1>; + qcom,saw = <&saw1>; }; cpu at 2 {
@@ -39,6 +41,7 @@ reg = <2>; next-level-cache = <&L2>; qcom,acc = <&acc2>; + qcom,saw = <&saw2>; }; cpu at 3 {
@@ -48,6 +51,7 @@ reg = <3>; next-level-cache = <&L2>; qcom,acc = <&acc3>; + qcom,saw = <&saw3>; }; L2: l2-cache {
@@ -144,7 +148,27 @@ }; }; - saw_l2: regulator at f9012000 { + saw0: power-controller at f9089000 { + compatible = "qcom,msm8974-saw2-v2.1-cpu"; + reg = <0xf9089000 0x1000>, <0xf9009000 0x1000>; + }; + + saw1: power-controller at f9099000 { + compatible = "qcom,msm8974-saw2-v2.1-cpu"; + reg = <0xf9099000 0x1000>, <0xf9009000 0x1000>; + }; + + saw2: power-controller at f90a9000 { + compatible = "qcom,msm8974-saw2-v2.1-cpu"; + reg = <0xf90a9000 0x1000>, <0xf9009000 0x1000>; + }; + + saw3: power-controller at f90b9000 { + compatible = "qcom,msm8974-saw2-v2.1-cpu"; + reg = <0xf90b9000 0x1000>, <0xf9009000 0x1000>; + }; + + saw_l2: power-controller at f9012000 { compatible = "qcom,saw2"; reg = <0xf9012000 0x1000>; regulator;
Signature · 1 line
2.1.0
PATCH v15 6/11 ARM: dts: qcom: Add power-controller device node for 8084 Krait CPUs
In reply to Lina IyerEach Krait CPU in the QCOM 8084 SoC has an SAW power controller to regulate the power to the cpu and aide the core in entering idle states. Reference the SAW instance and associate the instance with the CPU core.
--- arch/arm/boot/dts/qcom-apq8084.dtsi | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
arch/arm/boot/dts/qcom-apq8084.dtsi +25 -1
@@ -21,6 +21,7 @@ enable-method = "qcom,kpss-acc-v2"; next-level-cache = <&L2>; qcom,acc = <&acc0>; + qcom,saw = <&saw0>; }; cpu at 1 {
@@ -30,6 +31,7 @@ enable-method = "qcom,kpss-acc-v2"; next-level-cache = <&L2>; qcom,acc = <&acc1>; + qcom,saw = <&saw1>; }; cpu at 2 {
@@ -39,6 +41,7 @@ enable-method = "qcom,kpss-acc-v2"; next-level-cache = <&L2>; qcom,acc = <&acc2>; + qcom,saw = <&saw2>; }; cpu at 3 {
@@ -48,6 +51,7 @@ enable-method = "qcom,kpss-acc-v2"; next-level-cache = <&L2>; qcom,acc = <&acc3>; + qcom,saw = <&saw3>; }; L2: l2-cache {
@@ -144,7 +148,27 @@ }; }; - saw_l2: regulator at f9012000 { + saw0: power-controller at f9089000 { + compatible = "qcom,apq8084-saw2-v2.1-cpu"; + reg = <0xf9089000 0x1000>, <0xf9009000 0x1000>; + }; + + saw1: power-controller at f9099000 { + compatible = "qcom,apq8084-saw2-v2.1-cpu"; + reg = <0xf9099000 0x1000>, <0xf9009000 0x1000>; + }; + + saw2: power-controller at f90a9000 { + compatible = "qcom,apq8084-saw2-v2.1-cpu"; + reg = <0xf90a9000 0x1000>, <0xf9009000 0x1000>; + }; + + saw3: power-controller at f90b9000 { + compatible = "qcom,apq8084-saw2-v2.1-cpu"; + reg = <0xf90b9000 0x1000>, <0xf9009000 0x1000>; + }; + + saw_l2: power-controller at f9012000 { compatible = "qcom,saw2"; reg = <0xf9012000 0x1000>; regulator;
Signature · 1 line
2.1.0
PATCH v15 7/11 ARM: dts: qcom: Update power-controller device node for 8064 Krait CPUs
In reply to Lina IyerUpdate the SAW2 DT bindings to add qcom,apq8064-saw2-v1.1-cpu compatible binding string to configure SPM registers and allow the SPM to put the core in deeper idle states when the core is idle.
--- arch/arm/boot/dts/qcom-apq8064.dtsi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/arm/boot/dts/qcom-apq8064.dtsi +8 -8
@@ -139,26 +139,26 @@ reg = <0x020b8000 0x1000>, <0x02008000 0x1000>; }; - saw0: regulator at 2089000 { - compatible = "qcom,saw2"; + saw0: power-controller at 2089000 { + compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2"; reg = <0x02089000 0x1000>, <0x02009000 0x1000>; regulator; }; - saw1: regulator at 2099000 { - compatible = "qcom,saw2"; + saw1: power-controller at 2099000 { + compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2"; reg = <0x02099000 0x1000>, <0x02009000 0x1000>; regulator; }; - saw2: regulator at 20a9000 { - compatible = "qcom,saw2"; + saw2: power-controller at 20a9000 { + compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2"; reg = <0x020a9000 0x1000>, <0x02009000 0x1000>; regulator; }; - saw3: regulator at 20b9000 { - compatible = "qcom,saw2"; + saw3: power-controller at 20b9000 { + compatible = "qcom,apq8064-saw2-v1.1-cpu", "qcom,saw2"; reg = <0x020b9000 0x1000>, <0x02009000 0x1000>; regulator; };
Signature · 1 line
2.1.0
PATCH v15 8/11 ARM: dts: qcom: Add idle states device nodes for 8074
In reply to Lina IyerAdd ARM common idle states device bindings for cpuidle support for APQ 8074/8974.
Support Standby and Standalone power collapse (power down that does not affect any SoC idle states) for each cpu.
--- arch/arm/boot/dts/qcom-msm8974.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm/boot/dts/qcom-msm8974.dtsi +22 -0
@@ -22,6 +22,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc0>; qcom,saw = <&saw0>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 1 {
@@ -32,6 +33,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc1>; qcom,saw = <&saw1>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 2 {
@@ -42,6 +44,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc2>; qcom,saw = <&saw2>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 3 {
@@ -52,6 +55,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc3>; qcom,saw = <&saw3>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; L2: l2-cache {
@@ -59,6 +63,24 @@ cache-level = <2>; qcom,saw = <&saw_l2>; }; + + idle-states { + CPU_STBY: standby { + compatible = "qcom,idle-state-stby", + "arm,idle-state"; + entry-latency-us = <1>; + exit-latency-us = <1>; + min-residency-us = <2>; + }; + + CPU_SPC: spc { + compatible = "qcom,idle-state-spc", + "arm,idle-state"; + entry-latency-us = <150>; + exit-latency-us = <200>; + min-residency-us = <2000>; + }; + }; }; cpu-pmu {
Signature · 1 line
2.1.0
PATCH v15 9/11 ARM: dts: qcom: Add idle states device nodes for 8084
In reply to Lina IyerAdd ARM common idle states device bindings for cpuidle support for APQ 8084.
Support standby and standalone power collapse (power down that does not affect any SoC idle states) for each cpu.
--- arch/arm/boot/dts/qcom-apq8084.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm/boot/dts/qcom-apq8084.dtsi +22 -0
@@ -22,6 +22,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc0>; qcom,saw = <&saw0>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 1 {
@@ -32,6 +33,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc1>; qcom,saw = <&saw1>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 2 {
@@ -42,6 +44,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc2>; qcom,saw = <&saw2>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 3 {
@@ -52,6 +55,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc3>; qcom,saw = <&saw3>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; L2: l2-cache {
@@ -59,6 +63,24 @@ cache-level = <2>; qcom,saw = <&saw_l2>; }; + + idle-states { + CPU_STBY: standby { + compatible = "qcom,idle-state-stby", + "arm,idle-state"; + entry-latency-us = <1>; + exit-latency-us = <1>; + min-residency-us = <2>; + }; + + CPU_SPC: spc { + compatible = "qcom,idle-state-spc", + "arm,idle-state"; + entry-latency-us = <150>; + exit-latency-us = <200>; + min-residency-us = <2000>; + }; + }; }; cpu-pmu {
Signature · 1 line
2.1.0
PATCH v15 10/11 ARM: dts: qcom: Add idle state device nodes for 8064
In reply to Lina IyerAdd ARM common idle state device bindings for cpuidle support for APQ 8064.
Support Standby and Standalone power collapse (power down that does not affect any SoC idle states) for each cpu.
--- arch/arm/boot/dts/qcom-apq8064.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm/boot/dts/qcom-apq8064.dtsi +22 -0
@@ -23,6 +23,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc0>; qcom,saw = <&saw0>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 1 {
@@ -33,6 +34,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc1>; qcom,saw = <&saw1>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 2 {
@@ -43,6 +45,7 @@ next-level-cache = <&L2>; qcom,acc = <&acc2>; qcom,saw = <&saw2>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; cpu at 3 {
@@ -53,12 +56,31 @@ next-level-cache = <&L2>; qcom,acc = <&acc3>; qcom,saw = <&saw3>; + cpu-idle-states = <&CPU_STBY &CPU_SPC>; }; L2: l2-cache { compatible = "cache"; cache-level = <2>; }; + + idle-states { + CPU_STBY: standby { + compatible = "qcom,idle-state-stby", + "arm,idle-state"; + entry-latency-us = <1>; + exit-latency-us = <1>; + min-residency-us = <2>; + }; + + CPU_SPC: spc { + compatible = "qcom,idle-state-spc", + "arm,idle-state"; + entry-latency-us = <400>; + exit-latency-us = <900>; + min-residency-us = <3000>; + }; + }; }; cpu-pmu {
Signature · 1 line
2.1.0
PATCH v15 11/11 ARM: qcom: Update defconfig
In reply to Lina Iyer* Enable QCOM_PM
* Enable ARM_CPUIDLE
--- arch/arm/configs/qcom_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/qcom_defconfig +2 -0
@@ -30,6 +30,7 @@ CONFIG_CLEANCACHE=y CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_CPU_IDLE=y +CONFIG_ARM_CPUIDLE=y CONFIG_VFP=y CONFIG_NEON=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
@@ -135,6 +136,7 @@ CONFIG_DMADEVICES=y CONFIG_QCOM_BAM_DMA=y CONFIG_STAGING=y CONFIG_QCOM_GSBI=y +CONFIG_QCOM_PM=y CONFIG_COMMON_CLK_QCOM=y CONFIG_APQ_MMCC_8084=y CONFIG_IPQ_GCC_806X=y
Signature · 1 line
2.1.0