Commit | Line | Data |
---|---|---|
3bb16560 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
1ea60cf7 AT |
2 | /* |
3 | * based on arch/arm/mach-kirkwood/cpuidle.c | |
4 | * | |
5 | * CPU idle support for AT91 SoC | |
6 | * | |
1ea60cf7 AT |
7 | * The cpu idle uses wait-for-interrupt and RAM self refresh in order |
8 | * to implement two idle states - | |
9 | * #1 wait-for-interrupt | |
10 | * #2 wait-for-interrupt and RAM self refresh | |
11 | */ | |
12 | ||
13 | #include <linux/kernel.h> | |
14 | #include <linux/init.h> | |
15 | #include <linux/platform_device.h> | |
16 | #include <linux/cpuidle.h> | |
1ea60cf7 | 17 | #include <linux/io.h> |
dc28094b | 18 | #include <linux/export.h> |
7e348b90 | 19 | #include <asm/cpuidle.h> |
1ea60cf7 AT |
20 | |
21 | #define AT91_MAX_STATES 2 | |
22 | ||
5ad945ea DL |
23 | static void (*at91_standby)(void); |
24 | ||
1ea60cf7 AT |
25 | /* Actual code that puts the SoC in different idle states */ |
26 | static int at91_enter_idle(struct cpuidle_device *dev, | |
46bcfad7 | 27 | struct cpuidle_driver *drv, |
e978aa7d | 28 | int index) |
1ea60cf7 | 29 | { |
5ad945ea | 30 | at91_standby(); |
e978aa7d | 31 | return index; |
1ea60cf7 AT |
32 | } |
33 | ||
7e348b90 RL |
34 | static struct cpuidle_driver at91_idle_driver = { |
35 | .name = "at91_idle", | |
36 | .owner = THIS_MODULE, | |
7e348b90 RL |
37 | .states[0] = ARM_CPUIDLE_WFI_STATE, |
38 | .states[1] = { | |
39 | .enter = at91_enter_idle, | |
40 | .exit_latency = 10, | |
a008dad7 | 41 | .target_residency = 10000, |
7e348b90 RL |
42 | .name = "RAM_SR", |
43 | .desc = "WFI and DDR Self Refresh", | |
44 | }, | |
45 | .state_count = AT91_MAX_STATES, | |
46 | }; | |
47 | ||
1ea60cf7 | 48 | /* Initialize CPU idle by registering the idle states */ |
5ad945ea | 49 | static int at91_cpuidle_probe(struct platform_device *dev) |
1ea60cf7 | 50 | { |
5ad945ea DL |
51 | at91_standby = (void *)(dev->dev.platform_data); |
52 | ||
22f5d1fa | 53 | return cpuidle_register(&at91_idle_driver, NULL); |
1ea60cf7 AT |
54 | } |
55 | ||
5ad945ea DL |
56 | static struct platform_driver at91_cpuidle_driver = { |
57 | .driver = { | |
58 | .name = "cpuidle-at91", | |
5ad945ea DL |
59 | }, |
60 | .probe = at91_cpuidle_probe, | |
61 | }; | |
090d1cf1 | 62 | builtin_platform_driver(at91_cpuidle_driver); |