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; }
static int __INIT__ cs89x0_init(void) { int ret; __u16 ven_id, dev_id, val, line_st; struct net_device *ndev; ven_id = cs8900_inw(0x00); dev_id = cs8900_inw(0x02); printf("CS8900: vendor = 0x%04x, device = 0x%04x\n", ven_id, dev_id); ret = cs8900_reset(); if (ret < 0) { printf("CS8900 reset failed!\n"); return ret; } ndev = ndev_new(0); // if NULL ndev->chip_name = "CS8900A"; ndev->phy_mask = 0; ndev->send_packet = cs89x0_send_packet; ndev->set_mac_addr = cs89x0_set_mac; #ifndef CONFIG_IRQ_SUPPORT ndev->ndev_poll = cs89x0_poll; #endif irq_register_isr(CONFIG_CS8900_IRQ, cs89x0_isr, ndev); ret = ndev_register(ndev); cs8900_outw(PP_RxCTL, 0x3FC5); cs8900_outw(PP_LineCTL, 0xD3); val = cs8900_inw(PP_BusCTL); val |= 1 << 15; cs8900_outw(PP_BusCTL, val); val = cs8900_inw(PP_RxCFG); val |= 0x7100; cs8900_outw(PP_RxCFG, val); cs8900_outw(PP_INTN, 0x0); while (1) { line_st = cs8900_inw(PP_LineST); printf("line line_st = 0x%04x\n", line_st); if (line_st & 0x80) break; } return ret; }
/* 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; }
void cs8900_get_enetaddr(struct eth_device *dev) { int i; /* verify chip id */ if (get_reg_init_bus(dev, PP_ChipID) != 0x630e) return; cs8900_reset(dev); if ((get_reg(dev, PP_SelfSTAT) & (PP_SelfSTAT_EEPROM | PP_SelfSTAT_EEPROM_OK)) == (PP_SelfSTAT_EEPROM | PP_SelfSTAT_EEPROM_OK)) { /* Load the MAC from EEPROM */ for (i = 0; i < 3; i++) { u32 Addr; Addr = get_reg(dev, PP_IA + i * 2); dev->enetaddr[i * 2] = Addr & 0xFF; dev->enetaddr[i * 2 + 1] = Addr >> 8; } } }
void tfe_reset(void) { if (tfe_enabled && !should_activate) { cs8900_reset(); } }
void cs8900io_reset(void) { if (cs8900io_enabled && !should_activate) { cs8900_reset(); } }