From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lina Iyer Subject: Re: [PATCH v7 8/8] drivers: cpuidle: initialize Exynos driver through DT Date: Fri, 15 Aug 2014 15:12:33 -0600 Message-ID: <20140815211233.GA46224@ilina-mac.local> References: <1407945127-27554-1-git-send-email-lorenzo.pieralisi@arm.com> <1407945127-27554-9-git-send-email-lorenzo.pieralisi@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1407945127-27554-9-git-send-email-lorenzo.pieralisi@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Lorenzo Pieralisi Cc: Mark Rutland , Catalin Marinas , Tomasz Figa , Chander Kashyap , Kukjin Kim , Vincent Guittot , Nicolas Pitre , Daniel Lezcano , linux-arm-kernel@lists.infradead.org, Grant Likely , Charles Garcia Tobin , devicetree@vger.kernel.org, Kevin Hilman , linux-pm@vger.kernel.org, Sebastian Capella , Rob Herring , Antti Miettinen , Paul Walmsley , Geoff Levand , Peter De Schrijver , Stephen Boyd , Amit Kucheria , Bartlomiej Zolnierkiewicz List-Id: devicetree@vger.kernel.org On Wed, Aug 13, 2014 at 04:52:07PM +0100, Lorenzo Pieralisi wrote: >With the introduction of DT based idle states, CPUidle drivers for >ARM can now initialize idle states data through properties in the device >tree. > >This patch adds code to the Exynos CPUidle driver to dynamically >initialize idle states data through the updated device tree source >files. > >Cc: Chander Kashyap >Cc: Kukjin Kim >Cc: Tomasz Figa >Signed-off-by: Lorenzo Pieralisi >--- > arch/arm/boot/dts/exynos4210.dtsi | 11 +++++++++++ > arch/arm/boot/dts/exynos5250.dtsi | 11 +++++++++++ > drivers/cpuidle/Kconfig.arm | 1 + > drivers/cpuidle/cpuidle-exynos.c | 27 ++++++++++++++++++++++++--- > 4 files changed, 47 insertions(+), 3 deletions(-) > >diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi >index eab7c7b..69fd1a0 100644 >--- a/arch/arm/boot/dts/exynos4210.dtsi >+++ b/arch/arm/boot/dts/exynos4210.dtsi >@@ -48,12 +48,23 @@ > device_type = "cpu"; > compatible = "arm,cortex-a9"; > reg = <0x900>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; > }; > > cpu@901 { > device_type = "cpu"; > compatible = "arm,cortex-a9"; > reg = <0x901>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; >+ }; >+ >+ idle-states { >+ CLUSTER_SLEEP_0: cluster-sleep-0 { >+ compatible = "arm,idle-state"; >+ entry-latency-us = <1000>; >+ exit-latency-us = <300>; >+ min-residency-us = <100000>; >+ }; > }; > }; > >diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi >index 492e1ef..3a758ff 100644 >--- a/arch/arm/boot/dts/exynos5250.dtsi >+++ b/arch/arm/boot/dts/exynos5250.dtsi >@@ -63,12 +63,23 @@ > compatible = "arm,cortex-a15"; > reg = <0>; > clock-frequency = <1700000000>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; > }; > cpu@1 { > device_type = "cpu"; > compatible = "arm,cortex-a15"; > reg = <1>; > clock-frequency = <1700000000>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; >+ }; >+ >+ idle-states { >+ CLUSTER_SLEEP_0: cluster-sleep-0 { >+ compatible = "arm,idle-state"; >+ entry-latency-us = <1000>; >+ exit-latency-us = <300>; >+ min-residency-us = <100000>; >+ }; > }; > }; > >diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm >index e339c7f..04cc229 100644 >--- a/drivers/cpuidle/Kconfig.arm >+++ b/drivers/cpuidle/Kconfig.arm >@@ -55,6 +55,7 @@ config ARM_AT91_CPUIDLE > config ARM_EXYNOS_CPUIDLE > bool "Cpu Idle Driver for the Exynos processors" > depends on ARCH_EXYNOS >+ select DT_IDLE_STATES > help > Select this to enable cpuidle for Exynos processors > >diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c >index ba9b34b..6dff982 100644 >--- a/drivers/cpuidle/cpuidle-exynos.c >+++ b/drivers/cpuidle/cpuidle-exynos.c >@@ -13,11 +13,14 @@ > #include > #include > #include >+#include > > #include > #include > #include > >+#include "dt_idle_states.h" >+ > static void (*exynos_enter_aftr)(void); > > static int exynos_enter_lowpower(struct cpuidle_device *dev, >@@ -58,17 +61,35 @@ static struct cpuidle_driver exynos_idle_driver = { > > static int exynos_cpuidle_probe(struct platform_device *pdev) > { >- int ret; >+ int ret, i; >+ struct cpuidle_driver *drv = &exynos_idle_driver; > > exynos_enter_aftr = (void *)(pdev->dev.platform_data); > >- ret = cpuidle_register(&exynos_idle_driver, NULL); >+ drv->cpumask = kzalloc(cpumask_size(), GFP_KERNEL); >+ if (!drv->cpumask) >+ return -ENOMEM; drv->cpumask would not have any cpu set. I dont see it being modified elsewhere. >+ >+ /* Start at index 1, index 0 standard WFI */ >+ ret = dt_init_idle_driver(drv, 1); >+ if (ret < 0) { >+ dev_err(&pdev->dev, "failed to initialize idle states\n"); >+ goto free_mem; >+ } >+ >+ for (i = 1; i < drv->state_count; i++) >+ drv->states[i].enter = exynos_enter_lowpower; >+ >+ ret = cpuidle_register(drv, NULL); > if (ret) { > dev_err(&pdev->dev, "failed to register cpuidle driver\n"); >- return ret; >+ goto free_mem; > } > > return 0; >+free_mem: >+ kfree(drv->cpumask); >+ return ret; > } > > static struct platform_driver exynos_cpuidle_driver = { >-- >1.9.1 > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: lina.iyer@linaro.org (Lina Iyer) Date: Fri, 15 Aug 2014 15:12:33 -0600 Subject: [PATCH v7 8/8] drivers: cpuidle: initialize Exynos driver through DT In-Reply-To: <1407945127-27554-9-git-send-email-lorenzo.pieralisi@arm.com> References: <1407945127-27554-1-git-send-email-lorenzo.pieralisi@arm.com> <1407945127-27554-9-git-send-email-lorenzo.pieralisi@arm.com> Message-ID: <20140815211233.GA46224@ilina-mac.local> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, Aug 13, 2014 at 04:52:07PM +0100, Lorenzo Pieralisi wrote: >With the introduction of DT based idle states, CPUidle drivers for >ARM can now initialize idle states data through properties in the device >tree. > >This patch adds code to the Exynos CPUidle driver to dynamically >initialize idle states data through the updated device tree source >files. > >Cc: Chander Kashyap >Cc: Kukjin Kim >Cc: Tomasz Figa >Signed-off-by: Lorenzo Pieralisi >--- > arch/arm/boot/dts/exynos4210.dtsi | 11 +++++++++++ > arch/arm/boot/dts/exynos5250.dtsi | 11 +++++++++++ > drivers/cpuidle/Kconfig.arm | 1 + > drivers/cpuidle/cpuidle-exynos.c | 27 ++++++++++++++++++++++++--- > 4 files changed, 47 insertions(+), 3 deletions(-) > >diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi >index eab7c7b..69fd1a0 100644 >--- a/arch/arm/boot/dts/exynos4210.dtsi >+++ b/arch/arm/boot/dts/exynos4210.dtsi >@@ -48,12 +48,23 @@ > device_type = "cpu"; > compatible = "arm,cortex-a9"; > reg = <0x900>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; > }; > > cpu at 901 { > device_type = "cpu"; > compatible = "arm,cortex-a9"; > reg = <0x901>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; >+ }; >+ >+ idle-states { >+ CLUSTER_SLEEP_0: cluster-sleep-0 { >+ compatible = "arm,idle-state"; >+ entry-latency-us = <1000>; >+ exit-latency-us = <300>; >+ min-residency-us = <100000>; >+ }; > }; > }; > >diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi >index 492e1ef..3a758ff 100644 >--- a/arch/arm/boot/dts/exynos5250.dtsi >+++ b/arch/arm/boot/dts/exynos5250.dtsi >@@ -63,12 +63,23 @@ > compatible = "arm,cortex-a15"; > reg = <0>; > clock-frequency = <1700000000>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; > }; > cpu at 1 { > device_type = "cpu"; > compatible = "arm,cortex-a15"; > reg = <1>; > clock-frequency = <1700000000>; >+ cpu-idle-states = <&CLUSTER_SLEEP_0>; >+ }; >+ >+ idle-states { >+ CLUSTER_SLEEP_0: cluster-sleep-0 { >+ compatible = "arm,idle-state"; >+ entry-latency-us = <1000>; >+ exit-latency-us = <300>; >+ min-residency-us = <100000>; >+ }; > }; > }; > >diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm >index e339c7f..04cc229 100644 >--- a/drivers/cpuidle/Kconfig.arm >+++ b/drivers/cpuidle/Kconfig.arm >@@ -55,6 +55,7 @@ config ARM_AT91_CPUIDLE > config ARM_EXYNOS_CPUIDLE > bool "Cpu Idle Driver for the Exynos processors" > depends on ARCH_EXYNOS >+ select DT_IDLE_STATES > help > Select this to enable cpuidle for Exynos processors > >diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c >index ba9b34b..6dff982 100644 >--- a/drivers/cpuidle/cpuidle-exynos.c >+++ b/drivers/cpuidle/cpuidle-exynos.c >@@ -13,11 +13,14 @@ > #include > #include > #include >+#include > > #include > #include > #include > >+#include "dt_idle_states.h" >+ > static void (*exynos_enter_aftr)(void); > > static int exynos_enter_lowpower(struct cpuidle_device *dev, >@@ -58,17 +61,35 @@ static struct cpuidle_driver exynos_idle_driver = { > > static int exynos_cpuidle_probe(struct platform_device *pdev) > { >- int ret; >+ int ret, i; >+ struct cpuidle_driver *drv = &exynos_idle_driver; > > exynos_enter_aftr = (void *)(pdev->dev.platform_data); > >- ret = cpuidle_register(&exynos_idle_driver, NULL); >+ drv->cpumask = kzalloc(cpumask_size(), GFP_KERNEL); >+ if (!drv->cpumask) >+ return -ENOMEM; drv->cpumask would not have any cpu set. I dont see it being modified elsewhere. >+ >+ /* Start at index 1, index 0 standard WFI */ >+ ret = dt_init_idle_driver(drv, 1); >+ if (ret < 0) { >+ dev_err(&pdev->dev, "failed to initialize idle states\n"); >+ goto free_mem; >+ } >+ >+ for (i = 1; i < drv->state_count; i++) >+ drv->states[i].enter = exynos_enter_lowpower; >+ >+ ret = cpuidle_register(drv, NULL); > if (ret) { > dev_err(&pdev->dev, "failed to register cpuidle driver\n"); >- return ret; >+ goto free_mem; > } > > return 0; >+free_mem: >+ kfree(drv->cpumask); >+ return ret; > } > > static struct platform_driver exynos_cpuidle_driver = { >-- >1.9.1 > >