diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-06-18 06:54:45 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2015-08-10 05:40:44 -0400 |
commit | 8ab282305f88c693275925330a0f93b16cab9c37 (patch) | |
tree | 70b09b8fef1826f4d9f99f6b9c186ce5c4b4d88b /drivers/clocksource/timer-atmel-st.c | |
parent | 85250fb89be3792c8a6793a594e30307c4e39214 (diff) |
clockevents/drivers/atmel-st: Migrate to new 'set-state' interface
Migrate atmel-st 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.
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/clocksource/timer-atmel-st.c')
-rw-r--r-- | drivers/clocksource/timer-atmel-st.c | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c index 1692e17e096b..41b7b6dc1d0d 100644 --- a/drivers/clocksource/timer-atmel-st.c +++ b/drivers/clocksource/timer-atmel-st.c | |||
@@ -106,36 +106,47 @@ static struct clocksource clk32k = { | |||
106 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 106 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
107 | }; | 107 | }; |
108 | 108 | ||
109 | static void | 109 | static void clkdev32k_disable_and_flush_irq(void) |
110 | clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) | ||
111 | { | 110 | { |
112 | unsigned int val; | 111 | unsigned int val; |
113 | 112 | ||
114 | /* Disable and flush pending timer interrupts */ | 113 | /* Disable and flush pending timer interrupts */ |
115 | regmap_write(regmap_st, AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); | 114 | regmap_write(regmap_st, AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); |
116 | regmap_read(regmap_st, AT91_ST_SR, &val); | 115 | regmap_read(regmap_st, AT91_ST_SR, &val); |
117 | |||
118 | last_crtr = read_CRTR(); | 116 | last_crtr = read_CRTR(); |
119 | switch (mode) { | 117 | } |
120 | case CLOCK_EVT_MODE_PERIODIC: | 118 | |
121 | /* PIT for periodic irqs; fixed rate of 1/HZ */ | 119 | static int clkevt32k_shutdown(struct clock_event_device *evt) |
122 | irqmask = AT91_ST_PITS; | 120 | { |
123 | regmap_write(regmap_st, AT91_ST_PIMR, RM9200_TIMER_LATCH); | 121 | clkdev32k_disable_and_flush_irq(); |
124 | break; | 122 | irqmask = 0; |
125 | case CLOCK_EVT_MODE_ONESHOT: | 123 | regmap_write(regmap_st, AT91_ST_IER, irqmask); |
126 | /* ALM for oneshot irqs, set by next_event() | 124 | return 0; |
127 | * before 32 seconds have passed | 125 | } |
128 | */ | 126 | |
129 | irqmask = AT91_ST_ALMS; | 127 | static int clkevt32k_set_oneshot(struct clock_event_device *dev) |
130 | regmap_write(regmap_st, AT91_ST_RTAR, last_crtr); | 128 | { |
131 | break; | 129 | clkdev32k_disable_and_flush_irq(); |
132 | case CLOCK_EVT_MODE_SHUTDOWN: | 130 | |
133 | case CLOCK_EVT_MODE_UNUSED: | 131 | /* |
134 | case CLOCK_EVT_MODE_RESUME: | 132 | * ALM for oneshot irqs, set by next_event() |
135 | irqmask = 0; | 133 | * before 32 seconds have passed. |
136 | break; | 134 | */ |
137 | } | 135 | irqmask = AT91_ST_ALMS; |
136 | regmap_write(regmap_st, AT91_ST_RTAR, last_crtr); | ||
138 | regmap_write(regmap_st, AT91_ST_IER, irqmask); | 137 | regmap_write(regmap_st, AT91_ST_IER, irqmask); |
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static int clkevt32k_set_periodic(struct clock_event_device *dev) | ||
142 | { | ||
143 | clkdev32k_disable_and_flush_irq(); | ||
144 | |||
145 | /* PIT for periodic irqs; fixed rate of 1/HZ */ | ||
146 | irqmask = AT91_ST_PITS; | ||
147 | regmap_write(regmap_st, AT91_ST_PIMR, RM9200_TIMER_LATCH); | ||
148 | regmap_write(regmap_st, AT91_ST_IER, irqmask); | ||
149 | return 0; | ||
139 | } | 150 | } |
140 | 151 | ||
141 | static int | 152 | static int |
@@ -170,11 +181,15 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev) | |||
170 | } | 181 | } |
171 | 182 | ||
172 | static struct clock_event_device clkevt = { | 183 | static struct clock_event_device clkevt = { |
173 | .name = "at91_tick", | 184 | .name = "at91_tick", |
174 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | 185 | .features = CLOCK_EVT_FEAT_PERIODIC | |
175 | .rating = 150, | 186 | CLOCK_EVT_FEAT_ONESHOT, |
176 | .set_next_event = clkevt32k_next_event, | 187 | .rating = 150, |
177 | .set_mode = clkevt32k_mode, | 188 | .set_next_event = clkevt32k_next_event, |
189 | .set_state_shutdown = clkevt32k_shutdown, | ||
190 | .set_state_periodic = clkevt32k_set_periodic, | ||
191 | .set_state_oneshot = clkevt32k_set_oneshot, | ||
192 | .tick_resume = clkevt32k_shutdown, | ||
178 | }; | 193 | }; |
179 | 194 | ||
180 | /* | 195 | /* |