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>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/flash.h>
28 +struct avila_board_info {
29 + unsigned char *model;
30 + void (* setup)(void);
33 +static struct avila_board_info *avila_info __initdata;
35 static struct flash_platform_data avila_flash_data = {
36 .map_name = "cfi_probe",
38 @@ -192,10 +207,160 @@ static void __init avila_fixup(struct ma
42 +static void __init avila_gw23xx_setup(void)
44 + platform_device_register(&avila_npeb_device);
45 + platform_device_register(&avila_npec_device);
48 +#ifdef CONFIG_SENSORS_EEPROM
49 +static void __init avila_gw2342_setup(void)
51 + platform_device_register(&avila_npeb_device);
52 + platform_device_register(&avila_npec_device);
55 +static void __init avila_gw2345_setup(void)
57 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
58 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
59 + platform_device_register(&avila_npeb_device);
61 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
62 + platform_device_register(&avila_npec_device);
65 +static void __init avila_gw2347_setup(void)
67 + platform_device_register(&avila_npeb_device);
70 +static void __init avila_gw2348_setup(void)
72 + platform_device_register(&avila_npeb_device);
73 + platform_device_register(&avila_npec_device);
76 +static void __init avila_gw2353_setup(void)
78 + platform_device_register(&avila_npeb_device);
81 +static void __init avila_gw2355_setup(void)
83 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
84 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
85 + platform_device_register(&avila_npeb_device);
87 + avila_npec_data.phy = 5;
88 + platform_device_register(&avila_npec_device);
91 +static void __init avila_gw2357_setup(void)
93 + platform_device_register(&avila_npeb_device);
96 +static struct avila_board_info avila_boards[] __initdata = {
99 + .setup = avila_gw2342_setup,
102 + .setup = avila_gw2345_setup,
105 + .setup = avila_gw2347_setup,
108 + .setup = avila_gw2348_setup,
111 + .setup = avila_gw2353_setup,
114 + .setup = avila_gw2355_setup,
117 + .setup = avila_gw2357_setup,
121 +static struct avila_board_info * __init avila_find_board_info(char *model)
125 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
126 + struct avila_board_info *info = &avila_boards[i];
127 + if (strncmp(info->model, model, strlen(info->model)) == 0)
134 +struct avila_eeprom_header {
135 + unsigned char mac0[ETH_ALEN];
136 + unsigned char mac1[ETH_ALEN];
137 + unsigned char res0[4];
138 + unsigned char magic[2];
139 + unsigned char config[14];
140 + unsigned char model[16];
143 +static int __init avila_eeprom_notify(struct notifier_block *self,
144 + unsigned long event, void *t)
146 + struct eeprom_data *ee = t;
147 + struct avila_eeprom_header hdr;
150 + return NOTIFY_DONE;
152 + /* The eeprom is at address 0x51 */
153 + if (event != EEPROM_REGISTER || ee->client.addr != 0x51)
154 + return NOTIFY_DONE;
156 + ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr,
159 + if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W')
160 + return NOTIFY_DONE;
162 + memcpy(&avila_npeb_data.hwaddr, hdr.mac0, ETH_ALEN);
163 + memcpy(&avila_npec_data.hwaddr, hdr.mac1, ETH_ALEN);
165 + avila_info = avila_find_board_info(hdr.model);
170 +static struct notifier_block avila_eeprom_notifier __initdata = {
171 + .notifier_call = avila_eeprom_notify
174 +static void __init avila_register_eeprom_notifier(void)
176 + register_eeprom_notifier(&avila_eeprom_notifier);
179 +static void __init avila_unregister_eeprom_notifier(void)
181 + unregister_eeprom_notifier(&avila_eeprom_notifier);
183 +#else /* CONFIG_SENSORS_EEPROM */
184 +static inline void avila_register_eeprom_notifier(void) {};
185 +static inline void avila_unregister_eeprom_notifier(void) {};
186 +#endif /* CONFIG_SENSORS_EEPROM */
188 static void __init avila_init(void)
193 + * These devices are present on all Avila models and don't need any
194 + * model specific setup.
196 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
197 avila_flash_resource.end =
198 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
199 @@ -213,9 +378,28 @@ static void __init avila_init(void)
201 platform_device_register(&avila_pata);
203 - platform_device_register(avila_npeb_device);
204 - platform_device_register(avila_npec_device);
205 + avila_register_eeprom_notifier();
208 +static int __init avila_model_setup(void)
210 + if (!machine_is_avila())
214 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
215 + avila_info->model);
216 + avila_info->setup();
218 + printk(KERN_INFO "Unknown/missing Avila model number"
219 + " -- defaults will be used\n");
220 + avila_gw23xx_setup();
223 + avila_unregister_eeprom_notifier();
226 +late_initcall(avila_model_setup);
228 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
229 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */