c97c759e7ee82ac1002c0ac5f7c7b3f6ca63edad
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 002-phy_drivers_backport.patch
1 --- a/drivers/net/phy/adm6996.c
2 +++ b/drivers/net/phy/adm6996.c
3 @@ -287,7 +287,7 @@ static u16
4 adm6996_read_mii_reg(struct adm6996_priv *priv, enum admreg reg)
5 {
6 struct phy_device *phydev = priv->priv;
7 - struct mii_bus *bus = phydev->mdio.bus;
8 + struct mii_bus *bus = phydev->bus;
9
10 return bus->read(bus, PHYADDR(reg));
11 }
12 @@ -296,7 +296,7 @@ static void
13 adm6996_write_mii_reg(struct adm6996_priv *priv, enum admreg reg, u16 val)
14 {
15 struct phy_device *phydev = priv->priv;
16 - struct mii_bus *bus = phydev->mdio.bus;
17 + struct mii_bus *bus = phydev->bus;
18
19 bus->write(bus, PHYADDR(reg), val);
20 }
21 @@ -1019,13 +1019,13 @@ static int adm6996_config_init(struct ph
22 pdev->supported = ADVERTISED_100baseT_Full;
23 pdev->advertising = ADVERTISED_100baseT_Full;
24
25 - if (pdev->mdio.addr != 0) {
26 + if (pdev->addr != 0) {
27 pr_info ("%s: PHY overlaps ADM6996, providing fixed PHY 0x%x.\n"
28 - , pdev->attached_dev->name, pdev->mdio.addr);
29 + , pdev->attached_dev->name, pdev->addr);
30 return 0;
31 }
32
33 - priv = devm_kzalloc(&pdev->mdio.dev, sizeof(struct adm6996_priv), GFP_KERNEL);
34 + priv = devm_kzalloc(&pdev->dev, sizeof(struct adm6996_priv), GFP_KERNEL);
35 if (!priv)
36 return -ENOMEM;
37
38 @@ -1045,7 +1045,7 @@ static int adm6996_config_init(struct ph
39 }
40
41 /*
42 - * Warning: phydev->priv is NULL if phydev->mdio.addr != 0
43 + * Warning: phydev->priv is NULL if phydev->addr != 0
44 */
45 static int adm6996_read_status(struct phy_device *phydev)
46 {
47 @@ -1061,7 +1061,7 @@ static int adm6996_read_status(struct ph
48 }
49
50 /*
51 - * Warning: phydev->priv is NULL if phydev->mdio.addr != 0
52 + * Warning: phydev->priv is NULL if phydev->addr != 0
53 */
54 static int adm6996_config_aneg(struct phy_device *phydev)
55 {
56 @@ -1070,11 +1070,11 @@ static int adm6996_config_aneg(struct ph
57
58 static int adm6996_fixup(struct phy_device *dev)
59 {
60 - struct mii_bus *bus = dev->mdio.bus;
61 + struct mii_bus *bus = dev->bus;
62 u16 reg;
63
64 /* Our custom registers are at PHY addresses 0-10. Claim those. */
65 - if (dev->mdio.addr > 10)
66 + if (dev->addr > 10)
67 return 0;
68
69 /* look for the switch on the bus */
70 @@ -1121,6 +1121,7 @@ static struct phy_driver adm6996_phy_dri
71 .config_aneg = &adm6996_config_aneg,
72 .read_status = &adm6996_read_status,
73 .soft_reset = adm6996_soft_reset,
74 + .driver = { .owner = THIS_MODULE,},
75 };
76
77 static int adm6996_gpio_probe(struct platform_device *pdev)
78 @@ -1193,7 +1194,7 @@ static int __init adm6996_init(void)
79 int err;
80
81 phy_register_fixup_for_id(PHY_ANY_ID, adm6996_fixup);
82 - err = phy_driver_register(&adm6996_phy_driver, THIS_MODULE);
83 + err = phy_driver_register(&adm6996_phy_driver);
84 if (err)
85 return err;
86
87 --- a/drivers/net/phy/ar8216.c
88 +++ b/drivers/net/phy/ar8216.c
89 @@ -177,7 +177,7 @@ ar8xxx_phy_check_aneg(struct phy_device
90 if (ret & BMCR_ANENABLE)
91 return 0;
92
93 - dev_info(&phydev->mdio.dev, "ANEG disabled, re-enabling ...\n");
94 + dev_info(&phydev->dev, "ANEG disabled, re-enabling ...\n");
95 ret |= BMCR_ANENABLE | BMCR_ANRESTART;
96 return phy_write(phydev, MII_BMCR, ret);
97 }
98 @@ -1996,7 +1996,7 @@ ar8xxx_phy_config_init(struct phy_device
99
100 priv->phy = phydev;
101
102 - if (phydev->mdio.addr != 0) {
103 + if (phydev->addr != 0) {
104 if (chip_is_ar8316(priv)) {
105 /* switch device has been initialized, reinit */
106 priv->dev.ports = (AR8216_NUM_PORTS - 1);
107 @@ -2044,7 +2044,7 @@ ar8xxx_check_link_states(struct ar8xxx_p
108 /* flush ARL entries for this port if it went down*/
109 if (!link_new)
110 priv->chip->atu_flush_port(priv, i);
111 - dev_info(&priv->phy->mdio.dev, "Port %d is %s\n",
112 + dev_info(&priv->phy->dev, "Port %d is %s\n",
113 i, link_new ? "up" : "down");
114 }
115
116 @@ -2063,10 +2063,10 @@ ar8xxx_phy_read_status(struct phy_device
117 if (phydev->state == PHY_CHANGELINK)
118 ar8xxx_check_link_states(priv);
119
120 - if (phydev->mdio.addr != 0)
121 + if (phydev->addr != 0)
122 return genphy_read_status(phydev);
123
124 - ar8216_read_port_link(priv, phydev->mdio.addr, &link);
125 + ar8216_read_port_link(priv, phydev->addr, &link);
126 phydev->link = !!link.link;
127 if (!phydev->link)
128 return 0;
129 @@ -2096,7 +2096,7 @@ ar8xxx_phy_read_status(struct phy_device
130 static int
131 ar8xxx_phy_config_aneg(struct phy_device *phydev)
132 {
133 - if (phydev->mdio.addr == 0)
134 + if (phydev->addr == 0)
135 return 0;
136
137 return genphy_config_aneg(phydev);
138 @@ -2151,15 +2151,15 @@ ar8xxx_phy_probe(struct phy_device *phyd
139 int ret;
140
141 /* skip PHYs at unused adresses */
142 - if (phydev->mdio.addr != 0 && phydev->mdio.addr != 4)
143 + if (phydev->addr != 0 && phydev->addr != 4)
144 return -ENODEV;
145
146 - if (!ar8xxx_is_possible(phydev->mdio.bus))
147 + if (!ar8xxx_is_possible(phydev->bus))
148 return -ENODEV;
149
150 mutex_lock(&ar8xxx_dev_list_lock);
151 list_for_each_entry(priv, &ar8xxx_dev_list, list)
152 - if (priv->mii_bus == phydev->mdio.bus)
153 + if (priv->mii_bus == phydev->bus)
154 goto found;
155
156 priv = ar8xxx_create();
157 @@ -2168,7 +2168,7 @@ ar8xxx_phy_probe(struct phy_device *phyd
158 goto unlock;
159 }
160
161 - priv->mii_bus = phydev->mdio.bus;
162 + priv->mii_bus = phydev->bus;
163
164 ret = ar8xxx_probe_switch(priv);
165 if (ret)
166 @@ -2189,7 +2189,7 @@ ar8xxx_phy_probe(struct phy_device *phyd
167 found:
168 priv->use_count++;
169
170 - if (phydev->mdio.addr == 0) {
171 + if (phydev->addr == 0) {
172 if (ar8xxx_has_gige(priv)) {
173 phydev->supported = SUPPORTED_1000baseT_Full;
174 phydev->advertising = ADVERTISED_1000baseT_Full;
175 @@ -2277,21 +2277,33 @@ ar8xxx_phy_soft_reset(struct phy_device
176 return 0;
177 }
178
179 -static struct phy_driver ar8xxx_phy_driver[] = {
180 - {
181 - .phy_id = 0x004d0000,
182 - .name = "Atheros AR8216/AR8236/AR8316",
183 - .phy_id_mask = 0xffff0000,
184 - .features = PHY_BASIC_FEATURES,
185 - .probe = ar8xxx_phy_probe,
186 - .remove = ar8xxx_phy_remove,
187 - .detach = ar8xxx_phy_detach,
188 - .config_init = ar8xxx_phy_config_init,
189 - .config_aneg = ar8xxx_phy_config_aneg,
190 - .read_status = ar8xxx_phy_read_status,
191 - .soft_reset = ar8xxx_phy_soft_reset,
192 - }
193 +static struct phy_driver ar8xxx_phy_driver = {
194 + .phy_id = 0x004d0000,
195 + .name = "Atheros AR8216/AR8236/AR8316",
196 + .phy_id_mask = 0xffff0000,
197 + .features = PHY_BASIC_FEATURES,
198 + .probe = ar8xxx_phy_probe,
199 + .remove = ar8xxx_phy_remove,
200 + .detach = ar8xxx_phy_detach,
201 + .config_init = ar8xxx_phy_config_init,
202 + .config_aneg = ar8xxx_phy_config_aneg,
203 + .read_status = ar8xxx_phy_read_status,
204 + .soft_reset = ar8xxx_phy_soft_reset,
205 + .driver = { .owner = THIS_MODULE },
206 };
207
208 -module_phy_driver(ar8xxx_phy_driver);
209 +int __init
210 +ar8xxx_init(void)
211 +{
212 + return phy_driver_register(&ar8xxx_phy_driver);
213 +}
214 +
215 +void __exit
216 +ar8xxx_exit(void)
217 +{
218 + phy_driver_unregister(&ar8xxx_phy_driver);
219 +}
220 +
221 +module_init(ar8xxx_init);
222 +module_exit(ar8xxx_exit);
223 MODULE_LICENSE("GPL");
224 --- a/drivers/net/phy/ar8327.c
225 +++ b/drivers/net/phy/ar8327.c
226 @@ -619,11 +619,11 @@ ar8327_hw_init(struct ar8xxx_priv *priv)
227 if (!priv->chip_data)
228 return -ENOMEM;
229
230 - if (priv->phy->mdio.dev.of_node)
231 - ret = ar8327_hw_config_of(priv, priv->phy->mdio.dev.of_node);
232 + if (priv->phy->dev.of_node)
233 + ret = ar8327_hw_config_of(priv, priv->phy->dev.of_node);
234 else
235 ret = ar8327_hw_config_pdata(priv,
236 - priv->phy->mdio.dev.platform_data);
237 + priv->phy->dev.platform_data);
238
239 if (ret)
240 return ret;
241 --- a/drivers/net/phy/ip17xx.c
242 +++ b/drivers/net/phy/ip17xx.c
243 @@ -1273,7 +1273,7 @@ static int ip17xx_probe(struct phy_devic
244 int err;
245
246 /* We only attach to PHY 0, but use all available PHYs */
247 - if (pdev->mdio.addr != 0)
248 + if (pdev->addr != 0)
249 return -ENODEV;
250
251 state = kzalloc(sizeof(*state), GFP_KERNEL);
252 @@ -1283,7 +1283,7 @@ static int ip17xx_probe(struct phy_devic
253 dev = &state->dev;
254
255 pdev->priv = state;
256 - state->mii_bus = pdev->mdio.bus;
257 + state->mii_bus = pdev->bus;
258
259 err = get_model(state);
260 if (err < 0)
261 @@ -1295,7 +1295,7 @@ static int ip17xx_probe(struct phy_devic
262 dev->name = state->regs->NAME;
263 dev->ops = &ip17xx_ops;
264
265 - pr_info("IP17xx: Found %s at %s\n", dev->name, dev_name(&pdev->mdio.dev));
266 + pr_info("IP17xx: Found %s at %s\n", dev->name, dev_name(&pdev->dev));
267 return 0;
268
269 error:
270 @@ -1353,25 +1353,58 @@ static int ip17xx_read_status(struct phy
271 return 0;
272 }
273
274 -static struct phy_driver ip17xx_driver[] = {
275 - {
276 - .name = "IC+ IP17xx",
277 - .phy_id = 0x02430c00,
278 - .phy_id_mask = 0x0ffffc00,
279 - .features = PHY_BASIC_FEATURES,
280 - .probe = ip17xx_probe,
281 - .remove = ip17xx_remove,
282 - .config_init = ip17xx_config_init,
283 - .config_aneg = ip17xx_config_aneg,
284 - .aneg_done = ip17xx_aneg_done,
285 - .update_link = ip17xx_update_link,
286 - .read_status = ip17xx_read_status,
287 - }
288 +static struct phy_driver ip17xx_driver = {
289 + .name = "IC+ IP17xx",
290 + .phy_id = 0x02430c00,
291 + .phy_id_mask = 0x0ffffc00,
292 + .features = PHY_BASIC_FEATURES,
293 + .probe = ip17xx_probe,
294 + .remove = ip17xx_remove,
295 + .config_init = ip17xx_config_init,
296 + .config_aneg = ip17xx_config_aneg,
297 + .aneg_done = ip17xx_aneg_done,
298 + .update_link = ip17xx_update_link,
299 + .read_status = ip17xx_read_status,
300 + .driver = { .owner = THIS_MODULE },
301 };
302
303 -module_phy_driver(ip17xx_driver);
304 +static struct phy_driver ip175a_driver = {
305 + .name = "IC+ IP175A",
306 + .phy_id = 0x02430c50,
307 + .phy_id_mask = 0x0ffffff0,
308 + .features = PHY_BASIC_FEATURES,
309 + .probe = ip17xx_probe,
310 + .remove = ip17xx_remove,
311 + .config_init = ip17xx_config_init,
312 + .config_aneg = ip17xx_config_aneg,
313 + .aneg_done = ip17xx_aneg_done,
314 + .update_link = ip17xx_update_link,
315 + .read_status = ip17xx_read_status,
316 + .driver = { .owner = THIS_MODULE },
317 +};
318 +
319 +
320 +int __init ip17xx_init(void)
321 +{
322 + int ret;
323 +
324 + ret = phy_driver_register(&ip175a_driver);
325 + if (ret < 0)
326 + return ret;
327 +
328 + return phy_driver_register(&ip17xx_driver);
329 +}
330 +
331 +void __exit ip17xx_exit(void)
332 +{
333 + phy_driver_unregister(&ip17xx_driver);
334 + phy_driver_unregister(&ip175a_driver);
335 +}
336
337 MODULE_AUTHOR("Patrick Horn <patrick.horn@gmail.com>");
338 MODULE_AUTHOR("Felix Fietkau <nbd@nbd.name>");
339 MODULE_AUTHOR("Martin Mares <mj@ucw.cz>");
340 MODULE_LICENSE("GPL");
341 +
342 +module_init(ip17xx_init);
343 +module_exit(ip17xx_exit);
344 --- a/drivers/net/phy/mvswitch.c
345 +++ b/drivers/net/phy/mvswitch.c
346 @@ -50,17 +50,13 @@ struct mvswitch_priv {
347 static inline u16
348 r16(struct phy_device *phydev, int addr, int reg)
349 {
350 - struct mii_bus *bus = phydev->mdio.bus;
351 -
352 - return bus->read(bus, addr, reg);
353 + return phydev->bus->read(phydev->bus, addr, reg);
354 }
355
356 static inline void
357 w16(struct phy_device *phydev, int addr, int reg, u16 val)
358 {
359 - struct mii_bus *bus = phydev->mdio.bus;
360 -
361 - bus->write(bus, addr, reg, val);
362 + phydev->bus->write(phydev->bus, addr, reg, val);
363 }
364
365
366 @@ -392,13 +388,12 @@ mvswitch_probe(struct phy_device *pdev)
367 static int
368 mvswitch_fixup(struct phy_device *dev)
369 {
370 - struct mii_bus *bus = dev->mdio.bus;
371 u16 reg;
372
373 - if (dev->mdio.addr != 0x10)
374 + if (dev->addr != 0x10)
375 return 0;
376
377 - reg = bus->read(bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
378 + reg = dev->bus->read(dev->bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
379 if (reg != MV_IDENT_VALUE)
380 return 0;
381
382 @@ -418,13 +413,14 @@ static struct phy_driver mvswitch_driver
383 .config_init = &mvswitch_config_init,
384 .config_aneg = &mvswitch_config_aneg,
385 .read_status = &mvswitch_read_status,
386 + .driver = { .owner = THIS_MODULE,},
387 };
388
389 static int __init
390 mvswitch_init(void)
391 {
392 phy_register_fixup_for_id(PHY_ANY_ID, mvswitch_fixup);
393 - return phy_driver_register(&mvswitch_driver, THIS_MODULE);
394 + return phy_driver_register(&mvswitch_driver);
395 }
396
397 static void __exit
398 --- a/drivers/net/phy/psb6970.c
399 +++ b/drivers/net/phy/psb6970.c
400 @@ -70,16 +70,12 @@ struct psb6970_priv {
401
402 static u16 psb6970_mii_read(struct phy_device *phydev, int reg)
403 {
404 - struct mii_bus *bus = phydev->mdio.bus;
405 -
406 - return bus->read(bus, PHYADDR(reg));
407 + return phydev->bus->read(phydev->bus, PHYADDR(reg));
408 }
409
410 static void psb6970_mii_write(struct phy_device *phydev, int reg, u16 val)
411 {
412 - struct mii_bus *bus = phydev->mdio.bus;
413 -
414 - bus->write(bus, PHYADDR(reg), val);
415 + phydev->bus->write(phydev->bus, PHYADDR(reg), val);
416 }
417
418 static int
419 @@ -316,11 +312,11 @@ static int psb6970_config_init(struct ph
420
421 priv->phy = pdev;
422
423 - if (pdev->mdio.addr == 0)
424 + if (pdev->addr == 0)
425 printk(KERN_INFO "%s: psb6970 switch driver attached.\n",
426 pdev->attached_dev->name);
427
428 - if (pdev->mdio.addr != 0) {
429 + if (pdev->addr != 0) {
430 kfree(priv);
431 return 0;
432 }
433 @@ -388,14 +384,14 @@ static void psb6970_remove(struct phy_de
434 if (!priv)
435 return;
436
437 - if (pdev->mdio.addr == 0)
438 + if (pdev->addr == 0)
439 unregister_switch(&priv->dev);
440 kfree(priv);
441 }
442
443 static int psb6970_fixup(struct phy_device *dev)
444 {
445 - struct mii_bus *bus = dev->mdio.bus;
446 + struct mii_bus *bus = dev->bus;
447 u16 reg;
448
449 /* look for the switch on the bus */
450 @@ -419,12 +415,13 @@ static struct phy_driver psb6970_driver
451 .config_init = &psb6970_config_init,
452 .config_aneg = &psb6970_config_aneg,
453 .read_status = &psb6970_read_status,
454 + .driver = {.owner = THIS_MODULE},
455 };
456
457 int __init psb6970_init(void)
458 {
459 phy_register_fixup_for_id(PHY_ANY_ID, psb6970_fixup);
460 - return phy_driver_register(&psb6970_driver, THIS_MODULE);
461 + return phy_driver_register(&psb6970_driver);
462 }
463
464 module_init(psb6970_init);
465 --- a/drivers/net/phy/rtl8306.c
466 +++ b/drivers/net/phy/rtl8306.c
467 @@ -872,7 +872,7 @@ rtl8306_config_init(struct phy_device *p
468 int err;
469
470 /* Only init the switch for the primary PHY */
471 - if (pdev->mdio.addr != 0)
472 + if (pdev->addr != 0)
473 return 0;
474
475 val.value.i = 1;
476 @@ -882,7 +882,7 @@ rtl8306_config_init(struct phy_device *p
477 priv->dev.ops = &rtl8306_ops;
478 priv->do_cpu = 0;
479 priv->page = -1;
480 - priv->bus = pdev->mdio.bus;
481 + priv->bus = pdev->bus;
482
483 chipid = rtl_get(dev, RTL_REG_CHIPID);
484 chipver = rtl_get(dev, RTL_REG_CHIPVER);
485 @@ -928,13 +928,13 @@ rtl8306_fixup(struct phy_device *pdev)
486 u16 chipid;
487
488 /* Attach to primary LAN port and WAN port */
489 - if (pdev->mdio.addr != 0 && pdev->mdio.addr != 4)
490 + if (pdev->addr != 0 && pdev->addr != 4)
491 return 0;
492
493 memset(&priv, 0, sizeof(priv));
494 priv.fixup = true;
495 priv.page = -1;
496 - priv.bus = pdev->mdio.bus;
497 + priv.bus = pdev->bus;
498 chipid = rtl_get(&priv.dev, RTL_REG_CHIPID);
499 if (chipid == 0x5988)
500 pdev->phy_id = RTL8306_MAGIC;
501 @@ -952,14 +952,14 @@ rtl8306_probe(struct phy_device *pdev)
502 * share one rtl_priv instance between virtual phy
503 * devices on the same bus
504 */
505 - if (priv->bus == pdev->mdio.bus)
506 + if (priv->bus == pdev->bus)
507 goto found;
508 }
509 priv = kzalloc(sizeof(struct rtl_priv), GFP_KERNEL);
510 if (!priv)
511 return -ENOMEM;
512
513 - priv->bus = pdev->mdio.bus;
514 + priv->bus = pdev->bus;
515
516 found:
517 pdev->priv = priv;
518 @@ -980,7 +980,7 @@ rtl8306_config_aneg(struct phy_device *p
519 struct rtl_priv *priv = pdev->priv;
520
521 /* Only for WAN */
522 - if (pdev->mdio.addr == 0)
523 + if (pdev->addr == 0)
524 return 0;
525
526 /* Restart autonegotiation */
527 @@ -996,7 +996,7 @@ rtl8306_read_status(struct phy_device *p
528 struct rtl_priv *priv = pdev->priv;
529 struct switch_dev *dev = &priv->dev;
530
531 - if (pdev->mdio.addr == 4) {
532 + if (pdev->addr == 4) {
533 /* WAN */
534 pdev->speed = rtl_get(dev, RTL_PORT_REG(4, SPEED)) ? SPEED_100 : SPEED_10;
535 pdev->duplex = rtl_get(dev, RTL_PORT_REG(4, DUPLEX)) ? DUPLEX_FULL : DUPLEX_HALF;
536 @@ -1037,6 +1037,7 @@ static struct phy_driver rtl8306_driver
537 .config_init = &rtl8306_config_init,
538 .config_aneg = &rtl8306_config_aneg,
539 .read_status = &rtl8306_read_status,
540 + .driver = { .owner = THIS_MODULE,},
541 };
542
543
544 @@ -1044,7 +1045,7 @@ static int __init
545 rtl_init(void)
546 {
547 phy_register_fixup_for_id(PHY_ANY_ID, rtl8306_fixup);
548 - return phy_driver_register(&rtl8306_driver, THIS_MODULE);
549 + return phy_driver_register(&rtl8306_driver);
550 }
551
552 static void __exit