ar71xx: fix spelling, add copyright on wnr2000-v4
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wnr2000-v4.c
1 /*
2 * NETGEAR WNR2000v4 board support
3 *
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>
10 *
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.
14 */
15
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/platform_device.h>
19
20 #include <asm/mach-ath79/ath79.h>
21 #include <asm/mach-ath79/ar71xx_regs.h>
22
23 #include "common.h"
24 #include "dev-eth.h"
25 #include "dev-gpio-buttons.h"
26 #include "dev-leds-gpio.h"
27 #include "dev-m25p80.h"
28 #include "dev-usb.h"
29 #include "dev-wmac.h"
30 #include "machtypes.h"
31
32 /* AR9341 GPIOs */
33 #define WNR2000V4_GPIO_LED_WAN_AMBER 22
34 #define WNR2000V4_GPIO_LED_WAN_GREEN 17
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 STATUS_LED_GPIO 1
46 #define WNR2000V4_GPIO_LED_PWR_GREEN 0
47
48 #define WNR2000V4_GPIO_BTN_WPS 3
49 #define WNR2000V4_GPIO_BTN_RESET 4
50 #define WNR2000V4_GPIO_BTN_WLAN 11
51
52 #define WNR2000V4_KEYS_POLL_INTERVAL 20 /* msecs */
53 #define WNR2000V4_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000V4_KEYS_POLL_INTERVAL)
54
55 #define WNR2000V4_MAC0_OFFSET 0
56 #define WNR2000V4_MAC1_OFFSET 6
57
58 static struct gpio_led wnr2000v4_leds_gpio[] __initdata = {
59 {
60 .name = "netgear:green:power",
61 .gpio = WNR2000V4_GPIO_LED_PWR_GREEN,
62 .active_low = 1,
63 .default_trigger = "default-on",
64 }, {
65 .name = "netgear:green:wan",
66 .gpio = WNR2000V4_GPIO_LED_WAN_GREEN,
67 .active_low = 1,
68 }, {
69 .name = "netgear:amber:wan",
70 .gpio = WNR2000V4_GPIO_LED_WAN_AMBER,
71 .active_low = 1,
72 },
73 {
74 .name = "netgear:green:wps",
75 .gpio = WNR2000V4_GPIO_LED_WPS,
76 .active_low = 1,
77 },
78 {
79 .name = "netgear:amber:status",
80 .gpio = STATUS_LED_GPIO,
81 .active_low = 1,
82 },
83 {
84 .name = "netgear:blue:wlan",
85 .gpio = WNR2000V4_GPIO_LED_WLAN,
86 .active_low = 1,
87 },
88 /* LAN LEDS */
89 {
90 .name = "netgear:green:lan1",
91 .gpio = WNR2000V4_GPIO_LED_LAN1_GREEN,
92 .active_low = 1,
93 }, {
94 .name = "netgear:green:lan2",
95 .gpio = WNR2000V4_GPIO_LED_LAN2_GREEN,
96 .active_low = 1,
97 }, {
98 .name = "netgear:green:lan3",
99 .gpio = WNR2000V4_GPIO_LED_LAN3_GREEN,
100 .active_low = 1,
101 }, {
102 .name = "netgear:green:lan4",
103 .gpio = WNR2000V4_GPIO_LED_LAN4_GREEN,
104 .active_low = 1,
105 },
106 {
107 .name = "netgear:amber:lan1",
108 .gpio = WNR2000V4_GPIO_LED_LAN1_AMBER,
109 .active_low = 1,
110 }, {
111 .name = "netgear:amber:lan2",
112 .gpio = WNR2000V4_GPIO_LED_LAN2_AMBER,
113 .active_low = 1,
114 }, {
115 .name = "netgear:amber:lan3",
116 .gpio = WNR2000V4_GPIO_LED_LAN3_AMBER,
117 .active_low = 1,
118 }, {
119 .name = "netgear:amber:lan4",
120 .gpio = WNR2000V4_GPIO_LED_LAN4_AMBER,
121 .active_low = 1,
122 }
123 };
124
125 static struct gpio_keys_button wnr2000v4_gpio_keys[] __initdata = {
126 {
127 .desc = "WPS button",
128 .type = EV_KEY,
129 .code = KEY_WPS_BUTTON,
130 .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
131 .gpio = WNR2000V4_GPIO_BTN_WPS,
132 .active_low = 1,
133 },
134 {
135 .desc = "Reset button",
136 .type = EV_KEY,
137 .code = KEY_RESTART,
138 .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
139 .gpio = WNR2000V4_GPIO_BTN_RESET,
140 .active_low = 1,
141 },
142 {
143 .desc = "WLAN button",
144 .type = EV_KEY,
145 .code = KEY_RFKILL,
146 .debounce_interval = WNR2000V4_KEYS_DEBOUNCE_INTERVAL,
147 .gpio = WNR2000V4_GPIO_BTN_WLAN,
148 .active_low = 1,
149 },
150 };
151
152 static void __init wnr_common_setup(void)
153 {
154 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
155 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
156
157 ath79_register_mdio(1, 0x0);
158
159 ath79_register_usb();
160
161 ath79_register_m25p80(NULL);
162
163 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
164
165 ath79_init_mac(ath79_eth0_data.mac_addr, art+WNR2000V4_MAC0_OFFSET, 0);
166 ath79_init_mac(ath79_eth1_data.mac_addr, art+WNR2000V4_MAC1_OFFSET, 0);
167
168 /* GMAC0 is connected to the PHY0 of the internal switch, GE0 */
169 ath79_switch_data.phy4_mii_en = 1;
170 ath79_switch_data.phy_poll_mask = BIT(4);
171 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
172 ath79_eth0_data.phy_mask = BIT(4);
173 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
174 ath79_register_eth(0);
175
176 /* GMAC1 is connected to the internal switch, GE1 */
177 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
178 ath79_register_eth(1);
179
180 ath79_register_wmac(ee, art);
181 }
182
183 static void __init wnr2000v4_setup(void)
184 {
185 int i;
186
187 wnr_common_setup();
188
189 /* Ensure no LED has an internal MUX signal, otherwise
190 control of LED could be lost... This is especially important
191 for most green LEDS (Eth,WAN).. who arrive in this function with
192 MUX signals set. */
193 for (i = 0; i < ARRAY_SIZE(wnr2000v4_leds_gpio); i++)
194 ath79_gpio_output_select(wnr2000v4_leds_gpio[i].gpio,
195 AR934X_GPIO_OUT_GPIO);
196
197 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000v4_leds_gpio),
198 wnr2000v4_leds_gpio);
199
200 ath79_register_gpio_keys_polled(-1, WNR2000V4_KEYS_POLL_INTERVAL,
201 ARRAY_SIZE(wnr2000v4_gpio_keys),
202 wnr2000v4_gpio_keys);
203 }
204
205 MIPS_MACHINE(ATH79_MACH_WNR2000_V4, "WNR2000V4", "NETGEAR WNR2000 V4", wnr2000v4_setup);