blob: cb18524cc13dff8afc3cb173bb4a2241d2148416 [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>
Masahiro Yamada93665ab2019-05-24 14:40:10 +090016#include <linux/bits.h>
Noam Camus69fbd092016-01-14 12:20:08 +053017#include <linux/clk.h>
18#include <linux/clk-provider.h>
Vineet Guptad8005e62013-01-18 15:12:18 +053019#include <linux/clocksource.h>
20#include <linux/clockchips.h>
Noam Camuseec3c582016-01-01 15:48:49 +053021#include <linux/cpu.h>
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053022#include <linux/of.h>
23#include <linux/of_irq.h>
Alexey Brodkinbf287602018-11-19 14:29:17 +030024#include <linux/sched_clock.h>
Vineet Guptad8005e62013-01-18 15:12:18 +053025
Vineet Guptab26c2e32016-10-31 13:06:19 -070026#include <soc/arc/timers.h>
Vineet Gupta2d7f5c42016-10-31 11:27:08 -070027#include <soc/arc/mcip.h>
Vineet Gupta72d72882014-12-24 18:41:55 +053028
Vineet Guptad8005e62013-01-18 15:12:18 +053029
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053030static unsigned long arc_timer_freq;
31
32static int noinline arc_get_timer_clk(struct device_node *node)
33{
34 struct clk *clk;
35 int ret;
36
37 clk = of_clk_get(node, 0);
38 if (IS_ERR(clk)) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +010039 pr_err("timer missing clk\n");
Vineet Gupta77c8d0d2016-01-01 17:58:45 +053040 return PTR_ERR(clk);
41 }
42
43 ret = clk_prepare_enable(clk);
44 if (ret) {
45 pr_err("Couldn't enable parent clk\n");
46 return ret;
47 }
48
49 arc_timer_freq = clk_get_rate(clk);
50
51 return 0;
52}
53
Vineet Guptad8005e62013-01-18 15:12:18 +053054/********** Clock Source Device *********/
55
Vineet Gupta04421422016-10-31 14:26:41 -070056#ifdef CONFIG_ARC_TIMERS_64BIT
Vineet Gupta72d72882014-12-24 18:41:55 +053057
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +010058static u64 arc_read_gfrc(struct clocksource *cs)
Vineet Gupta72d72882014-12-24 18:41:55 +053059{
60 unsigned long flags;
Vineet Gupta2cd690e2016-11-03 11:38:52 -070061 u32 l, h;
Vineet Gupta72d72882014-12-24 18:41:55 +053062
Eugeniy Paltsev6bd95492018-04-19 18:53:05 +030063 /*
64 * From a programming model pov, there seems to be just one instance of
65 * MCIP_CMD/MCIP_READBACK however micro-architecturally there's
66 * an instance PER ARC CORE (not per cluster), and there are dedicated
67 * hardware decode logic (per core) inside ARConnect to handle
68 * simultaneous read/write accesses from cores via those two registers.
69 * So several concurrent commands to ARConnect are OK if they are
70 * trying to access two different sub-components (like GFRC,
71 * inter-core interrupt, etc...). HW also supports simultaneously
72 * accessing GFRC by multiple cores.
73 * That's why it is safe to disable hard interrupts on the local CPU
74 * before access to GFRC instead of taking global MCIP spinlock
75 * defined in arch/arc/kernel/mcip.c
76 */
Vineet Gupta72d72882014-12-24 18:41:55 +053077 local_irq_save(flags);
78
Vineet Guptad584f0f2016-01-22 14:27:50 +053079 __mcip_cmd(CMD_GFRC_READ_LO, 0);
Vineet Gupta2cd690e2016-11-03 11:38:52 -070080 l = read_aux_reg(ARC_REG_MCIP_READBACK);
Vineet Gupta72d72882014-12-24 18:41:55 +053081
Vineet Guptad584f0f2016-01-22 14:27:50 +053082 __mcip_cmd(CMD_GFRC_READ_HI, 0);
Vineet Gupta2cd690e2016-11-03 11:38:52 -070083 h = read_aux_reg(ARC_REG_MCIP_READBACK);
Vineet Gupta72d72882014-12-24 18:41:55 +053084
85 local_irq_restore(flags);
86
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +010087 return (((u64)h) << 32) | l;
Vineet Gupta72d72882014-12-24 18:41:55 +053088}
89
Alexey Brodkinbf287602018-11-19 14:29:17 +030090static notrace u64 arc_gfrc_clock_read(void)
91{
92 return arc_read_gfrc(NULL);
93}
94
Vineet Guptae608b532016-01-01 18:05:48 +053095static struct clocksource arc_counter_gfrc = {
Vineet Guptad584f0f2016-01-22 14:27:50 +053096 .name = "ARConnect GFRC",
Vineet Gupta72d72882014-12-24 18:41:55 +053097 .rating = 400,
Vineet Guptae608b532016-01-01 18:05:48 +053098 .read = arc_read_gfrc,
Vineet Gupta72d72882014-12-24 18:41:55 +053099 .mask = CLOCKSOURCE_MASK(64),
100 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
101};
102
Daniel Lezcano43d75602016-06-15 14:50:12 +0200103static int __init arc_cs_setup_gfrc(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530104{
Vineet Guptaec7cb872016-10-31 13:02:31 -0700105 struct mcip_bcr mp;
Vineet Guptae608b532016-01-01 18:05:48 +0530106 int ret;
107
Vineet Guptaec7cb872016-10-31 13:02:31 -0700108 READ_BCR(ARC_REG_MCIP_BCR, mp);
109 if (!mp.gfrc) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100110 pr_warn("Global-64-bit-Ctr clocksource not detected\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200111 return -ENXIO;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700112 }
Vineet Guptae608b532016-01-01 18:05:48 +0530113
114 ret = arc_get_timer_clk(node);
115 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200116 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530117
Alexey Brodkinbf287602018-11-19 14:29:17 +0300118 sched_clock_register(arc_gfrc_clock_read, 64, arc_timer_freq);
119
Daniel Lezcano43d75602016-06-15 14:50:12 +0200120 return clocksource_register_hz(&arc_counter_gfrc, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530121}
Daniel Lezcano17273392017-05-26 16:56:11 +0200122TIMER_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc);
Vineet Guptae608b532016-01-01 18:05:48 +0530123
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530124#define AUX_RTC_CTRL 0x103
125#define AUX_RTC_LOW 0x104
126#define AUX_RTC_HIGH 0x105
127
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100128static u64 arc_read_rtc(struct clocksource *cs)
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530129{
130 unsigned long status;
Vineet Gupta2cd690e2016-11-03 11:38:52 -0700131 u32 l, h;
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530132
Vineet Gupta922cc172016-10-31 14:09:52 -0700133 /*
134 * hardware has an internal state machine which tracks readout of
135 * low/high and updates the CTRL.status if
136 * - interrupt/exception taken between the two reads
137 * - high increments after low has been read
138 */
139 do {
Vineet Gupta2cd690e2016-11-03 11:38:52 -0700140 l = read_aux_reg(AUX_RTC_LOW);
141 h = read_aux_reg(AUX_RTC_HIGH);
Vineet Gupta922cc172016-10-31 14:09:52 -0700142 status = read_aux_reg(AUX_RTC_CTRL);
Masahiro Yamada93665ab2019-05-24 14:40:10 +0900143 } while (!(status & BIT(31)));
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530144
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100145 return (((u64)h) << 32) | l;
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530146}
147
Alexey Brodkinbf287602018-11-19 14:29:17 +0300148static notrace u64 arc_rtc_clock_read(void)
149{
150 return arc_read_rtc(NULL);
151}
152
Vineet Guptae608b532016-01-01 18:05:48 +0530153static struct clocksource arc_counter_rtc = {
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530154 .name = "ARCv2 RTC",
155 .rating = 350,
Vineet Guptae608b532016-01-01 18:05:48 +0530156 .read = arc_read_rtc,
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530157 .mask = CLOCKSOURCE_MASK(64),
158 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
159};
160
Daniel Lezcano43d75602016-06-15 14:50:12 +0200161static int __init arc_cs_setup_rtc(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530162{
Vineet Guptaec7cb872016-10-31 13:02:31 -0700163 struct bcr_timer timer;
Vineet Guptae608b532016-01-01 18:05:48 +0530164 int ret;
165
Vineet Guptaec7cb872016-10-31 13:02:31 -0700166 READ_BCR(ARC_REG_TIMERS_BCR, timer);
167 if (!timer.rtc) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100168 pr_warn("Local-64-bit-Ctr clocksource not detected\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200169 return -ENXIO;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700170 }
Vineet Guptae608b532016-01-01 18:05:48 +0530171
172 /* Local to CPU hence not usable in SMP */
Vineet Guptaec7cb872016-10-31 13:02:31 -0700173 if (IS_ENABLED(CONFIG_SMP)) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100174 pr_warn("Local-64-bit-Ctr not usable in SMP\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200175 return -EINVAL;
Vineet Guptaec7cb872016-10-31 13:02:31 -0700176 }
Vineet Guptae608b532016-01-01 18:05:48 +0530177
178 ret = arc_get_timer_clk(node);
179 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200180 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530181
182 write_aux_reg(AUX_RTC_CTRL, 1);
183
Alexey Brodkinbf287602018-11-19 14:29:17 +0300184 sched_clock_register(arc_rtc_clock_read, 64, arc_timer_freq);
185
Daniel Lezcano43d75602016-06-15 14:50:12 +0200186 return clocksource_register_hz(&arc_counter_rtc, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530187}
Daniel Lezcano17273392017-05-26 16:56:11 +0200188TIMER_OF_DECLARE(arc_rtc, "snps,archs-timer-rtc", arc_cs_setup_rtc);
Vineet Guptae608b532016-01-01 18:05:48 +0530189
190#endif
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530191
Vineet Guptad8005e62013-01-18 15:12:18 +0530192/*
Vineet Guptae608b532016-01-01 18:05:48 +0530193 * 32bit TIMER1 to keep counting monotonically and wraparound
Vineet Guptad8005e62013-01-18 15:12:18 +0530194 */
Vineet Guptad8005e62013-01-18 15:12:18 +0530195
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100196static u64 arc_read_timer1(struct clocksource *cs)
Vineet Guptad8005e62013-01-18 15:12:18 +0530197{
Thomas Gleixnera5a1d1c2016-12-21 20:32:01 +0100198 return (u64) read_aux_reg(ARC_REG_TIMER1_CNT);
Vineet Guptad8005e62013-01-18 15:12:18 +0530199}
200
Alexey Brodkinbf287602018-11-19 14:29:17 +0300201static notrace u64 arc_timer1_clock_read(void)
202{
203 return arc_read_timer1(NULL);
204}
205
Vineet Guptae608b532016-01-01 18:05:48 +0530206static struct clocksource arc_counter_timer1 = {
Vineet Guptad8005e62013-01-18 15:12:18 +0530207 .name = "ARC Timer1",
208 .rating = 300,
Vineet Guptae608b532016-01-01 18:05:48 +0530209 .read = arc_read_timer1,
Vineet Guptad8005e62013-01-18 15:12:18 +0530210 .mask = CLOCKSOURCE_MASK(32),
211 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
212};
213
Daniel Lezcano43d75602016-06-15 14:50:12 +0200214static int __init arc_cs_setup_timer1(struct device_node *node)
Vineet Guptae608b532016-01-01 18:05:48 +0530215{
216 int ret;
217
218 /* Local to CPU hence not usable in SMP */
219 if (IS_ENABLED(CONFIG_SMP))
Daniel Lezcano43d75602016-06-15 14:50:12 +0200220 return -EINVAL;
Vineet Guptae608b532016-01-01 18:05:48 +0530221
222 ret = arc_get_timer_clk(node);
223 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200224 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530225
Vineet Guptab26c2e32016-10-31 13:06:19 -0700226 write_aux_reg(ARC_REG_TIMER1_LIMIT, ARC_TIMERN_MAX);
Vineet Guptae608b532016-01-01 18:05:48 +0530227 write_aux_reg(ARC_REG_TIMER1_CNT, 0);
Randy Dunlap58100c32021-09-23 19:08:25 -0700228 write_aux_reg(ARC_REG_TIMER1_CTRL, ARC_TIMER_CTRL_NH);
Vineet Guptae608b532016-01-01 18:05:48 +0530229
Alexey Brodkinbf287602018-11-19 14:29:17 +0300230 sched_clock_register(arc_timer1_clock_read, 32, arc_timer_freq);
231
Daniel Lezcano43d75602016-06-15 14:50:12 +0200232 return clocksource_register_hz(&arc_counter_timer1, arc_timer_freq);
Vineet Guptae608b532016-01-01 18:05:48 +0530233}
Vineet Guptaaa93e8e2013-11-07 14:57:16 +0530234
Vineet Guptad8005e62013-01-18 15:12:18 +0530235/********** Clock Event Device *********/
236
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530237static int arc_timer_irq;
Noam Camuseec3c582016-01-01 15:48:49 +0530238
Vineet Guptad8005e62013-01-18 15:12:18 +0530239/*
Vineet Guptac9a98e182014-06-25 17:14:03 +0530240 * Arm the timer to interrupt after @cycles
Vineet Guptad8005e62013-01-18 15:12:18 +0530241 * The distinction for oneshot/periodic is done in arc_event_timer_ack() below
242 */
Vineet Guptac9a98e182014-06-25 17:14:03 +0530243static void arc_timer_event_setup(unsigned int cycles)
Vineet Guptad8005e62013-01-18 15:12:18 +0530244{
Vineet Guptac9a98e182014-06-25 17:14:03 +0530245 write_aux_reg(ARC_REG_TIMER0_LIMIT, cycles);
Vineet Guptad8005e62013-01-18 15:12:18 +0530246 write_aux_reg(ARC_REG_TIMER0_CNT, 0); /* start from 0 */
247
Randy Dunlap58100c32021-09-23 19:08:25 -0700248 write_aux_reg(ARC_REG_TIMER0_CTRL, ARC_TIMER_CTRL_IE | ARC_TIMER_CTRL_NH);
Vineet Guptad8005e62013-01-18 15:12:18 +0530249}
250
Vineet Guptad8005e62013-01-18 15:12:18 +0530251
252static int arc_clkevent_set_next_event(unsigned long delta,
253 struct clock_event_device *dev)
254{
255 arc_timer_event_setup(delta);
256 return 0;
257}
258
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530259static int arc_clkevent_set_periodic(struct clock_event_device *dev)
Vineet Guptad8005e62013-01-18 15:12:18 +0530260{
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530261 /*
262 * At X Hz, 1 sec = 1000ms -> X cycles;
263 * 10ms -> X / 100 cycles
264 */
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530265 arc_timer_event_setup(arc_timer_freq / HZ);
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530266 return 0;
Vineet Guptad8005e62013-01-18 15:12:18 +0530267}
268
269static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = {
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530270 .name = "ARC Timer0",
271 .features = CLOCK_EVT_FEAT_ONESHOT |
272 CLOCK_EVT_FEAT_PERIODIC,
273 .rating = 300,
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530274 .set_next_event = arc_clkevent_set_next_event,
275 .set_state_periodic = arc_clkevent_set_periodic,
Vineet Guptad8005e62013-01-18 15:12:18 +0530276};
277
278static irqreturn_t timer_irq_handler(int irq, void *dev_id)
279{
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530280 /*
281 * Note that generic IRQ core could have passed @evt for @dev_id if
282 * irq_set_chip_and_handler() asked for handle_percpu_devid_irq()
283 */
284 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
Viresh Kumaraeec6cd2015-07-16 16:56:14 +0530285 int irq_reenable = clockevent_state_periodic(evt);
Vineet Guptad8005e62013-01-18 15:12:18 +0530286
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530287 /*
Vineet Guptaa4f53852018-02-21 11:31:31 -0800288 * 1. ACK the interrupt
289 * - For ARC700, any write to CTRL reg ACKs it, so just rewrite
290 * Count when [N]ot [H]alted bit.
291 * - For HS3x, it is a bit subtle. On taken count-down interrupt,
292 * IP bit [3] is set, which needs to be cleared for ACK'ing.
293 * The write below can only update the other two bits, hence
294 * explicitly clears IP bit
295 * 2. Re-arm interrupt if periodic by writing to IE bit [0]
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530296 */
Randy Dunlap58100c32021-09-23 19:08:25 -0700297 write_aux_reg(ARC_REG_TIMER0_CTRL, irq_reenable | ARC_TIMER_CTRL_NH);
Vineet Guptaf8b34c32014-01-25 00:42:37 +0530298
299 evt->event_handler(evt);
300
Vineet Guptad8005e62013-01-18 15:12:18 +0530301 return IRQ_HANDLED;
302}
303
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000304
305static int arc_timer_starting_cpu(unsigned int cpu)
Vineet Guptad8005e62013-01-18 15:12:18 +0530306{
Vineet Gupta2d4899f2014-05-08 14:06:38 +0530307 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
Vineet Guptad8005e62013-01-18 15:12:18 +0530308
Noam Camuseec3c582016-01-01 15:48:49 +0530309 evt->cpumask = cpumask_of(smp_processor_id());
310
Vineet Guptab26c2e32016-10-31 13:06:19 -0700311 clockevents_config_and_register(evt, arc_timer_freq, 0, ARC_TIMERN_MAX);
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000312 enable_percpu_irq(arc_timer_irq, 0);
313 return 0;
Noam Camuseec3c582016-01-01 15:48:49 +0530314}
315
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000316static int arc_timer_dying_cpu(unsigned int cpu)
317{
318 disable_percpu_irq(arc_timer_irq);
319 return 0;
320}
Noam Camuseec3c582016-01-01 15:48:49 +0530321
322/*
323 * clockevent setup for boot CPU
324 */
Daniel Lezcano43d75602016-06-15 14:50:12 +0200325static int __init arc_clockevent_setup(struct device_node *node)
Noam Camuseec3c582016-01-01 15:48:49 +0530326{
327 struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device);
328 int ret;
329
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530330 arc_timer_irq = irq_of_parse_and_map(node, 0);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200331 if (arc_timer_irq <= 0) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100332 pr_err("clockevent: missing irq\n");
Daniel Lezcano43d75602016-06-15 14:50:12 +0200333 return -EINVAL;
334 }
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530335
336 ret = arc_get_timer_clk(node);
Dejin Zheng311fb702020-04-29 23:12:23 +0800337 if (ret)
Daniel Lezcano43d75602016-06-15 14:50:12 +0200338 return ret;
Vineet Gupta77c8d0d2016-01-01 17:58:45 +0530339
Noam Camuseec3c582016-01-01 15:48:49 +0530340 /* Needs apriori irq_set_percpu_devid() done in intc map function */
341 ret = request_percpu_irq(arc_timer_irq, timer_irq_handler,
342 "Timer0 (per-cpu-tick)", evt);
Daniel Lezcano43d75602016-06-15 14:50:12 +0200343 if (ret) {
344 pr_err("clockevent: unable to request irq\n");
345 return ret;
346 }
Vineet Gupta56957942016-01-28 12:56:03 +0530347
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000348 ret = cpuhp_setup_state(CPUHP_AP_ARC_TIMER_STARTING,
Thomas Gleixner73c1b412016-12-21 20:19:54 +0100349 "clockevents/arc/timer:starting",
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000350 arc_timer_starting_cpu,
351 arc_timer_dying_cpu);
352 if (ret) {
Rafał Miłeckiac9ce6d2017-03-09 10:47:10 +0100353 pr_err("Failed to setup hotplug state\n");
Anna-Maria Gleixnerecd80812016-07-13 17:17:07 +0000354 return ret;
355 }
Daniel Lezcano43d75602016-06-15 14:50:12 +0200356 return 0;
Vineet Guptad8005e62013-01-18 15:12:18 +0530357}
Vineet Guptae608b532016-01-01 18:05:48 +0530358
Daniel Lezcano43d75602016-06-15 14:50:12 +0200359static int __init arc_of_timer_init(struct device_node *np)
Vineet Guptae608b532016-01-01 18:05:48 +0530360{
361 static int init_count = 0;
Daniel Lezcano43d75602016-06-15 14:50:12 +0200362 int ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530363
364 if (!init_count) {
365 init_count = 1;
Daniel Lezcano43d75602016-06-15 14:50:12 +0200366 ret = arc_clockevent_setup(np);
Vineet Guptae608b532016-01-01 18:05:48 +0530367 } else {
Daniel Lezcano43d75602016-06-15 14:50:12 +0200368 ret = arc_cs_setup_timer1(np);
Vineet Guptae608b532016-01-01 18:05:48 +0530369 }
Daniel Lezcano43d75602016-06-15 14:50:12 +0200370
371 return ret;
Vineet Guptae608b532016-01-01 18:05:48 +0530372}
Daniel Lezcano17273392017-05-26 16:56:11 +0200373TIMER_OF_DECLARE(arc_clkevt, "snps,arc-timer", arc_of_timer_init);