792-v5.15-0003-net-dsa-b53-Fix-IMP-port-setup-on-BCM5301x.patch 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. From 63f8428b4077de3664eb0b252393c839b0b293ec Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  3. Date: Sun, 5 Sep 2021 19:23:28 +0200
  4. Subject: [PATCH] net: dsa: b53: Fix IMP port setup on BCM5301x
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Broadcom's b53 switches have one IMP (Inband Management Port) that needs
  9. to be programmed using its own designed register. IMP port may be
  10. different than CPU port - especially on devices with multiple CPU ports.
  11. For that reason it's required to explicitly note IMP port index and
  12. check for it when choosing a register to use.
  13. This commit fixes BCM5301x support. Those switches use CPU port 5 while
  14. their IMP port is 8. Before this patch b53 was trying to program port 5
  15. with B53_PORT_OVERRIDE_CTRL instead of B53_GMII_PORT_OVERRIDE_CTRL(5).
  16. It may be possible to also replace "cpu_port" usages with
  17. dsa_is_cpu_port() but that is out of the scope of thix BCM5301x fix.
  18. Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
  19. Signed-off-by: Rafał Miłecki <[email protected]>
  20. Signed-off-by: David S. Miller <[email protected]>
  21. ---
  22. drivers/net/dsa/b53/b53_common.c | 28 +++++++++++++++++++++++++---
  23. drivers/net/dsa/b53/b53_priv.h | 1 +
  24. 2 files changed, 26 insertions(+), 3 deletions(-)
  25. --- a/drivers/net/dsa/b53/b53_common.c
  26. +++ b/drivers/net/dsa/b53/b53_common.c
  27. @@ -1109,7 +1109,7 @@ static void b53_force_link(struct b53_de
  28. u8 reg, val, off;
  29. /* Override the port settings */
  30. - if (port == dev->cpu_port) {
  31. + if (port == dev->imp_port) {
  32. off = B53_PORT_OVERRIDE_CTRL;
  33. val = PORT_OVERRIDE_EN;
  34. } else {
  35. @@ -1133,7 +1133,7 @@ static void b53_force_port_config(struct
  36. u8 reg, val, off;
  37. /* Override the port settings */
  38. - if (port == dev->cpu_port) {
  39. + if (port == dev->imp_port) {
  40. off = B53_PORT_OVERRIDE_CTRL;
  41. val = PORT_OVERRIDE_EN;
  42. } else {
  43. @@ -1201,7 +1201,7 @@ static void b53_adjust_link(struct dsa_s
  44. b53_force_link(dev, port, phydev->link);
  45. if (is531x5(dev) && phy_interface_is_rgmii(phydev)) {
  46. - if (port == 8)
  47. + if (port == dev->imp_port)
  48. off = B53_RGMII_CTRL_IMP;
  49. else
  50. off = B53_RGMII_CTRL_P(port);
  51. @@ -2266,6 +2266,7 @@ struct b53_chip_data {
  52. const char *dev_name;
  53. u16 vlans;
  54. u16 enabled_ports;
  55. + u8 imp_port;
  56. u8 cpu_port;
  57. u8 vta_regs[3];
  58. u8 arl_bins;
  59. @@ -2290,6 +2291,7 @@ static const struct b53_chip_data b53_sw
  60. .enabled_ports = 0x1f,
  61. .arl_bins = 2,
  62. .arl_buckets = 1024,
  63. + .imp_port = 5,
  64. .cpu_port = B53_CPU_PORT_25,
  65. .duplex_reg = B53_DUPLEX_STAT_FE,
  66. },
  67. @@ -2300,6 +2302,7 @@ static const struct b53_chip_data b53_sw
  68. .enabled_ports = 0x1f,
  69. .arl_bins = 2,
  70. .arl_buckets = 1024,
  71. + .imp_port = 5,
  72. .cpu_port = B53_CPU_PORT_25,
  73. .duplex_reg = B53_DUPLEX_STAT_FE,
  74. },
  75. @@ -2310,6 +2313,7 @@ static const struct b53_chip_data b53_sw
  76. .enabled_ports = 0x1f,
  77. .arl_bins = 4,
  78. .arl_buckets = 1024,
  79. + .imp_port = 8,
  80. .cpu_port = B53_CPU_PORT,
  81. .vta_regs = B53_VTA_REGS,
  82. .duplex_reg = B53_DUPLEX_STAT_GE,
  83. @@ -2323,6 +2327,7 @@ static const struct b53_chip_data b53_sw
  84. .enabled_ports = 0x1f,
  85. .arl_bins = 4,
  86. .arl_buckets = 1024,
  87. + .imp_port = 8,
  88. .cpu_port = B53_CPU_PORT,
  89. .vta_regs = B53_VTA_REGS,
  90. .duplex_reg = B53_DUPLEX_STAT_GE,
  91. @@ -2336,6 +2341,7 @@ static const struct b53_chip_data b53_sw
  92. .enabled_ports = 0x1f,
  93. .arl_bins = 4,
  94. .arl_buckets = 1024,
  95. + .imp_port = 8,
  96. .cpu_port = B53_CPU_PORT,
  97. .vta_regs = B53_VTA_REGS_9798,
  98. .duplex_reg = B53_DUPLEX_STAT_GE,
  99. @@ -2349,6 +2355,7 @@ static const struct b53_chip_data b53_sw
  100. .enabled_ports = 0x7f,
  101. .arl_bins = 4,
  102. .arl_buckets = 1024,
  103. + .imp_port = 8,
  104. .cpu_port = B53_CPU_PORT,
  105. .vta_regs = B53_VTA_REGS_9798,
  106. .duplex_reg = B53_DUPLEX_STAT_GE,
  107. @@ -2363,6 +2370,7 @@ static const struct b53_chip_data b53_sw
  108. .arl_bins = 4,
  109. .arl_buckets = 1024,
  110. .vta_regs = B53_VTA_REGS,
  111. + .imp_port = 8,
  112. .cpu_port = B53_CPU_PORT,
  113. .duplex_reg = B53_DUPLEX_STAT_GE,
  114. .jumbo_pm_reg = B53_JUMBO_PORT_MASK,
  115. @@ -2375,6 +2383,7 @@ static const struct b53_chip_data b53_sw
  116. .enabled_ports = 0xff,
  117. .arl_bins = 4,
  118. .arl_buckets = 1024,
  119. + .imp_port = 8,
  120. .cpu_port = B53_CPU_PORT,
  121. .vta_regs = B53_VTA_REGS,
  122. .duplex_reg = B53_DUPLEX_STAT_GE,
  123. @@ -2388,6 +2397,7 @@ static const struct b53_chip_data b53_sw
  124. .enabled_ports = 0x1ff,
  125. .arl_bins = 4,
  126. .arl_buckets = 1024,
  127. + .imp_port = 8,
  128. .cpu_port = B53_CPU_PORT,
  129. .vta_regs = B53_VTA_REGS,
  130. .duplex_reg = B53_DUPLEX_STAT_GE,
  131. @@ -2401,6 +2411,7 @@ static const struct b53_chip_data b53_sw
  132. .enabled_ports = 0, /* pdata must provide them */
  133. .arl_bins = 4,
  134. .arl_buckets = 1024,
  135. + .imp_port = 8,
  136. .cpu_port = B53_CPU_PORT,
  137. .vta_regs = B53_VTA_REGS_63XX,
  138. .duplex_reg = B53_DUPLEX_STAT_63XX,
  139. @@ -2414,6 +2425,7 @@ static const struct b53_chip_data b53_sw
  140. .enabled_ports = 0x1f,
  141. .arl_bins = 4,
  142. .arl_buckets = 1024,
  143. + .imp_port = 8,
  144. .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
  145. .vta_regs = B53_VTA_REGS,
  146. .duplex_reg = B53_DUPLEX_STAT_GE,
  147. @@ -2427,6 +2439,7 @@ static const struct b53_chip_data b53_sw
  148. .enabled_ports = 0x1bf,
  149. .arl_bins = 4,
  150. .arl_buckets = 1024,
  151. + .imp_port = 8,
  152. .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
  153. .vta_regs = B53_VTA_REGS,
  154. .duplex_reg = B53_DUPLEX_STAT_GE,
  155. @@ -2440,6 +2453,7 @@ static const struct b53_chip_data b53_sw
  156. .enabled_ports = 0x1bf,
  157. .arl_bins = 4,
  158. .arl_buckets = 1024,
  159. + .imp_port = 8,
  160. .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
  161. .vta_regs = B53_VTA_REGS,
  162. .duplex_reg = B53_DUPLEX_STAT_GE,
  163. @@ -2453,6 +2467,7 @@ static const struct b53_chip_data b53_sw
  164. .enabled_ports = 0x1f,
  165. .arl_bins = 4,
  166. .arl_buckets = 1024,
  167. + .imp_port = 8,
  168. .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
  169. .vta_regs = B53_VTA_REGS,
  170. .duplex_reg = B53_DUPLEX_STAT_GE,
  171. @@ -2466,6 +2481,7 @@ static const struct b53_chip_data b53_sw
  172. .enabled_ports = 0x1f,
  173. .arl_bins = 4,
  174. .arl_buckets = 1024,
  175. + .imp_port = 8,
  176. .cpu_port = B53_CPU_PORT_25, /* TODO: auto detect */
  177. .vta_regs = B53_VTA_REGS,
  178. .duplex_reg = B53_DUPLEX_STAT_GE,
  179. @@ -2479,6 +2495,7 @@ static const struct b53_chip_data b53_sw
  180. .enabled_ports = 0x1ff,
  181. .arl_bins = 4,
  182. .arl_buckets = 1024,
  183. + .imp_port = 8,
  184. .cpu_port = B53_CPU_PORT,
  185. .vta_regs = B53_VTA_REGS,
  186. .duplex_reg = B53_DUPLEX_STAT_GE,
  187. @@ -2492,6 +2509,7 @@ static const struct b53_chip_data b53_sw
  188. .enabled_ports = 0x103,
  189. .arl_bins = 4,
  190. .arl_buckets = 1024,
  191. + .imp_port = 8,
  192. .cpu_port = B53_CPU_PORT,
  193. .vta_regs = B53_VTA_REGS,
  194. .duplex_reg = B53_DUPLEX_STAT_GE,
  195. @@ -2505,6 +2523,7 @@ static const struct b53_chip_data b53_sw
  196. .enabled_ports = 0x1ff,
  197. .arl_bins = 4,
  198. .arl_buckets = 1024,
  199. + .imp_port = 8,
  200. .cpu_port = B53_CPU_PORT,
  201. .vta_regs = B53_VTA_REGS,
  202. .duplex_reg = B53_DUPLEX_STAT_GE,
  203. @@ -2518,6 +2537,7 @@ static const struct b53_chip_data b53_sw
  204. .enabled_ports = 0x1ff,
  205. .arl_bins = 4,
  206. .arl_buckets = 256,
  207. + .imp_port = 8,
  208. .cpu_port = B53_CPU_PORT,
  209. .vta_regs = B53_VTA_REGS,
  210. .duplex_reg = B53_DUPLEX_STAT_GE,
  211. @@ -2543,6 +2563,7 @@ static int b53_switch_init(struct b53_de
  212. dev->vta_regs[1] = chip->vta_regs[1];
  213. dev->vta_regs[2] = chip->vta_regs[2];
  214. dev->jumbo_pm_reg = chip->jumbo_pm_reg;
  215. + dev->imp_port = chip->imp_port;
  216. dev->cpu_port = chip->cpu_port;
  217. dev->num_vlans = chip->vlans;
  218. dev->num_arl_bins = chip->arl_bins;
  219. --- a/drivers/net/dsa/b53/b53_priv.h
  220. +++ b/drivers/net/dsa/b53/b53_priv.h
  221. @@ -122,6 +122,7 @@ struct b53_device {
  222. /* used ports mask */
  223. u16 enabled_ports;
  224. + unsigned int imp_port;
  225. unsigned int cpu_port;
  226. /* connect specific data */