From: Gabor Juhos Date: Mon, 11 Mar 2013 15:55:20 +0000 (+0000) Subject: ar71xx: add kernel support for MR3420v2 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=902dd273837632007ce15b9a3898e90c4809736e;p=openwrt%2Fstaging%2Fmkresin.git ar71xx: add kernel support for MR3420v2 [juhosg: use gpio_request_one to enable the USB power] Patch-by: Dmytro Signed-off-by: Gabor Juhos SVN-Revision: 35961 --- 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); diff --git a/target/linux/ar71xx/patches-3.8/616-MIPS-ath79-TL-MR3420-v2-support.patch b/target/linux/ar71xx/patches-3.8/616-MIPS-ath79-TL-MR3420-v2-support.patch new file mode 100644 index 0000000000..855bb9614d --- /dev/null +++ b/target/linux/ar71xx/patches-3.8/616-MIPS-ath79-TL-MR3420-v2-support.patch @@ -0,0 +1,27 @@ +--- a/arch/mips/ath79/Kconfig ++++ b/arch/mips/ath79/Kconfig +@@ -585,12 +585,13 @@ config ATH79_MACH_TL_WR841N_V1 + select ATH79_DEV_M25P80 + + config ATH79_MACH_TL_WR841N_V8 +- bool "TP-LINK TL-WR841N/ND v8 support" ++ bool "TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 support" + select SOC_AR934X + select ATH79_DEV_ETH + select ATH79_DEV_GPIO_BUTTONS + select ATH79_DEV_LEDS_GPIO + select ATH79_DEV_M25P80 ++ select ATH79_DEV_USB + select ATH79_DEV_WMAC + + config ATH79_MACH_TL_WR941ND +--- a/arch/mips/ath79/machtypes.h ++++ b/arch/mips/ath79/machtypes.h +@@ -84,6 +84,7 @@ enum ath79_mach_type { + ATH79_MACH_TL_MR3220, /* TP-LINK TL-MR3220 */ + ATH79_MACH_TL_MR3220_V2, /* TP-LINK TL-MR3220 v2 */ + ATH79_MACH_TL_MR3420, /* TP-LINK TL-MR3420 */ ++ ATH79_MACH_TL_MR3420_V2, /* TP-LINK TL-MR3420 v2 */ + ATH79_MACH_TL_WA7510N_V1, /* TP-LINK TL-WA7510N v1*/ + ATH79_MACH_TL_WA901ND, /* TP-LINK TL-WA901ND */ + ATH79_MACH_TL_WA901ND_V2, /* TP-LINK TL-WA901ND v2 */