[kernel] 2.6.26: fix gpio_dev compile error
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 300-avila_fetch_mac.patch
1 --- a/arch/arm/mach-ixp4xx/avila-setup.c
2 +++ b/arch/arm/mach-ixp4xx/avila-setup.c
3 @@ -14,10 +14,18 @@
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>
17 +#endif
18 +
19 #include <linux/i2c-gpio.h>
20
21 #include <asm/types.h>
22 @@ -29,6 +37,13 @@
23 #include <asm/mach/arch.h>
24 #include <asm/mach/flash.h>
25
26 +struct avila_board_info {
27 + unsigned char *model;
28 + void (* setup)(void);
29 +};
30 +
31 +static struct avila_board_info *avila_info __initdata;
32 +
33 static struct flash_platform_data avila_flash_data = {
34 .map_name = "cfi_probe",
35 .width = 2,
36 @@ -163,10 +178,160 @@
37 &avila_uart
38 };
39
40 +static void __init avila_gw23xx_setup(void)
41 +{
42 + platform_device_register(&avila_npeb_device);
43 + platform_device_register(&avila_npec_device);
44 +}
45 +
46 +#ifdef CONFIG_SENSORS_EEPROM
47 +static void __init avila_gw2342_setup(void)
48 +{
49 + platform_device_register(&avila_npeb_device);
50 + platform_device_register(&avila_npec_device);
51 +}
52 +
53 +static void __init avila_gw2345_setup(void)
54 +{
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);
58 +
59 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
60 + platform_device_register(&avila_npec_device);
61 +}
62 +
63 +static void __init avila_gw2347_setup(void)
64 +{
65 + platform_device_register(&avila_npeb_device);
66 +}
67 +
68 +static void __init avila_gw2348_setup(void)
69 +{
70 + platform_device_register(&avila_npeb_device);
71 + platform_device_register(&avila_npec_device);
72 +}
73 +
74 +static void __init avila_gw2353_setup(void)
75 +{
76 + platform_device_register(&avila_npeb_device);
77 +}
78 +
79 +static void __init avila_gw2355_setup(void)
80 +{
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);
84 +
85 + avila_npec_data.phy = 16;
86 + platform_device_register(&avila_npec_device);
87 +}
88 +
89 +static void __init avila_gw2357_setup(void)
90 +{
91 + platform_device_register(&avila_npeb_device);
92 +}
93 +
94 +static struct avila_board_info avila_boards[] __initdata = {
95 + {
96 + .model = "GW2342",
97 + .setup = avila_gw2342_setup,
98 + }, {
99 + .model = "GW2345",
100 + .setup = avila_gw2345_setup,
101 + }, {
102 + .model = "GW2347",
103 + .setup = avila_gw2347_setup,
104 + }, {
105 + .model = "GW2348",
106 + .setup = avila_gw2348_setup,
107 + }, {
108 + .model = "GW2353",
109 + .setup = avila_gw2353_setup,
110 + }, {
111 + .model = "GW2355",
112 + .setup = avila_gw2355_setup,
113 + }, {
114 + .model = "GW2357",
115 + .setup = avila_gw2357_setup,
116 + }
117 +};
118 +
119 +static struct avila_board_info * __init avila_find_board_info(char *model)
120 +{
121 + int i;
122 +
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)
126 + return info;
127 + }
128 +
129 + return NULL;
130 +}
131 +
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];
139 +};
140 +
141 +static int __init avila_eeprom_notify(struct notifier_block *self,
142 + unsigned long event, void *t)
143 +{
144 + struct eeprom_data *ee = t;
145 + struct avila_eeprom_header hdr;
146 +
147 + if (avila_info)
148 + return NOTIFY_DONE;
149 +
150 + /* The eeprom is at address 0x51 */
151 + if (event != EEPROM_REGISTER || ee->client.addr != 0x51)
152 + return NOTIFY_DONE;
153 +
154 + ee->attr->read(&ee->client.dev.kobj, ee->attr, (char *)&hdr,
155 + 0, sizeof(hdr));
156 +
157 + if (hdr.magic[0] != 'G' || hdr.magic[1] != 'W')
158 + return NOTIFY_DONE;
159 +
160 + memcpy(&avila_npeb_data.hwaddr, hdr.mac0, ETH_ALEN);
161 + memcpy(&avila_npec_data.hwaddr, hdr.mac1, ETH_ALEN);
162 +
163 + avila_info = avila_find_board_info(hdr.model);
164 +
165 + return NOTIFY_OK;
166 +}
167 +
168 +static struct notifier_block avila_eeprom_notifier __initdata = {
169 + .notifier_call = avila_eeprom_notify
170 +};
171 +
172 +static void __init avila_register_eeprom_notifier(void)
173 +{
174 + register_eeprom_notifier(&avila_eeprom_notifier);
175 +}
176 +
177 +static void __init avila_unregister_eeprom_notifier(void)
178 +{
179 + unregister_eeprom_notifier(&avila_eeprom_notifier);
180 +}
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 */
185 +
186 static void __init avila_init(void)
187 {
188 ixp4xx_sys_init();
189
190 + /*
191 + * These devices are present on all Avila models and don't need any
192 + * model specific setup.
193 + */
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 @@
198
199 platform_device_register(&avila_pata);
200
201 - platform_device_register(avila_npeb_device);
202 - platform_device_register(avila_npec_device);
203 + avila_register_eeprom_notifier();
204 +}
205 +
206 +static int __init avila_model_setup(void)
207 +{
208 + if (!machine_is_avila())
209 + return 0;
210 +
211 + if (avila_info) {
212 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
213 + avila_info->model);
214 + avila_info->setup();
215 + } else {
216 + printk(KERN_INFO "Unknown/missing Avila model number"
217 + " -- defaults will be used\n");
218 + avila_gw23xx_setup();
219 + }
220 +
221 + avila_unregister_eeprom_notifier();
222 + return 0;
223 }
224 +late_initcall(avila_model_setup);
225
226 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
227 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
This page took 0.04979 seconds and 5 git commands to generate.