108-v5.14-net-stmmac-explicitly-deassert-gmac-ahb-reset.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From e67f325e9cd67562b761e884680c0fec03a6f404 Mon Sep 17 00:00:00 2001
  2. From: Matthew Hagan <[email protected]>
  3. Date: Tue, 8 Jun 2021 19:59:06 +0100
  4. Subject: net: stmmac: explicitly deassert GMAC_AHB_RESET
  5. We are currently assuming that GMAC_AHB_RESET will already be deasserted
  6. by the bootloader. However if this has not been done, probing of the GMAC
  7. will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted
  8. prior to probing.
  9. v2 changes:
  10. - remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
  11. - unwrap dev_err() message in stmmac_main.c
  12. - add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c
  13. v3 changes:
  14. - add error pointer to dev_err() output
  15. - add reset_control_assert(stmmac_ahb_rst) in stmmac_dvr_remove
  16. - revert PTR_ERR() around plat->stmmac_ahb_rst since this is performed
  17. on the returned value of ret by the calling function
  18. Signed-off-by: Matthew Hagan <[email protected]>
  19. Signed-off-by: David S. Miller <[email protected]>
  20. ---
  21. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++
  22. drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++++++
  23. include/linux/stmmac.h | 1 +
  24. 3 files changed, 12 insertions(+)
  25. --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
  26. +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
  27. @@ -5046,6 +5046,10 @@ int stmmac_dvr_probe(struct device *devi
  28. reset_control_reset(priv->plat->stmmac_rst);
  29. }
  30. + ret = reset_control_deassert(priv->plat->stmmac_ahb_rst);
  31. + if (ret == -ENOTSUPP)
  32. + dev_err(priv->device, "unable to bring out of ahb reset\n");
  33. +
  34. /* Init MAC and get the capabilities */
  35. ret = stmmac_hw_init(priv);
  36. if (ret)
  37. @@ -5260,6 +5264,7 @@ int stmmac_dvr_remove(struct device *dev
  38. phylink_destroy(priv->phylink);
  39. if (priv->plat->stmmac_rst)
  40. reset_control_assert(priv->plat->stmmac_rst);
  41. + reset_control_assert(priv->plat->stmmac_ahb_rst);
  42. pm_runtime_put(dev);
  43. pm_runtime_disable(dev);
  44. if (priv->hw->pcs != STMMAC_PCS_TBI &&
  45. --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
  46. +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
  47. @@ -616,6 +616,12 @@ stmmac_probe_config_dt(struct platform_d
  48. plat->stmmac_rst = NULL;
  49. }
  50. + plat->stmmac_ahb_rst = devm_reset_control_get_optional_shared(
  51. + &pdev->dev, "ahb");
  52. + if (IS_ERR(plat->stmmac_ahb_rst))
  53. + if (PTR_ERR(plat->stmmac_ahb_rst) == -EPROBE_DEFER)
  54. + goto error_hw_init;
  55. +
  56. return plat;
  57. error_hw_init:
  58. --- a/include/linux/stmmac.h
  59. +++ b/include/linux/stmmac.h
  60. @@ -192,6 +192,7 @@ struct plat_stmmacenet_data {
  61. unsigned int clk_ref_rate;
  62. s32 ptp_max_adj;
  63. struct reset_control *stmmac_rst;
  64. + struct reset_control *stmmac_ahb_rst;
  65. struct stmmac_axi *axi;
  66. int has_gmac4;
  67. bool has_sun8i;