aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0055-sdk_fman-DPAA-dTSEC-ports-fail-to-work-when-link-cha.patch
blob: e17c2a7a4dc62a6601fef68689a7f5fdab1dcada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
From 2b3d05ed1cb560b3a0b0721435c2fd73a19bd9bc Mon Sep 17 00:00:00 2001
From: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
Date: Mon, 29 May 2017 09:25:24 +0300
Subject: [PATCH] sdk_fman: DPAA-dTSEC ports fail to work when link changes

Signed-off-by: Iordache Florinel-R70177 <florinel.iordache@nxp.com>
---
 .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c  | 57 ++++++++++++++++++----
 1 file changed, 48 insertions(+), 9 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
@@ -386,6 +386,7 @@ static void FreeInitResources(t_Dtsec *p
 static t_Error GracefulStop(t_Dtsec *p_Dtsec, e_CommMode mode)
 {
     struct dtsec_regs *p_MemMap;
+    int pollTimeout = 0;
 
     ASSERT_COND(p_Dtsec);
 
@@ -408,16 +409,32 @@ static t_Error GracefulStop(t_Dtsec *p_D
     }
 
     if (mode & e_COMM_MODE_TX)
-#if defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
-    if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
-        DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
-#else  /* not defined(FM_GTS_ERRATA_DTSEC_A004) ||... */
-#ifdef FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014
-        DBG(INFO, ("GTS not supported due to DTSEC_A0014 errata."));
-#else  /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
+    {
+#if defined(FM_GTS_ERRATA_DTSEC_A004)
+        if (p_Dtsec->fmMacControllerDriver.fmRevInfo.majorRev == 2)
+            DBG(INFO, ("GTS not supported due to DTSEC_A004 errata."));
+#else  /* not defined(FM_GTS_ERRATA_DTSEC_A004) */
+
         fman_dtsec_stop_tx(p_MemMap);
-#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 */
-#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) ||...  */
+
+#if defined(FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012)
+        XX_UDelay(10);
+#endif /* FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014 || FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012 */
+#endif /* defined(FM_GTS_ERRATA_DTSEC_A004) */
+    }
+
+    /* Poll GRSC/GTSC bits in IEVENT register until both are set */
+#if defined(FM_GRS_ERRATA_DTSEC_A002) || defined(FM_GTS_ERRATA_DTSEC_A004) || defined(FM_GTS_AFTER_MAC_ABORTED_FRAME_ERRATA_DTSEC_A0012) || defined(FM_GTS_UNDERRUN_ERRATA_DTSEC_A0014) || defined(FM_GTS_AFTER_DROPPED_FRAME_ERRATA_DTSEC_A004839)
+    XX_UDelay(10);
+#else
+    while (fman_dtsec_get_event(p_MemMap, DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN) != (DTSEC_IMASK_GRSCEN | DTSEC_IMASK_GTSCEN))
+    {
+        if (pollTimeout == 100)
+            break;
+        XX_UDelay(1);
+        pollTimeout++;
+    }
+#endif
 
     return E_OK;
 }
@@ -632,7 +649,12 @@ static t_Error DtsecSetTxPauseFrames(t_H
                       " value should be greater than 320."));
 #endif /* FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003 */
 
+    GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     fman_dtsec_set_tx_pause_frames(p_Dtsec->p_MemMap, pauseTime);
+
+    GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     return E_OK;
 }
 
@@ -653,8 +675,12 @@ static t_Error DtsecRxIgnoreMacPause(t_H
     SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
     SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
 
+    GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     fman_dtsec_handle_rx_pause(p_Dtsec->p_MemMap, accept_pause);
 
+    GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     return E_OK;
 }
 
@@ -787,8 +813,13 @@ static t_Error DtsecModifyMacAddress (t_
     /* Initialize MAC Station Address registers (1 & 2)    */
     /* Station address have to be swapped (big endian to little endian */
     p_Dtsec->addr = ENET_ADDR_TO_UINT64(*p_EnetAddr);
+
+    GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     fman_dtsec_set_mac_address(p_Dtsec->p_MemMap, (uint8_t *)(*p_EnetAddr));
 
+    GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     return E_OK;
 }
 
@@ -1076,8 +1107,12 @@ static t_Error DtsecSetWakeOnLan(t_Handl
     SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
     SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
 
+    GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     fman_dtsec_set_wol(p_Dtsec->p_MemMap, en);
 
+    GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     return E_OK;
 }
 
@@ -1098,11 +1133,15 @@ static t_Error DtsecAdjustLink(t_Handle
     enet_speed = (enum enet_speed) ENET_SPEED_FROM_MODE(p_Dtsec->enetMode);
     p_Dtsec->halfDuplex = !fullDuplex;
 
+    GracefulStop(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     err = fman_dtsec_adjust_link(p_Dtsec->p_MemMap, enet_interface, enet_speed, fullDuplex);
 
     if (err == -EINVAL)
         RETURN_ERROR(MAJOR, E_CONFLICT, ("Ethernet interface does not support Half Duplex mode"));
 
+    GracefulRestart(p_Dtsec, e_COMM_MODE_RX_AND_TX);
+
     return (t_Error)err;
 }