Add imx cpuidle
Subsystems (3)
v2 cover Add imx cpuidle
Add common imx cpuidle initialization functionality and add a i.MX5 and i.MX6Q platform cpuidle implementation.
Based on v3.4-rc5 plus recently submitted device tree late_initcall patch:
http://www.spinics.net/lists/arm-kernel/msg171620.html
Changes since v1:
* Removed some unnecessary spaces
* Added return value for an error message
* Reworked init scheme to use device tree late_initcall.
* Moved imx6q and imx5 cpuidle functionality to existing files.
Robert Lee (3):
ARM: imx: Add common imx cpuidle init functionality.
ARM: imx: Add imx5 cpuidle driver
ARM: imx: Add imx6q cpuidle driver
arch/arm/mach-imx/cpuidle-imx6q.c | 33 ++++++++++++ arch/arm/mach-imx/mach-imx6q.c | 18 +++++++ arch/arm/mach-imx/mm-imx5.c | 42 ++++++++++++++-- arch/arm/plat-mxc/Makefile | 1 + arch/arm/plat-mxc/cpuidle.c | 80 ++++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/cpuidle.h | 22 ++++++++ 6 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 arch/arm/mach-imx/cpuidle-imx6q.c create mode 100644 arch/arm/plat-mxc/cpuidle.c create mode 100644 arch/arm/plat-mxc/include/mach/cpuidle.h
Signature · 1 line
1.7.10
PATCH v2 1/3 ARM: imx: Add common imx cpuidle init functionality.
Add common cpuidle init functionality that can be used by various imx platforms.
--- arch/arm/plat-mxc/Makefile | 1 + arch/arm/plat-mxc/cpuidle.c | 80 ++++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/cpuidle.h | 22 ++++++++ 3 files changed, 103 insertions(+) create mode 100644 arch/arm/plat-mxc/cpuidle.c create mode 100644 arch/arm/plat-mxc/include/mach/cpuidle.h
arch/arm/plat-mxc/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_MXC_ULPI) += ulpi.o obj-$(CONFIG_MXC_USE_EPIT) += epit.o obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o +obj-$(CONFIG_CPU_IDLE) += cpuidle.o ifdef CONFIG_SND_IMX_SOC obj-y += ssi-fiq.o obj-y += ssi-fiq-ksym.o
arch/arm/plat-mxc/cpuidle.c new file +80 -0
80 lines not on this page · raw message
arch/arm/plat-mxc/include/mach/cpuidle.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/cpuidle.h> + +#ifdef CONFIG_CPU_IDLE +extern void imx_cpuidle_devices_uninit (void ); +extern int imx_cpuidle_init (struct cpuidle_driver *drv); +#else +static inline void imx_cpuidle_devices_uninit (void ) {} +static inline int imx_cpuidle_init (struct cpuidle_driver *drv) +{return -ENODEV ; } +#endif
Signature · 1 line
1.7.10
Re: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
Quoted 53 lines · Robert Lee
Add common cpuidle init functionality that can be used by various imx platforms.
Signed-off-by Robert Lee <[email protected]>--- arch/arm/plat-mxc/Makefile | 1 + arch/arm/plat-mxc/cpuidle.c | 80 ++++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/cpuidle.h | 22 ++++++++ 3 files changed, 103 insertions(+) create mode 100644 arch/arm/plat-mxc/cpuidle.c create mode 100644 arch/arm/plat-mxc/include/mach/cpuidle.harch/arm/plat-mxc/Makefile +1
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_MXC_ULPI) += ulpi.o obj-$(CONFIG_MXC_USE_EPIT) += epit.o obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o +obj-$(CONFIG_CPU_IDLE) += cpuidle.o ifdef CONFIG_SND_IMX_SOC obj-y += ssi-fiq.o obj-y += ssi-fiq-ksym.oarch/arm/plat-mxc/cpuidle.c new file +23
-0@@ -0,0 +1,80 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/kernel.h> +#include <linux/io.h> +#include <linux/cpuidle.h> +#include <linux/hrtimer.h> +#include <linux/err.h> +#include <linux/slab.h> + +static struct cpuidle_device __percpu * imx_cpuidle_devices; + +void imx_cpuidle_devices_uninit (void ) +{
arch/arm/plat-mxc/cpuidle.c line 33
Quoted 10 lines
arch/arm/plat-mxc/cpuidle.c new file +10
-0+int cpu_id; +struct cpuidle_device *dev; + +for_each_possible_cpu (cpu_id) { + dev =per_cpu_ptr (imx_cpuidle_devices, cpu_id); +cpuidle_unregister_device (dev); + } + +free_percpu (imx_cpuidle_devices); +}
Does this function need to be exported? I haven't seen it being used anywhere outside this file. Also, can it be __init?
Quoted 24 lines
arch/arm/plat-mxc/cpuidle.c new file +24
-0+ +int __init imx_cpuidle_init (struct cpuidle_driver *drv) +{ +struct cpuidle_device *dev; +int cpu_id, ret; + +if (!drv || drv->state_count >CPUIDLE_STATE_MAX ) { +pr_err ("%s: Invalid Input\n" , __func__); +return -EINVAL ; + } + + ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("%s: Failed to register cpuidle driver with error: %d\n" , + __func__, ret); +return ret; + } + + imx_cpuidle_devices = alloc_percpu(struct cpuidle_device); +if (imx_cpuidle_devices ==NULL ) { + ret = -ENOMEM ; + goto unregister_drv; + } +
arch/arm/plat-mxc/cpuidle.c line 67
Quoted 10 lines
arch/arm/plat-mxc/cpuidle.c new file +10
-0+/* initialize state data for each cpuidle_device */ +for_each_possible_cpu (cpu_id) { + dev =per_cpu_ptr (imx_cpuidle_devices, cpu_id); + dev->cpu = cpu_id; + dev->state_count = drv->state_count; + + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("%s: Failed to register cpu %u\n" , + __func__, cpu_id);
Nit: print ret (error code) too?
Quoted 30 lines
arch/arm/plat-mxc/cpuidle.c new file +13
-0+ goto uninit; + } + } + +return 0 ; + +uninit: +imx_cpuidle_devices_uninit (); + +unregister_drv: +cpuidle_unregister_driver (drv); +return ret; +}arch/arm/plat-mxc/include/mach/cpuidle.h new file +11
-0@@ -0,0 +1,22 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/
arch/arm/plat-mxc/include/mach/cpuidle.h line 21
Quoted 10 lines
arch/arm/plat-mxc/include/mach/cpuidle.h new file +10
-0+ +#include <linux/cpuidle.h> + +#ifdef CONFIG_CPU_IDLE +extern void imx_cpuidle_devices_uninit (void ); +extern int imx_cpuidle_init (struct cpuidle_driver *drv); +#else +static inline void imx_cpuidle_devices_uninit (void ) {} +static inline int imx_cpuidle_init (struct cpuidle_driver *drv) +{return -ENODEV ; }
Nit: if it can not be in the same line with function name, we usually have it be:
{
return -ENODEV;
}Quoted 4 lines
arch/arm/plat-mxc/include/mach/cpuidle.h new file +1
-0+#endif Signature · 1 line
1.7.10
Signature · 2 lines
Regards, Shawn
Re: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
Shawn,
Quoted 59 lines · Shawn Guo
Quoted 58 lines · Robert Lee
Add common cpuidle init functionality that can be used by various imx platforms.
Signed-off-by Robert Lee <[email protected]>---
?arch/arm/plat-mxc/Makefile ? ? ? ? ? ? ? | ? ?1 + ?arch/arm/plat-mxc/cpuidle.c ? ? ? ? ? ? ?| ? 80 ++++++++++++++++++++++++++++++ ?arch/arm/plat-mxc/include/mach/cpuidle.h | ? 22 ++++++++?3 files changed, 103 insertions(+)
?create mode 100644arch/arm/plat-mxc/cpuidle.c?create mode 100644arch/arm/plat-mxc/include/mach/cpuidle.harch/arm/plat-mxc/Makefile +0
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_MXC_ULPI) += ulpi.o?obj-$(CONFIG_MXC_USE_EPIT) += epit.o ?obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o ?obj-$(CONFIG_CPU_FREQ_IMX) ? ?+= cpufreq.o +obj-$(CONFIG_CPU_IDLE) += cpuidle.o ?ifdef
CONFIG_SND_IMX_SOC
?obj-y += ssi-fiq.o
?obj-y += ssi-fiq-ksym.oarch/arm/plat-mxc/cpuidle.c new file +28
-0@@ -0,0 +1,80 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/kernel.h> +#include <linux/io.h> +#include <linux/cpuidle.h> +#include <linux/hrtimer.h> +#include <linux/err.h> +#include <linux/slab.h> + +static struct cpuidle_device __percpu * imx_cpuidle_devices; + +void imx_cpuidle_devices_uninit (void ) +{ + ? ? int cpu_id; + ? ? struct cpuidle_device *dev; + + ? ? for_each_possible_cpu(cpu_id) { + ? ? ? ? ? ? dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id);
Quoted 9 lines
arch/arm/plat-mxc/cpuidle.c line 33
Quoted 5 lines
arch/arm/plat-mxc/cpuidle.c new file +5
-0+ ? ? ? ? ? ? cpuidle_unregister_device(dev); + ? ? } + + ? ? free_percpu(imx_cpuidle_devices); +}Does this function need to be exported? ?I haven't seen it being used anywhere outside this file. ?Also, can it be
__init?
Yes to both for now and can be changed back if necessary in the future.
Quoted 28 lines
Quoted 28 lines
arch/arm/plat-mxc/cpuidle.c new file +28
-0+ +int __init imx_cpuidle_init (struct cpuidle_driver *drv) +{ + ? ? struct cpuidle_device *dev; + ? ? int cpu_id, ret; + + ? ? if (!drv || drv->state_count > CPUIDLE_STATE_MAX) { + ? ? ? ? ? ? pr_err("%s: Invalid Input\n", __func__); + ? ? ? ? ? ? return -EINVAL; + ? ? } + + ? ? ret = cpuidle_register_driver(drv); + ? ? if (ret) { + ? ? ? ? ? ? pr_err("%s: Failed to register cpuidle driver with error: %d\n", + ? ? ? ? ? ? ? ? ? ? ?__func__, ret); + ? ? ? ? ? ? return ret; + ? ? } + + ? ? imx_cpuidle_devices = alloc_percpu(struct cpuidle_device); + ? ? if (imx_cpuidle_devices == NULL) { + ? ? ? ? ? ? ret = -ENOMEM; + ? ? ? ? ? ? goto unregister_drv; + ? ? } + + ? ? /* initialize state data for each cpuidle_device */ + ? ? for_each_possible_cpu(cpu_id) { + ? ? ? ? ? ? dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id); + ? ? ? ? ? ? dev->cpu = cpu_id;
Quoted 9 lines
arch/arm/plat-mxc/cpuidle.c line 67
Quoted 6 lines
arch/arm/plat-mxc/cpuidle.c new file +6
-0+ ? ? ? ? ? ? dev->state_count = drv->state_count; + + ? ? ? ? ? ? ret = cpuidle_register_device(dev); + ? ? ? ? ? ? if (ret) { + ? ? ? ? ? ? ? ? ? ? pr_err("%s: Failed to register cpu %u\n", + ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__, cpu_id);Nit: print ret (error code) too?
I added the printing of the error code based on Sascha's suggestion in v1 of this submission.
Quoted 44 lines
Quoted 30 lines
arch/arm/plat-mxc/cpuidle.c new file +13
-0+ ? ? ? ? ? ? ? ? ? ? goto uninit; + ? ? ? ? ? ? } + ? ? } + + ? ? return 0; + +uninit: + ? ? imx_cpuidle_devices_uninit(); + +unregister_drv: + ? ? cpuidle_unregister_driver(drv); + ? ? return ret; +}arch/arm/plat-mxc/include/mach/cpuidle.h new file +11
-0@@ -0,0 +1,22 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ arch/arm/plat-mxc/include/mach/cpuidle.h line 21
Quoted 10 lines
arch/arm/plat-mxc/include/mach/cpuidle.h new file +10
-0+ +#include <linux/cpuidle.h> + +#ifdef CONFIG_CPU_IDLE +extern void imx_cpuidle_devices_uninit (void ); +extern int imx_cpuidle_init (struct cpuidle_driver *drv); +#else +static inline void imx_cpuidle_devices_uninit (void ) {} +static inline int imx_cpuidle_init (struct cpuidle_driver *drv) +{return -ENODEV ; }Nit: if it can not be in the same line with function name, we usually have it be:
Quoted 3 lines
{
? ? ? ?return-ENODEV;
}
Understood. I was just going by what I have seen used in other places (like include/linux/cpuidle.h).
Thanks,
Rob
Quoted 9 lines
Quoted 5 lines
arch/arm/plat-mxc/include/mach/cpuidle.h new file +1
-1+#endif --1.7.10
--
Regards,
Shawn
Re: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
Quoted 11 lines · Rob Lee
Quoted 7 lines
Quoted 4 lines
+ ? ? ? ? ? ? ret =
cpuidle_register_device(dev);
+ ? ? ? ? ? ? if (ret) {
+ ? ? ? ? ? ? ? ? ? ? pr_err("%s: Failed to register cpu %u\n",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ?__func__,cpu_id);Nit: print ret (error code) too?
I added the printing of the error code based on Sascha's suggestion in v1 of this submission.
But you did not print "ret" in above pr_err.
Regards,
Shawn
Re: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
Quoted 6 lines · Shawn Guo
Quoted 5 lines · Rob Lee
Quoted 5 lines
Quoted 4 lines
+ ? ? ? ? ? ? ret =
cpuidle_register_device(dev);
+ ? ? ? ? ? ? if (ret) {
+ ? ? ? ? ? ? ? ? ? ? pr_err("%s: Failed to register cpu %u\n",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ?__func__,cpu_id);
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Nit: print ret (error code) too?
I added the printing of the error code based on Sascha's suggestion in v1 of this submission.
But you did not print "ret" in above
pr_err.
Argh, sorry, still trying to wake up I guess. Thanks.
Quoted 2 lines
Regards,
Shawn
Sascha Hauer
maintainerRe: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
In reply to Robert Leearch/arm/plat-mxc/cpuidle.c line 40
Quoted 12 lines · Robert Lee
Add common cpuidle init functionality that can be used by various imx platforms.
Signed-off-by Robert Lee <[email protected]>---
arch/arm/plat-mxc/cpuidle.c new file +7
-0+ +int __init imx_cpuidle_init (struct cpuidle_driver *drv) +{ +struct cpuidle_device *dev; +int cpu_id, ret; + +if (!drv || drv->state_count >CPUIDLE_STATE_MAX ) {
Please don't check for !drv here. When someone calls this function with a NULL pointer he should get a nive stack trace allowing him to figure out what went wrong.
Quoted 18 lines
arch/arm/plat-mxc/cpuidle.c new file +18
-0+pr_err ("%s: Invalid Input\n" , __func__); +return -EINVAL ; + } + + ret =cpuidle_register_driver (drv); +if (ret) { +pr_err ("%s: Failed to register cpuidle driver with error: %d\n" , + __func__, ret); +return ret; + } + + imx_cpuidle_devices = alloc_percpu(struct cpuidle_device); +if (imx_cpuidle_devices ==NULL ) { + ret = -ENOMEM ; + goto unregister_drv; + } + +/* initialize state data for each cpuidle_device */
arch/arm/plat-mxc/cpuidle.c line 68
Quoted 10 lines
arch/arm/plat-mxc/cpuidle.c new file +10
-0+for_each_possible_cpu (cpu_id) { + dev =per_cpu_ptr (imx_cpuidle_devices, cpu_id); + dev->cpu = cpu_id; + dev->state_count = drv->state_count; + + ret =cpuidle_register_device (dev); +if (ret) { +pr_err ("%s: Failed to register cpu %u\n" , + __func__, cpu_id); + goto uninit;
You should only unregister the cpuidle devices you successfully registered. Unregistering not yet registered cpuidle devices probably has unwanted side effects.
Sascha
Quoted 44 lines
arch/arm/plat-mxc/cpuidle.c new file +12
-0+ } + } + +return 0 ; + +uninit: +imx_cpuidle_devices_uninit (); + +unregister_drv: +cpuidle_unregister_driver (drv); +return ret; +}arch/arm/plat-mxc/include/mach/cpuidle.h new file +22
-0@@ -0,0 +1,22 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/cpuidle.h> + +#ifdef CONFIG_CPU_IDLE +extern void imx_cpuidle_devices_uninit (void ); +extern int imx_cpuidle_init (struct cpuidle_driver *drv); +#else +static inline void imx_cpuidle_devices_uninit (void ) {} +static inline int imx_cpuidle_init (struct cpuidle_driver *drv) +{return -ENODEV ; } +#endif Signature · 1 line
1.7.10
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
Sascha,
Quoted 4 lines · Sascha Hauer
Quoted 3 lines · Robert Lee
Add common cpuidle init functionality that can be used by various imx platforms.
Quoted 14 lines
arch/arm/plat-mxc/cpuidle.c
Quoted 9 lines
Signed-off-by Robert Lee <[email protected]>---
arch/arm/plat-mxc/cpuidle.c new file +7
-0+ +int __init imx_cpuidle_init (struct cpuidle_driver *drv) +{ + ? ? struct cpuidle_device *dev; + ? ? int cpu_id, ret; + + ? ? if (!drv || drv->state_count > CPUIDLE_STATE_MAX) {Please don't check for !drv here. When someone calls this function with a NULL pointer he should get a nive stack trace allowing him to figure out what went wrong.
Ok, I will change this in v3. Given your statement, my understanding is that I should avoid adding checks to make sure a valid driver object was given as the stack trace information is all the handling that is needed. If there is any further logic needed in that rule, could you elaborate so that I don't make this mistake in the future, or so that I don't add a check on a driver object in a case that I should?
Quoted 24 lines
Quoted 24 lines
+ ? ? ? ? ? ?
pr_err("%s: Invalid Input\n", __func__);
+ ? ? ? ? ? ? return-EINVAL;
+ ? ? }(quoted diff) +21
-0+ + ? ? ret = cpuidle_register_driver(drv); + ? ? if (ret) { + ? ? ? ? ? ? pr_err("%s: Failed to register cpuidle driver with error: %d\n", + ? ? ? ? ? ? ? ? ? ? ?__func__, ret); + ? ? ? ? ? ? return ret; + ? ? } + + ? ? imx_cpuidle_devices = alloc_percpu(struct cpuidle_device); + ? ? if (imx_cpuidle_devices == NULL) { + ? ? ? ? ? ? ret = -ENOMEM; + ? ? ? ? ? ? goto unregister_drv; + ? ? } + + ? ? /* initialize state data for each cpuidle_device */ + ? ? for_each_possible_cpu(cpu_id) { + ? ? ? ? ? ? dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id); + ? ? ? ? ? ? dev->cpu = cpu_id; + ? ? ? ? ? ? dev->state_count = drv->state_count; + + ? ? ? ? ? ? ret = cpuidle_register_device(dev);
Quoted 9 lines
Quoted 4 lines
+ ? ? ? ? ? ? if (ret) {
+ ? ? ? ? ? ? ? ? ? ? pr_err("%s: Failed to register cpu %u\n",
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ?__func__,cpu_id);
+ ? ? ? ? ? ? ? ? ? ? goto uninit;You should only unregister the cpuidle devices you successfully registered. Unregistering not yet registered cpuidle devices probably has unwanted side effects.
I did not add in this handling because the cpuidle_unregister_device() call already has a "registered" check so extra handling seemed unnecessary. But if you still think it is needed just let me know.
cpuidle_unregister_device()
{
...
if (dev->registered == 0) return;
...
Thanks,
Rob
Quoted 52 lines
Sascha
Quoted 41 lines
+ ? ? ? ? ? ? }
+ ? ? }arch/arm/plat-mxc/cpuidle.c new file +10
-0+ + ? ? return 0; + +uninit: + ? ? imx_cpuidle_devices_uninit(); + +unregister_drv: + ? ? cpuidle_unregister_driver(drv); + ? ? return ret; +}arch/arm/plat-mxc/include/mach/cpuidle.h new file +22
-1@@ -0,0 +1,22 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/cpuidle.h> + +#ifdef CONFIG_CPU_IDLE +extern void imx_cpuidle_devices_uninit (void ); +extern int imx_cpuidle_init (struct cpuidle_driver *drv); +#else +static inline void imx_cpuidle_devices_uninit (void ) {} +static inline int imx_cpuidle_init (struct cpuidle_driver *drv) +{return -ENODEV ; } +#endif --Quoted 3 lines
1.7.10
--
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? | Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?| Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?| Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |
Sascha Hauer
maintainerRe: [PATCH v2 1/3] ARM: imx: Add common imx cpuidle init functionality.
Quoted 14 lines · Rob Lee
Sascha,
Quoted 11 lines
arch/arm/plat-mxc/cpuidle.c
Quoted 6 lines
arch/arm/plat-mxc/cpuidle.c new file +6
-0+int __init imx_cpuidle_init (struct cpuidle_driver *drv) +{ + ? ? struct cpuidle_device *dev; + ? ? int cpu_id, ret; + + ? ? if (!drv || drv->state_count > CPUIDLE_STATE_MAX) {Please don't check for !drv here. When someone calls this function with a NULL pointer he should get a nive stack trace allowing him to figure out what went wrong.
Quoted 7 lines
Ok, I will change this in v3. Given your statement, my understanding is that I should avoid adding checks to make sure a valid driver object was given as the stack trace information is all the handling that is needed. If there is any further logic needed in that rule, could you elaborate so that I don't make this mistake in the future, or so that I don't add a check on a driver object in a case that I should?
Here we have the case that only a Kernel developer will add a call to this function. For a kernel developer a stack trace is more useful than a pr_err. Of course this is different when not testing for a NULL pointer causes subtle bugs in unrelated code.
Quoted 10 lines
Quoted 5 lines
You should only unregister the cpuidle devices you successfully registered. Unregistering not yet registered cpuidle devices probably has unwanted side effects.
I did not add in this handling because the
cpuidle_unregister_device()call already has a "registered" check so extra handling seemed unnecessary. But if you still think it is needed just let me know.
It's ok then. I didn't check cpuidle_unregister_device.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 2/3 ARM: imx: Add imx5 cpuidle driver
In reply to Robert LeeAdd imx5 cpuidle driver.
--- arch/arm/mach-imx/mm-imx5.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-)
arch/arm/mach-imx/mm-imx5.c +39 -3
@@ -22,24 +22,59 @@#include <mach/common.h> #include <mach/devices-common.h> #include <mach/iomux-v3.h> +#include <mach/cpuidle.h> static struct clk *gpc_dvfs_clk; -static void imx5_idle (void ) +static int imx5_idle (void ) { +int ret =0 ; +/* gpc clock is needed for SRPG */ if (gpc_dvfs_clk ==NULL ) { gpc_dvfs_clk =clk_get (NULL ,"gpc_dvfs" );if (IS_ERR (gpc_dvfs_clk)) -return ; +return -ENODEV ; }clk_enable (gpc_dvfs_clk);mx5_cpu_lp_set (WAIT_UNCLOCKED_POWER_OFF );if (!tzic_enable_wake ())cpu_do_idle (); +else + ret = -EBUSY ;clk_disable (gpc_dvfs_clk); + +return ret; +} + +static int imx5_cpuidle_enter (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int idx) +{ +int ret; + + ret =imx5_idle (); + +if (ret <0 ) +return ret; + +return idx; } +static struct cpuidle_driver imx5_cpuidle_driver = { + .name ="imx5_cpuidle" , + .owner =THIS_MODULE , + .en_core_tk_irqen =1 , + .states[0 ] = { + .enter = imx5_cpuidle_enter, + .exit_latency =20 ,/* max latency@160MHz */ + .target_residency =1 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .name ="IMX5 SRPG" , + .desc ="CPU state retained,powered off" , + }, + .state_count =1 , +}; +/* * Define the MX50 memory map. */
@@ -103,7 +138,7 @@ void __init imx51_init_early(void)mxc_set_cpu_type (MXC_CPU_MX51 );mxc_iomux_v3_init (MX51_IO_ADDRESS (MX51_IOMUXC_BASE_ADDR ));mxc_arch_reset_init (MX51_IO_ADDRESS (MX51_WDOG1_BASE_ADDR )); - arm_pm_idle = imx5_idle; + arm_pm_idle = (void *)imx5_idle; }void __init imx53_init_early (void )
@@ -238,4 +273,5 @@ void __init imx53_soc_init(void)void __init imx51_init_late (void ) {mx51_neon_fixup (); +imx_cpuidle_init (&imx5_cpuidle_driver); }
Signature · 1 line
1.7.10
Sascha Hauer
maintainerRe: [PATCH v2 2/3] ARM: imx: Add imx5 cpuidle driver
Quoted 74 lines · Robert Lee
Add imx5 cpuidle driver.
Signed-off-by Robert Lee <[email protected]>--- arch/arm/mach-imx/mm-imx5.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-)arch/arm/mach-imx/mm-imx5.c +37
-2@@ -22,24 +22,59 @@#include <mach/common.h> #include <mach/devices-common.h> #include <mach/iomux-v3.h> +#include <mach/cpuidle.h> static struct clk *gpc_dvfs_clk; -static void imx5_idle (void ) +static int imx5_idle (void ) { +int ret =0 ; +/* gpc clock is needed for SRPG */ if (gpc_dvfs_clk ==NULL ) { gpc_dvfs_clk =clk_get (NULL ,"gpc_dvfs" );if (IS_ERR (gpc_dvfs_clk)) -return ; +return -ENODEV ; }clk_enable (gpc_dvfs_clk);mx5_cpu_lp_set (WAIT_UNCLOCKED_POWER_OFF );if (!tzic_enable_wake ())cpu_do_idle (); +else + ret = -EBUSY ;clk_disable (gpc_dvfs_clk); + +return ret; +} + +static int imx5_cpuidle_enter (struct cpuidle_device *dev, +struct cpuidle_driver *drv,int idx) +{ +int ret; + + ret =imx5_idle (); + +if (ret <0 ) +return ret; + +return idx; } +static struct cpuidle_driver imx5_cpuidle_driver = { + .name ="imx5_cpuidle" , + .owner =THIS_MODULE , + .en_core_tk_irqen =1 , + .states[0 ] = { + .enter = imx5_cpuidle_enter, + .exit_latency =20 ,/* max latency at 160MHz */ + .target_residency =1 , + .flags =CPUIDLE_FLAG_TIME_VALID , + .name ="IMX5 SRPG" , + .desc ="CPU state retained,powered off" , + }, + .state_count =1 , +}; +/* * Define the MX50 memory map. */
arch/arm/mach-imx/mm-imx5.c void __init imx51_init_early(void) · line 141
Quoted 5 lines
arch/arm/mach-imx/mm-imx5.c +1
-1@@ -103,7 +138,7 @@ void __init imx51_init_early(void)mxc_set_cpu_type (MXC_CPU_MX51 );mxc_iomux_v3_init (MX51_IO_ADDRESS (MX51_IOMUXC_BASE_ADDR ));mxc_arch_reset_init (MX51_IO_ADDRESS (MX51_WDOG1_BASE_ADDR )); - arm_pm_idle = imx5_idle; + arm_pm_idle = (void *)imx5_idle;
I don't like this. It will cover all warnings when the prototype of arm_pm_idle changes in future. Better add a static void imx5_idle which calls a static int imx5_do_idle, then you have an idle function which returns an int.
Quoted 13 lines
arch/arm/mach-imx/mm-imx5.c +1
-0}void __init imx53_init_early (void )@@ -238,4 +273,5 @@ void __init imx53_soc_init(void)void __init imx51_init_late (void ) {mx51_neon_fixup (); +imx_cpuidle_init (&imx5_cpuidle_driver); }Signature · 1 line
1.7.10
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH v2 2/3] ARM: imx: Add imx5 cpuidle driver
Sascha,
Quoted 77 lines · Sascha Hauer
Quoted 76 lines · Robert Lee
Add imx5 cpuidle driver.
Signed-off-by Robert Lee <[email protected]>---
?arch/arm/mach-imx/mm-imx5.c | ? 42 +++++++++++++++++++++++++++++++++++++++--- ?1 file changed, 39 insertions(+), 3 deletions(-)arch/arm/mach-imx/mm-imx5.c +0
-0@@ -22,24 +22,59 @@?#include <
mach/common.h>
?#include <mach/devices-common.h>
?#include <mach/iomux-v3.h>
+#include <mach/cpuidle.h>?static struct clk
*gpc_dvfs_clk;arch/arm/mach-imx/mm-imx5.c +1
-1-static void imx5_idle (void ) +static int imx5_idle (void )?{
+ ? ? int ret = 0;
+
? ? ? /* gpc clock is needed for SRPG */
? ? ? if (gpc_dvfs_clk== NULL) {
? ? ? ? ? ? ?gpc_dvfs_clk=clk_get(NULL, "gpc_dvfs"); ? ? ? ? ? ? ? if (IS_ERR(gpc_dvfs_clk))
- ? ? ? ? ? ? ? ? ? ? return;
+ ? ? ? ? ? ? ? ? ? ? return-ENODEV;
? ? ? }
? ? ?clk_enable(gpc_dvfs_clk);
? ? ?mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); ? ? ? if (!tzic_enable_wake())
? ? ? ? ? ? ?cpu_do_idle();
+ ? ? else
+ ? ? ? ? ? ? ret =-EBUSY;
? ? ?clk_disable(gpc_dvfs_clk);arch/arm/mach-imx/mm-imx5.c +15
-0+ + ? ? return ret; +} + +static int imx5_cpuidle_enter (struct cpuidle_device *dev, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct cpuidle_driver *drv, int idx) +{ + ? ? int ret; + + ? ? ret = imx5_idle(); + + ? ? if (ret < 0) + ? ? ? ? ? ? return ret; + + ? ? return idx;?}
arch/arm/mach-imx/mm-imx5.c +15
-0+static struct cpuidle_driver imx5_cpuidle_driver = { + ? ? .name ? ? ? ? ? ? ? ? ? = "imx5_cpuidle", + ? ? .owner ? ? ? ? ? ? ? ? ?= THIS_MODULE, + ? ? .en_core_tk_irqen ? ? ? = 1, + ? ? .states[0] ? ? ?= { + ? ? ? ? ? ? .enter ? ? ? ? ? ? ? ? ?= imx5_cpuidle_enter, + ? ? ? ? ? ? .exit_latency ? ? ? ? ? = 20, /* max latency at 160MHz */ + ? ? ? ? ? ? .target_residency ? ? ? = 1, + ? ? ? ? ? ? .flags ? ? ? ? ? ? ? ? ?= CPUIDLE_FLAG_TIME_VALID, + ? ? ? ? ? ? .name ? ? ? ? ? ? ? ? ? = "IMX5 SRPG", + ? ? ? ? ? ? .desc ? ? ? ? ? ? ? ? ? = "CPU state retained,powered off", + ? ? }, + ? ? .state_count ? ? ? ? ? ?= 1, +}; +?/*
? * Define the MX50 memory map.
? */arch/arm/mach-imx/mm-imx5.c +0
-0@@ -103,7 +138,7 @@ void __init imx51_init_early(void) ? ? ? mxc_set_cpu_type(MXC_CPU_MX51); ? ? ? mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
Quoted 9 lines
arch/arm/mach-imx/mm-imx5.c void __init imx51_init_early(void) · line 141
Quoted 3 lines
arch/arm/mach-imx/mm-imx5.c +1
-1? ? ? mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR)); - ? ? arm_pm_idle = imx5_idle; + ? ? arm_pm_idle = (void *)imx5_idle;I don't like this. It will cover all warnings when the prototype of
arm_pm_idlechanges in future. Better add a static voidimx5_idlewhich calls a static intimx5_do_idle, then you have an idle function which returns an int.
What about using the following:
arm_pm_idle = (void (*)(void))imx5_idle;
This will give warnings if arm_pm_idle prototype changes.
Thanks,
Rob
Quoted 19 lines
Quoted 10 lines
arch/arm/mach-imx/mm-imx5.c +1
-1?} ?void __init imx53_init_early(void)@@ -238,4 +273,5 @@ void __init imx53_soc_init(void) ?void __init imx51_init_late(void) ?{ ? ? ? mx51_neon_fixup(); + ? ? imx_cpuidle_init(&imx5_cpuidle_driver); ?} --Quoted 3 lines
1.7.10
--
Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? | Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?| Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?| Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |
Sascha Hauer
maintainerRe: [PATCH v2 2/3] ARM: imx: Add imx5 cpuidle driver
Quoted 13 lines · Rob Lee
Sascha,
Quoted 10 lines
Quoted 4 lines
? ? ? mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR)); ? ? ? mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
- ? ?arm_pm_idle=imx5_idle;
+ ? ?arm_pm_idle= (void *)imx5_idle;I don't like this. It will cover all warnings when the prototype of
arm_pm_idlechanges in future. Better add a static voidimx5_idlewhich calls a static intimx5_do_idle, then you have an idle function which returns an int.
Quoted 5 lines
What about using the following:
arm_pm_idle= (void (*)(void))imx5_idle;This will give warnings if
arm_pm_idleprototype changes.
This surely works but will look suspicious for people looking at the code.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v2 3/3 ARM: imx: Add imx6q cpuidle driver
In reply to Robert LeeAdd basic imx6q cpuidle driver. For now, only basic WFI state is supported. Deeper idle states will be added in the future.
--- arch/arm/mach-imx/cpuidle-imx6q.c | 33 +++++++++++++++++++++++++++++++++ arch/arm/mach-imx/mach-imx6q.c | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 arch/arm/mach-imx/cpuidle-imx6q.c
arch/arm/mach-imx/cpuidle-imx6q.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/cpuidle.h> +#include <linux/export.h> +#include <asm/cpuidle.h> +#include <mach/cpuidle.h> + +static struct cpuidle_driver imx6q_cpuidle_driver = { + .name ="imx6q_cpuidle" , + .owner =THIS_MODULE , + .en_core_tk_irqen =1 , + .states[0 ] =ARM_CPUIDLE_WFI_STATE , + .state_count =1 , +}; + +int __init imx6q_cpuidle_init (void ) +{ +imx_cpuidle_set_driver (&imx6q_cpuidle_driver); + +return 0 ; +}
arch/arm/mach-imx/mach-imx6q.c +18 -0
@@ -21,6 +21,9 @@#include <linux/of_platform.h> #include <linux/phy.h> #include <linux/micrel_phy.h> +#include <linux/export.h> +#include <linux/cpuidle.h> +#include <asm/cpuidle.h> #include <asm/smp_twd.h> #include <asm/hardware/cache-l2x0.h> #include <asm/hardware/gic.h>
@@ -29,6 +32,7 @@#include <asm/system_misc.h> #include <mach/common.h> #include <mach/hardware.h> +#include <mach/cpuidle.h> void imx6q_restart (char mode,const char *cmd) {
@@ -86,6 +90,19 @@ static void __init imx6q_init_machine(void)imx6q_pm_init (); } +static struct cpuidle_driver imx6q_cpuidle_driver = { + .name ="imx6q_cpuidle" , + .owner =THIS_MODULE , + .en_core_tk_irqen =1 , + .states[0 ] =ARM_CPUIDLE_WFI_STATE , + .state_count =1 , +}; + +static void __init imx6q_init_late (void ) +{ +imx_cpuidle_init (&imx6q_cpuidle_driver); +} +static void __init imx6q_map_io (void ) {imx_lluart_map_io ();
@@ -142,6 +159,7 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad (Device Tree)") .handle_irq = imx6q_handle_irq, .timer = &imx6q_timer, .init_machine = imx6q_init_machine, + .init_late = imx6q_init_late, .dt_compat = imx6q_dt_compat, .restart = imx6q_restart,MACHINE_END
Signature · 1 line
1.7.10
Re: [PATCH v2 3/3] ARM: imx: Add imx6q cpuidle driver
Quoted 6 lines · Robert Lee
Add basic imx6q cpuidle driver. For now, only basic WFI state is supported. Deeper idle states will be added in the future.
Signed-off-by Robert Lee <[email protected]>--- arch/arm/mach-imx/cpuidle-imx6q.c | 33 +++++++++++++++++++++++++++++++++
So, this file is not needed any more, I guess.
Quoted 58 lines
arch/arm/mach-imx/mach-imx6q.c | 18 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 arch/arm/mach-imx/cpuidle-imx6q.carch/arm/mach-imx/cpuidle-imx6q.c new file +33
-0@@ -0,0 +1,33 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/cpuidle.h> +#include <linux/export.h> +#include <asm/cpuidle.h> +#include <mach/cpuidle.h> + +static struct cpuidle_driver imx6q_cpuidle_driver = { + .name ="imx6q_cpuidle" , + .owner =THIS_MODULE , + .en_core_tk_irqen =1 , + .states[0 ] =ARM_CPUIDLE_WFI_STATE , + .state_count =1 , +}; + +int __init imx6q_cpuidle_init (void ) +{ +imx_cpuidle_set_driver (&imx6q_cpuidle_driver); + +return 0 ; +}arch/arm/mach-imx/mach-imx6q.c +3
-0@@ -21,6 +21,9 @@#include <linux/of_platform.h> #include <linux/phy.h> #include <linux/micrel_phy.h> +#include <linux/export.h> +#include <linux/cpuidle.h> +#include <asm/cpuidle.h> #include <asm/smp_twd.h> #include <asm/hardware/cache-l2x0.h> #include <asm/hardware/gic.h>
arch/arm/mach-imx/mach-imx6q.c line 35
Quoted 4 lines
arch/arm/mach-imx/mach-imx6q.c +1
-0@@ -29,6 +32,7 @@#include <asm/system_misc.h> #include <mach/common.h> #include <mach/hardware.h> +#include <mach/cpuidle.h>
The headers here are mostly sorted in names, so please ...
Regards,
Shawn
Quoted 34 lines
arch/arm/mach-imx/mach-imx6q.c +14
-0void imx6q_restart (char mode,const char *cmd) {@@ -86,6 +90,19 @@ static void __init imx6q_init_machine(void)imx6q_pm_init (); } +static struct cpuidle_driver imx6q_cpuidle_driver = { + .name ="imx6q_cpuidle" , + .owner =THIS_MODULE , + .en_core_tk_irqen =1 , + .states[0 ] =ARM_CPUIDLE_WFI_STATE , + .state_count =1 , +}; + +static void __init imx6q_init_late (void ) +{ +imx_cpuidle_init (&imx6q_cpuidle_driver); +} +static void __init imx6q_map_io (void ) {imx_lluart_map_io ();@@ -142,6 +159,7 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad (Device Tree)") .handle_irq = imx6q_handle_irq, .timer = &imx6q_timer, .init_machine = imx6q_init_machine, + .init_late = imx6q_init_late, .dt_compat = imx6q_dt_compat, .restart = imx6q_restart,MACHINE_END Signature · 1 line
1.7.10
Re: [PATCH v2 3/3] ARM: imx: Add imx6q cpuidle driver
Quoted 10 lines · Shawn Guo
Quoted 6 lines · Robert Lee
Add basic imx6q cpuidle driver. ?For now, only basic WFI state is supported. ?Deeper idle states will be added in the future.
Signed-off-by Robert Lee <[email protected]>---
?arch/arm/mach-imx/cpuidle-imx6q.c | ? 33 +++++++++++++++++++++++++++++++++So, this file is not needed any more, I guess.
Yes, I missed that. It shouldn't have been part of the patch.
Quoted 56 lines
Quoted 56 lines
?arch/arm/mach-imx/mach-imx6q.c ? ?| ? 18 ++++++++++++++++++ ?2 files changed, 51 insertions(+)
?create mode 100644arch/arm/mach-imx/cpuidle-imx6q.carch/arm/mach-imx/cpuidle-imx6q.c new file +33
-0@@ -0,0 +1,33 @@ +/* +* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012 Linaro Ltd. +* +* The code contained herein is licensed under the GNU General Public +* License. You may obtain a copy of the GNU General Public License +* Version 2 or later at the following locations: +* +* http://www.opensource.org/licenses/gpl-license.html +* http://www.gnu.org/copyleft/gpl.html +*/ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/cpuidle.h> +#include <linux/export.h> +#include <asm/cpuidle.h> +#include <mach/cpuidle.h> + +static struct cpuidle_driver imx6q_cpuidle_driver = { + ? ? .name ? ? ? ? ? ? ? ? ? = "imx6q_cpuidle", + ? ? .owner ? ? ? ? ? ? ? ? ?= THIS_MODULE, + ? ? .en_core_tk_irqen ? ? ? = 1, + ? ? .states[0] ? ? ? ? ? ? ?= ARM_CPUIDLE_WFI_STATE, + ? ? .state_count ? ? ? ? ? ?= 1, +}; + +int __init imx6q_cpuidle_init (void ) +{ + ? ? imx_cpuidle_set_driver(&imx6q_cpuidle_driver); + + ? ? return 0; +}arch/arm/mach-imx/mach-imx6q.c +0
-0@@ -21,6 +21,9 @@?#include <
linux/of_platform.h>
?#include <linux/phy.h>
?#include <linux/micrel_phy.h>arch/arm/mach-imx/mach-imx6q.c +3
-0+#include <linux/export.h> +#include <linux/cpuidle.h> +#include <asm/cpuidle.h> ?#include <
asm/smp_twd.h>
?#include <asm/hardware/cache-l2x0.h>
Quoted 9 lines
Quoted 6 lines
?#include <
asm/hardware/gic.h>arch/arm/mach-imx/mach-imx6q.c +0
-0@@ -29,6 +32,7 @@?#include <
asm/system_misc.h>
?#include <mach/common.h>
?#include <mach/hardware.h>
+#include <mach/cpuidle.h>The headers here are mostly sorted in names, so please ...
Do you mean sorted alphabetically per group? So the last three includes should look like this instead?
...
#include <mach/common.h>
#include <mach/cpuidle.h>
#include <mach/hardware.h>
...
Thanks,
Rob
Quoted 37 lines
Regards,
ShawnQuoted 34 lines
?void
imx6q_restart(char mode, const char *cmd)
?{arch/arm/mach-imx/mach-imx6q.c +14
-0@@ -86,6 +90,19 @@ static void __init imx6q_init_machine(void) ? ? ? imx6q_pm_init(); ?} +static struct cpuidle_driver imx6q_cpuidle_driver = { + ? ? .name ? ? ? ? ? ? ? ? ? = "imx6q_cpuidle", + ? ? .owner ? ? ? ? ? ? ? ? ?= THIS_MODULE, + ? ? .en_core_tk_irqen ? ? ? = 1, + ? ? .states[0] ? ? ? ? ? ? ?= ARM_CPUIDLE_WFI_STATE, + ? ? .state_count ? ? ? ? ? ?= 1, +}; + +static void __init imx6q_init_late (void ) +{ + ? ? imx_cpuidle_init(&imx6q_cpuidle_driver); +} + ?static void __init imx6q_map_io(void) ?{ ? ? ? imx_lluart_map_io();@@ -142,6 +159,7 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad (Device Tree)") ? ? ? .handle_irq ? ? = imx6q_handle_irq, ? ? ? .timer ? ? ? ? ?= &imx6q_timer, ? ? ? .init_machine ? = imx6q_init_machine, + ? ? .init_late ? ? ?= imx6q_init_late, ? ? ? .dt_compat ? ? ?= imx6q_dt_compat, ? ? ? .restart ? ? ? ?= imx6q_restart,?MACHINE_END
--
1.7.10
Re: [PATCH v2 3/3] ARM: imx: Add imx6q cpuidle driver
Quoted 21 lines · Rob Lee
Quoted 11 lines
Quoted 11 lines
arch/arm/mach-imx/mach-imx6q.c +0
-0@@ -21,6 +21,9 @@?#include <
linux/of_platform.h>
?#include <linux/phy.h>
?#include <linux/micrel_phy.h>arch/arm/mach-imx/mach-imx6q.c +3
-0+#include <linux/export.h> +#include <linux/cpuidle.h> +#include <asm/cpuidle.h> ?#include <
asm/smp_twd.h>
?#include <asm/hardware/cache-l2x0.h>Quoted 9 lines
Quoted 6 lines
?#include <
asm/hardware/gic.h>arch/arm/mach-imx/mach-imx6q.c +0
-0@@ -29,6 +32,7 @@?#include <
asm/system_misc.h>
?#include <mach/common.h>
?#include <mach/hardware.h>
+#include <mach/cpuidle.h>The headers here are mostly sorted in names, so please ...
Quoted 7 lines
Do you mean sorted alphabetically per group? So the last three includes should look like this instead?
...
#include <mach/common.h>
#include <mach/cpuidle.h>
#include <mach/hardware.h>
...
Yes. And do not forget <linux/export.h> and <linux/cpuidle.h>.
Signature · 2 lines
Regards, Shawn
Quoted 4 lines · Robert Lee
Add common imx cpuidle initialization functionality and add a i.MX5 and i.MX6Q platform cpuidle implementation.
Based on v3.4-rc5 plus recently submitted device tree
late_initcallpatch:
Just to clarify, this is not a device tree late_initcall but a machine specific late_initcall time hook. It has nothing to do with device tree.
Regards,
Shawn
Quoted 27 lines
http://www.spinics.net/lists/arm-kernel/msg171620.html
Changes since v1:
* Removed some unnecessary spaces
* Added return value for an error message
* Reworked init scheme to use device treelate_initcall.
* Moved imx6q and imx5 cpuidle functionality to existing files.Robert Lee (3):
ARM: imx: Add common imx cpuidle init functionality.
ARM: imx: Add imx5 cpuidle driver
ARM: imx: Add imx6q cpuidle driverarch/arm/mach-imx/cpuidle-imx6q.c | 33 ++++++++++++ arch/arm/mach-imx/mach-imx6q.c | 18 +++++++ arch/arm/mach-imx/mm-imx5.c | 42 ++++++++++++++-- arch/arm/plat-mxc/Makefile | 1 + arch/arm/plat-mxc/cpuidle.c | 80 ++++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/cpuidle.h | 22 ++++++++ 6 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 arch/arm/mach-imx/cpuidle-imx6q.c create mode 100644 arch/arm/plat-mxc/cpuidle.c create mode 100644 arch/arm/plat-mxc/include/mach/cpuidle.hSignature · 1 line
1.7.10