Merge tag 'trace-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux/fpc-iii.git] / drivers / cpuidle / cpuidle-kirkwood.c
blob511c4f46027a941d920cf10fecd4cea9d6dad5c0
1 /*
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>
22 #include <linux/io.h>
23 #include <linux/export.h>
24 #include <asm/cpuidle.h>
26 #define KIRKWOOD_MAX_STATES 2
28 static void __iomem *ddr_operation_base;
30 /* Actual code that puts the SoC in different idle states */
31 static int kirkwood_enter_idle(struct cpuidle_device *dev,
32 struct cpuidle_driver *drv,
33 int index)
35 writel(0x7, ddr_operation_base);
36 cpu_do_idle();
38 return index;
41 static struct cpuidle_driver kirkwood_idle_driver = {
42 .name = "kirkwood_idle",
43 .owner = THIS_MODULE,
44 .states[0] = ARM_CPUIDLE_WFI_STATE,
45 .states[1] = {
46 .enter = kirkwood_enter_idle,
47 .exit_latency = 10,
48 .target_residency = 100000,
49 .name = "DDR SR",
50 .desc = "WFI and DDR Self Refresh",
52 .state_count = KIRKWOOD_MAX_STATES,
55 /* Initialize CPU idle by registering the idle states */
56 static int kirkwood_cpuidle_probe(struct platform_device *pdev)
58 ddr_operation_base = devm_platform_ioremap_resource(pdev, 0);
59 if (IS_ERR(ddr_operation_base))
60 return PTR_ERR(ddr_operation_base);
62 return cpuidle_register(&kirkwood_idle_driver, NULL);
65 static int kirkwood_cpuidle_remove(struct platform_device *pdev)
67 cpuidle_unregister(&kirkwood_idle_driver);
68 return 0;
71 static struct platform_driver kirkwood_cpuidle_driver = {
72 .probe = kirkwood_cpuidle_probe,
73 .remove = kirkwood_cpuidle_remove,
74 .driver = {
75 .name = "kirkwood_cpuidle",
79 module_platform_driver(kirkwood_cpuidle_driver);
81 MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
82 MODULE_DESCRIPTION("Kirkwood cpu idle driver");
83 MODULE_LICENSE("GPL v2");
84 MODULE_ALIAS("platform:kirkwood-cpuidle");