142-phylink-add-EEE-support.patch 3.3 KB

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