diff mbox

[OpenWrt-Devel,4/4] a71xx: add support for TP-Link RE450

Message ID 1452127248-21017-4-git-send-email-kooolk@gmail.com
State Changes Requested
Headers show

Commit Message

Tal Keren Jan. 7, 2016, 12:40 a.m. UTC
Add full support for TP-Link RE450.
The wireless SoC is similiar to Archer C7: QCA9558 + QCA9880 (pci).
The ethernet interface is AR8035, but the mdio is connected to the gpio and
the chipset builtin mdio bus isn't used, which is unique (and weird), so the
kernel gpio mdio module is used.
The two ethernet leds are connected to the GPIO, so they are both configured,
one to indicate link status and the other to indicate data transfer.

The generation of the image was added to the image Makefile.
The return value of tplink-safeloader is not ignored anymore (to fail on error)

The result factory image is flashable from the stock web ui.

Signed-off-by: Tal Keren <kooolk@gmail.com>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   9 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   1 +
 target/linux/ar71xx/base-files/etc/diag.sh         |   3 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata       |   4 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh      |   1 +
 target/linux/ar71xx/config-4.1                     |   3 +
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  10 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../ar71xx/files/arch/mips/ath79/mach-re450.c      | 189 +++++++++++++++++++++
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/generic/profiles/tp-link.mk    |  11 ++
 target/linux/ar71xx/image/Makefile                 |  46 ++++-
 target/linux/ar71xx/mikrotik/config-default        |   1 +
 target/linux/ar71xx/nand/config-default            |   1 +
 15 files changed, 279 insertions(+), 5 deletions(-)
 create mode 100755 target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c

Comments

John Crispin Jan. 19, 2016, 9:32 a.m. UTC | #1
Hi,

again lots of changes all thrown into one patch.

changes like
> -define Image/Build/TPLINK-SAFELOADER
> +define Image/Build/TPLINK-SAFELOADER-ELF

need to be in their own patch.

and the following
> +# mktplinkfw-kernel <kernel-file> <output-file> <hw-id>
> +define Build/mktplinkfw-kernel
> +	$(STAGING_DIR_HOST)/bin/mktplinkfw-kernel \
> +		-H $3 -N OpenWrt -V $(REVISION) \
> +		-L $(KERNEL_LOADADDR) -E $(KERNEL_LOADADDR) \
> +		-k $1 \
> +		-o $2
> +endef
> +
should be part of the patch adding the tool rather than the board patch.
it might even qualify for its own patch.

	John



