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