@@ -567,158 +567,13 @@ static int rtl93xx_get_sds(struct phy_device *phydev)
567567 return sds_num ;
568568}
569569
570- static void rtldsa_83xx_pcs_get_state (struct phylink_pcs * pcs , struct phylink_link_state * state )
571- {
572- struct rtl838x_pcs * rtpcs = container_of (pcs , struct rtl838x_pcs , pcs );
573- struct rtl838x_switch_priv * priv = rtpcs -> priv ;
574- int port = rtpcs -> port ;
575- u64 speed ;
576-
577- state -> link = 0 ;
578- state -> speed = SPEED_UNKNOWN ;
579- state -> duplex = DUPLEX_UNKNOWN ;
580- state -> pause &= ~(MLO_PAUSE_RX | MLO_PAUSE_TX );
581-
582- if (port < 0 || port > priv -> cpu_port )
583- return ;
584-
585- if (!(priv -> r -> get_port_reg_le (priv -> r -> mac_link_sts ) & BIT_ULL (port )))
586- return ;
587-
588- state -> link = 1 ;
589-
590- if (priv -> r -> get_port_reg_le (priv -> r -> mac_link_dup_sts ) & BIT_ULL (port ))
591- state -> duplex = DUPLEX_FULL ;
592- else
593- state -> duplex = DUPLEX_HALF ;
594-
595- speed = priv -> r -> get_port_reg_le (priv -> r -> mac_link_spd_sts (port ));
596- speed = (speed >> ((port % 16 ) << 1 )) & 0x3 ;
597-
598- switch (speed ) {
599- case RTL_SPEED_10 :
600- state -> speed = SPEED_10 ;
601- break ;
602- case RTL_SPEED_100 :
603- state -> speed = SPEED_100 ;
604- break ;
605- case RTL_SPEED_1000 :
606- state -> speed = SPEED_1000 ;
607- break ;
608- case 3 :
609- /*
610- * This is ok so far but with minor inconsistencies. On RTL838x this setting is
611- * for either 500M or 2G. It might be that MAC_GLITE_STS register tells more. On
612- * RTL839x these vendor specifics are derived from MAC_LINK_500M_STS and mode 3
613- * is 10G. This is of interest so resolve to it. Sadly it is off by one for the
614- * current RTL_SPEED_10000 (=4) definition for RTL93xx.
615- */
616- state -> speed = SPEED_10000 ;
617- break ;
618- }
619-
620- if (priv -> r -> get_port_reg_le (priv -> r -> mac_rx_pause_sts ) & BIT_ULL (port ))
621- state -> pause |= MLO_PAUSE_RX ;
622- if (priv -> r -> get_port_reg_le (priv -> r -> mac_tx_pause_sts ) & BIT_ULL (port ))
623- state -> pause |= MLO_PAUSE_TX ;
624- }
625-
626- static void rtldsa_93xx_pcs_get_state (struct phylink_pcs * pcs ,
627- struct phylink_link_state * state )
628- {
629- struct rtl838x_pcs * rtpcs = container_of (pcs , struct rtl838x_pcs , pcs );
630- struct rtl838x_switch_priv * priv = rtpcs -> priv ;
631- int port = rtpcs -> port ;
632- u64 speed ;
633- u64 link ;
634- u64 media ;
635-
636- state -> link = 0 ;
637- state -> speed = SPEED_UNKNOWN ;
638- state -> duplex = DUPLEX_UNKNOWN ;
639- state -> pause &= ~(MLO_PAUSE_RX | MLO_PAUSE_TX );
640-
641- if (port < 0 || port > priv -> cpu_port )
642- return ;
643-
644- /* On the RTL9300 for at least the RTL8226B PHY, the MAC-side link
645- * state needs to be read twice in order to read a correct result.
646- * This would not be necessary for ports connected e.g. to RTL8218D
647- * PHYs.
648- */
649- link = priv -> r -> get_port_reg_le (priv -> r -> mac_link_sts );
650- link = priv -> r -> get_port_reg_le (priv -> r -> mac_link_sts );
651- if (!(link & BIT_ULL (port )))
652- return ;
653-
654- state -> link = 1 ;
655-
656- if (priv -> family_id == RTL9310_FAMILY_ID )
657- media = priv -> r -> get_port_reg_le (RTL931X_MAC_LINK_MEDIA_STS );
658-
659- if (priv -> family_id == RTL9300_FAMILY_ID )
660- media = sw_r32 (RTL930X_MAC_LINK_MEDIA_STS );
661-
662- pr_debug ("%s: link state port %d: %llx, media %llx\n" , __func__ , port ,
663- link & BIT_ULL (port ), media );
664-
665- if (priv -> r -> get_port_reg_le (priv -> r -> mac_link_dup_sts ) & BIT_ULL (port ))
666- state -> duplex = DUPLEX_FULL ;
667- else
668- state -> duplex = DUPLEX_HALF ;
669-
670- speed = priv -> r -> get_port_reg_le (priv -> r -> mac_link_spd_sts (port ));
671- speed = (speed >> ((port % 8 ) << 2 )) & 0xf ;
672- switch (speed ) {
673- case RTL_SPEED_10 :
674- state -> speed = SPEED_10 ;
675- break ;
676- case RTL_SPEED_100 :
677- state -> speed = SPEED_100 ;
678- break ;
679- case RTL_SPEED_1000 :
680- state -> speed = SPEED_1000 ;
681- break ;
682- case RTL_SPEED_10000 :
683- state -> speed = SPEED_10000 ;
684- break ;
685- case RTL_SPEED_2500 :
686- state -> speed = SPEED_2500 ;
687- break ;
688- case RTL_SPEED_5000 :
689- state -> speed = SPEED_5000 ;
690- break ;
691- default :
692- pr_err ("%s: unknown speed: %d\n" , __func__ , (u32 )speed & 0xf );
693- }
694-
695- pr_debug ("%s: speed is: %d %d\n" , __func__ , (u32 )speed & 0xf , state -> speed );
696- if (priv -> r -> get_port_reg_le (priv -> r -> mac_rx_pause_sts ) & BIT_ULL (port ))
697- state -> pause |= MLO_PAUSE_RX ;
698- if (priv -> r -> get_port_reg_le (priv -> r -> mac_tx_pause_sts ) & BIT_ULL (port ))
699- state -> pause |= MLO_PAUSE_TX ;
700- }
701-
702- static int rtl83xx_pcs_config (struct phylink_pcs * pcs , unsigned int neg_mode ,
703- phy_interface_t interface ,
704- const unsigned long * advertising ,
705- bool permit_pause_to_mac )
706- {
707- return 0 ;
708- }
709-
710- static void rtl83xx_pcs_an_restart (struct phylink_pcs * pcs )
711- {
712- /* No restart functionality existed before we migrated to pcs */
713- }
714-
715- static struct phylink_pcs * rtl83xx_phylink_mac_select_pcs (struct dsa_switch * ds ,
716- int port ,
717- phy_interface_t interface )
570+ static struct phylink_pcs * rtldsa_phylink_mac_select_pcs (struct dsa_switch * ds ,
571+ int port ,
572+ phy_interface_t interface )
718573{
719574 struct rtl838x_switch_priv * priv = ds -> priv ;
720575
721- return & priv -> pcs [port ]. pcs ;
576+ return priv -> pcs [port ];
722577}
723578
724579static void rtl83xx_config_interface (int port , phy_interface_t interface )
@@ -2678,12 +2533,6 @@ static int rtldsa_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val
26782533 return mdiobus_write_nested (priv -> parent_bus , addr , regnum , val );
26792534}
26802535
2681- const struct phylink_pcs_ops rtl83xx_pcs_ops = {
2682- .pcs_an_restart = rtl83xx_pcs_an_restart ,
2683- .pcs_get_state = rtldsa_83xx_pcs_get_state ,
2684- .pcs_config = rtl83xx_pcs_config ,
2685- };
2686-
26872536const struct dsa_switch_ops rtl83xx_switch_ops = {
26882537 .get_tag_protocol = rtl83xx_get_tag_protocol ,
26892538 .setup = rtl83xx_setup ,
@@ -2695,7 +2544,7 @@ const struct dsa_switch_ops rtl83xx_switch_ops = {
26952544 .phylink_mac_config = rtl83xx_phylink_mac_config ,
26962545 .phylink_mac_link_down = rtl83xx_phylink_mac_link_down ,
26972546 .phylink_mac_link_up = rtl83xx_phylink_mac_link_up ,
2698- .phylink_mac_select_pcs = rtl83xx_phylink_mac_select_pcs ,
2547+ .phylink_mac_select_pcs = rtldsa_phylink_mac_select_pcs ,
26992548
27002549 .get_strings = rtldsa_get_strings ,
27012550 .get_ethtool_stats = rtldsa_get_ethtool_stats ,
@@ -2741,12 +2590,6 @@ const struct dsa_switch_ops rtl83xx_switch_ops = {
27412590 .port_bridge_flags = rtl83xx_port_bridge_flags ,
27422591};
27432592
2744- const struct phylink_pcs_ops rtl93xx_pcs_ops = {
2745- .pcs_an_restart = rtl83xx_pcs_an_restart ,
2746- .pcs_get_state = rtldsa_93xx_pcs_get_state ,
2747- .pcs_config = rtl83xx_pcs_config ,
2748- };
2749-
27502593const struct dsa_switch_ops rtl930x_switch_ops = {
27512594 .get_tag_protocol = rtl83xx_get_tag_protocol ,
27522595 .setup = rtl93xx_setup ,
@@ -2758,7 +2601,7 @@ const struct dsa_switch_ops rtl930x_switch_ops = {
27582601 .phylink_mac_config = rtl93xx_phylink_mac_config ,
27592602 .phylink_mac_link_down = rtl93xx_phylink_mac_link_down ,
27602603 .phylink_mac_link_up = rtl93xx_phylink_mac_link_up ,
2761- .phylink_mac_select_pcs = rtl83xx_phylink_mac_select_pcs ,
2604+ .phylink_mac_select_pcs = rtldsa_phylink_mac_select_pcs ,
27622605
27632606 .get_strings = rtldsa_get_strings ,
27642607 .get_ethtool_stats = rtldsa_get_ethtool_stats ,
0 commit comments