075-v4.10-0004-net-phy-broadcom-Add-BCM54810-PHY-entry.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. From: Jon Mason <jon.mason@broadcom.com>
  2. Date: Fri, 4 Nov 2016 01:10:58 -0400
  3. Subject: [PATCH] net: phy: broadcom: Add BCM54810 PHY entry
  4. The BCM54810 PHY requires some semi-unique configuration, which results
  5. in some additional configuration in addition to the standard config.
  6. Also, some users of the BCM54810 require the PHY lanes to be swapped.
  7. Since there is no way to detect this, add a device tree query to see if
  8. it is applicable.
  9. Inspired-by: Vikas Soni <vsoni@broadcom.com>
  10. Signed-off-by: Jon Mason <jon.mason@broadcom.com>
  11. Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
  12. Reviewed-by: Andrew Lunn <andrew@lunn.ch>
  13. Signed-off-by: David S. Miller <davem@davemloft.net>
  14. ---
  15. --- a/drivers/net/phy/broadcom.c
  16. +++ b/drivers/net/phy/broadcom.c
  17. @@ -18,7 +18,7 @@
  18. #include <linux/module.h>
  19. #include <linux/phy.h>
  20. #include <linux/brcmphy.h>
  21. -
  22. +#include <linux/of.h>
  23. #define BRCM_PHY_MODEL(phydev) \
  24. ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
  25. @@ -45,6 +45,34 @@ static int bcm54xx_auxctl_write(struct p
  26. return phy_write(phydev, MII_BCM54XX_AUX_CTL, regnum | val);
  27. }
  28. +static int bcm54810_config(struct phy_device *phydev)
  29. +{
  30. + int rc, val;
  31. +
  32. + val = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
  33. + val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
  34. + rc = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
  35. + val);
  36. + if (rc < 0)
  37. + return rc;
  38. +
  39. + val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  40. + val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
  41. + val |= MII_BCM54XX_AUXCTL_MISC_WREN;
  42. + rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  43. + val);
  44. + if (rc < 0)
  45. + return rc;
  46. +
  47. + val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
  48. + val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
  49. + rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
  50. + if (rc < 0)
  51. + return rc;
  52. +
  53. + return 0;
  54. +}
  55. +
  56. /* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
  57. static int bcm50610_a0_workaround(struct phy_device *phydev)
  58. {
  59. @@ -217,6 +245,12 @@ static int bcm54xx_config_init(struct ph
  60. (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
  61. bcm54xx_adjust_rxrefclk(phydev);
  62. + if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
  63. + err = bcm54810_config(phydev);
  64. + if (err)
  65. + return err;
  66. + }
  67. +
  68. bcm54xx_phydsp_config(phydev);
  69. return 0;
  70. @@ -314,6 +348,7 @@ static int bcm5482_read_status(struct ph
  71. static int bcm5481_config_aneg(struct phy_device *phydev)
  72. {
  73. + struct device_node *np = phydev->mdio.dev.of_node;
  74. int ret;
  75. /* Aneg firsly. */
  76. @@ -344,6 +379,14 @@ static int bcm5481_config_aneg(struct ph
  77. phy_write(phydev, 0x18, reg);
  78. }
  79. + if (of_property_read_bool(np, "enet-phy-lane-swap")) {
  80. + /* Lane Swap - Undocumented register...magic! */
  81. + ret = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0x9,
  82. + 0x11B);
  83. + if (ret < 0)
  84. + return ret;
  85. + }
  86. +
  87. return ret;
  88. }
  89. @@ -578,6 +621,18 @@ static struct phy_driver broadcom_driver
  90. .ack_interrupt = bcm_phy_ack_intr,
  91. .config_intr = bcm_phy_config_intr,
  92. }, {
  93. + .phy_id = PHY_ID_BCM54810,
  94. + .phy_id_mask = 0xfffffff0,
  95. + .name = "Broadcom BCM54810",
  96. + .features = PHY_GBIT_FEATURES |
  97. + SUPPORTED_Pause | SUPPORTED_Asym_Pause,
  98. + .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
  99. + .config_init = bcm54xx_config_init,
  100. + .config_aneg = bcm5481_config_aneg,
  101. + .read_status = genphy_read_status,
  102. + .ack_interrupt = bcm_phy_ack_intr,
  103. + .config_intr = bcm_phy_config_intr,
  104. +}, {
  105. .phy_id = PHY_ID_BCM5482,
  106. .phy_id_mask = 0xfffffff0,
  107. .name = "Broadcom BCM5482",
  108. @@ -661,6 +716,7 @@ static struct mdio_device_id __maybe_unu
  109. { PHY_ID_BCM54616S, 0xfffffff0 },
  110. { PHY_ID_BCM5464, 0xfffffff0 },
  111. { PHY_ID_BCM5481, 0xfffffff0 },
  112. + { PHY_ID_BCM54810, 0xfffffff0 },
  113. { PHY_ID_BCM5482, 0xfffffff0 },
  114. { PHY_ID_BCM50610, 0xfffffff0 },
  115. { PHY_ID_BCM50610M, 0xfffffff0 },
  116. --- a/drivers/net/phy/Kconfig
  117. +++ b/drivers/net/phy/Kconfig
  118. @@ -204,7 +204,7 @@ config BROADCOM_PHY
  119. select BCM_NET_PHYLIB
  120. ---help---
  121. Currently supports the BCM5411, BCM5421, BCM5461, BCM54616S, BCM5464,
  122. - BCM5481 and BCM5482 PHYs.
  123. + BCM5481, BCM54810 and BCM5482 PHYs.
  124. config CICADA_PHY
  125. tristate "Cicada PHYs"
  126. --- a/include/linux/brcmphy.h
  127. +++ b/include/linux/brcmphy.h
  128. @@ -13,6 +13,7 @@
  129. #define PHY_ID_BCM5241 0x0143bc30
  130. #define PHY_ID_BCMAC131 0x0143bc70
  131. #define PHY_ID_BCM5481 0x0143bca0
  132. +#define PHY_ID_BCM54810 0x03625d00
  133. #define PHY_ID_BCM5482 0x0143bcb0
  134. #define PHY_ID_BCM5411 0x00206070
  135. #define PHY_ID_BCM5421 0x002060e0
  136. @@ -56,6 +57,7 @@
  137. #define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00002000
  138. #define PHY_BRCM_CLEAR_RGMII_MODE 0x00004000
  139. #define PHY_BRCM_DIS_TXCRXC_NOENRGY 0x00008000
  140. +
  141. /* Broadcom BCM7xxx specific workarounds */
  142. #define PHY_BRCM_7XXX_REV(x) (((x) >> 8) & 0xff)
  143. #define PHY_BRCM_7XXX_PATCH(x) ((x) & 0xff)
  144. @@ -111,6 +113,7 @@
  145. #define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC 0x7000
  146. #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC 0x0007
  147. #define MII_BCM54XX_AUXCTL_SHDWSEL_READ_SHIFT 12
  148. +#define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN (1 << 8)
  149. #define MII_BCM54XX_AUXCTL_SHDWSEL_MASK 0x0007
  150. @@ -192,6 +195,12 @@
  151. #define BCM5482_SSD_SGMII_SLAVE_EN 0x0002 /* Slave mode enable */
  152. #define BCM5482_SSD_SGMII_SLAVE_AD 0x0001 /* Slave auto-detection */
  153. +/* BCM54810 Registers */
  154. +#define BCM54810_EXP_BROADREACH_LRE_MISC_CTL (MII_BCM54XX_EXP_SEL_ER + 0x90)
  155. +#define BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN (1 << 0)
  156. +#define BCM54810_SHD_CLK_CTL 0x3
  157. +#define BCM54810_SHD_CLK_CTL_GTXCLK_EN (1 << 9)
  158. +
  159. /*****************************************************************************/
  160. /* Fast Ethernet Transceiver definitions. */