aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-07-16 07:26:15 -0400
committerHans-Christian Egtvedt <egtvedt@samfundet.no>2015-07-20 06:19:10 -0400
commit09adcdf212d777ace8bb31bed8ca5c1dbd56bd0f (patch)
treedf13925775aeb0b7f172086446a494fda7eadd26
parent52721d9d3334c1cb1f76219a161084094ec634dc (diff)
AVR32/time: Migrate to new 'set-state' interface
Migrate avr32 driver to the new 'set-state' interface provided by clockevents core, the earlier 'set-mode' interface is marked obsolete now. This also enables us to implement callbacks for new states of clockevent devices, for example: ONESHOT_STOPPED. We want to call cpu_idle_poll_ctrl() in shutdown only if we were in oneshot or resume state earlier. Create another variable to save this information and check that in shutdown callback. Cc: Haavard Skinnemoen <hskinnemoen@gmail.com> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
-rw-r--r--arch/avr32/kernel/time.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index d0f771be9e96..a124c55733db 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -18,6 +18,7 @@
18 18
19#include <mach/pm.h> 19#include <mach/pm.h>
20 20
21static bool disable_cpu_idle_poll;
21 22
22static cycle_t read_cycle_count(struct clocksource *cs) 23static cycle_t read_cycle_count(struct clocksource *cs)
23{ 24{
@@ -80,45 +81,45 @@ static int comparator_next_event(unsigned long delta,
80 return 0; 81 return 0;
81} 82}
82 83
83static void comparator_mode(enum clock_event_mode mode, 84static int comparator_shutdown(struct clock_event_device *evdev)
84 struct clock_event_device *evdev)
85{ 85{
86 switch (mode) { 86 pr_debug("%s: %s\n", __func__, evdev->name);
87 case CLOCK_EVT_MODE_ONESHOT: 87 sysreg_write(COMPARE, 0);
88 pr_debug("%s: start\n", evdev->name); 88
89 /* FALLTHROUGH */ 89 if (disable_cpu_idle_poll) {
90 case CLOCK_EVT_MODE_RESUME: 90 disable_cpu_idle_poll = false;
91 /* 91 /*
92 * If we're using the COUNT and COMPARE registers we 92 * Only disable idle poll if we have forced that
93 * need to force idle poll. 93 * in a previous call.
94 */ 94 */
95 cpu_idle_poll_ctrl(true); 95 cpu_idle_poll_ctrl(false);
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();
112 } 96 }
97 return 0;
98}
99
100static 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
115static struct clock_event_device comparator = { 114static struct clock_event_device comparator = {
116 .name = "avr32_comparator", 115 .name = "avr32_comparator",
117 .features = CLOCK_EVT_FEAT_ONESHOT, 116 .features = CLOCK_EVT_FEAT_ONESHOT,
118 .shift = 16, 117 .shift = 16,
119 .rating = 50, 118 .rating = 50,
120 .set_next_event = comparator_next_event, 119 .set_next_event = comparator_next_event,
121 .set_mode = comparator_mode, 120 .set_state_shutdown = comparator_shutdown,
121 .set_state_oneshot = comparator_set_oneshot,
122 .tick_resume = comparator_set_oneshot,
122}; 123};
123 124
124void read_persistent_clock(struct timespec *ts) 125void read_persistent_clock(struct timespec *ts)