078-0004-net-phy-cherry-pick-Broadcom-drivers-updates-from-v4.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  2. Subject: [PATCH] net: phy: cherry-pick Broadcom drivers updates from v4.11
  3. MIME-Version: 1.0
  4. Content-Type: text/plain; charset=UTF-8
  5. Content-Transfer-Encoding: 8bit
  6. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  7. ---
  8. --- a/drivers/net/phy/broadcom.c
  9. +++ b/drivers/net/phy/broadcom.c
  10. @@ -30,6 +30,50 @@ MODULE_DESCRIPTION("Broadcom PHY driver"
  11. MODULE_AUTHOR("Maciej W. Rozycki");
  12. MODULE_LICENSE("GPL");
  13. +static int bcm54210e_config_init(struct phy_device *phydev)
  14. +{
  15. + int val;
  16. +
  17. + val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  18. + val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
  19. + val |= MII_BCM54XX_AUXCTL_MISC_WREN;
  20. + bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, val);
  21. +
  22. + val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
  23. + val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
  24. + bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
  25. +
  26. + return 0;
  27. +}
  28. +
  29. +static int bcm54612e_config_init(struct phy_device *phydev)
  30. +{
  31. + /* Clear TX internal delay unless requested. */
  32. + if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  33. + (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
  34. + /* Disable TXD to GTXCLK clock delay (default set) */
  35. + /* Bit 9 is the only field in shadow register 00011 */
  36. + bcm_phy_write_shadow(phydev, 0x03, 0);
  37. + }
  38. +
  39. + /* Clear RX internal delay unless requested. */
  40. + if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  41. + (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
  42. + u16 reg;
  43. +
  44. + reg = bcm54xx_auxctl_read(phydev,
  45. + MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  46. + /* Disable RXD to RXC delay (default set) */
  47. + reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
  48. + /* Clear shadow selector field */
  49. + reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
  50. + bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  51. + MII_BCM54XX_AUXCTL_MISC_WREN | reg);
  52. + }
  53. +
  54. + return 0;
  55. +}
  56. +
  57. static int bcm54810_config(struct phy_device *phydev)
  58. {
  59. int rc, val;
  60. @@ -230,7 +274,15 @@ static int bcm54xx_config_init(struct ph
  61. (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
  62. bcm54xx_adjust_rxrefclk(phydev);
  63. - if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
  64. + if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E) {
  65. + err = bcm54210e_config_init(phydev);
  66. + if (err)
  67. + return err;
  68. + } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54612E) {
  69. + err = bcm54612e_config_init(phydev);
  70. + if (err)
  71. + return err;
  72. + } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
  73. err = bcm54810_config(phydev);
  74. if (err)
  75. return err;
  76. @@ -375,41 +427,6 @@ static int bcm5481_config_aneg(struct ph
  77. return ret;
  78. }
  79. -static int bcm54612e_config_aneg(struct phy_device *phydev)
  80. -{
  81. - int ret;
  82. -
  83. - /* First, auto-negotiate. */
  84. - ret = genphy_config_aneg(phydev);
  85. -
  86. - /* Clear TX internal delay unless requested. */
  87. - if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  88. - (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
  89. - /* Disable TXD to GTXCLK clock delay (default set) */
  90. - /* Bit 9 is the only field in shadow register 00011 */
  91. - bcm_phy_write_shadow(phydev, 0x03, 0);
  92. - }
  93. -
  94. - /* Clear RX internal delay unless requested. */
  95. - if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  96. - (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
  97. - u16 reg;
  98. -
  99. - /* Errata: reads require filling in the write selector field */
  100. - bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  101. - MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC);
  102. - reg = phy_read(phydev, MII_BCM54XX_AUX_CTL);
  103. - /* Disable RXD to RXC delay (default set) */
  104. - reg &= ~MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW;
  105. - /* Clear shadow selector field */
  106. - reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
  107. - bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  108. - MII_BCM54XX_AUXCTL_MISC_WREN | reg);
  109. - }
  110. -
  111. - return ret;
  112. -}
  113. -
  114. static int brcm_phy_setbits(struct phy_device *phydev, int reg, int set)
  115. {
  116. int val;
  117. @@ -548,6 +565,19 @@ static struct phy_driver broadcom_driver
  118. .config_intr = bcm_phy_config_intr,
  119. .driver = { .owner = THIS_MODULE },
  120. }, {
  121. + .phy_id = PHY_ID_BCM54210E,
  122. + .phy_id_mask = 0xfffffff0,
  123. + .name = "Broadcom BCM54210E",
  124. + .features = PHY_GBIT_FEATURES |
  125. + SUPPORTED_Pause | SUPPORTED_Asym_Pause,
  126. + .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
  127. + .config_init = bcm54xx_config_init,
  128. + .config_aneg = genphy_config_aneg,
  129. + .read_status = genphy_read_status,
  130. + .ack_interrupt = bcm_phy_ack_intr,
  131. + .config_intr = bcm_phy_config_intr,
  132. + .driver = { .owner = THIS_MODULE },
  133. +}, {
  134. .phy_id = PHY_ID_BCM5461,
  135. .phy_id_mask = 0xfffffff0,
  136. .name = "Broadcom BCM5461",
  137. @@ -568,7 +598,7 @@ static struct phy_driver broadcom_driver
  138. SUPPORTED_Pause | SUPPORTED_Asym_Pause,
  139. .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
  140. .config_init = bcm54xx_config_init,
  141. - .config_aneg = bcm54612e_config_aneg,
  142. + .config_aneg = genphy_config_aneg,
  143. .read_status = genphy_read_status,
  144. .ack_interrupt = bcm_phy_ack_intr,
  145. .config_intr = bcm_phy_config_intr,
  146. @@ -710,6 +740,7 @@ module_phy_driver(broadcom_drivers);
  147. static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
  148. { PHY_ID_BCM5411, 0xfffffff0 },
  149. { PHY_ID_BCM5421, 0xfffffff0 },
  150. + { PHY_ID_BCM54210E, 0xfffffff0 },
  151. { PHY_ID_BCM5461, 0xfffffff0 },
  152. { PHY_ID_BCM54612E, 0xfffffff0 },
  153. { PHY_ID_BCM54616S, 0xfffffff0 },
  154. --- a/include/linux/brcmphy.h
  155. +++ b/include/linux/brcmphy.h
  156. @@ -17,6 +17,7 @@
  157. #define PHY_ID_BCM5482 0x0143bcb0
  158. #define PHY_ID_BCM5411 0x00206070
  159. #define PHY_ID_BCM5421 0x002060e0
  160. +#define PHY_ID_BCM54210E 0x600d84a0
  161. #define PHY_ID_BCM5464 0x002060b0
  162. #define PHY_ID_BCM5461 0x002060c0
  163. #define PHY_ID_BCM54612E 0x03625e60