File indexing completed on 2025-05-11 08:22:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 #ifndef _GMAC_H
0083 #define _GMAC_H
0084
0085
0086
0087
0088 #include "chip.h"
0089
0090 #include <stdint.h>
0091
0092 #ifdef __cplusplus
0093 extern "C" {
0094 #endif
0095
0096
0097
0098
0099
0100
0101
0102 #define NUM_GMAC_QUEUES 3
0103
0104
0105 #define GMAC_DUPLEX_HALF 0
0106 #define GMAC_DUPLEX_FULL 1
0107
0108
0109 #define GMAC_SPEED_10M 0
0110 #define GMAC_SPEED_100M 1
0111 #define GMAC_SPEED_1000M 2
0112
0113
0114
0115
0116
0117
0118
0119
0120 #define GMAC_ADDRESS_MASK ((unsigned int)0xFFFFFFFC)
0121 #define GMAC_LENGTH_FRAME ((unsigned int)0x3FFF)
0122
0123
0124 #define GMAC_RX_OWNERSHIP_BIT (1u << 0)
0125 #define GMAC_RX_WRAP_BIT (1u << 1)
0126 #define GMAC_RX_SOF_BIT (1u << 14)
0127 #define GMAC_RX_EOF_BIT (1u << 15)
0128
0129
0130 #define GMAC_TX_LAST_BUFFER_BIT (1u << 15)
0131 #define GMAC_TX_WRAP_BIT (1u << 30)
0132 #define GMAC_TX_USED_BIT (1u << 31)
0133 #define GMAC_TX_RLE_BIT (1u << 29)
0134 #define GMAC_TX_UND_BIT (1u << 28)
0135 #define GMAC_TX_ERR_BIT (1u << 27)
0136 #define GMAC_TX_ERR_BITS \
0137 (GMAC_TX_RLE_BIT | GMAC_TX_UND_BIT | GMAC_TX_ERR_BIT)
0138
0139
0140 #define GMAC_INT_RX_BITS \
0141 (GMAC_IER_RCOMP | GMAC_IER_RXUBR | GMAC_IER_ROVR)
0142 #define GMAC_INT_TX_ERR_BITS \
0143 (GMAC_IER_TUR | GMAC_IER_RLEX | GMAC_IER_TFC | GMAC_IER_HRESP)
0144 #define GMAC_INT_TX_BITS \
0145 (GMAC_INT_TX_ERR_BITS | GMAC_IER_TCOMP)
0146
0147 #define GMAC_INT_RX_STATUS_BITS \
0148 (GMAC_ISR_RCOMP | GMAC_ISR_RXUBR | GMAC_ISR_ROVR)
0149 #define GMAC_INT_TX_STATUS_ERR_BITS \
0150 (GMAC_ISR_TUR | GMAC_ISR_RLEX | GMAC_ISR_TFC | GMAC_ISR_HRESP)
0151
0152
0153 #define GMAC_RXDESC_ST_CKSUM_RESULT_NOT_CHECKED (0)
0154 #define GMAC_RXDESC_ST_CKSUM_RESULT_IP_CHECKED (1)
0155 #define GMAC_RXDESC_ST_CKSUM_RESULT_IP_AND_TCP_CHECKED (2)
0156 #define GMAC_RXDESC_ST_CKSUM_RESULT_IP_AND_UDP_CHECKED (3)
0157
0158
0159
0160
0161
0162
0163
0164
0165 typedef enum {
0166 GMAC_QUE_0 = 0,
0167 GMAC_QUE_1 = 1,
0168 GMAC_QUE_2 = 2
0169 } gmacQueList_t;
0170
0171
0172 typedef struct _GmacRxDescriptor {
0173 union _GmacRxAddr {
0174 uint32_t val;
0175 struct _GmacRxAddrBM {
0176 uint32_t bOwnership: 1,
0177
0178
0179 bWrap: 1,
0180 addrDW: 30;
0181 } bm;
0182 } addr;
0183 union _GmacRxStatus {
0184 uint32_t val;
0185 struct _GmacRxStatusBM {
0186 uint32_t len: 12,
0187 offset: 2,
0188
0189
0190 bSof: 1,
0191 bEof: 1,
0192 bCFI: 1,
0193 vlanPriority: 3,
0194 bPriorityDetected: 1,
0195 bVlanDetected: 1,
0196 typeIDMatchOrCksumResult: 2,
0197 bTypeIDMatchFoundOrCksumSNAPState: 1,
0198 specAddrMatchRegister: 2,
0199 bSpecAddrMatchFound: 1,
0200 reserved: 1,
0201 bUniHashMatch: 1,
0202 bMultiHashMatch: 1,
0203 bBroadcastDetected: 1;
0204
0205 } bm;
0206 } status;
0207 } sGmacRxDescriptor;
0208
0209
0210 typedef struct _GmacTxDescriptor {
0211 uint32_t addr;
0212 union _GmacTxStatus {
0213 uint32_t val;
0214 struct _GmacTxStatusBM {
0215 uint32_t len: 11,
0216 reserved: 4,
0217 bLastBuffer: 1,
0218 bNoCRC: 1,
0219 reserved1: 10,
0220 bExhausted: 1,
0221 bUnderrun: 1,
0222 bError: 1,
0223 bWrap: 1,
0224 bUsed: 1;
0225
0226 } bm;
0227 } status;
0228 } sGmacTxDescriptor;
0229
0230
0231
0232
0233
0234
0235 extern uint8_t GMAC_IsIdle(Gmac *pGmac);
0236 extern void GMAC_PHYMaintain(Gmac *pGmac,
0237 uint8_t bPhyAddr,
0238 uint8_t bRegAddr,
0239 uint8_t bRW,
0240 uint16_t wData);
0241 extern uint16_t GMAC_PHYData(Gmac *pGmac);
0242 extern void GMAC_ClearStatistics(Gmac *pGmac);
0243 extern void GMAC_IncreaseStatistics(Gmac *pGmac);
0244 extern void GMAC_StatisticsWriteEnable(Gmac *pGmac, uint8_t bEnaDis);
0245 extern uint8_t GMAC_SetMdcClock(Gmac *pGmac, uint32_t mck);
0246 extern void GMAC_EnableMdio(Gmac *pGmac);
0247 extern void GMAC_DisableMdio(Gmac *pGmac);
0248 extern void GMAC_EnableMII(Gmac *pGmac);
0249 extern void GMAC_EnableRMII(Gmac *pGmac);
0250 extern void GMAC_EnableGMII(Gmac *pGmac);
0251 extern void GMAC_SetLinkSpeed(Gmac *pGmac, uint8_t speed, uint8_t fullduplex);
0252 extern void GMAC_EnableIt(Gmac *pGmac, uint32_t dwSources,
0253 gmacQueList_t queueIdx);
0254 extern void GMAC_EnableAllQueueIt(Gmac *pGmac, uint32_t dwSources);
0255 extern void GMAC_DisableIt(Gmac *pGmac, uint32_t dwSources,
0256 gmacQueList_t queueIdx);
0257 extern void GMAC_DisableAllQueueIt(Gmac *pGmac, uint32_t dwSources);
0258 extern uint32_t GMAC_GetItStatus(Gmac *pGmac, gmacQueList_t queueIdx);
0259 extern uint32_t GMAC_GetItMask(Gmac *pGmac, gmacQueList_t queueIdx);
0260 extern uint32_t GMAC_GetTxStatus(Gmac *pGmac);
0261 extern void GMAC_ClearTxStatus(Gmac *pGmac, uint32_t dwStatus);
0262 extern uint32_t GMAC_GetRxStatus(Gmac *pGmac);
0263 extern void GMAC_ClearRxStatus(Gmac *pGmac, uint32_t dwStatus);
0264 extern void GMAC_ReceiveEnable(Gmac *pGmac, uint8_t bEnaDis);
0265 extern void GMAC_TransmitEnable(Gmac *pGmac, uint8_t bEnaDis);
0266 extern uint32_t GMAC_SetLocalLoopBack(Gmac *pGmac);
0267 extern void GMAC_SetRxQueue(Gmac *pGmac, uint32_t dwAddr,
0268 gmacQueList_t queueIdx);
0269 extern uint32_t GMAC_GetRxQueue(Gmac *pGmac, gmacQueList_t queueIdx);
0270 extern void GMAC_SetTxQueue(Gmac *pGmac, uint32_t dwAddr,
0271 gmacQueList_t queueIdx);
0272 extern uint32_t GMAC_GetTxQueue(Gmac *pGmac, gmacQueList_t queueIdx);
0273 extern void GMAC_NetworkControl(Gmac *pGmac, uint32_t bmNCR);
0274 extern uint32_t GMAC_GetNetworkControl(Gmac *pGmac);
0275 extern void GMAC_SetAddress(Gmac *pGmac, uint8_t bIndex, uint8_t *pMacAddr);
0276 extern void GMAC_SetAddress32(Gmac *pGmac, uint8_t bIndex, uint32_t dwMacT,
0277 uint32_t dwMacB);
0278 extern void GMAC_SetAddress64(Gmac *pGmac, uint8_t bIndex, uint64_t ddwMac);
0279 extern void GMAC_Configure(Gmac *pGmac, uint32_t dwCfg);
0280 extern void GMAC_SetDMAConfig(Gmac *pGmac, uint32_t dwDmaCfg,
0281 gmacQueList_t queueIdx);
0282 extern uint32_t GMAC_GetDMAConfig(Gmac *pGmac, gmacQueList_t queueIdx);
0283 extern uint32_t GMAC_GetConfigure(Gmac *pGmac);
0284 extern void GMAC_TransmissionStart(Gmac *pGmac);
0285 extern void GMAC_TransmissionHalt(Gmac *pGmac);
0286 extern void GMAC_EnableRGMII(Gmac *pGmac, uint32_t duplex, uint32_t speed);
0287
0288 void GMAC_ClearScreener1Reg (Gmac *pGmac, gmacQueList_t queueIdx);
0289
0290 void GMAC_WriteScreener1Reg(Gmac *pGmac, gmacQueList_t queueIdx,
0291 uint32_t regVal);
0292
0293 void GMAC_ClearScreener2Reg (Gmac *pGmac, gmacQueList_t queueIdx);
0294
0295 void GMAC_WriteScreener2Reg (Gmac *pGmac, gmacQueList_t queueIdx,
0296 uint32_t regVal);
0297
0298 void GMAC_WriteEthTypeReg (Gmac *pGmac, gmacQueList_t queueIdx,
0299 uint16_t etherType);
0300
0301 void GMAC_WriteCompareReg(Gmac *pGmac, gmacQueList_t queueIdx, uint32_t c0Reg,
0302 uint16_t c1Reg);
0303
0304 void GMAC_EnableCbsQueA(Gmac *pGmac);
0305
0306 void GMAC_DisableCbsQueA(Gmac *pGmac);
0307
0308 void GMAC_EnableCbsQueB(Gmac *pGmac);
0309
0310 void GMAC_DisableCbsQueB(Gmac *pGmac);
0311
0312 void GMAC_ConfigIdleSlopeA(Gmac *pGmac, uint32_t idleSlopeA);
0313
0314 void GMAC_ConfigIdleSlopeB(Gmac *pGmac, uint32_t idleSlopeB);
0315
0316 void GMAC_SetTsuTmrIncReg(Gmac *pGmac, uint32_t nanoSec);
0317
0318 uint16_t GMAC_GetPtpEvtMsgRxdMsbSec(Gmac *pGmac);
0319
0320 uint32_t GMAC_GetPtpEvtMsgRxdLsbSec(Gmac *pGmac);
0321
0322 uint32_t GMAC_GetPtpEvtMsgRxdNanoSec(Gmac *pGmac);
0323
0324 void GMAC_SetTsuCompare(Gmac *pGmac, uint32_t seconds47, uint32_t seconds31,
0325 uint32_t nanosec);
0326
0327 void GMAC_SetTsuCompareNanoSec(Gmac *pGmac, uint32_t nanosec);
0328
0329 void GMAC_SetTsuCompareSec31(Gmac *pGmac, uint32_t seconds31);
0330
0331 void GMAC_SetTsuCompareSec47(Gmac *pGmac, uint16_t seconds47);
0332
0333 uint32_t GMAC_GetRxEvtFrameSec(Gmac *pGmac);
0334
0335 uint32_t GMAC_GetRxEvtFrameNsec(Gmac *pGmac);
0336
0337 uint32_t GMAC_GetRxPeerEvtFrameSec(Gmac *pGmac);
0338
0339 uint32_t GMAC_GetRxPeerEvtFrameNsec(Gmac *pGmac);
0340
0341 uint32_t GMAC_GetTxEvtFrameSec(Gmac *pGmac);
0342
0343 uint32_t GMAC_GetTxEvtFrameNsec(Gmac *pGmac);
0344
0345 uint32_t GMAC_GetTxPeerEvtFrameSec(Gmac *pGmac);
0346
0347 uint32_t GMAC_GetTxPeerEvtFrameNsec(Gmac *pGmac);
0348
0349 #ifdef __cplusplus
0350 }
0351 #endif
0352
0353 #endif
0354