075-v5.13-0001-net-dsa-bcm_sf2-store-PHY-interface-mode-in-port-str.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From 01488a0ccd9abe15565bed50a45afcddbb0fe199 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  3. Date: Fri, 12 Mar 2021 11:41:07 +0100
  4. Subject: [PATCH] net: dsa: bcm_sf2: store PHY interface/mode in port structure
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. It's needed later for proper switch / crossbar setup.
  9. Signed-off-by: Rafał Miłecki <[email protected]>
  10. Acked-by: Florian Fainelli <[email protected]>
  11. Signed-off-by: David S. Miller <[email protected]>
  12. ---
  13. drivers/net/dsa/bcm_sf2.c | 16 ++++++++++++----
  14. drivers/net/dsa/bcm_sf2.h | 1 +
  15. 2 files changed, 13 insertions(+), 4 deletions(-)
  16. --- a/drivers/net/dsa/bcm_sf2.c
  17. +++ b/drivers/net/dsa/bcm_sf2.c
  18. @@ -380,8 +380,9 @@ static void bcm_sf2_intr_disable(struct
  19. static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
  20. struct device_node *dn)
  21. {
  22. + struct device *dev = priv->dev->ds->dev;
  23. + struct bcm_sf2_port_status *port_st;
  24. struct device_node *port;
  25. - int mode;
  26. unsigned int port_num;
  27. priv->moca_port = -1;
  28. @@ -390,19 +391,26 @@ static void bcm_sf2_identify_ports(struc
  29. if (of_property_read_u32(port, "reg", &port_num))
  30. continue;
  31. + if (port_num >= DSA_MAX_PORTS) {
  32. + dev_err(dev, "Invalid port number %d\n", port_num);
  33. + continue;
  34. + }
  35. +
  36. + port_st = &priv->port_sts[port_num];
  37. +
  38. /* Internal PHYs get assigned a specific 'phy-mode' property
  39. * value: "internal" to help flag them before MDIO probing
  40. * has completed, since they might be turned off at that
  41. * time
  42. */
  43. - mode = of_get_phy_mode(port);
  44. - if (mode < 0)
  45. + port_st->mode = of_get_phy_mode(port);
  46. + if (port_st->mode < 0)
  47. continue;
  48. - if (mode == PHY_INTERFACE_MODE_INTERNAL)
  49. + if (port_st->mode == PHY_INTERFACE_MODE_INTERNAL)
  50. priv->int_phy_mask |= 1 << port_num;
  51. - if (mode == PHY_INTERFACE_MODE_MOCA)
  52. + if (port_st->mode == PHY_INTERFACE_MODE_MOCA)
  53. priv->moca_port = port_num;
  54. if (of_property_read_bool(port, "brcm,use-bcm-hdr"))
  55. --- a/drivers/net/dsa/bcm_sf2.h
  56. +++ b/drivers/net/dsa/bcm_sf2.h
  57. @@ -43,6 +43,7 @@ struct bcm_sf2_hw_params {
  58. #define BCM_SF2_REGS_NUM 6
  59. struct bcm_sf2_port_status {
  60. + int mode;
  61. unsigned int link;
  62. };