void init_emacps(xemacpsif_s *xemacps, struct netif *netif) { unsigned mac_address = (unsigned)(netif->state); XEmacPs *xemacpsp; XEmacPs_Config *mac_config; int Status = XST_SUCCESS; /* obtain config of this emac */ mac_config = (XEmacPs_Config *)xemacps_lookup_config(mac_address); xemacpsp = &xemacps->emacps; /* set mac address */ Status = XEmacPs_SetMacAddress(xemacpsp, (void*)(netif->hwaddr), 1); if (Status != XST_SUCCESS) { xil_printf("In %s:Emac Mac Address set failed...\r\n",__func__); } XEmacPs_SetMdioDivisor(xemacpsp, MDC_DIV_224); link_speed = Phy_Setup(xemacpsp); XEmacPs_SetOperatingSpeed(xemacpsp, link_speed); /* Setting the operating speed of the MAC needs a delay. */ { volatile int wait; for (wait=0; wait < 20000; wait++); } }
void init_emacps(xemacpsif_s *xemacps, struct netif *netif) { int rdy; unsigned mac_address = (unsigned)(netif->state); unsigned link_speed = 1000; unsigned options; unsigned lock_message_printed = 0; XEmacPs *xemacpsp; XEmacPs_Config *mac_config; int Status = XST_SUCCESS; /* obtain config of this emac */ mac_config = lookup_config(mac_address); xemacpsp = &xemacps->emacps; #if 0 options = XEmacPs_GetOptions(xemacpsp); options |= XEMACPS_FLOW_CONTROL_OPTION; options |= XEMACPS_TRANSMITTER_ENABLE_OPTION; options |= XEMACPS_RECEIVER_ENABLE_OPTION; options |= XEMACPS_FCS_STRIP_OPTION; options |= XEMACPS_BROADCAST_OPTION; options |= XEMACPS_FCS_INSERT_OPTION; options |= XEMACPS_RX_CHKSUM_ENABLE_OPTION; options |= XEMACPS_TX_CHKSUM_ENABLE_OPTION; options |= XEMACPS_LENTYPE_ERR_OPTION; XEmacPs_SetOptions(xemacpsp, options); XEmacPs_ClearOptions(xemacpsp, ~options); #endif /* set mac address */ Status = XEmacPs_SetMacAddress(xemacpsp, (void*)(netif->hwaddr), 1); if (Status != XST_SUCCESS) { xil_printf("In %s:Emac Mac Address set failed...\r\n",__func__); } link_speed = Phy_Setup(xemacpsp); XEmacPs_SetOperatingSpeed(xemacpsp, link_speed); /* Setting the operating speed of the MAC needs a delay. */ { volatile int wait; for (wait=0; wait < 20000; wait++); } Status = XEmacPs_SetOptions(xemacpsp, XEMACPS_PROMISC_OPTION); if (Status != XST_SUCCESS) { xil_printf("In %s:Setting up of promiscuous mode failed...\r\n",__func__); } }
void init_lltemac(xlltemacif_s *xlltemacif, struct netif *netif) { int rdy; unsigned mac_address = (unsigned)(netif->state); unsigned link_speed = 1000; unsigned options; unsigned lock_message_printed = 0; /* obtain config of this emac */ XLlTemac_Config *mac_config = lookup_config(mac_address); XLlTemac *xlltemacp = &xlltemacif->lltemac; XLlTemac_CfgInitialize(xlltemacp, mac_config, mac_config->BaseAddress); options = XLlTemac_GetOptions(xlltemacp); options |= XTE_FLOW_CONTROL_OPTION; options |= XTE_JUMBO_OPTION; options |= XTE_TRANSMITTER_ENABLE_OPTION; options |= XTE_RECEIVER_ENABLE_OPTION; options |= XTE_FCS_STRIP_OPTION; options |= XTE_MULTICAST_OPTION; XLlTemac_SetOptions(xlltemacp, options); XLlTemac_ClearOptions(xlltemacp, ~options); /* set mac address */ XLlTemac_SetMacAddress(xlltemacp, (Xuint8*)(netif->hwaddr)); /* make sure the hard TEMAC is ready */ rdy = XLlTemac_ReadReg(xlltemacp->Config.BaseAddress, XTE_RDY_OFFSET); while ((rdy & XTE_RDY_HARD_ACS_RDY_MASK) == 0) { rdy = XLlTemac_ReadReg(xlltemacp->Config.BaseAddress, XTE_RDY_OFFSET); } link_speed = Phy_Setup(xlltemacp); XLlTemac_SetOperatingSpeed(xlltemacp, 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++); } /* 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 (!(XLlTemac_ReadReg(xlltemacp->Config.BaseAddress, XTE_IS_OFFSET) & XTE_INT_RXDCM_LOCK_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"); /* start the temac */ XLlTemac_Start(xlltemacp); /* enable TEMAC interrupts */ XLlTemac_IntEnable(xlltemacp, XTE_INT_RECV_ERROR_MASK); }
void init_axiemac(xaxiemacif_s *xaxiemac, struct netif *netif) { unsigned mac_address = (unsigned)(netif->state); unsigned link_speed = 1000; unsigned options; XAxiEthernet *xaxiemacp; XAxiEthernet_Config *mac_config; /* obtain config of this emac */ mac_config = xaxiemac_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 USE_JUMBO_FRAMES 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, (unsigned char*)(netif->hwaddr)); link_speed = Phy_Setup(xaxiemacp); 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); }