@@ -425,32 +425,40 @@ static int macb_mii_probe(struct net_device *dev)
425
425
int phy_irq ;
426
426
int ret ;
427
427
428
- phydev = phy_find_first (bp -> mii_bus );
429
- if (!phydev ) {
430
- netdev_err (dev , "no PHY found\n" );
431
- return - ENXIO ;
432
- }
428
+ if (bp -> phy_node ) {
429
+ phydev = of_phy_connect (dev , bp -> phy_node ,
430
+ & macb_handle_link_change , 0 ,
431
+ bp -> phy_interface );
432
+ if (!phydev )
433
+ return - ENODEV ;
434
+ } else {
435
+ phydev = phy_find_first (bp -> mii_bus );
436
+ if (!phydev ) {
437
+ netdev_err (dev , "no PHY found\n" );
438
+ return - ENXIO ;
439
+ }
433
440
434
- pdata = dev_get_platdata (& bp -> pdev -> dev );
435
- if (pdata ) {
436
- if (gpio_is_valid (pdata -> phy_irq_pin )) {
437
- ret = devm_gpio_request (& bp -> pdev -> dev ,
438
- pdata -> phy_irq_pin , "phy int" );
439
- if (!ret ) {
440
- phy_irq = gpio_to_irq (pdata -> phy_irq_pin );
441
- phydev -> irq = (phy_irq < 0 ) ? PHY_POLL : phy_irq ;
441
+ pdata = dev_get_platdata (& bp -> pdev -> dev );
442
+ if (pdata ) {
443
+ if (gpio_is_valid (pdata -> phy_irq_pin )) {
444
+ ret = devm_gpio_request (& bp -> pdev -> dev ,
445
+ pdata -> phy_irq_pin , "phy int" );
446
+ if (!ret ) {
447
+ phy_irq = gpio_to_irq (pdata -> phy_irq_pin );
448
+ phydev -> irq = (phy_irq < 0 ) ? PHY_POLL : phy_irq ;
449
+ }
450
+ } else {
451
+ phydev -> irq = PHY_POLL ;
442
452
}
443
- } else {
444
- phydev -> irq = PHY_POLL ;
445
453
}
446
- }
447
454
448
- /* attach the mac to the phy */
449
- ret = phy_connect_direct (dev , phydev , & macb_handle_link_change ,
450
- bp -> phy_interface );
451
- if (ret ) {
452
- netdev_err (dev , "Could not attach to PHY\n" );
453
- return ret ;
455
+ /* attach the mac to the phy */
456
+ ret = phy_connect_direct (dev , phydev , & macb_handle_link_change ,
457
+ bp -> phy_interface );
458
+ if (ret ) {
459
+ netdev_err (dev , "Could not attach to PHY\n" );
460
+ return ret ;
461
+ }
454
462
}
455
463
456
464
/* mask with MAC supported features */
@@ -499,26 +507,37 @@ static int macb_mii_init(struct macb *bp)
499
507
500
508
np = bp -> pdev -> dev .of_node ;
501
509
if (np ) {
502
- /* try dt phy registration */
503
- err = of_mdiobus_register (bp -> mii_bus , np );
510
+ if (of_phy_is_fixed_link (np )) {
511
+ if (of_phy_register_fixed_link (np ) < 0 ) {
512
+ dev_err (& bp -> pdev -> dev ,
513
+ "broken fixed-link specification\n" );
514
+ goto err_out_unregister_bus ;
515
+ }
516
+ bp -> phy_node = of_node_get (np );
504
517
505
- /* fallback to standard phy registration if no phy were
506
- * found during dt phy registration
507
- */
508
- if (!err && !phy_find_first (bp -> mii_bus )) {
509
- for (i = 0 ; i < PHY_MAX_ADDR ; i ++ ) {
510
- struct phy_device * phydev ;
511
-
512
- phydev = mdiobus_scan (bp -> mii_bus , i );
513
- if (IS_ERR (phydev ) &&
514
- PTR_ERR (phydev ) != - ENODEV ) {
515
- err = PTR_ERR (phydev );
516
- break ;
518
+ err = mdiobus_register (bp -> mii_bus );
519
+ } else {
520
+ /* try dt phy registration */
521
+ err = of_mdiobus_register (bp -> mii_bus , np );
522
+
523
+ /* fallback to standard phy registration if no phy were
524
+ * found during dt phy registration
525
+ */
526
+ if (!err && !phy_find_first (bp -> mii_bus )) {
527
+ for (i = 0 ; i < PHY_MAX_ADDR ; i ++ ) {
528
+ struct phy_device * phydev ;
529
+
530
+ phydev = mdiobus_scan (bp -> mii_bus , i );
531
+ if (IS_ERR (phydev ) &&
532
+ PTR_ERR (phydev ) != - ENODEV ) {
533
+ err = PTR_ERR (phydev );
534
+ break ;
535
+ }
517
536
}
518
- }
519
537
520
- if (err )
521
- goto err_out_unregister_bus ;
538
+ if (err )
539
+ goto err_out_unregister_bus ;
540
+ }
522
541
}
523
542
} else {
524
543
for (i = 0 ; i < PHY_MAX_ADDR ; i ++ )
@@ -3438,6 +3457,7 @@ static int macb_remove(struct platform_device *pdev)
3438
3457
clk_disable_unprepare (bp -> hclk );
3439
3458
clk_disable_unprepare (bp -> pclk );
3440
3459
clk_disable_unprepare (bp -> rx_clk );
3460
+ of_node_put (bp -> phy_node );
3441
3461
free_netdev (dev );
3442
3462
}
3443
3463
0 commit comments