705-12-v6.0-net-dsa-mt7530-rework-mt753-01-_setup.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From 1f0dfd443eea7fc3e818e96f7c8264913ba41859 Mon Sep 17 00:00:00 2001
  2. From: Frank Wunderlich <[email protected]>
  3. Date: Fri, 10 Jun 2022 19:05:38 +0200
  4. Subject: [PATCH 12/13] net: dsa: mt7530: rework mt753[01]_setup
  5. Enumerate available cpu-ports instead of using hardcoded constant.
  6. Suggested-by: Vladimir Oltean <[email protected]>
  7. Signed-off-by: Frank Wunderlich <[email protected]>
  8. Reviewed-by: Vladimir Oltean <[email protected]>
  9. Reviewed-by: Florian Fainelli <[email protected]>
  10. Signed-off-by: Jakub Kicinski <[email protected]>
  11. ---
  12. drivers/net/dsa/mt7530.c | 25 +++++++++++++++++++++----
  13. 1 file changed, 21 insertions(+), 4 deletions(-)
  14. --- a/drivers/net/dsa/mt7530.c
  15. +++ b/drivers/net/dsa/mt7530.c
  16. @@ -2101,11 +2101,12 @@ static int
  17. mt7530_setup(struct dsa_switch *ds)
  18. {
  19. struct mt7530_priv *priv = ds->priv;
  20. + struct device_node *dn = NULL;
  21. struct device_node *phy_node;
  22. struct device_node *mac_np;
  23. struct mt7530_dummy_poll p;
  24. phy_interface_t interface;
  25. - struct device_node *dn;
  26. + struct dsa_port *cpu_dp;
  27. u32 id, val;
  28. int ret, i;
  29. @@ -2113,7 +2114,19 @@ mt7530_setup(struct dsa_switch *ds)
  30. * controller also is the container for two GMACs nodes representing
  31. * as two netdev instances.
  32. */
  33. - dn = dsa_to_port(ds, MT7530_CPU_PORT)->master->dev.of_node->parent;
  34. + dsa_switch_for_each_cpu_port(cpu_dp, ds) {
  35. + dn = cpu_dp->master->dev.of_node->parent;
  36. + /* It doesn't matter which CPU port is found first,
  37. + * their masters should share the same parent OF node
  38. + */
  39. + break;
  40. + }
  41. +
  42. + if (!dn) {
  43. + dev_err(ds->dev, "parent OF node of DSA master not found");
  44. + return -EINVAL;
  45. + }
  46. +
  47. ds->assisted_learning_on_cpu_port = true;
  48. ds->mtu_enforcement_ingress = true;
  49. @@ -2286,6 +2299,7 @@ mt7531_setup(struct dsa_switch *ds)
  50. {
  51. struct mt7530_priv *priv = ds->priv;
  52. struct mt7530_dummy_poll p;
  53. + struct dsa_port *cpu_dp;
  54. u32 val, id;
  55. int ret, i;
  56. @@ -2360,8 +2374,11 @@ mt7531_setup(struct dsa_switch *ds)
  57. CORE_PLL_GROUP4, val);
  58. /* BPDU to CPU port */
  59. - mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK,
  60. - BIT(MT7530_CPU_PORT));
  61. + dsa_switch_for_each_cpu_port(cpu_dp, ds) {
  62. + mt7530_rmw(priv, MT7531_CFC, MT7531_CPU_PMAP_MASK,
  63. + BIT(cpu_dp->index));
  64. + break;
  65. + }
  66. mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK,
  67. MT753X_BPDU_CPU_ONLY);