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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From: Roman Yeryomin <roman@advem.lv>
  2. Subject: kernel: add at803x fix for sgmii mode
  3. Some (possibly broken) bootloaders incorreclty initialize at8033
  4. phy. This patch enables sgmii autonegotiation mode.
  5. [john@phrozen.org: felix added this to his upstream queue]
  6. Signed-off-by: Roman Yeryomin <roman@advem.lv>
  7. ---
  8. drivers/net/phy/at803x.c | 25 +++++++++++++++++++++++++
  9. 1 file changed, 25 insertions(+)
  10. --- a/drivers/net/phy/at803x.c
  11. +++ b/drivers/net/phy/at803x.c
  12. @@ -46,6 +46,7 @@
  13. #define AT803X_FUNC_DATA 0x4003
  14. #define AT803X_REG_CHIP_CONFIG 0x1f
  15. #define AT803X_BT_BX_REG_SEL 0x8000
  16. +#define AT803X_SGMII_ANEG_EN 0x1000
  17. #define AT803X_PCS_SMART_EEE_CTRL3 0x805D
  18. #define AT803X_SMART_EEE_CTRL3_LPI_TX_DELAY_SEL_MASK 0x3
  19. @@ -295,6 +296,27 @@ static int at803x_config_init(struct phy
  20. {
  21. struct at803x_platform_data *pdata;
  22. int ret;
  23. + u32 v;
  24. +
  25. + if (phydev->drv->phy_id == ATH8031_PHY_ID &&
  26. + phydev->interface == PHY_INTERFACE_MODE_SGMII)
  27. + {
  28. + v = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
  29. + /* select SGMII/fiber page */
  30. + ret = phy_write(phydev, AT803X_REG_CHIP_CONFIG,
  31. + v & ~AT803X_BT_BX_REG_SEL);
  32. + if (ret)
  33. + return ret;
  34. + /* enable SGMII autonegotiation */
  35. + ret = phy_write(phydev, MII_BMCR, AT803X_SGMII_ANEG_EN);
  36. + if (ret)
  37. + return ret;
  38. + /* select copper page */
  39. + ret = phy_write(phydev, AT803X_REG_CHIP_CONFIG,
  40. + v | AT803X_BT_BX_REG_SEL);
  41. + if (ret)
  42. + return ret;
  43. + }
  44. ret = genphy_config_init(phydev);
  45. if (ret < 0)