Lines Matching refs:to

62 static void stm32_timer_of_bits_set(struct timer_of *to, int bits)  in stm32_timer_of_bits_set()  argument
64 struct stm32_timer_private *pd = to->private_data; in stm32_timer_of_bits_set()
78 static int stm32_timer_of_bits_get(struct timer_of *to) in stm32_timer_of_bits_get() argument
80 struct stm32_timer_private *pd = to->private_data; in stm32_timer_of_bits_get()
99 static void stm32_clock_event_disable(struct timer_of *to) in stm32_clock_event_disable() argument
101 writel_relaxed(0, timer_of_base(to) + TIM_DIER); in stm32_clock_event_disable()
112 static void stm32_timer_start(struct timer_of *to) in stm32_timer_start() argument
114 writel_relaxed(TIM_CR1_UDIS | TIM_CR1_CEN, timer_of_base(to) + TIM_CR1); in stm32_timer_start()
119 struct timer_of *to = to_timer_of(clkevt); in stm32_clock_event_shutdown() local
121 stm32_clock_event_disable(to); in stm32_clock_event_shutdown()
129 struct timer_of *to = to_timer_of(clkevt); in stm32_clock_event_set_next_event() local
132 next = readl_relaxed(timer_of_base(to) + TIM_CNT) + evt; in stm32_clock_event_set_next_event()
133 writel_relaxed(next, timer_of_base(to) + TIM_CCR1); in stm32_clock_event_set_next_event()
134 now = readl_relaxed(timer_of_base(to) + TIM_CNT); in stm32_clock_event_set_next_event()
139 writel_relaxed(TIM_DIER_CC1IE, timer_of_base(to) + TIM_DIER); in stm32_clock_event_set_next_event()
146 struct timer_of *to = to_timer_of(clkevt); in stm32_clock_event_set_periodic() local
148 stm32_timer_start(to); in stm32_clock_event_set_periodic()
150 return stm32_clock_event_set_next_event(timer_of_period(to), clkevt); in stm32_clock_event_set_periodic()
155 struct timer_of *to = to_timer_of(clkevt); in stm32_clock_event_set_oneshot() local
157 stm32_timer_start(to); in stm32_clock_event_set_oneshot()
165 struct timer_of *to = to_timer_of(clkevt); in stm32_clock_event_handler() local
167 writel_relaxed(0, timer_of_base(to) + TIM_SR); in stm32_clock_event_handler()
188 static void __init stm32_timer_set_width(struct timer_of *to) in stm32_timer_set_width() argument
192 writel_relaxed(UINT_MAX, timer_of_base(to) + TIM_ARR); in stm32_timer_set_width()
194 width = readl_relaxed(timer_of_base(to) + TIM_ARR); in stm32_timer_set_width()
196 stm32_timer_of_bits_set(to, width == UINT_MAX ? 32 : 16); in stm32_timer_set_width()
207 static void __init stm32_timer_set_prescaler(struct timer_of *to) in stm32_timer_set_prescaler() argument
211 if (stm32_timer_of_bits_get(to) != 32) { in stm32_timer_set_prescaler()
212 prescaler = DIV_ROUND_CLOSEST(timer_of_rate(to), in stm32_timer_set_prescaler()
222 writel_relaxed(prescaler - 1, timer_of_base(to) + TIM_PSC); in stm32_timer_set_prescaler()
223 writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR); in stm32_timer_set_prescaler()
224 writel_relaxed(0, timer_of_base(to) + TIM_SR); in stm32_timer_set_prescaler()
227 to->of_clk.rate = DIV_ROUND_CLOSEST(to->of_clk.rate, prescaler); in stm32_timer_set_prescaler()
228 to->of_clk.period = DIV_ROUND_UP(to->of_clk.rate, HZ); in stm32_timer_set_prescaler()
231 static int __init stm32_clocksource_init(struct timer_of *to) in stm32_clocksource_init() argument
233 u32 bits = stm32_timer_of_bits_get(to); in stm32_clocksource_init()
234 const char *name = to->np->full_name; in stm32_clocksource_init()
251 stm32_timer_start(to); in stm32_clocksource_init()
253 stm32_timer_cnt = timer_of_base(to) + TIM_CNT; in stm32_clocksource_init()
254 sched_clock_register(stm32_read_sched_clock, bits, timer_of_rate(to)); in stm32_clocksource_init()
258 stm32_timer_delay.freq = timer_of_rate(to); in stm32_clocksource_init()
263 return clocksource_mmio_init(timer_of_base(to) + TIM_CNT, name, in stm32_clocksource_init()
264 timer_of_rate(to), bits == 32 ? 250 : 100, in stm32_clocksource_init()
268 static void __init stm32_clockevent_init(struct timer_of *to) in stm32_clockevent_init() argument
270 u32 bits = stm32_timer_of_bits_get(to); in stm32_clockevent_init()
272 to->clkevt.name = to->np->full_name; in stm32_clockevent_init()
273 to->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; in stm32_clockevent_init()
274 to->clkevt.set_state_shutdown = stm32_clock_event_shutdown; in stm32_clockevent_init()
275 to->clkevt.set_state_periodic = stm32_clock_event_set_periodic; in stm32_clockevent_init()
276 to->clkevt.set_state_oneshot = stm32_clock_event_set_oneshot; in stm32_clockevent_init()
277 to->clkevt.tick_resume = stm32_clock_event_shutdown; in stm32_clockevent_init()
278 to->clkevt.set_next_event = stm32_clock_event_set_next_event; in stm32_clockevent_init()
279 to->clkevt.rating = bits == 32 ? 250 : 100; in stm32_clockevent_init()
281 clockevents_config_and_register(&to->clkevt, timer_of_rate(to), 0x1, in stm32_clockevent_init()
285 to->np, bits); in stm32_clockevent_init()
291 struct timer_of *to; in stm32_timer_init() local
294 to = kzalloc(sizeof(*to), GFP_KERNEL); in stm32_timer_init()
295 if (!to) in stm32_timer_init()
298 to->flags = TIMER_OF_IRQ | TIMER_OF_CLOCK | TIMER_OF_BASE; in stm32_timer_init()
299 to->of_irq.handler = stm32_clock_event_handler; in stm32_timer_init()
301 ret = timer_of_init(node, to); in stm32_timer_init()
305 to->private_data = kzalloc(sizeof(struct stm32_timer_private), in stm32_timer_init()
307 if (!to->private_data) { in stm32_timer_init()
318 stm32_timer_set_width(to); in stm32_timer_init()
320 stm32_timer_set_prescaler(to); in stm32_timer_init()
322 ret = stm32_clocksource_init(to); in stm32_timer_init()
326 stm32_clockevent_init(to); in stm32_timer_init()
330 timer_of_cleanup(to); in stm32_timer_init()
332 kfree(to); in stm32_timer_init()