738-v5.5-net-phy-marvell10g-add-SFP-support.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 0836d9fb41ed90090ef4af0d7abe784ee7706f80 Mon Sep 17 00:00:00 2001
  2. From: Russell King <[email protected]>
  3. Date: Fri, 14 Apr 2017 14:21:25 +0100
  4. Subject: [PATCH 636/660] net: phy: marvell10g: add SFP+ support
  5. Add support for SFP+ cages to the Marvell 10G PHY driver. This is
  6. slightly complicated by the way phylib works in that we need to use
  7. a multi-step process to attach the SFP bus, and we also need to track
  8. the phylink state machine to know when the module's transmit disable
  9. signal should change state.
  10. With appropriate DT changes, this allows the SFP+ canges on the
  11. Macchiatobin platform to be functional.
  12. Signed-off-by: Russell King <[email protected]>
  13. ---
  14. drivers/net/phy/marvell10g.c | 25 ++++++++++++++++++++++++-
  15. 1 file changed, 24 insertions(+), 1 deletion(-)
  16. --- a/drivers/net/phy/marvell10g.c
  17. +++ b/drivers/net/phy/marvell10g.c
  18. @@ -25,6 +25,7 @@
  19. #include <linux/hwmon.h>
  20. #include <linux/marvell_phy.h>
  21. #include <linux/phy.h>
  22. +#include <linux/sfp.h>
  23. enum {
  24. MV_PMA_BOOT = 0xc050,
  25. @@ -219,6 +220,28 @@ static int mv3310_hwmon_probe(struct phy
  26. }
  27. #endif
  28. +static int mv3310_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
  29. +{
  30. + struct phy_device *phydev = upstream;
  31. + __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, };
  32. + phy_interface_t iface;
  33. +
  34. + sfp_parse_support(phydev->sfp_bus, id, support);
  35. + iface = sfp_select_interface(phydev->sfp_bus, id, support);
  36. +
  37. + if (iface != PHY_INTERFACE_MODE_10GKR) {
  38. + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
  39. + return -EINVAL;
  40. + }
  41. + return 0;
  42. +}
  43. +
  44. +static const struct sfp_upstream_ops mv3310_sfp_ops = {
  45. + .attach = phy_sfp_attach,
  46. + .detach = phy_sfp_detach,
  47. + .module_insert = mv3310_sfp_insert,
  48. +};
  49. +
  50. static int mv3310_probe(struct phy_device *phydev)
  51. {
  52. struct mv3310_priv *priv;
  53. @@ -249,7 +272,7 @@ static int mv3310_probe(struct phy_devic
  54. if (ret)
  55. return ret;
  56. - return 0;
  57. + return phy_sfp_probe(phydev, &mv3310_sfp_ops);
  58. }
  59. static int mv3310_suspend(struct phy_device *phydev)