1 From e67f325e9cd67562b761e884680c0fec03a6f404 Mon Sep 17 00:00:00 2001
2 From: Matthew Hagan <mnhagan88@gmail.com>
3 Date: Tue, 8 Jun 2021 19:59:06 +0100
4 Subject: net: stmmac: explicitly deassert GMAC_AHB_RESET
6 We are currently assuming that GMAC_AHB_RESET will already be deasserted
7 by the bootloader. However if this has not been done, probing of the GMAC
8 will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted
12 - remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
13 - unwrap dev_err() message in stmmac_main.c
14 - add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c
17 - add error pointer to dev_err() output
18 - add reset_control_assert(stmmac_ahb_rst) in stmmac_dvr_remove
19 - revert PTR_ERR() around plat->stmmac_ahb_rst since this is performed
20 on the returned value of ret by the calling function
22 Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
23 Signed-off-by: David S. Miller <davem@davemloft.net>
25 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++
26 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++++++
27 include/linux/stmmac.h | 1 +
28 3 files changed, 12 insertions(+)
30 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
31 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
32 @@ -5020,6 +5020,10 @@ int stmmac_dvr_probe(struct device *devi
33 reset_control_reset(priv->plat->stmmac_rst);
36 + ret = reset_control_deassert(priv->plat->stmmac_ahb_rst);
37 + if (ret == -ENOTSUPP)
38 + dev_err(priv->device, "unable to bring out of ahb reset\n");
40 /* Init MAC and get the capabilities */
41 ret = stmmac_hw_init(priv);
43 @@ -5244,6 +5248,7 @@ int stmmac_dvr_remove(struct device *dev
44 phylink_destroy(priv->phylink);
45 if (priv->plat->stmmac_rst)
46 reset_control_assert(priv->plat->stmmac_rst);
47 + reset_control_assert(priv->plat->stmmac_ahb_rst);
49 pm_runtime_disable(dev);
50 if (priv->hw->pcs != STMMAC_PCS_TBI &&
51 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
52 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
53 @@ -616,6 +616,12 @@ stmmac_probe_config_dt(struct platform_d
54 plat->stmmac_rst = NULL;
57 + plat->stmmac_ahb_rst = devm_reset_control_get_optional_shared(
59 + if (IS_ERR(plat->stmmac_ahb_rst))
60 + if (PTR_ERR(plat->stmmac_ahb_rst) == -EPROBE_DEFER)
66 --- a/include/linux/stmmac.h
67 +++ b/include/linux/stmmac.h
68 @@ -192,6 +192,7 @@ struct plat_stmmacenet_data {
69 unsigned int clk_ref_rate;
71 struct reset_control *stmmac_rst;
72 + struct reset_control *stmmac_ahb_rst;
73 struct stmmac_axi *axi;