Index: target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr3500.c
===================================================================
--- target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr3500.c	(revision 0)
+++ target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wdr3500.c	(revision 0)
@@ -0,0 +1,139 @@
+/*
+ *  TP-LINK TL-WDR3500 board support
+ *
+ *  Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
+ *  Copyright (C) 2013 Gui Iribarren <gui@altermundi.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/pci.h>
+#include <linux/phy.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/ath9k_platform.h>
+#include <linux/ar8216_platform.h>
+
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+#include "common.h"
+#include "dev-ap9x-pci.h"
+#include "dev-eth.h"
+#include "dev-gpio-buttons.h"
+#include "dev-leds-gpio.h"
+#include "dev-m25p80.h"
+#include "dev-spi.h"
+#include "dev-usb.h"
+#include "dev-wmac.h"
+#include "machtypes.h"
+
+#define WDR3500_GPIO_LED_USB1		11
+#define WDR3500_GPIO_LED_WLAN2G		13
+#define WDR3500_GPIO_LED_SYSTEM		14
+#define WDR3500_GPIO_LED_QSS		15
+
+#define WDR3500_GPIO_BTN_WPS		16
+#define WDR3500_GPIO_BTN_RFKILL		17
+
+#define WDR3500_GPIO_USB1_POWER		22
+
+#define WDR3500_KEYS_POLL_INTERVAL	20	/* msecs */
+#define WDR3500_KEYS_DEBOUNCE_INTERVAL	(3 * WDR3500_KEYS_POLL_INTERVAL)
+
+#define WDR3500_MAC0_OFFSET		0
+#define WDR3500_MAC1_OFFSET		6
+#define WDR3500_WMAC_CALDATA_OFFSET	0x1000
+#define WDR3500_PCIE_CALDATA_OFFSET	0x5000
+
+static const char *wdr3500_part_probes[] = {
+	"tp-link",
+	NULL,
+};
+
+static struct flash_platform_data wdr3500_flash_data = {
+	.part_probes	= wdr3500_part_probes,
+};
+
+static struct gpio_led wdr3500_leds_gpio[] __initdata = {
+	{
+		.name		= "tp-link:blue:qss",
+		.gpio		= WDR3500_GPIO_LED_QSS,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:blue:system",
+		.gpio		= WDR3500_GPIO_LED_SYSTEM,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:green:usb1",
+		.gpio		= WDR3500_GPIO_LED_USB1,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:blue:wlan2g",
+		.gpio		= WDR3500_GPIO_LED_WLAN2G,
+		.active_low	= 1,
+	},
+};
+
+static struct gpio_keys_button wdr3500_gpio_keys[] __initdata = {
+	{
+		.desc		= "QSS button",
+		.type		= EV_KEY,
+		.code		= KEY_WPS_BUTTON,
+		.debounce_interval = WDR3500_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= WDR3500_GPIO_BTN_WPS,
+		.active_low	= 1,
+	},
+	{
+		.desc		= "RFKILL switch",
+		.type		= EV_SW,
+		.code		= KEY_RFKILL,
+		.debounce_interval = WDR3500_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= WDR3500_GPIO_BTN_RFKILL,
+	},
+};
+
+
+static void __init wdr3500_setup(void)
+{
+	u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
+
+	ath79_register_m25p80(&wdr3500_flash_data);
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(wdr3500_leds_gpio),
+				 wdr3500_leds_gpio);
+	ath79_register_gpio_keys_polled(-1, WDR3500_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(wdr3500_gpio_keys),
+					wdr3500_gpio_keys);
+
+	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);
+
+	/* GMAC0 is connected to the PHY0 of the internal switch */
+	ath79_switch_data.phy4_mii_en = 1;
+	ath79_switch_data.phy_poll_mask = BIT(0);
+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
+	ath79_eth0_data.phy_mask = BIT(0);
+	ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
+	ath79_register_eth(0);
+
+	/* GMAC1 is connected to the internal switch */
+	ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
+	ath79_register_eth(1);
+
+	gpio_request_one(WDR3500_GPIO_USB1_POWER,
+			 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
+			 "USB1 power");
+	ath79_register_usb();
+}
+
+MIPS_MACHINE(ATH79_MACH_TL_WDR3500, "TL-WDR3500",
+	     "TP-LINK TL-WDR3500",
+	     wdr3500_setup);
Index: target/linux/ar71xx/image/Makefile
===================================================================
--- target/linux/ar71xx/image/Makefile	(revision 35162)
+++ target/linux/ar71xx/image/Makefile	(working copy)
@@ -913,6 +913,7 @@
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWR841NV8,tl-wr841n-v8,TL-WR841N-v8,ttyS0,115200,0x08410008,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWR1041,tl-wr1041n-v2,TL-WR1041N-v2,ttyS0,115200,0x10410002,1,4Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWR2543,tl-wr2543-v1,TL-WR2543N,ttyS0,115200,0x25430001,1,8Mlzma,-v 3.13.99))
+$(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWDR3500V1,tl-wdr3500-v1,TL-WDR3500,ttyS0,115200,0x35000001,1,8Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWDR3600V1,tl-wdr3600-v1,TL-WDR4300,ttyS0,115200,0x36000001,1,8Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWDR4300V1,tl-wdr4300-v1,TL-WDR4300,ttyS0,115200,0x43000001,1,8Mlzma))
 $(eval $(call SingleProfile,TPLINK-LZMA,$(fs_64kraw),TLWDR4310V1,tl-wdr4310-v1,TL-WDR4300,ttyS0,115200,0x43100001,1,8Mlzma))
