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
20032003 u32 ch, sts;
20042004 int err;
20052005
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−
20142006 /* Enable peripheral clock for register access */
20152007 err = clk_prepare_enable(gpriv->clkp);
20162008 if (err) {
20172009 dev_err(dev, "failed to enable peripheral clock: %pe\n",
20182010 ERR_PTR(err));
2019− goto fail_reset2;
2011+ return err;
20202012 }
20212013
20222014 /* Enable RAM clock */
@@ -2027,10 +2019,18 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) · 4 unmodified lines
20272019 goto fail_clk;
20282020 }
20292021
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+
20302030 err = rcar_canfd_reset_controller(gpriv);
20312031 if (err) {
20322032 dev_err(dev, "reset controller failed: %pe\n", ERR_PTR(err));
2033− goto fail_ram_clk;
2033+ goto fail_reset2;
20342034 }
20352035
20362036 /* 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
20682068
20692069 fail_mode:
20702070 rcar_canfd_disable_global_interrupts(gpriv);
2071−fail_ram_clk:
2072− clk_disable_unprepare(gpriv->clk_ram);
2073−fail_clk:
2074− clk_disable_unprepare(gpriv->clkp);
20752071 fail_reset2:
20762072 reset_control_assert(gpriv->rstc2);
20772073 fail_reset1:
20782074 reset_control_assert(gpriv->rstc1);
2075+fail_ram_clk:
2076+ clk_disable_unprepare(gpriv->clk_ram);
2077+fail_clk:
2078+ clk_disable_unprepare(gpriv->clkp);
20792079 return err;
20802080 }
20812081
@@ -2090,10 +2090,10 @@ static void rcar_canfd_global_deinit(struct rcar_canfd_global *gpriv, bool full) · 8 unmodified lines
20902090 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR);
20912091 }
20922092
2093− clk_disable_unprepare(gpriv->clk_ram);
2094− clk_disable_unprepare(gpriv->clkp);
20952093 reset_control_assert(gpriv->rstc2);
20962094 reset_control_assert(gpriv->rstc1);
2095+ clk_disable_unprepare(gpriv->clk_ram);
2096+ clk_disable_unprepare(gpriv->clkp);
20972097 }
20982098
20992099 static 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