@@ -57,9 +57,7 @@ struct mac_priv_s {
57
57
struct device * dev ;
58
58
void __iomem * vaddr ;
59
59
u8 cell_index ;
60
- phy_interface_t phy_if ;
61
60
struct fman * fman ;
62
- struct device_node * phy_node ;
63
61
struct device_node * internal_phy_node ;
64
62
/* List of multicast addresses */
65
63
struct list_head mc_addr_list ;
@@ -106,7 +104,7 @@ static void set_fman_mac_params(struct mac_device *mac_dev,
106
104
resource_size (mac_dev -> res ));
107
105
memcpy (& params -> addr , mac_dev -> addr , sizeof (mac_dev -> addr ));
108
106
params -> max_speed = priv -> max_speed ;
109
- params -> phy_if = priv -> phy_if ;
107
+ params -> phy_if = mac_dev -> phy_if ;
110
108
params -> basex_if = false;
111
109
params -> mac_id = priv -> cell_index ;
112
110
params -> fm = (void * )priv -> fman ;
@@ -419,15 +417,12 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
419
417
}
420
418
EXPORT_SYMBOL (fman_get_pause_cfg );
421
419
422
- static void adjust_link_void (struct net_device * net_dev )
420
+ static void adjust_link_void (struct mac_device * mac_dev )
423
421
{
424
422
}
425
423
426
- static void adjust_link_dtsec (struct net_device * net_dev )
424
+ static void adjust_link_dtsec (struct mac_device * mac_dev )
427
425
{
428
- struct device * dev = net_dev -> dev .parent ;
429
- struct dpaa_eth_data * eth_data = dev -> platform_data ;
430
- struct mac_device * mac_dev = eth_data -> mac_dev ;
431
426
struct phy_device * phy_dev = mac_dev -> phy_dev ;
432
427
struct fman_mac * fman_mac ;
433
428
bool rx_pause , tx_pause ;
@@ -444,14 +439,12 @@ static void adjust_link_dtsec(struct net_device *net_dev)
444
439
fman_get_pause_cfg (mac_dev , & rx_pause , & tx_pause );
445
440
err = fman_set_mac_active_pause (mac_dev , rx_pause , tx_pause );
446
441
if (err < 0 )
447
- netdev_err (net_dev , "fman_set_mac_active_pause() = %d\n" , err );
442
+ dev_err (mac_dev -> priv -> dev , "fman_set_mac_active_pause() = %d\n" ,
443
+ err );
448
444
}
449
445
450
- static void adjust_link_memac (struct net_device * net_dev )
446
+ static void adjust_link_memac (struct mac_device * mac_dev )
451
447
{
452
- struct device * dev = net_dev -> dev .parent ;
453
- struct dpaa_eth_data * eth_data = dev -> platform_data ;
454
- struct mac_device * mac_dev = eth_data -> mac_dev ;
455
448
struct phy_device * phy_dev = mac_dev -> phy_dev ;
456
449
struct fman_mac * fman_mac ;
457
450
bool rx_pause , tx_pause ;
@@ -463,60 +456,12 @@ static void adjust_link_memac(struct net_device *net_dev)
463
456
fman_get_pause_cfg (mac_dev , & rx_pause , & tx_pause );
464
457
err = fman_set_mac_active_pause (mac_dev , rx_pause , tx_pause );
465
458
if (err < 0 )
466
- netdev_err (net_dev , "fman_set_mac_active_pause() = %d\n" , err );
467
- }
468
-
469
- /* Initializes driver's PHY state, and attaches to the PHY.
470
- * Returns 0 on success.
471
- */
472
- static struct phy_device * init_phy (struct net_device * net_dev ,
473
- struct mac_device * mac_dev ,
474
- void (* adj_lnk )(struct net_device * ))
475
- {
476
- struct phy_device * phy_dev ;
477
- struct mac_priv_s * priv = mac_dev -> priv ;
478
-
479
- phy_dev = of_phy_connect (net_dev , priv -> phy_node , adj_lnk , 0 ,
480
- priv -> phy_if );
481
- if (!phy_dev ) {
482
- netdev_err (net_dev , "Could not connect to PHY\n" );
483
- return NULL ;
484
- }
485
-
486
- /* Remove any features not supported by the controller */
487
- phy_dev -> supported &= mac_dev -> if_support ;
488
- /* Enable the symmetric and asymmetric PAUSE frame advertisements,
489
- * as most of the PHY drivers do not enable them by default.
490
- */
491
- phy_dev -> supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause );
492
- phy_dev -> advertising = phy_dev -> supported ;
493
-
494
- mac_dev -> phy_dev = phy_dev ;
495
-
496
- return phy_dev ;
497
- }
498
-
499
- static struct phy_device * dtsec_init_phy (struct net_device * net_dev ,
500
- struct mac_device * mac_dev )
501
- {
502
- return init_phy (net_dev , mac_dev , & adjust_link_dtsec );
503
- }
504
-
505
- static struct phy_device * tgec_init_phy (struct net_device * net_dev ,
506
- struct mac_device * mac_dev )
507
- {
508
- return init_phy (net_dev , mac_dev , adjust_link_void );
509
- }
510
-
511
- static struct phy_device * memac_init_phy (struct net_device * net_dev ,
512
- struct mac_device * mac_dev )
513
- {
514
- return init_phy (net_dev , mac_dev , & adjust_link_memac );
459
+ dev_err (mac_dev -> priv -> dev , "fman_set_mac_active_pause() = %d\n" ,
460
+ err );
515
461
}
516
462
517
463
static void setup_dtsec (struct mac_device * mac_dev )
518
464
{
519
- mac_dev -> init_phy = dtsec_init_phy ;
520
465
mac_dev -> init = dtsec_initialization ;
521
466
mac_dev -> set_promisc = dtsec_set_promiscuous ;
522
467
mac_dev -> change_addr = dtsec_modify_mac_address ;
@@ -528,14 +473,13 @@ static void setup_dtsec(struct mac_device *mac_dev)
528
473
mac_dev -> set_multi = set_multi ;
529
474
mac_dev -> start = start ;
530
475
mac_dev -> stop = stop ;
531
-
476
+ mac_dev -> adjust_link = adjust_link_dtsec ;
532
477
mac_dev -> priv -> enable = dtsec_enable ;
533
478
mac_dev -> priv -> disable = dtsec_disable ;
534
479
}
535
480
536
481
static void setup_tgec (struct mac_device * mac_dev )
537
482
{
538
- mac_dev -> init_phy = tgec_init_phy ;
539
483
mac_dev -> init = tgec_initialization ;
540
484
mac_dev -> set_promisc = tgec_set_promiscuous ;
541
485
mac_dev -> change_addr = tgec_modify_mac_address ;
@@ -547,14 +491,13 @@ static void setup_tgec(struct mac_device *mac_dev)
547
491
mac_dev -> set_multi = set_multi ;
548
492
mac_dev -> start = start ;
549
493
mac_dev -> stop = stop ;
550
-
494
+ mac_dev -> adjust_link = adjust_link_void ;
551
495
mac_dev -> priv -> enable = tgec_enable ;
552
496
mac_dev -> priv -> disable = tgec_disable ;
553
497
}
554
498
555
499
static void setup_memac (struct mac_device * mac_dev )
556
500
{
557
- mac_dev -> init_phy = memac_init_phy ;
558
501
mac_dev -> init = memac_initialization ;
559
502
mac_dev -> set_promisc = memac_set_promiscuous ;
560
503
mac_dev -> change_addr = memac_modify_mac_address ;
@@ -566,7 +509,7 @@ static void setup_memac(struct mac_device *mac_dev)
566
509
mac_dev -> set_multi = set_multi ;
567
510
mac_dev -> start = start ;
568
511
mac_dev -> stop = stop ;
569
-
512
+ mac_dev -> adjust_link = adjust_link_memac ;
570
513
mac_dev -> priv -> enable = memac_enable ;
571
514
mac_dev -> priv -> disable = memac_disable ;
572
515
}
@@ -850,13 +793,13 @@ static int mac_probe(struct platform_device *_of_dev)
850
793
mac_node );
851
794
phy_if = PHY_INTERFACE_MODE_SGMII ;
852
795
}
853
- priv -> phy_if = phy_if ;
796
+ mac_dev -> phy_if = phy_if ;
854
797
855
- priv -> speed = phy2speed [priv -> phy_if ];
798
+ priv -> speed = phy2speed [mac_dev -> phy_if ];
856
799
priv -> max_speed = priv -> speed ;
857
800
mac_dev -> if_support = DTSEC_SUPPORTED ;
858
801
/* We don't support half-duplex in SGMII mode */
859
- if (priv -> phy_if == PHY_INTERFACE_MODE_SGMII )
802
+ if (mac_dev -> phy_if == PHY_INTERFACE_MODE_SGMII )
860
803
mac_dev -> if_support &= ~(SUPPORTED_10baseT_Half |
861
804
SUPPORTED_100baseT_Half );
862
805
@@ -865,12 +808,12 @@ static int mac_probe(struct platform_device *_of_dev)
865
808
mac_dev -> if_support |= SUPPORTED_1000baseT_Full ;
866
809
867
810
/* The 10G interface only supports one mode */
868
- if (priv -> phy_if == PHY_INTERFACE_MODE_XGMII )
811
+ if (mac_dev -> phy_if == PHY_INTERFACE_MODE_XGMII )
869
812
mac_dev -> if_support = SUPPORTED_10000baseT_Full ;
870
813
871
814
/* Get the rest of the PHY information */
872
- priv -> phy_node = of_parse_phandle (mac_node , "phy-handle" , 0 );
873
- if (!priv -> phy_node && of_phy_is_fixed_link (mac_node )) {
815
+ mac_dev -> phy_node = of_parse_phandle (mac_node , "phy-handle" , 0 );
816
+ if (!mac_dev -> phy_node && of_phy_is_fixed_link (mac_node )) {
874
817
struct phy_device * phy ;
875
818
876
819
err = of_phy_register_fixed_link (mac_node );
@@ -884,8 +827,8 @@ static int mac_probe(struct platform_device *_of_dev)
884
827
goto _return_dev_set_drvdata ;
885
828
}
886
829
887
- priv -> phy_node = of_node_get (mac_node );
888
- phy = of_phy_find_device (priv -> phy_node );
830
+ mac_dev -> phy_node = of_node_get (mac_node );
831
+ phy = of_phy_find_device (mac_dev -> phy_node );
889
832
if (!phy ) {
890
833
err = - EINVAL ;
891
834
goto _return_dev_set_drvdata ;
@@ -903,7 +846,7 @@ static int mac_probe(struct platform_device *_of_dev)
903
846
err = mac_dev -> init (mac_dev );
904
847
if (err < 0 ) {
905
848
dev_err (dev , "mac_dev->init() = %d\n" , err );
906
- of_node_put (priv -> phy_node );
849
+ of_node_put (mac_dev -> phy_node );
907
850
goto _return_dev_set_drvdata ;
908
851
}
909
852
0 commit comments