[package] iw: update to 0.9.17
[openwrt.git] / target / linux / ixp4xx / patches-2.6.30 / 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,16 @@
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 +#include <linux/i2c.h>
15 +#include <linux/i2c/at24.h>
16 +
17 #include <linux/i2c-gpio.h>
18
19 #include <asm/types.h>
20 @@ -29,6 +35,13 @@
21 #include <asm/mach/arch.h>
22 #include <asm/mach/flash.h>
23
24 +struct avila_board_info {
25 + unsigned char *model;
26 + void (*setup)(void);
27 +};
28 +
29 +static struct avila_board_info *avila_info __initdata;
30 +
31 static struct flash_platform_data avila_flash_data = {
32 .map_name = "cfi_probe",
33 .width = 2,
34 @@ -132,16 +145,181 @@ static struct platform_device avila_pata
35 .resource = avila_pata_resources,
36 };
37
38 +/* Built-in 10/100 Ethernet MAC interfaces */
39 +static struct eth_plat_info avila_npeb_data = {
40 + .phy = 0,
41 + .rxq = 3,
42 + .txreadyq = 20,
43 +};
44 +
45 +static struct eth_plat_info avila_npec_data = {
46 + .phy = 1,
47 + .rxq = 4,
48 + .txreadyq = 21,
49 +};
50 +
51 +static struct platform_device avila_npeb_device = {
52 + .name = "ixp4xx_eth",
53 + .id = IXP4XX_ETH_NPEB,
54 + .dev.platform_data = &avila_npeb_data,
55 +};
56 +
57 +static struct platform_device avila_npec_device = {
58 + .name = "ixp4xx_eth",
59 + .id = IXP4XX_ETH_NPEC,
60 + .dev.platform_data = &avila_npec_data,
61 +};
62 +
63 static struct platform_device *avila_devices[] __initdata = {
64 &avila_i2c_gpio,
65 &avila_flash,
66 &avila_uart
67 };
68
69 +static void __init avila_gw23xx_setup(void)
70 +{
71 + platform_device_register(&avila_npeb_device);
72 + platform_device_register(&avila_npec_device);
73 +}
74 +
75 +static void __init avila_gw2342_setup(void)
76 +{
77 + platform_device_register(&avila_npeb_device);
78 + platform_device_register(&avila_npec_device);
79 +}
80 +
81 +static void __init avila_gw2345_setup(void)
82 +{
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);
86 +
87 + avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
88 + platform_device_register(&avila_npec_device);
89 +}
90 +
91 +static void __init avila_gw2347_setup(void)
92 +{
93 + platform_device_register(&avila_npeb_device);
94 +}
95 +
96 +static void __init avila_gw2348_setup(void)
97 +{
98 + platform_device_register(&avila_npeb_device);
99 + platform_device_register(&avila_npec_device);
100 +}
101 +
102 +static void __init avila_gw2353_setup(void)
103 +{
104 + platform_device_register(&avila_npeb_device);
105 +}
106 +
107 +static void __init avila_gw2355_setup(void)
108 +{
109 + avila_npeb_data.phy = IXP4XX_ETH_PHY_MAX_ADDR;
110 + avila_npeb_data.phy_mask = 0x1e; /* ports 1-4 of the KS8995 switch */
111 + platform_device_register(&avila_npeb_device);
112 +
113 + avila_npec_data.phy = 16;
114 + platform_device_register(&avila_npec_device);
115 +}
116 +
117 +static void __init avila_gw2357_setup(void)
118 +{
119 + platform_device_register(&avila_npeb_device);
120 +}
121 +
122 +static struct avila_board_info avila_boards[] __initdata = {
123 + {
124 + .model = "GW2342",
125 + .setup = avila_gw2342_setup,
126 + }, {
127 + .model = "GW2345",
128 + .setup = avila_gw2345_setup,
129 + }, {
130 + .model = "GW2347",
131 + .setup = avila_gw2347_setup,
132 + }, {
133 + .model = "GW2348",
134 + .setup = avila_gw2348_setup,
135 + }, {
136 + .model = "GW2353",
137 + .setup = avila_gw2353_setup,
138 + }, {
139 + .model = "GW2355",
140 + .setup = avila_gw2355_setup,
141 + }, {
142 + .model = "GW2357",
143 + .setup = avila_gw2357_setup,
144 + }
145 +};
146 +
147 +static struct avila_board_info * __init avila_find_board_info(char *model)
148 +{
149 + int i;
150 +
151 + for (i = 0; i < ARRAY_SIZE(avila_boards); i++) {
152 + struct avila_board_info *info = &avila_boards[i];
153 + if (strcmp(info->model, model) == 0)
154 + return info;
155 + }
156 +
157 + return NULL;
158 +}
159 +
160 +static struct memory_accessor *at24_mem_acc;
161 +
162 +static int at24_setup(struct memory_accessor *mem_acc, void *context)
163 +{
164 + char mac_addr[ETH_ALEN];
165 + char model[6];
166 +
167 + at24_mem_acc = mem_acc;
168 +
169 + /* Read MAC addresses */
170 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x0, 6) == 6) {
171 + memcpy(&avila_npeb_data.hwaddr, mac_addr, ETH_ALEN);
172 + }
173 + if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x6, 6) == 6) {
174 + memcpy(&avila_npec_data.hwaddr, mac_addr, ETH_ALEN);
175 + }
176 +
177 + /* Read the first 6 bytes of the model number */
178 + if (at24_mem_acc->read(at24_mem_acc, model, 0x20, 6) == 6) {
179 + avila_info = avila_find_board_info(model);
180 + }
181 +
182 + return 0;
183 +}
184 +
185 +static struct at24_platform_data avila_eeprom_info = {
186 + .byte_len = 1024,
187 + .page_size = 16,
188 + .flags = AT24_FLAG_READONLY,
189 + .setup = at24_setup,
190 +};
191 +
192 +static struct i2c_board_info __initdata avila_i2c_board_info[] = {
193 + {
194 + I2C_BOARD_INFO("ds1672", 0x68),
195 + },
196 + {
197 + I2C_BOARD_INFO("ad7418", 0x28),
198 + },
199 + {
200 + I2C_BOARD_INFO("24c08", 0x51),
201 + .platform_data = &avila_eeprom_info
202 + },
203 +};
204 +
205 static void __init avila_init(void)
206 {
207 ixp4xx_sys_init();
208
209 + /*
210 + * These devices are present on all Avila models and don't need any
211 + * model specific setup.
212 + */
213 avila_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
214 avila_flash_resource.end =
215 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
216 @@ -159,7 +337,28 @@ static void __init avila_init(void)
217
218 platform_device_register(&avila_pata);
219
220 + i2c_register_board_info(0, avila_i2c_board_info,
221 + ARRAY_SIZE(avila_i2c_board_info));
222 +}
223 +
224 +static int __init avila_model_setup(void)
225 +{
226 + if (!machine_is_avila())
227 + return 0;
228 +
229 + if (avila_info) {
230 + printk(KERN_DEBUG "Running on Gateworks Avila %s\n",
231 + avila_info->model);
232 + avila_info->setup();
233 + } else {
234 + printk(KERN_INFO "Unknown/missing Avila model number"
235 + " -- defaults will be used\n");
236 + avila_gw23xx_setup();
237 + }
238 +
239 + return 0;
240 }
241 +late_initcall(avila_model_setup);
242
243 MACHINE_START(AVILA, "Gateworks Avila Network Platform")
244 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
This page took 0.050932 seconds and 5 git commands to generate.