18 #include <linux/kernel.h>
22 #include <linux/types.h>
31 #define IRQ_TIMERCOUNTER0 42
47 #define XTTCPSS_CLOCKSOURCE 0
48 #define XTTCPSS_CLOCKEVENT 1
50 #define XTTCPSS_TIMER_BASE TTC0_BASE
51 #define XTTCPCC_EVENT_TIMER_IRQ (IRQ_TIMERCOUNTER0 + 1)
56 #define XTTCPSS_CLK_CNTRL_OFFSET 0x00
57 #define XTTCPSS_CNT_CNTRL_OFFSET 0x0C
58 #define XTTCPSS_COUNT_VAL_OFFSET 0x18
59 #define XTTCPSS_INTR_VAL_OFFSET 0x24
60 #define XTTCPSS_MATCH_1_OFFSET 0x30
61 #define XTTCPSS_MATCH_2_OFFSET 0x3C
62 #define XTTCPSS_MATCH_3_OFFSET 0x48
63 #define XTTCPSS_ISR_OFFSET 0x54
64 #define XTTCPSS_IER_OFFSET 0x60
66 #define XTTCPSS_CNT_CNTRL_DISABLE_MASK 0x1
70 #define TIMER_RATE (PERIPHERAL_CLOCK_RATE / 32)
82 static struct clock_event_device xttcpss_clockevent;
119 struct clock_event_device *
evt = &xttcpss_clockevent;
126 evt->event_handler(evt);
131 static struct irqaction event_timer_irq = {
132 .name =
"xttcpss clockevent",
134 .handler = xttcpss_clock_event_interrupt,
143 static void __init xttcpss_timer_hardware_init(
void)
195 .name =
"xttcpss_timer1",
197 .read = __raw_readl_cycles,
211 static int xttcpss_set_next_event(
unsigned long cycles,
212 struct clock_event_device *evt)
216 xttcpss_set_interval(timer, cycles);
226 static void xttcpss_set_mode(
enum clock_event_mode
mode,
227 struct clock_event_device *evt)
233 case CLOCK_EVT_MODE_PERIODIC:
236 case CLOCK_EVT_MODE_ONESHOT:
237 case CLOCK_EVT_MODE_UNUSED:
238 case CLOCK_EVT_MODE_SHUTDOWN:
245 case CLOCK_EVT_MODE_RESUME:
258 static struct clock_event_device xttcpss_clockevent = {
259 .name =
"xttcpss_timer2",
260 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
261 .set_next_event = xttcpss_set_next_event,
262 .set_mode = xttcpss_set_mode,
272 static void __init xttcpss_timer_init(
void)
274 xttcpss_timer_hardware_init();
275 clocksource_register_hz(&clocksource_xttcpss,
TIMER_RATE);
280 clockevents_calc_mult_shift(&xttcpss_clockevent,
TIMER_RATE, 4);
282 xttcpss_clockevent.max_delta_ns =
284 xttcpss_clockevent.min_delta_ns =
297 .init = xttcpss_timer_init,