@@ -963,7 +964,7 @@
 $(eval $(call MultiProfile,TLWR741,TLWR741NV1 TLWR741NV2 TLWR741NV4))
 $(eval $(call MultiProfile,TLWR841,TLWR841NV15 TLWR841NV3 TLWR841NV5 TLWR841NV7 TLWR841NV8))
 $(eval $(call MultiProfile,TLWR941,TLWR941NV2 TLWR941NV3 TLWR941NV4))
-$(eval $(call MultiProfile,TLWDR4300,TLWDR3600V1 TLWDR4300V1 TLWDR4310V1))
+$(eval $(call MultiProfile,TLWDR4300,TLWDR3500V1 TLWDR3600V1 TLWDR4300V1 TLWDR4310V1))
 $(eval $(call MultiProfile,UBNT,UBNTAIRROUTER UBNTRS UBNTRSPRO UBNTLSSR71 UBNTBULLETM UBNTROCKETM UBNTNANOM UBNTUNIFI UBNTUNIFIOUTDOOR UAPPRO))
 $(eval $(call MultiProfile,WNDR3700,WNDR3700V1 WNDR3700V2 WNDR3800 WNDRMAC WNDRMACV2))
 $(eval $(call MultiProfile,WP543,WP543_2M WP543_4M WP543_8M WP543_16M))
Index: target/linux/ar71xx/base-files/lib/ar71xx.sh
===================================================================
--- target/linux/ar71xx/base-files/lib/ar71xx.sh	(revision 35162)
+++ target/linux/ar71xx/base-files/lib/ar71xx.sh	(working copy)
@@ -123,6 +123,9 @@
 	"342000"*)
 		model="TP-Link TL-MR3420"
 		;;
+	"350000"*)
+		model="TP-Link TL-WDR3500"
+		;;
 	"360000"*)
 		model="TP-Link TL-WDR3600"
 		;;
@@ -366,6 +369,9 @@
 	*"TL-WA901ND v2")
 		name="tl-wa901nd-v2"
 		;;
+	*"TL-WDR3500")
+		name="tl-wdr3500"
+		;;
 	*"TL-WDR3600/4300/4310")
 		name="tl-wdr4300"
 		;;
Index: target/linux/ar71xx/config-3.7
===================================================================
--- target/linux/ar71xx/config-3.7	(revision 35162)
+++ target/linux/ar71xx/config-3.7	(working copy)
@@ -63,6 +63,7 @@
 CONFIG_ATH79_MACH_TL_MR3X20=y
 CONFIG_ATH79_MACH_TL_WA901ND=y
 CONFIG_ATH79_MACH_TL_WA901ND_V2=y
+CONFIG_ATH79_MACH_TL_WDR3500=y
 CONFIG_ATH79_MACH_TL_WDR4300=y
 CONFIG_ATH79_MACH_TL_WR1041N_V2=y
 CONFIG_ATH79_MACH_TL_WR1043ND=y