On 07/01/2016 01:40, Tal Keren wrote:
> Add full support for TP-Link RE450.
> The wireless SoC is similiar to Archer C7: QCA9558 + QCA9880 (pci).
> The ethernet interface is AR8035, but the mdio is connected to the gpio and
> the chipset builtin mdio bus isn't used, which is unique (and weird), so the
> kernel gpio mdio module is used.
> The two ethernet leds are connected to the GPIO, so they are both configured,
> one to indicate link status and the other to indicate data transfer.
> 
> The generation of the image was added to the image Makefile.
> The return value of tplink-safeloader is not ignored anymore (to fail on error)
> 
> The result factory image is flashable from the stock web ui.
> 
> Signed-off-by: Tal Keren <kooolk@gmail.com>
> ---
>  target/linux/ar71xx/base-files/etc/board.d/01_leds |   9 +
>  .../linux/ar71xx/base-files/etc/board.d/02_network |   1 +
>  target/linux/ar71xx/base-files/etc/diag.sh         |   3 +
>  .../etc/hotplug.d/firmware/11-ath10k-caldata       |   4 +
>  target/linux/ar71xx/base-files/lib/ar71xx.sh       |   3 +
>  .../ar71xx/base-files/lib/upgrade/platform.sh      |   1 +
>  target/linux/ar71xx/config-4.1                     |   3 +
>  .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  10 ++
>  target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
>  .../ar71xx/files/arch/mips/ath79/mach-re450.c      | 189 +++++++++++++++++++++
>  .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
>  target/linux/ar71xx/generic/profiles/tp-link.mk    |  11 ++
>  target/linux/ar71xx/image/Makefile                 |  46 ++++-
>  target/linux/ar71xx/mikrotik/config-default        |   1 +
>  target/linux/ar71xx/nand/config-default            |   1 +
>  15 files changed, 279 insertions(+), 5 deletions(-)
>  create mode 100755 target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c
> 
> diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
> index cfb42a5..88d1a9c 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
> +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
> @@ -398,6 +398,15 @@ qihoo-c301)
>  	ucidef_set_led_wlan "wlan2g" "WLAN2G" "qihoo:red:status" "phy1tpt"
>  	;;
>  
> +re450)
> +	ucidef_set_led_netdev "lan_data" "LAN Data" "tp-link:green:lan_data" "eth0" "tx rx"
> +	ucidef_set_led_netdev "lan_link" "LAN Link" "tp-link:green:lan_link" "eth0" "link"
> +	ucidef_set_led_default "wps" "WPS" "tp-link:blue:wps" "0"
> +	ucidef_set_led_default "wps_error" "WPS Error" "tp-link:red:wps" "0"
> +	ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "tp-link:blue:wlan2g" "phy1tpt"
> +	ucidef_set_led_wlan "wlan5g" "WLAN 5 GHz" "tp-link:blue:wlan5g" "phy0tpt"
> +	;;
> +
>  smart-300)
>  	ucidef_set_led_netdev "wan" "WAN" "nc-link:green:wan" "eth0"
>  	ucidef_set_led_switch "lan1" "LAN1" "nc-link:green:lan1" "switch0" "0x04"
> diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
> index 6b6c6a4..8c16c53 100755
> --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
> +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
> @@ -340,6 +340,7 @@ rb-912uag-2hpnd |\
>  rb-912uag-5hpnd |\
>  rb-sxt2n |\
>  rb-sxt5n |\
> +re450 |\
>  rocket-m-xw |\
>  tl-mr10u |\
>  tl-mr11u |\
> diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
> index 13a0a98..077a6a9 100644
> --- a/target/linux/ar71xx/base-files/etc/diag.sh
> +++ b/target/linux/ar71xx/base-files/etc/diag.sh
> @@ -245,6 +245,9 @@ get_status_led() {
>  	rb-sxt5n)
>  		status_led="rb:green:power"
>  		;;
> +	re450)
> +		status_led="tp-link:blue:system"
> +		;;
>  	routerstation | routerstation-pro)
>  		status_led="ubnt:green:rf"
>  		;;
> diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> index 74c3417..88eb10a 100644
> --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
> @@ -75,6 +75,10 @@ case "$FIRMWARE" in
>  		ath10kcal_extract "ART" 20480 2116
>  		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
>  		;;
> +	re450)
> +		ath10kcal_extract "art" 20480 2116
> +		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
> +		;;
>  	esac
>  	;;
>  "ath10k/cal-pci-0000:01:00.0.bin")
> diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> index 678482e..5853633 100755
> --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
> +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
> @@ -644,6 +644,9 @@ ar71xx_board_detect() {
>  	*"Qihoo 360 C301")
>  		name="qihoo-c301"
>  		;;
> +	*"RE450")
> +		name="re450"
> +		;;
>  	*"RouterBOARD 411/A/AH")
>  		name="rb-411"
>  		;;
> diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> index e662524..f267420 100755
> --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
> @@ -333,6 +333,7 @@ platform_check_image() {
>  	minibox-v1 |\
>  	onion-omega | \
>  	oolite | \
> +	re450 | \
>  	smart-300 | \
>  	tl-mr10u | \
>  	tl-mr11u | \
> diff --git a/target/linux/ar71xx/config-4.1 b/target/linux/ar71xx/config-4.1
> index fe1dd68..b511686 100644
> --- a/target/linux/ar71xx/config-4.1
> +++ b/target/linux/ar71xx/config-4.1
> @@ -121,6 +121,7 @@ CONFIG_ATH79_MACH_R6100=y
>  # CONFIG_ATH79_MACH_RB922 is not set
>  # CONFIG_ATH79_MACH_RB95X is not set
>  # CONFIG_ATH79_MACH_RBSXTLITE is not set
> +CONFIG_ATH79_MACH_RE450=y
>  CONFIG_ATH79_MACH_RW2458N=y
>  CONFIG_ATH79_MACH_SMART_300=y
>  CONFIG_ATH79_MACH_TEW_632BRP=y
> @@ -282,7 +283,9 @@ CONFIG_IRQ_WORK=y
>  CONFIG_LEDS_GPIO=y
>  # CONFIG_LEDS_WNDR3700_USB is not set
>  CONFIG_MARVELL_PHY=y
> +CONFIG_MDIO_BITBANG=y
>  CONFIG_MDIO_BOARDINFO=y
> +CONFIG_MDIO_GPIO=y
>  CONFIG_MICREL_PHY=y
>  CONFIG_MIPS=y
>  # CONFIG_MIPS_HUGE_TLB_SUPPORT is not set
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> index cdd4fa2..703e299 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
> @@ -1022,6 +1022,16 @@ config ATH79_MACH_CPE510
>  	select ATH79_DEV_M25P80
>  	select ATH79_DEV_WMAC
>  
> +config ATH79_MACH_RE450
> +	bool "TP-LINK RE450 board support"
> +	select SOC_QCA955X
> +	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_WMAC
> +
>  config ATH79_MACH_TL_MR11U
>  	bool "TP-LINK TL-MR11U/TL-MR3040 support"
>  	select SOC_AR933X
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> index 991f6f2..094816e 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
> @@ -128,6 +128,7 @@ obj-$(CONFIG_ATH79_MACH_RB922)		+= mach-rb922.o
>  obj-$(CONFIG_ATH79_MACH_RB95X)		+= mach-rb95x.o
>  obj-$(CONFIG_ATH79_MACH_RB2011)		+= mach-rb2011.o
>  obj-$(CONFIG_ATH79_MACH_RBSXTLITE)	+= mach-rbsxtlite.o
> +obj-$(CONFIG_ATH79_MACH_RE450)		+= mach-re450.o
>  obj-$(CONFIG_ATH79_MACH_RW2458N)	+= mach-rw2458n.o
>  obj-$(CONFIG_ATH79_MACH_SMART_300)	+= mach-smart-300.o
>  obj-$(CONFIG_ATH79_MACH_TEW_632BRP)	+= mach-tew-632brp.o
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c
> new file mode 100755
> index 0000000..55414de
> --- /dev/null
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c
> @@ -0,0 +1,189 @@
> +/*
> + * TP-LINK Archer RE450 board support
> + *
> + * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
> + * Copyright (c) 2016 Tal Keren <kooolk@gmail.com>
> + *
> + * Based on the Qualcomm Atheros AP135/AP136 reference board support code
> + *   Copyright (c) 2012 Qualcomm Atheros
> + *
> + * Permission to use, copy, modify, and/or distribute this software for any
> + * purpose with or without fee is hereby granted, provided that the above
> + * copyright notice and this permission notice appear in all copies.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> + *
> + */
> +
> +#include <linux/pci.h>
> +#include <linux/phy.h>
> +#include <linux/gpio.h>
> +#include <linux/mdio-gpio.h>
> +#include <linux/platform_device.h>
> +#include <linux/ar8216_platform.h>
> +
> +#include <asm/mach-ath79/ath79.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-wmac.h"
> +#include "machtypes.h"
> +#include "pci.h"
> +
> +#define RE450_GPIO_LED_SYSTEM		12
> +#define RE450_GPIO_LED_WLAN2G		13
> +#define RE450_GPIO_LED_WLAN5G		14
> +#define RE450_GPIO_LED_LAN_DATA		17
> +#define RE450_GPIO_LED_JUMPSTART	21
> +#define RE450_GPIO_LED_JUMPSTART_RED	22
> +#define RE450_GPIO_LED_LAN_LINK		23
> +
> +#define RE450_GPIO_BTN_RESET		18
> +#define RE450_GPIO_BTN_LED		19
> +#define RE450_GPIO_BTN_JUMPSTART	20
> +
> +#define RE450_GPIO_SMI_MDIO		1
> +#define RE450_GPIO_SMI_MDC		3
> +
> +#define RE450_LAN_PHYADDR		4
> +
> +#define RE450_KEYS_POLL_INTERVAL	20	/* msecs */
> +#define RE450_KEYS_DEBOUNCE_INTERVAL (3 * RE450_KEYS_POLL_INTERVAL)
> +
> +#define RE450_WMAC_CALDATA_OFFSET	0x1000
> +
> +static const char *tl_re450_part_probes[] = {
> +	"cmdlinepart",
> +	NULL,
> +};
> +
> +static struct flash_platform_data tl_re450_flash_data = {
> +	.part_probes	= tl_re450_part_probes,
> +};
> +
> +static struct gpio_led re450_leds_gpio[] __initdata = {
> +	{
> +		.name		= "tp-link:blue:system",
> +		.gpio		= RE450_GPIO_LED_SYSTEM,
> +		.active_low	= 1,
> +	},
> +	{
> +		.name		= "tp-link:blue:wlan2g",
> +		.gpio		= RE450_GPIO_LED_WLAN2G,
> +		.active_low	= 1,
> +	},
> +	{
> +		.name		= "tp-link:blue:wlan5g",
> +		.gpio		= RE450_GPIO_LED_WLAN5G,
> +		.active_low	= 1,
> +	},
> +	{
> +		.name		= "tp-link:blue:wps",
> +		.gpio		= RE450_GPIO_LED_JUMPSTART,
> +	},
> +	{
> +		.name		= "tp-link:red:wps",
> +		.gpio		= RE450_GPIO_LED_JUMPSTART_RED,
> +	},
> +	{
> +		.name		= "tp-link:green:lan_data",
> +		.gpio		= RE450_GPIO_LED_LAN_DATA,
> +		.active_low	= 1,
> +	},
> +	{
> +		.name		= "tp-link:green:lan_link",
> +		.gpio		= RE450_GPIO_LED_LAN_LINK,
> +		.active_low	= 1,
> +	},
> +};
> +
> +static struct gpio_keys_button re450_gpio_keys[] __initdata = {
> +	{
> +		.desc		= "Reset button",
> +		.type		= EV_KEY,
> +		.code		= KEY_WPS_BUTTON,
> +		.debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
> +		.gpio		= RE450_GPIO_BTN_RESET,
> +		.active_low	= 1,
> +	},
> +	{
> +		.desc		= "WPS button",
> +		.type		= EV_KEY,
> +		.code		= KEY_RESTART,
> +		.debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
> +		.gpio		= RE450_GPIO_BTN_JUMPSTART,
> +		.active_low	= 1,
> +	},
> +	{
> +		.desc		= "Control LED button",
> +		.type		= EV_KEY,
> +		.code		= BTN_0,
> +		.debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
> +		.gpio		= RE450_GPIO_BTN_LED,
> +		.active_low	= 1,
> +	},
> +};
> +
> +static struct mdio_gpio_platform_data re450_mdio = {
> +	.mdc		= RE450_GPIO_SMI_MDC,
> +	.mdio		= RE450_GPIO_SMI_MDIO,
> +	.phy_mask	= ~BIT(RE450_LAN_PHYADDR),
> +};
> +
> +static struct platform_device re450_phy_device = {
> +	.name	= "mdio-gpio",
> +	.id	= 0,
> +	.dev	= {
> +		.platform_data = &re450_mdio,
> +	},
> +};
> +
> +
> +static void __init re450_setup(void)
> +{
> +	u8 *mac = (u8 *) KSEG1ADDR(0x1f610008);
> +	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
> +	u8 tmpmac[ETH_ALEN];
> +
> +	ath79_register_m25p80(&tl_re450_flash_data);
> +	ath79_register_leds_gpio(-1, ARRAY_SIZE(re450_leds_gpio),
> +				 re450_leds_gpio);
> +	ath79_register_gpio_keys_polled(-1, RE450_KEYS_POLL_INTERVAL,
> +					ARRAY_SIZE(re450_gpio_keys),
> +					re450_gpio_keys);
> +
> +	ath79_init_mac(tmpmac, mac, -1);
> +	ath79_register_wmac(art + RE450_WMAC_CALDATA_OFFSET, tmpmac);
> +
> +	ath79_register_pci();
> +
> +	/* MDIO Interface */
> +	platform_device_register(&re450_phy_device);
> +
> +	ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
> +
> +	/* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
> +	ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
> +	ath79_eth0_data.mii_bus_dev = &re450_phy_device.dev;
> +	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
> +	ath79_eth0_data.phy_mask = BIT(RE450_LAN_PHYADDR);
> +	ath79_eth0_pll_data.pll_1000 = 0xa6000000;
> +	ath79_eth0_pll_data.pll_100 = 0xa0000101;
> +	ath79_eth0_pll_data.pll_10 = 0x80001313;
> +	ath79_register_eth(0);
> +}
> +
> +MIPS_MACHINE(ATH79_MACH_RE450, "RE450", "TP-LINK RE450",
> +	     re450_setup)
> +
> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> index d12829f..5e3f088 100644
> --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
> @@ -141,6 +141,7 @@ enum ath79_mach_type {
>  	ATH79_MACH_RB_2011R5,		/* Mikrotik RouterBOARD 2011UiAS(-2Hnd) */
>  	ATH79_MACH_RB_SXTLITE2ND,	/* Mikrotik RouterBOARD SXT Lite 2nD */
>  	ATH79_MACH_RB_SXTLITE5ND,	/* Mikrotik RouterBOARD SXT Lite 5nD */
> +	ATH79_MACH_RE450,		/* TP-LINK RE450 */
>  	ATH79_MACH_RW2458N,		/* Redwave RW2458N */
>  	ATH79_MACH_SMART_300,		/* NC-LINK SMART-300 */
>  	ATH79_MACH_TEW_632BRP,		/* TRENDnet TEW-632BRP */
> diff --git a/target/linux/ar71xx/generic/profiles/tp-link.mk b/target/linux/ar71xx/generic/profiles/tp-link.mk
> index 2875290..96b8bfb 100644
> --- a/target/linux/ar71xx/generic/profiles/tp-link.mk
> +++ b/target/linux/ar71xx/generic/profiles/tp-link.mk
> @@ -27,6 +27,17 @@ endef
>  $(eval $(call Profile,CPE510))
>  
>  
> +define Profile/RE450
> +	NAME:=TP-LINK RE450
> +	PACKAGES:=kmod-ath10k
> +endef
> +
> +define Profile/RE450/Description
> +	Package set optimized for the TP-LINK RE450.
> +endef
> +$(eval $(call Profile,RE450))
> +
> +
>  define Profile/TLMR10U
>  	NAME:=TP-LINK TL-MR10U
>  	PACKAGES:=kmod-usb-core kmod-usb2
> diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
> index 31eb345..26882e1 100644
> --- a/target/linux/ar71xx/image/Makefile
> +++ b/target/linux/ar71xx/image/Makefile
> @@ -71,6 +71,15 @@ define Build/mktplinkfw-initramfs
>  	@mv $@.new $@
>  endef
>  
> +# mktplinkfw-kernel <kernel-file> <output-file> <hw-id>
> +define Build/mktplinkfw-kernel
> +	$(STAGING_DIR_HOST)/bin/mktplinkfw-kernel \
> +		-H $3 -N OpenWrt -V $(REVISION) \
> +		-L $(KERNEL_LOADADDR) -E $(KERNEL_LOADADDR) \
> +		-k $1 \
> +		-o $2
> +endef
> +
>  define Build/loader-common
>  	rm -rf $@.src
>  	$(MAKE) -C lzma-loader \
> @@ -1566,6 +1575,7 @@ mr12_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13440k(rootfs),
>  mr16_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13440k(rootfs),2304k(kernel),128k(art)ro,15744k@0x80000(firmware)
>  pb92_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
>  planex_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),128k(art)ro
> +re450_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,1280k(kernel),4736k(rootfs),64k(pation-table)ro,64k(product-info)ro,1856k(config)ro,64k(art)ro,6016k@0x20000(firmware)
>  ubntxm_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
>  uap_pro_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1536k(kernel),14208k(rootfs),256k(cfg)ro,64k(EEPROM)ro,15744k@0x50000(firmware)
>  ubdev_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware),64k(certs),256k(cfg)ro,64k(EEPROM)ro
> @@ -2001,19 +2011,19 @@ define Image/Build/Senao
>  		$(call sysupname,$(1),$(2))
>  endef
>  
> -Image/Build/TPLINK-SAFELOADER/loader = $(call Image/BuildLoaderPatched,$(1),elf,$(2) $(3))
> +Image/Build/TPLINK-SAFELOADER-ELF/loader = $(call Image/BuildLoaderPatched,$(1),elf,$(2) $(3))
>  
> -define Image/Build/TPLINK-SAFELOADER
> +define Image/Build/TPLINK-SAFELOADER-ELF
>  	[ -e "$(KDIR)/loader-$(2).elf" ]
>  
> -	-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
> +	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
>  		-B $(5) \
>  		-k $(KDIR)/loader-$(2).elf \
>  		-r $(KDIR)/root.$(1) \
>  		-V $(REVISION) \
>  		-j \
>  		-o $(call factoryname,$(1),$(2))
> -	-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
> +	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
>  		-B $(5) \
>  		-k $(KDIR)/loader-$(2).elf \
>  		-r $(KDIR)/root.$(1) \
> @@ -2023,6 +2033,31 @@ define Image/Build/TPLINK-SAFELOADER
>  endef
>  
>  
> +define Image/Build/TPLINK-SAFELOADER-TPLINK/buildkernel
> +	$(call PatchKernelLzma,$(2),$(3) $(4))
> +	$(call Build/mktplinkfw-kernel,$(KDIR_TMP)/vmlinux-$(2).bin.lzma,$(KDIR_TMP)/vmlinux-$(2).tplink.bin,$6)
> +endef
> +
> +define Image/Build/TPLINK-SAFELOADER-TPLINK
> +	[ -e "$(KDIR_TMP)/vmlinux-$(2).tplink.bin" ]
> +
> +	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
> +		-B $(5) \
> +		-k $(KDIR_TMP)/vmlinux-$(2).tplink.bin \
> +		-r $(KDIR)/root.$(1) \
> +		-V $(REVISION) \
> +		-j \
> +		-o $(call factoryname,$(1),$(2))
> +	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
> +		-B $(5) \
> +		-k $(KDIR_TMP)/vmlinux-$(2).tplink.bin \
> +		-r $(KDIR)/root.$(1) \
> +		-V $(REVISION) \
> +		-j -S \
> +		-o $(call sysupname,$(1),$(2))
> +endef
> +
> +
>  define Image/Build/CyberTAN
>  	echo -n '' > $(KDIR_TMP)/empty.bin
>  	$(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp \
> @@ -2461,7 +2496,8 @@ $(eval $(call SingleProfile,Seama,64k,QIHOO360,qihoo-c301,QIHOO-C301,ttyS0,11520
>  
>  $(eval $(call SingleProfile,Senao,squashfs-only,EAP300V2,eap300v2,EAP300V2,ttyS0,115200,$$(eap300v2_mtdlayout)))
>  
> -$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
> +$(eval $(call SingleProfile,TPLINK-SAFELOADER-ELF,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
> +$(eval $(call SingleProfile,TPLINK-SAFELOADER-TPLINK,64kraw,RE450,re450,RE450,ttyS0,115200,$$(re450_mtdlayout),RE450,0x04500100))
>  
>  $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRG301N,whr-g301n,WHR-G301N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-G301N))
>  $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRHPG300N,whr-hp-g300n,WHR-HP-G300N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-HP-G300N))
> diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
> index 88ac6cf..983017b 100644
> --- a/target/linux/ar71xx/mikrotik/config-default
> +++ b/target/linux/ar71xx/mikrotik/config-default
> @@ -71,6 +71,7 @@ CONFIG_ATH79_MACH_RB91X=y
>  CONFIG_ATH79_MACH_RB922=y
>  CONFIG_ATH79_MACH_RB95X=y
>  CONFIG_ATH79_MACH_RBSXTLITE=y
> +# CONFIG_ATH79_MACH_RE450 is not set
>  # CONFIG_ATH79_MACH_RW2458N is not set
>  # CONFIG_ATH79_MACH_SMART_300 is not set
>  # CONFIG_ATH79_MACH_TEW_632BRP is not set
> diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
> index e67d1ad..3632fd2 100644
> --- a/target/linux/ar71xx/nand/config-default
> +++ b/target/linux/ar71xx/nand/config-default
> @@ -38,6 +38,7 @@
>  # CONFIG_ATH79_MACH_PB42 is not set
>  # CONFIG_ATH79_MACH_PB44 is not set
>  # CONFIG_ATH79_MACH_PB92 is not set
> +# CONFIG_ATH79_MACH_RE450 is not set
>  # CONFIG_ATH79_MACH_RW2458N is not set
>  # CONFIG_ATH79_MACH_TEW_632BRP is not set
>  # CONFIG_ATH79_MACH_TEW_673GRU is not set
>
diff mbox

Patch

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index cfb42a5..88d1a9c 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -398,6 +398,15 @@  qihoo-c301)
 	ucidef_set_led_wlan "wlan2g" "WLAN2G" "qihoo:red:status" "phy1tpt"
 	;;
 
