History

can: rcar_canfd: change the initializing flow for clocks and resets

Testing CANFD on RZ/G3E shows that many registers do not reset to their initial values with the current flow of deasserting resets first and then enabling clocks. Based on the HW manual, clocks should be supplied first and the resets deasserted afterward. section 7.4.3 Procedure for Activating Modules: RZ/G2L section 4.4.9.3 Procedure for Starting up Units: RZ/G3E So, update the order of the initializing flow for resets and clocks to match the hardware manual, resetting all CANFD registers to their initial values. Also update rcar_canfd_global_deinit() to assert resets before disabling clocks, so the teardown path mirrors the new init ordering.

Tu Nguyen committed 4 months ago

Commit bef90041 parent 0293dd11 file · +16 −16Browse files

Unified · Split

drivers/net/can/rcar/rcar_canfd.c+16−16
@@ -2003,20 +2003,12 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) · 2002 unmodified lines
2003 u32 ch, sts;2003 u32 ch, sts;
2004 int err;2004 int err;
2005 2005
2006 err = reset_control_reset(gpriv->rstc1);
2007 if (err)
2008 return err;
2009
2010 err = reset_control_reset(gpriv->rstc2);
2011 if (err)
2012 goto fail_reset1;
2013
2014 /* Enable peripheral clock for register access */2006 /* Enable peripheral clock for register access */
2015 err = clk_prepare_enable(gpriv->clkp);2007 err = clk_prepare_enable(gpriv->clkp);
2016 if (err) {2008 if (err) {
2017 dev_err(dev, "failed to enable peripheral clock: %pe\n",2009 dev_err(dev, "failed to enable peripheral clock: %pe\n",
2018 ERR_PTR(err));2010 ERR_PTR(err));
2019 goto fail_reset2;2011 return err;
2020 }2012 }
2021 2013
2022 /* Enable RAM clock */2014 /* Enable RAM clock */
@@ -2027,10 +2019,18 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) · 4 unmodified lines
2027 goto fail_clk;2019 goto fail_clk;
2028 }2020 }
2029 2021
2022 err = reset_control_reset(gpriv->rstc1);
2023 if (err)
2024 goto fail_ram_clk;
2025
2026 err = reset_control_reset(gpriv->rstc2);
2027 if (err)
2028 goto fail_reset1;
2029
2030 err = rcar_canfd_reset_controller(gpriv);2030 err = rcar_canfd_reset_controller(gpriv);
2031 if (err) {2031 if (err) {
2032 dev_err(dev, "reset controller failed: %pe\n", ERR_PTR(err));2032 dev_err(dev, "reset controller failed: %pe\n", ERR_PTR(err));
2033 goto fail_ram_clk;2033 goto fail_reset2;
2034 }2034 }
2035 2035
2036 /* Controller in Global reset & Channel reset mode */2036 /* Controller in Global reset & Channel reset mode */
@@ -2068,14 +2068,14 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) · 31 unmodified lines
2068 2068
2069fail_mode:2069fail_mode:
2070 rcar_canfd_disable_global_interrupts(gpriv);2070 rcar_canfd_disable_global_interrupts(gpriv);
2071fail_ram_clk:
2072 clk_disable_unprepare(gpriv->clk_ram);
2073fail_clk:
2074 clk_disable_unprepare(gpriv->clkp);
2075fail_reset2:2071fail_reset2:
2076 reset_control_assert(gpriv->rstc2);2072 reset_control_assert(gpriv->rstc2);
2077fail_reset1:2073fail_reset1:
2078 reset_control_assert(gpriv->rstc1);2074 reset_control_assert(gpriv->rstc1);
2075fail_ram_clk:
2076 clk_disable_unprepare(gpriv->clk_ram);
2077fail_clk:
2078 clk_disable_unprepare(gpriv->clkp);
2079 return err;2079 return err;
2080}2080}
2081 2081
@@ -2090,10 +2090,10 @@ static void rcar_canfd_global_deinit(struct rcar_canfd_global *gpriv, bool full) · 8 unmodified lines
2090 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR);2090 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR);
2091 }2091 }
2092 2092
2093 clk_disable_unprepare(gpriv->clk_ram);
2094 clk_disable_unprepare(gpriv->clkp);
2095 reset_control_assert(gpriv->rstc2);2093 reset_control_assert(gpriv->rstc2);
2096 reset_control_assert(gpriv->rstc1);2094 reset_control_assert(gpriv->rstc1);
2095 clk_disable_unprepare(gpriv->clk_ram);
2096 clk_disable_unprepare(gpriv->clkp);
2097}2097}
2098 2098
2099static int rcar_canfd_probe(struct platform_device *pdev)2099static int rcar_canfd_probe(struct platform_device *pdev)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t