X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/5951d03bc4e55cc541795c60c10ee6be6eec4f23..2a88ac56956dbae4320bb19b2a17536d7757049c:/target/linux/ixp4xx/patches-2.6.27/300-avila_fetch_mac.patch?ds=sidebyside diff --git a/target/linux/ixp4xx/patches-2.6.27/300-avila_fetch_mac.patch b/target/linux/ixp4xx/patches-2.6.27/300-avila_fetch_mac.patch index db25efbea..4581bdd34 100644 --- a/target/linux/ixp4xx/patches-2.6.27/300-avila_fetch_mac.patch +++ b/target/linux/ixp4xx/patches-2.6.27/300-avila_fetch_mac.patch @@ -1,6 +1,6 @@ --- a/arch/arm/mach-ixp4xx/avila-setup.c +++ b/arch/arm/mach-ixp4xx/avila-setup.c -@@ -14,10 +14,18 @@ +@@ -14,10 +14,16 @@ #include #include #include @@ -11,21 +11,19 @@ #include #include #include -+#ifdef CONFIG_SENSORS_EEPROM -+# include -+# include -+#endif ++#include ++#include + #include #include -@@ -29,6 +37,13 @@ +@@ -29,6 +35,13 @@ #include #include +struct avila_board_info { + unsigned char *model; -+ void (* setup)(void); ++ void (*setup)(void); +}; + +static struct avila_board_info *avila_info __initdata; @@ -33,7 +31,38 @@ static struct flash_platform_data avila_flash_data = { .map_name = "cfi_probe", .width = 2, -@@ -163,10 +178,160 @@ +@@ -132,16 +145,181 @@ static struct platform_device avila_pata + .resource = avila_pata_resources, + }; + ++/* Built-in 10/100 Ethernet MAC interfaces */ ++static struct eth_plat_info avila_npeb_data = { ++ .phy = 0, ++ .rxq = 3, ++ .txreadyq = 20, ++}; ++ ++static struct eth_plat_info avila_npec_data = { ++ .phy = 1, ++ .rxq = 4, ++ .txreadyq = 21, ++}; ++ ++static struct platform_device avila_npeb_device = { ++ .name = "ixp4xx_eth", ++ .id = IXP4XX_ETH_NPEB, ++ .dev.platform_data = &avila_npeb_data, ++}; ++ ++static struct platform_device avila_npec_device = { ++ .name = "ixp4xx_eth", ++ .id = IXP4XX_ETH_NPEC, ++ .dev.platform_data = &avila_npec_data, ++}; ++ + static struct platform_device *avila_devices[] __initdata = { + &avila_i2c_gpio, + &avila_flash, &avila_uart }; @@ -43,7 +72,6 @@ + platform_device_register(&avila_npec_device); +} + -+#ifdef CONFIG_SENSORS_EEPROM +static void __init avila_gw2342_setup(void) +{ + platform_device_register(&avila_npeb_device); @@ -122,66 +150,57 @@ + + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) { + struct avila_board_info *info = &avila_boards[i]; -+ if (strncmp(info->model, model, strlen(info->model)) == 0) ++ if (strcmp(info->model, model) == 0) + return info; + } + + return NULL; +} + -+struct avila_eeprom_header { -+ unsigned char mac0[ETH_ALEN]; -+ unsigned char mac1[ETH_ALEN]; -+ unsigned char res0[4]; -+ unsigned char magic[2]; -+ unsigned char config[14]; -+ unsigned char model[16]; -+}; ++static struct at24_iface *at24_if; + -+static int __init avila_eeprom_notify(struct notifier_block *self, -+ unsigned long event, void *t) ++static int at24_setup(struct at24_iface *iface, void *context) +{ -+ struct eeprom_data *ee = t; -+ struct avila_eeprom_header hdr; -+ -+ if (avila_info) -+ return NOTIFY_DONE; -+ -+ /* The eeprom is at address 0x51 */ -+ if (event != EEPROM_REGISTER || ee->client.addr != 0x51) -+ return NOTIFY_DONE; -+ -+ ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr, -+ 0, sizeof(hdr)); ++ char mac_addr[ETH_ALEN]; ++ char model[6]; + -+ if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W') -+ return NOTIFY_DONE; ++ at24_if = iface; + -+ memcpy(&avila_npeb_data.hwaddr, hdr.mac0, ETH_ALEN); -+ memcpy(&avila_npec_data.hwaddr, hdr.mac1, ETH_ALEN); ++ /* Read MAC addresses */ ++ if (at24_if->read(at24_if, mac_addr, 0x0, 6) == 6) { ++ memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN); ++ } ++ if (at24_if->read(at24_if, mac_addr, 0x6, 6) == 6) { ++ memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN); ++ } + -+ avila_info = avila_find_board_info(hdr.model); ++ /* Read the first 6 bytes of the model number */ ++ if (at24_if->read(at24_if, model, 0x20, 6) == 6) { ++ avila_info = avila_find_board_info(model); ++ } + -+ return NOTIFY_OK; ++ return 0; +} + -+static struct notifier_block avila_eeprom_notifier __initdata = { -+ .notifier_call = avila_eeprom_notify ++static struct at24_platform_data avila_eeprom_info = { ++ .byte_len = 1024, ++ .page_size = 16, ++ .flags = AT24_FLAG_READONLY, ++ .setup = at24_setup, +}; + -+static void __init avila_register_eeprom_notifier(void) -+{ -+ register_eeprom_notifier(&avila_eeprom_notifier); -+} -+ -+static void __init avila_unregister_eeprom_notifier(void) -+{ -+ unregister_eeprom_notifier(&avila_eeprom_notifier); -+} -+#else /* CONFIG_SENSORS_EEPROM */ -+static inline void avila_register_eeprom_notifier(void) {}; -+static inline void avila_unregister_eeprom_notifier(void) {}; -+#endif /* CONFIG_SENSORS_EEPROM */ ++static struct i2c_board_info __initdata avila_i2c_board_info[] = { ++ { ++ I2C_BOARD_INFO("ds1672", 0x68), ++ }, ++ { ++ I2C_BOARD_INFO("ad7418", 0x28), ++ }, ++ { ++ I2C_BOARD_INFO("24c08", 0x51), ++ .platform_data = &avila_eeprom_info ++ }, ++}; + static void __init avila_init(void) { @@ -194,13 +213,12 @@ avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); avila_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; -@@ -184,9 +349,28 @@ +@@ -159,7 +337,28 @@ static void __init avila_init(void) platform_device_register(&avila_pata); -- platform_device_register(avila_npeb_device); -- platform_device_register(avila_npec_device); -+ avila_register_eeprom_notifier(); ++ i2c_register_board_info(0, avila_i2c_board_info, ++ ARRAY_SIZE(avila_i2c_board_info)); +} + +static int __init avila_model_setup(void) @@ -218,7 +236,6 @@ + avila_gw23xx_setup(); + } + -+ avila_unregister_eeprom_notifier(); + return 0; } +late_initcall(avila_model_setup);