@@ -515,6 +515,15 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
515515{
516516 struct ravb_private * priv = netdev_priv (ndev );
517517
518+ if (priv -> phy_interface == PHY_INTERFACE_MODE_MII ) {
519+ ravb_write (ndev , (1000 << 16 ) | CXR35_SEL_XMII_MII , CXR35 );
520+ ravb_modify (ndev , CXR31 , CXR31_SEL_LINK0 | CXR31_SEL_LINK1 , 0 );
521+ } else {
522+ ravb_write (ndev , (1000 << 16 ) | CXR35_SEL_XMII_RGMII , CXR35 );
523+ ravb_modify (ndev , CXR31 , CXR31_SEL_LINK0 | CXR31_SEL_LINK1 ,
524+ CXR31_SEL_LINK0 );
525+ }
526+
518527 /* Receive frame limit set register */
519528 ravb_write (ndev , GBETH_RX_BUFF_MAX + ETH_FCS_LEN , RFLR );
520529
@@ -537,14 +546,6 @@ static void ravb_emac_init_gbeth(struct net_device *ndev)
537546
538547 /* E-MAC interrupt enable register */
539548 ravb_write (ndev , ECSIPR_ICDIP , ECSIPR );
540-
541- if (priv -> phy_interface == PHY_INTERFACE_MODE_MII ) {
542- ravb_modify (ndev , CXR31 , CXR31_SEL_LINK0 | CXR31_SEL_LINK1 , 0 );
543- ravb_write (ndev , (1000 << 16 ) | CXR35_SEL_XMII_MII , CXR35 );
544- } else {
545- ravb_modify (ndev , CXR31 , CXR31_SEL_LINK0 | CXR31_SEL_LINK1 ,
546- CXR31_SEL_LINK0 );
547- }
548549}
549550
550551static void ravb_emac_init_rcar (struct net_device * ndev )
@@ -1811,19 +1812,20 @@ static int ravb_open(struct net_device *ndev)
18111812 if (info -> gptp )
18121813 ravb_ptp_init (ndev , priv -> pdev );
18131814
1814- netif_tx_start_all_queues (ndev );
1815-
18161815 /* PHY control start */
18171816 error = ravb_phy_start (ndev );
18181817 if (error )
18191818 goto out_ptp_stop ;
18201819
1820+ netif_tx_start_all_queues (ndev );
1821+
18211822 return 0 ;
18221823
18231824out_ptp_stop :
18241825 /* Stop PTP Clock driver */
18251826 if (info -> gptp )
18261827 ravb_ptp_stop (ndev );
1828+ ravb_stop_dma (ndev );
18271829out_free_irq_mgmta :
18281830 if (!info -> multi_irqs )
18291831 goto out_free_irq ;
@@ -2654,9 +2656,14 @@ static int ravb_probe(struct platform_device *pdev)
26542656 ndev -> features = info -> net_features ;
26552657 ndev -> hw_features = info -> net_hw_features ;
26562658
2657- reset_control_deassert (rstc );
2659+ error = reset_control_deassert (rstc );
2660+ if (error )
2661+ goto out_free_netdev ;
2662+
26582663 pm_runtime_enable (& pdev -> dev );
2659- pm_runtime_get_sync (& pdev -> dev );
2664+ error = pm_runtime_resume_and_get (& pdev -> dev );
2665+ if (error < 0 )
2666+ goto out_rpm_disable ;
26602667
26612668 if (info -> multi_irqs ) {
26622669 if (info -> err_mgmt_irqs )
@@ -2881,11 +2888,12 @@ static int ravb_probe(struct platform_device *pdev)
28812888out_disable_refclk :
28822889 clk_disable_unprepare (priv -> refclk );
28832890out_release :
2884- free_netdev (ndev );
2885-
28862891 pm_runtime_put (& pdev -> dev );
2892+ out_rpm_disable :
28872893 pm_runtime_disable (& pdev -> dev );
28882894 reset_control_assert (rstc );
2895+ out_free_netdev :
2896+ free_netdev (ndev );
28892897 return error ;
28902898}
28912899
@@ -2895,22 +2903,26 @@ static void ravb_remove(struct platform_device *pdev)
28952903 struct ravb_private * priv = netdev_priv (ndev );
28962904 const struct ravb_hw_info * info = priv -> info ;
28972905
2898- /* Stop PTP Clock driver */
2899- if (info -> ccc_gac )
2900- ravb_ptp_stop (ndev );
2901-
2902- clk_disable_unprepare (priv -> gptp_clk );
2903- clk_disable_unprepare (priv -> refclk );
2904-
2905- /* Set reset mode */
2906- ravb_write (ndev , CCC_OPC_RESET , CCC );
29072906 unregister_netdev (ndev );
29082907 if (info -> nc_queues )
29092908 netif_napi_del (& priv -> napi [RAVB_NC ]);
29102909 netif_napi_del (& priv -> napi [RAVB_BE ]);
2910+
29112911 ravb_mdio_release (priv );
2912+
2913+ /* Stop PTP Clock driver */
2914+ if (info -> ccc_gac )
2915+ ravb_ptp_stop (ndev );
2916+
29122917 dma_free_coherent (ndev -> dev .parent , priv -> desc_bat_size , priv -> desc_bat ,
29132918 priv -> desc_bat_dma );
2919+
2920+ /* Set reset mode */
2921+ ravb_write (ndev , CCC_OPC_RESET , CCC );
2922+
2923+ clk_disable_unprepare (priv -> gptp_clk );
2924+ clk_disable_unprepare (priv -> refclk );
2925+
29142926 pm_runtime_put_sync (& pdev -> dev );
29152927 pm_runtime_disable (& pdev -> dev );
29162928 reset_control_assert (priv -> rstc );
0 commit comments