Lines Matching refs:timer
49 static inline u32 apbt_readl(struct dw_apb_timer *timer, unsigned long offs)
51 return readl(timer->base + offs);
54 static inline void apbt_writel(struct dw_apb_timer *timer, u32 val,
57 writel(val, timer->base + offs);
60 static inline u32 apbt_readl_relaxed(struct dw_apb_timer *timer, unsigned long offs)
62 return readl_relaxed(timer->base + offs);
65 static inline void apbt_writel_relaxed(struct dw_apb_timer *timer, u32 val,
68 writel_relaxed(val, timer->base + offs);
71 static void apbt_eoi(struct dw_apb_timer *timer)
73 apbt_readl_relaxed(timer, APBTMR_N_EOI);
82 pr_info("Spurious APBT timer interrupt %d\n", irq);
87 dw_ced->eoi(&dw_ced->timer);
93 static void apbt_enable_int(struct dw_apb_timer *timer)
95 u32 ctrl = apbt_readl(timer, APBTMR_N_CONTROL);
97 apbt_readl(timer, APBTMR_N_EOI);
99 apbt_writel(timer, ctrl, APBTMR_N_CONTROL);
110 ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL);
112 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
124 ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL);
126 * set free running mode, this mode will let timer reload max
133 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
135 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
141 apbt_writel(&dw_ced->timer, ~0, APBTMR_N_LOAD_COUNT);
144 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
151 unsigned long period = DIV_ROUND_UP(dw_ced->timer.freq, HZ);
157 ctrl = apbt_readl(&dw_ced->timer, APBTMR_N_CONTROL);
159 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
161 * DW APB p. 46, have to disable timer before load counter,
165 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
168 apbt_writel(&dw_ced->timer, period, APBTMR_N_LOAD_COUNT);
170 apbt_writel(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
181 apbt_enable_int(&dw_ced->timer);
191 /* Disable timer */
192 ctrl = apbt_readl_relaxed(&dw_ced->timer, APBTMR_N_CONTROL);
194 apbt_writel_relaxed(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
196 apbt_writel_relaxed(&dw_ced->timer, delta, APBTMR_N_LOAD_COUNT);
198 apbt_writel_relaxed(&dw_ced->timer, ctrl, APBTMR_N_CONTROL);
204 * dw_apb_clockevent_init() - use an APB timer as a clock_event_device
208 * @name: The name used for the timer and the IRQ for it.
209 * @rating: The rating to give the timer.
210 * @base: I/O base for the timer registers.
211 * @irq: The interrupt number to use for the timer.
212 * @freq: The frequency that the timer counts at.
217 * it has been called for a timer then the IRQ will be requested, if not it
231 dw_ced->timer.base = base;
232 dw_ced->timer.irq = irq;
233 dw_ced->timer.freq = freq;
250 dw_ced->ced.irq = dw_ced->timer.irq;
259 pr_err("failed to request timer irq\n");
274 apbt_writel(&dw_ced->timer, 0, APBTMR_N_CONTROL);
276 apbt_enable_int(&dw_ced->timer);
293 u32 ctrl = apbt_readl(&dw_cs->timer, APBTMR_N_CONTROL);
296 apbt_writel(&dw_cs->timer, ctrl, APBTMR_N_CONTROL);
297 apbt_writel(&dw_cs->timer, ~0, APBTMR_N_LOAD_COUNT);
301 apbt_writel(&dw_cs->timer, ctrl, APBTMR_N_CONTROL);
312 current_count = apbt_readl_relaxed(&dw_cs->timer,
327 * dw_apb_clocksource_init() - use an APB timer as a clocksource.
331 * @base: The I/O base for the timer registers.
332 * @freq: The frequency that the timer counts at.
334 * This creates a clocksource using an APB timer but does not yet register it
347 dw_cs->timer.base = base;
348 dw_cs->timer.freq = freq;
366 clocksource_register_hz(&dw_cs->cs, dw_cs->timer.freq);
376 return (u64)~apbt_readl(&dw_cs->timer, APBTMR_N_CURRENT_VALUE);