1
0

076-v4.11-0007-net-phy-broadcom-rehook-BCM54612E-specific-init.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  2. Date: Tue, 31 Jan 2017 22:54:54 +0100
  3. Subject: [PATCH] net: phy: broadcom: rehook BCM54612E specific init
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. This extra BCM54612E code in PHY driver isn't really aneg specific. Even
  8. without it aneg works OK but the problem is no packets pass through PHY.
  9. Moreover putting this code inside config_aneg callback didn't allow
  10. resuming PHY correctly. When driver called phy_stop and phy_start it was
  11. putting PHY machine into RESUMING state. After that machine was
  12. switching into AN and NOLINK without ever calling phy_start_aneg. This
  13. prevented this extra setup from being called and PHY didn't work.
  14. This change has been verified to fix network on BCM47186B0 SoC device
  15. with BCM54612E.
  16. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  17. Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
  18. Signed-off-by: David S. Miller <davem@davemloft.net>
  19. ---
  20. --- a/drivers/net/phy/broadcom.c
  21. +++ b/drivers/net/phy/broadcom.c
  22. @@ -46,6 +46,34 @@ static int bcm54210e_config_init(struct
  23. return 0;
  24. }
  25. +static int bcm54612e_config_init(struct phy_device *phydev)
  26. +{
  27. + /* Clear TX internal delay unless requested. */
  28. + if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  29. + (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
  30. + /* Disable TXD to GTXCLK clock delay (default set) */
  31. + /* Bit 9 is the only field in shadow register 00011 */
  32. + bcm_phy_write_shadow(phydev, 0x03, 0);
  33. + }
  34. +
  35. + /* Clear RX internal delay unless requested. */
  36. + if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  37. + (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
  38. + u16 reg;
  39. +
  40. + reg = bcm54xx_auxctl_read(phydev,
  41. + MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  42. + /* Disable RXD to RXC delay (default set) */
  43. + reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
  44. + /* Clear shadow selector field */
  45. + reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
  46. + bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  47. + MII_BCM54XX_AUXCTL_MISC_WREN | reg);
  48. + }
  49. +
  50. + return 0;
  51. +}
  52. +
  53. static int bcm54810_config(struct phy_device *phydev)
  54. {
  55. int rc, val;
  56. @@ -250,6 +278,10 @@ static int bcm54xx_config_init(struct ph
  57. err = bcm54210e_config_init(phydev);
  58. if (err)
  59. return err;
  60. + } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54612E) {
  61. + err = bcm54612e_config_init(phydev);
  62. + if (err)
  63. + return err;
  64. } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
  65. err = bcm54810_config(phydev);
  66. if (err)
  67. @@ -395,39 +427,6 @@ static int bcm5481_config_aneg(struct ph
  68. return ret;
  69. }
  70. -static int bcm54612e_config_aneg(struct phy_device *phydev)
  71. -{
  72. - int ret;
  73. -
  74. - /* First, auto-negotiate. */
  75. - ret = genphy_config_aneg(phydev);
  76. -
  77. - /* Clear TX internal delay unless requested. */
  78. - if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  79. - (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) {
  80. - /* Disable TXD to GTXCLK clock delay (default set) */
  81. - /* Bit 9 is the only field in shadow register 00011 */
  82. - bcm_phy_write_shadow(phydev, 0x03, 0);
  83. - }
  84. -
  85. - /* Clear RX internal delay unless requested. */
  86. - if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) &&
  87. - (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) {
  88. - u16 reg;
  89. -
  90. - reg = bcm54xx_auxctl_read(phydev,
  91. - MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
  92. - /* Disable RXD to RXC delay (default set) */
  93. - reg &= ~MII_BCM54XX_AUXCTL_MISC_RXD_RXC_SKEW;
  94. - /* Clear shadow selector field */
  95. - reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK;
  96. - bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
  97. - MII_BCM54XX_AUXCTL_MISC_WREN | reg);
  98. - }
  99. -
  100. - return ret;
  101. -}
  102. -
  103. static int brcm_phy_setbits(struct phy_device *phydev, int reg, int set)
  104. {
  105. int val;
  106. @@ -594,7 +593,7 @@ static struct phy_driver broadcom_driver
  107. SUPPORTED_Pause | SUPPORTED_Asym_Pause,
  108. .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
  109. .config_init = bcm54xx_config_init,
  110. - .config_aneg = bcm54612e_config_aneg,
  111. + .config_aneg = genphy_config_aneg,
  112. .read_status = genphy_read_status,
  113. .ack_interrupt = bcm_phy_ack_intr,
  114. .config_intr = bcm_phy_config_intr,