2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
9 #include <linux/init.h>
10 #include <linux/platform_device.h>
11 #include <linux/leds.h>
12 #include <linux/gpio.h>
13 #include <linux/gpio_buttons.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/input.h>
18 #include <linux/etherdevice.h>
19 #include <linux/ath5k_platform.h>
20 #include <linux/pci.h>
22 #include <lantiq_soc.h>
23 #include <lantiq_platform.h>
24 #include <dev-gpio-leds.h>
25 #include <dev-gpio-buttons.h>
27 #include "../machtypes.h"
28 #include "dev-wifi-rt2x00.h"
29 #include "dev-wifi-ath5k.h"
31 #include "dev-dwc_otg.h"
33 static struct mtd_partition arv4510_partitions[] =
51 .name = "board_config",
57 static struct mtd_partition arv45xx_partitions[] =
75 .name = "board_config",
81 static struct mtd_partition arv45xx_brnboot_partitions[] =
99 .name = "reserved", /* 12-byte signature at 0x3efff4 :/ */
110 static struct mtd_partition arv7525_partitions[] =
128 .name = "board_config",
134 static struct mtd_partition arv75xx_partitions[] =
152 .name = "board_config",
158 static struct physmap_flash_data arv4510_flash_data = {
159 .nr_parts = ARRAY_SIZE(arv4510_partitions),
160 .parts = arv4510_partitions,
163 static struct physmap_flash_data arv45xx_flash_data = {
164 .nr_parts = ARRAY_SIZE(arv45xx_partitions),
165 .parts = arv45xx_partitions,
168 static struct physmap_flash_data arv45xx_brnboot_flash_data = {
169 .nr_parts = ARRAY_SIZE(arv45xx_brnboot_partitions),
170 .parts = arv45xx_brnboot_partitions,
173 static struct physmap_flash_data arv7525_flash_data = {
174 .nr_parts = ARRAY_SIZE(arv7525_partitions),
175 .parts = arv7525_partitions,
178 static struct physmap_flash_data arv75xx_flash_data = {
179 .nr_parts = ARRAY_SIZE(arv75xx_partitions),
180 .parts = arv75xx_partitions,
183 static struct ltq_pci_data ltq_pci_data = {
184 .clock = PCI_CLOCK_EXT,
185 .gpio = PCI_GNT1 | PCI_REQ1,
187 [14] = INT_NUM_IM0_IRL0 + 22,
191 static struct ltq_eth_data ltq_eth_data = {
192 .mii_mode = PHY_INTERFACE_MODE_RMII,
195 static struct gpio_led
196 arv4510pw_gpio_leds[] __initdata = {
197 { .name = "soc:green:foo", .gpio = 4, .active_low = 1, },
200 static struct gpio_led
201 arv4518pw_gpio_leds[] __initdata = {
202 { .name = "soc:green:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" },
203 { .name = "soc:green:adsl", .gpio = 4, .active_low = 1, .default_trigger = "default-on" },
204 { .name = "soc:green:internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" },
205 { .name = "soc:green:wifi", .gpio = 6, .active_low = 1, .default_trigger = "default-on" },
206 { .name = "soc:yellow:wps", .gpio = 7, .active_low = 1, .default_trigger = "default-on" },
207 { .name = "soc:red:fail", .gpio = 8, .active_low = 1, .default_trigger = "default-on" },
208 { .name = "soc:green:usb", .gpio = 19, .active_low = 1, .default_trigger = "default-on" },
209 { .name = "soc:green:voip", .gpio = 100, .active_low = 1, .default_trigger = "default-on" },
210 { .name = "soc:green:fxs1", .gpio = 101, .active_low = 1, .default_trigger = "default-on" },
211 { .name = "soc:green:fxs2", .gpio = 102, .active_low = 1, .default_trigger = "default-on" },
212 { .name = "soc:green:fxo", .gpio = 103, .active_low = 1, .default_trigger = "default-on" },
215 static struct gpio_keys_button
216 arv4518pw_gpio_keys[] __initdata = {
221 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
229 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
237 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
243 static struct gpio_led
244 arv4520pw_gpio_leds[] __initdata = {
245 { .name = "soc:blue:power", .gpio = 3, .active_low = 1, },
246 { .name = "soc:blue:adsl", .gpio = 4, .active_low = 1, },
247 { .name = "soc:blue:internet", .gpio = 5, .active_low = 1, },
248 { .name = "soc:red:power", .gpio = 6, .active_low = 1, },
249 { .name = "soc:yellow:wps", .gpio = 7, .active_low = 1, },
250 { .name = "soc:red:wps", .gpio = 9, .active_low = 1, },
251 { .name = "soc:blue:voip", .gpio = 100, .active_low = 1, },
252 { .name = "soc:blue:fxs1", .gpio = 101, .active_low = 1, },
253 { .name = "soc:blue:fxs2", .gpio = 102, .active_low = 1, },
254 { .name = "soc:blue:fxo", .gpio = 103, .active_low = 1, },
255 { .name = "soc:blue:voice", .gpio = 104, .active_low = 1, },
256 { .name = "soc:blue:usb", .gpio = 105, .active_low = 1, },
257 { .name = "soc:blue:wifi", .gpio = 106, .active_low = 1, },
260 static struct gpio_led
261 arv452cpw_gpio_leds[] __initdata = {
262 { .name = "soc:blue:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" },
263 { .name = "soc:blue:adsl", .gpio = 4, .active_low = 1, .default_trigger = "default-on" },
264 { .name = "soc:blue:isdn", .gpio = 5, .active_low = 1, .default_trigger = "default-on" },
265 { .name = "soc:red:power", .gpio = 6, .active_low = 1, .default_trigger = "default-on" },
266 { .name = "soc:yellow:wps", .gpio = 7, .active_low = 1, .default_trigger = "default-on" },
267 { .name = "soc:red:wps", .gpio = 9, .active_low = 1, .default_trigger = "default-on" },
268 { .name = "soc:blue:fxs1", .gpio = 100, .active_low = 1, .default_trigger = "default-on" },
269 { .name = "soc:blue:fxs2", .gpio = 101, .active_low = 1, .default_trigger = "default-on" },
270 { .name = "soc:blue:wps", .gpio = 102, .active_low = 1, .default_trigger = "default-on" },
271 { .name = "soc:blue:fxo", .gpio = 103, .active_low = 1, .default_trigger = "default-on" },
272 { .name = "soc:blue:voice", .gpio = 104, .active_low = 1, .default_trigger = "default-on" },
273 { .name = "soc:blue:usb", .gpio = 105, .active_low = 1, .default_trigger = "default-on" },
274 { .name = "soc:blue:wifi", .gpio = 106, .active_low = 1, .default_trigger = "default-on" },
275 { .name = "soc:blue:internet", .gpio = 108, .active_low = 1, .default_trigger = "default-on" },
276 { .name = "soc:red:internet", .gpio = 109, .active_low = 1, .default_trigger = "default-on" },
279 static struct gpio_led
280 arv4525pw_gpio_leds[] __initdata = {
281 { .name = "soc:green:dsl", .gpio = 6, .active_low = 1, .default_trigger = "default-on" },
282 { .name = "soc:green:wifi", .gpio = 8, .active_low = 1, .default_trigger = "default-on" },
283 { .name = "soc:green:online", .gpio = 9, .active_low = 1, .default_trigger = "default-on" },
284 { .name = "soc:green:fxs-internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" },
285 { .name = "soc:green:fxs-festnetz", .gpio = 4, .active_low = 1, .default_trigger = "default-on" },
288 #define ARV4525PW_PHYRESET 13
289 #define ARV4525PW_RELAY 31
291 static struct gpio arv4525pw_gpios[] __initdata = {
292 { ARV4525PW_PHYRESET, GPIOF_OUT_INIT_HIGH, "phyreset" },
293 { ARV4525PW_RELAY, GPIOF_OUT_INIT_HIGH, "relay" },
297 static struct gpio_led
298 arv752dpw22_gpio_leds[] __initdata = {
299 { .name = "soc:blue:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" },
300 { .name = "soc:red:internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" },
301 { .name = "soc:red:power", .gpio = 6, .active_low = 1, .default_trigger = "default-on" },
302 { .name = "soc:red:wps", .gpio = 8, .active_low = 1, .default_trigger = "default-on" },
303 { .name = "soc:red:fxo", .gpio = 103, .active_low = 1, .default_trigger = "default-on" },
304 { .name = "soc:red:voice", .gpio = 104, .active_low = 1, .default_trigger = "default-on" },
305 { .name = "soc:green:usb", .gpio = 105, .active_low = 1, .default_trigger = "default-on" },
306 { .name = "soc:green:wifi", .gpio = 106, .active_low = 1, .default_trigger = "default-on" },
307 { .name = "soc:green:wifi1", .gpio = 107, .active_low = 1, .default_trigger = "default-on" },
308 { .name = "soc:blue:wifi", .gpio = 108, .active_low = 1, .default_trigger = "default-on" },
309 { .name = "soc:blue:wifi1", .gpio = 109, .active_low = 1, .default_trigger = "default-on" },
310 { .name = "soc:green:eth1", .gpio = 111, .active_low = 1, .default_trigger = "default-on" },
311 { .name = "soc:green:eth2", .gpio = 112, .active_low = 1, .default_trigger = "default-on" },
312 { .name = "soc:green:eth3", .gpio = 113, .active_low = 1, .default_trigger = "default-on" },
313 { .name = "soc:green:eth4", .gpio = 114, .active_low = 1, .default_trigger = "default-on", },
316 static struct gpio_keys_button
317 arv752dpw22_gpio_keys[] __initdata = {
322 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
330 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
338 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
344 static struct gpio_led
345 arv7518pw_gpio_leds[] __initdata = {
346 { .name = "soc:green:power", .gpio = 2, .active_low = 1, },
347 { .name = "soc:green:adsl", .gpio = 4, .active_low = 1, },
348 { .name = "soc:green:internet", .gpio = 5, .active_low = 1, },
349 { .name = "soc:green:wifi", .gpio = 6, .active_low = 1, },
350 { .name = "soc:red:internet", .gpio = 8, .active_low = 1, },
351 { .name = "soc:green:usb", .gpio = 19, .active_low = 1, },
354 static struct gpio_keys_button
355 arv7518pw_gpio_keys[] __initdata = {
360 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
368 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
374 static struct gpio_keys_button
375 arv7525pw_gpio_keys[] __initdata = {
380 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
387 arv45xx_register_ethernet(void)
389 #define ARV45XX_BRN_MAC 0x3f0016
390 memcpy_fromio(<q_eth_data.mac.sa_data,
391 (void *)KSEG1ADDR(LTQ_FLASH_START + ARV45XX_BRN_MAC), 6);
392 ltq_register_etop(<q_eth_data);
396 arv75xx_register_ethernet(void)
398 #define ARV75XX_BRN_MAC 0x7f0016
399 memcpy_fromio(<q_eth_data.mac.sa_data,
400 (void *)KSEG1ADDR(LTQ_FLASH_START + ARV75XX_BRN_MAC), 6);
401 ltq_register_etop(<q_eth_data);
405 bewan_register_ethernet(void)
407 #define BEWAN_BRN_MAC 0x3f0014
408 memcpy_fromio(<q_eth_data.mac.sa_data,
409 (void *)KSEG1ADDR(LTQ_FLASH_START + BEWAN_BRN_MAC), 6);
410 ltq_register_etop(<q_eth_data);
413 static u16 arv45xx_ath5k_eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS];
414 static u8 arv45xx_ath5k_eeprom_mac[6];
417 arv45xx_register_ath5k(void)
419 #define ARV45XX_BRN_ATH 0x3f0478
421 static u16 eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS];
422 u32 *p = (u32*)arv45xx_ath5k_eeprom_data;
424 memcpy_fromio(arv45xx_ath5k_eeprom_mac,
425 (void *)KSEG1ADDR(LTQ_FLASH_START + ARV45XX_BRN_MAC), 6);
426 arv45xx_ath5k_eeprom_mac[5]++;
427 memcpy_fromio(arv45xx_ath5k_eeprom_data,
428 (void *)KSEG1ADDR(LTQ_FLASH_START + ARV45XX_BRN_ATH), ATH5K_PLAT_EEP_MAX_WORDS);
430 for (i = 0; i < ATH5K_PLAT_EEP_MAX_WORDS>>1; i++){
431 //arv4518_ath5k_eeprom_data[i] = ((eeprom_data[i]&0xff)<<8)|((eeprom_data[i]&0xff00)>>8);
432 p[i] = ((eeprom_data[(i<<1)+1]&0xff)<<24)|((eeprom_data[(i<<1)+1]&0xff00)<<8)|((eeprom_data[i<<1]&0xff)<<8)|((eeprom_data[i<<1]&0xff00)>>8);
434 // printk ("regdomain: 0x%x --> 0x%x\n", p[i], (p[i] & 0xffff0000)|0x67);
435 /* regdomain is invalid?? how did original fw convert
437 * for now, force to 0x67 */
447 ltq_register_gpio_stp();
448 //ltq_add_device_gpio_leds(arv3527p_gpio_leds, ARRAY_SIZE(arv3527p_gpio_leds));
449 ltq_register_nor(&arv45xx_flash_data);
450 arv45xx_register_ethernet();
453 MIPS_MACHINE(LANTIQ_MACH_ARV3527P,
455 "ARV3527P - Arcor Easybox 401",
461 ltq_register_gpio_stp();
462 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4510pw_gpio_leds), arv4510pw_gpio_leds);
463 ltq_register_nor(&arv4510_flash_data);
464 ltq_pci_data.irq[12] = (INT_NUM_IM2_IRL0 + 31);
465 ltq_pci_data.irq[15] = (INT_NUM_IM0_IRL0 + 26);
466 ltq_pci_data.gpio |= PCI_EXIN2 | PCI_REQ2;
467 ltq_register_pci(<q_pci_data);
468 bewan_register_ethernet();
471 MIPS_MACHINE(LANTIQ_MACH_ARV4510PW,
473 "ARV4510PW - Wippies Homebox",
479 #define ARV4518PW_EBU 0
480 #define ARV4518PW_USB 14
481 #define ARV4518PW_SWITCH_RESET 13
482 #define ARV4518PW_MADWIFI_ADDR 0xb07f0400
484 ltq_register_gpio_ebu(ARV4518PW_EBU);
485 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4518pw_gpio_leds), arv4518pw_gpio_leds);
486 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL,
487 ARRAY_SIZE(arv4518pw_gpio_keys), arv4518pw_gpio_keys);
488 ltq_register_nor(&arv45xx_flash_data);
489 ltq_pci_data.gpio = PCI_GNT2 | PCI_REQ2;
490 ltq_register_pci(<q_pci_data);
491 ltq_register_madwifi_eep(ARV4518PW_MADWIFI_ADDR);
492 ltq_register_ath5k(arv45xx_ath5k_eeprom_data, arv45xx_ath5k_eeprom_mac);
493 xway_register_dwc(ARV4518PW_USB);
494 arv45xx_register_ethernet();
496 gpio_request(ARV4518PW_SWITCH_RESET, "switch");
497 gpio_direction_output(ARV4518PW_SWITCH_RESET, 1);
498 gpio_export(ARV4518PW_SWITCH_RESET, 0);
501 MIPS_MACHINE(LANTIQ_MACH_ARV4518PW,
503 "ARV4518PW - SMC7908A-ISP, Airties WAV-221",
509 #define ARV4520PW_EBU 0x400
510 #define ARV4520PW_USB 28
511 #define ARV4520PW_SWITCH_RESET 110
513 ltq_register_gpio_ebu(ARV4520PW_EBU);
514 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4520pw_gpio_leds), arv4520pw_gpio_leds);
515 ltq_register_nor(&arv45xx_flash_data);
516 ltq_register_pci(<q_pci_data);
518 arv45xx_register_ethernet();
519 xway_register_dwc(ARV4520PW_USB);
521 gpio_request(ARV4520PW_SWITCH_RESET, "switch");
522 gpio_set_value(ARV4520PW_SWITCH_RESET, 1);
525 MIPS_MACHINE(LANTIQ_MACH_ARV4520PW,
527 "ARV4520PW - Airties WAV-281, Arcor A800",
533 #define ARV452CPW_EBU 0x77f
534 #define ARV452CPW_USB 28
535 #define ARV452CPW_RELAY1 31
536 #define ARV452CPW_RELAY2 107
537 #define ARV452CPW_SWITCH_RESET 110
538 #define ARV452CPW_MADWIFI_ADDR 0xb07f0400
540 ltq_register_gpio_ebu(ARV452CPW_EBU);
541 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv452cpw_gpio_leds), arv452cpw_gpio_leds);
542 ltq_register_nor(&arv45xx_flash_data);
543 ltq_register_pci(<q_pci_data);
544 ltq_register_madwifi_eep(ARV452CPW_MADWIFI_ADDR);
545 xway_register_dwc(ARV452CPW_USB);
546 arv45xx_register_ethernet();
547 arv45xx_register_ath5k();
549 gpio_request(ARV452CPW_SWITCH_RESET, "switch");
550 gpio_set_value(ARV452CPW_SWITCH_RESET, 1);
551 gpio_export(ARV452CPW_SWITCH_RESET, 0);
553 gpio_request(ARV452CPW_RELAY1, "relay1");
554 gpio_direction_output(ARV452CPW_RELAY1, 1);
555 gpio_export(ARV452CPW_RELAY1, 0);
557 gpio_request(ARV452CPW_RELAY2, "relay2");
558 gpio_set_value(ARV452CPW_RELAY2, 1);
559 gpio_export(ARV452CPW_RELAY2, 0);
562 MIPS_MACHINE(LANTIQ_MACH_ARV452CPW,
564 "ARV452CPW - Arcor A801",
570 #define ARV4525PW_MADWIFI_ADDR 0xb03f0400
572 ltq_register_nor(&arv45xx_brnboot_flash_data);
574 ltq_register_nor(&arv45xx_flash_data);
576 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds), arv4525pw_gpio_leds);
577 gpio_request_array(arv4525pw_gpios, ARRAY_SIZE(arv4525pw_gpios));
578 gpio_export(ARV4525PW_RELAY, false);
579 gpio_export(ARV4525PW_PHYRESET, false);
580 ltq_pci_data.clock = PCI_CLOCK_INT;
581 ltq_register_pci(<q_pci_data);
582 ltq_register_madwifi_eep(ARV4525PW_MADWIFI_ADDR);
583 arv45xx_register_ath5k();
584 ltq_register_ath5k(arv45xx_ath5k_eeprom_data, arv45xx_ath5k_eeprom_mac);
585 ltq_eth_data.mii_mode = PHY_INTERFACE_MODE_MII;
586 arv45xx_register_ethernet();
589 MIPS_MACHINE(LANTIQ_MACH_ARV4525PW,
591 "ARV4525PW - Speedport W502V",
597 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds), arv4525pw_gpio_leds);
598 ltq_register_nor(&arv7525_flash_data);
599 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL,
600 ARRAY_SIZE(arv7525pw_gpio_keys), arv7525pw_gpio_keys);
601 ltq_pci_data.clock = PCI_CLOCK_INT;
602 ltq_pci_data.gpio = PCI_GNT1 | PCI_EXIN1;
603 ltq_pci_data.irq[14] = (INT_NUM_IM3_IRL0 + 31);
604 ltq_register_pci(<q_pci_data);
605 ltq_eth_data.mii_mode = PHY_INTERFACE_MODE_MII;
606 ltq_register_rt2x00("RT2860.eeprom");
608 arv45xx_register_ethernet();
611 MIPS_MACHINE(LANTIQ_MACH_ARV7525PW,
613 "ARV7525PW - Speedport W303V",
619 #define ARV7518PW_EBU 0x2
620 #define ARV7518PW_USB 14
622 ltq_register_gpio_ebu(ARV7518PW_EBU);
623 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv7518pw_gpio_leds), arv7518pw_gpio_leds);
624 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL,
625 ARRAY_SIZE(arv7518pw_gpio_keys), arv7518pw_gpio_keys);
626 ltq_register_nor(&arv75xx_flash_data);
627 ltq_register_pci(<q_pci_data);
629 xway_register_dwc(ARV7518PW_USB);
630 arv75xx_register_ethernet();
631 //arv7518_register_ath9k(mac);
634 MIPS_MACHINE(LANTIQ_MACH_ARV7518PW,
636 "ARV7518PW - ASTORIA",
640 arv752dpw22_init(void)
642 #define ARV752DPW22_EBU 0x2
643 #define ARV752DPW22_USB 100
644 #define ARV752DPW22_RELAY 101
646 ltq_register_gpio_ebu(ARV752DPW22_EBU);
647 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv752dpw22_gpio_leds), arv752dpw22_gpio_leds);
648 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL,
649 ARRAY_SIZE(arv752dpw22_gpio_keys), arv752dpw22_gpio_keys);
650 ltq_register_nor(&arv75xx_flash_data);
651 ltq_pci_data.irq[15] = (INT_NUM_IM3_IRL0 + 31);
652 ltq_pci_data.gpio |= PCI_EXIN1 | PCI_REQ2;
653 ltq_register_pci(<q_pci_data);
654 xway_register_dwc(ARV752DPW22_USB);
655 arv75xx_register_ethernet();
657 gpio_request(ARV752DPW22_RELAY, "relay");
658 gpio_set_value(ARV752DPW22_RELAY, 1);
659 gpio_export(ARV752DPW22_RELAY, 0);
662 MIPS_MACHINE(LANTIQ_MACH_ARV752DPW22,
664 "ARV752DPW22 - Arcor A803",