ar71xx: wpa8630: change board name to tl-wpa8630
[openwrt/staging/wigyori.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-dragino2.c
1 /*
2 * DRAGINO V2 board support, based on Atheros AP121 board support
3 *
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2012 Elektra Wagenrad <elektra@villagetelco.org>
6 * Copyright (C) 2014 Vittorio Gambaletta <openwrt@vittgam.net>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13 #include <linux/gpio.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
16 #include "common.h"
17 #include "dev-eth.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21 #include "dev-spi.h"
22 #include "dev-usb.h"
23 #include "dev-wmac.h"
24 #include "machtypes.h"
25
26 #define DRAGINO2_GPIO_LED_WLAN 0
27 #define DRAGINO2_GPIO_LED_LAN 13
28 #define DRAGINO2_GPIO_LED_WAN 17
29
30 /*
31 * The following GPIO is named "SYS" on newer revisions of the the board.
32 * It was previously used to indicate USB activity, even though it was
33 * named "Router".
34 */
35
36 #define DRAGINO2_GPIO_LED_SYS 28
37 #define DRAGINO2_GPIO_BTN_JUMPSTART 11
38 #define DRAGINO2_GPIO_BTN_RESET 12
39
40 #define DRAGINO2_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define DRAGINO2_KEYS_DEBOUNCE_INTERVAL (3 * DRAGINO2_KEYS_POLL_INTERVAL)
42
43 #define DRAGINO2_MAC0_OFFSET 0x0000
44 #define DRAGINO2_MAC1_OFFSET 0x0006
45 #define DRAGINO2_CALDATA_OFFSET 0x1000
46 #define DRAGINO2_WMAC_MAC_OFFSET 0x1002
47
48 static struct gpio_led dragino2_leds_gpio[] __initdata = {
49 {
50 .name = "dragino2:red:wlan",
51 .gpio = DRAGINO2_GPIO_LED_WLAN,
52 .active_low = 0,
53 },
54 {
55 .name = "dragino2:red:wan",
56 .gpio = DRAGINO2_GPIO_LED_WAN,
57 .active_low = 1,
58 },
59 {
60 .name = "dragino2:red:lan",
61 .gpio = DRAGINO2_GPIO_LED_LAN,
62 .active_low = 1,
63 },
64 {
65 .name = "dragino2:red:system",
66 .gpio = DRAGINO2_GPIO_LED_SYS,
67 .active_low = 0,
68 },
69 };
70
71 static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
72 {
73 .desc = "jumpstart button",
74 .type = EV_KEY,
75 .code = KEY_WPS_BUTTON,
76 .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
77 .gpio = DRAGINO2_GPIO_BTN_JUMPSTART,
78 .active_low = 1,
79 },
80 {
81 .desc = "reset button",
82 .type = EV_KEY,
83 .code = KEY_RESTART,
84 .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
85 .gpio = DRAGINO2_GPIO_BTN_RESET,
86 .active_low = 1,
87 }
88 };
89
90 static void __init dragino2_common_setup(void)
91 {
92 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
93
94 ath79_register_m25p80(NULL);
95 ath79_register_wmac(art + DRAGINO2_CALDATA_OFFSET,
96 art + DRAGINO2_WMAC_MAC_OFFSET);
97
98 ath79_init_mac(ath79_eth0_data.mac_addr, art + DRAGINO2_MAC0_OFFSET, 0);
99 ath79_init_mac(ath79_eth1_data.mac_addr, art + DRAGINO2_MAC1_OFFSET, 0);
100
101 ath79_register_mdio(0, 0x0);
102
103 /* Enable GPIO13, GPIO14, GPIO15, GPIO16 and GPIO17 */
104 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
105 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
106 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
107 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
108 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
109
110 /* LAN port */
111 ath79_register_eth(1);
112
113 /* WAN port */
114 ath79_register_eth(0);
115
116 /* Enable GPIO26 and GPIO27 */
117 ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP,
118 ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP) |
119 AR933X_BOOTSTRAP_MDIO_GPIO_EN);
120 }
121
122 static void __init dragino2_setup(void)
123 {
124 dragino2_common_setup();
125
126 ath79_register_leds_gpio(-1, ARRAY_SIZE(dragino2_leds_gpio),
127 dragino2_leds_gpio);
128 ath79_register_gpio_keys_polled(-1, DRAGINO2_KEYS_POLL_INTERVAL,
129 ARRAY_SIZE(dragino2_gpio_keys),
130 dragino2_gpio_keys);
131 ath79_register_usb();
132 }
133
134 MIPS_MACHINE(ATH79_MACH_DRAGINO2, "DRAGINO2", "Dragino Dragino v2",
135 dragino2_setup);
136