add loft support for setting the maclist from EEPROM Signed-off-by: John Bowler --- linux-2.6.15/arch/arm/mach-ixp4xx/ixdp425-setup.c 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.15/arch/arm/mach-ixp4xx/ixdp425-setup.c 1970-01-01 00:00:00.000000000 +0000 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,8 @@ #include #include +#include + static struct flash_platform_data ixdp425_flash_data = { .map_name = "cfi_probe", .width = 2, @@ -188,9 +191,62 @@ MACHINE_END /* * Loft is functionally equivalent to Avila except that it has a * different number for the maximum PCI devices. The MACHINE - * structure below is identical to Avila except for the comment. + * structure below is identical to Avila except for the and + * the use of a loft specific init. + * + * The loft init registers a notifier on the on-board EEPROM to + * detect the MAC addresses. + * NOTE: this probably works for all Gateworks Avila boards and + * maybe the ixdp425 too. */ #ifdef CONFIG_MACH_LOFT +/* + * When the EEPROM is added the MAC address are read from it. + */ +static void loft_eeprom_add(int address, int kind, struct kobject *kobj, + struct bin_attribute *eeprom_attr) { + /* The MACs are the first 12 bytes in the eeprom at address 0x51 */ + if (address == 0x51) { + ssize_t retlen; + char data[12]; + + /* Two Macs, one at 0, the other at 6, maclist_add will + * complain if the ID is not a valid MAC. + */ + retlen = eeprom_attr->read(kobj, data, 0, sizeof data); + if (retlen >= 6) { + u8 mac[6]; + memcpy(mac, data+0, sizeof mac); + printk(KERN_INFO "LOFT MAC[0]: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + maclist_add(mac); + } + if (retlen >= 12) { + u8 mac[6]; + memcpy(mac, data+6, sizeof mac); + printk(KERN_INFO "LOFT MAC[1]: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + maclist_add(mac); + } + } +} + +static struct eeprom_notifier loft_eeprom_notifier = { + .add = loft_eeprom_add +}; + +static void __init loft_init(void) +{ + /* The EEPROM has two ethernet MACs embedded in it which we need, + * that is all this notifier does. + */ + register_eeprom_user(&loft_eeprom_notifier); + + ixp4xx_sys_init(); + + platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices)); +} + MACHINE_START(LOFT, "Giant Shoulder Inc Loft board") /* Maintainer: Tom Billman */ .phys_ram = PHYS_OFFSET, @@ -200,7 +256,7 @@ MACHINE_START(LOFT, "Giant Shoulder Inc .init_irq = ixp4xx_init_irq, .timer = &ixp4xx_timer, .boot_params = 0x0100, - .init_machine = ixdp425_init, + .init_machine = loft_init, MACHINE_END #endif