@@ -57,9 +57,7 @@ struct mac_priv_s {
5757 struct device * dev ;
5858 void __iomem * vaddr ;
5959 u8 cell_index ;
60- phy_interface_t phy_if ;
6160 struct fman * fman ;
62- struct device_node * phy_node ;
6361 struct device_node * internal_phy_node ;
6462 /* List of multicast addresses */
6563 struct list_head mc_addr_list ;
@@ -106,7 +104,7 @@ static void set_fman_mac_params(struct mac_device *mac_dev,
106104 resource_size (mac_dev -> res ));
107105 memcpy (& params -> addr , mac_dev -> addr , sizeof (mac_dev -> addr ));
108106 params -> max_speed = priv -> max_speed ;
109- params -> phy_if = priv -> phy_if ;
107+ params -> phy_if = mac_dev -> phy_if ;
110108 params -> basex_if = false;
111109 params -> mac_id = priv -> cell_index ;
112110 params -> fm = (void * )priv -> fman ;
@@ -419,15 +417,12 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
419417}
420418EXPORT_SYMBOL (fman_get_pause_cfg );
421419
422- static void adjust_link_void (struct net_device * net_dev )
420+ static void adjust_link_void (struct mac_device * mac_dev )
423421{
424422}
425423
426- static void adjust_link_dtsec (struct net_device * net_dev )
424+ static void adjust_link_dtsec (struct mac_device * mac_dev )
427425{
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 ;
431426 struct phy_device * phy_dev = mac_dev -> phy_dev ;
432427 struct fman_mac * fman_mac ;
433428 bool rx_pause , tx_pause ;
@@ -444,14 +439,12 @@ static void adjust_link_dtsec(struct net_device *net_dev)
444439 fman_get_pause_cfg (mac_dev , & rx_pause , & tx_pause );
445440 err = fman_set_mac_active_pause (mac_dev , rx_pause , tx_pause );
446441 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 );
448444}
449445
450- static void adjust_link_memac (struct net_device * net_dev )
446+ static void adjust_link_memac (struct mac_device * mac_dev )
451447{
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 ;
455448 struct phy_device * phy_dev = mac_dev -> phy_dev ;
456449 struct fman_mac * fman_mac ;
457450 bool rx_pause , tx_pause ;
@@ -463,60 +456,12 @@ static void adjust_link_memac(struct net_device *net_dev)
463456 fman_get_pause_cfg (mac_dev , & rx_pause , & tx_pause );
464457 err = fman_set_mac_active_pause (mac_dev , rx_pause , tx_pause );
465458 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 );
515461}
516462
517463static void setup_dtsec (struct mac_device * mac_dev )
518464{
519- mac_dev -> init_phy = dtsec_init_phy ;
520465 mac_dev -> init = dtsec_initialization ;
521466 mac_dev -> set_promisc = dtsec_set_promiscuous ;
522467 mac_dev -> change_addr = dtsec_modify_mac_address ;
@@ -528,14 +473,13 @@ static void setup_dtsec(struct mac_device *mac_dev)
528473 mac_dev -> set_multi = set_multi ;
529474 mac_dev -> start = start ;
530475 mac_dev -> stop = stop ;
531-
476+ mac_dev -> adjust_link = adjust_link_dtsec ;
532477 mac_dev -> priv -> enable = dtsec_enable ;
533478 mac_dev -> priv -> disable = dtsec_disable ;
534479}
535480
536481static void setup_tgec (struct mac_device * mac_dev )
537482{
538- mac_dev -> init_phy = tgec_init_phy ;
539483 mac_dev -> init = tgec_initialization ;
540484 mac_dev -> set_promisc = tgec_set_promiscuous ;
541485 mac_dev -> change_addr = tgec_modify_mac_address ;
@@ -547,14 +491,13 @@ static void setup_tgec(struct mac_device *mac_dev)
547491 mac_dev -> set_multi = set_multi ;
548492 mac_dev -> start = start ;
549493 mac_dev -> stop = stop ;
550-
494+ mac_dev -> adjust_link = adjust_link_void ;
551495 mac_dev -> priv -> enable = tgec_enable ;
552496 mac_dev -> priv -> disable = tgec_disable ;
553497}
554498
555499static void setup_memac (struct mac_device * mac_dev )
556500{
557- mac_dev -> init_phy = memac_init_phy ;
558501 mac_dev -> init = memac_initialization ;
559502 mac_dev -> set_promisc = memac_set_promiscuous ;
560503 mac_dev -> change_addr = memac_modify_mac_address ;
@@ -566,7 +509,7 @@ static void setup_memac(struct mac_device *mac_dev)
566509 mac_dev -> set_multi = set_multi ;
567510 mac_dev -> start = start ;
568511 mac_dev -> stop = stop ;
569-
512+ mac_dev -> adjust_link = adjust_link_memac ;
570513 mac_dev -> priv -> enable = memac_enable ;
571514 mac_dev -> priv -> disable = memac_disable ;
572515}
@@ -850,13 +793,13 @@ static int mac_probe(struct platform_device *_of_dev)
850793 mac_node );
851794 phy_if = PHY_INTERFACE_MODE_SGMII ;
852795 }
853- priv -> phy_if = phy_if ;
796+ mac_dev -> phy_if = phy_if ;
854797
855- priv -> speed = phy2speed [priv -> phy_if ];
798+ priv -> speed = phy2speed [mac_dev -> phy_if ];
856799 priv -> max_speed = priv -> speed ;
857800 mac_dev -> if_support = DTSEC_SUPPORTED ;
858801 /* 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 )
860803 mac_dev -> if_support &= ~(SUPPORTED_10baseT_Half |
861804 SUPPORTED_100baseT_Half );
862805
@@ -865,12 +808,12 @@ static int mac_probe(struct platform_device *_of_dev)
865808 mac_dev -> if_support |= SUPPORTED_1000baseT_Full ;
866809
867810 /* 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 )
869812 mac_dev -> if_support = SUPPORTED_10000baseT_Full ;
870813
871814 /* 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 )) {
874817 struct phy_device * phy ;
875818
876819 err = of_phy_register_fixed_link (mac_node );
@@ -884,8 +827,8 @@ static int mac_probe(struct platform_device *_of_dev)
884827 goto _return_dev_set_drvdata ;
885828 }
886829
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 );
889832 if (!phy ) {
890833 err = - EINVAL ;
891834 goto _return_dev_set_drvdata ;
@@ -903,7 +846,7 @@ static int mac_probe(struct platform_device *_of_dev)
903846 err = mac_dev -> init (mac_dev );
904847 if (err < 0 ) {
905848 dev_err (dev , "mac_dev->init() = %d\n" , err );
906- of_node_put (priv -> phy_node );
849+ of_node_put (mac_dev -> phy_node );
907850 goto _return_dev_set_drvdata ;
908851 }
909852
0 commit comments