-static int fec_send(struct eth_device *dev, void *packet, int length)
-{
- struct fec_info_s *info = dev->priv;
- volatile fec_t *fecp = (fec_t *) (info->iobase);
- int j, rc;
- u16 phyStatus;
-
- miiphy_read(dev->name, info->phy_addr, MII_BMSR, &phyStatus);
-
- /* section 16.9.23.3
- * Wait for ready
- */
- j = 0;
- while ((info->txbd[info->txIdx].cbd_sc & BD_ENET_TX_READY) &&
- (j < MCFFEC_TOUT_LOOP)) {
- udelay(1);
- j++;
- }
- if (j >= MCFFEC_TOUT_LOOP) {
- printf("TX not ready\n");
- }
-
- info->txbd[info->txIdx].cbd_bufaddr = (uint) packet;
- info->txbd[info->txIdx].cbd_datlen = length;
- info->txbd[info->txIdx].cbd_sc |= BD_ENET_TX_RDY_LST;
-
- /* Activate transmit Buffer Descriptor polling */
- fecp->tdar = 0x01000000; /* Descriptor polling active */
-
-#ifndef CONFIG_SYS_FEC_BUF_USE_SRAM
- /*
- * FEC unable to initial transmit data packet.
- * A nop will ensure the descriptor polling active completed.
- * CF Internal RAM has shorter cycle access than DRAM. If use
- * DRAM as Buffer descriptor and data, a nop is a must.
- * Affect only V2 and V3.
- */
- __asm__ ("nop");
-
-#endif
-
-#ifdef CONFIG_SYS_UNIFY_CACHE
- icache_invalid();
-#endif
-
- j = 0;
- while ((info->txbd[info->txIdx].cbd_sc & BD_ENET_TX_READY) &&
- (j < MCFFEC_TOUT_LOOP)) {
- udelay(1);
- j++;
- }
- if (j >= MCFFEC_TOUT_LOOP) {
- printf("TX timeout\n");
- }
-
-#ifdef ET_DEBUG
- printf("%s[%d] %s: cycles: %d status: %x retry cnt: %d\n",
- __FILE__, __LINE__, __FUNCTION__, j,
- info->txbd[info->txIdx].cbd_sc,
- (info->txbd[info->txIdx].cbd_sc & 0x003C) >> 2);
-#endif
-
- /* return only status bits */
- rc = (info->txbd[info->txIdx].cbd_sc & BD_ENET_TX_STATS);
- info->txIdx = (info->txIdx + 1) % TX_BUF_CNT;
-
- return rc;
-}
-
-int fec_recv(struct eth_device *dev)
-{
- struct fec_info_s *info = dev->priv;
- volatile fec_t *fecp = (fec_t *) (info->iobase);
- int length;
-
- for (;;) {
-#ifndef CONFIG_SYS_FEC_BUF_USE_SRAM
-#endif
-#ifdef CONFIG_SYS_UNIFY_CACHE
- icache_invalid();
-#endif
- /* section 16.9.23.2 */
- if (info->rxbd[info->rxIdx].cbd_sc & BD_ENET_RX_EMPTY) {
- length = -1;
- break; /* nothing received - leave for() loop */
- }
-
- length = info->rxbd[info->rxIdx].cbd_datlen;
-
- if (info->rxbd[info->rxIdx].cbd_sc & 0x003f) {
- printf("%s[%d] err: %x\n",
- __FUNCTION__, __LINE__,
- info->rxbd[info->rxIdx].cbd_sc);
-#ifdef ET_DEBUG
- printf("%s[%d] err: %x\n",
- __FUNCTION__, __LINE__,
- info->rxbd[info->rxIdx].cbd_sc);
-#endif
- } else {
-
- length -= 4;
- /* Pass the packet up to the protocol layers. */
- net_process_received_packet(net_rx_packets[info->rxIdx],
- length);
-
- fecp->eir |= FEC_EIR_RXF;
- }
-
- /* Give the buffer back to the FEC. */
- info->rxbd[info->rxIdx].cbd_datlen = 0;
-
- /* wrap around buffer index when necessary */
- if (info->rxIdx == LAST_PKTBUFSRX) {
- info->rxbd[PKTBUFSRX - 1].cbd_sc = BD_ENET_RX_W_E;
- info->rxIdx = 0;
- } else {
- info->rxbd[info->rxIdx].cbd_sc = BD_ENET_RX_EMPTY;
- info->rxIdx++;
- }
-
- /* Try to fill Buffer Descriptors */
- fecp->rdar = 0x01000000; /* Descriptor polling active */
- }
-
- return length;
-}
-