blob: ebfbccefc7b31d82ee2543aa050e3a8d95146ae5 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Vineet Guptad8005e62013-01-18 15:12:18 +05302/*
Vineet Guptac4c9a042016-10-31 13:46:38 -07003 * Copyright (C) 2016-17 Synopsys, Inc. (www.synopsys.com)
Vineet Guptad8005e62013-01-18 15:12:18 +05304 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
Vineet Guptad8005e62013-01-18 15:12:18 +05305 */
6
Vineet Guptac4c9a042016-10-31 13:46:38 -07007/* ARC700 has two 32bit independent prog Timers: TIMER0 and TIMER1, Each can be
8 * programmed to go from @count to @limit and optionally interrupt.
9 * We've designated TIMER0 for clockevents and TIMER1 for clocksource
Vineet Guptad8005e62013-01-18 15:12:18 +053010 *
Vineet Guptac4c9a042016-10-31 13:46:38 -070011 * ARCv2 based HS38 cores have RTC (in-core) and GFRC (inside ARConnect/MCIP)
12 * which are suitable for UP and SMP based clocksources respectively
Vineet Guptad8005e62013-01-18 15:12:18 +053013 */
14
Vineet Guptad8005e62013-01-18 15:12:18 +053015#include <linux/interrupt.h>
Noam Camus69fbd092016-01-14 12:20:08 +053016#include <linux/clk.h>
17#include <linux/clk-provider.h>
Vineet Guptad8005e62013-01-18 15:12:18 +053018#include <linux/clocksource.h>
19#include <linux/clockchips.h>
Noam Camuseec3c582016-01-01 15:48:49 +053020#include <linux/cpu.h>
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053021#include <linux/of.h>
22#include <linux/of_irq.h>
Alexey Brodkinbf287602018-11-19 14:29:17 +030023#include <linux/sched_clock.h>
Vineet Guptad8005e62013-01-18 15:12:18 +053024
Vineet Guptab26c2e32016-10-31 13:06:19 -070025#include <soc/arc/timers.h>
Vineet Gupta2d7f5c42016-10-31 11:27:08 -070026#include <soc/arc/mcip.h>
Vineet Gupta72d72882014-12-24 18:41:55 +053027
Vineet Guptad8005e62013-01-18 15:12:18 +053028
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053029static unsigned long arc_timer_freq;
30
31static int noinline arc_get_timer_clk(struct device_node *node)
32{
33 struct clk *clk;
34 int ret;
35
36 clk = of_clk_get(node, 0);
37 if (IS_ERR(clk)) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +010038 pr_err("timer missing clk\n");
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053039 return PTR_ERR(clk);
40 }
41
42 ret = clk_prepare_enable(clk);
43 if (ret) {
44 pr_err("Couldn't enable parent clk\n");
45 return ret;
46 }
47
48 arc_timer_freq = clk_get_rate(clk);
49
50 return 0;
51}
52
Vineet Guptad8005e62013-01-18 15:12:18 +053053/********** Clock Source Device *********/
54
Vineet Gupta04421422016-10-31 14:26:41 -070055#ifdef CONFIG_ARC_TIMERS_64BIT
Vineet Gupta72d72882014-12-24 18:41:55 +053056
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +010057static u64 arc_read_gfrc(struct clocksource *cs)
Vineet Gupta72d72882014-12-24 18:41:55 +053058{
59 unsigned long flags;
Vineet Gupta2cd690e2016-11-03 11:38:52 -070060 u32 l, h;
Vineet Gupta72d72882014-12-24 18:41:55 +053061
Eugeniy Paltsev6bd95492018-04-19 18:53:05 +030062 /*
63 * From a programming model pov, there seems to be just one instance of
64 * MCIP_CMD/MCIP_READBACK however micro-architecturally there's
65 * an instance PER ARC CORE (not per cluster), and there are dedicated
66 * hardware decode logic (per core) inside ARConnect to handle
67 * simultaneous read/write accesses from cores via those two registers.
68 * So several concurrent commands to ARConnect are OK if they are
69 * trying to access two different sub-components (like GFRC,
70 * inter-core interrupt, etc...). HW also supports simultaneously
71 * accessing GFRC by multiple cores.
72 * That's why it is safe to disable hard interrupts on the local CPU
73 * before access to GFRC instead of taking global MCIP spinlock
74 * defined in arch/arc/kernel/mcip.c
75 */
Vineet Gupta72d72882014-12-24 18:41:55 +053076 local_irq_save(flags);
77
Vineet Guptad584f0f2016-01-22 14:27:50 +053078 __mcip_cmd(CMD_GFRC_READ_LO, 0);
Vineet Gupta2cd690e2016-11-03 11:38:52 -070079 l = read_aux_reg(ARC_REG_MCIP_READBACK);
Vineet Gupta72d72882014-12-24 18:41:55 +053080
Vineet Guptad584f0f2016-01-22 14:27:50 +053081 __mcip_cmd(CMD_GFRC_READ_HI, 0);
Vineet Gupta2cd690e2016-11-03 11:38:52 -070082 h = read_aux_reg(ARC_REG_MCIP_READBACK);
Vineet Gupta72d72882014-12-24 18:41:55 +053083
84 local_irq_restore(flags);
85
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +010086 return (((u64)h) << 32) | l;
Vineet Gupta72d72882014-12-24 18:41:55 +053087}
88
Alexey Brodkinbf287602018-11-19 14:29:17 +030089static notrace u64 arc_gfrc_clock_read(void)
90{
91 return arc_read_gfrc(NULL);
92}
93
Vineet Guptae608b532016-01-01 18:05:48 +053094static struct clocksource arc_counter_gfrc = {
Vineet Guptad584f0f2016-01-22 14:27:50 +053095 .name = "ARConnect GFRC",
Vineet Gupta72d72882014-12-24 18:41:55 +053096 .rating = 400,
Vineet Guptae608b532016-01-01 18:05:48 +053097 .read = arc_read_gfrc,
Vineet Gupta72d72882014-12-24 18:41:55 +053098 .mask = CLOCKSOURCE_MASK(64),
99 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
100};
101
Daniel Lezcano43d75602016-06-15 14:50:12 +0200102static int __init arc_cs_setup_gfrc(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530103{
Vineet Guptaec7cb872016-10-31 13:02:31 -0700104 struct mcip_bcr mp;
Vineet Guptae608b532016-01-01 18:05:48 +0530105 int ret;
106
Vineet Guptaec7cb872016-10-31 13:02:31 -0700107 READ_BCR(ARC_REG_MCIP_BCR, mp);
108 if (!mp.gfrc) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100109 pr_warn("Global-64-bit-Ctr clocksource not detected\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200110 return -ENXIO;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700111 }
Vineet Guptae608b532016-01-01 18:05:48 +0530112
113 ret = arc_get_timer_clk(node);
114 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200115 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530116
Alexey Brodkinbf287602018-11-19 14:29:17 +0300117 sched_clock_register(arc_gfrc_clock_read, 64, arc_timer_freq);
118
Daniel Lezcano43d75602016-06-15 14:50:12 +0200119 return clocksource_register_hz(&arc_counter_gfrc, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530120}
Daniel Lezcano17273392017-05-26 16:56:11 +0200121TIMER_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc);
Vineet Guptae608b532016-01-01 18:05:48 +0530122
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530123#define AUX_RTC_CTRL 0x103
124#define AUX_RTC_LOW 0x104
125#define AUX_RTC_HIGH 0x105
126
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100127static u64 arc_read_rtc(struct clocksource *cs)
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530128{
129 unsigned long status;
Vineet Gupta2cd690e2016-11-03 11:38:52 -0700130 u32 l, h;
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530131
Vineet Gupta922cc172016-10-31 14:09:52 -0700132 /*
133 * hardware has an internal state machine which tracks readout of
134 * low/high and updates the CTRL.status if
135 * - interrupt/exception taken between the two reads
136 * - high increments after low has been read
137 */
138 do {
Vineet Gupta2cd690e2016-11-03 11:38:52 -0700139 l = read_aux_reg(AUX_RTC_LOW);
140 h = read_aux_reg(AUX_RTC_HIGH);
Vineet Gupta922cc172016-10-31 14:09:52 -0700141 status = read_aux_reg(AUX_RTC_CTRL);
142 } while (!(status & _BITUL(31)));
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530143
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100144 return (((u64)h) << 32) | l;
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530145}
146
Alexey Brodkinbf287602018-11-19 14:29:17 +0300147static notrace u64 arc_rtc_clock_read(void)
148{
149 return arc_read_rtc(NULL);
150}
151
Vineet Guptae608b532016-01-01 18:05:48 +0530152static struct clocksource arc_counter_rtc = {
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530153 .name = "ARCv2 RTC",
154 .rating = 350,
Vineet Guptae608b532016-01-01 18:05:48 +0530155 .read = arc_read_rtc,
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530156 .mask = CLOCKSOURCE_MASK(64),
157 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
158};
159
Daniel Lezcano43d75602016-06-15 14:50:12 +0200160static int __init arc_cs_setup_rtc(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530161{
Vineet Guptaec7cb872016-10-31 13:02:31 -0700162 struct bcr_timer timer;
Vineet Guptae608b532016-01-01 18:05:48 +0530163 int ret;
164
Vineet Guptaec7cb872016-10-31 13:02:31 -0700165 READ_BCR(ARC_REG_TIMERS_BCR, timer);
166 if (!timer.rtc) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100167 pr_warn("Local-64-bit-Ctr clocksource not detected\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200168 return -ENXIO;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700169 }
Vineet Guptae608b532016-01-01 18:05:48 +0530170
171 /* Local to CPU hence not usable in SMP */
Vineet Guptaec7cb872016-10-31 13:02:31 -0700172 if (IS_ENABLED(CONFIG_SMP)) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100173 pr_warn("Local-64-bit-Ctr not usable in SMP\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200174 return -EINVAL;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700175 }
Vineet Guptae608b532016-01-01 18:05:48 +0530176
177 ret = arc_get_timer_clk(node);
178 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200179 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530180
181 write_aux_reg(AUX_RTC_CTRL, 1);
182
Alexey Brodkinbf287602018-11-19 14:29:17 +0300183 sched_clock_register(arc_rtc_clock_read, 64, arc_timer_freq);
184
Daniel Lezcano43d75602016-06-15 14:50:12 +0200185 return clocksource_register_hz(&arc_counter_rtc, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530186}
Daniel Lezcano17273392017-05-26 16:56:11 +0200187TIMER_OF_DECLARE(arc_rtc, "snps,archs-timer-rtc", arc_cs_setup_rtc);
Vineet Guptae608b532016-01-01 18:05:48 +0530188
189#endif
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530190
Vineet Guptad8005e62013-01-18 15:12:18 +0530191/*
Vineet Guptae608b532016-01-01 18:05:48 +0530192 * 32bit TIMER1 to keep counting monotonically and wraparound
Vineet Guptad8005e62013-01-18 15:12:18 +0530193 */
Vineet Guptad8005e62013-01-18 15:12:18 +0530194
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100195static u64 arc_read_timer1(struct clocksource *cs)
Vineet Guptad8005e62013-01-18 15:12:18 +0530196{
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100197 return (u64) read_aux_reg(ARC_REG_TIMER1_CNT);
Vineet Guptad8005e62013-01-18 15:12:18 +0530198}
199
Alexey Brodkinbf287602018-11-19 14:29:17 +0300200static notrace u64 arc_timer1_clock_read(void)
201{
202 return arc_read_timer1(NULL);
203}
204
Vineet Guptae608b532016-01-01 18:05:48 +0530205static struct clocksource arc_counter_timer1 = {
Vineet Guptad8005e62013-01-18 15:12:18 +0530206 .name = "ARC Timer1",
207 .rating = 300,
Vineet Guptae608b532016-01-01 18:05:48 +0530208 .read = arc_read_timer1,
Vineet Guptad8005e62013-01-18 15:12:18 +0530209 .mask = CLOCKSOURCE_MASK(32),
210 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
211};
212
Daniel Lezcano43d75602016-06-15 14:50:12 +0200213static int __init arc_cs_setup_timer1(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530214{
215 int ret;
216
217 /* Local to CPU hence not usable in SMP */
218 if (IS_ENABLED(CONFIG_SMP))
Daniel Lezcano43d75602016-06-15 14:50:12 +0200219 return -EINVAL;
Vineet Guptae608b532016-01-01 18:05:48 +0530220
221 ret = arc_get_timer_clk(node);
222 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200223 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530224
Vineet Guptab26c2e32016-10-31 13:06:19 -0700225 write_aux_reg(ARC_REG_TIMER1_LIMIT, ARC_TIMERN_MAX);
Vineet Guptae608b532016-01-01 18:05:48 +0530226 write_aux_reg(ARC_REG_TIMER1_CNT, 0);
227 write_aux_reg(ARC_REG_TIMER1_CTRL, TIMER_CTRL_NH);
228
Alexey Brodkinbf287602018-11-19 14:29:17 +0300229 sched_clock_register(arc_timer1_clock_read, 32, arc_timer_freq);
230
Daniel Lezcano43d75602016-06-15 14:50:12 +0200231 return clocksource_register_hz(&arc_counter_timer1, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530232}
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530233
Vineet Guptad8005e62013-01-18 15:12:18 +0530234/********** Clock Event Device *********/
235
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530236static int arc_timer_irq;
Noam Camuseec3c582016-01-01 15:48:49 +0530237
Vineet Guptad8005e62013-01-18 15:12:18 +0530238/*
Vineet Guptac9a98e182014-06-25 17:14:03 +0530239 * Arm the timer to interrupt after @cycles
Vineet Guptad8005e62013-01-18 15:12:18 +0530240 * The distinction for oneshot/periodic is done in arc_event_timer_ack() below
241 */
Vineet Guptac9a98e182014-06-25 17:14:03 +0530242static void arc_timer_event_setup(unsigned int cycles)
Vineet Guptad8005e62013-01-18 15:12:18 +0530243{
Vineet Guptac9a98e182014-06-25 17:14:03 +0530244 write_aux_reg(ARC_REG_TIMER0_LIMIT, cycles);
Vineet Guptad8005e62013-01-18 15:12:18 +0530245 write_aux_reg(ARC_REG_TIMER0_CNT, 0); /* start from 0 */
246
247 write_aux_reg(ARC_REG_TIMER0_CTRL, TIMER_CTRL_IE | TIMER_CTRL_NH);
248}
249
Vineet Guptad8005e62013-01-18 15:12:18 +0530250
251static int arc_clkevent_set_next_event(unsigned long delta,
252 struct clock_event_device *dev)
253{
254 arc_timer_event_setup(delta);
255 return 0;
256}
257
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530258static int arc_clkevent_set_periodic(struct clock_event_device *dev)
Vineet Guptad8005e62013-01-18 15:12:18 +0530259{
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530260 /*
261 * At X Hz, 1 sec = 1000ms -> X cycles;
262 * 10ms -> X / 100 cycles
263 */
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530264 arc_timer_event_setup(arc_timer_freq / HZ);
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530265 return 0;
Vineet Guptad8005e62013-01-18 15:12:18 +0530266}
267
268static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530269 .name = "ARC Timer0",
270 .features = CLOCK_EVT_FEAT_ONESHOT |
271 CLOCK_EVT_FEAT_PERIODIC,
272 .rating = 300,
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530273 .set_next_event = arc_clkevent_set_next_event,
274 .set_state_periodic = arc_clkevent_set_periodic,
Vineet Guptad8005e62013-01-18 15:12:18 +0530275};
276
277static irqreturn_t timer_irq_handler(int irq, void *dev_id)
278{
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530279 /*
280 * Note that generic IRQ core could have passed @evt for @dev_id if
281 * irq_set_chip_and_handler() asked for handle_percpu_devid_irq()
282 */
283 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530284 int irq_reenable = clockevent_state_periodic(evt);
Vineet Guptad8005e62013-01-18 15:12:18 +0530285
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530286 /*
Vineet Guptaa4f53852018-02-21 11:31:31 -0800287 * 1. ACK the interrupt
288 * - For ARC700, any write to CTRL reg ACKs it, so just rewrite
289 * Count when [N]ot [H]alted bit.
290 * - For HS3x, it is a bit subtle. On taken count-down interrupt,
291 * IP bit [3] is set, which needs to be cleared for ACK'ing.
292 * The write below can only update the other two bits, hence
293 * explicitly clears IP bit
294 * 2. Re-arm interrupt if periodic by writing to IE bit [0]
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530295 */
296 write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | TIMER_CTRL_NH);
297
298 evt->event_handler(evt);
299
Vineet Guptad8005e62013-01-18 15:12:18 +0530300 return IRQ_HANDLED;
301}
302
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000303
304static int arc_timer_starting_cpu(unsigned int cpu)
Vineet Guptad8005e62013-01-18 15:12:18 +0530305{
Vineet Gupta2d4899f2014-05-08 14:06:38 +0530306 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
Vineet Guptad8005e62013-01-18 15:12:18 +0530307
Noam Camuseec3c582016-01-01 15:48:49 +0530308 evt->cpumask = cpumask_of(smp_processor_id());
309
Vineet Guptab26c2e32016-10-31 13:06:19 -0700310 clockevents_config_and_register(evt, arc_timer_freq, 0, ARC_TIMERN_MAX);
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000311 enable_percpu_irq(arc_timer_irq, 0);
312 return 0;
Noam Camuseec3c582016-01-01 15:48:49 +0530313}
314
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000315static int arc_timer_dying_cpu(unsigned int cpu)
316{
317 disable_percpu_irq(arc_timer_irq);
318 return 0;
319}
Noam Camuseec3c582016-01-01 15:48:49 +0530320
321/*
322 * clockevent setup for boot CPU
323 */
Daniel Lezcano43d75602016-06-15 14:50:12 +0200324static int __init arc_clockevent_setup(struct device_node *node)
Noam Camuseec3c582016-01-01 15:48:49 +0530325{
326 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
327 int ret;
328
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530329 arc_timer_irq = irq_of_parse_and_map(node, 0);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200330 if (arc_timer_irq <= 0) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100331 pr_err("clockevent: missing irq\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200332 return -EINVAL;
333 }
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530334
335 ret = arc_get_timer_clk(node);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200336 if (ret) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100337 pr_err("clockevent: missing clk\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200338 return ret;
339 }
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530340
Noam Camuseec3c582016-01-01 15:48:49 +0530341 /* Needs apriori irq_set_percpu_devid() done in intc map function */
342 ret = request_percpu_irq(arc_timer_irq, timer_irq_handler,
343 "Timer0 (per-cpu-tick)", evt);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200344 if (ret) {
345 pr_err("clockevent: unable to request irq\n");
346 return ret;
347 }
Vineet Gupta56957942016-01-28 12:56:03 +0530348
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000349 ret = cpuhp_setup_state(CPUHP_AP_ARC_TIMER_STARTING,
Thomas Gleixner73c1b412016-12-21 20:19:54 +0100350 "clockevents/arc/timer:starting",
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000351 arc_timer_starting_cpu,
352 arc_timer_dying_cpu);
353 if (ret) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100354 pr_err("Failed to setup hotplug state\n");
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000355 return ret;
356 }
Daniel Lezcano43d75602016-06-15 14:50:12 +0200357 return 0;
Vineet Guptad8005e62013-01-18 15:12:18 +0530358}
Vineet Guptae608b532016-01-01 18:05:48 +0530359
Daniel Lezcano43d75602016-06-15 14:50:12 +0200360static int __init arc_of_timer_init(struct device_node *np)
Vineet Guptae608b532016-01-01 18:05:48 +0530361{
362 static int init_count = 0;
Daniel Lezcano43d75602016-06-15 14:50:12 +0200363 int ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530364
365 if (!init_count) {
366 init_count = 1;
Daniel Lezcano43d75602016-06-15 14:50:12 +0200367 ret = arc_clockevent_setup(np);
Vineet Guptae608b532016-01-01 18:05:48 +0530368 } else {
Daniel Lezcano43d75602016-06-15 14:50:12 +0200369 ret = arc_cs_setup_timer1(np);
Vineet Guptae608b532016-01-01 18:05:48 +0530370 }
Daniel Lezcano43d75602016-06-15 14:50:12 +0200371
372 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530373}
Daniel Lezcano17273392017-05-26 16:56:11 +0200374TIMER_OF_DECLARE(arc_clkevt, "snps,arc-timer", arc_of_timer_init);