Index: target/linux/ar71xx/generic/profiles/tp-link.mk
===================================================================
--- target/linux/ar71xx/generic/profiles/tp-link.mk	(revision 35162)
+++ target/linux/ar71xx/generic/profiles/tp-link.mk	(working copy)
@@ -115,12 +115,12 @@
 
 
 define Profile/TLWDR4300
-	NAME:=TP-LINK TL-WDR3600/4300/4310
+	NAME:=TP-LINK TL-WDR3500/3600/4300/4310
 	PACKAGES:=kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev
 endef
 
 define Profile/TLWDR4300/Description
-	Package set optimized for the TP-LINK TL-WDR3600/4300/4310.
+	Package set optimized for the TP-LINK TL-WDR3500/3600/4300/4310.
 endef
 $(eval $(call Profile,TLWDR4300))
 
Index: target/linux/ar71xx/patches-3.7/610-MIPS-ath79-openwrt-machines.patch
===================================================================
--- target/linux/ar71xx/patches-3.7/610-MIPS-ath79-openwrt-machines.patch	(revision 35162)
+++ target/linux/ar71xx/patches-3.7/610-MIPS-ath79-openwrt-machines.patch	(working copy)
@@ -1,6 +1,8 @@
---- a/arch/mips/ath79/machtypes.h
-+++ b/arch/mips/ath79/machtypes.h
-@@ -16,22 +16,112 @@
+Index: linux-3.7.2/arch/mips/ath79/machtypes.h
+===================================================================
+--- linux-3.7.2.orig/arch/mips/ath79/machtypes.h	2013-01-19 19:19:59.820770571 -0300
++++ linux-3.7.2/arch/mips/ath79/machtypes.h	2013-01-19 19:28:26.029039311 -0300
+@@ -16,22 +16,113 @@
  
  enum ath79_mach_type {
  	ATH79_MACH_GENERIC = 0,
@@ -70,6 +72,7 @@
 +	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 */
++	ATH79_MACH_TL_WDR3500,		/* TP-LINK TL-WDR3500 */
 +	ATH79_MACH_TL_WDR4300,		/* TP-LINK TL-WDR4300 */
 +	ATH79_MACH_TL_WR1041N_V2,	/* TP-LINK TL-WR1041N v2 */
 +	ATH79_MACH_TL_WR1043ND,		/* TP-LINK TL-WR1043ND */
@@ -113,9 +116,11 @@
  };
  
  #endif /* _ATH79_MACHTYPE_H */
---- a/arch/mips/ath79/Kconfig
-+++ b/arch/mips/ath79/Kconfig
-@@ -2,6 +2,61 @@ if ATH79
+Index: linux-3.7.2/arch/mips/ath79/Kconfig
+===================================================================
+--- linux-3.7.2.orig/arch/mips/ath79/Kconfig	2013-01-19 19:19:59.820770571 -0300
++++ linux-3.7.2/arch/mips/ath79/Kconfig	2013-01-19 19:27:47.009514821 -0300
+@@ -2,6 +2,61 @@
  
  menu "Atheros AR71XX/AR724X/AR913X machine selection"
  
@@ -177,7 +182,7 @@
  config ATH79_MACH_AP121
  	bool "Atheros AP121 reference board"
  	select SOC_AR933X
-@@ -41,6 +96,24 @@ config ATH79_MACH_AP81
+@@ -41,6 +96,24 @@
  	  Say 'Y' here if you want your kernel to support the
  	  Atheros AP81 reference board.
  
@@ -202,7 +207,7 @@
  config ATH79_MACH_DB120
  	bool "Atheros DB120 reference board"
  	select SOC_AR934X
-@@ -56,6 +129,13 @@ config ATH79_MACH_DB120
+@@ -56,6 +129,13 @@
  	  Say 'Y' here if you want your kernel to support the
  	  Atheros DB120 reference board.
  
@@ -216,7 +221,7 @@
  config ATH79_MACH_PB44
  	bool "Atheros PB44 reference board"
  	select SOC_AR71XX
-@@ -68,6 +148,488 @@ config ATH79_MACH_PB44
+@@ -68,6 +148,499 @@
  	  Say 'Y' here if you want your kernel to support the
  	  Atheros PB44 reference board.
  
