static int __init rbtx4938_ethaddr_init(void) { #ifdef CONFIG_PCI unsigned char dat[17]; unsigned char sum; int i; /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */ if (spi_eeprom_read(SPI_BUSNO, SEEPROM1_CS, 0, dat, sizeof(dat))) { printk(KERN_ERR "seeprom: read error.\n"); return -ENODEV; } else { if (strcmp(dat, "MAC") != 0) printk(KERN_WARNING "seeprom: bad signature.\n"); for (i = 0, sum = 0; i < sizeof(dat); i++) sum += dat[i]; if (sum) printk(KERN_WARNING "seeprom: bad checksum.\n"); } tx4938_ethaddr_init(&dat[4], &dat[4 + 6]); #endif /* CONFIG_PCI */ return 0; }
ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len) { int offset; int i; ssize_t res; offset = 0; for (i=0;i<alen;i++) { offset <<= 8; offset |= addr[i]; } #ifdef CONFIG_SYS_SC520_CDP_USE_SPI res = spi_eeprom_read(1, offset, buffer, len); #endif #ifdef CONFIG_SYS_SC520_CDP_USE_MW res = mw_eeprom_read(2, offset, buffer, len); #endif #if !defined(CONFIG_SYS_SC520_CDP_USE_SPI) && !defined(CONFIG_SYS_SC520_CDP_USE_MW) res = 0; #endif return res; }