OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * ZyXEL NBG6716/NBG6616 board support |
||
3 | * |
||
4 | * Based on the Qualcomm Atheros AP135/AP136 reference board support code |
||
5 | * Copyright (c) 2012 Qualcomm Atheros |
||
6 | * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org> |
||
7 | * Copyright (c) 2013 Andre Valentin <avalentin@marcant.net> |
||
8 | * |
||
9 | * Permission to use, copy, modify, and/or distribute this software for any |
||
10 | * purpose with or without fee is hereby granted, provided that the above |
||
11 | * copyright notice and this permission notice appear in all copies. |
||
12 | * |
||
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
20 | * |
||
21 | */ |
||
22 | |||
23 | #include <linux/platform_device.h> |
||
24 | #include <linux/ar8216_platform.h> |
||
25 | #include <linux/gpio.h> |
||
26 | #include <linux/mtd/mtd.h> |
||
27 | #include <linux/mtd/nand.h> |
||
28 | #include <linux/platform/ar934x_nfc.h> |
||
29 | |||
30 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
31 | |||
32 | #include "common.h" |
||
33 | #include "pci.h" |
||
34 | #include "dev-ap9x-pci.h" |
||
35 | #include "dev-gpio-buttons.h" |
||
36 | #include "dev-eth.h" |
||
37 | #include "dev-leds-gpio.h" |
||
38 | #include "dev-nfc.h" |
||
39 | #include "dev-m25p80.h" |
||
40 | #include "dev-usb.h" |
||
41 | #include "dev-wmac.h" |
||
42 | #include "machtypes.h" |
||
43 | #include "nvram.h" |
||
44 | |||
45 | #define NBG6716_GPIO_LED_INTERNET 18 |
||
46 | #define NBG6716_GPIO_LED_POWER 15 |
||
47 | #define NBG6716_GPIO_LED_USB1 4 |
||
48 | #define NBG6716_GPIO_LED_USB2 13 |
||
49 | #define NBG6716_GPIO_LED_WIFI2G 19 |
||
50 | #define NBG6716_GPIO_LED_WIFI5G 17 |
||
51 | #define NBG6716_GPIO_LED_WPS 21 |
||
52 | |||
53 | #define NBG6716_GPIO_BTN_RESET 23 |
||
54 | #define NBG6716_GPIO_BTN_RFKILL 1 |
||
55 | #define NBG6716_GPIO_BTN_USB1 0 |
||
56 | #define NBG6716_GPIO_BTN_USB2 14 |
||
57 | #define NBG6716_GPIO_BTN_WPS 22 |
||
58 | |||
59 | #define NBG6716_GPIO_USB_POWER 16 |
||
60 | |||
61 | #define NBG6716_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
62 | #define NBG6716_KEYS_DEBOUNCE_INTERVAL (3 * NBG6716_KEYS_POLL_INTERVAL) |
||
63 | |||
64 | #define NBG6716_MAC0_OFFSET 0 |
||
65 | #define NBG6716_MAC1_OFFSET 6 |
||
66 | #define NBG6716_WMAC_CALDATA_OFFSET 0x1000 |
||
67 | #define NBG6716_PCIE_CALDATA_OFFSET 0x5000 |
||
68 | |||
69 | /* NBG6616 has a different GPIO usage as it does not have USB Buttons */ |
||
70 | #define NBG6616_GPIO_LED_USB0 14 |
||
71 | #define NBG6616_GPIO_LED_USB1 21 |
||
72 | #define NBG6616_GPIO_LED_WPS 0 |
||
73 | |||
74 | static struct gpio_led nbg6716_leds_gpio[] __initdata = { |
||
75 | { |
||
76 | .name = "nbg6716:white:internet", |
||
77 | .gpio = NBG6716_GPIO_LED_INTERNET, |
||
78 | .active_low = 1, |
||
79 | }, |
||
80 | { |
||
81 | .name = "nbg6716:white:power", |
||
82 | .gpio = NBG6716_GPIO_LED_POWER, |
||
83 | .active_low = 1, |
||
84 | }, |
||
85 | { |
||
86 | .name = "nbg6716:white:usb1", |
||
87 | .gpio = NBG6716_GPIO_LED_USB1, |
||
88 | .active_low = 1, |
||
89 | }, |
||
90 | { |
||
91 | .name = "nbg6716:white:usb2", |
||
92 | .gpio = NBG6716_GPIO_LED_USB2, |
||
93 | .active_low = 1, |
||
94 | }, |
||
95 | { |
||
96 | .name = "nbg6716:white:wifi2g", |
||
97 | .gpio = NBG6716_GPIO_LED_WIFI2G, |
||
98 | .active_low = 1, |
||
99 | }, |
||
100 | { |
||
101 | .name = "nbg6716:white:wifi5g", |
||
102 | .gpio = NBG6716_GPIO_LED_WIFI5G, |
||
103 | .active_low = 1, |
||
104 | }, |
||
105 | { |
||
106 | .name = "nbg6716:white:wps", |
||
107 | .gpio = NBG6716_GPIO_LED_WPS, |
||
108 | .active_low = 1, |
||
109 | } |
||
110 | }; |
||
111 | |||
112 | static struct gpio_keys_button nbg6716_gpio_keys[] __initdata = { |
||
113 | { |
||
114 | .desc = "RESET button", |
||
115 | .type = EV_KEY, |
||
116 | .code = KEY_RESTART, |
||
117 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
118 | .gpio = NBG6716_GPIO_BTN_RESET, |
||
119 | .active_low = 1, |
||
120 | }, |
||
121 | { |
||
122 | .desc = "RFKILL button", |
||
123 | .type = EV_SW, |
||
124 | .code = KEY_RFKILL, |
||
125 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
126 | .gpio = NBG6716_GPIO_BTN_RFKILL, |
||
127 | .active_low = 0, |
||
128 | }, |
||
129 | { |
||
130 | .desc = "USB1 eject button", |
||
131 | .type = EV_KEY, |
||
132 | .code = BTN_1, |
||
133 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
134 | .gpio = NBG6716_GPIO_BTN_USB1, |
||
135 | .active_low = 1, |
||
136 | }, |
||
137 | { |
||
138 | .desc = "USB2 eject button", |
||
139 | .type = EV_KEY, |
||
140 | .code = BTN_2, |
||
141 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
142 | .gpio = NBG6716_GPIO_BTN_USB2, |
||
143 | .active_low = 1, |
||
144 | }, |
||
145 | { |
||
146 | .desc = "WPS button", |
||
147 | .type = EV_KEY, |
||
148 | .code = KEY_WPS_BUTTON, |
||
149 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
150 | .gpio = NBG6716_GPIO_BTN_WPS, |
||
151 | .active_low = 1, |
||
152 | }, |
||
153 | }; |
||
154 | |||
155 | |||
156 | |||
157 | static struct gpio_led nbg6616_leds_gpio[] __initdata = { |
||
158 | { |
||
159 | .name = "nbg6616:green:power", |
||
160 | .gpio = NBG6716_GPIO_LED_POWER, |
||
161 | .active_low = 1, |
||
162 | }, |
||
163 | { |
||
164 | .name = "nbg6616:green:usb2", |
||
165 | .gpio = NBG6616_GPIO_LED_USB0, |
||
166 | .active_low = 1, |
||
167 | }, |
||
168 | { |
||
169 | .name = "nbg6616:green:usb1", |
||
170 | .gpio = NBG6616_GPIO_LED_USB1, |
||
171 | .active_low = 1, |
||
172 | }, |
||
173 | { |
||
174 | .name = "nbg6616:green:wifi2g", |
||
175 | .gpio = NBG6716_GPIO_LED_WIFI2G, |
||
176 | .active_low = 1, |
||
177 | }, |
||
178 | { |
||
179 | .name = "nbg6616:green:wifi5g", |
||
180 | .gpio = NBG6716_GPIO_LED_WIFI5G, |
||
181 | .active_low = 1, |
||
182 | }, |
||
183 | { |
||
184 | .name = "nbg6616:green:wps", |
||
185 | .gpio = NBG6616_GPIO_LED_WPS, |
||
186 | .active_low = 1, |
||
187 | } |
||
188 | }; |
||
189 | |||
190 | static struct gpio_keys_button nbg6616_gpio_keys[] __initdata = { |
||
191 | { |
||
192 | .desc = "RESET button", |
||
193 | .type = EV_KEY, |
||
194 | .code = KEY_RESTART, |
||
195 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
196 | .gpio = NBG6716_GPIO_BTN_RESET, |
||
197 | .active_low = 1, |
||
198 | }, |
||
199 | { |
||
200 | .desc = "RFKILL button", |
||
201 | .type = EV_KEY, |
||
202 | .code = KEY_RFKILL, |
||
203 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
204 | .gpio = NBG6716_GPIO_BTN_RFKILL, |
||
205 | .active_low = 1, |
||
206 | }, |
||
207 | { |
||
208 | .desc = "WPS button", |
||
209 | .type = EV_KEY, |
||
210 | .code = KEY_WPS_BUTTON, |
||
211 | .debounce_interval = NBG6716_KEYS_DEBOUNCE_INTERVAL, |
||
212 | .gpio = NBG6716_GPIO_BTN_WPS, |
||
213 | .active_low = 1, |
||
214 | }, |
||
215 | }; |
||
216 | |||
217 | |||
218 | static struct ar8327_pad_cfg nbg6716_ar8327_pad0_cfg; |
||
219 | static struct ar8327_pad_cfg nbg6716_ar8327_pad6_cfg; |
||
220 | static struct ar8327_led_cfg nbg6716_ar8327_led_cfg; |
||
221 | |||
222 | static struct ar8327_platform_data nbg6716_ar8327_data = { |
||
223 | .pad0_cfg = &nbg6716_ar8327_pad0_cfg, |
||
224 | .pad6_cfg = &nbg6716_ar8327_pad6_cfg, |
||
225 | .port0_cfg = { |
||
226 | .force_link = 1, |
||
227 | .speed = AR8327_PORT_SPEED_1000, |
||
228 | .duplex = 1, |
||
229 | .txpause = 1, |
||
230 | .rxpause = 1, |
||
231 | }, |
||
232 | .port6_cfg = { |
||
233 | .force_link = 1, |
||
234 | .speed = AR8327_PORT_SPEED_1000, |
||
235 | .duplex = 1, |
||
236 | .txpause = 1, |
||
237 | .rxpause = 1, |
||
238 | }, |
||
239 | .led_cfg = &nbg6716_ar8327_led_cfg |
||
240 | }; |
||
241 | |||
242 | static struct mdio_board_info nbg6716_mdio0_info[] = { |
||
243 | { |
||
244 | .bus_id = "ag71xx-mdio.0", |
||
3 | office | 245 | .phy_addr = 0, |
1 | office | 246 | .platform_data = &nbg6716_ar8327_data, |
247 | }, |
||
248 | }; |
||
249 | |||
250 | static void nbg6716_get_mac(void* nvram_addr, const char *name, char *mac) |
||
251 | { |
||
252 | u8 *nvram = (u8 *) KSEG1ADDR(nvram_addr); |
||
253 | int err; |
||
254 | |||
255 | err = ath79_nvram_parse_mac_addr(nvram, 0x10000, |
||
256 | name, mac); |
||
257 | if (err) |
||
258 | pr_err("no MAC address found for %s\n", name); |
||
259 | } |
||
260 | |||
261 | static void __init nbg6716_common_setup(u32 leds_num, struct gpio_led* leds, |
||
262 | u32 keys_num, |
||
263 | struct gpio_keys_button* keys, |
||
264 | void* art_addr, void* nvram) |
||
265 | { |
||
266 | u8 *art = (u8 *) KSEG1ADDR(art_addr); |
||
267 | u8 tmpmac[ETH_ALEN]; |
||
268 | |||
269 | ath79_register_m25p80(NULL); |
||
270 | |||
271 | ath79_register_leds_gpio(-1, leds_num, leds); |
||
272 | ath79_register_gpio_keys_polled(-1, NBG6716_KEYS_POLL_INTERVAL, |
||
273 | keys_num, keys); |
||
274 | |||
275 | ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW); |
||
276 | ath79_register_nfc(); |
||
277 | |||
278 | gpio_request_one(NBG6716_GPIO_USB_POWER, |
||
279 | GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, |
||
280 | "USB power"); |
||
281 | |||
282 | ath79_register_usb(); |
||
283 | |||
284 | nbg6716_get_mac(nvram, "ethaddr=", tmpmac); |
||
285 | |||
286 | ath79_register_pci(); |
||
287 | |||
288 | ath79_register_wmac(art + NBG6716_WMAC_CALDATA_OFFSET, tmpmac); |
||
289 | |||
290 | ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN); |
||
291 | |||
292 | ath79_register_mdio(0, 0x0); |
||
293 | |||
294 | ath79_init_mac(ath79_eth0_data.mac_addr, tmpmac, 2); |
||
295 | ath79_init_mac(ath79_eth1_data.mac_addr, tmpmac, 3); |
||
296 | |||
297 | mdiobus_register_board_info(nbg6716_mdio0_info, |
||
298 | ARRAY_SIZE(nbg6716_mdio0_info)); |
||
299 | |||
300 | /* GMAC0 is connected to the RMGII interface */ |
||
301 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
302 | ath79_eth0_data.phy_mask = BIT(0); |
||
303 | ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
||
304 | |||
305 | ath79_register_eth(0); |
||
306 | |||
307 | /* GMAC1 is connected to the SGMII interface */ |
||
308 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; |
||
309 | ath79_eth1_data.speed = SPEED_1000; |
||
310 | ath79_eth1_data.duplex = DUPLEX_FULL; |
||
311 | |||
312 | ath79_register_eth(1); |
||
313 | } |
||
314 | |||
315 | static void __init nbg6716_010_setup(void) |
||
316 | { |
||
317 | /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */ |
||
318 | nbg6716_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII; |
||
319 | nbg6716_ar8327_pad0_cfg.txclk_delay_en = true; |
||
320 | nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true; |
||
321 | nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1; |
||
322 | nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2; |
||
323 | |||
324 | /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */ |
||
325 | nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII; |
||
326 | nbg6716_ar8327_pad6_cfg.rxclk_delay_en = true; |
||
327 | nbg6716_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0; |
||
328 | |||
329 | ath79_eth0_pll_data.pll_1000 = 0xa6000000; |
||
330 | ath79_eth1_pll_data.pll_1000 = 0x03000101; |
||
331 | |||
332 | nbg6716_ar8327_led_cfg.open_drain = 0; |
||
333 | nbg6716_ar8327_led_cfg.led_ctrl0 = 0xffb7ffb7; |
||
334 | nbg6716_ar8327_led_cfg.led_ctrl1 = 0xffb7ffb7; |
||
335 | nbg6716_ar8327_led_cfg.led_ctrl2 = 0xffb7ffb7; |
||
336 | nbg6716_ar8327_led_cfg.led_ctrl3 = 0x03ffff00; |
||
337 | |||
338 | nbg6716_common_setup(ARRAY_SIZE(nbg6716_leds_gpio), nbg6716_leds_gpio, |
||
339 | ARRAY_SIZE(nbg6716_gpio_keys), nbg6716_gpio_keys, |
||
340 | (void*) 0x1f050000, (void*) 0x1f040000); |
||
341 | } |
||
342 | |||
343 | static void __init nbg6616_010_setup(void) |
||
344 | { |
||
345 | /* GMAC0 of the AR8337 switch is connected to GMAC0 via RGMII */ |
||
346 | nbg6716_ar8327_pad0_cfg.mode = AR8327_PAD_MAC_RGMII; |
||
347 | nbg6716_ar8327_pad0_cfg.txclk_delay_en = true; |
||
348 | nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true; |
||
349 | nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1; |
||
350 | nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2; |
||
351 | |||
352 | /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */ |
||
353 | nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII; |
||
354 | nbg6716_ar8327_pad6_cfg.rxclk_delay_en = true; |
||
355 | nbg6716_ar8327_pad6_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL0; |
||
356 | |||
357 | ath79_eth0_pll_data.pll_1000 = 0xa6000000; |
||
358 | ath79_eth1_pll_data.pll_1000 = 0x03000101; |
||
359 | |||
360 | nbg6716_ar8327_led_cfg.open_drain = 0; |
||
361 | nbg6716_ar8327_led_cfg.led_ctrl0 = 0xffb7ffb7; |
||
362 | nbg6716_ar8327_led_cfg.led_ctrl1 = 0xffb7ffb7; |
||
363 | nbg6716_ar8327_led_cfg.led_ctrl2 = 0xffb7ffb7; |
||
364 | nbg6716_ar8327_led_cfg.led_ctrl3 = 0x03ffff00; |
||
365 | |||
366 | |||
367 | nbg6716_common_setup(ARRAY_SIZE(nbg6616_leds_gpio), nbg6616_leds_gpio, |
||
368 | ARRAY_SIZE(nbg6616_gpio_keys), nbg6616_gpio_keys, |
||
369 | (void*) 0x1f040000, (void*) 0x1f030000); |
||
370 | } |
||
371 | |||
372 | |||
373 | MIPS_MACHINE(ATH79_MACH_NBG6716, "NBG6716", |
||
374 | "Zyxel NBG6716", |
||
375 | nbg6716_010_setup); |
||
376 | |||
377 | MIPS_MACHINE(ATH79_MACH_NBG6616, "NBG6616", |
||
378 | "Zyxel NBG6616", |
||
379 | nbg6616_010_setup); |
||
380 |