+re450)
+	ucidef_set_led_netdev "lan_data" "LAN Data" "tp-link:green:lan_data" "eth0" "tx rx"
+	ucidef_set_led_netdev "lan_link" "LAN Link" "tp-link:green:lan_link" "eth0" "link"
+	ucidef_set_led_default "wps" "WPS" "tp-link:blue:wps" "0"
+	ucidef_set_led_default "wps_error" "WPS Error" "tp-link:red:wps" "0"
+	ucidef_set_led_wlan "wlan2g" "WLAN 2.4 GHz" "tp-link:blue:wlan2g" "phy1tpt"
+	ucidef_set_led_wlan "wlan5g" "WLAN 5 GHz" "tp-link:blue:wlan5g" "phy0tpt"
+	;;
+
 smart-300)
 	ucidef_set_led_netdev "wan" "WAN" "nc-link:green:wan" "eth0"
 	ucidef_set_led_switch "lan1" "LAN1" "nc-link:green:lan1" "switch0" "0x04"
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 6b6c6a4..8c16c53 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -340,6 +340,7 @@  rb-912uag-2hpnd |\
 rb-912uag-5hpnd |\
 rb-sxt2n |\
 rb-sxt5n |\
+re450 |\
 rocket-m-xw |\
 tl-mr10u |\
 tl-mr11u |\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index 13a0a98..077a6a9 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -245,6 +245,9 @@  get_status_led() {
 	rb-sxt5n)
 		status_led="rb:green:power"
 		;;
