@@ -106,12 +106,11 @@ struct qcom_ethqos {
106106 struct platform_device * pdev ;
107107 void __iomem * rgmii_base ;
108108 void __iomem * mac_base ;
109- int (* configure_func )(struct qcom_ethqos * ethqos );
109+ int (* configure_func )(struct qcom_ethqos * ethqos , int speed );
110110
111111 unsigned int link_clk_rate ;
112112 struct clk * link_clk ;
113113 struct phy * serdes_phy ;
114- int speed ;
115114 int serdes_speed ;
116115 phy_interface_t phy_mode ;
117116
@@ -385,7 +384,7 @@ static int ethqos_dll_configure(struct qcom_ethqos *ethqos)
385384 return 0 ;
386385}
387386
388- static int ethqos_rgmii_macro_init (struct qcom_ethqos * ethqos )
387+ static int ethqos_rgmii_macro_init (struct qcom_ethqos * ethqos , int speed )
389388{
390389 struct device * dev = & ethqos -> pdev -> dev ;
391390 int phase_shift ;
@@ -412,7 +411,7 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
412411 rgmii_updatel (ethqos , RGMII_CONFIG_INTF_SEL ,
413412 0 , RGMII_IO_MACRO_CONFIG );
414413
415- switch (ethqos -> speed ) {
414+ switch (speed ) {
416415 case SPEED_1000 :
417416 rgmii_updatel (ethqos , RGMII_CONFIG_DDR_MODE ,
418417 RGMII_CONFIG_DDR_MODE , RGMII_IO_MACRO_CONFIG );
@@ -532,14 +531,14 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos)
532531 loopback , RGMII_IO_MACRO_CONFIG );
533532 break ;
534533 default :
535- dev_err (dev , "Invalid speed %d\n" , ethqos -> speed );
534+ dev_err (dev , "Invalid speed %d\n" , speed );
536535 return - EINVAL ;
537536 }
538537
539538 return 0 ;
540539}
541540
542- static int ethqos_configure_rgmii (struct qcom_ethqos * ethqos )
541+ static int ethqos_configure_rgmii (struct qcom_ethqos * ethqos , int speed )
543542{
544543 struct device * dev = & ethqos -> pdev -> dev ;
545544 volatile unsigned int dll_lock ;
@@ -562,7 +561,7 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
562561 SDCC_DLL_CONFIG_PDN , SDCC_HC_REG_DLL_CONFIG );
563562
564563 if (ethqos -> has_emac_ge_3 ) {
565- if (ethqos -> speed == SPEED_1000 ) {
564+ if (speed == SPEED_1000 ) {
566565 rgmii_writel (ethqos , 0x1800000 , SDCC_TEST_CTL );
567566 rgmii_writel (ethqos , 0x2C010800 , SDCC_USR_CTL );
568567 rgmii_writel (ethqos , 0xA001 , SDCC_HC_REG_DLL_CONFIG2 );
@@ -580,7 +579,7 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
580579 rgmii_updatel (ethqos , SDCC_DLL_CONFIG_PDN , 0 ,
581580 SDCC_HC_REG_DLL_CONFIG );
582581
583- if (ethqos -> speed != SPEED_100 && ethqos -> speed != SPEED_10 ) {
582+ if (speed != SPEED_100 && speed != SPEED_10 ) {
584583 /* Set DLL_EN */
585584 rgmii_updatel (ethqos , SDCC_DLL_CONFIG_DLL_EN ,
586585 SDCC_DLL_CONFIG_DLL_EN , SDCC_HC_REG_DLL_CONFIG );
@@ -607,10 +606,10 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
607606 dev_err (dev , "Timeout while waiting for DLL lock\n" );
608607 }
609608
610- if (ethqos -> speed == SPEED_1000 )
609+ if (speed == SPEED_1000 )
611610 ethqos_dll_configure (ethqos );
612611
613- ethqos_rgmii_macro_init (ethqos );
612+ ethqos_rgmii_macro_init (ethqos , speed );
614613
615614 return 0 ;
616615}
@@ -626,15 +625,15 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed)
626625/* On interface toggle MAC registers gets reset.
627626 * Configure MAC block for SGMII on ethernet phy link up
628627 */
629- static int ethqos_configure_sgmii (struct qcom_ethqos * ethqos )
628+ static int ethqos_configure_sgmii (struct qcom_ethqos * ethqos , int speed )
630629{
631630 struct net_device * dev = platform_get_drvdata (ethqos -> pdev );
632631 struct stmmac_priv * priv = netdev_priv (dev );
633632 int val ;
634633
635634 val = readl (ethqos -> mac_base + MAC_CTRL_REG );
636635
637- switch (ethqos -> speed ) {
636+ switch (speed ) {
638637 case SPEED_2500 :
639638 val &= ~ETHQOS_MAC_CTRL_PORT_SEL ;
640639 rgmii_updatel (ethqos , RGMII_CONFIG2_RGMII_CLK_SEL_CFG ,
@@ -673,27 +672,18 @@ static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos)
673672 return val ;
674673}
675674
676- static void qcom_ethqos_speed_mode_2500 (struct net_device * ndev , void * data )
675+ static int ethqos_configure (struct qcom_ethqos * ethqos , int speed )
677676{
678- struct stmmac_priv * priv = netdev_priv (ndev );
679-
680- priv -> plat -> max_speed = 2500 ;
681- priv -> plat -> phy_interface = PHY_INTERFACE_MODE_2500BASEX ;
682- }
683-
684- static int ethqos_configure (struct qcom_ethqos * ethqos )
685- {
686- return ethqos -> configure_func (ethqos );
677+ return ethqos -> configure_func (ethqos , speed );
687678}
688679
689680static void ethqos_fix_mac_speed (void * priv , int speed , unsigned int mode )
690681{
691682 struct qcom_ethqos * ethqos = priv ;
692683
693684 qcom_ethqos_set_sgmii_loopback (ethqos , false);
694- ethqos -> speed = speed ;
695685 ethqos_update_link_clk (ethqos , speed );
696- ethqos_configure (ethqos );
686+ ethqos_configure (ethqos , speed );
697687}
698688
699689static int qcom_ethqos_serdes_powerup (struct net_device * ndev , void * priv )
@@ -709,7 +699,7 @@ static int qcom_ethqos_serdes_powerup(struct net_device *ndev, void *priv)
709699 if (ret )
710700 return ret ;
711701
712- return phy_set_speed (ethqos -> serdes_phy , ethqos -> speed );
702+ return phy_set_speed (ethqos -> serdes_phy , ethqos -> serdes_speed );
713703}
714704
715705static void qcom_ethqos_serdes_powerdown (struct net_device * ndev , void * priv )
@@ -803,8 +793,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
803793 ethqos -> configure_func = ethqos_configure_rgmii ;
804794 break ;
805795 case PHY_INTERFACE_MODE_2500BASEX :
806- plat_dat -> speed_mode_2500 = qcom_ethqos_speed_mode_2500 ;
807- fallthrough ;
808796 case PHY_INTERFACE_MODE_SGMII :
809797 ethqos -> configure_func = ethqos_configure_sgmii ;
810798 break ;
@@ -847,7 +835,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
847835 return dev_err_probe (dev , PTR_ERR (ethqos -> serdes_phy ),
848836 "Failed to get serdes phy\n" );
849837
850- ethqos -> speed = SPEED_1000 ;
851838 ethqos -> serdes_speed = SPEED_1000 ;
852839 ethqos_update_link_clk (ethqos , SPEED_1000 );
853840 ethqos_set_func_clk_en (ethqos );
0 commit comments