2 * NETGEAR WNR2000v4 board support
4 * Copytight (C) 2014 Michaƫl Burtin <mburtin@gmail.com>
5 * Copytight (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>
17 #include <linux/platform_device.h>
19 #include <asm/mach-ath79/ath79.h>
20 #include <asm/mach-ath79/ar71xx_regs.h>
24 #include "dev-gpio-buttons.h"
25 #include "dev-leds-gpio.h"
26 #include "dev-m25p80.h"
29 #include "machtypes.h"
32 #define WNR2000V4_GPIO_LED_WAN_AMBER 22
33 #define WNR2000V4_GPIO_LED_WAN_GREEN 17
34 #define WNR2000V4_GPIO_LED_WPS 2
35 #define WNR2000V4_GPIO_LED_WLAN 12
36 #define WNR2000V4_GPIO_LED_LAN1_GREEN 13
37 #define WNR2000V4_GPIO_LED_LAN2_GREEN 14
38 #define WNR2000V4_GPIO_LED_LAN3_GREEN 15
39 #define WNR2000V4_GPIO_LED_LAN4_GREEN 16
40 #define WNR2000V4_GPIO_LED_LAN1_AMBER 18
41 #define WNR2000V4_GPIO_LED_LAN2_AMBER 19
42 #define WNR2000V4_GPIO_LED_LAN3_AMBER 20
43 #define WNR2000V4_GPIO_LED_LAN4_AMBER 21
44 #define STATUS_LED_GPIO 1
45 #define WNR2000V4_GPIO_LED_PWR_GREEN 0
47 #define WNR2000V4_GPIO_BTN_WPS 3
48 #define WNR2000V4_GPIO_BTN_RESET 4
49 #define WNR2000V4_GPIO_BTN_WLAN 11
51 #define WNR2000V4_KEYS_POLL_INTERVAL 20 /* msecs */
52 #define WNR2000V4_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V4_KEYS_POLL_INTERVAL)
54 #define WNR2000V4_MAC0_OFFSET 0
55 #define WNR2000V4_MAC1_OFFSET 6
57 static struct gpio_led wnr2000v4_leds_gpio
[] __initdata
= {
59 .name
= "netgear:green:power",
60 .gpio
= WNR2000V4_GPIO_LED_PWR_GREEN
,
62 .default_trigger
= "default-on",
64 .name
= "netgear:amber:wan",
65 .gpio
= WNR2000V4_GPIO_LED_WAN_AMBER
,
69 .name
= "netgear:green:wps",
70 .gpio
= WNR2000V4_GPIO_LED_WPS
,
74 .name
= "netgear:amber:status",
75 .gpio
= STATUS_LED_GPIO
,
79 .name
= "netgear:blue:wlan",
80 .gpio
= WNR2000V4_GPIO_LED_WLAN
,
85 .name
= "netgear:green:lan1",
86 .gpio
= WNR2000V4_GPIO_LED_LAN1_GREEN
,
89 .name
= "netgear:green:lan2",
90 .gpio
= WNR2000V4_GPIO_LED_LAN2_GREEN
,
93 .name
= "netgear:green:lan3",
94 .gpio
= WNR2000V4_GPIO_LED_LAN3_GREEN
,
97 .name
= "netgear:green:lan4",
98 .gpio
= WNR2000V4_GPIO_LED_LAN4_GREEN
,
102 .name
= "netgear:amber:lan1",
103 .gpio
= WNR2000V4_GPIO_LED_LAN1_AMBER
,
106 .name
= "netgear:amber:lan2",
107 .gpio
= WNR2000V4_GPIO_LED_LAN2_AMBER
,
110 .name
= "netgear:amber:lan3",
111 .gpio
= WNR2000V4_GPIO_LED_LAN3_AMBER
,
114 .name
= "netgear:amber:lan4",
115 .gpio
= WNR2000V4_GPIO_LED_LAN4_AMBER
,
120 static struct gpio_keys_button wnr2000v4_gpio_keys
[] __initdata
= {
122 .desc
= "WPS button",
124 .code
= KEY_WPS_BUTTON
,
125 .debounce_interval
= WNR2000V4_KEYS_DEBOUNCE_INTERVAL
,
126 .gpio
= WNR2000V4_GPIO_BTN_WPS
,
130 .desc
= "Reset button",
133 .debounce_interval
= WNR2000V4_KEYS_DEBOUNCE_INTERVAL
,
134 .gpio
= WNR2000V4_GPIO_BTN_RESET
,
138 .desc
= "WLAN button",
141 .debounce_interval
= WNR2000V4_KEYS_DEBOUNCE_INTERVAL
,
142 .gpio
= WNR2000V4_GPIO_BTN_WLAN
,
147 static void __init
wnr_common_setup(void)
149 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
150 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
152 ath79_register_mdio(1, 0x0);
154 ath79_register_usb();
156 ath79_register_m25p80(NULL
);
158 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE
);
160 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
+WNR2000V4_MAC0_OFFSET
, 0);
161 ath79_init_mac(ath79_eth1_data
.mac_addr
, art
+WNR2000V4_MAC1_OFFSET
, 0);
163 /* GMAC0 is connected to the PHY0 of the internal switch, GE0 */
164 ath79_switch_data
.phy4_mii_en
= 1;
165 ath79_switch_data
.phy_poll_mask
= BIT(4);
166 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
167 ath79_eth0_data
.phy_mask
= BIT(4);
168 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
169 ath79_register_eth(0);
171 /* GMAC1 is connected to the internal switch, GE1 */
172 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
173 ath79_register_eth(1);
175 ath79_register_wmac(ee
, art
);
178 static void __init
wnr2000v4_setup(void)
184 /* Ensure no LED has an internal MUX signal, otherwise
185 control of LED could be lost... This is especially important
186 for most green LEDS (Eth,WAN).. who arrive in this function with
188 for (i
= 0; i
< ARRAY_SIZE(wnr2000v4_leds_gpio
); i
++)
189 ath79_gpio_output_select(wnr2000v4_leds_gpio
[i
].gpio
,
190 AR934X_GPIO_OUT_GPIO
);
192 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v4_leds_gpio
),
193 wnr2000v4_leds_gpio
);
195 ath79_register_gpio_keys_polled(-1, WNR2000V4_KEYS_POLL_INTERVAL
,
196 ARRAY_SIZE(wnr2000v4_gpio_keys
),
197 wnr2000v4_gpio_keys
);
200 MIPS_MACHINE(ATH79_MACH_WNR2000_V4
, "WNR2000V4", "NETGEAR WNR2000 V4", wnr2000v4_setup
);