|
18 | 18 |
|
19 | 19 | #include <mach/pm.h>
|
20 | 20 |
|
| 21 | +static bool disable_cpu_idle_poll; |
21 | 22 |
|
22 | 23 | static cycle_t read_cycle_count(struct clocksource *cs)
|
23 | 24 | {
|
@@ -80,45 +81,45 @@ static int comparator_next_event(unsigned long delta,
|
80 | 81 | return 0;
|
81 | 82 | }
|
82 | 83 |
|
83 |
| -static void comparator_mode(enum clock_event_mode mode, |
84 |
| - struct clock_event_device *evdev) |
| 84 | +static int comparator_shutdown(struct clock_event_device *evdev) |
85 | 85 | {
|
86 |
| - switch (mode) { |
87 |
| - case CLOCK_EVT_MODE_ONESHOT: |
88 |
| - pr_debug("%s: start\n", evdev->name); |
89 |
| - /* FALLTHROUGH */ |
90 |
| - case CLOCK_EVT_MODE_RESUME: |
| 86 | + pr_debug("%s: %s\n", __func__, evdev->name); |
| 87 | + sysreg_write(COMPARE, 0); |
| 88 | + |
| 89 | + if (disable_cpu_idle_poll) { |
| 90 | + disable_cpu_idle_poll = false; |
91 | 91 | /*
|
92 |
| - * If we're using the COUNT and COMPARE registers we |
93 |
| - * need to force idle poll. |
| 92 | + * Only disable idle poll if we have forced that |
| 93 | + * in a previous call. |
94 | 94 | */
|
95 |
| - cpu_idle_poll_ctrl(true); |
96 |
| - break; |
97 |
| - case CLOCK_EVT_MODE_UNUSED: |
98 |
| - case CLOCK_EVT_MODE_SHUTDOWN: |
99 |
| - sysreg_write(COMPARE, 0); |
100 |
| - pr_debug("%s: stop\n", evdev->name); |
101 |
| - if (evdev->mode == CLOCK_EVT_MODE_ONESHOT || |
102 |
| - evdev->mode == CLOCK_EVT_MODE_RESUME) { |
103 |
| - /* |
104 |
| - * Only disable idle poll if we have forced that |
105 |
| - * in a previous call. |
106 |
| - */ |
107 |
| - cpu_idle_poll_ctrl(false); |
108 |
| - } |
109 |
| - break; |
110 |
| - default: |
111 |
| - BUG(); |
| 95 | + cpu_idle_poll_ctrl(false); |
112 | 96 | }
|
| 97 | + return 0; |
| 98 | +} |
| 99 | + |
| 100 | +static int comparator_set_oneshot(struct clock_event_device *evdev) |
| 101 | +{ |
| 102 | + pr_debug("%s: %s\n", __func__, evdev->name); |
| 103 | + |
| 104 | + disable_cpu_idle_poll = true; |
| 105 | + /* |
| 106 | + * If we're using the COUNT and COMPARE registers we |
| 107 | + * need to force idle poll. |
| 108 | + */ |
| 109 | + cpu_idle_poll_ctrl(true); |
| 110 | + |
| 111 | + return 0; |
113 | 112 | }
|
114 | 113 |
|
115 | 114 | static struct clock_event_device comparator = {
|
116 |
| - .name = "avr32_comparator", |
117 |
| - .features = CLOCK_EVT_FEAT_ONESHOT, |
118 |
| - .shift = 16, |
119 |
| - .rating = 50, |
120 |
| - .set_next_event = comparator_next_event, |
121 |
| - .set_mode = comparator_mode, |
| 115 | + .name = "avr32_comparator", |
| 116 | + .features = CLOCK_EVT_FEAT_ONESHOT, |
| 117 | + .shift = 16, |
| 118 | + .rating = 50, |
| 119 | + .set_next_event = comparator_next_event, |
| 120 | + .set_state_shutdown = comparator_shutdown, |
| 121 | + .set_state_oneshot = comparator_set_oneshot, |
| 122 | + .tick_resume = comparator_set_oneshot, |
122 | 123 | };
|
123 | 124 |
|
124 | 125 | void read_persistent_clock(struct timespec *ts)
|
|
0 commit comments