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

clocksource: sun5i: Add support for reset controller

The Allwinner A31 that uses this timer has the timer IP asserted in reset.
Add an optional reset property to the DT, and deassert the timer from reset if
it's there.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Maxime Ripard and committed by
Daniel Lezcano
e50a00be a5e11117

+10
+4
Documentation/devicetree/bindings/timer/allwinner,sun5i-a13-hstimer.txt
··· 9 9 one) 10 10 - clocks: phandle to the source clock (usually the AHB clock) 11 11 12 + Optionnal properties: 13 + - resets: phandle to a reset controller asserting the timer 14 + 12 15 Example: 13 16 14 17 timer@01c60000 { ··· 22 19 <0 53 1>, 23 20 <0 54 1>; 24 21 clocks = <&ahb1_gates 19>; 22 + resets = <&ahb1rst 19>; 25 23 };
+6
drivers/clocksource/timer-sun5i.c
··· 16 16 #include <linux/interrupt.h> 17 17 #include <linux/irq.h> 18 18 #include <linux/irqreturn.h> 19 + #include <linux/reset.h> 19 20 #include <linux/sched_clock.h> 20 21 #include <linux/of.h> 21 22 #include <linux/of_address.h> ··· 144 143 145 144 static void __init sun5i_timer_init(struct device_node *node) 146 145 { 146 + struct reset_control *rstc; 147 147 unsigned long rate; 148 148 struct clk *clk; 149 149 int ret, irq; ··· 163 161 panic("Can't get timer clock"); 164 162 clk_prepare_enable(clk); 165 163 rate = clk_get_rate(clk); 164 + 165 + rstc = of_reset_control_get(node, NULL); 166 + if (!IS_ERR(rstc)) 167 + reset_control_deassert(rstc); 166 168 167 169 writel(~0, timer_base + TIMER_INTVAL_LO_REG(1)); 168 170 writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,