+	re450)
+		status_led="tp-link:blue:system"
+		;;
 	routerstation | routerstation-pro)
 		status_led="ubnt:green:rf"
 		;;
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 74c3417..88eb10a 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -75,6 +75,10 @@  case "$FIRMWARE" in
 		ath10kcal_extract "ART" 20480 2116
 		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) +16)
 		;;
+	re450)
+		ath10kcal_extract "art" 20480 2116
+		ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
+		;;
 	esac
 	;;
 "ath10k/cal-pci-0000:01:00.0.bin")
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 678482e..5853633 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -644,6 +644,9 @@  ar71xx_board_detect() {
 	*"Qihoo 360 C301")
 		name="qihoo-c301"
 		;;
+	*"RE450")
+		name="re450"
+		;;
 	*"RouterBOARD 411/A/AH")
 		name="rb-411"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index e662524..f267420 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -333,6 +333,7 @@  platform_check_image() {
 	minibox-v1 |\
 	onion-omega | \
 	oolite | \
+	re450 | \
 	smart-300 | \
 	tl-mr10u | \
 	tl-mr11u | \
diff --git a/target/linux/ar71xx/config-4.1 b/target/linux/ar71xx/config-4.1
index fe1dd68..b511686 100644
--- a/target/linux/ar71xx/config-4.1
+++ b/target/linux/ar71xx/config-4.1
@@ -121,6 +121,7 @@  CONFIG_ATH79_MACH_R6100=y
 # CONFIG_ATH79_MACH_RB922 is not set
 # CONFIG_ATH79_MACH_RB95X is not set
 # CONFIG_ATH79_MACH_RBSXTLITE is not set
+CONFIG_ATH79_MACH_RE450=y
 CONFIG_ATH79_MACH_RW2458N=y
 CONFIG_ATH79_MACH_SMART_300=y
 CONFIG_ATH79_MACH_TEW_632BRP=y
@@ -282,7 +283,9 @@  CONFIG_IRQ_WORK=y
 CONFIG_LEDS_GPIO=y
 # CONFIG_LEDS_WNDR3700_USB is not set
 CONFIG_MARVELL_PHY=y
+CONFIG_MDIO_BITBANG=y
 CONFIG_MDIO_BOARDINFO=y
+CONFIG_MDIO_GPIO=y
 CONFIG_MICREL_PHY=y
 CONFIG_MIPS=y
 # CONFIG_MIPS_HUGE_TLB_SUPPORT is not set
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index cdd4fa2..703e299 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1022,6 +1022,16 @@  config ATH79_MACH_CPE510
 	select ATH79_DEV_M25P80
 	select ATH79_DEV_WMAC
 
+config ATH79_MACH_RE450
+	bool "TP-LINK RE450 board support"
+	select SOC_QCA955X
+	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_WMAC
+
 config ATH79_MACH_TL_MR11U
 	bool "TP-LINK TL-MR11U/TL-MR3040 support"
 	select SOC_AR933X
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
index 991f6f2..094816e 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
@@ -128,6 +128,7 @@  obj-$(CONFIG_ATH79_MACH_RB922)		+= mach-rb922.o
 obj-$(CONFIG_ATH79_MACH_RB95X)		+= mach-rb95x.o
 obj-$(CONFIG_ATH79_MACH_RB2011)		+= mach-rb2011.o
 obj-$(CONFIG_ATH79_MACH_RBSXTLITE)	+= mach-rbsxtlite.o
+obj-$(CONFIG_ATH79_MACH_RE450)		+= mach-re450.o
 obj-$(CONFIG_ATH79_MACH_RW2458N)	+= mach-rw2458n.o
 obj-$(CONFIG_ATH79_MACH_SMART_300)	+= mach-smart-300.o
 obj-$(CONFIG_ATH79_MACH_TEW_632BRP)	+= mach-tew-632brp.o
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c
new file mode 100755
index 0000000..55414de
--- /dev/null
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-re450.c
@@ -0,0 +1,189 @@ 
+/*
+ * TP-LINK Archer RE450 board support
+ *
+ * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
+ * Copyright (c) 2016 Tal Keren <kooolk@gmail.com>
+ *
+ * Based on the Qualcomm Atheros AP135/AP136 reference board support code
+ *   Copyright (c) 2012 Qualcomm Atheros
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include <linux/pci.h>
+#include <linux/phy.h>
+#include <linux/gpio.h>
+#include <linux/mdio-gpio.h>
+#include <linux/platform_device.h>
+#include <linux/ar8216_platform.h>
+
+#include <asm/mach-ath79/ath79.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-wmac.h"
+#include "machtypes.h"
+#include "pci.h"
+
+#define RE450_GPIO_LED_SYSTEM		12
+#define RE450_GPIO_LED_WLAN2G		13
+#define RE450_GPIO_LED_WLAN5G		14
+#define RE450_GPIO_LED_LAN_DATA		17
+#define RE450_GPIO_LED_JUMPSTART	21
+#define RE450_GPIO_LED_JUMPSTART_RED	22
+#define RE450_GPIO_LED_LAN_LINK		23
+
+#define RE450_GPIO_BTN_RESET		18
+#define RE450_GPIO_BTN_LED		19
+#define RE450_GPIO_BTN_JUMPSTART	20
+
+#define RE450_GPIO_SMI_MDIO		1
+#define RE450_GPIO_SMI_MDC		3
+
+#define RE450_LAN_PHYADDR		4
+
+#define RE450_KEYS_POLL_INTERVAL	20	/* msecs */
+#define RE450_KEYS_DEBOUNCE_INTERVAL (3 * RE450_KEYS_POLL_INTERVAL)
+
+#define RE450_WMAC_CALDATA_OFFSET	0x1000
+
+static const char *tl_re450_part_probes[] = {
+	"cmdlinepart",
+	NULL,
+};
+
+static struct flash_platform_data tl_re450_flash_data = {
+	.part_probes	= tl_re450_part_probes,
+};
+
+static struct gpio_led re450_leds_gpio[] __initdata = {
+	{
+		.name		= "tp-link:blue:system",
+		.gpio		= RE450_GPIO_LED_SYSTEM,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:blue:wlan2g",
+		.gpio		= RE450_GPIO_LED_WLAN2G,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:blue:wlan5g",
+		.gpio		= RE450_GPIO_LED_WLAN5G,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:blue:wps",
+		.gpio		= RE450_GPIO_LED_JUMPSTART,
+	},
+	{
+		.name		= "tp-link:red:wps",
+		.gpio		= RE450_GPIO_LED_JUMPSTART_RED,
+	},
+	{
+		.name		= "tp-link:green:lan_data",
+		.gpio		= RE450_GPIO_LED_LAN_DATA,
+		.active_low	= 1,
+	},
+	{
+		.name		= "tp-link:green:lan_link",
+		.gpio		= RE450_GPIO_LED_LAN_LINK,
+		.active_low	= 1,
+	},
+};
+
+static struct gpio_keys_button re450_gpio_keys[] __initdata = {
+	{
+		.desc		= "Reset button",
+		.type		= EV_KEY,
+		.code		= KEY_WPS_BUTTON,
+		.debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= RE450_GPIO_BTN_RESET,
+		.active_low	= 1,
+	},
+	{
+		.desc		= "WPS button",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= RE450_GPIO_BTN_JUMPSTART,
+		.active_low	= 1,
+	},
+	{
+		.desc		= "Control LED button",
+		.type		= EV_KEY,
+		.code		= BTN_0,
+		.debounce_interval = RE450_KEYS_DEBOUNCE_INTERVAL,
+		.gpio		= RE450_GPIO_BTN_LED,
+		.active_low	= 1,
+	},
+};
+
+static struct mdio_gpio_platform_data re450_mdio = {
+	.mdc		= RE450_GPIO_SMI_MDC,
+	.mdio		= RE450_GPIO_SMI_MDIO,
+	.phy_mask	= ~BIT(RE450_LAN_PHYADDR),
+};
+
+static struct platform_device re450_phy_device = {
+	.name	= "mdio-gpio",
+	.id	= 0,
+	.dev	= {
+		.platform_data = &re450_mdio,
+	},
+};
+
+
+static void __init re450_setup(void)
+{
+	u8 *mac = (u8 *) KSEG1ADDR(0x1f610008);
+	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
+	u8 tmpmac[ETH_ALEN];
+
+	ath79_register_m25p80(&tl_re450_flash_data);
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(re450_leds_gpio),
+				 re450_leds_gpio);
+	ath79_register_gpio_keys_polled(-1, RE450_KEYS_POLL_INTERVAL,
+					ARRAY_SIZE(re450_gpio_keys),
+					re450_gpio_keys);
+
+	ath79_init_mac(tmpmac, mac, -1);
+	ath79_register_wmac(art + RE450_WMAC_CALDATA_OFFSET, tmpmac);
+
+	ath79_register_pci();
+
+	/* MDIO Interface */
+	platform_device_register(&re450_phy_device);
+
+	ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
+
+	/* GMAC0 is connected to the RGMII interface to an Atheros AR8035-A */
+	ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
+	ath79_eth0_data.mii_bus_dev = &re450_phy_device.dev;
+	ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
+	ath79_eth0_data.phy_mask = BIT(RE450_LAN_PHYADDR);
+	ath79_eth0_pll_data.pll_1000 = 0xa6000000;
+	ath79_eth0_pll_data.pll_100 = 0xa0000101;
+	ath79_eth0_pll_data.pll_10 = 0x80001313;
+	ath79_register_eth(0);
+}
+
+MIPS_MACHINE(ATH79_MACH_RE450, "RE450", "TP-LINK RE450",
+	     re450_setup)
+
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
index d12829f..5e3f088 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
+++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
@@ -141,6 +141,7 @@  enum ath79_mach_type {
 	ATH79_MACH_RB_2011R5,		/* Mikrotik RouterBOARD 2011UiAS(-2Hnd) */
 	ATH79_MACH_RB_SXTLITE2ND,	/* Mikrotik RouterBOARD SXT Lite 2nD */
 	ATH79_MACH_RB_SXTLITE5ND,	/* Mikrotik RouterBOARD SXT Lite 5nD */
+	ATH79_MACH_RE450,		/* TP-LINK RE450 */
 	ATH79_MACH_RW2458N,		/* Redwave RW2458N */
 	ATH79_MACH_SMART_300,		/* NC-LINK SMART-300 */
 	ATH79_MACH_TEW_632BRP,		/* TRENDnet TEW-632BRP */
diff --git a/target/linux/ar71xx/generic/profiles/tp-link.mk b/target/linux/ar71xx/generic/profiles/tp-link.mk
index 2875290..96b8bfb 100644
--- a/target/linux/ar71xx/generic/profiles/tp-link.mk
+++ b/target/linux/ar71xx/generic/profiles/tp-link.mk
@@ -27,6 +27,17 @@  endef
 $(eval $(call Profile,CPE510))
 
 
+define Profile/RE450
+	NAME:=TP-LINK RE450
+	PACKAGES:=kmod-ath10k
+endef
+
+define Profile/RE450/Description
+	Package set optimized for the TP-LINK RE450.
+endef
+$(eval $(call Profile,RE450))
+
+
 define Profile/TLMR10U
 	NAME:=TP-LINK TL-MR10U
 	PACKAGES:=kmod-usb-core kmod-usb2
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index 31eb345..26882e1 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -71,6 +71,15 @@  define Build/mktplinkfw-initramfs
 	@mv $@.new $@
 endef
 
+# mktplinkfw-kernel <kernel-file> <output-file> <hw-id>
+define Build/mktplinkfw-kernel
+	$(STAGING_DIR_HOST)/bin/mktplinkfw-kernel \
+		-H $3 -N OpenWrt -V $(REVISION) \
+		-L $(KERNEL_LOADADDR) -E $(KERNEL_LOADADDR) \
+		-k $1 \
+		-o $2
+endef
+
 define Build/loader-common
 	rm -rf $@.src
 	$(MAKE) -C lzma-loader \
@@ -1566,6 +1575,7 @@  mr12_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13440k(rootfs),
 mr16_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13440k(rootfs),2304k(kernel),128k(art)ro,15744k@0x80000(firmware)
 pb92_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
 planex_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),128k(art)ro
