1 --- a/arch/arm/mach-ixp4xx/avila-setup.c
2 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
4 #include <linux/kernel.h>
5 #include <linux/init.h>
6 #include <linux/device.h>
7 +#include <linux/if_ether.h>
8 +#include <linux/socket.h>
9 +#include <linux/netdevice.h>
10 #include <linux/serial.h>
11 #include <linux/tty.h>
12 #include <linux/serial_8250.h>
13 #include <linux/slab.h>
14 +#ifdef CONFIG_SENSORS_EEPROM
15 +# include <linux/i2c.h>
16 +# include <linux/eeprom.h>
19 #include <linux/i2c-gpio.h>
21 #include <asm/types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/flash.h>
26 +struct avila_board_info {
27 + unsigned char *model;
28 + void (* setup)(void);
31 +static struct avila_board_info *avila_info __initdata;
33 static struct flash_platform_data avila_flash_data = {
34 .map_name = "cfi_probe",
36 @@ -163,10 +178,160 @@ static struct platform_device *avila_dev
40 +static void __init avila_gw23xx_setup(void)
42 + platform_device_register(&avila_npeb_device);
43 + platform_device_register(&avila_npec_device);
46 +#ifdef CONFIG_SENSORS_EEPROM
47 +static void __init avila_gw2342_setup(void)
49 + platform_device_register(&avila_npeb_device);
50 + platform_device_register(&avila_npec_device);
53 +static void __init avila_gw2345_setup(void)
55 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
56 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
57 + platform_device_register(&avila_npeb_device);
59 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
60 + platform_device_register(&avila_npec_device);
63 +static void __init avila_gw2347_setup(void)
65 + platform_device_register(&avila_npeb_device);
68 +static void __init avila_gw2348_setup(void)
70 + platform_device_register(&avila_npeb_device);
71 + platform_device_register(&avila_npec_device);
74 +static void __init avila_gw2353_setup(void)
76 + platform_device_register(&avila_npeb_device);
79 +static void __init avila_gw2355_setup(void)
81 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
82 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
83 + platform_device_register(&avila_npeb_device);
85 + avila_npec_data.phy = 16;
86 + platform_device_register(&avila_npec_device);
89 +static void __init avila_gw2357_setup(void)
91 + platform_device_register(&avila_npeb_device);
94 +static struct avila_board_info avila_boards[] __initdata = {
97 + .setup = avila_gw2342_setup,
100 + .setup = avila_gw2345_setup,
103 + .setup = avila_gw2347_setup,
106 + .setup = avila_gw2348_setup,
109 + .setup = avila_gw2353_setup,
112 + .setup = avila_gw2355_setup,
115 + .setup = avila_gw2357_setup,
119 +static struct avila_board_info * __init avila_find_board_info(char *model)
123 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
124 + struct avila_board_info *info = &avila_boards[i];
125 + if (strncmp(info->model, model, strlen(info->model)) == 0)
132 +struct avila_eeprom_header {
133 + unsigned char mac0[ETH_ALEN];
134 + unsigned char mac1[ETH_ALEN];
135 + unsigned char res0[4];
136 + unsigned char magic[2];
137 + unsigned char config[14];
138 + unsigned char model[16];
141 +static int __init avila_eeprom_notify(struct notifier_block *self,
142 + unsigned long event, void *t)
144 + struct eeprom_data *ee = t;
145 + struct avila_eeprom_header hdr;
148 + return NOTIFY_DONE;
150 + /* The eeprom is at address 0x51 */
151 + if (event != EEPROM_REGISTER || ee->client.addr != 0x51)
152 + return NOTIFY_DONE;
154 + ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr,
157 + if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W')
158 + return NOTIFY_DONE;
160 + memcpy(&avila_npeb_data.hwaddr, hdr.mac0, ETH_ALEN);
161 + memcpy(&avila_npec_data.hwaddr, hdr.mac1, ETH_ALEN);
163 + avila_info = avila_find_board_info(hdr.model);
168 +static struct notifier_block avila_eeprom_notifier __initdata = {
169 + .notifier_call = avila_eeprom_notify
172 +static void __init avila_register_eeprom_notifier(void)
174 + register_eeprom_notifier(&avila_eeprom_notifier);
177 +static void __init avila_unregister_eeprom_notifier(void)
179 + unregister_eeprom_notifier(&avila_eeprom_notifier);
181 +#else /* CONFIG_SENSORS_EEPROM */
182 +static inline void avila_register_eeprom_notifier(void) {};
183 +static inline void avila_unregister_eeprom_notifier(void) {};
184 +#endif /* CONFIG_SENSORS_EEPROM */
186 static void __init avila_init(void)
191 + * These devices are present on all Avila models and don't need any
192 + * model specific setup.
194 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
195 avila_flash_resource.end =
196 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
197 @@ -184,9 +349,28 @@ static void __init avila_init(void)
199 platform_device_register(&avila_pata);
201 - platform_device_register(avila_npeb_device);
202 - platform_device_register(avila_npec_device);
203 + avila_register_eeprom_notifier();
206 +static int __init avila_model_setup(void)
208 + if (!machine_is_avila())
212 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
213 + avila_info->model);
214 + avila_info->setup();
216 + printk(KERN_INFO "Unknown/missing Avila model number"
217 + " -- defaults will be used\n");
218 + avila_gw23xx_setup();
221 + avila_unregister_eeprom_notifier();
224 +late_initcall(avila_model_setup);
226 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
227 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */