21 #include <linux/types.h>
22 #include <linux/module.h>
27 #include <linux/serial.h>
33 #include <linux/string.h>
40 #include <asm/addrspace.h>
75 goto out_gpio_enabled;
103 static struct resource vlynq_low_res[] = {
130 static struct resource vlynq_high_res[] = {
179 .platform_data = &vlynq_low_data,
181 .resource = vlynq_low_res,
189 .platform_data = &vlynq_high_data,
191 .resource = vlynq_high_res,
198 static struct resource physmap_flash_resource = {
210 .name =
"physmap-flash",
212 .platform_data = &physmap_flash_data,
214 .resource = &physmap_flash_resource,
221 static struct resource cpmac_low_res[] = {
236 static struct resource cpmac_high_res[] = {
260 .phy_mask = 0x80000000,
266 .phy_mask = 0x7fffffff,
275 .dma_mask = &cpmac_dma_mask,
277 .platform_data = &cpmac_low_data,
279 .resource = cpmac_low_res,
287 .dma_mask = &cpmac_dma_mask,
289 .platform_data = &cpmac_high_data,
291 .resource = cpmac_high_res,
295 static void __init cpmac_get_mac(
int instance,
unsigned char *dev_addr)
299 sprintf(name,
"mac%c",
'a' + instance);
301 if (!mac && instance) {
307 if (
sscanf(mac,
"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
308 &dev_addr[0], &dev_addr[1],
309 &dev_addr[2], &dev_addr[3],
310 &dev_addr[4], &dev_addr[5]) != 6) {
312 "using random address\n");
313 eth_random_addr(dev_addr);
316 eth_random_addr(dev_addr);
322 static struct resource usb_res[] = {
352 static struct gpio_led default_leds[] = {
360 static struct gpio_led titan_leds[] = {
361 { .name =
"status", .gpio = 8, .active_low = 1, },
362 { .name =
"wifi", .gpio = 13, .active_low = 1, },
365 static struct gpio_led dsl502t_leds[] = {
383 static struct gpio_led dg834g_leds[] = {
408 .default_trigger =
"default-on",
412 static struct gpio_led fb_sl_leds[] = {
439 static struct gpio_led fb_fon_leds[] = {
465 static struct gpio_led gt701_leds[] = {
467 .name =
"inet:green",
487 .name =
"power:green",
490 .default_trigger =
"default-on",
504 .platform_data = &ar7_led_data,
508 static void __init detect_leds(
void)
510 char *prid, *usb_prod;
513 ar7_led_data.num_leds =
ARRAY_SIZE(default_leds);
514 ar7_led_data.leds = default_leds;
524 if (
strstr(prid,
"Fritz_Box_FON")) {
525 ar7_led_data.num_leds =
ARRAY_SIZE(fb_fon_leds);
526 ar7_led_data.leds = fb_fon_leds;
527 }
else if (
strstr(prid,
"Fritz_Box_")) {
528 ar7_led_data.num_leds =
ARRAY_SIZE(fb_sl_leds);
529 ar7_led_data.leds = fb_sl_leds;
530 }
else if ((!
strcmp(prid,
"AR7RD") || !
strcmp(prid,
"AR7DB"))
531 && usb_prod !=
NULL &&
strstr(usb_prod,
"DSL-502T")) {
532 ar7_led_data.num_leds =
ARRAY_SIZE(dsl502t_leds);
533 ar7_led_data.leds = dsl502t_leds;
534 }
else if (
strstr(prid,
"DG834")) {
535 ar7_led_data.num_leds =
ARRAY_SIZE(dg834g_leds);
536 ar7_led_data.leds = dg834g_leds;
537 }
else if (
strstr(prid,
"CYWM") ||
strstr(prid,
"CYWL")) {
538 ar7_led_data.num_leds =
ARRAY_SIZE(titan_leds);
539 ar7_led_data.leds = titan_leds;
540 }
else if (
strstr(prid,
"GT701")) {
541 ar7_led_data.num_leds =
ARRAY_SIZE(gt701_leds);
542 ar7_led_data.leds = gt701_leds;
549 static struct resource ar7_wdt_res = {
558 .resource = &ar7_wdt_res,
565 static int __init ar7_register_uarts(
void)
567 #ifdef CONFIG_SERIAL_8250
576 panic(
"unable to get bus clk");
608 static void __init titan_fixup_devices(
void)
621 vlynq_low_res[1].
start = 33;
622 vlynq_low_res[1].
end = 33;
623 vlynq_low_res[2].
start = 0x0c000000;
624 vlynq_low_res[2].
end = 0x0fffffff;
625 vlynq_low_res[3].
start = 80;
626 vlynq_low_res[3].
end = 111;
631 vlynq_high_res[1].
start = 34;
632 vlynq_high_res[1].
end = 34;
633 vlynq_high_res[2].
start = 0x40000000;
634 vlynq_high_res[2].
end = 0x43ffffff;
635 vlynq_high_res[3].
start = 112;
636 vlynq_high_res[3].
end = 143;
639 cpmac_low_data.
phy_mask = 0x40000000;
642 cpmac_high_data.
phy_mask = 0x80000000;
653 static int __init ar7_register_devices(
void)
659 res = ar7_register_uarts();
661 pr_err(
"unable to setup uart(s): %d\n", res);
665 pr_warning(
"unable to register physmap-flash: %d\n", res);
668 titan_fixup_devices();
670 ar7_device_disable(vlynq_low_data.
reset_bit);
673 pr_warning(
"unable to register vlynq-low: %d\n", res);
676 ar7_device_disable(vlynq_high_data.
reset_bit);
679 pr_warning(
"unable to register vlynq-high: %d\n", res);
682 if (ar7_has_high_cpmac()) {
685 cpmac_get_mac(1, cpmac_high_data.
dev_addr);
689 pr_warning(
"unable to register cpmac-high: %d\n", res);
691 pr_warning(
"unable to add cpmac-high phy: %d\n", res);
693 cpmac_low_data.
phy_mask = 0xffffffff;
697 cpmac_get_mac(0, cpmac_low_data.
dev_addr);
700 pr_warning(
"unable to register cpmac-low: %d\n", res);
702 pr_warning(
"unable to add cpmac-low phy: %d\n", res);
707 pr_warning(
"unable to register leds: %d\n", res);
711 pr_warning(
"unable to register usb slave: %d\n", res);
723 ar7_wdt_res.
end = ar7_wdt_res.
start + 0x20;
726 pr_warning(
"unable to register watchdog: %d\n", res);