MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / FGmac_InitializeHw

Function FGmac_InitializeHw

bsp/ft2004/libraries/bsp/ft_gmac/ft_gmac_hw.c:279–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279s32 FGmac_InitializeHw(FGmac_Config_t *Config)
280{
281 u32 Wait_Counter = 0;
282 u32 RegValue;
283 s32 ret = FST_SUCCESS;
284
285 /*Gmac Software reset */
286 Ft_out32(Config->BaseAddress + DMA_BUS_MODE_OFFSET, DMA_BUS_SWR);
287
288 while ((Ft_in32(Config->BaseAddress + DMA_BUS_MODE_OFFSET) & DMA_BUS_SWR) == DMA_BUS_SWR)
289 {
290 if (++Wait_Counter > 30)
291 {
292 GMAC_HW_DEBUG_E("DMA_BUS_MODE_OFFSET wait is too long ,Addr %x \r\n", Config->BaseAddress);
293 return FST_ERROR_COUNT_MAX;
294 }
295 Ft_GenericTimer_UsDelay(PHY_CONFIG_DELAY_US);
296 }
297 Wait_Counter = 0;
298 Ft_out32(Config->BaseAddress + DMA_BUS_MODE_OFFSET, DMA_BUS_INIT);
299
300 Ft_out32(Config->BaseAddress + DMA_OP_OFFSET, Ft_in32(Config->BaseAddress + DMA_OP_OFFSET) | DMA_OP_FTF);
301
302 while ((Ft_in32(Config->BaseAddress + DMA_OP_OFFSET) & DMA_OP_FTF) == DMA_OP_FTF)
303 {
304 if (++Wait_Counter > 30)
305 {
306 GMAC_HW_DEBUG_E("DMA_OP_OFFSET wait is too long \r\n");
307 return FST_ERROR_COUNT_MAX;
308 }
309 Ft_GenericTimer_UsDelay(PHY_CONFIG_DELAY_US);
310 }
311
312 Wait_Counter = 0;
313
314 /* GMAC Init */
315 Ft_out32(Config->BaseAddress + GMAC_CONTROL_OFFSET, GMAC_CONTROL_INIT);
316 /* disable flow control */
317 Ft_out32(Config->BaseAddress + GMAC_FLOW_CTRL_OFFSET, 0);
318
319 Ft_out32(Config->BaseAddress + DMA_STATUS_OFFSET, DMA_STATUS_INIT);
320
321 Ft_out32(Config->BaseAddress + DMA_INTR_ENA_OFFSET, 0);
322
323 /* get Phy addr */
324 Ft_assertNonvoid(FGmac_PhyAddrGet(Config) == FST_SUCCESS);
325
326 /*-------------------------------- MAC Initialization ----------------------*/
327 /*-------------------- PHY initialization and configuration ----------------*/
328 /* Put the PHY in reset mode */
329 if (Gmac_WritePHYRegister(Config, PHY_BCR_OFFSET, PHY_RESET) != FST_SUCCESS)
330 {
331 GMAC_HW_DEBUG_E("PHY_BCR_OFFSET is error \r\n");
332 return FST_FAILURE;
333 }
334
335 do
336 {

Callers 1

Ft_Gmac_HwInitializeFunction · 0.85

Calls 7

Ft_out32Function · 0.85
Ft_in32Function · 0.85
Ft_GenericTimer_UsDelayFunction · 0.85
FGmac_PhyAddrGetFunction · 0.85
Gmac_WritePHYRegisterFunction · 0.85
FGmac_ReadPHYRegisterFunction · 0.85
FGmac_MACDMAInitFunction · 0.85

Tested by

no test coverage detected