@@ -482,7 +482,8 @@ static void enetc_port_si_configure(struct enetc_si *si)
482482 enetc_port_wr (hw , ENETC_PSIVLANFMR , ENETC_PSIVLANFMR_VS );
483483}
484484
485- static void enetc_configure_port_mac (struct enetc_hw * hw )
485+ static void enetc_configure_port_mac (struct enetc_hw * hw ,
486+ phy_interface_t phy_mode )
486487{
487488 enetc_port_wr (hw , ENETC_PM0_MAXFRM ,
488489 ENETC_SET_MAXFRM (ENETC_RX_MAXFRM_SIZE ));
@@ -498,9 +499,11 @@ static void enetc_configure_port_mac(struct enetc_hw *hw)
498499 ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC |
499500 ENETC_PM0_TX_EN | ENETC_PM0_RX_EN );
500501 /* set auto-speed for RGMII */
501- if (enetc_port_rd (hw , ENETC_PM0_IF_MODE ) & ENETC_PMO_IFM_RG )
502+ if (enetc_port_rd (hw , ENETC_PM0_IF_MODE ) & ENETC_PMO_IFM_RG ||
503+ phy_interface_mode_is_rgmii (phy_mode ))
502504 enetc_port_wr (hw , ENETC_PM0_IF_MODE , ENETC_PM0_IFM_RGAUTO );
503- if (enetc_global_rd (hw , ENETC_G_EPFBLPR (1 )) == ENETC_G_EPFBLPR1_XGMII )
505+
506+ if (phy_mode == PHY_INTERFACE_MODE_USXGMII )
504507 enetc_port_wr (hw , ENETC_PM0_IF_MODE , ENETC_PM0_IFM_XGMII );
505508}
506509
@@ -524,7 +527,7 @@ static void enetc_configure_port(struct enetc_pf *pf)
524527
525528 enetc_configure_port_pmac (hw );
526529
527- enetc_configure_port_mac (hw );
530+ enetc_configure_port_mac (hw , pf -> if_mode );
528531
529532 enetc_port_si_configure (pf -> si );
530533
@@ -776,43 +779,43 @@ static void enetc_mdio_remove(struct enetc_pf *pf)
776779 mdiobus_unregister (pf -> mdio );
777780}
778781
779- static int enetc_of_get_phy (struct enetc_ndev_priv * priv )
782+ static int enetc_of_get_phy (struct enetc_pf * pf )
780783{
781- struct enetc_pf * pf = enetc_si_priv ( priv -> si ) ;
782- struct device_node * np = priv -> dev -> of_node ;
784+ struct device * dev = & pf -> si -> pdev -> dev ;
785+ struct device_node * np = dev -> of_node ;
783786 struct device_node * mdio_np ;
784787 int err ;
785788
786- priv -> phy_node = of_parse_phandle (np , "phy-handle" , 0 );
787- if (!priv -> phy_node ) {
789+ pf -> phy_node = of_parse_phandle (np , "phy-handle" , 0 );
790+ if (!pf -> phy_node ) {
788791 if (!of_phy_is_fixed_link (np )) {
789- dev_err (priv -> dev , "PHY not specified\n" );
792+ dev_err (dev , "PHY not specified\n" );
790793 return - ENODEV ;
791794 }
792795
793796 err = of_phy_register_fixed_link (np );
794797 if (err < 0 ) {
795- dev_err (priv -> dev , "fixed link registration failed\n" );
798+ dev_err (dev , "fixed link registration failed\n" );
796799 return err ;
797800 }
798801
799- priv -> phy_node = of_node_get (np );
802+ pf -> phy_node = of_node_get (np );
800803 }
801804
802805 mdio_np = of_get_child_by_name (np , "mdio" );
803806 if (mdio_np ) {
804807 of_node_put (mdio_np );
805808 err = enetc_mdio_probe (pf );
806809 if (err ) {
807- of_node_put (priv -> phy_node );
810+ of_node_put (pf -> phy_node );
808811 return err ;
809812 }
810813 }
811814
812- err = of_get_phy_mode (np , & priv -> if_mode );
815+ err = of_get_phy_mode (np , & pf -> if_mode );
813816 if (err ) {
814- dev_err (priv -> dev , "missing phy type\n" );
815- of_node_put (priv -> phy_node );
817+ dev_err (dev , "missing phy type\n" );
818+ of_node_put (pf -> phy_node );
816819 if (of_phy_is_fixed_link (np ))
817820 of_phy_deregister_fixed_link (np );
818821 else
@@ -824,14 +827,14 @@ static int enetc_of_get_phy(struct enetc_ndev_priv *priv)
824827 return 0 ;
825828}
826829
827- static void enetc_of_put_phy (struct enetc_ndev_priv * priv )
830+ static void enetc_of_put_phy (struct enetc_pf * pf )
828831{
829- struct device_node * np = priv -> dev -> of_node ;
832+ struct device_node * np = pf -> si -> pdev -> dev . of_node ;
830833
831834 if (np && of_phy_is_fixed_link (np ))
832835 of_phy_deregister_fixed_link (np );
833- if (priv -> phy_node )
834- of_node_put (priv -> phy_node );
836+ if (pf -> phy_node )
837+ of_node_put (pf -> phy_node );
835838}
836839
837840static int enetc_imdio_init (struct enetc_pf * pf , bool is_c45 )
@@ -994,6 +997,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
994997 pf -> si = si ;
995998 pf -> total_vfs = pci_sriov_get_totalvfs (pdev );
996999
1000+ err = enetc_of_get_phy (pf );
1001+ if (err )
1002+ dev_warn (& pdev -> dev , "Fallback to PHY-less operation\n" );
1003+
9971004 enetc_configure_port (pf );
9981005
9991006 enetc_get_si_caps (si );
@@ -1008,6 +1015,8 @@ static int enetc_pf_probe(struct pci_dev *pdev,
10081015 enetc_pf_netdev_setup (si , ndev , & enetc_ndev_ops );
10091016
10101017 priv = netdev_priv (ndev );
1018+ priv -> phy_node = pf -> phy_node ;
1019+ priv -> if_mode = pf -> if_mode ;
10111020
10121021 enetc_init_si_rings_params (priv );
10131022
@@ -1023,10 +1032,6 @@ static int enetc_pf_probe(struct pci_dev *pdev,
10231032 goto err_alloc_msix ;
10241033 }
10251034
1026- err = enetc_of_get_phy (priv );
1027- if (err )
1028- dev_warn (& pdev -> dev , "Fallback to PHY-less operation\n" );
1029-
10301035 err = enetc_configure_serdes (priv );
10311036 if (err )
10321037 dev_warn (& pdev -> dev , "Attempted SerDes config but failed\n" );
@@ -1040,14 +1045,14 @@ static int enetc_pf_probe(struct pci_dev *pdev,
10401045 return 0 ;
10411046
10421047err_reg_netdev :
1043- enetc_of_put_phy (priv );
10441048 enetc_free_msix (priv );
10451049err_alloc_msix :
10461050 enetc_free_si_resources (priv );
10471051err_alloc_si_res :
10481052 si -> ndev = NULL ;
10491053 free_netdev (ndev );
10501054err_alloc_netdev :
1055+ enetc_of_put_phy (pf );
10511056err_map_pf_space :
10521057 enetc_pci_remove (pdev );
10531058
@@ -1068,7 +1073,7 @@ static void enetc_pf_remove(struct pci_dev *pdev)
10681073
10691074 enetc_imdio_remove (pf );
10701075 enetc_mdio_remove (pf );
1071- enetc_of_put_phy (priv );
1076+ enetc_of_put_phy (pf );
10721077
10731078 enetc_free_msix (priv );
10741079
0 commit comments