2 * CPU idle Marvell Kirkwood SoCs
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
8 * The cpu idle uses wait-for-interrupt and DDR self refresh in order
9 * to implement two idle states -
10 * #1 wait-for-interrupt
11 * #2 wait-for-interrupt and DDR self refresh
13 * Maintainer: Jason Cooper <jason@lakedaemon.net>
14 * Maintainer: Andrew Lunn <andrew@lunn.ch>
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/cpuidle.h>
23 #include <linux/export.h>
24 #include <asm/proc-fns.h>
25 #include <asm/cpuidle.h>
27 #define KIRKWOOD_MAX_STATES 2
29 static void __iomem *ddr_operation_base;
31 /* Actual code that puts the SoC in different idle states */
32 static int kirkwood_enter_idle(struct cpuidle_device *dev,
33 struct cpuidle_driver *drv,
36 writel(0x7, ddr_operation_base);
42 static struct cpuidle_driver kirkwood_idle_driver = {
43 .name = "kirkwood_idle",
45 .states[0] = ARM_CPUIDLE_WFI_STATE,
47 .enter = kirkwood_enter_idle,
49 .target_residency = 100000,
50 .flags = CPUIDLE_FLAG_TIME_VALID,
52 .desc = "WFI and DDR Self Refresh",
54 .state_count = KIRKWOOD_MAX_STATES,
57 /* Initialize CPU idle by registering the idle states */
58 static int kirkwood_cpuidle_probe(struct platform_device *pdev)
62 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
66 ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
67 if (IS_ERR(ddr_operation_base))
68 return PTR_ERR(ddr_operation_base);
70 return cpuidle_register(&kirkwood_idle_driver, NULL);
73 int kirkwood_cpuidle_remove(struct platform_device *pdev)
75 cpuidle_unregister(&kirkwood_idle_driver);
79 static struct platform_driver kirkwood_cpuidle_driver = {
80 .probe = kirkwood_cpuidle_probe,
81 .remove = kirkwood_cpuidle_remove,
83 .name = "kirkwood_cpuidle",
88 module_platform_driver(kirkwood_cpuidle_driver);
90 MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
91 MODULE_DESCRIPTION("Kirkwood cpu idle driver");
92 MODULE_LICENSE("GPL v2");
93 MODULE_ALIAS("platform:kirkwood-cpuidle");