static int cs8900_open(struct eth_device *dev) { struct cs8900_priv *priv = (struct cs8900_priv *)dev->priv; cs8900_reset(priv); cs8900_reginit(priv); return 0; }
/* Send a data block via Ethernet. */ static int cs8900_send(struct eth_device *dev, volatile void *packet, int length) { volatile u16 *addr; int tmo; u16 s; struct cs8900_priv *priv = (struct cs8900_priv *)(dev->priv); retry: /* initiate a transmit sequence */ REG_WRITE(PP_TxCmd_TxStart_Full, &priv->regs->txcmd); REG_WRITE(length, &priv->regs->txlen); /* Test to see if the chip has allocated memory for the packet */ if ((get_reg(dev, PP_BusSTAT) & PP_BusSTAT_TxRDY) == 0) { /* Oops... this should not happen! */ debug("cs: unable to send packet; retrying...\n"); for (tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; get_timer(0) < tmo;) /*NOP*/; cs8900_reset(dev); cs8900_reginit(dev); goto retry; } /* Write the contents of the packet */ /* assume even number of bytes */ for (addr = packet; length > 0; length -= 2) REG_WRITE(*addr++, &priv->regs->rtdata); /* wait for transfer to succeed */ tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; while ((s = get_reg(dev, PP_TER) & ~0x1F) == 0) { if (get_timer(0) >= tmo) break; } /* nothing */ ; if((s & (PP_TER_CRS | PP_TER_TxOK)) != PP_TER_TxOK) { debug("\ntransmission error %#x\n", s); } return 0; }
static int cs8900_init(struct eth_device *dev, bd_t * bd) { uchar *enetaddr = dev->enetaddr; u16 id; /* verify chip id */ id = get_reg_init_bus(dev, PP_ChipID); if (id != 0x630e) { printf ("CS8900 Ethernet chip not found: " "ID=0x%04x instead 0x%04x\n", id, 0x630e); return 1; } cs8900_reset (dev); /* set the ethernet address */ put_reg(dev, PP_IA + 0, enetaddr[0] | (enetaddr[1] << 8)); put_reg(dev, PP_IA + 2, enetaddr[2] | (enetaddr[3] << 8)); put_reg(dev, PP_IA + 4, enetaddr[4] | (enetaddr[5] << 8)); cs8900_reginit(dev); return 0; }