aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/arm_global_timer.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-06-12 04:00:13 -0400
committerDaniel Lezcano <daniel.lezcano@linaro.org>2015-08-06 06:16:41 -0400
commite511e6c3cd9baa3177f29aeb30c4ac7150c5f93b (patch)
tree681402a9f5441439ffb60339d5b8751c34cb270e /drivers/clocksource/arm_global_timer.c
parent46c5bfdda3de91ba4324d73403af7dfb60f5ee38 (diff)
clockevents/drivers/arm_global_timer: Migrate to new 'set-state' interface
Migrate arm_global_timer driver to the new 'set-state' interface provided by the 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. Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Maxime Coquelin <maxime.coquelin@st.com> Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Srinivas Kandagatla <srinivas.kandagatla@gmail.com> Cc: Maxime Coquelin <maxime.coquelin@st.com> Cc: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource/arm_global_timer.c')
-rw-r--r--drivers/clocksource/arm_global_timer.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c
index e6833771a716..29ea50ac366a 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -107,26 +107,21 @@ static void gt_compare_set(unsigned long delta, int periodic)
107 writel(ctrl, gt_base + GT_CONTROL); 107 writel(ctrl, gt_base + GT_CONTROL);
108} 108}
109 109
110static void gt_clockevent_set_mode(enum clock_event_mode mode, 110static int gt_clockevent_shutdown(struct clock_event_device *evt)
111 struct clock_event_device *clk)
112{ 111{
113 unsigned long ctrl; 112 unsigned long ctrl;
114 113
115 switch (mode) { 114 ctrl = readl(gt_base + GT_CONTROL);
116 case CLOCK_EVT_MODE_PERIODIC: 115 ctrl &= ~(GT_CONTROL_COMP_ENABLE | GT_CONTROL_IRQ_ENABLE |
117 gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1); 116 GT_CONTROL_AUTO_INC);
118 break; 117 writel(ctrl, gt_base + GT_CONTROL);
119 case CLOCK_EVT_MODE_ONESHOT: 118 return 0;
120 case CLOCK_EVT_MODE_UNUSED: 119}
121 case CLOCK_EVT_MODE_SHUTDOWN: 120
122 ctrl = readl(gt_base + GT_CONTROL); 121static int gt_clockevent_set_periodic(struct clock_event_device *evt)
123 ctrl &= ~(GT_CONTROL_COMP_ENABLE | 122{
124 GT_CONTROL_IRQ_ENABLE | GT_CONTROL_AUTO_INC); 123 gt_compare_set(DIV_ROUND_CLOSEST(gt_clk_rate, HZ), 1);
125 writel(ctrl, gt_base + GT_CONTROL); 124 return 0;
126 break;
127 default:
128 break;
129 }
130} 125}
131 126
132static int gt_clockevent_set_next_event(unsigned long evt, 127static int gt_clockevent_set_next_event(unsigned long evt,
@@ -155,7 +150,7 @@ static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id)
155 * the Global Timer flag _after_ having incremented 150 * the Global Timer flag _after_ having incremented
156 * the Comparator register value to a higher value. 151 * the Comparator register value to a higher value.
157 */ 152 */
158 if (evt->mode == CLOCK_EVT_MODE_ONESHOT) 153 if (clockevent_state_oneshot(evt))
159 gt_compare_set(ULONG_MAX, 0); 154 gt_compare_set(ULONG_MAX, 0);
160 155
161 writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS); 156 writel_relaxed(GT_INT_STATUS_EVENT_FLAG, gt_base + GT_INT_STATUS);
@@ -171,7 +166,9 @@ static int gt_clockevents_init(struct clock_event_device *clk)
171 clk->name = "arm_global_timer"; 166 clk->name = "arm_global_timer";
172 clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | 167 clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT |
173 CLOCK_EVT_FEAT_PERCPU; 168 CLOCK_EVT_FEAT_PERCPU;
174 clk->set_mode = gt_clockevent_set_mode; 169 clk->set_state_shutdown = gt_clockevent_shutdown;
170 clk->set_state_periodic = gt_clockevent_set_periodic;
171 clk->set_state_oneshot = gt_clockevent_shutdown;
175 clk->set_next_event = gt_clockevent_set_next_event; 172 clk->set_next_event = gt_clockevent_set_next_event;
176 clk->cpumask = cpumask_of(cpu); 173 clk->cpumask = cpumask_of(cpu);
177 clk->rating = 300; 174 clk->rating = 300;
@@ -184,7 +181,7 @@ static int gt_clockevents_init(struct clock_event_device *clk)
184 181
185static void gt_clockevents_stop(struct clock_event_device *clk) 182static void gt_clockevents_stop(struct clock_event_device *clk)
186{ 183{
187 gt_clockevent_set_mode(CLOCK_EVT_MODE_UNUSED, clk); 184 gt_clockevent_shutdown(clk);
188 disable_percpu_irq(clk->irq); 185 disable_percpu_irq(clk->irq);
189} 186}
190 187