diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-07-06 07:11:57 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-09-03 06:07:51 -0400 |
commit | c88f2fb4d81df3dbafd79d51b2cacefb356d466c (patch) | |
tree | 9ea6d995925ed24bc36d724edd469953a8ecf493 | |
parent | 9f95618f9fe5fc902a3d8fecd10c98e482fab6c5 (diff) |
MIPS: cevt-gt641xx: Migrate to new 'set-state' interface
Migrate cevt-gt641xx 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.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-mips@linux-mips.org
Cc: linaro-kernel@lists.linaro.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Patchwork: https://patchwork.linux-mips.org/patch/10604/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/kernel/cevt-gt641xx.c | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/arch/mips/kernel/cevt-gt641xx.c b/arch/mips/kernel/cevt-gt641xx.c index f069460751ab..66040051151d 100644 --- a/arch/mips/kernel/cevt-gt641xx.c +++ b/arch/mips/kernel/cevt-gt641xx.c | |||
@@ -64,8 +64,7 @@ static int gt641xx_timer0_set_next_event(unsigned long delta, | |||
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | static void gt641xx_timer0_set_mode(enum clock_event_mode mode, | 67 | static int gt641xx_timer0_shutdown(struct clock_event_device *evt) |
68 | struct clock_event_device *evt) | ||
69 | { | 68 | { |
70 | u32 ctrl; | 69 | u32 ctrl; |
71 | 70 | ||
@@ -73,21 +72,39 @@ static void gt641xx_timer0_set_mode(enum clock_event_mode mode, | |||
73 | 72 | ||
74 | ctrl = GT_READ(GT_TC_CONTROL_OFS); | 73 | ctrl = GT_READ(GT_TC_CONTROL_OFS); |
75 | ctrl &= ~(GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK); | 74 | ctrl &= ~(GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK); |
75 | GT_WRITE(GT_TC_CONTROL_OFS, ctrl); | ||
76 | |||
77 | raw_spin_unlock(>641xx_timer_lock); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int gt641xx_timer0_set_oneshot(struct clock_event_device *evt) | ||
82 | { | ||
83 | u32 ctrl; | ||
84 | |||
85 | raw_spin_lock(>641xx_timer_lock); | ||
86 | |||
87 | ctrl = GT_READ(GT_TC_CONTROL_OFS); | ||
88 | ctrl &= ~GT_TC_CONTROL_SELTC0_MSK; | ||
89 | ctrl |= GT_TC_CONTROL_ENTC0_MSK; | ||
90 | GT_WRITE(GT_TC_CONTROL_OFS, ctrl); | ||
91 | |||
92 | raw_spin_unlock(>641xx_timer_lock); | ||
93 | return 0; | ||
94 | } | ||
76 | 95 | ||
77 | switch (mode) { | 96 | static int gt641xx_timer0_set_periodic(struct clock_event_device *evt) |
78 | case CLOCK_EVT_MODE_PERIODIC: | 97 | { |
79 | ctrl |= GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK; | 98 | u32 ctrl; |
80 | break; | 99 | |
81 | case CLOCK_EVT_MODE_ONESHOT: | 100 | raw_spin_lock(>641xx_timer_lock); |
82 | ctrl |= GT_TC_CONTROL_ENTC0_MSK; | ||
83 | break; | ||
84 | default: | ||
85 | break; | ||
86 | } | ||
87 | 101 | ||
102 | ctrl = GT_READ(GT_TC_CONTROL_OFS); | ||
103 | ctrl |= GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK; | ||
88 | GT_WRITE(GT_TC_CONTROL_OFS, ctrl); | 104 | GT_WRITE(GT_TC_CONTROL_OFS, ctrl); |
89 | 105 | ||
90 | raw_spin_unlock(>641xx_timer_lock); | 106 | raw_spin_unlock(>641xx_timer_lock); |
107 | return 0; | ||
91 | } | 108 | } |
92 | 109 | ||
93 | static void gt641xx_timer0_event_handler(struct clock_event_device *dev) | 110 | static void gt641xx_timer0_event_handler(struct clock_event_device *dev) |
@@ -95,12 +112,16 @@ static void gt641xx_timer0_event_handler(struct clock_event_device *dev) | |||
95 | } | 112 | } |
96 | 113 | ||
97 | static struct clock_event_device gt641xx_timer0_clockevent = { | 114 | static struct clock_event_device gt641xx_timer0_clockevent = { |
98 | .name = "gt641xx-timer0", | 115 | .name = "gt641xx-timer0", |
99 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | 116 | .features = CLOCK_EVT_FEAT_PERIODIC | |
100 | .irq = GT641XX_TIMER0_IRQ, | 117 | CLOCK_EVT_FEAT_ONESHOT, |
101 | .set_next_event = gt641xx_timer0_set_next_event, | 118 | .irq = GT641XX_TIMER0_IRQ, |
102 | .set_mode = gt641xx_timer0_set_mode, | 119 | .set_next_event = gt641xx_timer0_set_next_event, |
103 | .event_handler = gt641xx_timer0_event_handler, | 120 | .set_state_shutdown = gt641xx_timer0_shutdown, |
121 | .set_state_periodic = gt641xx_timer0_set_periodic, | ||
122 | .set_state_oneshot = gt641xx_timer0_set_oneshot, | ||
123 | .tick_resume = gt641xx_timer0_shutdown, | ||
124 | .event_handler = gt641xx_timer0_event_handler, | ||
104 | }; | 125 | }; |
105 | 126 | ||
106 | static irqreturn_t gt641xx_timer0_interrupt(int irq, void *dev_id) | 127 | static irqreturn_t gt641xx_timer0_interrupt(int irq, void *dev_id) |