Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
[deliverable/linux.git] / drivers / cpuidle / cpuidle-kirkwood.c
CommitLineData
e50b6bef 1/*
e50b6bef
RK
2 * CPU idle Marvell Kirkwood SoCs
3 *
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.
7 *
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
a8e39c35
DL
12 *
13 * Maintainer: Jason Cooper <jason@lakedaemon.net>
14 * Maintainer: Andrew Lunn <andrew@lunn.ch>
e50b6bef
RK
15 */
16
17#include <linux/kernel.h>
9cfc94eb 18#include <linux/module.h>
e50b6bef
RK
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/cpuidle.h>
22#include <linux/io.h>
dc28094b 23#include <linux/export.h>
e50b6bef 24#include <asm/proc-fns.h>
b334648d 25#include <asm/cpuidle.h>
e50b6bef
RK
26
27#define KIRKWOOD_MAX_STATES 2
28
9cfc94eb
AL
29static void __iomem *ddr_operation_base;
30
e50b6bef
RK
31/* Actual code that puts the SoC in different idle states */
32static int kirkwood_enter_idle(struct cpuidle_device *dev,
9cfc94eb 33 struct cpuidle_driver *drv,
e978aa7d 34 int index)
e50b6bef 35{
9cfc94eb 36 writel(0x7, ddr_operation_base);
b334648d 37 cpu_do_idle();
e978aa7d
DD
38
39 return index;
e50b6bef
RK
40}
41
b334648d
RL
42static struct cpuidle_driver kirkwood_idle_driver = {
43 .name = "kirkwood_idle",
44 .owner = THIS_MODULE,
b334648d
RL
45 .states[0] = ARM_CPUIDLE_WFI_STATE,
46 .states[1] = {
47 .enter = kirkwood_enter_idle,
48 .exit_latency = 10,
49 .target_residency = 100000,
b334648d
RL
50 .name = "DDR SR",
51 .desc = "WFI and DDR Self Refresh",
52 },
53 .state_count = KIRKWOOD_MAX_STATES,
54};
b334648d 55
e50b6bef 56/* Initialize CPU idle by registering the idle states */
9cfc94eb 57static int kirkwood_cpuidle_probe(struct platform_device *pdev)
e50b6bef 58{
9cfc94eb
AL
59 struct resource *res;
60
61 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
488540bf
SMP
62 ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
63 if (IS_ERR(ddr_operation_base))
64 return PTR_ERR(ddr_operation_base);
e50b6bef 65
30dc72c6 66 return cpuidle_register(&kirkwood_idle_driver, NULL);
e50b6bef
RK
67}
68
75d6137d 69static int kirkwood_cpuidle_remove(struct platform_device *pdev)
9cfc94eb 70{
30dc72c6 71 cpuidle_unregister(&kirkwood_idle_driver);
9cfc94eb
AL
72 return 0;
73}
74
75static struct platform_driver kirkwood_cpuidle_driver = {
76 .probe = kirkwood_cpuidle_probe,
77 .remove = kirkwood_cpuidle_remove,
78 .driver = {
79 .name = "kirkwood_cpuidle",
9cfc94eb
AL
80 },
81};
82
83module_platform_driver(kirkwood_cpuidle_driver);
84
85MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>");
86MODULE_DESCRIPTION("Kirkwood cpu idle driver");
87MODULE_LICENSE("GPL v2");
88MODULE_ALIAS("platform:kirkwood-cpuidle");
This page took 0.4716 seconds and 5 git commands to generate.