2 * NETGEAR WNR2000v4 board support
4 * Copyright (C) 2015 Michael Bazzinotti <mbazzinotti@gmail.com>
5 * Copyright (C) 2014 Michaƫl Burtin <mburtin@gmail.com>
6 * Copyright (C) 2013 Mathieu Olivari <mathieu.olivari@gmail.com>
7 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
8 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
9 * Copyright (C) 2008-2009 Andy Boyett <agb@openwrt.org>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation.
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/platform_device.h>
20 #include <asm/mach-ath79/ath79.h>
21 #include <asm/mach-ath79/ar71xx_regs.h>
25 #include "dev-gpio-buttons.h"
26 #include "dev-leds-gpio.h"
27 #include "dev-m25p80.h"
30 #include "machtypes.h"
33 #define WNR2000V4_GPIO_LED_PWR_GREEN 0
34 #define WNR2000V4_GPIO_LED_PWR_AMBER 1
35 #define WNR2000V4_GPIO_LED_WPS 2
36 #define WNR2000V4_GPIO_LED_WLAN 12
37 #define WNR2000V4_GPIO_LED_LAN1_GREEN 13
38 #define WNR2000V4_GPIO_LED_LAN2_GREEN 14
39 #define WNR2000V4_GPIO_LED_LAN3_GREEN 15
40 #define WNR2000V4_GPIO_LED_LAN4_GREEN 16
41 #define WNR2000V4_GPIO_LED_LAN1_AMBER 18
42 #define WNR2000V4_GPIO_LED_LAN2_AMBER 19
43 #define WNR2000V4_GPIO_LED_LAN3_AMBER 20
44 #define WNR2000V4_GPIO_LED_LAN4_AMBER 21
45 #define WNR2000V4_GPIO_LED_WAN_GREEN 17
46 #define WNR2000V4_GPIO_LED_WAN_AMBER 22
48 #define WNR2000V4_GPIO_BTN_WPS 3
49 #define WNR2000V4_GPIO_BTN_RESET 4
50 #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)
56 #define WNR2000V4_MAC0_OFFSET 0 /* WAN/WLAN0 MAC */
57 #define WNR2000V4_MAC1_OFFSET 6 /* Eth-switch0 MAC */
59 static struct gpio_led wnr2000v4_leds_gpio[] __initdata = {
61 .name = "netgear:green:power",
62 .gpio = WNR2000V4_GPIO_LED_PWR_GREEN,
64 .default_trigger = "default-on",
67 .name = "netgear:amber:status",
68 .gpio = WNR2000V4_GPIO_LED_PWR_AMBER,
72 .name = "netgear:green:wan",
73 .gpio = WNR2000V4_GPIO_LED_WAN_GREEN,
77 .name = "netgear:amber:wan",
78 .gpio = WNR2000V4_GPIO_LED_WAN_AMBER,
82 .name = "netgear:blue:wlan",
83 .gpio = WNR2000V4_GPIO_LED_WLAN,
88 .name = "netgear:green:lan1",
89 .gpio = WNR2000V4_GPIO_LED_LAN1_GREEN,
93 .name = "netgear:green:lan2",
94 .gpio = WNR2000V4_GPIO_LED_LAN2_GREEN,
98 .name = "netgear:green:lan3",
99 .gpio = WNR2000V4_GPIO_LED_LAN3_GREEN,
103 .name = "netgear:green:lan4",
104 .gpio = WNR2000V4_GPIO_LED_LAN4_GREEN,
108 .name = "netgear:amber:lan1",
109 .gpio = WNR2000V4_GPIO_LED_LAN1_AMBER,
113 .name = "netgear:amber:lan2",
114 .gpio = WNR2000V4_GPIO_LED_LAN2_AMBER,
118 .name = "netgear:amber:lan3",
119 .gpio = WNR2000V4_GPIO_LED_LAN3_AMBER,
123 .name = "netgear:amber:lan4",
124 .gpio = WNR2000V4_GPIO_LED_LAN4_AMBER,
128 .name = "netgear:green:wps",
129 .gpio = WNR2000V4_GPIO_LED_WPS,
134 static struct gpio_keys_button wnr2000v4_gpio_keys[] __initdata = {
136 .desc = "WPS button",
138 .code = KEY_WPS_BUTTON,
139 .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
140 .gpio = WNR2000V4_GPIO_BTN_WPS,
144 .desc = "Reset button",
147 .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
148 .gpio = WNR2000V4_GPIO_BTN_RESET,
152 .desc = "WLAN button",
155 .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
156 .gpio = WNR2000V4_GPIO_BTN_WLAN,
161 static void __init wnr_common_setup(void)
163 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
164 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
166 ath79_register_mdio(1, 0x0);
168 ath79_register_usb();
170 ath79_register_m25p80(NULL);
172 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
174 ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V4_MAC0_OFFSET, 0);
175 ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V4_MAC1_OFFSET, 0);
177 /* GMAC0 is connected to the PHY0 of the internal switch, GE0 */
178 ath79_switch_data.phy4_mii_en = 1;
179 ath79_switch_data.phy_poll_mask = BIT(4);
180 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
181 ath79_eth0_data.phy_mask = BIT(4);
182 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
183 ath79_register_eth(0);
185 /* GMAC1 is connected to the internal switch, GE1 */
186 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
187 ath79_register_eth(1);
189 ath79_register_wmac(ee, art);
192 static void __init wnr2000v4_setup(void)
198 /* Ensure no LED has an internal MUX signal, otherwise
199 control of LED could be lost... This is especially important
200 for most green LEDS (Eth,WAN).. who arrive in this function with
202 for (i = 0; i < ARRAY_SIZE(wnr2000v4_leds_gpio); i++)
203 ath79_gpio_output_select(wnr2000v4_leds_gpio[i].gpio,
204 AR934X_GPIO_OUT_GPIO);
206 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v4_leds_gpio),
207 wnr2000v4_leds_gpio);
209 ath79_register_gpio_keys_polled(-1, WNR2000V4_KEYS_POLL_INTERVAL,
210 ARRAY_SIZE(wnr2000v4_gpio_keys),
211 wnr2000v4_gpio_keys);
214 MIPS_MACHINE(ATH79_MACH_WNR2000_V4, "WNR2000V4", "NETGEAR WNR2000 V4", wnr2000v4_setup);