2 * DRAGINO V2 board support, based on Atheros AP121 board support
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>
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.
13 #include <linux/gpio.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define DRAGINO2_GPIO_LED_WLAN 0
27 #define DRAGINO2_GPIO_LED_LAN 13
28 #define DRAGINO2_GPIO_LED_WAN 17
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
36 #define DRAGINO2_GPIO_LED_SYS 28
37 #define DRAGINO2_GPIO_BTN_JUMPSTART 11
38 #define DRAGINO2_GPIO_BTN_RESET 12
40 #define DRAGINO2_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define DRAGINO2_KEYS_DEBOUNCE_INTERVAL (3 * DRAGINO2_KEYS_POLL_INTERVAL)
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
48 static struct gpio_led dragino2_leds_gpio[] __initdata = {
50 .name = "dragino2:red:wlan",
51 .gpio = DRAGINO2_GPIO_LED_WLAN,
55 .name = "dragino2:red:wan",
56 .gpio = DRAGINO2_GPIO_LED_WAN,
60 .name = "dragino2:red:lan",
61 .gpio = DRAGINO2_GPIO_LED_LAN,
65 .name = "dragino2:red:system",
66 .gpio = DRAGINO2_GPIO_LED_SYS,
71 static struct gpio_keys_button dragino2_gpio_keys[] __initdata = {
73 .desc = "jumpstart button",
75 .code = KEY_WPS_BUTTON,
76 .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
77 .gpio = DRAGINO2_GPIO_BTN_JUMPSTART,
81 .desc = "reset button",
84 .debounce_interval = DRAGINO2_KEYS_DEBOUNCE_INTERVAL,
85 .gpio = DRAGINO2_GPIO_BTN_RESET,
90 static void __init dragino2_common_setup(void)
92 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
94 ath79_register_m25p80(NULL);
95 ath79_register_wmac(art + DRAGINO2_CALDATA_OFFSET,
96 art + DRAGINO2_WMAC_MAC_OFFSET);
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);
101 ath79_register_mdio(0, 0x0);
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);
111 ath79_register_eth(1);
114 ath79_register_eth(0);
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);
122 static void __init dragino2_setup(void)
124 dragino2_common_setup();
126 ath79_register_leds_gpio(-1, ARRAY_SIZE(dragino2_leds_gpio),
128 ath79_register_gpio_keys_polled(-1, DRAGINO2_KEYS_POLL_INTERVAL,
129 ARRAY_SIZE(dragino2_gpio_keys),
131 ath79_register_usb();
134 MIPS_MACHINE(ATH79_MACH_DRAGINO2, "DRAGINO2", "Dragino Dragino v2",