1
0

735-net-phy-at803x-fix-at8033-sgmii-mode.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. --- a/drivers/net/phy/at803x.c
  2. +++ b/drivers/net/phy/at803x.c
  3. @@ -36,6 +36,9 @@
  4. #define AT803X_INER 0x0012
  5. #define AT803X_INER_INIT 0xec00
  6. #define AT803X_INSR 0x0013
  7. +#define AT803X_REG_CHIP_CONFIG 0x1f
  8. +#define AT803X_BT_BX_REG_SEL 0x8000
  9. +#define AT803X_SGMII_ANEG_EN 0x1000
  10. #define AT803X_PCS_SMART_EEE_CTRL3 0x805D
  11. #define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3
  12. @@ -49,9 +52,10 @@
  13. #define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05
  14. #define AT803X_DEBUG_RGMII_TX_CLK_DLY BIT(8)
  15. -#define ATH8030_PHY_ID 0x004dd076
  16. -#define ATH8031_PHY_ID 0x004dd074
  17. -#define ATH8035_PHY_ID 0x004dd072
  18. +#define AT803X_PHY_ID_MASK 0xffffffef
  19. +#define ATH8030_PHY_ID 0x004dd076
  20. +#define ATH8031_PHY_ID 0x004dd074
  21. +#define ATH8035_PHY_ID 0x004dd072
  22. MODULE_DESCRIPTION("Atheros 803x PHY driver");
  23. MODULE_AUTHOR("Matus Ujhelyi");
  24. @@ -268,6 +272,27 @@ static int at803x_config_init(struct phy
  25. {
  26. struct at803x_platform_data *pdata;
  27. int ret;
  28. + u32 v;
  29. +
  30. + if (phydev->drv->phy_id == ATH8031_PHY_ID &&
  31. + phydev->interface == PHY_INTERFACE_MODE_SGMII)
  32. + {
  33. + v = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
  34. + /* select SGMII/fiber page */
  35. + ret = phy_write(phydev, AT803X_REG_CHIP_CONFIG,
  36. + v & ~AT803X_BT_BX_REG_SEL);
  37. + if (ret)
  38. + return ret;
  39. + /* enable SGMII autonegotiation */
  40. + ret = phy_write(phydev, MII_BMCR, AT803X_SGMII_ANEG_EN);
  41. + if (ret)
  42. + return ret;
  43. + /* select copper page */
  44. + ret = phy_write(phydev, AT803X_REG_CHIP_CONFIG,
  45. + v | AT803X_BT_BX_REG_SEL);
  46. + if (ret)
  47. + return ret;
  48. + }
  49. ret = genphy_config_init(phydev);
  50. if (ret < 0)
  51. @@ -394,7 +419,7 @@ static struct phy_driver at803x_driver[]
  52. /* ATHEROS 8035 */
  53. .phy_id = ATH8035_PHY_ID,
  54. .name = "Atheros 8035 ethernet",
  55. - .phy_id_mask = 0xffffffef,
  56. + .phy_id_mask = AT803X_PHY_ID_MASK,
  57. .probe = at803x_probe,
  58. .config_init = at803x_config_init,
  59. .link_change_notify = at803x_link_change_notify,
  60. @@ -415,7 +440,7 @@ static struct phy_driver at803x_driver[]
  61. /* ATHEROS 8030 */
  62. .phy_id = ATH8030_PHY_ID,
  63. .name = "Atheros 8030 ethernet",
  64. - .phy_id_mask = 0xffffffef,
  65. + .phy_id_mask = AT803X_PHY_ID_MASK,
  66. .probe = at803x_probe,
  67. .config_init = at803x_config_init,
  68. .link_change_notify = at803x_link_change_notify,
  69. @@ -435,8 +460,8 @@ static struct phy_driver at803x_driver[]
  70. }, {
  71. /* ATHEROS 8031 */
  72. .phy_id = ATH8031_PHY_ID,
  73. - .name = "Atheros 8031 ethernet",
  74. - .phy_id_mask = 0xffffffef,
  75. + .name = "Atheros 8031/8033 ethernet",
  76. + .phy_id_mask = AT803X_PHY_ID_MASK,
  77. .probe = at803x_probe,
  78. .config_init = at803x_config_init,
  79. .link_change_notify = at803x_link_change_notify,
  80. @@ -458,9 +483,9 @@ static struct phy_driver at803x_driver[]
  81. module_phy_driver(at803x_driver);
  82. static struct mdio_device_id __maybe_unused atheros_tbl[] = {
  83. - { ATH8030_PHY_ID, 0xffffffef },
  84. - { ATH8031_PHY_ID, 0xffffffef },
  85. - { ATH8035_PHY_ID, 0xffffffef },
  86. + { ATH8030_PHY_ID, AT803X_PHY_ID_MASK },
  87. + { ATH8031_PHY_ID, AT803X_PHY_ID_MASK },
  88. + { ATH8035_PHY_ID, AT803X_PHY_ID_MASK },
  89. { }
  90. };