/** * write_eeprom_reg - write specified value into specified register in EEPROM */ static int write_eeprom_reg(u8 value, u8 reg) { int ret; /* enable erasing/writing */ ret = do_eeprom_cmd(E2P_CMD_EPC_CMD_EWEN, reg); if (ret) goto done; /* erase the eeprom reg */ ret = do_eeprom_cmd(E2P_CMD_EPC_CMD_ERASE, reg); if (ret) goto done; /* write the eeprom reg */ smc911x_reg_write(E2P_DATA, value); ret = do_eeprom_cmd(E2P_CMD_EPC_CMD_WRITE, reg); if (ret) goto done; /* disable erasing/writing */ ret = do_eeprom_cmd(E2P_CMD_EPC_CMD_EWDS, reg); done: return ret; }
/** * read_eeprom_reg - read specified register in EEPROM */ static u8 read_eeprom_reg(u8 reg) { int ret = do_eeprom_cmd(E2P_CMD_EPC_CMD_READ, reg); return (ret ? : smc911x_reg_read(E2P_DATA)); }
/** * read_eeprom_reg - read specified register in EEPROM */ static u8 read_eeprom_reg(struct eth_device *dev, u8 reg) { int ret = do_eeprom_cmd(dev, E2P_CMD_EPC_CMD_READ, reg); return (ret ? : smc911x_reg_read(dev, E2P_DATA)); }
int __declspec(dllexport) install(struct unit *unit, char *opts) { int i; struct board *board; struct nic *sp; struct dev *dev; unsigned short ioaddr; unsigned short irq; unsigned short eeprom[0x100]; // Check license if (license() != LICENSE_GPL) kprintf(KERN_WARNING "notice: eepro100 driver is under GPL license\n"); // Determine NIC type board = lookup_board(board_tbl, unit); if (!board) return -EIO; unit->vendorname = board->vendorname; unit->productname = board->productname; // Get NIC PCI configuration ioaddr = (unsigned short) get_unit_iobase(unit); irq = irq = (unsigned short) get_unit_irq(unit); // Enable bus mastering pci_enable_busmastering(unit); // Allocate private memory sp = kmalloc(sizeof(struct nic)); if (sp == NULL) return -ENOMEM; memset(sp, 0, sizeof(struct nic)); // Read the station address EEPROM before doing the reset. // Nominally his should even be done before accepting the device, but // then we wouldn't have a device name with which to report the error. // The size test is for 6 bit vs. 8 bit address serial EEPROMs. { unsigned short sum = 0; int j; int read_cmd, ee_size; if ((do_eeprom_cmd(ioaddr, EE_READ_CMD << 24, 27) & 0xffe0000) == 0xffe0000) { ee_size = 0x100; read_cmd = EE_READ_CMD << 24; } else { ee_size = 0x40; read_cmd = EE_READ_CMD << 22; } for (j = 0, i = 0; i < ee_size; i++) { unsigned short value = do_eeprom_cmd(ioaddr, read_cmd | (i << 16), 27); eeprom[i] = value; sum += value; if (i < 3) { sp->hwaddr.addr[j++] = (unsigned char) (value % 0xFF); sp->hwaddr.addr[j++] = (unsigned char) (value >> 8); } } if (sum != 0xBABA) kprintf(KERN_WARNING "eepro100: Invalid EEPROM checksum %#4.4x!\n", sum); }