@@ -563,6 +568,17 @@
 +	select ATH79_DEV_M25P80
 +	select ATH79_DEV_WMAC
 +
++config ATH79_MACH_TL_WDR3500
++	bool "TP-LINK TL-WDR3500 board support"
++	select SOC_AR934X
++	select ATH79_DEV_AP9X_PCI if PCI
++	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_WDR4300
 +	bool "TP-LINK TL-WDR3600/4300/4310 board support"
 +	select SOC_AR934X
@@ -705,7 +721,7 @@
  config ATH79_MACH_UBNT_XM
  	bool "Ubiquiti Networks XM/UniFi boards"
  	select SOC_AR724X
-@@ -83,6 +645,24 @@ config ATH79_MACH_UBNT_XM
+@@ -83,6 +656,24 @@
  	  Say 'Y' here if you want your kernel to support the
  	  Ubiquiti Networks XM (rev 1.0) board.
  
@@ -730,7 +746,7 @@
  endmenu
  
  config SOC_AR71XX
-@@ -118,10 +698,6 @@ config SOC_QCA955X
+@@ -118,10 +709,6 @@
  	select PCI_AR724X if PCI
  	def_bool n
  
@@ -741,7 +757,7 @@
  config ATH79_DEV_AP9X_PCI
  	select ATH79_PCI_ATH9K_FIXUP
  	def_bool n
-@@ -132,7 +708,14 @@ config ATH79_DEV_DSA
+@@ -132,7 +719,14 @@
  config ATH79_DEV_ETH
  	def_bool n
  
@@ -757,7 +773,7 @@
  	def_bool n
  
  config ATH79_DEV_GPIO_BUTTONS
-@@ -164,4 +747,7 @@ config ATH79_PCI_ATH9K_FIXUP
+@@ -164,4 +758,7 @@
  config ATH79_ROUTERBOOT
  	def_bool n
  
@@ -765,9 +781,11 @@
 +	def_bool n
 +
  endif
---- a/arch/mips/ath79/Makefile
-+++ b/arch/mips/ath79/Makefile
-@@ -38,9 +38,71 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)		+= route
+Index: linux-3.7.2/arch/mips/ath79/Makefile
+===================================================================
+--- linux-3.7.2.orig/arch/mips/ath79/Makefile	2013-01-19 19:19:59.584779159 -0300
++++ linux-3.7.2/arch/mips/ath79/Makefile	2013-01-19 19:28:52.673543920 -0300
+@@ -38,9 +38,72 @@
  #
  # Machines
  #
@@ -812,6 +830,7 @@
 +obj-$(CONFIG_ATH79_MACH_TL_MR3X20)	+= mach-tl-mr3x20.o
 +obj-$(CONFIG_ATH79_MACH_TL_WA901ND)	+= mach-tl-wa901nd.o
 +obj-$(CONFIG_ATH79_MACH_TL_WA901ND_V2)	+= mach-tl-wa901nd-v2.o
++obj-$(CONFIG_ATH79_MACH_TL_WDR3500)     += mach-tl-wdr3500.o
 +obj-$(CONFIG_ATH79_MACH_TL_WDR4300)     += mach-tl-wdr4300.o
 +obj-$(CONFIG_ATH79_MACH_TL_WR741ND)	+= mach-tl-wr741nd.o
 +obj-$(CONFIG_ATH79_MACH_TL_WR741ND_V4)	+= mach-tl-wr741nd-v4.o
@@ -839,9 +858,11 @@
 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H)	+= mach-wzr-hp-g450h.o
 +obj-$(CONFIG_ATH79_MACH_ZCN_1523H)	+= mach-zcn-1523h.o
 +
---- a/arch/mips/ath79/prom.c
-+++ b/arch/mips/ath79/prom.c
-@@ -180,6 +180,10 @@ void __init prom_init(void)
+Index: linux-3.7.2/arch/mips/ath79/prom.c
+===================================================================
+--- linux-3.7.2.orig/arch/mips/ath79/prom.c	2013-01-19 19:19:59.257658577 -0300
++++ linux-3.7.2/arch/mips/ath79/prom.c	2013-01-19 19:19:59.856749020 -0300
+@@ -180,6 +180,10 @@
  			ath79_prom_append_cmdline("board", env);
  		}
  	}
