diff options
| author | Robert Lee <rob.lee@linaro.org> | 2012-05-21 18:50:28 -0400 |
|---|---|---|
| committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-06-05 02:51:47 -0400 |
| commit | 2da50e6284caadd92ded697e41fb200358f64261 (patch) | |
| tree | f57de192f1697a217df1d450d48c298f3263b14d | |
| parent | aa96a18d22dc7ad4dbc98cb0f4b2967a9fc979ca (diff) | |
ARM: imx: Add common imx cpuidle init functionality.
Add common cpuidle init functionality that can be used by various
imx platforms.
Signed-off-by: Robert Lee <rob.lee@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| -rw-r--r-- | arch/arm/plat-mxc/Makefile | 1 | ||||
| -rw-r--r-- | arch/arm/plat-mxc/cpuidle.c | 80 | ||||
| -rw-r--r-- | arch/arm/plat-mxc/include/mach/cpuidle.h | 22 |
3 files changed, 103 insertions, 0 deletions
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile index e81290c27c65..63b064b5c1d5 100644 --- a/arch/arm/plat-mxc/Makefile +++ b/arch/arm/plat-mxc/Makefile | |||
| @@ -16,6 +16,7 @@ obj-$(CONFIG_MXC_ULPI) += ulpi.o | |||
| 16 | obj-$(CONFIG_MXC_USE_EPIT) += epit.o | 16 | obj-$(CONFIG_MXC_USE_EPIT) += epit.o |
| 17 | obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o | 17 | obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o |
| 18 | obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o | 18 | obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o |
| 19 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | ||
| 19 | ifdef CONFIG_SND_IMX_SOC | 20 | ifdef CONFIG_SND_IMX_SOC |
| 20 | obj-y += ssi-fiq.o | 21 | obj-y += ssi-fiq.o |
| 21 | obj-y += ssi-fiq-ksym.o | 22 | obj-y += ssi-fiq-ksym.o |
diff --git a/arch/arm/plat-mxc/cpuidle.c b/arch/arm/plat-mxc/cpuidle.c new file mode 100644 index 000000000000..d4cb511a44a8 --- /dev/null +++ b/arch/arm/plat-mxc/cpuidle.c | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
| 3 | * Copyright 2012 Linaro Ltd. | ||
| 4 | * | ||
| 5 | * The code contained herein is licensed under the GNU General Public | ||
| 6 | * License. You may obtain a copy of the GNU General Public License | ||
| 7 | * Version 2 or later at the following locations: | ||
| 8 | * | ||
| 9 | * http://www.opensource.org/licenses/gpl-license.html | ||
| 10 | * http://www.gnu.org/copyleft/gpl.html | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/cpuidle.h> | ||
| 14 | #include <linux/err.h> | ||
| 15 | #include <linux/hrtimer.h> | ||
| 16 | #include <linux/io.h> | ||
| 17 | #include <linux/kernel.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | |||
| 20 | static struct cpuidle_device __percpu * imx_cpuidle_devices; | ||
| 21 | |||
| 22 | static void __init imx_cpuidle_devices_uninit(void) | ||
| 23 | { | ||
| 24 | int cpu_id; | ||
| 25 | struct cpuidle_device *dev; | ||
| 26 | |||
| 27 | for_each_possible_cpu(cpu_id) { | ||
| 28 | dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id); | ||
| 29 | cpuidle_unregister_device(dev); | ||
| 30 | } | ||
| 31 | |||
| 32 | free_percpu(imx_cpuidle_devices); | ||
| 33 | } | ||
| 34 | |||
| 35 | int __init imx_cpuidle_init(struct cpuidle_driver *drv) | ||
| 36 | { | ||
| 37 | struct cpuidle_device *dev; | ||
| 38 | int cpu_id, ret; | ||
| 39 | |||
| 40 | if (drv->state_count > CPUIDLE_STATE_MAX) { | ||
| 41 | pr_err("%s: state_count exceeds maximum\n", __func__); | ||
| 42 | return -EINVAL; | ||
| 43 | } | ||
| 44 | |||
| 45 | ret = cpuidle_register_driver(drv); | ||
| 46 | if (ret) { | ||
| 47 | pr_err("%s: Failed to register cpuidle driver with error: %d\n", | ||
| 48 | __func__, ret); | ||
| 49 | return ret; | ||
| 50 | } | ||
| 51 | |||
| 52 | imx_cpuidle_devices = alloc_percpu(struct cpuidle_device); | ||
| 53 | if (imx_cpuidle_devices == NULL) { | ||
| 54 | ret = -ENOMEM; | ||
| 55 | goto unregister_drv; | ||
| 56 | } | ||
| 57 | |||
| 58 | /* initialize state data for each cpuidle_device */ | ||
| 59 | for_each_possible_cpu(cpu_id) { | ||
| 60 | dev = per_cpu_ptr(imx_cpuidle_devices, cpu_id); | ||
| 61 | dev->cpu = cpu_id; | ||
| 62 | dev->state_count = drv->state_count; | ||
| 63 | |||
| 64 | ret = cpuidle_register_device(dev); | ||
| 65 | if (ret) { | ||
| 66 | pr_err("%s: Failed to register cpu %u, error: %d\n", | ||
| 67 | __func__, cpu_id, ret); | ||
| 68 | goto uninit; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | return 0; | ||
| 73 | |||
| 74 | uninit: | ||
| 75 | imx_cpuidle_devices_uninit(); | ||
| 76 | |||
| 77 | unregister_drv: | ||
| 78 | cpuidle_unregister_driver(drv); | ||
| 79 | return ret; | ||
| 80 | } | ||
diff --git a/arch/arm/plat-mxc/include/mach/cpuidle.h b/arch/arm/plat-mxc/include/mach/cpuidle.h new file mode 100644 index 000000000000..bc932d1af372 --- /dev/null +++ b/arch/arm/plat-mxc/include/mach/cpuidle.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
| 3 | * Copyright 2012 Linaro Ltd. | ||
| 4 | * | ||
| 5 | * The code contained herein is licensed under the GNU General Public | ||
| 6 | * License. You may obtain a copy of the GNU General Public License | ||
| 7 | * Version 2 or later at the following locations: | ||
| 8 | * | ||
| 9 | * http://www.opensource.org/licenses/gpl-license.html | ||
| 10 | * http://www.gnu.org/copyleft/gpl.html | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/cpuidle.h> | ||
| 14 | |||
| 15 | #ifdef CONFIG_CPU_IDLE | ||
| 16 | extern int imx_cpuidle_init(struct cpuidle_driver *drv); | ||
| 17 | #else | ||
| 18 | static inline int imx_cpuidle_init(struct cpuidle_driver *drv) | ||
| 19 | { | ||
| 20 | return -ENODEV; | ||
| 21 | } | ||
| 22 | #endif | ||
