| 277 | } |
| 278 | |
| 279 | s32 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 | { |
no test coverage detected