xref: /linux-6.15/include/linux/dw_apb_timer.h (revision 55a68c23)
1 /*
2  * (C) Copyright 2009 Intel Corporation
3  * Author: Jacob Pan ([email protected])
4  *
5  * Shared with ARM platforms, Jamie Iles, Picochip 2011
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * Support for the Synopsys DesignWare APB Timers.
12  */
13 #ifndef __DW_APB_TIMER_H__
14 #define __DW_APB_TIMER_H__
15 
16 #include <linux/clockchips.h>
17 #include <linux/clocksource.h>
18 #include <linux/interrupt.h>
19 
20 #define APBTMR_N_LOAD_COUNT		0x00
21 #define APBTMR_N_CURRENT_VALUE		0x04
22 #define APBTMR_N_CONTROL		0x08
23 #define APBTMR_N_EOI			0x0c
24 #define APBTMR_N_INT_STATUS		0x10
25 
26 #define APBTMRS_REG_SIZE       0x14
27 
28 struct dw_apb_timer {
29 	void __iomem				*base;
30 	unsigned long				freq;
31 	int					irq;
32 };
33 
34 struct dw_apb_clock_event_device {
35 	struct clock_event_device		ced;
36 	struct dw_apb_timer			timer;
37 	struct irqaction			irqaction;
38 	void					(*eoi)(struct dw_apb_timer *);
39 };
40 
41 struct dw_apb_clocksource {
42 	struct dw_apb_timer			timer;
43 	struct clocksource			cs;
44 };
45 
46 void dw_apb_clockevent_register(struct dw_apb_clock_event_device *dw_ced);
47 void dw_apb_clockevent_pause(struct dw_apb_clock_event_device *dw_ced);
48 void dw_apb_clockevent_resume(struct dw_apb_clock_event_device *dw_ced);
49 void dw_apb_clockevent_stop(struct dw_apb_clock_event_device *dw_ced);
50 
51 struct dw_apb_clock_event_device *
52 dw_apb_clockevent_init(int cpu, const char *name, unsigned rating,
53 		       void __iomem *base, int irq, unsigned long freq);
54 struct dw_apb_clocksource *
55 dw_apb_clocksource_init(unsigned rating, const char *name, void __iomem *base,
56 			unsigned long freq);
57 void dw_apb_clocksource_register(struct dw_apb_clocksource *dw_cs);
58 void dw_apb_clocksource_start(struct dw_apb_clocksource *dw_cs);
59 cycle_t dw_apb_clocksource_read(struct dw_apb_clocksource *dw_cs);
60 
61 extern void dw_apb_timer_init(void);
62 #endif /* __DW_APB_TIMER_H__ */
63