0511-net-mediatek-add-support-for-the-multiphy-carrier-pa.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 6543b4cef96c12903f5ec5c015cd223a6b3c9a33 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Mon, 14 Dec 2015 21:16:59 +0100
  4. Subject: [PATCH 511/513] net: mediatek: add support for the multiphy carrier
  5. patch
  6. Signed-off-by: John Crispin <blogic@openwrt.org>
  7. ---
  8. drivers/net/ethernet/mediatek/gsw_mt7620.c | 1 +
  9. drivers/net/ethernet/mediatek/gsw_mt7620.h | 1 +
  10. drivers/net/ethernet/mediatek/gsw_mt7621.c | 1 +
  11. drivers/net/ethernet/mediatek/mdio.c | 1 +
  12. drivers/net/ethernet/mediatek/mdio_mt7620.c | 12 ++++++++++++
  13. 5 files changed, 16 insertions(+)
  14. --- a/drivers/net/ethernet/mediatek/gsw_mt7620.c
  15. +++ b/drivers/net/ethernet/mediatek/gsw_mt7620.c
  16. @@ -54,6 +54,7 @@ static irqreturn_t gsw_interrupt_mt7620(
  17. priv->link[i] = link;
  18. }
  19. + mt7620_handle_carrier(priv);
  20. mtk_switch_w32(gsw, status, GSW_REG_ISR);
  21. return IRQ_HANDLED;
  22. --- a/drivers/net/ethernet/mediatek/gsw_mt7620.h
  23. +++ b/drivers/net/ethernet/mediatek/gsw_mt7620.h
  24. @@ -113,5 +113,6 @@ u32 mt7530_mdio_r32(struct mt7620_gsw *g
  25. u32 _mt7620_mii_write(struct mt7620_gsw *gsw, u32 phy_addr,
  26. u32 phy_register, u32 write_data);
  27. u32 _mt7620_mii_read(struct mt7620_gsw *gsw, int phy_addr, int phy_reg);
  28. +void mt7620_handle_carrier(struct fe_priv *priv);
  29. #endif
  30. --- a/drivers/net/ethernet/mediatek/gsw_mt7621.c
  31. +++ b/drivers/net/ethernet/mediatek/gsw_mt7621.c
  32. @@ -60,6 +60,7 @@ static irqreturn_t gsw_interrupt_mt7621(
  33. }
  34. }
  35. + mt7620_handle_carrier(priv);
  36. mt7530_mdio_w32(gsw, 0x700c, 0x1f);
  37. return IRQ_HANDLED;
  38. --- a/drivers/net/ethernet/mediatek/mdio.c
  39. +++ b/drivers/net/ethernet/mediatek/mdio.c
  40. @@ -89,6 +89,7 @@ int fe_connect_phy_node(struct fe_priv *
  41. phydev->supported &= PHY_GBIT_FEATURES;
  42. phydev->advertising = phydev->supported;
  43. + phydev->no_auto_carrier_off = 1;
  44. dev_info(priv->device,
  45. "connected port %d to PHY at %s [uid=%08x, driver=%s]\n",
  46. --- a/drivers/net/ethernet/mediatek/mdio_mt7620.c
  47. +++ b/drivers/net/ethernet/mediatek/mdio_mt7620.c
  48. @@ -137,6 +137,17 @@ int mt7620_has_carrier(struct fe_priv *p
  49. }
  50. +void mt7620_handle_carrier(struct fe_priv *priv)
  51. +{
  52. + if (!priv->phy)
  53. + return;
  54. +
  55. + if (mt7620_has_carrier(priv))
  56. + netif_carrier_on(priv->netdev);
  57. + else
  58. + netif_carrier_off(priv->netdev);
  59. +}
  60. +
  61. void mt7620_print_link_state(struct fe_priv *priv, int port, int link,
  62. int speed, int duplex)
  63. {
  64. @@ -153,4 +164,5 @@ void mt7620_mdio_link_adjust(struct fe_p
  65. mt7620_print_link_state(priv, port, priv->link[port],
  66. priv->phy->speed[port],
  67. (priv->phy->duplex[port] == DUPLEX_FULL));
  68. + mt7620_handle_carrier(priv);
  69. }