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 18
37 #define WNR2000V4_GPIO_LED_LAN2 19
38 #define WNR2000V4_GPIO_LED_LAN3 20
39 #define WNR2000V4_GPIO_LED_LAN4 21
40 #define STATUS_LED_GPIO 1
41 #define WNR2000V4_GPIO_LED_PWR_GREEN 0
43 #define WNR2000V4_GPIO_BTN_WPS 3
44 #define WNR2000V4_GPIO_BTN_RESET 4
45 #define WNR2000V4_GPIO_BTN_WLAN 11
47 #define WNR2000V4_KEYS_POLL_INTERVAL 20 /* msecs */
48 #define WNR2000V4_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V4_KEYS_POLL_INTERVAL)
50 #define WNR2000V4_MAC0_OFFSET 0
51 #define WNR2000V4_MAC1_OFFSET 6
53 static struct gpio_led wnr2000v4_leds_gpio
[] __initdata
= {
55 .name
= "netgear:green:power",
56 .gpio
= WNR2000V4_GPIO_LED_PWR_GREEN
,
58 .default_trigger
= "default-on",
60 .name
= "netgear:green:wan",
61 .gpio
= WNR2000V4_GPIO_LED_WAN_AMBER
,
65 .name
= "netgear:green:wps",
66 .gpio
= WNR2000V4_GPIO_LED_WPS
,
70 .name
= "netgear:amber:status",
71 .gpio
= STATUS_LED_GPIO
,
75 .name
= "netgear:blue:wlan",
76 .gpio
= WNR2000V4_GPIO_LED_WLAN
,
80 .name
= "netgear:amber:lan1",
81 .gpio
= WNR2000V4_GPIO_LED_LAN1
,
84 .name
= "netgear:amber:lan2",
85 .gpio
= WNR2000V4_GPIO_LED_LAN2
,
88 .name
= "netgear:amber:lan3",
89 .gpio
= WNR2000V4_GPIO_LED_LAN3
,
92 .name
= "netgear:amber:lan4",
93 .gpio
= WNR2000V4_GPIO_LED_LAN4
,
98 static struct gpio_keys_button wnr2000v4_gpio_keys
[] __initdata
= {
100 .desc
= "WPS button",
102 .code
= KEY_WPS_BUTTON
,
103 .debounce_interval
= WNR2000V4_KEYS_DEBOUNCE_INTERVAL
,
104 .gpio
= WNR2000V4_GPIO_BTN_WPS
,
107 .desc
= "Reset button",
110 .debounce_interval
= WNR2000V4_KEYS_DEBOUNCE_INTERVAL
,
111 .gpio
= WNR2000V4_GPIO_BTN_RESET
,
114 .desc
= "WLAN button",
117 .debounce_interval
= WNR2000V4_KEYS_DEBOUNCE_INTERVAL
,
118 .gpio
= WNR2000V4_GPIO_BTN_WLAN
,
122 static void __init
wnr_common_setup(void)
124 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
125 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
127 ath79_register_mdio(1, 0x0);
129 ath79_register_usb();
131 ath79_register_m25p80(NULL
);
133 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE
);
135 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
+WNR2000V4_MAC0_OFFSET
, 0);
136 ath79_init_mac(ath79_eth1_data
.mac_addr
, art
+WNR2000V4_MAC1_OFFSET
, 0);
138 /* GMAC0 is connected to the PHY0 of the internal switch, GE0 */
139 ath79_switch_data
.phy4_mii_en
= 1;
140 ath79_switch_data
.phy_poll_mask
= BIT(4);
141 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
142 ath79_eth0_data
.phy_mask
= BIT(4);
143 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
144 ath79_register_eth(0);
146 /* GMAC1 is connected to the internal switch, GE1 */
147 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
148 ath79_register_eth(1);
150 ath79_register_wmac(ee
, art
);
153 static void __init
wnr2000v4_setup(void)
157 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v4_leds_gpio
),
158 wnr2000v4_leds_gpio
);
160 ath79_register_gpio_keys_polled(-1, WNR2000V4_KEYS_POLL_INTERVAL
,
161 ARRAY_SIZE(wnr2000v4_gpio_keys
),
162 wnr2000v4_gpio_keys
);
165 MIPS_MACHINE(ATH79_MACH_WNR2000_V4
, "WNR2000V4", "NETGEAR WNR2000 V4", wnr2000v4_setup
);