427-phylink-add-EEE-support.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From: Russell King <[email protected]>
  2. Date: Thu, 1 Oct 2015 21:19:53 +0100
  3. Subject: [PATCH] phylink: add EEE support
  4. Add EEE hooks to phylink to allow the phylib EEE functions for the
  5. connected phy to be safely accessed.
  6. Signed-off-by: Russell King <[email protected]>
  7. ---
  8. --- a/drivers/net/ethernet/marvell/mvneta.c
  9. +++ b/drivers/net/ethernet/marvell/mvneta.c
  10. @@ -3306,7 +3306,8 @@ static void mvneta_mac_link_down(struct
  11. }
  12. }
  13. -static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode)
  14. +static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
  15. + struct phy_device *phy)
  16. {
  17. struct mvneta_port *pp = netdev_priv(ndev);
  18. u32 val;
  19. --- a/drivers/net/phy/phylink.c
  20. +++ b/drivers/net/phy/phylink.c
  21. @@ -379,7 +379,8 @@ static void phylink_resolve(struct work_
  22. if (pl->phydev)
  23. phylink_mac_config(pl, &link_state);
  24. - pl->ops->mac_link_up(ndev, pl->link_an_mode);
  25. + pl->ops->mac_link_up(ndev, pl->link_an_mode,
  26. + pl->phydev);
  27. netif_carrier_on(ndev);
  28. @@ -929,6 +930,58 @@ int phylink_ethtool_set_pauseparam(struc
  29. }
  30. EXPORT_SYMBOL_GPL(phylink_ethtool_set_pauseparam);
  31. +int phylink_init_eee(struct phylink *pl, bool clk_stop_enable)
  32. +{
  33. + int ret = -EPROTONOSUPPORT;
  34. +
  35. + mutex_lock(&pl->config_mutex);
  36. + if (pl->phydev)
  37. + ret = phy_init_eee(pl->phydev, clk_stop_enable);
  38. + mutex_unlock(&pl->config_mutex);
  39. +
  40. + return ret;
  41. +}
  42. +EXPORT_SYMBOL_GPL(phylink_init_eee);
  43. +
  44. +int phylink_get_eee_err(struct phylink *pl)
  45. +{
  46. + int ret = 0;
  47. +
  48. + mutex_lock(&pl->config_mutex);
  49. + if (pl->phydev)
  50. + ret = phy_get_eee_err(pl->phydev);
  51. + mutex_unlock(&pl->config_mutex);
  52. +
  53. + return ret;
  54. +}
  55. +EXPORT_SYMBOL_GPL(phylink_get_eee_err);
  56. +
  57. +int phylink_ethtool_get_eee(struct phylink *pl, struct ethtool_eee *eee)
  58. +{
  59. + int ret = -EOPNOTSUPP;
  60. +
  61. + mutex_lock(&pl->config_mutex);
  62. + if (pl->phydev)
  63. + ret = phy_ethtool_get_eee(pl->phydev, eee);
  64. + mutex_unlock(&pl->config_mutex);
  65. +
  66. + return ret;
  67. +}
  68. +EXPORT_SYMBOL_GPL(phylink_ethtool_get_eee);
  69. +
  70. +int phylink_ethtool_set_eee(struct phylink *pl, struct ethtool_eee *eee)
  71. +{
  72. + int ret = -EOPNOTSUPP;
  73. +
  74. + mutex_lock(&pl->config_mutex);
  75. + if (pl->phydev)
  76. + ret = phy_ethtool_set_eee(pl->phydev, eee);
  77. + mutex_unlock(&pl->config_mutex);
  78. +
  79. + return ret;
  80. +}
  81. +EXPORT_SYMBOL_GPL(phylink_ethtool_set_eee);
  82. +
  83. /* This emulates MII registers for a fixed-mode phy operating as per the
  84. * passed in state. "aneg" defines if we report negotiation is possible.
  85. *
  86. --- a/include/linux/phylink.h
  87. +++ b/include/linux/phylink.h
  88. @@ -70,7 +70,8 @@ struct phylink_mac_ops {
  89. void (*mac_an_restart)(struct net_device *, unsigned int mode);
  90. void (*mac_link_down)(struct net_device *, unsigned int mode);
  91. - void (*mac_link_up)(struct net_device *, unsigned int mode);
  92. + void (*mac_link_up)(struct net_device *, unsigned int mode,
  93. + struct phy_device *);
  94. };
  95. struct phylink *phylink_create(struct net_device *, struct device_node *,
  96. @@ -95,6 +96,10 @@ void phylink_ethtool_get_pauseparam(stru
  97. struct ethtool_pauseparam *);
  98. int phylink_ethtool_set_pauseparam(struct phylink *,
  99. struct ethtool_pauseparam *);
  100. +int phylink_init_eee(struct phylink *, bool);
  101. +int phylink_get_eee_err(struct phylink *);
  102. +int phylink_ethtool_get_eee(struct phylink *, struct ethtool_eee *);
  103. +int phylink_ethtool_set_eee(struct phylink *, struct ethtool_eee *);
  104. int phylink_mii_ioctl(struct phylink *, struct ifreq *, int);
  105. int phylink_set_link(struct phylink *pl, unsigned int mode, u8 port,