int wlan_eth_init() { int status; ETH_A_NUM_RX_BD = min(queue_total_size()/2,200); xil_printf("Setting up %d DMA BDs\n", ETH_A_NUM_RX_BD); //The TEMAC driver is only used during init - all packet interactions are handed via the DMA driver XAxiEthernet_Config *ETH_A_MAC_CFG_ptr; XAxiEthernet ETH_A_MAC_Instance; ETH_A_MAC_CFG_ptr = XAxiEthernet_LookupConfig(ETH_A_MAC_DEVICE_ID); status = XAxiEthernet_CfgInitialize(Ð_A_MAC_Instance, ETH_A_MAC_CFG_ptr, ETH_A_MAC_CFG_ptr->BaseAddress); if (status != XST_SUCCESS) {xil_printf("Error in XAxiEthernet_CfgInitialize! Err = %d\n", status); return -1;}; //Setup the TEMAC options status = XAxiEthernet_ClearOptions(Ð_A_MAC_Instance, XAE_LENTYPE_ERR_OPTION | XAE_FLOW_CONTROL_OPTION | XAE_JUMBO_OPTION); status |= XAxiEthernet_SetOptions(Ð_A_MAC_Instance, XAE_FCS_STRIP_OPTION | XAE_PROMISC_OPTION | XAE_MULTICAST_OPTION | XAE_BROADCAST_OPTION | XAE_FCS_INSERT_OPTION); status |= XAxiEthernet_SetOptions(Ð_A_MAC_Instance, XAE_RECEIVER_ENABLE_OPTION | XAE_TRANSMITTER_ENABLE_OPTION); if (status != XST_SUCCESS) {xil_printf("Error in XAxiEthernet_Set/ClearOptions! Err = %d\n", status); return -1;}; XAxiEthernet_SetOperatingSpeed(Ð_A_MAC_Instance, ETH_A_LINK_SPEED); //Initialize the axi_dma attached to the TEMAC status = wlan_eth_dma_init(); XAxiEthernet_Start(Ð_A_MAC_Instance); return 0; }
void init_axiemac(xaxiemacif_s *xaxiemac, struct netif *netif) { int rdy; unsigned mac_address = (unsigned)(netif->state); unsigned link_speed = 1000; unsigned options; unsigned lock_message_printed = 0; XAxiEthernet *xaxiemacp; XAxiEthernet_Config *mac_config; /* obtain config of this emac */ mac_config = lookup_config(mac_address); xaxiemacp = &xaxiemac->axi_ethernet; XAxiEthernet_CfgInitialize(xaxiemacp, mac_config, mac_config->BaseAddress); options = XAxiEthernet_GetOptions(xaxiemacp); options |= XAE_FLOW_CONTROL_OPTION; #ifdef XLLTEMACIF_USE_JUMBO_FRAMES_EXPERIMENTAL options |= XAE_JUMBO_OPTION; #endif options |= XAE_TRANSMITTER_ENABLE_OPTION; options |= XAE_RECEIVER_ENABLE_OPTION; options |= XAE_FCS_STRIP_OPTION; options |= XAE_MULTICAST_OPTION; XAxiEthernet_SetOptions(xaxiemacp, options); XAxiEthernet_ClearOptions(xaxiemacp, ~options); /* set mac address */ XAxiEthernet_SetMacAddress(xaxiemacp, (Xuint8*)(netif->hwaddr)); /* set PHY <--> MAC data clock */ #ifdef CONFIG_LINKSPEED_AUTODETECT link_speed = get_IEEE_phy_speed(xaxiemacp); xil_printf("auto-negotiated link speed: %d\r\n", link_speed); #elif defined(CONFIG_LINKSPEED1000) link_speed = 1000; #elif defined(CONFIG_LINKSPEED100) link_speed = 100; #elif defined(CONFIG_LINKSPEED10) link_speed = 10; #endif XAxiEthernet_SetOperatingSpeed(xaxiemacp, link_speed); /* Setting the operating speed of the MAC needs a delay. */ { volatile int wait; for (wait=0; wait < 100000; wait++); for (wait=0; wait < 100000; wait++); } #ifdef NOTNOW /* in a soft temac implementation, we need to explicitly make sure that * the RX DCM has been locked. See xps_ll_temac manual for details. * This bit is guaranteed to be 1 for hard temac's */ lock_message_printed = 0; while (!(XAxiEthernet_ReadReg(xaxiemacp->Config.BaseAddress, XAE_IS_OFFSET) & XAE_INT_RXDCMLOCK_MASK)) { int first = 1; if (first) { print("Waiting for RX DCM to lock.."); first = 0; lock_message_printed = 1; } } if (lock_message_printed) print("RX DCM locked.\r\n"); #endif /* start the temac */ XAxiEthernet_Start(xaxiemacp); /* enable MAC interrupts */ XAxiEthernet_IntEnable(xaxiemacp, XAE_INT_RECV_ERROR_MASK); }