Lines Matching +full:sp804 +full:- +full:has +full:- +full:irq
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * linux/drivers/clocksource/timer-sp.c
5 * Copyright (C) 1999 - 2003 ARM Limited
16 #include <linux/irq.h>
24 #include "timer-sp.h"
26 /* Hisilicon 64-bit timer(a variant of ARM SP804) */
67 clk = clk_get_sys("sp804", name); in sp804_get_clock_rate()
102 return ~readl_relaxed(sched_clkevt->value); in sp804_read()
115 return -EINVAL; in sp804_clocksource_and_sched_clock_init()
119 writel(0, clkevt->ctrl); in sp804_clocksource_and_sched_clock_init()
120 writel(0xffffffff, clkevt->load); in sp804_clocksource_and_sched_clock_init()
121 writel(0xffffffff, clkevt->value); in sp804_clocksource_and_sched_clock_init()
122 if (clkevt->width == 64) { in sp804_clocksource_and_sched_clock_init()
123 writel(0xffffffff, clkevt->load_h); in sp804_clocksource_and_sched_clock_init()
124 writel(0xffffffff, clkevt->value_h); in sp804_clocksource_and_sched_clock_init()
127 clkevt->ctrl); in sp804_clocksource_and_sched_clock_init()
129 clocksource_mmio_init(clkevt->value, name, in sp804_clocksource_and_sched_clock_init()
144 * IRQ handler for the timer
146 static irqreturn_t sp804_timer_interrupt(int irq, void *dev_id) in sp804_timer_interrupt() argument
151 writel(1, common_clkevt->intclr); in sp804_timer_interrupt()
153 evt->event_handler(evt); in sp804_timer_interrupt()
160 writel(0, common_clkevt->ctrl); in evt_timer_shutdown()
175 writel(common_clkevt->reload, common_clkevt->load); in sp804_set_periodic()
176 writel(ctrl, common_clkevt->ctrl); in sp804_set_periodic()
186 writel(next, common_clkevt->load); in sp804_set_next_event()
187 writel(ctrl, common_clkevt->ctrl); in sp804_set_next_event()
204 static int __init sp804_clockevents_init(void __iomem *base, unsigned int irq, in sp804_clockevents_init() argument
212 return -EINVAL; in sp804_clockevents_init()
215 common_clkevt->reload = DIV_ROUND_CLOSEST(rate, HZ); in sp804_clockevents_init()
216 evt->name = name; in sp804_clockevents_init()
217 evt->irq = irq; in sp804_clockevents_init()
218 evt->cpumask = cpu_possible_mask; in sp804_clockevents_init()
220 writel(0, common_clkevt->ctrl); in sp804_clockevents_init()
222 if (request_irq(irq, sp804_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL, in sp804_clockevents_init()
238 timer_base = base + timer->timer_base[i]; in sp804_clkevt_init()
240 clkevt->base = timer_base; in sp804_clkevt_init()
241 clkevt->load = timer_base + timer->load; in sp804_clkevt_init()
242 clkevt->load_h = timer_base + timer->load_h; in sp804_clkevt_init()
243 clkevt->value = timer_base + timer->value; in sp804_clkevt_init()
244 clkevt->value_h = timer_base + timer->value_h; in sp804_clkevt_init()
245 clkevt->ctrl = timer_base + timer->ctrl; in sp804_clkevt_init()
246 clkevt->intclr = timer_base + timer->intclr; in sp804_clkevt_init()
247 clkevt->width = timer->width; in sp804_clkevt_init()
257 int irq, ret = -EINVAL; in sp804_of_init() local
263 pr_debug("%pOF: skipping further SP804 timer device\n", np); in sp804_of_init()
269 return -ENXIO; in sp804_of_init()
271 timer1_base = base + timer->timer_base[0]; in sp804_of_init()
272 timer2_base = base + timer->timer_base[1]; in sp804_of_init()
275 writel(0, timer1_base + timer->ctrl); in sp804_of_init()
276 writel(0, timer2_base + timer->ctrl); in sp804_of_init()
282 /* Get the 2nd clock if the timer has 3 timer clocks */ in sp804_of_init()
293 irq = irq_of_parse_and_map(np, 0); in sp804_of_init()
294 if (irq <= 0) in sp804_of_init()
299 of_property_read_u32(np, "arm,sp804-has-irq", &irq_num); in sp804_of_init()
302 ret = sp804_clockevents_init(timer2_base, irq, clk2, name); in sp804_of_init()
312 ret = sp804_clockevents_init(timer1_base, irq, clk1, name); in sp804_of_init()
333 TIMER_OF_DECLARE(sp804, "arm,sp804", arm_sp804_of_init);
339 TIMER_OF_DECLARE(hisi_sp804, "hisilicon,sp804", hisi_sp804_of_init);
345 int irq, ret = -EINVAL; in integrator_cp_of_init() local
352 return -ENXIO; in integrator_cp_of_init()
375 irq = irq_of_parse_and_map(np, 0); in integrator_cp_of_init()
376 if (irq <= 0) in integrator_cp_of_init()
379 ret = sp804_clockevents_init(base, irq, clk, name); in integrator_cp_of_init()
390 TIMER_OF_DECLARE(intcp, "arm,integrator-cp-timer", integrator_cp_of_init);