2 * D-Link DIR-600 rev. A1 board support
4 * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2012 Vadim Girlin <vadimgirlin@gmail.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
12 #include <asm/mach-ath79/ath79.h>
13 #include <asm/mach-ath79/ar71xx_regs.h>
16 #include "dev-ap9x-pci.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21 #include "machtypes.h"
24 #define DIR_600_A1_GPIO_LED_WPS 0
25 #define DIR_600_A1_GPIO_LED_POWER_AMBER 1
26 #define DIR_600_A1_GPIO_LED_POWER_GREEN 6
27 #define DIR_600_A1_GPIO_LED_LAN1 13
28 #define DIR_600_A1_GPIO_LED_LAN2 14
29 #define DIR_600_A1_GPIO_LED_LAN3 15
30 #define DIR_600_A1_GPIO_LED_LAN4 16
31 #define DIR_600_A1_GPIO_LED_WAN_AMBER 7
32 #define DIR_600_A1_GPIO_LED_WAN_GREEN 17
34 #define DIR_600_A1_GPIO_BTN_RESET 8
35 #define DIR_600_A1_GPIO_BTN_WPS 12
37 #define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
40 #define DIR_600_A1_NVRAM_ADDR 0x1f030000
41 #define DIR_600_A1_NVRAM_SIZE 0x10000
43 static struct gpio_led dir_600_a1_leds_gpio
[] __initdata
= {
45 .name
= "d-link:green:power",
46 .gpio
= DIR_600_A1_GPIO_LED_POWER_GREEN
,
48 .name
= "d-link:amber:power",
49 .gpio
= DIR_600_A1_GPIO_LED_POWER_AMBER
,
51 .name
= "d-link:amber:wan",
52 .gpio
= DIR_600_A1_GPIO_LED_WAN_AMBER
,
54 .name
= "d-link:green:wan",
55 .gpio
= DIR_600_A1_GPIO_LED_WAN_GREEN
,
58 .name
= "d-link:green:lan1",
59 .gpio
= DIR_600_A1_GPIO_LED_LAN1
,
62 .name
= "d-link:green:lan2",
63 .gpio
= DIR_600_A1_GPIO_LED_LAN2
,
66 .name
= "d-link:green:lan3",
67 .gpio
= DIR_600_A1_GPIO_LED_LAN3
,
70 .name
= "d-link:green:lan4",
71 .gpio
= DIR_600_A1_GPIO_LED_LAN4
,
74 .name
= "d-link:blue:wps",
75 .gpio
= DIR_600_A1_GPIO_LED_WPS
,
80 static struct gpio_keys_button dir_600_a1_gpio_keys
[] __initdata
= {
85 .debounce_interval
= DIR_600_A1_KEYS_DEBOUNCE_INTERVAL
,
86 .gpio
= DIR_600_A1_GPIO_BTN_RESET
,
91 .code
= KEY_WPS_BUTTON
,
92 .debounce_interval
= DIR_600_A1_KEYS_DEBOUNCE_INTERVAL
,
93 .gpio
= DIR_600_A1_GPIO_BTN_WPS
,
98 static void __init
dir_600_a1_setup(void)
100 const char *nvram
= (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR
);
101 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
105 if (ath79_nvram_parse_mac_addr(nvram
, DIR_600_A1_NVRAM_SIZE
,
106 "lan_mac=", mac_buff
) == 0) {
107 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac_buff
, 0);
108 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac_buff
, 1);
112 ath79_register_m25p80(NULL
);
114 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
115 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
116 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
117 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
118 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
120 ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio
),
121 dir_600_a1_leds_gpio
);
123 ath79_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL
,
124 ARRAY_SIZE(dir_600_a1_gpio_keys
),
125 dir_600_a1_gpio_keys
);
127 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
128 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
130 ath79_register_mdio(0, 0x0);
133 ath79_register_eth(1);
136 ath79_register_eth(0);
138 ap91_pci_init(ee
, mac
);
141 MIPS_MACHINE(ATH79_MACH_DIR_600_A1
, "DIR-600-A1", "D-Link DIR-600 rev. A1",
144 static void __init
dir_615_e4_setup(void)
147 ap9x_pci_setup_wmac_led_pin(0, 1);
150 MIPS_MACHINE(ATH79_MACH_DIR_615_E4
, "DIR-615-E4", "D-Link DIR-615 rev. E4",