| 274 | } |
| 275 | |
| 276 | static rt_err_t eth_init(rt_device_t device) |
| 277 | { |
| 278 | struct eth_device *eth_device = (struct eth_device *)device; |
| 279 | RT_ASSERT(eth_device != RT_NULL); |
| 280 | |
| 281 | s32 ijk; |
| 282 | s32 status = 0; |
| 283 | u64 dma_addr; |
| 284 | u32 Mac_changed = 0; |
| 285 | struct pbuf *pbuf; |
| 286 | u8 macaddr[6] = DEFAULT_MAC_ADDRESS; |
| 287 | struct rt_eth_dev *dev = ð_dev; |
| 288 | struct synopGMACNetworkAdapter *adapter = dev->priv; |
| 289 | synopGMACdevice *gmacdev = (synopGMACdevice *)adapter->synopGMACdev; |
| 290 | |
| 291 | synopGMAC_reset(gmacdev); |
| 292 | synopGMAC_attach(gmacdev, (regbase + MACBASE), (regbase + DMABASE), DEFAULT_PHY_BASE, macaddr); |
| 293 | |
| 294 | synopGMAC_read_version(gmacdev); |
| 295 | |
| 296 | synopGMAC_set_mdc_clk_div(gmacdev, GmiiCsrClk3); |
| 297 | gmacdev->ClockDivMdc = synopGMAC_get_mdc_clk_div(gmacdev); |
| 298 | |
| 299 | init_phy(adapter->synopGMACdev); |
| 300 | |
| 301 | DEBUG_MES("tx desc_queue\n"); |
| 302 | synopGMAC_setup_tx_desc_queue(gmacdev, TRANSMIT_DESC_SIZE, RINGMODE); |
| 303 | synopGMAC_init_tx_desc_base(gmacdev); |
| 304 | |
| 305 | DEBUG_MES("rx desc_queue\n"); |
| 306 | synopGMAC_setup_rx_desc_queue(gmacdev, RECEIVE_DESC_SIZE, RINGMODE); |
| 307 | synopGMAC_init_rx_desc_base(gmacdev); |
| 308 | DEBUG_MES("DmaRxBaseAddr = %08x\n", synopGMACReadReg(gmacdev->DmaBase, DmaRxBaseAddr)); |
| 309 | |
| 310 | // u32 dmaRx_Base_addr = synopGMACReadReg(gmacdev->DmaBase,DmaRxBaseAddr); |
| 311 | // rt_kprintf("first_desc_addr = 0x%x\n", dmaRx_Base_addr); |
| 312 | |
| 313 | #ifdef ENH_DESC_8W |
| 314 | synopGMAC_dma_bus_mode_init(gmacdev, DmaBurstLength32 | DmaDescriptorSkip2 | DmaDescriptor8Words); |
| 315 | #else |
| 316 | //synopGMAC_dma_bus_mode_init(gmacdev, DmaBurstLength4 | DmaDescriptorSkip1); |
| 317 | synopGMAC_dma_bus_mode_init(gmacdev, DmaBurstLength4 | DmaDescriptorSkip2); |
| 318 | #endif |
| 319 | synopGMAC_dma_control_init(gmacdev, DmaStoreAndForward | DmaTxSecondFrame | DmaRxThreshCtrl128); |
| 320 | |
| 321 | status = synopGMAC_check_phy_init(adapter); |
| 322 | synopGMAC_mac_init(gmacdev); |
| 323 | |
| 324 | synopGMAC_pause_control(gmacdev); |
| 325 | |
| 326 | #ifdef IPC_OFFLOAD |
| 327 | synopGMAC_enable_rx_chksum_offload(gmacdev); |
| 328 | synopGMAC_rx_tcpip_chksum_drop_enable(gmacdev); |
| 329 | #endif |
| 330 | |
| 331 | u32 skb; |
| 332 | do |
| 333 | { |
nothing calls this directly
no test coverage detected