1 Index: linux-2.6.24.2/arch/arm/mach-ixp4xx/avila-setup.c
2 ===================================================================
3 --- linux-2.6.24.2.orig/arch/arm/mach-ixp4xx/avila-setup.c
4 +++ linux-2.6.24.2/arch/arm/mach-ixp4xx/avila-setup.c
6 #include <linux/kernel.h>
7 #include <linux/init.h>
8 #include <linux/device.h>
9 +#include <linux/if_ether.h>
10 +#include <linux/socket.h>
11 +#include <linux/netdevice.h>
12 #include <linux/serial.h>
13 #include <linux/tty.h>
14 #include <linux/serial_8250.h>
15 #include <linux/slab.h>
16 +#ifdef CONFIG_SENSORS_EEPROM
17 +# include <linux/i2c.h>
18 +# include <linux/eeprom.h>
21 #include <linux/i2c-gpio.h>
23 #include <asm/types.h>
24 @@ -177,6 +185,118 @@ static struct platform_device *avila_eth
28 +#ifdef CONFIG_SENSORS_EEPROM
29 +struct avila_board_info {
30 + unsigned char *model;
36 +static struct avila_board_info avila_boards[] = {
47 + .model = "GW2348-2",
52 + .model = "GW2348-4",
72 +static struct avila_board_info *avila_find_board_info(char *model)
76 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
77 + struct avila_board_info *info = &avila_boards[i];
78 + if (strncmp(info->model, model, strlen(info->model)) == 0)
85 +struct avila_eeprom_header {
86 + unsigned char mac0[ETH_ALEN];
87 + unsigned char mac1[ETH_ALEN];
88 + unsigned char res0[4];
89 + unsigned char magic[2];
90 + unsigned char config[14];
91 + unsigned char model[16];
94 +static int avila_eeprom_notify(struct notifier_block *self,
95 + unsigned long event, void *t)
97 + struct eeprom_data *ee = t;
98 + struct avila_board_info *info = NULL;
99 + struct avila_eeprom_header hdr;
101 + /* The eeprom is at address 0x51 */
102 + if (event != EEPROM_REGISTER || ee->client.addr != 0x51)
103 + return NOTIFY_DONE;
105 + ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr,
108 + if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W')
109 + return NOTIFY_DONE;
111 + memcpy(&avila_plat_eth[0].hwaddr, hdr.mac0, ETH_ALEN);
112 + memcpy(&avila_plat_eth[1].hwaddr, hdr.mac1, ETH_ALEN);
114 + info = avila_find_board_info(hdr.model);
117 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
119 + avila_plat_eth[0].phy = info->npeb_phy;
120 + avila_plat_eth[1].phy = info->npec_phy;
121 + platform_add_devices(avila_eth_devices,
124 + printk(KERN_INFO "Unknown/missing Avila model number"
125 + " -- defaults will be used\n");
126 + platform_add_devices(avila_eth_devices,
127 + ARRAY_SIZE(avila_eth_devices));
130 + unregister_eeprom_notifier(self);
135 +static struct notifier_block avila_eeprom_notifier = {
136 + .notifier_call = avila_eeprom_notify
140 static void __init avila_init(void)
143 @@ -201,7 +321,11 @@ static void __init avila_init(void)
145 platform_device_register(&avila_pata);
147 +#ifdef CONFIG_SENSORS_EEPROM
148 + register_eeprom_notifier(&avila_eeprom_notifier);
150 platform_add_devices(avila_eth_devices, ARRAY_SIZE(avila_eth_devices));
154 MACHINE_START(AVILA, "Gateworks Avila Network Platform")