@@ -1093,6 +1093,29 @@ static void fec_enet_enable_ring(struct net_device *ndev)
10931093 }
10941094}
10951095
1096+ /* Whack a reset. We should wait for this.
1097+ * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
1098+ * instead of reset MAC itself.
1099+ */
1100+ static void fec_ctrl_reset (struct fec_enet_private * fep , bool allow_wol )
1101+ {
1102+ u32 val ;
1103+
1104+ if (!allow_wol || !(fep -> wol_flag & FEC_WOL_FLAG_SLEEP_ON )) {
1105+ if (fep -> quirks & FEC_QUIRK_HAS_MULTI_QUEUES ||
1106+ ((fep -> quirks & FEC_QUIRK_NO_HARD_RESET ) && fep -> link )) {
1107+ writel (0 , fep -> hwp + FEC_ECNTRL );
1108+ } else {
1109+ writel (FEC_ECR_RESET , fep -> hwp + FEC_ECNTRL );
1110+ udelay (10 );
1111+ }
1112+ } else {
1113+ val = readl (fep -> hwp + FEC_ECNTRL );
1114+ val |= (FEC_ECR_MAGICEN | FEC_ECR_SLEEP );
1115+ writel (val , fep -> hwp + FEC_ECNTRL );
1116+ }
1117+ }
1118+
10961119/*
10971120 * This function is called to start or restart the FEC during a link
10981121 * change, transmit timeout, or to reconfigure the FEC. The network
@@ -1109,17 +1132,7 @@ fec_restart(struct net_device *ndev)
11091132 if (fep -> bufdesc_ex )
11101133 fec_ptp_save_state (fep );
11111134
1112- /* Whack a reset. We should wait for this.
1113- * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
1114- * instead of reset MAC itself.
1115- */
1116- if (fep -> quirks & FEC_QUIRK_HAS_MULTI_QUEUES ||
1117- ((fep -> quirks & FEC_QUIRK_NO_HARD_RESET ) && fep -> link )) {
1118- writel (0 , fep -> hwp + FEC_ECNTRL );
1119- } else {
1120- writel (1 , fep -> hwp + FEC_ECNTRL );
1121- udelay (10 );
1122- }
1135+ fec_ctrl_reset (fep , false);
11231136
11241137 /*
11251138 * enet-mac reset will reset mac address registers too,
@@ -1373,22 +1386,7 @@ fec_stop(struct net_device *ndev)
13731386 if (fep -> bufdesc_ex )
13741387 fec_ptp_save_state (fep );
13751388
1376- /* Whack a reset. We should wait for this.
1377- * For i.MX6SX SOC, enet use AXI bus, we use disable MAC
1378- * instead of reset MAC itself.
1379- */
1380- if (!(fep -> wol_flag & FEC_WOL_FLAG_SLEEP_ON )) {
1381- if (fep -> quirks & FEC_QUIRK_HAS_MULTI_QUEUES ) {
1382- writel (0 , fep -> hwp + FEC_ECNTRL );
1383- } else {
1384- writel (FEC_ECR_RESET , fep -> hwp + FEC_ECNTRL );
1385- udelay (10 );
1386- }
1387- } else {
1388- val = readl (fep -> hwp + FEC_ECNTRL );
1389- val |= (FEC_ECR_MAGICEN | FEC_ECR_SLEEP );
1390- writel (val , fep -> hwp + FEC_ECNTRL );
1391- }
1389+ fec_ctrl_reset (fep , true);
13921390 writel (fep -> phy_speed , fep -> hwp + FEC_MII_SPEED );
13931391 writel (FEC_DEFAULT_IMASK , fep -> hwp + FEC_IMASK );
13941392
0 commit comments