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