2 * TP-LINK TL-WA830RE v2 board support
4 * Copyright (C) 2014 Fredrik Jonson <fredrik@famjonson.se>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/gpio.h>
12 #include <linux/platform_device.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define TL_WA830REV2_GPIO_LED_WLAN 13
27 #define TL_WA830REV2_GPIO_LED_QSS 15
28 #define TL_WA830REV2_GPIO_LED_LAN 18
29 #define TL_WA830REV2_GPIO_LED_SYSTEM 14
31 #define TL_WA830REV2_GPIO_BTN_RESET 17
32 #define TL_WA830REV2_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */
34 #define TL_WA830REV2_GPIO_USB_POWER 4
36 #define TL_WA830REV2_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WA830REV2_KEYS_POLL_INTERVAL)
39 static const char *tl_wa830re_v2_part_probes
[] = {
44 static struct flash_platform_data tl_wa830re_v2_flash_data
= {
45 .part_probes
= tl_wa830re_v2_part_probes
,
48 static struct gpio_led tl_wa830re_v2_leds_gpio
[] __initdata
= {
50 .name
= "tp-link:green:qss",
51 .gpio
= TL_WA830REV2_GPIO_LED_QSS
,
54 .name
= "tp-link:green:system",
55 .gpio
= TL_WA830REV2_GPIO_LED_SYSTEM
,
58 .name
= "tp-link:green:lan",
59 .gpio
= TL_WA830REV2_GPIO_LED_LAN
,
62 .name
= "tp-link:green:wlan",
63 .gpio
= TL_WA830REV2_GPIO_LED_WLAN
,
68 static struct gpio_keys_button tl_wa830re_v2_gpio_keys
[] __initdata
= {
70 .desc
= "Reset button",
73 .debounce_interval
= TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL
,
74 .gpio
= TL_WA830REV2_GPIO_BTN_RESET
,
77 .desc
= "RFKILL switch",
80 .debounce_interval
= TL_WA830REV2_KEYS_DEBOUNCE_INTERVAL
,
81 .gpio
= TL_WA830REV2_GPIO_SW_RFKILL
,
86 static void __init
tl_ap123_setup(void)
88 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
89 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
91 /* Disable JTAG, enabling GPIOs 0-3 */
92 /* Configure OBS4 line, for GPIO 4*/
93 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE
,
94 AR934X_GPIO_FUNC_CLK_OBS4_EN
);
96 /* config gpio4 as normal gpio function */
97 ath79_gpio_output_select(TL_WA830REV2_GPIO_USB_POWER
,
98 AR934X_GPIO_OUT_GPIO
);
100 ath79_register_m25p80(&tl_wa830re_v2_flash_data
);
102 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP
);
104 ath79_register_mdio(1, 0x0);
106 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
108 /* GMAC0 is connected to the PHY0 of the internal switch */
109 ath79_switch_data
.phy4_mii_en
= 1;
110 ath79_switch_data
.phy_poll_mask
= BIT(0);
111 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
112 ath79_eth0_data
.phy_mask
= BIT(0);
113 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
114 ath79_register_eth(0);
116 ath79_register_wmac(ee
, mac
);
119 static void __init
tl_wa830re_v2_setup(void)
123 ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wa830re_v2_leds_gpio
) - 1,
124 tl_wa830re_v2_leds_gpio
);
126 ath79_register_gpio_keys_polled(1, TL_WA830REV2_KEYS_POLL_INTERVAL
,
127 ARRAY_SIZE(tl_wa830re_v2_gpio_keys
),
128 tl_wa830re_v2_gpio_keys
);
131 MIPS_MACHINE(ATH79_MACH_TL_WA830RE_V2
, "TL-WA830RE-v2", "TP-LINK TL-WA830RE v2",
132 tl_wa830re_v2_setup
);