+re450_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,1280k(kernel),4736k(rootfs),64k(pation-table)ro,64k(product-info)ro,1856k(config)ro,64k(art)ro,6016k@0x20000(firmware)
 ubntxm_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
 uap_pro_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1536k(kernel),14208k(rootfs),256k(cfg)ro,64k(EEPROM)ro,15744k@0x50000(firmware)
 ubdev_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware),64k(certs),256k(cfg)ro,64k(EEPROM)ro
@@ -2001,19 +2011,19 @@  define Image/Build/Senao
 		$(call sysupname,$(1),$(2))
 endef
 
-Image/Build/TPLINK-SAFELOADER/loader = $(call Image/BuildLoaderPatched,$(1),elf,$(2) $(3))
+Image/Build/TPLINK-SAFELOADER-ELF/loader = $(call Image/BuildLoaderPatched,$(1),elf,$(2) $(3))
 
-define Image/Build/TPLINK-SAFELOADER
+define Image/Build/TPLINK-SAFELOADER-ELF
 	[ -e "$(KDIR)/loader-$(2).elf" ]
 
-	-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
+	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
 		-B $(5) \
 		-k $(KDIR)/loader-$(2).elf \
 		-r $(KDIR)/root.$(1) \
 		-V $(REVISION) \
 		-j \
 		-o $(call factoryname,$(1),$(2))
