Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clocksource/drivers/nomadik-mtu: Handle 32kHz clock

It happens on the U8420-sysclk Ux500 PRCMU firmware
variant that the MTU clock is just 32768 Hz, and in this
mode the minimum ticks is 5 rather than two.

I think this is simply so that there is enough time
for the register write to propagate through the
interconnect to the registers.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200628220153.67011-1-linus.walleij@linaro.org

authored by

Linus Walleij and committed by
Daniel Lezcano
aaea0b83 ad7794d4

+9 -2
+9 -2
drivers/clocksource/nomadik-mtu.c
··· 186 186 { 187 187 unsigned long rate; 188 188 int ret; 189 + int min_ticks; 189 190 190 191 mtu_base = base; 191 192 ··· 195 194 196 195 /* 197 196 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz 198 - * for ux500. 197 + * for ux500, and in one specific Ux500 case 32768 Hz. 198 + * 199 199 * Use a divide-by-16 counter if the tick rate is more than 32MHz. 200 200 * At 32 MHz, the timer (with 32 bit counter) can be programmed 201 201 * to wake-up at a max 127s a head in time. Dividing a 2.4 MHz timer ··· 232 230 pr_err("%s: request_irq() failed\n", "Nomadik Timer Tick"); 233 231 nmdk_clkevt.cpumask = cpumask_of(0); 234 232 nmdk_clkevt.irq = irq; 235 - clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU); 233 + if (rate < 100000) 234 + min_ticks = 5; 235 + else 236 + min_ticks = 2; 237 + clockevents_config_and_register(&nmdk_clkevt, rate, min_ticks, 238 + 0xffffffffU); 236 239 237 240 mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer; 238 241 mtu_delay_timer.freq = rate;