xref: /OK3568_Linux_fs/kernel/drivers/clocksource/dummy_timer.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  linux/drivers/clocksource/dummy_timer.c
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Copyright (C) 2013 ARM Ltd.
6*4882a593Smuzhiyun  *  All Rights Reserved
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun #include <linux/clockchips.h>
9*4882a593Smuzhiyun #include <linux/cpu.h>
10*4882a593Smuzhiyun #include <linux/init.h>
11*4882a593Smuzhiyun #include <linux/percpu.h>
12*4882a593Smuzhiyun #include <linux/cpumask.h>
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun static DEFINE_PER_CPU(struct clock_event_device, dummy_timer_evt);
15*4882a593Smuzhiyun 
dummy_timer_starting_cpu(unsigned int cpu)16*4882a593Smuzhiyun static int dummy_timer_starting_cpu(unsigned int cpu)
17*4882a593Smuzhiyun {
18*4882a593Smuzhiyun 	struct clock_event_device *evt = per_cpu_ptr(&dummy_timer_evt, cpu);
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun 	evt->name	= "dummy_timer";
21*4882a593Smuzhiyun 	evt->features	= CLOCK_EVT_FEAT_PERIODIC |
22*4882a593Smuzhiyun 			  CLOCK_EVT_FEAT_ONESHOT |
23*4882a593Smuzhiyun 			  CLOCK_EVT_FEAT_DUMMY;
24*4882a593Smuzhiyun 	evt->rating	= 100;
25*4882a593Smuzhiyun 	evt->cpumask	= cpumask_of(cpu);
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun 	clockevents_register_device(evt);
28*4882a593Smuzhiyun 	return 0;
29*4882a593Smuzhiyun }
30*4882a593Smuzhiyun 
dummy_timer_register(void)31*4882a593Smuzhiyun static int __init dummy_timer_register(void)
32*4882a593Smuzhiyun {
33*4882a593Smuzhiyun 	return cpuhp_setup_state(CPUHP_AP_DUMMY_TIMER_STARTING,
34*4882a593Smuzhiyun 				 "clockevents/dummy_timer:starting",
35*4882a593Smuzhiyun 				 dummy_timer_starting_cpu, NULL);
36*4882a593Smuzhiyun }
37*4882a593Smuzhiyun early_initcall(dummy_timer_register);
38