From 8257859d48229f00e021c2a2a36dd46b579da687 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 11 Mar 2013 15:55:20 +0000 Subject: ar71xx: add kernel support for MR3420v2 [juhosg: use gpio_request_one to enable the USB power] Patch-by: Dmytro Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35961 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/arch/mips/ath79/mach-tl-wr841n-v8.c | 81 ++++++++++++++++++---- 1 file changed, 69 insertions(+), 12 deletions(-) (limited to 'target/linux/ar71xx/files') diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c index ffaf8d1552..976c7ee261 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr841n-v8.c @@ -1,5 +1,5 @@ /* - * TP-LINK TL-WR841N/ND v8 board support + * TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support * * Copyright (C) 2012 Gabor Juhos * @@ -8,6 +8,7 @@ * by the Free Software Foundation. */ +#include #include #include @@ -18,6 +19,7 @@ #include "dev-gpio-buttons.h" #include "dev-leds-gpio.h" #include "dev-m25p80.h" +#include "dev-usb.h" #include "dev-wmac.h" #include "machtypes.h" @@ -31,7 +33,10 @@ #define TL_WR841NV8_GPIO_LED_SYSTEM 14 #define TL_WR841NV8_GPIO_BTN_RESET 17 -#define TL_WR841NV8_GPIO_SW_RFKILL 16 +#define TL_WR841NV8_GPIO_SW_RFKILL 16 /* WPS for MR3420 v2 */ + +#define TL_MR3420V2_GPIO_LED_3G 11 +#define TL_MR3420V2_GPIO_USB_POWER 4 #define TL_WR841NV8_KEYS_POLL_INTERVAL 20 /* msecs */ #define TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR841NV8_KEYS_POLL_INTERVAL) @@ -78,6 +83,11 @@ static struct gpio_led tl_wr841n_v8_leds_gpio[] __initdata = { .name = "tp-link:green:wlan", .gpio = TL_WR841NV8_GPIO_LED_WLAN, .active_low = 1, + }, { + /* the 3G LED is only present on the MR3420 v2 */ + .name = "tp-link:green:3g", + .gpio = TL_MR3420V2_GPIO_LED_3G, + .active_low = 1, }, }; @@ -99,24 +109,33 @@ static struct gpio_keys_button tl_wr841n_v8_gpio_keys[] __initdata = { } }; -static void __init tl_wr841n_v8_setup(void) +static struct gpio_keys_button tl_mr3420v2_gpio_keys[] __initdata = { + { + .desc = "Reset button", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL, + .gpio = TL_WR841NV8_GPIO_BTN_RESET, + .active_low = 1, + }, { + .desc = "WPS", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .debounce_interval = TL_WR841NV8_KEYS_DEBOUNCE_INTERVAL, + .gpio = TL_WR841NV8_GPIO_SW_RFKILL, + .active_low = 0, + } +}; + +static void __init tl_ap123_setup(void) { u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); - ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio), - tl_wr841n_v8_leds_gpio); - - ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL, - ARRAY_SIZE(tl_wr841n_v8_gpio_keys), - tl_wr841n_v8_gpio_keys); - ath79_register_m25p80(&tl_wr841n_v8_flash_data); ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_PHY_SWAP); - ath79_register_mdio(1, 0x0); - ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1); ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0); @@ -135,5 +154,43 @@ static void __init tl_wr841n_v8_setup(void) ath79_register_wmac(ee, mac); } +static void __init tl_wr841n_v8_setup(void) +{ + tl_ap123_setup(); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio) - 1, + tl_wr841n_v8_leds_gpio); + + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL, + ARRAY_SIZE(tl_wr841n_v8_gpio_keys), + tl_wr841n_v8_gpio_keys); + + ath79_register_mdio(1, 0x0); +} + MIPS_MACHINE(ATH79_MACH_TL_WR841N_V8, "TL-WR841N-v8", "TP-LINK TL-WR841N/ND v8", tl_wr841n_v8_setup); + +static void __init tl_mr3420v2_setup(void) +{ + tl_ap123_setup(); + + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v8_leds_gpio), + tl_wr841n_v8_leds_gpio); + + ath79_register_gpio_keys_polled(1, TL_WR841NV8_KEYS_POLL_INTERVAL, + ARRAY_SIZE(tl_mr3420v2_gpio_keys), + tl_mr3420v2_gpio_keys); + + ath79_register_mdio(0, 0x0); + + /* enable power for the USB port */ + gpio_request_one(TL_MR3420V2_GPIO_USB_POWER, + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, + "USB power"); + + ath79_register_usb(); +} + +MIPS_MACHINE(ATH79_MACH_TL_MR3420_V2, "TL-MR3420-v2", "TP-LINK TL-MR3420 v2", + tl_mr3420v2_setup); -- cgit v1.2.3