123
123
#define DTSEC_ECNTRL_R100M 0x00000008
124
124
#define DTSEC_ECNTRL_QSGMIIM 0x00000001
125
125
126
- #define DTSEC_TCTRL_GTS 0x00000020
126
+ #define TCTRL_GTS 0x00000020
127
127
128
128
#define RCTRL_PAL_MASK 0x001f0000
129
129
#define RCTRL_PAL_SHIFT 16
@@ -863,6 +863,52 @@ int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool new_val)
863
863
return 0 ;
864
864
}
865
865
866
+ static void graceful_start (struct fman_mac * dtsec , enum comm_mode mode )
867
+ {
868
+ struct dtsec_regs __iomem * regs = dtsec -> regs ;
869
+
870
+ if (mode & COMM_MODE_TX )
871
+ iowrite32be (ioread32be (& regs -> tctrl ) &
872
+ ~TCTRL_GTS , & regs -> tctrl );
873
+ if (mode & COMM_MODE_RX )
874
+ iowrite32be (ioread32be (& regs -> rctrl ) &
875
+ ~RCTRL_GRS , & regs -> rctrl );
876
+ }
877
+
878
+ static void graceful_stop (struct fman_mac * dtsec , enum comm_mode mode )
879
+ {
880
+ struct dtsec_regs __iomem * regs = dtsec -> regs ;
881
+ u32 tmp ;
882
+
883
+ /* Graceful stop - Assert the graceful Rx stop bit */
884
+ if (mode & COMM_MODE_RX ) {
885
+ tmp = ioread32be (& regs -> rctrl ) | RCTRL_GRS ;
886
+ iowrite32be (tmp , & regs -> rctrl );
887
+
888
+ if (dtsec -> fm_rev_info .major == 2 ) {
889
+ /* Workaround for dTSEC Errata A002 */
890
+ usleep_range (100 , 200 );
891
+ } else {
892
+ /* Workaround for dTSEC Errata A004839 */
893
+ usleep_range (10 , 50 );
894
+ }
895
+ }
896
+
897
+ /* Graceful stop - Assert the graceful Tx stop bit */
898
+ if (mode & COMM_MODE_TX ) {
899
+ if (dtsec -> fm_rev_info .major == 2 ) {
900
+ /* dTSEC Errata A004: Do not use TCTRL[GTS]=1 */
901
+ pr_debug ("GTS not supported due to DTSEC_A004 Errata.\n" );
902
+ } else {
903
+ tmp = ioread32be (& regs -> tctrl ) | TCTRL_GTS ;
904
+ iowrite32be (tmp , & regs -> tctrl );
905
+
906
+ /* Workaround for dTSEC Errata A0012, A0014 */
907
+ usleep_range (10 , 50 );
908
+ }
909
+ }
910
+ }
911
+
866
912
int dtsec_enable (struct fman_mac * dtsec , enum comm_mode mode )
867
913
{
868
914
struct dtsec_regs __iomem * regs = dtsec -> regs ;
@@ -880,13 +926,8 @@ int dtsec_enable(struct fman_mac *dtsec, enum comm_mode mode)
880
926
881
927
iowrite32be (tmp , & regs -> maccfg1 );
882
928
883
- /* Graceful start - clear the graceful receive stop bit */
884
- if (mode & COMM_MODE_TX )
885
- iowrite32be (ioread32be (& regs -> tctrl ) & ~DTSEC_TCTRL_GTS ,
886
- & regs -> tctrl );
887
- if (mode & COMM_MODE_RX )
888
- iowrite32be (ioread32be (& regs -> rctrl ) & ~RCTRL_GRS ,
889
- & regs -> rctrl );
929
+ /* Graceful start - clear the graceful Rx/Tx stop bit */
930
+ graceful_start (dtsec , mode );
890
931
891
932
return 0 ;
892
933
}
@@ -899,23 +940,8 @@ int dtsec_disable(struct fman_mac *dtsec, enum comm_mode mode)
899
940
if (!is_init_done (dtsec -> dtsec_drv_param ))
900
941
return - EINVAL ;
901
942
902
- /* Gracefull stop - Assert the graceful transmit stop bit */
903
- if (mode & COMM_MODE_RX ) {
904
- tmp = ioread32be (& regs -> rctrl ) | RCTRL_GRS ;
905
- iowrite32be (tmp , & regs -> rctrl );
906
-
907
- if (dtsec -> fm_rev_info .major == 2 )
908
- usleep_range (100 , 200 );
909
- else
910
- udelay (10 );
911
- }
912
-
913
- if (mode & COMM_MODE_TX ) {
914
- if (dtsec -> fm_rev_info .major == 2 )
915
- pr_debug ("GTS not supported due to DTSEC_A004 errata.\n" );
916
- else
917
- pr_debug ("GTS not supported due to DTSEC_A0014 errata.\n" );
918
- }
943
+ /* Graceful stop - Assert the graceful Rx/Tx stop bit */
944
+ graceful_stop (dtsec , mode );
919
945
920
946
tmp = ioread32be (& regs -> maccfg1 );
921
947
if (mode & COMM_MODE_RX )
@@ -933,11 +959,19 @@ int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
933
959
u16 pause_time , u16 __maybe_unused thresh_time )
934
960
{
935
961
struct dtsec_regs __iomem * regs = dtsec -> regs ;
962
+ enum comm_mode mode = COMM_MODE_NONE ;
936
963
u32 ptv = 0 ;
937
964
938
965
if (!is_init_done (dtsec -> dtsec_drv_param ))
939
966
return - EINVAL ;
940
967
968
+ if ((ioread32be (& regs -> rctrl ) & RCTRL_GRS ) == 0 )
969
+ mode |= COMM_MODE_RX ;
970
+ if ((ioread32be (& regs -> tctrl ) & TCTRL_GTS ) == 0 )
971
+ mode |= COMM_MODE_TX ;
972
+
973
+ graceful_stop (dtsec , mode );
974
+
941
975
if (pause_time ) {
942
976
/* FM_BAD_TX_TS_IN_B_2_B_ERRATA_DTSEC_A003 Errata workaround */
943
977
if (dtsec -> fm_rev_info .major == 2 && pause_time <= 320 ) {
@@ -958,38 +992,62 @@ int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
958
992
iowrite32be (ioread32be (& regs -> maccfg1 ) & ~MACCFG1_TX_FLOW ,
959
993
& regs -> maccfg1 );
960
994
995
+ graceful_start (dtsec , mode );
996
+
961
997
return 0 ;
962
998
}
963
999
964
1000
int dtsec_accept_rx_pause_frames (struct fman_mac * dtsec , bool en )
965
1001
{
966
1002
struct dtsec_regs __iomem * regs = dtsec -> regs ;
1003
+ enum comm_mode mode = COMM_MODE_NONE ;
967
1004
u32 tmp ;
968
1005
969
1006
if (!is_init_done (dtsec -> dtsec_drv_param ))
970
1007
return - EINVAL ;
971
1008
1009
+ if ((ioread32be (& regs -> rctrl ) & RCTRL_GRS ) == 0 )
1010
+ mode |= COMM_MODE_RX ;
1011
+ if ((ioread32be (& regs -> tctrl ) & TCTRL_GTS ) == 0 )
1012
+ mode |= COMM_MODE_TX ;
1013
+
1014
+ graceful_stop (dtsec , mode );
1015
+
972
1016
tmp = ioread32be (& regs -> maccfg1 );
973
1017
if (en )
974
1018
tmp |= MACCFG1_RX_FLOW ;
975
1019
else
976
1020
tmp &= ~MACCFG1_RX_FLOW ;
977
1021
iowrite32be (tmp , & regs -> maccfg1 );
978
1022
1023
+ graceful_start (dtsec , mode );
1024
+
979
1025
return 0 ;
980
1026
}
981
1027
982
1028
int dtsec_modify_mac_address (struct fman_mac * dtsec , enet_addr_t * enet_addr )
983
1029
{
1030
+ struct dtsec_regs __iomem * regs = dtsec -> regs ;
1031
+ enum comm_mode mode = COMM_MODE_NONE ;
1032
+
984
1033
if (!is_init_done (dtsec -> dtsec_drv_param ))
985
1034
return - EINVAL ;
986
1035
1036
+ if ((ioread32be (& regs -> rctrl ) & RCTRL_GRS ) == 0 )
1037
+ mode |= COMM_MODE_RX ;
1038
+ if ((ioread32be (& regs -> tctrl ) & TCTRL_GTS ) == 0 )
1039
+ mode |= COMM_MODE_TX ;
1040
+
1041
+ graceful_stop (dtsec , mode );
1042
+
987
1043
/* Initialize MAC Station Address registers (1 & 2)
988
1044
* Station address have to be swapped (big endian to little endian
989
1045
*/
990
1046
dtsec -> addr = ENET_ADDR_TO_UINT64 (* enet_addr );
991
1047
set_mac_address (dtsec -> regs , (u8 * )(* enet_addr ));
992
1048
1049
+ graceful_start (dtsec , mode );
1050
+
993
1051
return 0 ;
994
1052
}
995
1053
@@ -1162,11 +1220,19 @@ int dtsec_set_promiscuous(struct fman_mac *dtsec, bool new_val)
1162
1220
int dtsec_adjust_link (struct fman_mac * dtsec , u16 speed )
1163
1221
{
1164
1222
struct dtsec_regs __iomem * regs = dtsec -> regs ;
1223
+ enum comm_mode mode = COMM_MODE_NONE ;
1165
1224
u32 tmp ;
1166
1225
1167
1226
if (!is_init_done (dtsec -> dtsec_drv_param ))
1168
1227
return - EINVAL ;
1169
1228
1229
+ if ((ioread32be (& regs -> rctrl ) & RCTRL_GRS ) == 0 )
1230
+ mode |= COMM_MODE_RX ;
1231
+ if ((ioread32be (& regs -> tctrl ) & TCTRL_GTS ) == 0 )
1232
+ mode |= COMM_MODE_TX ;
1233
+
1234
+ graceful_stop (dtsec , mode );
1235
+
1170
1236
tmp = ioread32be (& regs -> maccfg2 );
1171
1237
1172
1238
/* Full Duplex */
@@ -1186,6 +1252,8 @@ int dtsec_adjust_link(struct fman_mac *dtsec, u16 speed)
1186
1252
tmp &= ~DTSEC_ECNTRL_R100M ;
1187
1253
iowrite32be (tmp , & regs -> ecntrl );
1188
1254
1255
+ graceful_start (dtsec , mode );
1256
+
1189
1257
return 0 ;
1190
1258
}
1191
1259
0 commit comments