Blame view
drivers/cpuidle/cpuidle-kirkwood.c
2.29 KB
e50b6befa
|
1 |
/* |
e50b6befa
|
2 3 4 5 6 7 8 9 10 11 |
* CPU idle Marvell Kirkwood SoCs * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. * * The cpu idle uses wait-for-interrupt and DDR self refresh in order * to implement two idle states - * #1 wait-for-interrupt * #2 wait-for-interrupt and DDR self refresh |
a8e39c35b
|
12 13 14 |
* * Maintainer: Jason Cooper <jason@lakedaemon.net> * Maintainer: Andrew Lunn <andrew@lunn.ch> |
e50b6befa
|
15 16 17 |
*/ #include <linux/kernel.h> |
9cfc94eb0
|
18 |
#include <linux/module.h> |
e50b6befa
|
19 20 21 22 |
#include <linux/init.h> #include <linux/platform_device.h> #include <linux/cpuidle.h> #include <linux/io.h> |
dc28094b9
|
23 |
#include <linux/export.h> |
e50b6befa
|
24 |
#include <asm/proc-fns.h> |
b334648db
|
25 |
#include <asm/cpuidle.h> |
e50b6befa
|
26 27 |
#define KIRKWOOD_MAX_STATES 2 |
9cfc94eb0
|
28 |
static void __iomem *ddr_operation_base; |
e50b6befa
|
29 30 |
/* Actual code that puts the SoC in different idle states */ static int kirkwood_enter_idle(struct cpuidle_device *dev, |
9cfc94eb0
|
31 |
struct cpuidle_driver *drv, |
e978aa7d7
|
32 |
int index) |
e50b6befa
|
33 |
{ |
9cfc94eb0
|
34 |
writel(0x7, ddr_operation_base); |
b334648db
|
35 |
cpu_do_idle(); |
e978aa7d7
|
36 37 |
return index; |
e50b6befa
|
38 |
} |
b334648db
|
39 40 41 |
static struct cpuidle_driver kirkwood_idle_driver = { .name = "kirkwood_idle", .owner = THIS_MODULE, |
b334648db
|
42 43 44 45 46 |
.states[0] = ARM_CPUIDLE_WFI_STATE, .states[1] = { .enter = kirkwood_enter_idle, .exit_latency = 10, .target_residency = 100000, |
b334648db
|
47 48 49 50 51 |
.name = "DDR SR", .desc = "WFI and DDR Self Refresh", }, .state_count = KIRKWOOD_MAX_STATES, }; |
b334648db
|
52 |
|
e50b6befa
|
53 |
/* Initialize CPU idle by registering the idle states */ |
9cfc94eb0
|
54 |
static int kirkwood_cpuidle_probe(struct platform_device *pdev) |
e50b6befa
|
55 |
{ |
9cfc94eb0
|
56 57 58 |
struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
488540bf4
|
59 60 61 |
ddr_operation_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(ddr_operation_base)) return PTR_ERR(ddr_operation_base); |
e50b6befa
|
62 |
|
30dc72c6f
|
63 |
return cpuidle_register(&kirkwood_idle_driver, NULL); |
e50b6befa
|
64 |
} |
75d6137da
|
65 |
static int kirkwood_cpuidle_remove(struct platform_device *pdev) |
9cfc94eb0
|
66 |
{ |
30dc72c6f
|
67 |
cpuidle_unregister(&kirkwood_idle_driver); |
9cfc94eb0
|
68 69 70 71 72 73 74 75 |
return 0; } static struct platform_driver kirkwood_cpuidle_driver = { .probe = kirkwood_cpuidle_probe, .remove = kirkwood_cpuidle_remove, .driver = { .name = "kirkwood_cpuidle", |
9cfc94eb0
|
76 77 78 79 80 81 82 83 84 |
}, }; module_platform_driver(kirkwood_cpuidle_driver); MODULE_AUTHOR("Andrew Lunn <andrew@lunn.ch>"); MODULE_DESCRIPTION("Kirkwood cpu idle driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:kirkwood-cpuidle"); |