Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * i8253.c  8253/PIT functions
0004  *
0005  */
0006 #include <linux/clockchips.h>
0007 #include <linux/i8253.h>
0008 #include <linux/export.h>
0009 #include <linux/smp.h>
0010 #include <linux/irq.h>
0011 
0012 #include <asm/time.h>
0013 
0014 static irqreturn_t timer_interrupt(int irq, void *dev_id)
0015 {
0016     i8253_clockevent.event_handler(&i8253_clockevent);
0017 
0018     return IRQ_HANDLED;
0019 }
0020 
0021 void __init setup_pit_timer(void)
0022 {
0023     unsigned long flags = IRQF_NOBALANCING | IRQF_TIMER;
0024 
0025     clockevent_i8253_init(true);
0026     if (request_irq(0, timer_interrupt, flags, "timer", NULL))
0027         pr_err("Failed to request irq 0 (timer)\n");
0028 }
0029 
0030 static int __init init_pit_clocksource(void)
0031 {
0032     if (num_possible_cpus() > 1 || /* PIT does not scale! */
0033         !clockevent_state_periodic(&i8253_clockevent))
0034         return 0;
0035 
0036     return clocksource_i8253_init();
0037 }
0038 arch_initcall(init_pit_clocksource);