blob: b28970ca4a7a985f7d8aec23c3c7049851b68eae [file] [log] [blame]
Vineet Guptad8005e62013-01-18 15:12:18 +05301/*
Vineet Guptac4c9a042016-10-31 13:46:38 -07002 * Copyright (C) 2016-17 Synopsys, Inc. (www.synopsys.com)
Vineet Guptad8005e62013-01-18 15:12:18 +05303 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
Vineet Guptad8005e62013-01-18 15:12:18 +05308 */
9
Vineet Guptac4c9a042016-10-31 13:46:38 -070010/* ARC700 has two 32bit independent prog Timers: TIMER0 and TIMER1, Each can be
11 * programmed to go from @count to @limit and optionally interrupt.
12 * We've designated TIMER0 for clockevents and TIMER1 for clocksource
Vineet Guptad8005e62013-01-18 15:12:18 +053013 *
Vineet Guptac4c9a042016-10-31 13:46:38 -070014 * ARCv2 based HS38 cores have RTC (in-core) and GFRC (inside ARConnect/MCIP)
15 * which are suitable for UP and SMP based clocksources respectively
Vineet Guptad8005e62013-01-18 15:12:18 +053016 */
17
Vineet Guptad8005e62013-01-18 15:12:18 +053018#include <linux/interrupt.h>
Noam Camus69fbd092016-01-14 12:20:08 +053019#include <linux/clk.h>
20#include <linux/clk-provider.h>
Vineet Guptad8005e62013-01-18 15:12:18 +053021#include <linux/clocksource.h>
22#include <linux/clockchips.h>
Noam Camuseec3c582016-01-01 15:48:49 +053023#include <linux/cpu.h>
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053024#include <linux/of.h>
25#include <linux/of_irq.h>
Alexey Brodkinbf75d932018-11-19 14:29:17 +030026#include <linux/sched_clock.h>
Vineet Guptad8005e62013-01-18 15:12:18 +053027
Vineet Guptab26c2e32016-10-31 13:06:19 -070028#include <soc/arc/timers.h>
Vineet Gupta2d7f5c42016-10-31 11:27:08 -070029#include <soc/arc/mcip.h>
Vineet Gupta72d72882014-12-24 18:41:55 +053030
Vineet Guptad8005e62013-01-18 15:12:18 +053031
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053032static unsigned long arc_timer_freq;
33
34static int noinline arc_get_timer_clk(struct device_node *node)
35{
36 struct clk *clk;
37 int ret;
38
39 clk = of_clk_get(node, 0);
40 if (IS_ERR(clk)) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +010041 pr_err("timer missing clk\n");
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053042 return PTR_ERR(clk);
43 }
44
45 ret = clk_prepare_enable(clk);
46 if (ret) {
47 pr_err("Couldn't enable parent clk\n");
48 return ret;
49 }
50
51 arc_timer_freq = clk_get_rate(clk);
52
53 return 0;
54}
55
Vineet Guptad8005e62013-01-18 15:12:18 +053056/********** Clock Source Device *********/
57
Vineet Gupta04421422016-10-31 14:26:41 -070058#ifdef CONFIG_ARC_TIMERS_64BIT
Vineet Gupta72d72882014-12-24 18:41:55 +053059
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +010060static u64 arc_read_gfrc(struct clocksource *cs)
Vineet Gupta72d72882014-12-24 18:41:55 +053061{
62 unsigned long flags;
Vineet Gupta2cd690e2016-11-03 11:38:52 -070063 u32 l, h;
Vineet Gupta72d72882014-12-24 18:41:55 +053064
Eugeniy Paltsev6bd95492018-04-19 18:53:05 +030065 /*
66 * From a programming model pov, there seems to be just one instance of
67 * MCIP_CMD/MCIP_READBACK however micro-architecturally there's
68 * an instance PER ARC CORE (not per cluster), and there are dedicated
69 * hardware decode logic (per core) inside ARConnect to handle
70 * simultaneous read/write accesses from cores via those two registers.
71 * So several concurrent commands to ARConnect are OK if they are
72 * trying to access two different sub-components (like GFRC,
73 * inter-core interrupt, etc...). HW also supports simultaneously
74 * accessing GFRC by multiple cores.
75 * That's why it is safe to disable hard interrupts on the local CPU
76 * before access to GFRC instead of taking global MCIP spinlock
77 * defined in arch/arc/kernel/mcip.c
78 */
Vineet Gupta72d72882014-12-24 18:41:55 +053079 local_irq_save(flags);
80
Vineet Guptad584f0f2016-01-22 14:27:50 +053081 __mcip_cmd(CMD_GFRC_READ_LO, 0);
Vineet Gupta2cd690e2016-11-03 11:38:52 -070082 l = read_aux_reg(ARC_REG_MCIP_READBACK);
Vineet Gupta72d72882014-12-24 18:41:55 +053083
Vineet Guptad584f0f2016-01-22 14:27:50 +053084 __mcip_cmd(CMD_GFRC_READ_HI, 0);
Vineet Gupta2cd690e2016-11-03 11:38:52 -070085 h = read_aux_reg(ARC_REG_MCIP_READBACK);
Vineet Gupta72d72882014-12-24 18:41:55 +053086
87 local_irq_restore(flags);
88
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +010089 return (((u64)h) << 32) | l;
Vineet Gupta72d72882014-12-24 18:41:55 +053090}
91
Alexey Brodkinbf75d932018-11-19 14:29:17 +030092static notrace u64 arc_gfrc_clock_read(void)
93{
94 return arc_read_gfrc(NULL);
95}
96
Vineet Guptae608b532016-01-01 18:05:48 +053097static struct clocksource arc_counter_gfrc = {
Vineet Guptad584f0f2016-01-22 14:27:50 +053098 .name = "ARConnect GFRC",
Vineet Gupta72d72882014-12-24 18:41:55 +053099 .rating = 400,
Vineet Guptae608b532016-01-01 18:05:48 +0530100 .read = arc_read_gfrc,
Vineet Gupta72d72882014-12-24 18:41:55 +0530101 .mask = CLOCKSOURCE_MASK(64),
102 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
103};
104
Daniel Lezcano43d75602016-06-15 14:50:12 +0200105static int __init arc_cs_setup_gfrc(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530106{
Vineet Guptaec7cb872016-10-31 13:02:31 -0700107 struct mcip_bcr mp;
Vineet Guptae608b532016-01-01 18:05:48 +0530108 int ret;
109
Vineet Guptaec7cb872016-10-31 13:02:31 -0700110 READ_BCR(ARC_REG_MCIP_BCR, mp);
111 if (!mp.gfrc) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100112 pr_warn("Global-64-bit-Ctr clocksource not detected\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200113 return -ENXIO;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700114 }
Vineet Guptae608b532016-01-01 18:05:48 +0530115
116 ret = arc_get_timer_clk(node);
117 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200118 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530119
Alexey Brodkinbf75d932018-11-19 14:29:17 +0300120 sched_clock_register(arc_gfrc_clock_read, 64, arc_timer_freq);
121
Daniel Lezcano43d75602016-06-15 14:50:12 +0200122 return clocksource_register_hz(&arc_counter_gfrc, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530123}
Daniel Lezcano17273392017-05-26 16:56:11 +0200124TIMER_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc);
Vineet Guptae608b532016-01-01 18:05:48 +0530125
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530126#define AUX_RTC_CTRL 0x103
127#define AUX_RTC_LOW 0x104
128#define AUX_RTC_HIGH 0x105
129
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100130static u64 arc_read_rtc(struct clocksource *cs)
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530131{
132 unsigned long status;
Vineet Gupta2cd690e2016-11-03 11:38:52 -0700133 u32 l, h;
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530134
Vineet Gupta922cc172016-10-31 14:09:52 -0700135 /*
136 * hardware has an internal state machine which tracks readout of
137 * low/high and updates the CTRL.status if
138 * - interrupt/exception taken between the two reads
139 * - high increments after low has been read
140 */
141 do {
Vineet Gupta2cd690e2016-11-03 11:38:52 -0700142 l = read_aux_reg(AUX_RTC_LOW);
143 h = read_aux_reg(AUX_RTC_HIGH);
Vineet Gupta922cc172016-10-31 14:09:52 -0700144 status = read_aux_reg(AUX_RTC_CTRL);
145 } while (!(status & _BITUL(31)));
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530146
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100147 return (((u64)h) << 32) | l;
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530148}
149
Alexey Brodkinbf75d932018-11-19 14:29:17 +0300150static notrace u64 arc_rtc_clock_read(void)
151{
152 return arc_read_rtc(NULL);
153}
154
Vineet Guptae608b532016-01-01 18:05:48 +0530155static struct clocksource arc_counter_rtc = {
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530156 .name = "ARCv2 RTC",
157 .rating = 350,
Vineet Guptae608b532016-01-01 18:05:48 +0530158 .read = arc_read_rtc,
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530159 .mask = CLOCKSOURCE_MASK(64),
160 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
161};
162
Daniel Lezcano43d75602016-06-15 14:50:12 +0200163static int __init arc_cs_setup_rtc(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530164{
Vineet Guptaec7cb872016-10-31 13:02:31 -0700165 struct bcr_timer timer;
Vineet Guptae608b532016-01-01 18:05:48 +0530166 int ret;
167
Vineet Guptaec7cb872016-10-31 13:02:31 -0700168 READ_BCR(ARC_REG_TIMERS_BCR, timer);
169 if (!timer.rtc) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100170 pr_warn("Local-64-bit-Ctr clocksource not detected\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200171 return -ENXIO;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700172 }
Vineet Guptae608b532016-01-01 18:05:48 +0530173
174 /* Local to CPU hence not usable in SMP */
Vineet Guptaec7cb872016-10-31 13:02:31 -0700175 if (IS_ENABLED(CONFIG_SMP)) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100176 pr_warn("Local-64-bit-Ctr not usable in SMP\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200177 return -EINVAL;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700178 }
Vineet Guptae608b532016-01-01 18:05:48 +0530179
180 ret = arc_get_timer_clk(node);
181 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200182 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530183
184 write_aux_reg(AUX_RTC_CTRL, 1);
185
Alexey Brodkinbf75d932018-11-19 14:29:17 +0300186 sched_clock_register(arc_rtc_clock_read, 64, arc_timer_freq);
187
Daniel Lezcano43d75602016-06-15 14:50:12 +0200188 return clocksource_register_hz(&arc_counter_rtc, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530189}
Daniel Lezcano17273392017-05-26 16:56:11 +0200190TIMER_OF_DECLARE(arc_rtc, "snps,archs-timer-rtc", arc_cs_setup_rtc);
Vineet Guptae608b532016-01-01 18:05:48 +0530191
192#endif
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530193
Vineet Guptad8005e62013-01-18 15:12:18 +0530194/*
Vineet Guptae608b532016-01-01 18:05:48 +0530195 * 32bit TIMER1 to keep counting monotonically and wraparound
Vineet Guptad8005e62013-01-18 15:12:18 +0530196 */
Vineet Guptad8005e62013-01-18 15:12:18 +0530197
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100198static u64 arc_read_timer1(struct clocksource *cs)
Vineet Guptad8005e62013-01-18 15:12:18 +0530199{
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100200 return (u64) read_aux_reg(ARC_REG_TIMER1_CNT);
Vineet Guptad8005e62013-01-18 15:12:18 +0530201}
202
Alexey Brodkinbf75d932018-11-19 14:29:17 +0300203static notrace u64 arc_timer1_clock_read(void)
204{
205 return arc_read_timer1(NULL);
206}
207
Vineet Guptae608b532016-01-01 18:05:48 +0530208static struct clocksource arc_counter_timer1 = {
Vineet Guptad8005e62013-01-18 15:12:18 +0530209 .name = "ARC Timer1",
210 .rating = 300,
Vineet Guptae608b532016-01-01 18:05:48 +0530211 .read = arc_read_timer1,
Vineet Guptad8005e62013-01-18 15:12:18 +0530212 .mask = CLOCKSOURCE_MASK(32),
213 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
214};
215
Daniel Lezcano43d75602016-06-15 14:50:12 +0200216static int __init arc_cs_setup_timer1(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530217{
218 int ret;
219
220 /* Local to CPU hence not usable in SMP */
221 if (IS_ENABLED(CONFIG_SMP))
Daniel Lezcano43d75602016-06-15 14:50:12 +0200222 return -EINVAL;
Vineet Guptae608b532016-01-01 18:05:48 +0530223
224 ret = arc_get_timer_clk(node);
225 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200226 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530227
Vineet Guptab26c2e32016-10-31 13:06:19 -0700228 write_aux_reg(ARC_REG_TIMER1_LIMIT, ARC_TIMERN_MAX);
Vineet Guptae608b532016-01-01 18:05:48 +0530229 write_aux_reg(ARC_REG_TIMER1_CNT, 0);
230 write_aux_reg(ARC_REG_TIMER1_CTRL, TIMER_CTRL_NH);
231
Alexey Brodkinbf75d932018-11-19 14:29:17 +0300232 sched_clock_register(arc_timer1_clock_read, 32, arc_timer_freq);
233
Daniel Lezcano43d75602016-06-15 14:50:12 +0200234 return clocksource_register_hz(&arc_counter_timer1, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530235}
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530236
Vineet Guptad8005e62013-01-18 15:12:18 +0530237/********** Clock Event Device *********/
238
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530239static int arc_timer_irq;
Noam Camuseec3c582016-01-01 15:48:49 +0530240
Vineet Guptad8005e62013-01-18 15:12:18 +0530241/*
Vineet Guptac9a98e182014-06-25 17:14:03 +0530242 * Arm the timer to interrupt after @cycles
Vineet Guptad8005e62013-01-18 15:12:18 +0530243 * The distinction for oneshot/periodic is done in arc_event_timer_ack() below
244 */
Vineet Guptac9a98e182014-06-25 17:14:03 +0530245static void arc_timer_event_setup(unsigned int cycles)
Vineet Guptad8005e62013-01-18 15:12:18 +0530246{
Vineet Guptac9a98e182014-06-25 17:14:03 +0530247 write_aux_reg(ARC_REG_TIMER0_LIMIT, cycles);
Vineet Guptad8005e62013-01-18 15:12:18 +0530248 write_aux_reg(ARC_REG_TIMER0_CNT, 0); /* start from 0 */
249
250 write_aux_reg(ARC_REG_TIMER0_CTRL, TIMER_CTRL_IE | TIMER_CTRL_NH);
251}
252
Vineet Guptad8005e62013-01-18 15:12:18 +0530253
254static int arc_clkevent_set_next_event(unsigned long delta,
255 struct clock_event_device *dev)
256{
257 arc_timer_event_setup(delta);
258 return 0;
259}
260
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530261static int arc_clkevent_set_periodic(struct clock_event_device *dev)
Vineet Guptad8005e62013-01-18 15:12:18 +0530262{
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530263 /*
264 * At X Hz, 1 sec = 1000ms -> X cycles;
265 * 10ms -> X / 100 cycles
266 */
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530267 arc_timer_event_setup(arc_timer_freq / HZ);
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530268 return 0;
Vineet Guptad8005e62013-01-18 15:12:18 +0530269}
270
271static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530272 .name = "ARC Timer0",
273 .features = CLOCK_EVT_FEAT_ONESHOT |
274 CLOCK_EVT_FEAT_PERIODIC,
275 .rating = 300,
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530276 .set_next_event = arc_clkevent_set_next_event,
277 .set_state_periodic = arc_clkevent_set_periodic,
Vineet Guptad8005e62013-01-18 15:12:18 +0530278};
279
280static irqreturn_t timer_irq_handler(int irq, void *dev_id)
281{
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530282 /*
283 * Note that generic IRQ core could have passed @evt for @dev_id if
284 * irq_set_chip_and_handler() asked for handle_percpu_devid_irq()
285 */
286 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530287 int irq_reenable = clockevent_state_periodic(evt);
Vineet Guptad8005e62013-01-18 15:12:18 +0530288
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530289 /*
Vineet Guptaa4f53852018-02-21 11:31:31 -0800290 * 1. ACK the interrupt
291 * - For ARC700, any write to CTRL reg ACKs it, so just rewrite
292 * Count when [N]ot [H]alted bit.
293 * - For HS3x, it is a bit subtle. On taken count-down interrupt,
294 * IP bit [3] is set, which needs to be cleared for ACK'ing.
295 * The write below can only update the other two bits, hence
296 * explicitly clears IP bit
297 * 2. Re-arm interrupt if periodic by writing to IE bit [0]
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530298 */
299 write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | TIMER_CTRL_NH);
300
301 evt->event_handler(evt);
302
Vineet Guptad8005e62013-01-18 15:12:18 +0530303 return IRQ_HANDLED;
304}
305
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000306
307static int arc_timer_starting_cpu(unsigned int cpu)
Vineet Guptad8005e62013-01-18 15:12:18 +0530308{
Vineet Gupta2d4899f2014-05-08 14:06:38 +0530309 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
Vineet Guptad8005e62013-01-18 15:12:18 +0530310
Noam Camuseec3c582016-01-01 15:48:49 +0530311 evt->cpumask = cpumask_of(smp_processor_id());
312
Vineet Guptab26c2e32016-10-31 13:06:19 -0700313 clockevents_config_and_register(evt, arc_timer_freq, 0, ARC_TIMERN_MAX);
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000314 enable_percpu_irq(arc_timer_irq, 0);
315 return 0;
Noam Camuseec3c582016-01-01 15:48:49 +0530316}
317
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000318static int arc_timer_dying_cpu(unsigned int cpu)
319{
320 disable_percpu_irq(arc_timer_irq);
321 return 0;
322}
Noam Camuseec3c582016-01-01 15:48:49 +0530323
324/*
325 * clockevent setup for boot CPU
326 */
Daniel Lezcano43d75602016-06-15 14:50:12 +0200327static int __init arc_clockevent_setup(struct device_node *node)
Noam Camuseec3c582016-01-01 15:48:49 +0530328{
329 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
330 int ret;
331
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530332 arc_timer_irq = irq_of_parse_and_map(node, 0);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200333 if (arc_timer_irq <= 0) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100334 pr_err("clockevent: missing irq\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200335 return -EINVAL;
336 }
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530337
338 ret = arc_get_timer_clk(node);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200339 if (ret) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100340 pr_err("clockevent: missing clk\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200341 return ret;
342 }
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530343
Noam Camuseec3c582016-01-01 15:48:49 +0530344 /* Needs apriori irq_set_percpu_devid() done in intc map function */
345 ret = request_percpu_irq(arc_timer_irq, timer_irq_handler,
346 "Timer0 (per-cpu-tick)", evt);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200347 if (ret) {
348 pr_err("clockevent: unable to request irq\n");
349 return ret;
350 }
Vineet Gupta56957942016-01-28 12:56:03 +0530351
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000352 ret = cpuhp_setup_state(CPUHP_AP_ARC_TIMER_STARTING,
Thomas Gleixner73c1b412016-12-21 20:19:54 +0100353 "clockevents/arc/timer:starting",
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000354 arc_timer_starting_cpu,
355 arc_timer_dying_cpu);
356 if (ret) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100357 pr_err("Failed to setup hotplug state\n");
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000358 return ret;
359 }
Daniel Lezcano43d75602016-06-15 14:50:12 +0200360 return 0;
Vineet Guptad8005e62013-01-18 15:12:18 +0530361}
Vineet Guptae608b532016-01-01 18:05:48 +0530362
Daniel Lezcano43d75602016-06-15 14:50:12 +0200363static int __init arc_of_timer_init(struct device_node *np)
Vineet Guptae608b532016-01-01 18:05:48 +0530364{
365 static int init_count = 0;
Daniel Lezcano43d75602016-06-15 14:50:12 +0200366 int ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530367
368 if (!init_count) {
369 init_count = 1;
Daniel Lezcano43d75602016-06-15 14:50:12 +0200370 ret = arc_clockevent_setup(np);
Vineet Guptae608b532016-01-01 18:05:48 +0530371 } else {
Daniel Lezcano43d75602016-06-15 14:50:12 +0200372 ret = arc_cs_setup_timer1(np);
Vineet Guptae608b532016-01-01 18:05:48 +0530373 }
Daniel Lezcano43d75602016-06-15 14:50:12 +0200374
375 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530376}
Daniel Lezcano17273392017-05-26 16:56:11 +0200377TIMER_OF_DECLARE(arc_clkevt, "snps,arc-timer", arc_of_timer_init);