diff --git a/src/etherboot/sis900.c b/src/etherboot/sis900.c index f7823c9692..178146158e 100644 --- a/src/etherboot/sis900.c +++ b/src/etherboot/sis900.c @@ -28,11 +28,11 @@ /* 01 March 2001 mdc 1.0 - Initial Release. Tested with PCI based sis900 card and ThinkNIC - computer. + Initial Release. Tested with PCI based sis900 card and ThinkNIC + computer. 20 March 2001 P.Koegel - added support for sis630e and PHY ICS1893 and RTL8201 - Testet with SIS730S chipset + ICS1893 + added support for sis630e and PHY ICS1893 and RTL8201 + Testet with SIS730S chipset + ICS1893 */ @@ -40,11 +40,12 @@ #include #include +#include +#include + #include "etherboot.h" #include "nic.h" -#include "pci.h" #include "cards.h" - #include "sis900.h" /* Globals */ @@ -70,15 +71,15 @@ static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE]; #endif static struct mac_chip_info { - const char *name; - u16 vendor_id, device_id, flags; - int io_size; + const char *name; + u16 vendor_id, device_id, flags; + int io_size; } mac_chip_table[] = { - { "SiS 900 PCI Fast Ethernet", PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900, - PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE}, - { "SiS 7016 PCI Fast Ethernet",PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016, - PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE}, - {0,0,0,0,0} /* 0 terminated list. */ + { "SiS 900 PCI Fast Ethernet", PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_900, + PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE}, + { "SiS 7016 PCI Fast Ethernet",PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7016, + PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE}, + {0,0,0,0,0} /* 0 terminated list. */ }; static void sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex); @@ -87,38 +88,31 @@ static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *du static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex); static struct mii_chip_info { - const char * name; - u16 phy_id0; - u16 phy_id1; - void (*read_mode) (struct nic *nic, int phy_addr, int *speed, int *duplex); + const char * name; + u16 phy_id0; + u16 phy_id1; + void (*read_mode) (struct nic *nic, int phy_addr, int *speed, int *duplex); } mii_chip_table[] = { - {"SiS 900 Internal MII PHY", 0x001d, 0x8000, sis900_read_mode}, - {"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode}, - {"AMD 79C901 10BASE-T PHY", 0x0000, 0x35b9, amd79c901_read_mode}, - {"AMD 79C901 HomePNA PHY", 0x0000, 0x35c8, amd79c901_read_mode}, - {"ICS 1893 Integrated PHYceiver" , 0x0015, 0xf441,ics1893_read_mode}, - {"RTL 8201 10/100Mbps Phyceiver" , 0x0000, 0x8201,rtl8201_read_mode}, - {0,0,0,0} + {"SiS 900 Internal MII PHY", 0x001d, 0x8000, sis900_read_mode}, + {"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode}, + {"AMD 79C901 10BASE-T PHY", 0x0000, 0x35b9, amd79c901_read_mode}, + {"AMD 79C901 HomePNA PHY", 0x0000, 0x35c8, amd79c901_read_mode}, + {"ICS 1893 Integrated PHYceiver" , 0x0015, 0xf441,ics1893_read_mode}, + {"RTL 8201 10/100Mbps Phyceiver" , 0x0000, 0x8201,rtl8201_read_mode}, + {0,0,0,0} }; static struct mii_phy { - struct mii_phy * next; - struct mii_chip_info * chip_info; - int phy_addr; - u16 status; + struct mii_phy * next; + struct mii_chip_info * chip_info; + int phy_addr; + u16 status; } mii; -// PCI to ISA bridge for SIS640E access -static struct pci_device pci_isa_bridge_list[] = { - { 0x1039, 0x0008, - "SIS 85C503/5513 PCI to ISA bridge", 0, 0, 0, 0}, - {0, 0, NULL, 0, 0, 0, 0} -}; - /* Function Prototypes */ -struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci); +struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_dev *pci); static u16 sis900_read_eeprom(int location); static void sis900_mdio_reset(long mdio_addr); @@ -151,21 +145,21 @@ static void sis900_disable(struct nic *nic); * MAC address is read from read_eeprom() into @net_dev->dev_addr. */ -static int sis900_get_mac_addr(struct pci_device * pci_dev , struct nic *nic) +static int sis900_get_mac_addr(struct pci_dev * pci_dev , struct nic *nic) { u16 signature; int i; /* check to see if we have sane EEPROM */ - signature = (u16) sis900_read_eeprom( EEPROMSignature); + signature = (u16) sis900_read_eeprom(EEPROMSignature); if (signature == 0xffff || signature == 0x0000) { - printk_info ("sis900_probe: Error EERPOM read %x\n", signature); + printk_err ("sis900_probe: Error EERPOM read %x\n", signature); return 0; } /* get MAC address from EEPROM */ for (i = 0; i < 3; i++) - ((u16 *)(nic->node_addr))[i] = sis900_read_eeprom(i+EEPROMMACAddr); + ((u16 *)(nic->node_addr))[i] = sis900_read_eeprom(i+EEPROMMACAddr); return 1; } @@ -178,63 +172,33 @@ static int sis900_get_mac_addr(struct pci_device * pci_dev , struct nic *nic) * APC CMOS RAM is accessed through ISA bridge. * MAC address is read into @net_dev->dev_addr. */ - -#if 0 -static int sis630e_get_mac_addr(struct pci_device * pci_dev, struct nic *nic) +static int sis630e_get_mac_addr(struct pci_dev * pci_dev, struct nic *nic) { u8 reg; int i; - struct pci_device *p; + struct pci_dev *isa_bridge = NULL; // find PCI to ISA bridge - eth_pci_init(pci_isa_bridge_list); + isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5513, + (void *) NULL); + if (isa_bridge == NULL) { + printk_err("%s:%s Can not find ISA bridge\n", __FILE__, __LINE__); + return 0; + } - /* the firts entry in this list should contain bus/devfn */ - p = pci_isa_bridge_list; + pci_read_config_byte(isa_bridge, 0x48, ®); + pci_write_config_byte(isa_bridge, 0x48, reg | 0x40); - pcibios_read_config_byte(p->bus,p->devfn, 0x48, ®); - pcibios_write_config_byte(p->bus,p->devfn, 0x48, reg | 0x40); - - for (i = 0; i < 6; i++) - { + for (i = 0; i < 6; i++) { outb(0x09 + i, 0x70); ((u8 *)(nic->node_addr))[i] = inb(0x71); } - pcibios_write_config_byte(p->bus,p->devfn, 0x48, reg & ~0x40); + + pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40); return 1; } -#else - -static int sis630e_get_mac_addr(struct pci_device * pci_dev, struct nic *nic) -{ - u8 reg; - int i; - struct pci_device *p; - - // find PCI to ISA bridge -// eth_pci_init(pci_isa_bridge_list); - - /* the firts entry in this list should contain bus/devfn */ - // p = pci_isa_bridge_list; - - outl(0x80000848, 0xcf8); - outb(0x50,0x0cfc); -// pcibios_read_config_byte(p->bus,p->devfn, 0x48, ®); -// pcibios_write_config_byte(p->bus,p->devfn, 0x48, reg | 0x40); - - for (i = 0; i < 6; i++) - { - outb(0x09 + i, 0x70); - ((u8 *)(nic->node_addr))[i] = inb(0x71); - } -// pcibios_write_config_byte(p->bus,p->devfn, 0x48, reg & ~0x40); - - return 1; -} - -#endif /* * Function: sis900_probe @@ -250,106 +214,105 @@ static int sis630e_get_mac_addr(struct pci_device * pci_dev, struct nic *nic) * Returns: struct nic *: pointer to NIC data structure */ -struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci) +struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_dev *pci) { - int i; - int found=0; - int phy_addr; - u16 signature; - u8 revision; - int ret; + int i; + int found=0; + int phy_addr; + u8 revision; + int ret; - if (io_addrs == 0 || *io_addrs == 0) - return NULL; + if (io_addrs == 0 || *io_addrs == 0) + return NULL; - ioaddr = *io_addrs & ~3; - vendor = pci->vendor; - dev_id = pci->dev_id; + ioaddr = *io_addrs & ~3; + vendor = pci->vendor; + dev_id = pci->device; - /* wakeup chip */ - pcibios_write_config_dword(pci->bus, pci->devfn, 0x40, 0x00000000); + /* wakeup chip */ + pci_write_config_dword(pci, 0x40, 0x00000000); - /* get MAC address */ - ret = 0; - pcibios_read_config_byte(pci->bus,pci->devfn, PCI_REVISION, &revision); - ret = sis630e_get_mac_addr(pci, nic); + /* enable Bus Master DMA */ + pci_write_config_byte(pci, 0x04, 0x07); -#if 0 - if (revision == SIS630E_900_REV || revision == SIS630EA1_900_REV) - ret = sis630e_get_mac_addr(pci, nic); - else if (revision == SIS630S_900_REV) - ret = sis630e_get_mac_addr(pci, nic); - else - ret = sis900_get_mac_addr(pci, nic); -#endif + /* get MAC address */ + ret = 0; + pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - if (ret == 0) - { - printk_info ("sis900_probe: Error MAC address not found\n"); - return NULL; - } + if (revision == SIS630E_900_REV || revision == SIS630EA1_900_REV) + ret = sis630e_get_mac_addr(pci, nic); + else if (revision == SIS630S_900_REV) + ret = sis630e_get_mac_addr(pci, nic); + else + ret = sis900_get_mac_addr(pci, nic); - printk_info("\nsis900_probe: MAC addr %02x:%02x:%02x:%02x:%02x:%02x at ioaddr %04x\n", - nic->node_addr[0],nic->node_addr[1],nic->node_addr[2], - nic->node_addr[3],nic->node_addr[4],nic->node_addr[5], - ioaddr); - printk_info("sis900_probe: Vendor:%04x Device:%04x\n", vendor, dev_id); + if (ret == 0) { + printk_err("sis900_probe: Error MAC address not found\n"); + return NULL; + } - /* probe for mii transceiver */ - /* search for total of 32 possible mii phy addresses */ + printk_info("\nsis900_probe: MAC addr %02x:%02x:%02x:%02x:%02x:%02x at ioaddr %04x\n", + nic->node_addr[0], nic->node_addr[1], nic->node_addr[2], + nic->node_addr[3], nic->node_addr[4], nic->node_addr[5], + ioaddr); + printk_info("sis900_probe: Vendor:%04x Device:%04x\n", vendor, dev_id); - found = 0; - for (phy_addr = 0; phy_addr < 32; phy_addr++) { - u16 mii_status; - u16 phy_id0, phy_id1; + /* probe for mii transceiver */ + /* search for total of 32 possible mii phy addresses */ + + found = 0; + for (phy_addr = 0; phy_addr < 32; phy_addr++) { + u16 mii_status; + u16 phy_id0, phy_id1; - mii_status = sis900_mdio_read(phy_addr, MII_STATUS); - if (mii_status == 0xffff || mii_status == 0x0000) - /* the mii is not accessable, try next one */ - continue; + mii_status = sis900_mdio_read(phy_addr, MII_STATUS); + if (mii_status == 0xffff || mii_status == 0x0000) + /* the mii is not accessable, try next one */ + continue; - phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0); - phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1); + phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0); + phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1); - /* search our mii table for the current mii */ - for (i = 0; mii_chip_table[i].phy_id1; i++) { + /* search our mii table for the current mii */ + for (i = 0; mii_chip_table[i].phy_id1; i++) { - if (phy_id0 == mii_chip_table[i].phy_id0) { + if (phy_id0 == mii_chip_table[i].phy_id0) { - printk_info("sis900_probe: %s transceiver found at address %d.\n", - mii_chip_table[i].name, phy_addr); + printk_info("sis900_probe: %s transceiver found at address %d.\n", + mii_chip_table[i].name, phy_addr); - mii.chip_info = &mii_chip_table[i]; - mii.phy_addr = phy_addr; - mii.status = sis900_mdio_read(phy_addr, MII_STATUS); - mii.next = NULL; + mii.chip_info = &mii_chip_table[i]; + mii.phy_addr = phy_addr; + mii.status = sis900_mdio_read(phy_addr, MII_STATUS); + mii.next = NULL; - found=1; - break; - } else { - printk_info("Found an MII, but can't recognize it. id= %u:%u\n", phy_id0, phy_id1); - } - } - } - - if (found == 0) { - printk_info("sis900_probe: No MII transceivers found!\n"); - return NULL; - } + found = 1; + break; + } else { + printk_info("Found an MII, but can't recognize it. id= %u:%u\n", + phy_id0, phy_id1); + } + } + } - /* Arbitrarily select the last PHY found as current PHY */ - cur_phy = mii.phy_addr; - printk_info("sis900_probe: Using %s as default\n", mii.chip_info->name); + if (found == 0) { + printk_info("sis900_probe: No MII transceivers found!\n"); + return NULL; + } - /* initialize device */ - sis900_init(nic); + /* Arbitrarily select the last PHY found as current PHY */ + cur_phy = mii.phy_addr; + printk_info("sis900_probe: Using %s as default\n", mii.chip_info->name); - nic->reset = sis900_init; - nic->poll = sis900_poll; - nic->transmit = sis900_transmit; - nic->disable = sis900_disable; + /* initialize device */ + sis900_init(nic); - return nic; + nic->reset = sis900_init; + nic->poll = sis900_poll; + nic->transmit = sis900_transmit; + nic->disable = sis900_disable; + + return nic; } @@ -377,43 +340,43 @@ struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_d in word (16 bits) unit */ static u16 sis900_read_eeprom(int location) { - int i; - u16 retval = 0; - long ee_addr = ioaddr + mear; - u32 read_cmd = location | EEread; + int i; + u16 retval = 0; + long ee_addr = ioaddr + mear; + u32 read_cmd = location | EEread; - outl(0, ee_addr); - eeprom_delay(); - outl(EECLK, ee_addr); - eeprom_delay(); + outl(0, ee_addr); + eeprom_delay(); + outl(EECLK, ee_addr); + eeprom_delay(); - /* Shift the read command (9) bits out. */ - for (i = 8; i >= 0; i--) { - u32 dataval = (read_cmd & (1 << i)) ? EEDI | EECS : EECS; - outl(dataval, ee_addr); - eeprom_delay(); - outl(dataval | EECLK, ee_addr); - eeprom_delay(); - } - outb(EECS, ee_addr); - eeprom_delay(); + /* Shift the read command (9) bits out. */ + for (i = 8; i >= 0; i--) { + u32 dataval = (read_cmd & (1 << i)) ? EEDI | EECS : EECS; + outl(dataval, ee_addr); + eeprom_delay(); + outl(dataval | EECLK, ee_addr); + eeprom_delay(); + } + outb(EECS, ee_addr); + eeprom_delay(); - /* read the 16-bits data in */ - for (i = 16; i > 0; i--) { - outl(EECS, ee_addr); - eeprom_delay(); - outl(EECS | EECLK, ee_addr); - eeprom_delay(); - retval = (retval << 1) | ((inl(ee_addr) & EEDO) ? 1 : 0); - eeprom_delay(); - } + /* read the 16-bits data in */ + for (i = 16; i > 0; i--) { + outl(EECS, ee_addr); + eeprom_delay(); + outl(EECS | EECLK, ee_addr); + eeprom_delay(); + retval = (retval << 1) | ((inl(ee_addr) & EEDO) ? 1 : 0); + eeprom_delay(); + } - /* Terminate the EEPROM access. */ - outl(0, ee_addr); - eeprom_delay(); - outl(EECLK, ee_addr); + /* Terminate the EEPROM access. */ + outl(0, ee_addr); + eeprom_delay(); + outl(EECLK, ee_addr); - return (retval); + return (retval); } #define sis900_mdio_delay() inl(mdio_addr) @@ -427,91 +390,91 @@ static u16 sis900_read_eeprom(int location) static void sis900_mdio_idle(long mdio_addr) { - outl(MDIO | MDDIR, mdio_addr); - sis900_mdio_delay(); - outl(MDIO | MDDIR | MDC, mdio_addr); + outl(MDIO | MDDIR, mdio_addr); + sis900_mdio_delay(); + outl(MDIO | MDDIR | MDC, mdio_addr); } /* Syncronize the MII management interface by shifting 32 one bits out. */ static void sis900_mdio_reset(long mdio_addr) { - int i; + int i; - for (i = 31; i >= 0; i--) { - outl(MDDIR | MDIO, mdio_addr); - sis900_mdio_delay(); - outl(MDDIR | MDIO | MDC, mdio_addr); - sis900_mdio_delay(); - } - return; + for (i = 31; i >= 0; i--) { + outl(MDDIR | MDIO, mdio_addr); + sis900_mdio_delay(); + outl(MDDIR | MDIO | MDC, mdio_addr); + sis900_mdio_delay(); + } + return; } static u16 sis900_mdio_read(int phy_id, int location) { - long mdio_addr = ioaddr + mear; - int mii_cmd = MIIread|(phy_id<= 0; i--) { - int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR; - outl(dataval, mdio_addr); - sis900_mdio_delay(); - outl(dataval | MDC, mdio_addr); - sis900_mdio_delay(); - } + for (i = 15; i >= 0; i--) { + int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR; + outl(dataval, mdio_addr); + sis900_mdio_delay(); + outl(dataval | MDC, mdio_addr); + sis900_mdio_delay(); + } - /* Read the 16 data bits. */ - for (i = 16; i > 0; i--) { - outl(0, mdio_addr); - sis900_mdio_delay(); - retval = (retval << 1) | ((inl(mdio_addr) & MDIO) ? 1 : 0); - outl(MDC, mdio_addr); - sis900_mdio_delay(); - } - return retval; + /* Read the 16 data bits. */ + for (i = 16; i > 0; i--) { + outl(0, mdio_addr); + sis900_mdio_delay(); + retval = (retval << 1) | ((inl(mdio_addr) & MDIO) ? 1 : 0); + outl(MDC, mdio_addr); + sis900_mdio_delay(); + } + return retval; } static void sis900_mdio_write(int phy_id, int location, int value) { - long mdio_addr = ioaddr + mear; - int mii_cmd = MIIwrite|(phy_id<= 0; i--) { - int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR; - outb(dataval, mdio_addr); - sis900_mdio_delay(); - outb(dataval | MDC, mdio_addr); - sis900_mdio_delay(); - } - sis900_mdio_delay(); + /* Shift the command bits out. */ + for (i = 15; i >= 0; i--) { + int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR; + outb(dataval, mdio_addr); + sis900_mdio_delay(); + outb(dataval | MDC, mdio_addr); + sis900_mdio_delay(); + } + sis900_mdio_delay(); - /* Shift the value bits out. */ - for (i = 15; i >= 0; i--) { - int dataval = (value & (1 << i)) ? MDDIR | MDIO : MDDIR; - outl(dataval, mdio_addr); - sis900_mdio_delay(); - outl(dataval | MDC, mdio_addr); - sis900_mdio_delay(); - } - sis900_mdio_delay(); + /* Shift the value bits out. */ + for (i = 15; i >= 0; i--) { + int dataval = (value & (1 << i)) ? MDDIR | MDIO : MDDIR; + outl(dataval, mdio_addr); + sis900_mdio_delay(); + outl(dataval | MDC, mdio_addr); + sis900_mdio_delay(); + } + sis900_mdio_delay(); - /* Clear out extra bits. */ - for (i = 2; i > 0; i--) { - outb(0, mdio_addr); - sis900_mdio_delay(); - outb(MDC, mdio_addr); - sis900_mdio_delay(); - } - return; + /* Clear out extra bits. */ + for (i = 2; i > 0; i--) { + outb(0, mdio_addr); + sis900_mdio_delay(); + outb(MDC, mdio_addr); + sis900_mdio_delay(); + } + return; } @@ -528,19 +491,19 @@ static void sis900_mdio_write(int phy_id, int location, int value) static void sis900_init(struct nic *nic) { - /* Soft reset the chip. */ - sis900_reset(nic); + /* Soft reset the chip. */ + sis900_reset(nic); - sis900_init_rxfilter(nic); + sis900_init_rxfilter(nic); - sis900_init_txd(nic); - sis900_init_rxd(nic); + sis900_init_txd(nic); + sis900_init_rxd(nic); - sis900_set_rx_mode(nic); + sis900_set_rx_mode(nic); - sis900_check_mode(nic); + sis900_check_mode(nic); - outl(RxENA, ioaddr + cr); + outl(RxENA, ioaddr + cr); } @@ -557,20 +520,20 @@ sis900_init(struct nic *nic) static void sis900_reset(struct nic *nic) { - int i = 0; - u32 status = TxRCMP | RxRCMP; + int i = 0; + u32 status = TxRCMP | RxRCMP; - outl(0, ioaddr + ier); - outl(0, ioaddr + imr); - outl(0, ioaddr + rfcr); + outl(0, ioaddr + ier); + outl(0, ioaddr + imr); + outl(0, ioaddr + rfcr); - outl(RxRESET | TxRESET | RESET, ioaddr + cr); + outl(RxRESET | TxRESET | RESET, ioaddr + cr); - /* Check that the chip has finished the reset. */ - while (status && (i++ < 1000)) { - status ^= (inl(isr + ioaddr) & status); - } - outl(PESEL, ioaddr + cfg); + /* Check that the chip has finished the reset. */ + while (status && (i++ < 1000)) { + status ^= (inl(isr + ioaddr) & status); + } + outl(PESEL, ioaddr + cfg); } @@ -586,29 +549,29 @@ sis900_reset(struct nic *nic) static void sis900_init_rxfilter(struct nic *nic) { - u32 rfcrSave; - int i; + u32 rfcrSave; + int i; - rfcrSave = inl(rfcr + ioaddr); + rfcrSave = inl(rfcr + ioaddr); - /* disable packet filtering before setting filter */ - outl(rfcrSave & ~RFEN, rfcr); + /* disable packet filtering before setting filter */ + outl(rfcrSave & ~RFEN, rfcr); - /* load MAC addr to filter data register */ - for (i = 0 ; i < 3 ; i++) { - u32 w; + /* load MAC addr to filter data register */ + for (i = 0 ; i < 3 ; i++) { + u32 w; - w = (u32) *((u16 *)(nic->node_addr)+i); - outl((i << RFADDR_shift), ioaddr + rfcr); - outl(w, ioaddr + rfdr); + w = (u32) *((u16 *)(nic->node_addr)+i); + outl((i << RFADDR_shift), ioaddr + rfcr); + outl(w, ioaddr + rfdr); - if (sis900_debug > 0) - printk_info("sis900_init_rxfilter: Receive Filter Addrss[%d]=%x\n", - i, inl(ioaddr + rfdr)); - } + if (sis900_debug > 0) + printk_info("sis900_init_rxfilter: Receive Filter Addrss[%d]=%x\n", + i, inl(ioaddr + rfdr)); + } - /* enable packet filitering */ - outl(rfcrSave | RFEN, rfcr + ioaddr); + /* enable packet filitering */ + outl(rfcrSave | RFEN, rfcr + ioaddr); } @@ -625,15 +588,15 @@ sis900_init_rxfilter(struct nic *nic) static void sis900_init_txd(struct nic *nic) { - txd.link = (u32) 0; - txd.cmdsts = (u32) 0; - txd.bufptr = (u32) &txb[0]; + txd.link = (u32) 0; + txd.cmdsts = (u32) 0; + txd.bufptr = (u32) &txb[0]; - /* load Transmit Descriptor Register */ - outl((u32) &txd, ioaddr + txdp); - if (sis900_debug > 0) - printk_info("sis900_init_txd: TX descriptor register loaded with: %X\n", - inl(ioaddr + txdp)); + /* load Transmit Descriptor Register */ + outl((u32) &txd, ioaddr + txdp); + if (sis900_debug > 0) + printk_info("sis900_init_txd: TX descriptor register loaded with: %X\n", + inl(ioaddr + txdp)); } @@ -649,26 +612,26 @@ sis900_init_txd(struct nic *nic) static void sis900_init_rxd(struct nic *nic) { - int i; + int i; - cur_rx = 0; + cur_rx = 0; - /* init RX descriptor */ - for (i = 0; i < NUM_RX_DESC; i++) { - rxd[i].link = (i+1 < NUM_RX_DESC) ? (u32) &rxd[i+1] : (u32) &rxd[0]; - rxd[i].cmdsts = (u32) RX_BUF_SIZE; - rxd[i].bufptr = (u32) &rxb[i*RX_BUF_SIZE]; - if (sis900_debug > 0) - printk_info("sis900_init_rxd: rxd[%d]=%X link=%X cmdsts=%X bufptr=%X\n", - i, &rxd[i], rxd[i].link, rxd[i].cmdsts, rxd[i].bufptr); - } + /* init RX descriptor */ + for (i = 0; i < NUM_RX_DESC; i++) { + rxd[i].link = (i+1 < NUM_RX_DESC) ? (u32) &rxd[i+1] : (u32) &rxd[0]; + rxd[i].cmdsts = (u32) RX_BUF_SIZE; + rxd[i].bufptr = (u32) &rxb[i*RX_BUF_SIZE]; + if (sis900_debug > 0) + printk_info("sis900_init_rxd: rxd[%d]=%X link=%X cmdsts=%X bufptr=%X\n", + i, &rxd[i], rxd[i].link, rxd[i].cmdsts, rxd[i].bufptr); + } - /* load Receive Descriptor Register */ - outl((u32) &rxd[0], ioaddr + rxdp); + /* load Receive Descriptor Register */ + outl((u32) &rxd[0], ioaddr + rxdp); - if (sis900_debug > 0) - printk_info("sis900_init_rxd: RX descriptor register loaded with: %X\n", - inl(ioaddr + rxdp)); + if (sis900_debug > 0) + printk_info("sis900_init_rxd: RX descriptor register loaded with: %X\n", + inl(ioaddr + rxdp)); } @@ -686,20 +649,20 @@ sis900_init_rxd(struct nic *nic) static void sis900_set_rx_mode(struct nic *nic) { - int i; + int i; - /* Configure Multicast Hash Table in Receive Filter - to reject all MCAST packets */ - for (i = 0; i < 8; i++) { - /* why plus 0x04? That makes the correct value for hash table. */ - outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr); - outl((u32)(0x0), ioaddr + rfdr); - } - /* Accept Broadcast packets, destination addresses that match - our MAC address */ - outl(RFEN | RFAAB, ioaddr + rfcr); + /* Configure Multicast Hash Table in Receive Filter + to reject all MCAST packets */ + for (i = 0; i < 8; i++) { + /* why plus 0x04? That makes the correct value for hash table. */ + outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr); + outl((u32)(0x0), ioaddr + rfdr); + } + /* Accept Broadcast packets, destination addresses that match + our MAC address */ + outl(RFEN | RFAAB, ioaddr + rfcr); - return; + return; } @@ -716,30 +679,30 @@ static void sis900_set_rx_mode(struct nic *nic) static void sis900_check_mode (struct nic *nic) { - int speed, duplex; - u32 tx_flags = 0, rx_flags = 0; + int speed, duplex; + u32 tx_flags = 0, rx_flags = 0; - mii.chip_info->read_mode(nic, cur_phy, &speed, &duplex); + mii.chip_info->read_mode(nic, cur_phy, &speed, &duplex); - tx_flags = TxATP | (TX_DMA_BURST << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift); - rx_flags = RX_DMA_BURST << RxMXDMA_shift; + tx_flags = TxATP | (TX_DMA_BURST << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift); + rx_flags = RX_DMA_BURST << RxMXDMA_shift; - if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) { - rx_flags |= (RxDRNT_10 << RxDRNT_shift); - tx_flags |= (TxDRNT_10 << TxDRNT_shift); - } - else { - rx_flags |= (RxDRNT_100 << RxDRNT_shift); - tx_flags |= (TxDRNT_100 << TxDRNT_shift); - } + if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) { + rx_flags |= (RxDRNT_10 << RxDRNT_shift); + tx_flags |= (TxDRNT_10 << TxDRNT_shift); + } + else { + rx_flags |= (RxDRNT_100 << RxDRNT_shift); + tx_flags |= (TxDRNT_100 << TxDRNT_shift); + } - if (duplex == FDX_CAPABLE_FULL_SELECTED) { - tx_flags |= (TxCSI | TxHBI); - rx_flags |= RxATX; - } + if (duplex == FDX_CAPABLE_FULL_SELECTED) { + tx_flags |= (TxCSI | TxHBI); + rx_flags |= RxATX; + } - outl (tx_flags, ioaddr + txcfg); - outl (rx_flags, ioaddr + rxcfg); + outl (tx_flags, ioaddr + txcfg); + outl (rx_flags, ioaddr + rxcfg); } @@ -756,31 +719,31 @@ sis900_check_mode (struct nic *nic) static void sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex) { - int i = 0; - u32 status; + int i = 0; + u32 status; - /* STSOUT register is Latched on Transition, read operation updates it */ - while (i++ < 2) - status = sis900_mdio_read(phy_addr, MII_STSOUT); + /* STSOUT register is Latched on Transition, read operation updates it */ + while (i++ < 2) + status = sis900_mdio_read(phy_addr, MII_STSOUT); - if (status & MII_STSOUT_SPD) - *speed = HW_SPEED_100_MBPS; - else - *speed = HW_SPEED_10_MBPS; + if (status & MII_STSOUT_SPD) + *speed = HW_SPEED_100_MBPS; + else + *speed = HW_SPEED_10_MBPS; - if (status & MII_STSOUT_DPLX) - *duplex = FDX_CAPABLE_FULL_SELECTED; - else - *duplex = FDX_CAPABLE_HALF_SELECTED; + if (status & MII_STSOUT_DPLX) + *duplex = FDX_CAPABLE_FULL_SELECTED; + else + *duplex = FDX_CAPABLE_HALF_SELECTED; - if (status & MII_STSOUT_LINK_FAIL) - printk_info("sis900_read_mode: Media Link Off\n"); - else - printk_info("sis900_read_mode: Media Link On %s %s-duplex \n", - *speed == HW_SPEED_100_MBPS ? - "100mbps" : "10mbps", - *duplex == FDX_CAPABLE_FULL_SELECTED ? - "full" : "half"); + if (status & MII_STSOUT_LINK_FAIL) + printk_info("sis900_read_mode: Media Link Off\n"); + else + printk_info("sis900_read_mode: Media Link On %s %s-duplex \n", + *speed == HW_SPEED_100_MBPS ? + "100mbps" : "10mbps", + *duplex == FDX_CAPABLE_FULL_SELECTED ? + "full" : "half"); } @@ -797,43 +760,43 @@ sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex) static void amd79c901_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex) { - int i; - u16 status; + int i; + u16 status; - for (i = 0; i < 2; i++) - status = sis900_mdio_read(phy_addr, MII_STATUS); + for (i = 0; i < 2; i++) + status = sis900_mdio_read(phy_addr, MII_STATUS); - if (status & MII_STAT_CAN_AUTO) { - /* 10BASE-T PHY */ - for (i = 0; i < 2; i++) - status = sis900_mdio_read(phy_addr, MII_STATUS_SUMMARY); - if (status & MII_STSSUM_SPD) - *speed = HW_SPEED_100_MBPS; - else - *speed = HW_SPEED_10_MBPS; - if (status & MII_STSSUM_DPLX) - *duplex = FDX_CAPABLE_FULL_SELECTED; - else - *duplex = FDX_CAPABLE_HALF_SELECTED; + if (status & MII_STAT_CAN_AUTO) { + /* 10BASE-T PHY */ + for (i = 0; i < 2; i++) + status = sis900_mdio_read(phy_addr, MII_STATUS_SUMMARY); + if (status & MII_STSSUM_SPD) + *speed = HW_SPEED_100_MBPS; + else + *speed = HW_SPEED_10_MBPS; + if (status & MII_STSSUM_DPLX) + *duplex = FDX_CAPABLE_FULL_SELECTED; + else + *duplex = FDX_CAPABLE_HALF_SELECTED; - if (status & MII_STSSUM_LINK) - printk_info("amd79c901_read_mode: Media Link On %s %s-duplex \n", - *speed == HW_SPEED_100_MBPS ? - "100mbps" : "10mbps", - *duplex == FDX_CAPABLE_FULL_SELECTED ? - "full" : "half"); - else - printk_info("amd79c901_read_mode: Media Link Off\n"); - } - else { - /* HomePNA */ - *speed = HW_SPEED_HOME; - *duplex = FDX_CAPABLE_HALF_SELECTED; - if (status & MII_STAT_LINK) - printk_info("amd79c901_read_mode:Media Link On 1mbps half-duplex \n"); - else - printk_info("amd79c901_read_mode: Media Link Off\n"); - } + if (status & MII_STSSUM_LINK) + printk_info("amd79c901_read_mode: Media Link On %s %s-duplex \n", + *speed == HW_SPEED_100_MBPS ? + "100mbps" : "10mbps", + *duplex == FDX_CAPABLE_FULL_SELECTED ? + "full" : "half"); + else + printk_info("amd79c901_read_mode: Media Link Off\n"); + } + else { + /* HomePNA */ + *speed = HW_SPEED_HOME; + *duplex = FDX_CAPABLE_HALF_SELECTED; + if (status & MII_STAT_LINK) + printk_info("amd79c901_read_mode:Media Link On 1mbps half-duplex \n"); + else + printk_info("amd79c901_read_mode: Media Link Off\n"); + } } @@ -869,10 +832,10 @@ static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *du if (status & MII_STSICS_LINKSTS) printk_info("ics1893_read_mode: Media Link On %s %s-duplex \n", - *speed == HW_SPEED_100_MBPS ? - "100mbps" : "10mbps", - *duplex == FDX_CAPABLE_FULL_SELECTED ? - "full" : "half"); + *speed == HW_SPEED_100_MBPS ? + "100mbps" : "10mbps", + *duplex == FDX_CAPABLE_FULL_SELECTED ? + "full" : "half"); else printk_info("ics1893_read_mode: Media Link Off\n"); } @@ -913,10 +876,10 @@ static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *du if (status & MII_STAT_LINK) printk_info("rtl8201_read_mode: Media Link On %s %s-duplex \n", - *speed == HW_SPEED_100_MBPS ? - "100mbps" : "10mbps", - *duplex == FDX_CAPABLE_FULL_SELECTED ? - "full" : "half"); + *speed == HW_SPEED_100_MBPS ? + "100mbps" : "10mbps", + *duplex == FDX_CAPABLE_FULL_SELECTED ? + "full" : "half"); else printk_info("rtl9201_read_config_mode: Media Link Off\n"); } @@ -935,64 +898,64 @@ static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *du static void sis900_transmit(struct nic *nic, - const char *d, /* Destination */ - unsigned int t, /* Type */ + const char *dest, /* Destination */ + unsigned int type, /* Type */ unsigned int s, /* size */ const char *p) /* Packet */ { - u32 status, to, nstype; - u32 tx_status; + u32 status, to, nstype; + u32 tx_status; - /* Stop the transmitter */ - outl(TxDIS, ioaddr + cr); + /* Stop the transmitter */ + outl(TxDIS, ioaddr + cr); - /* load Transmit Descriptor Register */ - outl((u32) &txd, ioaddr + txdp); - if (sis900_debug > 1) - printk_info("sis900_transmit: TX descriptor register loaded with: %X\n", - inl(ioaddr + txdp)); + /* load Transmit Descriptor Register */ + outl((u32) &txd, ioaddr + txdp); + if (sis900_debug > 1) + printk_info("sis900_transmit: TX descriptor register loaded with: %X\n", + inl(ioaddr + txdp)); - memcpy(txb, d, ETH_ALEN); - memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN); - nstype = htons(t); - memcpy(txb + 2 * ETH_ALEN, (char*)&nstype, 2); - memcpy(txb + ETH_HLEN, p, s); + memcpy(txb, dest, ETH_ALEN); + memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN); + nstype = htons(type); + memcpy(txb + 2 * ETH_ALEN, (char*)&nstype, 2); + memcpy(txb + ETH_HLEN, p, s); - s += ETH_HLEN; - s &= DSIZE; + s += ETH_HLEN; + s &= DSIZE; - if (sis900_debug > 1) - printk_info("sis900_transmit: sending %d bytes ethtype %x\n", (int) s, t); + if (sis900_debug > 1) + printk_info("sis900_transmit: sending %d bytes ethtype %x\n", (int) s, type); - /* pad to minimum packet size */ - while (s < ETH_ZLEN) - txb[s++] = '\0'; + /* pad to minimum packet size */ + while (s < ETH_ZLEN) + txb[s++] = '\0'; - /* set the transmit buffer descriptor and enable Transmit State Machine */ - txd.bufptr = (u32) &txb[0]; - txd.cmdsts = (u32) OWN | s; + /* set the transmit buffer descriptor and enable Transmit State Machine */ + txd.bufptr = (u32) &txb[0]; + txd.cmdsts = (u32) OWN | s; - /* restart the transmitter */ - outl(TxENA, ioaddr + cr); + /* restart the transmitter */ + outl(TxENA, ioaddr + cr); - if (sis900_debug > 1) - printk_info("sis900_transmit: Queued Tx packet size %d.\n", (int) s); + if (sis900_debug > 1) + printk_info("sis900_transmit: Queued Tx packet size %d.\n", (int) s); - to = currticks() + TX_TIMEOUT; + to = currticks() + TX_TIMEOUT; - while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to)) - /* wait */ ; + while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to)) + /* wait */ ; - if (currticks() >= to) { - printk_info("sis900_transmit: TX Timeout! Tx status %X.\n", tx_status); - } + if (currticks() >= to) { + printk_info("sis900_transmit: TX Timeout! Tx status %X.\n", tx_status); + } - if (tx_status & (ABORT | UNDERRUN | OWCOLL)) { - /* packet unsuccessfully transmited */ - printk_info("sis900_transmit: Transmit error, Tx status %X.\n", tx_status); - } - /* Disable interrupts by clearing the interrupt mask. */ - outl(0, ioaddr + imr); + if (tx_status & (ABORT | UNDERRUN | OWCOLL)) { + /* packet unsuccessfully transmited */ + printk_info("sis900_transmit: Transmit error, Tx status %X.\n", tx_status); + } + /* Disable interrupts by clearing the interrupt mask. */ + outl(0, ioaddr + imr); } @@ -1013,43 +976,43 @@ sis900_transmit(struct nic *nic, static int sis900_poll(struct nic *nic) { - u32 rx_status = rxd[cur_rx].cmdsts; - int retstat = 0; + u32 rx_status = rxd[cur_rx].cmdsts; + int retstat = 0; - if (sis900_debug > 2) - printk_info("sis900_poll: cur_rx:%d, status:%X\n", cur_rx, rx_status); + if (sis900_debug > 2) + printk_info("sis900_poll: cur_rx:%d, status:%X\n", cur_rx, rx_status); - if (!(rx_status & OWN)) - return retstat; + if (!(rx_status & OWN)) + return retstat; - if (sis900_debug > 1) - printk_info("sis900_poll: got a packet: cur_rx:%d, status:%X\n", - cur_rx, rx_status); + if (sis900_debug > 1) + printk_info("sis900_poll: got a packet: cur_rx:%d, status:%X\n", + cur_rx, rx_status); - nic->packetlen = (rx_status & DSIZE) - CRC_SIZE; + nic->packetlen = (rx_status & DSIZE) - CRC_SIZE; - if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) { - /* corrupted packet received */ - printk_info("sis900_poll: Corrupted packet received, buffer status = %X\n", - rx_status); - retstat = 0; - } else { - /* give packet to higher level routine */ - memcpy(nic->packet, (rxb + cur_rx*RX_BUF_SIZE), nic->packetlen); - retstat = 1; - } + if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) { + /* corrupted packet received */ + printk_info("sis900_poll: Corrupted packet received, buffer status = %X\n", + rx_status); + retstat = 0; + } else { + /* give packet to higher level routine */ + memcpy(nic->packet, (rxb + cur_rx*RX_BUF_SIZE), nic->packetlen); + retstat = 1; + } - /* return the descriptor and buffer to receive ring */ - rxd[cur_rx].cmdsts = RX_BUF_SIZE; - rxd[cur_rx].bufptr = (u32) &rxb[cur_rx*RX_BUF_SIZE]; + /* return the descriptor and buffer to receive ring */ + rxd[cur_rx].cmdsts = RX_BUF_SIZE; + rxd[cur_rx].bufptr = (u32) &rxb[cur_rx*RX_BUF_SIZE]; - if (++cur_rx == NUM_RX_DESC) - cur_rx = 0; + if (++cur_rx == NUM_RX_DESC) + cur_rx = 0; - /* re-enable the potentially idle receive state machine */ - outl(RxENA , ioaddr + cr); + /* re-enable the potentially idle receive state machine */ + outl(RxENA , ioaddr + cr); - return retstat; + return retstat; } @@ -1065,10 +1028,10 @@ sis900_poll(struct nic *nic) static void sis900_disable(struct nic *nic) { - /* Disable interrupts by clearing the interrupt mask. */ - outl(0, ioaddr + imr); - outl(0, ioaddr + ier); + /* Disable interrupts by clearing the interrupt mask. */ + outl(0, ioaddr + imr); + outl(0, ioaddr + ier); - /* Stop the chip's Tx and Rx Status Machine */ - outl(RxDIS | TxDIS, ioaddr + cr); + /* Stop the chip's Tx and Rx Status Machine */ + outl(RxDIS | TxDIS, ioaddr + cr); }