7575#define RGMII_CONFIG2_DATA_DIVIDE_CLK_SEL BIT(6)
7676#define RGMII_CONFIG2_TX_CLK_PHASE_SHIFT_EN BIT(5)
7777
78+ /* MAC_CTRL_REG bits */
79+ #define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14)
80+ #define ETHQOS_MAC_CTRL_PORT_SEL BIT(15)
81+
7882struct ethqos_emac_por {
7983 unsigned int offset ;
8084 unsigned int value ;
@@ -92,6 +96,7 @@ struct ethqos_emac_driver_data {
9296struct qcom_ethqos {
9397 struct platform_device * pdev ;
9498 void __iomem * rgmii_base ;
99+ void __iomem * mac_base ;
95100 int (* configure_func )(struct qcom_ethqos * ethqos );
96101
97102 unsigned int link_clk_rate ;
@@ -559,6 +564,33 @@ static int ethqos_configure_rgmii(struct qcom_ethqos *ethqos)
559564 return 0 ;
560565}
561566
567+ static int ethqos_configure_sgmii (struct qcom_ethqos * ethqos )
568+ {
569+ int val ;
570+
571+ val = readl (ethqos -> mac_base + MAC_CTRL_REG );
572+
573+ switch (ethqos -> speed ) {
574+ case SPEED_1000 :
575+ val &= ~ETHQOS_MAC_CTRL_PORT_SEL ;
576+ rgmii_updatel (ethqos , RGMII_CONFIG2_RGMII_CLK_SEL_CFG ,
577+ RGMII_CONFIG2_RGMII_CLK_SEL_CFG ,
578+ RGMII_IO_MACRO_CONFIG2 );
579+ break ;
580+ case SPEED_100 :
581+ val |= ETHQOS_MAC_CTRL_PORT_SEL | ETHQOS_MAC_CTRL_SPEED_MODE ;
582+ break ;
583+ case SPEED_10 :
584+ val |= ETHQOS_MAC_CTRL_PORT_SEL ;
585+ val &= ~ETHQOS_MAC_CTRL_SPEED_MODE ;
586+ break ;
587+ }
588+
589+ writel (val , ethqos -> mac_base + MAC_CTRL_REG );
590+
591+ return val ;
592+ }
593+
562594static int ethqos_configure (struct qcom_ethqos * ethqos )
563595{
564596 return ethqos -> configure_func (ethqos );
@@ -663,6 +695,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
663695 case PHY_INTERFACE_MODE_RGMII_TXID :
664696 ethqos -> configure_func = ethqos_configure_rgmii ;
665697 break ;
698+ case PHY_INTERFACE_MODE_SGMII :
699+ ethqos -> configure_func = ethqos_configure_sgmii ;
700+ break ;
666701 case - ENODEV :
667702 ret = - ENODEV ;
668703 goto out_config_dt ;
@@ -678,6 +713,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
678713 goto out_config_dt ;
679714 }
680715
716+ ethqos -> mac_base = stmmac_res .addr ;
717+
681718 data = of_device_get_match_data (dev );
682719 ethqos -> por = data -> por ;
683720 ethqos -> num_por = data -> num_por ;
0 commit comments