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 arv7525_partitions
[] =
99 .name
= "board_config",
105 static struct mtd_partition arv75xx_partitions
[] =
123 .name
= "board_config",
129 static struct physmap_flash_data arv4510_flash_data
= {
130 .nr_parts
= ARRAY_SIZE(arv4510_partitions
),
131 .parts
= arv4510_partitions
,
134 static struct physmap_flash_data arv45xx_flash_data
= {
135 .nr_parts
= ARRAY_SIZE(arv45xx_partitions
),
136 .parts
= arv45xx_partitions
,
139 static struct physmap_flash_data arv7525_flash_data
= {
140 .nr_parts
= ARRAY_SIZE(arv7525_partitions
),
141 .parts
= arv7525_partitions
,
144 static struct physmap_flash_data arv75xx_flash_data
= {
145 .nr_parts
= ARRAY_SIZE(arv75xx_partitions
),
146 .parts
= arv75xx_partitions
,
149 static struct ltq_pci_data ltq_pci_data
= {
150 .clock
= PCI_CLOCK_EXT
,
151 .gpio
= PCI_GNT1
| PCI_REQ1
,
153 [14] = INT_NUM_IM0_IRL0
+ 22,
157 static struct ltq_eth_data ltq_eth_data
= {
158 .mii_mode
= PHY_INTERFACE_MODE_RMII
,
161 static struct gpio_led
162 arv4510pw_gpio_leds
[] __initdata
= {
163 { .name
= "soc:green:foo", .gpio
= 4, .active_low
= 1, },
166 static struct gpio_led
167 arv4518pw_gpio_leds
[] __initdata
= {
168 { .name
= "soc:green:power", .gpio
= 3, .active_low
= 1, .default_trigger
= "default-on" },
169 { .name
= "soc:green:adsl", .gpio
= 4, .active_low
= 1, .default_trigger
= "default-on" },
170 { .name
= "soc:green:internet", .gpio
= 5, .active_low
= 1, .default_trigger
= "default-on" },
171 { .name
= "soc:green:wifi", .gpio
= 6, .active_low
= 1, .default_trigger
= "default-on" },
172 { .name
= "soc:yellow:wps", .gpio
= 7, .active_low
= 1, .default_trigger
= "default-on" },
173 { .name
= "soc:red:fail", .gpio
= 8, .active_low
= 1, .default_trigger
= "default-on" },
174 { .name
= "soc:green:usb", .gpio
= 19, .active_low
= 1, .default_trigger
= "default-on" },
175 { .name
= "soc:green:voip", .gpio
= 100, .active_low
= 1, .default_trigger
= "default-on" },
176 { .name
= "soc:green:fxs1", .gpio
= 101, .active_low
= 1, .default_trigger
= "default-on" },
177 { .name
= "soc:green:fxs2", .gpio
= 102, .active_low
= 1, .default_trigger
= "default-on" },
178 { .name
= "soc:green:fxo", .gpio
= 103, .active_low
= 1, .default_trigger
= "default-on" },
181 static struct gpio_keys_button
182 arv4518pw_gpio_keys
[] __initdata
= {
187 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
195 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
203 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
209 static struct gpio_led
210 arv4520pw_gpio_leds
[] __initdata
= {
211 { .name
= "soc:blue:power", .gpio
= 3, .active_low
= 1, },
212 { .name
= "soc:blue:adsl", .gpio
= 4, .active_low
= 1, },
213 { .name
= "soc:blue:internet", .gpio
= 5, .active_low
= 1, },
214 { .name
= "soc:red:power", .gpio
= 6, .active_low
= 1, },
215 { .name
= "soc:yellow:wps", .gpio
= 7, .active_low
= 1, },
216 { .name
= "soc:red:wps", .gpio
= 9, .active_low
= 1, },
217 { .name
= "soc:blue:voip", .gpio
= 100, .active_low
= 1, },
218 { .name
= "soc:blue:fxs1", .gpio
= 101, .active_low
= 1, },
219 { .name
= "soc:blue:fxs2", .gpio
= 102, .active_low
= 1, },
220 { .name
= "soc:blue:fxo", .gpio
= 103, .active_low
= 1, },
221 { .name
= "soc:blue:voice", .gpio
= 104, .active_low
= 1, },
222 { .name
= "soc:blue:usb", .gpio
= 105, .active_low
= 1, },
223 { .name
= "soc:blue:wifi", .gpio
= 106, .active_low
= 1, },
226 static struct gpio_led
227 arv452cpw_gpio_leds
[] __initdata
= {
228 { .name
= "soc:blue:power", .gpio
= 3, .active_low
= 1, .default_trigger
= "default-on" },
229 { .name
= "soc:blue:adsl", .gpio
= 4, .active_low
= 1, .default_trigger
= "default-on" },
230 { .name
= "soc:blue:isdn", .gpio
= 5, .active_low
= 1, .default_trigger
= "default-on" },
231 { .name
= "soc:red:power", .gpio
= 6, .active_low
= 1, .default_trigger
= "default-on" },
232 { .name
= "soc:yellow:wps", .gpio
= 7, .active_low
= 1, .default_trigger
= "default-on" },
233 { .name
= "soc:red:wps", .gpio
= 9, .active_low
= 1, .default_trigger
= "default-on" },
234 { .name
= "soc:blue:fxs1", .gpio
= 100, .active_low
= 1, .default_trigger
= "default-on" },
235 { .name
= "soc:blue:fxs2", .gpio
= 101, .active_low
= 1, .default_trigger
= "default-on" },
236 { .name
= "soc:blue:wps", .gpio
= 102, .active_low
= 1, .default_trigger
= "default-on" },
237 { .name
= "soc:blue:fxo", .gpio
= 103, .active_low
= 1, .default_trigger
= "default-on" },
238 { .name
= "soc:blue:voice", .gpio
= 104, .active_low
= 1, .default_trigger
= "default-on" },
239 { .name
= "soc:blue:usb", .gpio
= 105, .active_low
= 1, .default_trigger
= "default-on" },
240 { .name
= "soc:blue:wifi", .gpio
= 106, .active_low
= 1, .default_trigger
= "default-on" },
241 { .name
= "soc:blue:internet", .gpio
= 108, .active_low
= 1, .default_trigger
= "default-on" },
242 { .name
= "soc:red:internet", .gpio
= 109, .active_low
= 1, .default_trigger
= "default-on" },
245 static struct gpio_led
246 arv4525pw_gpio_leds
[] __initdata
= {
247 { .name
= "soc:green:fxs1", .gpio
= 4, .active_low
= 1, .default_trigger
= "default-on" },
248 { .name
= "soc:green:fxs2", .gpio
= 5, .active_low
= 1, .default_trigger
= "default-on" },
249 { .name
= "soc:red:dsl", .gpio
= 6, .active_low
= 1, .default_trigger
= "default-on" },
250 { .name
= "soc:green:wifi", .gpio
= 8, .active_low
= 1, .default_trigger
= "default-on" },
251 { .name
= "soc:green:online", .gpio
= 9, .active_low
= 1, .default_trigger
= "default-on" },
254 static struct gpio_led
255 arv752dpw22_gpio_leds
[] __initdata
= {
256 { .name
= "soc:blue:power", .gpio
= 3, .active_low
= 1, .default_trigger
= "default-on" },
257 { .name
= "soc:red:internet", .gpio
= 5, .active_low
= 1, .default_trigger
= "default-on" },
258 { .name
= "soc:red:power", .gpio
= 6, .active_low
= 1, .default_trigger
= "default-on" },
259 { .name
= "soc:red:wps", .gpio
= 8, .active_low
= 1, .default_trigger
= "default-on" },
260 { .name
= "soc:red:fxo", .gpio
= 103, .active_low
= 1, .default_trigger
= "default-on" },
261 { .name
= "soc:red:voice", .gpio
= 104, .active_low
= 1, .default_trigger
= "default-on" },
262 { .name
= "soc:green:usb", .gpio
= 105, .active_low
= 1, .default_trigger
= "default-on" },
263 { .name
= "soc:green:wifi", .gpio
= 106, .active_low
= 1, .default_trigger
= "default-on" },
264 { .name
= "soc:green:wifi1", .gpio
= 107, .active_low
= 1, .default_trigger
= "default-on" },
265 { .name
= "soc:blue:wifi", .gpio
= 108, .active_low
= 1, .default_trigger
= "default-on" },
266 { .name
= "soc:blue:wifi1", .gpio
= 109, .active_low
= 1, .default_trigger
= "default-on" },
267 { .name
= "soc:green:eth1", .gpio
= 111, .active_low
= 1, .default_trigger
= "default-on" },
268 { .name
= "soc:green:eth2", .gpio
= 112, .active_low
= 1, .default_trigger
= "default-on" },
269 { .name
= "soc:green:eth3", .gpio
= 113, .active_low
= 1, .default_trigger
= "default-on" },
270 { .name
= "soc:green:eth4", .gpio
= 114, .active_low
= 1, .default_trigger
= "default-on", },
273 static struct gpio_keys_button
274 arv752dpw22_gpio_keys
[] __initdata
= {
279 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
287 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
295 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
301 static struct gpio_led
302 arv7518pw_gpio_leds
[] __initdata
= {
303 { .name
= "soc:green:power", .gpio
= 2, .active_low
= 1, },
304 { .name
= "soc:green:adsl", .gpio
= 4, .active_low
= 1, },
305 { .name
= "soc:green:internet", .gpio
= 5, .active_low
= 1, },
306 { .name
= "soc:green:wifi", .gpio
= 6, .active_low
= 1, },
307 { .name
= "soc:red:internet", .gpio
= 8, .active_low
= 1, },
308 { .name
= "soc:green:usb", .gpio
= 19, .active_low
= 1, },
311 static struct gpio_keys_button
312 arv7518pw_gpio_keys
[] __initdata
= {
317 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
325 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
331 static struct gpio_keys_button
332 arv7525pw_gpio_keys
[] __initdata
= {
337 .debounce_interval
= LTQ_KEYS_DEBOUNCE_INTERVAL
,
344 arv45xx_register_ethernet(void)
346 #define ARV45XX_BRN_MAC 0x3f0016
347 memcpy_fromio(<q_eth_data
.mac
.sa_data
,
348 (void *)KSEG1ADDR(LTQ_FLASH_START
+ ARV45XX_BRN_MAC
), 6);
349 ltq_register_etop(<q_eth_data
);
353 arv75xx_register_ethernet(void)
355 #define ARV75XX_BRN_MAC 0x7f0016
356 memcpy_fromio(<q_eth_data
.mac
.sa_data
,
357 (void *)KSEG1ADDR(LTQ_FLASH_START
+ ARV75XX_BRN_MAC
), 6);
358 ltq_register_etop(<q_eth_data
);
362 bewan_register_ethernet(void)
364 #define BEWAN_BRN_MAC 0x3f0014
365 memcpy_fromio(<q_eth_data
.mac
.sa_data
,
366 (void *)KSEG1ADDR(LTQ_FLASH_START
+ BEWAN_BRN_MAC
), 6);
367 ltq_register_etop(<q_eth_data
);
370 static u16 arv45xx_ath5k_eeprom_data
[ATH5K_PLAT_EEP_MAX_WORDS
];
371 static u8 arv45xx_ath5k_eeprom_mac
[6];
374 arv45xx_register_ath5k(void)
376 #define ARV45XX_BRN_ATH 0x3f0478
378 static u16 eeprom_data
[ATH5K_PLAT_EEP_MAX_WORDS
];
379 u32
*p
= (u32
*)arv45xx_ath5k_eeprom_data
;
381 memcpy_fromio(arv45xx_ath5k_eeprom_mac
,
382 (void *)KSEG1ADDR(LTQ_FLASH_START
+ ARV45XX_BRN_MAC
), 6);
383 arv45xx_ath5k_eeprom_mac
[5]++;
384 memcpy_fromio(arv45xx_ath5k_eeprom_data
,
385 (void *)KSEG1ADDR(LTQ_FLASH_START
+ ARV45XX_BRN_ATH
), ATH5K_PLAT_EEP_MAX_WORDS
);
387 for (i
= 0; i
< ATH5K_PLAT_EEP_MAX_WORDS
>>1; i
++){
388 //arv4518_ath5k_eeprom_data[i] = ((eeprom_data[i]&0xff)<<8)|((eeprom_data[i]&0xff00)>>8);
389 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);
391 // printk ("regdomain: 0x%x --> 0x%x\n", p[i], (p[i] & 0xffff0000)|0x67);
392 /* regdomain is invalid?? how did original fw convert
394 * for now, force to 0x67 */
404 ltq_register_gpio_stp();
405 //ltq_add_device_gpio_leds(arv3527p_gpio_leds, ARRAY_SIZE(arv3527p_gpio_leds));
406 ltq_register_nor(&arv45xx_flash_data
);
407 arv45xx_register_ethernet();
410 MIPS_MACHINE(LANTIQ_MACH_ARV3527P
,
412 "ARV3527P - Arcor Easybox 401",
418 ltq_register_gpio_stp();
419 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4510pw_gpio_leds
), arv4510pw_gpio_leds
);
420 ltq_register_nor(&arv4510_flash_data
);
421 ltq_pci_data
.irq
[12] = (INT_NUM_IM2_IRL0
+ 31);
422 ltq_pci_data
.irq
[15] = (INT_NUM_IM0_IRL0
+ 26);
423 ltq_pci_data
.gpio
|= PCI_EXIN2
| PCI_REQ2
;
424 ltq_register_pci(<q_pci_data
);
425 bewan_register_ethernet();
428 MIPS_MACHINE(LANTIQ_MACH_ARV4510PW
,
430 "ARV4510PW - Wippies Homebox",
436 #define ARV4518PW_EBU 0
437 #define ARV4518PW_USB 14
438 #define ARV4518PW_SWITCH_RESET 13
439 #define ARV4518PW_MADWIFI_ADDR 0xb07f0400
441 ltq_register_gpio_ebu(ARV4518PW_EBU
);
442 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4518pw_gpio_leds
), arv4518pw_gpio_leds
);
443 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL
,
444 ARRAY_SIZE(arv4518pw_gpio_keys
), arv4518pw_gpio_keys
);
445 ltq_register_nor(&arv45xx_flash_data
);
446 ltq_pci_data
.gpio
= PCI_GNT2
| PCI_REQ2
;
447 ltq_register_pci(<q_pci_data
);
448 ltq_register_madwifi_eep(ARV4518PW_MADWIFI_ADDR
);
449 ltq_register_ath5k(arv45xx_ath5k_eeprom_data
, arv45xx_ath5k_eeprom_mac
);
450 xway_register_dwc(ARV4518PW_USB
);
451 arv45xx_register_ethernet();
453 gpio_request(ARV4518PW_SWITCH_RESET
, "switch");
454 gpio_direction_output(ARV4518PW_SWITCH_RESET
, 1);
455 gpio_export(ARV4518PW_SWITCH_RESET
, 0);
458 MIPS_MACHINE(LANTIQ_MACH_ARV4518PW
,
460 "ARV4518PW - SMC7908A-ISP, Airties WAV-221",
466 #define ARV4520PW_EBU 0x400
467 #define ARV4520PW_USB 28
468 #define ARV4520PW_SWITCH_RESET 110
470 ltq_register_gpio_ebu(ARV4520PW_EBU
);
471 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4520pw_gpio_leds
), arv4520pw_gpio_leds
);
472 ltq_register_nor(&arv45xx_flash_data
);
473 ltq_register_pci(<q_pci_data
);
475 arv45xx_register_ethernet();
476 xway_register_dwc(ARV4520PW_USB
);
478 gpio_request(ARV4520PW_SWITCH_RESET
, "switch");
479 gpio_set_value(ARV4520PW_SWITCH_RESET
, 1);
482 MIPS_MACHINE(LANTIQ_MACH_ARV4520PW
,
484 "ARV4520PW - Airties WAV-281, Arcor A800",
490 #define ARV452CPW_EBU 0x77f
491 #define ARV452CPW_USB 28
492 #define ARV452CPW_RELAY1 31
493 #define ARV452CPW_RELAY2 107
494 #define ARV452CPW_SWITCH_RESET 110
495 #define ARV452CPW_MADWIFI_ADDR 0xb07f0400
497 ltq_register_gpio_ebu(ARV452CPW_EBU
);
498 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv452cpw_gpio_leds
), arv452cpw_gpio_leds
);
499 ltq_register_nor(&arv45xx_flash_data
);
500 ltq_register_pci(<q_pci_data
);
501 ltq_register_madwifi_eep(ARV452CPW_MADWIFI_ADDR
);
502 xway_register_dwc(ARV452CPW_USB
);
503 arv45xx_register_ethernet();
504 arv45xx_register_ath5k();
506 gpio_request(ARV452CPW_SWITCH_RESET
, "switch");
507 gpio_set_value(ARV452CPW_SWITCH_RESET
, 1);
508 gpio_export(ARV452CPW_SWITCH_RESET
, 0);
510 gpio_request(ARV452CPW_RELAY1
, "relay1");
511 gpio_direction_output(ARV452CPW_RELAY1
, 1);
512 gpio_export(ARV452CPW_RELAY1
, 0);
514 gpio_request(ARV452CPW_RELAY2
, "relay2");
515 gpio_set_value(ARV452CPW_RELAY2
, 1);
516 gpio_export(ARV452CPW_RELAY2
, 0);
519 MIPS_MACHINE(LANTIQ_MACH_ARV452CPW
,
521 "ARV452CPW - Arcor A801",
528 #define ARV4525PW_MADWIFI_ADDR 0xb07f0400
529 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds
), arv4525pw_gpio_leds
);
530 ltq_register_nor(&arv45xx_flash_data
);
531 ltq_pci_data
.clock
= PCI_CLOCK_INT
;
532 ltq_register_pci(<q_pci_data
);
533 ltq_register_madwifi_eep(ARV4525PW_MADWIFI_ADDR
);
534 ltq_eth_data
.mii_mode
= PHY_INTERFACE_MODE_MII
;
535 arv45xx_register_ethernet();
538 MIPS_MACHINE(LANTIQ_MACH_ARV4525PW
,
540 "ARV4525PW - Speedport W502V",
546 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds
), arv4525pw_gpio_leds
);
547 ltq_register_nor(&arv7525_flash_data
);
548 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL
,
549 ARRAY_SIZE(arv7525pw_gpio_keys
), arv7525pw_gpio_keys
);
550 ltq_pci_data
.clock
= PCI_CLOCK_INT
;
551 ltq_pci_data
.gpio
= PCI_GNT1
| PCI_EXIN1
;
552 ltq_pci_data
.irq
[14] = (INT_NUM_IM3_IRL0
+ 31);
553 ltq_register_pci(<q_pci_data
);
554 ltq_eth_data
.mii_mode
= PHY_INTERFACE_MODE_MII
;
555 ltq_register_rt2x00("RT2860.eeprom");
557 arv45xx_register_ethernet();
560 MIPS_MACHINE(LANTIQ_MACH_ARV7525PW
,
562 "ARV7525PW - Speedport W303V",
568 #define ARV7518PW_EBU 0x2
569 #define ARV7518PW_USB 14
571 ltq_register_gpio_ebu(ARV7518PW_EBU
);
572 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv7518pw_gpio_leds
), arv7518pw_gpio_leds
);
573 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL
,
574 ARRAY_SIZE(arv7518pw_gpio_keys
), arv7518pw_gpio_keys
);
575 ltq_register_nor(&arv75xx_flash_data
);
576 ltq_register_pci(<q_pci_data
);
578 xway_register_dwc(ARV7518PW_USB
);
579 arv75xx_register_ethernet();
580 //arv7518_register_ath9k(mac);
583 MIPS_MACHINE(LANTIQ_MACH_ARV7518PW
,
585 "ARV7518PW - ASTORIA",
589 arv752dpw22_init(void)
591 #define ARV752DPW22_EBU 0x2
592 #define ARV752DPW22_USB 100
593 #define ARV752DPW22_RELAY 101
595 ltq_register_gpio_ebu(ARV752DPW22_EBU
);
596 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv752dpw22_gpio_leds
), arv752dpw22_gpio_leds
);
597 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL
,
598 ARRAY_SIZE(arv752dpw22_gpio_keys
), arv752dpw22_gpio_keys
);
599 ltq_register_nor(&arv75xx_flash_data
);
600 ltq_pci_data
.irq
[15] = (INT_NUM_IM3_IRL0
+ 31);
601 ltq_pci_data
.gpio
|= PCI_EXIN1
| PCI_REQ2
;
602 ltq_register_pci(<q_pci_data
);
603 xway_register_dwc(ARV752DPW22_USB
);
604 arv75xx_register_ethernet();
606 gpio_request(ARV752DPW22_RELAY
, "relay");
607 gpio_set_value(ARV752DPW22_RELAY
, 1);
608 gpio_export(ARV752DPW22_RELAY
, 0);
611 MIPS_MACHINE(LANTIQ_MACH_ARV752DPW22
,
613 "ARV752DPW22 - Arcor A803",