bcm4908: backport brcmstb USB PHY driver changes
[openwrt/openwrt.git] / target / linux / bcm4908 / patches-5.4 / 084-v5.6-0005-phy-usb-Restructure-in-preparation-for-adding-7216-U.patch
1 From 94583a41047eb9489f576344b8ba9370cf4cbfb7 Mon Sep 17 00:00:00 2001
2 From: Al Cooper <alcooperx@gmail.com>
3 Date: Fri, 3 Jan 2020 13:18:03 -0500
4 Subject: [PATCH] phy: usb: Restructure in preparation for adding 7216 USB
5 support
6
7 The driver is being restructured in preparation for adding support
8 for the new Synopsys USB conroller on the 7216. Since all the bugs
9 and work-arounds in previous STB chips are supposed to be fixed,
10 most of the code in phy-brcm-usb-init.c is not needed. Instead of
11 adding more complexity to the already complicated phy-brcm-usb-init.c
12 module, the driver will be restructured to use a vector table to
13 dispatch into different C modules for the different controllers.
14
15 There was also some general cleanup done including some ipp setup
16 code that was incorrect.
17
18 Signed-off-by: Al Cooper <alcooperx@gmail.com>
19 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
20 Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
21 ---
22 drivers/phy/broadcom/phy-brcm-usb-init.c | 191 ++++++++++-------------
23 drivers/phy/broadcom/phy-brcm-usb-init.h | 140 +++++++++++++++--
24 drivers/phy/broadcom/phy-brcm-usb.c | 6 +-
25 3 files changed, 214 insertions(+), 123 deletions(-)
26
27 --- a/drivers/phy/broadcom/phy-brcm-usb-init.c
28 +++ b/drivers/phy/broadcom/phy-brcm-usb-init.c
29 @@ -129,10 +129,6 @@ enum {
30 USB_CTRL_SELECTOR_COUNT,
31 };
32
33 -#define USB_CTRL_REG(base, reg) ((void __iomem *)base + USB_CTRL_##reg)
34 -#define USB_XHCI_EC_REG(base, reg) ((void __iomem *)base + USB_XHCI_EC_##reg)
35 -#define USB_CTRL_MASK(reg, field) \
36 - USB_CTRL_##reg##_##field##_MASK
37 #define USB_CTRL_MASK_FAMILY(params, reg, field) \
38 (params->usb_reg_bits_map[USB_CTRL_##reg##_##field##_SELECTOR])
39
40 @@ -143,13 +139,6 @@ enum {
41 usb_ctrl_unset_family(params, USB_CTRL_##reg, \
42 USB_CTRL_##reg##_##field##_SELECTOR)
43
44 -#define USB_CTRL_SET(base, reg, field) \
45 - usb_ctrl_set(USB_CTRL_REG(base, reg), \
46 - USB_CTRL_##reg##_##field##_MASK)
47 -#define USB_CTRL_UNSET(base, reg, field) \
48 - usb_ctrl_unset(USB_CTRL_REG(base, reg), \
49 - USB_CTRL_##reg##_##field##_MASK)
50 -
51 #define MDIO_USB2 0
52 #define MDIO_USB3 BIT(31)
53
54 @@ -405,26 +394,14 @@ usb_reg_bits_map_table[BRCM_FAMILY_COUNT
55 },
56 };
57
58 -static inline u32 brcmusb_readl(void __iomem *addr)
59 -{
60 - return readl(addr);
61 -}
62 -
63 -static inline void brcmusb_writel(u32 val, void __iomem *addr)
64 -{
65 - writel(val, addr);
66 -}
67 -
68 static inline
69 void usb_ctrl_unset_family(struct brcm_usb_init_params *params,
70 u32 reg_offset, u32 field)
71 {
72 u32 mask;
73 - void __iomem *reg;
74
75 mask = params->usb_reg_bits_map[field];
76 - reg = params->ctrl_regs + reg_offset;
77 - brcmusb_writel(brcmusb_readl(reg) & ~mask, reg);
78 + brcm_usb_ctrl_unset(params->ctrl_regs + reg_offset, mask);
79 };
80
81 static inline
82 @@ -432,45 +409,27 @@ void usb_ctrl_set_family(struct brcm_usb
83 u32 reg_offset, u32 field)
84 {
85 u32 mask;
86 - void __iomem *reg;
87
88 mask = params->usb_reg_bits_map[field];
89 - reg = params->ctrl_regs + reg_offset;
90 - brcmusb_writel(brcmusb_readl(reg) | mask, reg);
91 + brcm_usb_ctrl_set(params->ctrl_regs + reg_offset, mask);
92 };
93
94 -static inline void usb_ctrl_set(void __iomem *reg, u32 field)
95 -{
96 - u32 value;
97 -
98 - value = brcmusb_readl(reg);
99 - brcmusb_writel(value | field, reg);
100 -}
101 -
102 -static inline void usb_ctrl_unset(void __iomem *reg, u32 field)
103 -{
104 - u32 value;
105 -
106 - value = brcmusb_readl(reg);
107 - brcmusb_writel(value & ~field, reg);
108 -}
109 -
110 static u32 brcmusb_usb_mdio_read(void __iomem *ctrl_base, u32 reg, int mode)
111 {
112 u32 data;
113
114 data = (reg << 16) | mode;
115 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
116 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
117 data |= (1 << 24);
118 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
119 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
120 data &= ~(1 << 24);
121 /* wait for the 60MHz parallel to serial shifter */
122 usleep_range(10, 20);
123 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
124 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
125 /* wait for the 60MHz parallel to serial shifter */
126 usleep_range(10, 20);
127
128 - return brcmusb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff;
129 + return brcm_usb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff;
130 }
131
132 static void brcmusb_usb_mdio_write(void __iomem *ctrl_base, u32 reg,
133 @@ -479,14 +438,14 @@ static void brcmusb_usb_mdio_write(void
134 u32 data;
135
136 data = (reg << 16) | val | mode;
137 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
138 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
139 data |= (1 << 25);
140 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
141 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
142 data &= ~(1 << 25);
143
144 /* wait for the 60MHz parallel to serial shifter */
145 usleep_range(10, 20);
146 - brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
147 + brcm_usb_writel(data, USB_CTRL_REG(ctrl_base, MDIO));
148 /* wait for the 60MHz parallel to serial shifter */
149 usleep_range(10, 20);
150 }
151 @@ -713,12 +672,12 @@ static void brcmusb_usb3_otp_fix(struct
152
153 if (params->family_id != 0x74371000 || !xhci_ec_base)
154 return;
155 - brcmusb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR));
156 - val = brcmusb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT));
157 + brcm_usb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR));
158 + val = brcm_usb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT));
159
160 /* set cfg_pick_ss_lock */
161 val |= (1 << 27);
162 - brcmusb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT));
163 + brcm_usb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT));
164
165 /* Reset USB 3.0 PHY for workaround to take effect */
166 USB_CTRL_UNSET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB);
167 @@ -751,7 +710,7 @@ static void brcmusb_xhci_soft_reset(stru
168 * - default chip/rev.
169 * NOTE: The minor rev is always ignored.
170 */
171 -static enum brcm_family_type brcmusb_get_family_type(
172 +static enum brcm_family_type get_family_type(
173 struct brcm_usb_init_params *params)
174 {
175 int last_type = -1;
176 @@ -779,7 +738,7 @@ static enum brcm_family_type brcmusb_get
177 return last_type;
178 }
179
180 -void brcm_usb_init_ipp(struct brcm_usb_init_params *params)
181 +static void usb_init_ipp(struct brcm_usb_init_params *params)
182 {
183 void __iomem *ctrl = params->ctrl_regs;
184 u32 reg;
185 @@ -795,7 +754,7 @@ void brcm_usb_init_ipp(struct brcm_usb_i
186 USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IPP);
187 }
188
189 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP));
190 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP));
191 orig_reg = reg;
192 if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_CC_DRD_MODE_ENABLE_SEL))
193 /* Never use the strap, it's going away. */
194 @@ -803,8 +762,8 @@ void brcm_usb_init_ipp(struct brcm_usb_i
195 SETUP,
196 STRAP_CC_DRD_MODE_ENABLE_SEL));
197 if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_IPP_SEL))
198 + /* override ipp strap pin (if it exits) */
199 if (params->ipp != 2)
200 - /* override ipp strap pin (if it exits) */
201 reg &= ~(USB_CTRL_MASK_FAMILY(params, SETUP,
202 STRAP_IPP_SEL));
203
204 @@ -812,54 +771,26 @@ void brcm_usb_init_ipp(struct brcm_usb_i
205 reg &= ~(USB_CTRL_MASK(SETUP, IPP) | USB_CTRL_MASK(SETUP, IOC));
206 if (params->ioc)
207 reg |= USB_CTRL_MASK(SETUP, IOC);
208 - if (params->ipp == 1 && ((reg & USB_CTRL_MASK(SETUP, IPP)) == 0))
209 + if (params->ipp == 1)
210 reg |= USB_CTRL_MASK(SETUP, IPP);
211 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
212 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
213
214 /*
215 * If we're changing IPP, make sure power is off long enough
216 * to turn off any connected devices.
217 */
218 - if (reg != orig_reg)
219 + if ((reg ^ orig_reg) & USB_CTRL_MASK(SETUP, IPP))
220 msleep(50);
221 }
222
223 -int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params)
224 -{
225 - void __iomem *ctrl = params->ctrl_regs;
226 - u32 reg = 0;
227 -
228 - if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
229 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
230 - reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
231 - PORT_MODE);
232 - }
233 - return reg;
234 -}
235 -
236 -void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params,
237 - int mode)
238 -{
239 - void __iomem *ctrl = params->ctrl_regs;
240 - u32 reg;
241 -
242 - if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
243 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
244 - reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
245 - PORT_MODE);
246 - reg |= mode;
247 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
248 - }
249 -}
250 -
251 -void brcm_usb_init_common(struct brcm_usb_init_params *params)
252 +static void usb_init_common(struct brcm_usb_init_params *params)
253 {
254 u32 reg;
255 void __iomem *ctrl = params->ctrl_regs;
256
257 /* Clear any pending wake conditions */
258 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS));
259 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS));
260 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS));
261 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS));
262
263 /* Take USB out of power down */
264 if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) {
265 @@ -885,7 +816,7 @@ void brcm_usb_init_common(struct brcm_us
266 /* Block auto PLL suspend by USB2 PHY (Sasi) */
267 USB_CTRL_SET(ctrl, PLL_CTL, PLL_SUSPEND_EN);
268
269 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP));
270 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP));
271 if (params->selected_family == BRCM_FAMILY_7364A0)
272 /* Suppress overcurrent indication from USB30 ports for A0 */
273 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, OC3_DISABLE);
274 @@ -901,16 +832,16 @@ void brcm_usb_init_common(struct brcm_us
275 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN);
276 if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN))
277 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN);
278 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
279 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
280
281 brcmusb_memc_fix(params);
282
283 if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
284 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
285 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
286 reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
287 PORT_MODE);
288 reg |= params->mode;
289 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
290 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
291 }
292 if (USB_CTRL_MASK_FAMILY(params, USB_PM, BDC_SOFT_RESETB)) {
293 switch (params->mode) {
294 @@ -932,7 +863,7 @@ void brcm_usb_init_common(struct brcm_us
295 }
296 }
297
298 -void brcm_usb_init_eohci(struct brcm_usb_init_params *params)
299 +static void usb_init_eohci(struct brcm_usb_init_params *params)
300 {
301 u32 reg;
302 void __iomem *ctrl = params->ctrl_regs;
303 @@ -948,10 +879,10 @@ void brcm_usb_init_eohci(struct brcm_usb
304 USB_CTRL_SET(ctrl, EBRIDGE, ESTOP_SCB_REQ);
305
306 /* Setup the endian bits */
307 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP));
308 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, SETUP));
309 reg &= ~USB_CTRL_SETUP_ENDIAN_BITS;
310 reg |= USB_CTRL_MASK_FAMILY(params, SETUP, ENDIAN);
311 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
312 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, SETUP));
313
314 if (params->selected_family == BRCM_FAMILY_7271A0)
315 /* Enable LS keep alive fix for certain keyboards */
316 @@ -962,14 +893,14 @@ void brcm_usb_init_eohci(struct brcm_usb
317 * Make the burst size 512 bytes to fix a hardware bug
318 * on the 7255a0. See HW7255-24.
319 */
320 - reg = brcmusb_readl(USB_CTRL_REG(ctrl, EBRIDGE));
321 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, EBRIDGE));
322 reg &= ~USB_CTRL_MASK(EBRIDGE, EBR_SCB_SIZE);
323 reg |= 0x800;
324 - brcmusb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE));
325 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, EBRIDGE));
326 }
327 }
328
329 -void brcm_usb_init_xhci(struct brcm_usb_init_params *params)
330 +static void usb_init_xhci(struct brcm_usb_init_params *params)
331 {
332 void __iomem *ctrl = params->ctrl_regs;
333
334 @@ -997,7 +928,7 @@ void brcm_usb_init_xhci(struct brcm_usb_
335 brcmusb_usb3_otp_fix(params);
336 }
337
338 -void brcm_usb_uninit_common(struct brcm_usb_init_params *params)
339 +static void usb_uninit_common(struct brcm_usb_init_params *params)
340 {
341 if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN))
342 USB_CTRL_SET_FAMILY(params, USB_PM, USB_PWRDN);
343 @@ -1006,17 +937,47 @@ void brcm_usb_uninit_common(struct brcm_
344 USB_CTRL_SET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN);
345 }
346
347 -void brcm_usb_uninit_eohci(struct brcm_usb_init_params *params)
348 +static void usb_uninit_eohci(struct brcm_usb_init_params *params)
349 {
350 }
351
352 -void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params)
353 +static void usb_uninit_xhci(struct brcm_usb_init_params *params)
354 {
355 brcmusb_xhci_soft_reset(params, 1);
356 USB_CTRL_SET(params->ctrl_regs, USB30_PCTL, PHY3_IDDQ_OVERRIDE);
357 }
358
359 -void brcm_usb_wake_enable(struct brcm_usb_init_params *params,
360 +static int usb_get_dual_select(struct brcm_usb_init_params *params)
361 +{
362 + void __iomem *ctrl = params->ctrl_regs;
363 + u32 reg = 0;
364 +
365 + pr_debug("%s\n", __func__);
366 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
367 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
368 + reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
369 + PORT_MODE);
370 + }
371 + return reg;
372 +}
373 +
374 +static void usb_set_dual_select(struct brcm_usb_init_params *params, int mode)
375 +{
376 + void __iomem *ctrl = params->ctrl_regs;
377 + u32 reg;
378 +
379 + pr_debug("%s\n", __func__);
380 +
381 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) {
382 + reg = brcm_usb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
383 + reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1,
384 + PORT_MODE);
385 + reg |= mode;
386 + brcm_usb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1));
387 + }
388 +}
389 +
390 +static void usb_wake_enable(struct brcm_usb_init_params *params,
391 int enable)
392 {
393 void __iomem *ctrl = params->ctrl_regs;
394 @@ -1027,13 +988,29 @@ void brcm_usb_wake_enable(struct brcm_us
395 USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN);
396 }
397
398 -void brcm_usb_set_family_map(struct brcm_usb_init_params *params)
399 +static const struct brcm_usb_init_ops bcm7445_ops = {
400 + .init_ipp = usb_init_ipp,
401 + .init_common = usb_init_common,
402 + .init_eohci = usb_init_eohci,
403 + .init_xhci = usb_init_xhci,
404 + .uninit_common = usb_uninit_common,
405 + .uninit_eohci = usb_uninit_eohci,
406 + .uninit_xhci = usb_uninit_xhci,
407 + .get_dual_select = usb_get_dual_select,
408 + .set_dual_select = usb_set_dual_select,
409 + .wake_enable = usb_wake_enable,
410 +};
411 +
412 +void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params)
413 {
414 int fam;
415
416 - fam = brcmusb_get_family_type(params);
417 + pr_debug("%s\n", __func__);
418 +
419 + fam = get_family_type(params);
420 params->selected_family = fam;
421 params->usb_reg_bits_map =
422 &usb_reg_bits_map_table[fam][0];
423 params->family_name = family_names[fam];
424 + params->ops = &bcm7445_ops;
425 }
426 --- a/drivers/phy/broadcom/phy-brcm-usb-init.h
427 +++ b/drivers/phy/broadcom/phy-brcm-usb-init.h
428 @@ -13,6 +13,33 @@
429
430 struct brcm_usb_init_params;
431
432 +#define USB_CTRL_REG(base, reg) ((void __iomem *)base + USB_CTRL_##reg)
433 +#define USB_XHCI_EC_REG(base, reg) ((void __iomem *)base + USB_XHCI_EC_##reg)
434 +#define USB_CTRL_MASK(reg, field) \
435 + USB_CTRL_##reg##_##field##_MASK
436 +#define USB_CTRL_SET(base, reg, field) \
437 + brcm_usb_ctrl_set(USB_CTRL_REG(base, reg), \
438 + USB_CTRL_##reg##_##field##_MASK)
439 +#define USB_CTRL_UNSET(base, reg, field) \
440 + brcm_usb_ctrl_unset(USB_CTRL_REG(base, reg), \
441 + USB_CTRL_##reg##_##field##_MASK)
442 +
443 +struct brcm_usb_init_params;
444 +
445 +struct brcm_usb_init_ops {
446 + void (*init_ipp)(struct brcm_usb_init_params *params);
447 + void (*init_common)(struct brcm_usb_init_params *params);
448 + void (*init_eohci)(struct brcm_usb_init_params *params);
449 + void (*init_xhci)(struct brcm_usb_init_params *params);
450 + void (*uninit_common)(struct brcm_usb_init_params *params);
451 + void (*uninit_eohci)(struct brcm_usb_init_params *params);
452 + void (*uninit_xhci)(struct brcm_usb_init_params *params);
453 + int (*get_dual_select)(struct brcm_usb_init_params *params);
454 + void (*set_dual_select)(struct brcm_usb_init_params *params, int mode);
455 + void (*wake_enable)(struct brcm_usb_init_params *params,
456 + int enable);
457 +};
458 +
459 struct brcm_usb_init_params {
460 void __iomem *ctrl_regs;
461 void __iomem *xhci_ec_regs;
462 @@ -24,20 +51,107 @@ struct brcm_usb_init_params {
463 int selected_family;
464 const char *family_name;
465 const u32 *usb_reg_bits_map;
466 + const struct brcm_usb_init_ops *ops;
467 };
468
469 -void brcm_usb_set_family_map(struct brcm_usb_init_params *params);
470 -int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params);
471 -void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params,
472 - int mode);
473 -
474 -void brcm_usb_init_ipp(struct brcm_usb_init_params *ini);
475 -void brcm_usb_init_common(struct brcm_usb_init_params *ini);
476 -void brcm_usb_init_eohci(struct brcm_usb_init_params *ini);
477 -void brcm_usb_init_xhci(struct brcm_usb_init_params *ini);
478 -void brcm_usb_uninit_common(struct brcm_usb_init_params *ini);
479 -void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini);
480 -void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini);
481 -void brcm_usb_wake_enable(struct brcm_usb_init_params *params, int enable);
482 +void brcm_usb_dvr_init_7445(struct brcm_usb_init_params *params);
483 +
484 +static inline u32 brcm_usb_readl(void __iomem *addr)
485 +{
486 + /*
487 + * MIPS endianness is configured by boot strap, which also reverses all
488 + * bus endianness (i.e., big-endian CPU + big endian bus ==> native
489 + * endian I/O).
490 + *
491 + * Other architectures (e.g., ARM) either do not support big endian, or
492 + * else leave I/O in little endian mode.
493 + */
494 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN))
495 + return __raw_readl(addr);
496 + else
497 + return readl_relaxed(addr);
498 +}
499 +
500 +static inline void brcm_usb_writel(u32 val, void __iomem *addr)
501 +{
502 + /* See brcmnand_readl() comments */
503 + if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN))
504 + __raw_writel(val, addr);
505 + else
506 + writel_relaxed(val, addr);
507 +}
508 +
509 +static inline void brcm_usb_ctrl_unset(void __iomem *reg, u32 mask)
510 +{
511 + brcm_usb_writel(brcm_usb_readl(reg) & ~(mask), reg);
512 +};
513 +
514 +static inline void brcm_usb_ctrl_set(void __iomem *reg, u32 mask)
515 +{
516 + brcm_usb_writel(brcm_usb_readl(reg) | (mask), reg);
517 +};
518 +
519 +static inline void brcm_usb_init_ipp(struct brcm_usb_init_params *ini)
520 +{
521 + if (ini->ops->init_ipp)
522 + ini->ops->init_ipp(ini);
523 +}
524 +
525 +static inline void brcm_usb_init_common(struct brcm_usb_init_params *ini)
526 +{
527 + if (ini->ops->init_common)
528 + ini->ops->init_common(ini);
529 +}
530 +
531 +static inline void brcm_usb_init_eohci(struct brcm_usb_init_params *ini)
532 +{
533 + if (ini->ops->init_eohci)
534 + ini->ops->init_eohci(ini);
535 +}
536 +
537 +static inline void brcm_usb_init_xhci(struct brcm_usb_init_params *ini)
538 +{
539 + if (ini->ops->init_xhci)
540 + ini->ops->init_xhci(ini);
541 +}
542 +
543 +static inline void brcm_usb_uninit_common(struct brcm_usb_init_params *ini)
544 +{
545 + if (ini->ops->uninit_common)
546 + ini->ops->uninit_common(ini);
547 +}
548 +
549 +static inline void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini)
550 +{
551 + if (ini->ops->uninit_eohci)
552 + ini->ops->uninit_eohci(ini);
553 +}
554 +
555 +static inline void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini)
556 +{
557 + if (ini->ops->uninit_xhci)
558 + ini->ops->uninit_xhci(ini);
559 +}
560 +
561 +static inline void brcm_usb_wake_enable(struct brcm_usb_init_params *ini,
562 + int enable)
563 +{
564 + if (ini->ops->wake_enable)
565 + ini->ops->wake_enable(ini, enable);
566 +}
567 +
568 +static inline int brcm_usb_get_dual_select(struct brcm_usb_init_params *ini)
569 +{
570 + if (ini->ops->get_dual_select)
571 + return ini->ops->get_dual_select(ini);
572 + return 0;
573 +}
574 +
575 +static inline void brcm_usb_set_dual_select(struct brcm_usb_init_params *ini,
576 + int mode)
577 +{
578 + if (ini->ops->set_dual_select)
579 + ini->ops->set_dual_select(ini, mode);
580 +}
581
582 #endif /* _USB_BRCM_COMMON_INIT_H */
583 --- a/drivers/phy/broadcom/phy-brcm-usb.c
584 +++ b/drivers/phy/broadcom/phy-brcm-usb.c
585 @@ -207,7 +207,7 @@ static ssize_t dual_select_store(struct
586 res = name_to_value(&brcm_dual_mode_to_name[0],
587 ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value);
588 if (!res) {
589 - brcm_usb_init_set_dual_select(&priv->ini, value);
590 + brcm_usb_set_dual_select(&priv->ini, value);
591 res = len;
592 }
593 mutex_unlock(&sysfs_lock);
594 @@ -222,7 +222,7 @@ static ssize_t dual_select_show(struct d
595 int value;
596
597 mutex_lock(&sysfs_lock);
598 - value = brcm_usb_init_get_dual_select(&priv->ini);
599 + value = brcm_usb_get_dual_select(&priv->ini);
600 mutex_unlock(&sysfs_lock);
601 return sprintf(buf, "%s\n",
602 value_to_name(&brcm_dual_mode_to_name[0],
603 @@ -331,7 +331,7 @@ static int brcm_usb_phy_probe(struct pla
604
605 priv->ini.family_id = brcmstb_get_family_id();
606 priv->ini.product_id = brcmstb_get_product_id();
607 - brcm_usb_set_family_map(&priv->ini);
608 + brcm_usb_dvr_init_7445(&priv->ini);
609 dev_dbg(dev, "Best mapping table is for %s\n",
610 priv->ini.family_name);
611 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);