diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-02-27 03:09:52 -0500 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2015-07-16 22:56:23 -0400 |
commit | c22437b78e77ae05768d77d44bb5651ac7ef5da9 (patch) | |
tree | f4dc657b5fdd94d5767d31f1ce75aabc77a25026 /arch/arm/mach-netx/time.c | |
parent | a785fb39e1b7070da5d53a7d09b140c80c31974e (diff) |
ARM/netx/time: Migrate to new 'set-state' interface
Migrate netx 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 aren't writing zero twice on the control register for shutdown or
resume state now.
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'arch/arm/mach-netx/time.c')
-rw-r--r-- | arch/arm/mach-netx/time.c | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c index 5fb2a590ec17..054a8a61e379 100644 --- a/arch/arm/mach-netx/time.c +++ b/arch/arm/mach-netx/time.c | |||
@@ -34,40 +34,40 @@ | |||
34 | #define TIMER_CLOCKEVENT 0 | 34 | #define TIMER_CLOCKEVENT 0 |
35 | #define TIMER_CLOCKSOURCE 1 | 35 | #define TIMER_CLOCKSOURCE 1 |
36 | 36 | ||
37 | static void netx_set_mode(enum clock_event_mode mode, | 37 | static inline void timer_shutdown(struct clock_event_device *evt) |
38 | struct clock_event_device *clk) | ||
39 | { | 38 | { |
40 | u32 tmode; | ||
41 | |||
42 | /* disable timer */ | 39 | /* disable timer */ |
43 | writel(0, NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKEVENT)); | 40 | writel(0, NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKEVENT)); |
41 | } | ||
42 | |||
43 | static int netx_shutdown(struct clock_event_device *evt) | ||
44 | { | ||
45 | timer_shutdown(evt); | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static int netx_set_oneshot(struct clock_event_device *evt) | ||
51 | { | ||
52 | u32 tmode = NETX_GPIO_COUNTER_CTRL_IRQ_EN | NETX_GPIO_COUNTER_CTRL_RUN; | ||
53 | |||
54 | timer_shutdown(evt); | ||
55 | writel(0, NETX_GPIO_COUNTER_MAX(TIMER_CLOCKEVENT)); | ||
56 | writel(tmode, NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKEVENT)); | ||
44 | 57 | ||
45 | switch (mode) { | 58 | return 0; |
46 | case CLOCK_EVT_MODE_PERIODIC: | 59 | } |
47 | writel(NETX_LATCH, NETX_GPIO_COUNTER_MAX(TIMER_CLOCKEVENT)); | ||
48 | tmode = NETX_GPIO_COUNTER_CTRL_RST_EN | | ||
49 | NETX_GPIO_COUNTER_CTRL_IRQ_EN | | ||
50 | NETX_GPIO_COUNTER_CTRL_RUN; | ||
51 | break; | ||
52 | |||
53 | case CLOCK_EVT_MODE_ONESHOT: | ||
54 | writel(0, NETX_GPIO_COUNTER_MAX(TIMER_CLOCKEVENT)); | ||
55 | tmode = NETX_GPIO_COUNTER_CTRL_IRQ_EN | | ||
56 | NETX_GPIO_COUNTER_CTRL_RUN; | ||
57 | break; | ||
58 | |||
59 | default: | ||
60 | WARN(1, "%s: unhandled mode %d\n", __func__, mode); | ||
61 | /* fall through */ | ||
62 | |||
63 | case CLOCK_EVT_MODE_SHUTDOWN: | ||
64 | case CLOCK_EVT_MODE_UNUSED: | ||
65 | case CLOCK_EVT_MODE_RESUME: | ||
66 | tmode = 0; | ||
67 | break; | ||
68 | } | ||
69 | 60 | ||
61 | static int netx_set_periodic(struct clock_event_device *evt) | ||
62 | { | ||
63 | u32 tmode = NETX_GPIO_COUNTER_CTRL_RST_EN | | ||
64 | NETX_GPIO_COUNTER_CTRL_IRQ_EN | NETX_GPIO_COUNTER_CTRL_RUN; | ||
65 | |||
66 | timer_shutdown(evt); | ||
67 | writel(NETX_LATCH, NETX_GPIO_COUNTER_MAX(TIMER_CLOCKEVENT)); | ||
70 | writel(tmode, NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKEVENT)); | 68 | writel(tmode, NETX_GPIO_COUNTER_CTRL(TIMER_CLOCKEVENT)); |
69 | |||
70 | return 0; | ||
71 | } | 71 | } |
72 | 72 | ||
73 | static int netx_set_next_event(unsigned long evt, | 73 | static int netx_set_next_event(unsigned long evt, |
@@ -81,7 +81,10 @@ static struct clock_event_device netx_clockevent = { | |||
81 | .name = "netx-timer" __stringify(TIMER_CLOCKEVENT), | 81 | .name = "netx-timer" __stringify(TIMER_CLOCKEVENT), |
82 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | 82 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, |
83 | .set_next_event = netx_set_next_event, | 83 | .set_next_event = netx_set_next_event, |
84 | .set_mode = netx_set_mode, | 84 | .set_state_shutdown = netx_shutdown, |
85 | .set_state_periodic = netx_set_periodic, | ||
86 | .set_state_oneshot = netx_set_oneshot, | ||
87 | .tick_resume = netx_shutdown, | ||
85 | }; | 88 | }; |
86 | 89 | ||
87 | /* | 90 | /* |