From: xingyu.wu Date: Tue, 12 Jul 2022 02:57:13 +0000 (+0800) Subject: clocksource: starfive: Add reset control support X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3097bce5e5d1616cce6fc8def38699635f09e46b;p=platform%2Fkernel%2Flinux-starfive.git clocksource: starfive: Add reset control support Reset the timer if the reset control is available. Signed-off-by: Xingyu Wu Signed-off-by: Ley Foon Tan --- diff --git a/drivers/clocksource/timer-starfive.c b/drivers/clocksource/timer-starfive.c index fe1d6b4..b7b7e36 100755 --- a/drivers/clocksource/timer-starfive.c +++ b/drivers/clocksource/timer-starfive.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "timer-starfive.h" #define CLOCK_SOURCE_RATE 200 @@ -339,6 +340,8 @@ static int __init do_starfive_timer_of_init(struct device_node *np, const char *name = NULL; struct clk *clk; struct clk *pclk; + struct reset_control *prst; + struct reset_control *rst; struct starfive_clkevt *clkevt; void __iomem *base; @@ -357,6 +360,12 @@ static int __init do_starfive_timer_of_init(struct device_node *np, pr_warn("pclk for %pOFn is present," "but could not be activated\n", np); + prst = of_reset_control_get(np, "apb_rst"); + if (!IS_ERR(prst)) { + reset_control_assert(prst); + reset_control_deassert(prst); + } + count = of_irq_count(np); if (count > NR_TIMERS || count <= 0) { ret = -EINVAL; @@ -388,6 +397,13 @@ static int __init do_starfive_timer_of_init(struct device_node *np, "but could not be activated\n", np); } + rst = of_reset_control_get(np, name); + if (!IS_ERR(rst)) { + clkevt->rst = rst; + reset_control_assert(rst); + reset_control_deassert(rst); + } + irq = irq_of_parse_and_map(np, index); if (irq < 0) { ret = -EINVAL; @@ -414,6 +430,10 @@ init_err: register_err: free_irq(clkevt->irq, &clkevt->evt); irq_err: + if (!clkevt->rst) { + reset_control_assert(clkevt->rst); + reset_control_put(clkevt->rst); + } if (!clkevt->clk) { clk_disable_unprepare(clkevt->clk); clk_put(clkevt->clk); diff --git a/drivers/clocksource/timer-starfive.h b/drivers/clocksource/timer-starfive.h old mode 100644 new mode 100755 index 3d702e4..940b7b9 --- a/drivers/clocksource/timer-starfive.h +++ b/drivers/clocksource/timer-starfive.h @@ -84,6 +84,7 @@ struct starfive_timer { struct starfive_clkevt { struct clock_event_device evt; struct clk *clk; + struct reset_control *rst; int irq; u64 periodic; u64 rate;