brcm63xx: Add fallback sprom for CT5361_CT5621
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-3.14 / 534-board_hw556.patch
1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -12,6 +12,7 @@
4 #include <linux/string.h>
5 #include <linux/gpio_keys.h>
6 #include <linux/input.h>
7 +#include <linux/pci_ids.h>
8 #include <linux/platform_device.h>
9 #include <linux/spi/spi.h>
10 #include <linux/spi/spi_gpio.h>
11 @@ -1821,6 +1822,492 @@ static struct board_info __initdata boar
12 },
13 };
14
15 +static struct board_info __initdata board_HW556 = {
16 + .name = "HW556",
17 + .expected_cpu_id = 0x6358,
18 +
19 + .has_uart0 = 1,
20 + .has_pci = 1,
21 + .has_ohci0 = 1,
22 + .has_ehci0 = 1,
23 + .num_usbh_ports = 2,
24 +
25 + .has_caldata = 1,
26 + .caldata = {
27 + {
28 + .caldata_offset = 0xe00000,
29 + },
30 + },
31 +
32 + .has_enet1 = 1,
33 + .enet1 = {
34 + .has_phy = 1,
35 + .phy_id = 0,
36 + .force_speed_100 = 1,
37 + .force_duplex_full = 1,
38 + },
39 +
40 + .leds = {
41 + {
42 + .name = "HW556:red:message",
43 + .gpio = 0,
44 + .active_low = 1,
45 + },
46 + {
47 + .name = "HW556:red:hspa",
48 + .gpio = 1,
49 + .active_low = 1,
50 + },
51 + {
52 + .name = "HW556:red:dsl",
53 + .gpio = 2,
54 + .active_low = 1,
55 + },
56 + {
57 + .name = "HW556:red:power",
58 + .gpio = 3,
59 + .active_low = 1,
60 + .default_trigger = "default-on",
61 + },
62 + {
63 + .name = "HW556:red:all",
64 + .gpio = 6,
65 + .active_low = 1,
66 + .default_trigger = "default-on",
67 + },
68 + },
69 +
70 + .buttons = {
71 + {
72 + .desc = "help",
73 + .gpio = 8,
74 + .active_low = 1,
75 + .type = EV_KEY,
76 + .code = KEY_HELP,
77 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
78 + },
79 + {
80 + .desc = "wlan",
81 + .gpio = 9,
82 + .active_low = 1,
83 + .type = EV_KEY,
84 + .code = KEY_WLAN,
85 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
86 + },
87 + {
88 + .desc = "restart",
89 + .gpio = 10,
90 + .active_low = 1,
91 + .type = EV_KEY,
92 + .code = KEY_RESTART,
93 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
94 + },
95 + {
96 + .desc = "reset",
97 + .gpio = 11,
98 + .active_low = 1,
99 + .type = EV_KEY,
100 + .code = KEY_CONFIG,
101 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
102 + },
103 + },
104 +};
105 +static struct board_info __initdata board_HW556_A = {
106 + .name = "HW556_A",
107 + .expected_cpu_id = 0x6358,
108 +
109 + .has_uart0 = 1,
110 + .has_pci = 1,
111 + .has_ohci0 = 1,
112 + .has_ehci0 = 1,
113 + .num_usbh_ports = 2,
114 +
115 + .has_caldata = 1,
116 + .caldata = {
117 + {
118 + .vendor = PCI_VENDOR_ID_RALINK,
119 + .caldata_offset = 0xeffe00,
120 + .slot = 1,
121 + .eeprom = "rt2x00.eeprom",
122 + },
123 + },
124 +
125 + .has_enet1 = 1,
126 + .enet1 = {
127 + .has_phy = 1,
128 + .phy_id = 0,
129 + .force_speed_100 = 1,
130 + .force_duplex_full = 1,
131 + },
132 +
133 + .leds = {
134 + {
135 + .name = "HW556:green:lan1",
136 + .gpio = 0,
137 + .active_low = 1,
138 + },
139 + {
140 + .name = "HW556:green:lan2",
141 + .gpio = 1,
142 + .active_low = 1,
143 + },
144 + {
145 + .name = "HW556:red:dsl",
146 + .gpio = 2,
147 + .active_low = 1,
148 + },
149 + {
150 + .name = "HW556:red:power",
151 + .gpio = 3,
152 + .active_low = 1,
153 + .default_trigger = "default-on",
154 + },
155 + {
156 + .name = "HW556:red:message",
157 + .gpio = 12,
158 + .active_low = 1,
159 + },
160 + {
161 + .name = "HW556:red:lan1",
162 + .gpio = 13,
163 + .active_low = 1,
164 + },
165 + {
166 + .name = "HW556:red:hspa",
167 + .gpio = 15,
168 + .active_low = 1,
169 + },
170 + {
171 + .name = "HW556:red:lan2",
172 + .gpio = 22,
173 + .active_low = 1,
174 + },
175 + {
176 + .name = "HW556:green:lan3",
177 + .gpio = 23,
178 + .active_low = 1,
179 + },
180 + {
181 + .name = "HW556:red:lan3",
182 + .gpio = 26,
183 + .active_low = 1,
184 + },
185 + {
186 + .name = "HW556:green:lan4",
187 + .gpio = 27,
188 + .active_low = 1,
189 + },
190 + {
191 + .name = "HW556:red:lan4",
192 + .gpio = 28,
193 + .active_low = 1,
194 + },
195 + },
196 +
197 + .buttons = {
198 + {
199 + .desc = "help",
200 + .gpio = 8,
201 + .active_low = 1,
202 + .type = EV_KEY,
203 + .code = KEY_HELP,
204 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
205 + },
206 + {
207 + .desc = "wlan",
208 + .gpio = 9,
209 + .active_low = 1,
210 + .type = EV_KEY,
211 + .code = KEY_WLAN,
212 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
213 + },
214 + {
215 + .desc = "restart",
216 + .gpio = 10,
217 + .active_low = 1,
218 + .type = EV_KEY,
219 + .code = KEY_RESTART,
220 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
221 + },
222 + {
223 + .desc = "reset",
224 + .gpio = 11,
225 + .active_low = 1,
226 + .type = EV_KEY,
227 + .code = KEY_CONFIG,
228 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
229 + },
230 + },
231 +};
232 +static struct board_info __initdata board_HW556_B = {
233 + .name = "HW556_B",
234 + .expected_cpu_id = 0x6358,
235 +
236 + .has_uart0 = 1,
237 + .has_pci = 1,
238 + .has_ohci0 = 1,
239 + .has_ehci0 = 1,
240 + .num_usbh_ports = 2,
241 +
242 + .has_caldata = 1,
243 + .caldata = {
244 + {
245 + .vendor = PCI_VENDOR_ID_ATHEROS,
246 + .caldata_offset = 0xf7e000,
247 + .slot = 1,
248 + .endian_check = 1,
249 + .led_pin = 2,
250 + },
251 + },
252 +
253 + .has_enet1 = 1,
254 + .enet1 = {
255 + .has_phy = 1,
256 + .phy_id = 0,
257 + .force_speed_100 = 1,
258 + .force_duplex_full = 1,
259 + },
260 +
261 + .leds = {
262 + {
263 + .name = "HW556:red:message",
264 + .gpio = 0,
265 + .active_low = 1,
266 + },
267 + {
268 + .name = "HW556:red:hspa",
269 + .gpio = 1,
270 + .active_low = 1,
271 + },
272 + {
273 + .name = "HW556:red:dsl",
274 + .gpio = 2,
275 + .active_low = 1,
276 + },
277 + {
278 + .name = "HW556:red:power",
279 + .gpio = 3,
280 + .active_low = 1,
281 + .default_trigger = "default-on",
282 + },
283 + {
284 + .name = "HW556:red:all",
285 + .gpio = 6,
286 + .active_low = 1,
287 + .default_trigger = "default-on",
288 + },
289 + {
290 + .name = "HW556:green:lan1",
291 + .gpio = 12,
292 + .active_low = 1,
293 + },
294 + {
295 + .name = "HW556:red:lan1",
296 + .gpio = 13,
297 + .active_low = 1,
298 + },
299 + {
300 + .name = "HW556:green:lan2",
301 + .gpio = 15,
302 + .active_low = 1,
303 + },
304 + {
305 + .name = "HW556:red:lan2",
306 + .gpio = 22,
307 + .active_low = 1,
308 + },
309 + {
310 + .name = "HW556:green:lan3",
311 + .gpio = 23,
312 + .active_low = 1,
313 + },
314 + {
315 + .name = "HW556:red:lan3",
316 + .gpio = 26,
317 + .active_low = 1,
318 + },
319 + {
320 + .name = "HW556:green:lan4",
321 + .gpio = 27,
322 + .active_low = 1,
323 + },
324 + {
325 + .name = "HW556:red:lan4",
326 + .gpio = 28,
327 + .active_low = 1,
328 + },
329 + },
330 +
331 + .buttons = {
332 + {
333 + .desc = "help",
334 + .gpio = 8,
335 + .active_low = 1,
336 + .type = EV_KEY,
337 + .code = KEY_HELP,
338 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
339 + },
340 + {
341 + .desc = "wlan",
342 + .gpio = 9,
343 + .active_low = 1,
344 + .type = EV_KEY,
345 + .code = KEY_WLAN,
346 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
347 + },
348 + {
349 + .desc = "restart",
350 + .gpio = 10,
351 + .active_low = 1,
352 + .type = EV_KEY,
353 + .code = KEY_RESTART,
354 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
355 + },
356 + {
357 + .desc = "reset",
358 + .gpio = 11,
359 + .active_low = 1,
360 + .type = EV_KEY,
361 + .code = KEY_CONFIG,
362 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
363 + },
364 + },
365 +};
366 +static struct board_info __initdata board_HW556_C = {
367 + .name = "HW556_C",
368 + .expected_cpu_id = 0x6358,
369 +
370 + .has_uart0 = 1,
371 + .has_pci = 1,
372 + .has_ohci0 = 1,
373 + .has_ehci0 = 1,
374 + .num_usbh_ports = 2,
375 +
376 + .has_caldata = 1,
377 + .caldata = {
378 + {
379 + .vendor = PCI_VENDOR_ID_ATHEROS,
380 + .caldata_offset = 0xefe000,
381 + .slot = 1,
382 + .endian_check = 1,
383 + .led_pin = 2,
384 + },
385 + },
386 +
387 + .has_enet1 = 1,
388 + .enet1 = {
389 + .has_phy = 1,
390 + .phy_id = 0,
391 + .force_speed_100 = 1,
392 + .force_duplex_full = 1,
393 + },
394 +
395 + .leds = {
396 + {
397 + .name = "HW556:red:message",
398 + .gpio = 0,
399 + .active_low = 1,
400 + },
401 + {
402 + .name = "HW556:red:hspa",
403 + .gpio = 1,
404 + .active_low = 1,
405 + },
406 + {
407 + .name = "HW556:red:dsl",
408 + .gpio = 2,
409 + .active_low = 1,
410 + },
411 + {
412 + .name = "HW556:red:power",
413 + .gpio = 3,
414 + .active_low = 1,
415 + .default_trigger = "default-on",
416 + },
417 + {
418 + .name = "HW556:red:all",
419 + .gpio = 6,
420 + .active_low = 1,
421 + .default_trigger = "default-on",
422 + },
423 + {
424 + .name = "HW556:green:lan1",
425 + .gpio = 12,
426 + .active_low = 1,
427 + },
428 + {
429 + .name = "HW556:red:lan1",
430 + .gpio = 13,
431 + .active_low = 1,
432 + },
433 + {
434 + .name = "HW556:green:lan2",
435 + .gpio = 15,
436 + .active_low = 1,
437 + },
438 + {
439 + .name = "HW556:red:lan2",
440 + .gpio = 22,
441 + .active_low = 1,
442 + },
443 + {
444 + .name = "HW556:green:lan3",
445 + .gpio = 23,
446 + .active_low = 1,
447 + },
448 + {
449 + .name = "HW556:red:lan3",
450 + .gpio = 26,
451 + .active_low = 1,
452 + },
453 + {
454 + .name = "HW556:green:lan4",
455 + .gpio = 27,
456 + .active_low = 1,
457 + },
458 + {
459 + .name = "HW556:red:lan4",
460 + .gpio = 28,
461 + .active_low = 1,
462 + },
463 + },
464 +
465 + .buttons = {
466 + {
467 + .desc = "help",
468 + .gpio = 8,
469 + .active_low = 1,
470 + .type = EV_KEY,
471 + .code = KEY_HELP,
472 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
473 + },
474 + {
475 + .desc = "wlan",
476 + .gpio = 9,
477 + .active_low = 1,
478 + .type = EV_KEY,
479 + .code = KEY_WLAN,
480 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
481 + },
482 + {
483 + .desc = "restart",
484 + .gpio = 10,
485 + .active_low = 1,
486 + .type = EV_KEY,
487 + .code = KEY_RESTART,
488 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
489 + },
490 + {
491 + .desc = "reset",
492 + .gpio = 11,
493 + .active_low = 1,
494 + .type = EV_KEY,
495 + .code = KEY_CONFIG,
496 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
497 + },
498 + },
499 +};
500 +
501 /* T-Home Speedport W 303V Typ B */
502 static struct board_info __initdata board_spw303v = {
503 .name = "96358-502V",
504 @@ -3350,6 +3837,10 @@ static const struct board_info __initcon
505 &board_nb4_fxc_r2,
506 &board_ct6373_1,
507 &board_HW553,
508 + &board_HW556,
509 + &board_HW556_A,
510 + &board_HW556_B,
511 + &board_HW556_C,
512 &board_spw303v,
513 &board_DVAG3810BN,
514 #endif
515 @@ -3369,13 +3860,37 @@ static void __init boardid_fixup(u8 *boo
516 struct bcm_tag *tag = (struct bcm_tag *)(boot_addr + CFE_OFFSET_64K);
517 char *board_name = (char *)bcm63xx_nvram_get_name();
518
519 - if (BCMCPU_IS_6358() && (!strcmp(board_name, "96358VW"))) {
520 - u8 *p = boot_addr + NB4_PID_OFFSET;
521 -
522 - /* Extract nb4 PID */
523 - if (!memcmp(p, "NB4-", 4)) {
524 - memcpy(board_name, p, sizeof("NB4-XXX-rX"));
525 - return;
526 + if (BCMCPU_IS_6358()) {
527 + if (!strcmp(board_name, "96358VW")) {
528 + u8 *p = boot_addr + NB4_PID_OFFSET;
529 +
530 + /* Extract nb4 PID */
531 + if (!memcmp(p, "NB4-", 4)) {
532 + memcpy(board_name, p, sizeof("NB4-XXX-rX"));
533 + return;
534 + }
535 + } else if (!strcmp(board_name, "HW556")) {
536 + /*
537 + * HW556 has different wlan caldatas depending on
538 + * hardware version.
539 + * Detect hardware version and change board id
540 + */
541 + u8 cal_data_ath9k[4] = { 0xa5, 0x5a, 0, 0 };
542 + u8 cal_data_rt3062[4] = { 0x62, 0x30, 1, 0 };
543 +
544 + if (!memcmp(boot_addr + 0xeffe00,
545 + &cal_data_rt3062, 4)) {
546 + /* Ralink 0xeffe00 */
547 + memcpy(board_name, "HW556_A", 7);
548 + } else if (!memcmp(boot_addr + 0xf7e000,
549 + &cal_data_ath9k, 4)) {
550 + /* Atheros 0xf7e000 */
551 + memcpy(board_name, "HW556_B", 7);
552 + } else if (!memcmp(boot_addr + 0xefe000,
553 + &cal_data_ath9k, 4)) {
554 + /* Atheros 0xefe000 */
555 + memcpy(board_name, "HW556_C", 7);
556 + }
557 }
558 }
559
560 --- a/drivers/mtd/bcm63xxpart.c
561 +++ b/drivers/mtd/bcm63xxpart.c
562 @@ -70,6 +70,11 @@ static int bcm63xx_parse_cfe_partitions(
563 BCM63XX_CFE_BLOCK_SIZE);
564
565 cfelen = cfe_erasesize;
566 +
567 + /* Fix HW556 MX29LV128DB */
568 + if (!strncmp(bcm63xx_nvram_get_name(), "HW556", 5))
569 + cfelen = 0x20000;
570 +
571 nvramlen = bcm63xx_nvram_get_psi_size() * SZ_1K;
572 nvramlen = roundup(nvramlen, cfe_erasesize);
573 nvramaddr = master->size - nvramlen;