xref: /linux/arch/mips/kernel/i8253.c (revision ead5d1f4d877e92c051e1a1ade623d0d30e71619)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2d865bea4SRalf Baechle /*
3d865bea4SRalf Baechle  * i8253.c  8253/PIT functions
4d865bea4SRalf Baechle  *
5d865bea4SRalf Baechle  */
6d865bea4SRalf Baechle #include <linux/clockchips.h>
7334955efSRalf Baechle #include <linux/i8253.h>
873bc256dSPaul Gortmaker #include <linux/export.h>
9631330f5SRalf Baechle #include <linux/smp.h>
10ca4d3e67SDavid Howells #include <linux/irq.h>
11d865bea4SRalf Baechle 
12dd3db6ebSRalf Baechle #include <asm/time.h>
13d865bea4SRalf Baechle 
timer_interrupt(int irq,void * dev_id)14dd3db6ebSRalf Baechle static irqreturn_t timer_interrupt(int irq, void *dev_id)
15d865bea4SRalf Baechle {
16ded7c1eeSThomas Gleixner 	i8253_clockevent.event_handler(&i8253_clockevent);
17d865bea4SRalf Baechle 
18d865bea4SRalf Baechle 	return IRQ_HANDLED;
19d865bea4SRalf Baechle }
20d865bea4SRalf Baechle 
setup_pit_timer(void)21d865bea4SRalf Baechle void __init setup_pit_timer(void)
22d865bea4SRalf Baechle {
23*ac8fd122Safzal mohammed 	unsigned long flags = IRQF_NOBALANCING | IRQF_TIMER;
24*ac8fd122Safzal mohammed 
252d02612fSThomas Gleixner 	clockevent_i8253_init(true);
26*ac8fd122Safzal mohammed 	if (request_irq(0, timer_interrupt, flags, "timer", NULL))
27*ac8fd122Safzal mohammed 		pr_err("Failed to request irq 0 (timer)\n");
28d865bea4SRalf Baechle }
29d865bea4SRalf Baechle 
init_pit_clocksource(void)30d865bea4SRalf Baechle static int __init init_pit_clocksource(void)
31d865bea4SRalf Baechle {
32a07e3324SThomas Bogendoerfer 	if (num_possible_cpus() > 1 || /* PIT does not scale! */
33a07e3324SThomas Bogendoerfer 	    !clockevent_state_periodic(&i8253_clockevent))
34d865bea4SRalf Baechle 		return 0;
35d865bea4SRalf Baechle 
36798778b8SRussell King 	return clocksource_i8253_init();
37d865bea4SRalf Baechle }
38d865bea4SRalf Baechle arch_initcall(init_pit_clocksource);
39