-	-$(STAGING_DIR_HOST)/bin/tplink-safeloader \
+	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
 		-B $(5) \
 		-k $(KDIR)/loader-$(2).elf \
 		-r $(KDIR)/root.$(1) \
@@ -2023,6 +2033,31 @@  define Image/Build/TPLINK-SAFELOADER
 endef
 
 
+define Image/Build/TPLINK-SAFELOADER-TPLINK/buildkernel
+	$(call PatchKernelLzma,$(2),$(3) $(4))
+	$(call Build/mktplinkfw-kernel,$(KDIR_TMP)/vmlinux-$(2).bin.lzma,$(KDIR_TMP)/vmlinux-$(2).tplink.bin,$6)
+endef
+
+define Image/Build/TPLINK-SAFELOADER-TPLINK
+	[ -e "$(KDIR_TMP)/vmlinux-$(2).tplink.bin" ]
+
+	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
+		-B $(5) \
+		-k $(KDIR_TMP)/vmlinux-$(2).tplink.bin \
+		-r $(KDIR)/root.$(1) \
+		-V $(REVISION) \
+		-j \
+		-o $(call factoryname,$(1),$(2))
+	$(STAGING_DIR_HOST)/bin/tplink-safeloader \
+		-B $(5) \
+		-k $(KDIR_TMP)/vmlinux-$(2).tplink.bin \
+		-r $(KDIR)/root.$(1) \
+		-V $(REVISION) \
+		-j -S \
+		-o $(call sysupname,$(1),$(2))
+endef
+
+
 define Image/Build/CyberTAN
 	echo -n '' > $(KDIR_TMP)/empty.bin
 	$(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp \
@@ -2461,7 +2496,8 @@  $(eval $(call SingleProfile,Seama,64k,QIHOO360,qihoo-c301,QIHOO-C301,ttyS0,11520
 
 $(eval $(call SingleProfile,Senao,squashfs-only,EAP300V2,eap300v2,EAP300V2,ttyS0,115200,$$(eap300v2_mtdlayout)))
 
-$(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
+$(eval $(call SingleProfile,TPLINK-SAFELOADER-ELF,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
+$(eval $(call SingleProfile,TPLINK-SAFELOADER-TPLINK,64kraw,RE450,re450,RE450,ttyS0,115200,$$(re450_mtdlayout),RE450,0x04500100))
 
 $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRG301N,whr-g301n,WHR-G301N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-G301N))
 $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRHPG300N,whr-hp-g300n,WHR-HP-G300N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-HP-G300N))
diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
index 88ac6cf..983017b 100644
--- a/target/linux/ar71xx/mikrotik/config-default
+++ b/target/linux/ar71xx/mikrotik/config-default
@@ -71,6 +71,7 @@  CONFIG_ATH79_MACH_RB91X=y
 CONFIG_ATH79_MACH_RB922=y
 CONFIG_ATH79_MACH_RB95X=y
 CONFIG_ATH79_MACH_RBSXTLITE=y
+# CONFIG_ATH79_MACH_RE450 is not set
 # CONFIG_ATH79_MACH_RW2458N is not set
 # CONFIG_ATH79_MACH_SMART_300 is not set
 # CONFIG_ATH79_MACH_TEW_632BRP is not set
diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
index e67d1ad..3632fd2 100644
--- a/target/linux/ar71xx/nand/config-default
+++ b/target/linux/ar71xx/nand/config-default
@@ -38,6 +38,7 @@ 
 # CONFIG_ATH79_MACH_PB42 is not set
 # CONFIG_ATH79_MACH_PB44 is not set
 # CONFIG_ATH79_MACH_PB92 is not set
+# CONFIG_ATH79_MACH_RE450 is not set
 # CONFIG_ATH79_MACH_RW2458N is not set
 # CONFIG_ATH79_MACH_TEW_632BRP is not set
 # CONFIG_ATH79_MACH_TEW_673GRU is not set