1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include <linux/init.h>
29#include <linux/cpuidle.h>
30#include <linux/platform_device.h>
31#include <asm/cpuidle.h>
32
33#define ZYNQ_MAX_STATES 2
34
35
36static int zynq_enter_idle(struct cpuidle_device *dev,
37 struct cpuidle_driver *drv, int index)
38{
39
40 cpu_do_idle();
41
42 return index;
43}
44
45static struct cpuidle_driver zynq_idle_driver = {
46 .name = "zynq_idle",
47 .owner = THIS_MODULE,
48 .states = {
49 ARM_CPUIDLE_WFI_STATE,
50 {
51 .enter = zynq_enter_idle,
52 .exit_latency = 10,
53 .target_residency = 10000,
54 .name = "RAM_SR",
55 .desc = "WFI and RAM Self Refresh",
56 },
57 },
58 .safe_state_index = 0,
59 .state_count = ZYNQ_MAX_STATES,
60};
61
62
63static int zynq_cpuidle_probe(struct platform_device *pdev)
64{
65 pr_info("Xilinx Zynq CpuIdle Driver started\n");
66
67 return cpuidle_register(&zynq_idle_driver, NULL);
68}
69
70static struct platform_driver zynq_cpuidle_driver = {
71 .driver = {
72 .name = "cpuidle-zynq",
73 },
74 .probe = zynq_cpuidle_probe,
75};
76builtin_platform_driver(zynq_cpuidle_driver);
77