net: stmmac: explicitly deassert GMAC_AHB_RESET
authorMatthew Hagan <mnhagan88@gmail.com>
Tue, 8 Jun 2021 18:59:06 +0000 (19:59 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Jun 2021 23:42:12 +0000 (16:42 -0700)
We are currently assuming that GMAC_AHB_RESET will already be deasserted
by the bootloader. However if this has not been done, probing of the GMAC
will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted
prior to probing.

v2 changes:
 - remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
 - unwrap dev_err() message in stmmac_main.c
 - add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c

v3 changes:
 - add error pointer to dev_err() output
 - add reset_control_assert(stmmac_ahb_rst) in stmmac_dvr_remove
 - revert PTR_ERR() around plat->stmmac_ahb_rst since this is performed
   on the returned value of ret by the calling function

Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
include/linux/stmmac.h

index f2adff5..1c881ec 100644 (file)
@@ -6843,6 +6843,11 @@ int stmmac_dvr_probe(struct device *device,
                        reset_control_reset(priv->plat->stmmac_rst);
        }
 
+       ret = reset_control_deassert(priv->plat->stmmac_ahb_rst);
+       if (ret == -ENOTSUPP)
+               dev_err(priv->device, "unable to bring out of ahb reset: %pe\n",
+                       ERR_PTR(ret));
+
        /* Init MAC and get the capabilities */
        ret = stmmac_hw_init(priv);
        if (ret)
@@ -7086,6 +7091,7 @@ int stmmac_dvr_remove(struct device *dev)
        phylink_destroy(priv->phylink);
        if (priv->plat->stmmac_rst)
                reset_control_assert(priv->plat->stmmac_rst);
+       reset_control_assert(priv->plat->stmmac_ahb_rst);
        pm_runtime_put(dev);
        pm_runtime_disable(dev);
        if (priv->hw->pcs != STMMAC_PCS_TBI &&
index 97a1fed..d8ae58b 100644 (file)
@@ -600,6 +600,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
                goto error_hw_init;
        }
 
+       plat->stmmac_ahb_rst = devm_reset_control_get_optional_shared(
+                                                       &pdev->dev, "ahb");
+       if (IS_ERR(plat->stmmac_ahb_rst)) {
+               ret = plat->stmmac_ahb_rst;
+               goto error_hw_init;
+       }
+
        return plat;
 
 error_hw_init:
index b10be33..3867980 100644 (file)
@@ -240,6 +240,7 @@ struct plat_stmmacenet_data {
        unsigned int mult_fact_100ns;
        s32 ptp_max_adj;
        struct reset_control *stmmac_rst;
+       struct reset_control *stmmac_ahb_rst;
        struct stmmac_axi *axi;
        int has_gmac4;
        bool has_sun8i;