This source file includes following definitions.
- ux500_enter_idle
- dbx500_cpuidle_probe
1
2
3
4
5
6
7
8
9 #include <linux/init.h>
10 #include <linux/cpuidle.h>
11 #include <linux/spinlock.h>
12 #include <linux/atomic.h>
13 #include <linux/smp.h>
14 #include <linux/mfd/dbx500-prcmu.h>
15 #include <linux/platform_data/arm-ux500-pm.h>
16 #include <linux/platform_device.h>
17
18 #include <asm/cpuidle.h>
19
20 static atomic_t master = ATOMIC_INIT(0);
21 static DEFINE_SPINLOCK(master_lock);
22
23 static inline int ux500_enter_idle(struct cpuidle_device *dev,
24 struct cpuidle_driver *drv, int index)
25 {
26 int this_cpu = smp_processor_id();
27 bool recouple = false;
28
29 if (atomic_inc_return(&master) == num_online_cpus()) {
30
31
32
33 if (!spin_trylock(&master_lock))
34 goto wfi;
35
36
37 if (prcmu_gic_decouple()) {
38 spin_unlock(&master_lock);
39 goto out;
40 }
41
42
43
44 recouple = true;
45
46
47
48
49 if (!prcmu_is_cpu_in_wfi(this_cpu ? 0 : 1))
50 goto out;
51
52
53
54 if (prcmu_copy_gic_settings())
55 goto out;
56
57
58
59 if (prcmu_gic_pending_irq())
60 goto out;
61
62
63 if (prcmu_pending_irq())
64 goto out;
65
66
67
68
69 if (prcmu_set_power_state(PRCMU_AP_IDLE, true, true))
70 goto out;
71
72
73
74 recouple = false;
75
76 spin_unlock(&master_lock);
77 }
78 wfi:
79 cpu_do_idle();
80 out:
81 atomic_dec(&master);
82
83 if (recouple) {
84 prcmu_gic_recouple();
85 spin_unlock(&master_lock);
86 }
87
88 return index;
89 }
90
91 static struct cpuidle_driver ux500_idle_driver = {
92 .name = "ux500_idle",
93 .owner = THIS_MODULE,
94 .states = {
95 ARM_CPUIDLE_WFI_STATE,
96 {
97 .enter = ux500_enter_idle,
98 .exit_latency = 70,
99 .target_residency = 260,
100 .flags = CPUIDLE_FLAG_TIMER_STOP,
101 .name = "ApIdle",
102 .desc = "ARM Retention",
103 },
104 },
105 .safe_state_index = 0,
106 .state_count = 2,
107 };
108
109 static int dbx500_cpuidle_probe(struct platform_device *pdev)
110 {
111
112 prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
113 PRCMU_WAKEUP(ABB));
114
115 return cpuidle_register(&ux500_idle_driver, NULL);
116 }
117
118 static struct platform_driver dbx500_cpuidle_plat_driver = {
119 .driver = {
120 .name = "cpuidle-dbx500",
121 },
122 .probe = dbx500_cpuidle_probe,
123 };
124 builtin_platform_driver(dbx500_cpuidle_plat_driver);