2 * NETGEAR WNR2000v3/WNR612v2/WNR1000v2/WPN824N board support
4 * Copyright (C) 2015 Hartmut Knaack <knaack.h@gmx.de>
5 * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
6 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
7 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
8 * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
18 #include <asm/mach-ath79/ath79.h>
19 #include <asm/mach-ath79/ar71xx_regs.h> /* needed to disable switch LEDs */
20 #include "common.h" /* needed to disable switch LEDs */
22 #include "dev-ap9x-pci.h"
24 #include "dev-gpio-buttons.h"
25 #include "dev-leds-gpio.h"
26 #include "dev-m25p80.h"
27 #include "machtypes.h"
29 #define WNR2000V3_GPIO_LED_WAN_GREEN 0
30 #define WNR2000V3_GPIO_LED_LAN1_AMBER 1
31 #define WNR2000V3_GPIO_LED_LAN4_AMBER 12
32 #define WNR2000V3_GPIO_LED_PWR_GREEN 14
33 #define WNR2000V3_GPIO_BTN_WPS 11
35 #define WNR612V2_GPIO_LED_PWR_GREEN 11
37 #define WNR1000V2_GPIO_LED_PWR_AMBER 1
38 #define WNR1000V2_GPIO_LED_PWR_GREEN 11
40 /* Connected through AR7240 */
41 #define WPN824N_GPIO_LED_WAN_AMBER 0
42 #define WPN824N_GPIO_LED_STATUS_AMBER 1
43 #define WPN824N_GPIO_LED_LAN1_AMBER 6 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
44 #define WPN824N_GPIO_LED_LAN2_AMBER 7 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
45 #define WPN824N_GPIO_LED_LAN3_AMBER 8 /* AR724X_GPIO_FUNC_JTAG_DISABLE */
46 #define WPN824N_GPIO_LED_LAN4_AMBER 12
47 #define WPN824N_GPIO_LED_LAN1_GREEN 13
48 #define WPN824N_GPIO_LED_LAN2_GREEN 14
49 #define WPN824N_GPIO_LED_LAN3_GREEN 15 /* AR724X_GPIO_FUNC_CLK_OBS3_EN */
50 #define WPN824N_GPIO_LED_LAN4_GREEN 16
51 #define WPN824N_GPIO_LED_WAN_GREEN 17
53 /* Connected through AR9285 */
54 #define WPN824N_WGPIO_LED_PWR_GREEN 0
55 #define WPN824N_WGPIO_LED_WLAN_BLUE 1
56 #define WPN824N_WGPIO_LED_WPS1_BLUE 5
57 #define WPN824N_WGPIO_LED_WPS2_BLUE 9
58 #define WPN824N_WGPIO_LED_TEST_AMBER 10
59 #define WPN824N_WGPIO_BTN_PUSH 6 /* currently unused */
60 #define WPN824N_WGPIO_BTN_RESET 7 /* currently unused */
61 #define WPN824N_WGPIO_BTN_WLAN 8 /* currently unused */
63 #define WNR2000V3_KEYS_POLL_INTERVAL 20 /* msecs */
64 #define WNR2000V3_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V3_KEYS_POLL_INTERVAL)
66 #define WNR2000V3_MAC0_OFFSET 0
67 #define WNR2000V3_MAC1_OFFSET 6
68 #define WNR2000V3_PCIE_CALDATA_OFFSET 0x1000
70 static struct gpio_led wnr2000v3_leds_gpio
[] __initdata
= {
72 .name
= "wnr2000v3:green:power",
73 .gpio
= WNR2000V3_GPIO_LED_PWR_GREEN
,
76 .name
= "wnr2000v3:green:wan",
77 .gpio
= WNR2000V3_GPIO_LED_WAN_GREEN
,
82 static struct gpio_led wnr612v2_leds_gpio
[] __initdata
= {
84 .name
= "netgear:green:power",
85 .gpio
= WNR612V2_GPIO_LED_PWR_GREEN
,
90 static struct gpio_led wnr1000v2_leds_gpio
[] __initdata
= {
92 .name
= "netgear:green:power",
93 .gpio
= WNR1000V2_GPIO_LED_PWR_GREEN
,
96 .name
= "netgear:amber:power",
97 .gpio
= WNR1000V2_GPIO_LED_PWR_AMBER
,
102 static struct gpio_led wpn824n_leds_gpio
[] __initdata
= {
104 .name
= "netgear:amber:wan",
105 .gpio
= WPN824N_GPIO_LED_WAN_AMBER
,
108 .name
= "netgear:amber:status",
109 .gpio
= WPN824N_GPIO_LED_STATUS_AMBER
,
112 .name
= "netgear:amber:lan1",
113 .gpio
= WPN824N_GPIO_LED_LAN1_AMBER
,
116 .name
= "netgear:amber:lan2",
117 .gpio
= WPN824N_GPIO_LED_LAN2_AMBER
,
120 .name
= "netgear:amber:lan3",
121 .gpio
= WPN824N_GPIO_LED_LAN3_AMBER
,
124 .name
= "netgear:amber:lan4",
125 .gpio
= WPN824N_GPIO_LED_LAN4_AMBER
,
128 .name
= "netgear:green:lan1",
129 .gpio
= WPN824N_GPIO_LED_LAN1_GREEN
,
132 .name
= "netgear:green:lan2",
133 .gpio
= WPN824N_GPIO_LED_LAN2_GREEN
,
136 .name
= "netgear:green:lan3",
137 .gpio
= WPN824N_GPIO_LED_LAN3_GREEN
,
140 .name
= "netgear:green:lan4",
141 .gpio
= WPN824N_GPIO_LED_LAN4_GREEN
,
144 .name
= "netgear:green:wan",
145 .gpio
= WPN824N_GPIO_LED_WAN_GREEN
,
150 static struct gpio_led wpn824n_wmac_leds_gpio
[] = {
152 .name
= "netgear:green:power",
153 .gpio
= WPN824N_WGPIO_LED_PWR_GREEN
,
156 .name
= "netgear:blue:wlan",
157 .gpio
= WPN824N_WGPIO_LED_WLAN_BLUE
,
160 .name
= "netgear:blue:wps1",
161 .gpio
= WPN824N_WGPIO_LED_WPS1_BLUE
,
164 .name
= "netgear:blue:wps2",
165 .gpio
= WPN824N_WGPIO_LED_WPS2_BLUE
,
168 .name
= "netgear:amber:test",
169 .gpio
= WPN824N_WGPIO_LED_TEST_AMBER
,
174 static struct gpio_keys_button wnr2000v3_gpio_keys
[] __initdata
= {
178 .code
= KEY_WPS_BUTTON
,
179 .debounce_interval
= WNR2000V3_KEYS_DEBOUNCE_INTERVAL
,
180 .gpio
= WNR2000V3_GPIO_BTN_WPS
,
184 static void __init
wnr_common_setup(void)
186 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
188 ath79_register_mdio(0, 0x0);
190 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
+WNR2000V3_MAC0_OFFSET
, 0);
191 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
192 ath79_eth0_data
.speed
= SPEED_100
;
193 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
195 ath79_init_mac(ath79_eth1_data
.mac_addr
, art
+WNR2000V3_MAC1_OFFSET
, 0);
196 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RMII
;
197 ath79_eth1_data
.phy_mask
= 0x10;
199 ath79_register_eth(0);
200 ath79_register_eth(1);
202 ath79_register_m25p80(NULL
);
203 ap91_pci_init(art
+ WNR2000V3_PCIE_CALDATA_OFFSET
, NULL
);
206 static void __init
wnr2000v3_setup(void)
210 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v3_leds_gpio
),
211 wnr2000v3_leds_gpio
);
213 ath79_register_gpio_keys_polled(-1, WNR2000V3_KEYS_POLL_INTERVAL
,
214 ARRAY_SIZE(wnr2000v3_gpio_keys
),
215 wnr2000v3_gpio_keys
);
218 MIPS_MACHINE(ATH79_MACH_WNR2000_V3
, "WNR2000V3", "NETGEAR WNR2000 V3", wnr2000v3_setup
);
220 static void __init
wnr612v2_setup(void)
224 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio
),
228 MIPS_MACHINE(ATH79_MACH_WNR612_V2
, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup
);
230 static void __init
wnr1000v2_setup(void)
234 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr1000v2_leds_gpio
),
235 wnr1000v2_leds_gpio
);
238 MIPS_MACHINE(ATH79_MACH_WNR1000_V2
, "WNR1000V2", "NETGEAR WNR1000 V2", wnr1000v2_setup
);
240 static void __init
wpn824n_setup(void)
242 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE
,
243 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
244 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
245 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
246 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
247 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
|
248 AR724X_GPIO_FUNC_CLK_OBS3_EN
);
252 ath79_register_leds_gpio(-1, ARRAY_SIZE(wpn824n_leds_gpio
),
255 ap9x_pci_setup_wmac_led_pin(0, WPN824N_WGPIO_LED_WLAN_BLUE
);
256 ap9x_pci_setup_wmac_leds(0, wpn824n_wmac_leds_gpio
,
257 ARRAY_SIZE(wpn824n_wmac_leds_gpio
));
260 MIPS_MACHINE(ATH79_MACH_WPN824N
, "WPN824N", "NETGEAR WPN824N", wpn824n_setup
);