0046-ar71xx-add-support-for-TP-LINK-Archer-C7-v4.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Tue, 25 Jul 2017 13:32:47 +0200
  3. Subject: ar71xx: add support for TP-LINK Archer C7 v4
  4. TP-Link Archer C7 v4 is a dual-band AC1750 router, based on Qualcomm/Atheros
  5. QCA9561+QCA9888.
  6. Specification:
  7. - 775/650/258 MHz (CPU/DDR/AHB)
  8. - 128 MB of RAM (DDR2)
  9. - 16 MB of FLASH (SPI NOR)
  10. - 3T3R 2.4 GHz
  11. - 3T3R 5 GHz
  12. - 5x 10/100/1000 Mbps Ethernet
  13. - 7x LED, 2x button
  14. - UART header on PCB
  15. Flash instruction:
  16. 1. Upload lede-ar71xx-generic-archer-c7-v4-squashfs-factory.bin via Web interface
  17. Flash instruction using TFTP recovery:
  18. 1. Set PC to fixed ip address 192.168.0.66
  19. 2. Download lede-ar71xx-generic-archer-c7-v4-squashfs-factory.bin
  20. and rename it to ArcherC7v4_tp_recovery.bin
  21. 3. Start a tftp server with the file tp_recovery.bin in its root directory
  22. 4. Turn off the router
  23. 5. Press and hold Reset button
  24. 6. Turn on router with the reset button pressed and wait ~15 seconds
  25. 7. Release the reset button and after a short time
  26. the firmware should be transferred from the tftp server
  27. 8. Wait ~30 second to complete recovery.
  28. Flash instruction under U-Boot, using UART:
  29. 1. tftp 0x81000000 lede-ar71xx-...-sysupgrade.bin
  30. 2. erase 0x9f040000 +$filesize
  31. 3. cp.b $fileaddr 0x9f040000 $filesize
  32. 4. reset
  33. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  34. diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
  35. index e67b5e38561e841b88e486341950c52e1d454322..44b1c2837e8392596eed14b4bc0d761042109715 100755
  36. --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
  37. +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
  38. @@ -53,7 +53,8 @@ ap121f)
  39. ucidef_set_led_netdev "lan" "LAN" "$board:green:lan" "eth0"
  40. ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan" "phy0tpt"
  41. ;;
  42. -archer-c25-v1)
  43. +archer-c25-v1|\
  44. +archer-c7-v4)
  45. ucidef_set_led_netdev "wan" "WAN" "$board:green:wan" "eth0"
  46. ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan2g" "phy1tpt"
  47. ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:green:wlan5g" "phy0tpt"
  48. @@ -61,6 +62,12 @@ archer-c25-v1)
  49. ucidef_set_led_switch "lan2" "LAN2" "$board:green:lan2" "switch0" "0x08"
  50. ucidef_set_led_switch "lan3" "LAN3" "$board:green:lan3" "switch0" "0x04"
  51. ucidef_set_led_switch "lan4" "LAN4" "$board:green:lan4" "switch0" "0x02"
  52. + case "$board" in
  53. + archer-c7-v4)
  54. + ucidef_set_led_usbdev "usb1" "USB1" "$board:green:usb1" "1-1"
  55. + ucidef_set_led_usbdev "usb2" "USB2" "$board:green:usb2" "2-1"
  56. + ;;
  57. + esac
  58. ;;
  59. arduino-yun)
  60. ucidef_set_led_wlan "wlan" "WLAN" "arduino:blue:wlan" "phy0tpt"
  61. diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
  62. index 454abe6a5005621967dd96e0282e7bce2a0b127e..86ac949bca12561536ce2c8adb190eb004c162e4 100755
  63. --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
  64. +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
  65. @@ -386,6 +386,7 @@ ar71xx_setup_interfaces()
  66. ucidef_set_interface_wan "eth0"
  67. ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
  68. ;;
  69. + archer-c7-v4|\
  70. tl-wdr4300|\
  71. tl-wr1041n-v2)
  72. ucidef_add_switch "switch0" \
  73. diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
  74. index 61db387c9ecefd7090c25a5f5d75fdbf65a44d65..97372bed0ea2fadfab10f22916a1e0d6a9c65725 100644
  75. --- a/target/linux/ar71xx/base-files/etc/diag.sh
  76. +++ b/target/linux/ar71xx/base-files/etc/diag.sh
  77. @@ -51,6 +51,7 @@ get_status_led() {
  78. status_led="ap135:green:status"
  79. ;;
  80. archer-c25-v1|\
  81. + archer-c7-v4|\
  82. mr12|\
  83. mr16|\
  84. nbg6616|\
  85. 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
  86. index 68f90de802ddd18e09a1da39c0d56292eea9489c..96b8f6b9a4bdd6a1609a819e72ade315bccfb3c0 100644
  87. --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  88. +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  89. @@ -92,6 +92,7 @@ case "$FIRMWARE" in
  90. ath10kcal_extract "art" 20480 2116
  91. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
  92. ;;
  93. + archer-c7-v4|\
  94. archer-c25-v1|\
  95. tl-wdr6500-v2)
  96. ath10kcal_extract "art" 20480 2116
  97. diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  98. index de6042b202bbd07e64833743933be1cbaf1ed495..ddb8f0db80ed6eab39c832bfd893182d9f591ad4 100755
  99. --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
  100. +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  101. @@ -466,6 +466,9 @@ ar71xx_board_detect() {
  102. *"Archer C5")
  103. name="archer-c5"
  104. ;;
  105. + *"Archer C7 v4")
  106. + name="archer-c7-v4"
  107. + ;;
  108. *"Archer C7")
  109. name="archer-c7"
  110. ;;
  111. diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  112. index e748a2559cdb3a0ca6618429b0f613a656e39388..d414af969912894574e73e286ed5a3998532d34e 100755
  113. --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  114. +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  115. @@ -207,6 +207,7 @@ platform_check_image() {
  116. ap132|\
  117. ap90q|\
  118. archer-c25-v1|\
  119. + archer-c7-v4|\
  120. bullet-m|\
  121. c-55|\
  122. carambola2|\
  123. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  124. index 7ad5419f51ec9909d8b59f33178221a7d81ec184..0a25294c40b5e2d3be825554ec7246a50b9c029b 100644
  125. --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  126. +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  127. @@ -1247,6 +1247,7 @@ config ATH79_MACH_ARCHER_C25_V1
  128. config ATH79_MACH_ARCHER_C7
  129. bool "TP-LINK Archer C5/C7/TL-WDR4900 v2 board support"
  130. select SOC_QCA955X
  131. + select SOC_QCA956X
  132. select ATH79_DEV_AP9X_PCI if PCI
  133. select ATH79_DEV_ETH
  134. select ATH79_DEV_GPIO_BUTTONS
  135. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
  136. index 3365a43ce16fc77b3212b39b92081efe678e8803..a0c73550eb0d5bf07ee731171be9e5ef9ff073e7 100644
  137. --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
  138. +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
  139. @@ -58,6 +58,7 @@ obj-$(CONFIG_ATH79_MACH_AP90Q) += mach-ap90q.o
  140. obj-$(CONFIG_ATH79_MACH_AP96) += mach-ap96.o
  141. obj-$(CONFIG_ATH79_MACH_ARCHER_C25_V1) += mach-archer-c25-v1.o
  142. obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7.o
  143. +obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7-v4.o
  144. obj-$(CONFIG_ATH79_MACH_ARDUINO_YUN) += mach-arduino-yun.o
  145. obj-$(CONFIG_ATH79_MACH_AW_NR580) += mach-aw-nr580.o
  146. obj-$(CONFIG_ATH79_MACH_BHR_4GRV2) += mach-bhr-4grv2.o
  147. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7-v4.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7-v4.c
  148. new file mode 100644
  149. index 0000000000000000000000000000000000000000..64955c79945c0b2c28d5a93be6e45662200e60ed
  150. --- /dev/null
  151. +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c7-v4.c
  152. @@ -0,0 +1,260 @@
  153. +
  154. +/*
  155. + * Atheros ARCHER_C7 reference board support
  156. + *
  157. + * Copyright (c) 2017 Felix Fietkau <nbd@nbd.name>
  158. + * Copyright (c) 2014 The Linux Foundation. All rights reserved.
  159. + * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  160. + *
  161. + * Permission to use, copy, modify, and/or distribute this software for any
  162. + * purpose with or without fee is hereby granted, provided that the above
  163. + * copyright notice and this permission notice appear in all copies.
  164. + *
  165. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  166. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  167. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  168. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  169. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  170. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  171. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  172. + *
  173. + */
  174. +
  175. +#include <linux/platform_device.h>
  176. +#include <linux/ath9k_platform.h>
  177. +#include <linux/ar8216_platform.h>
  178. +#include <linux/proc_fs.h>
  179. +#include <linux/gpio.h>
  180. +#include <linux/spi/spi_gpio.h>
  181. +#include <linux/spi/74x164.h>
  182. +
  183. +#include <asm/mach-ath79/ar71xx_regs.h>
  184. +
  185. +#include "common.h"
  186. +#include "dev-m25p80.h"
  187. +#include "machtypes.h"
  188. +#include "pci.h"
  189. +#include "dev-eth.h"
  190. +#include "dev-gpio-buttons.h"
  191. +#include "dev-leds-gpio.h"
  192. +#include "dev-spi.h"
  193. +#include "dev-usb.h"
  194. +#include "dev-wmac.h"
  195. +
  196. +
  197. +#define ARCHER_C7_GPIO_SHIFT_OE 1
  198. +#define ARCHER_C7_GPIO_SHIFT_SER 14
  199. +#define ARCHER_C7_GPIO_SHIFT_SRCLK 15
  200. +#define ARCHER_C7_GPIO_SHIFT_RCLK 16
  201. +#define ARCHER_C7_GPIO_SHIFT_SRCLR 21
  202. +
  203. +#define ARCHER_C7_GPIO_BTN_RESET 5
  204. +#define ARCHER_C7_GPIO_BTN_WPS_WIFI 2
  205. +
  206. +#define ARCHER_C7_GPIO_LED_WLAN5 9
  207. +#define ARCHER_C7_GPIO_LED_POWER 6
  208. +#define ARCHER_C7_GPIO_LED_USB1 7
  209. +#define ARCHER_C7_GPIO_LED_USB2 8
  210. +
  211. +#define ARCHER_C7_74HC_GPIO_BASE QCA956X_GPIO_COUNT
  212. +#define ARCHER_C7_GPIO_LED_WPS (ARCHER_C7_74HC_GPIO_BASE + 0)
  213. +#define ARCHER_C7_GPIO_LED_LAN1 (ARCHER_C7_74HC_GPIO_BASE + 1)
  214. +#define ARCHER_C7_GPIO_LED_LAN2 (ARCHER_C7_74HC_GPIO_BASE + 2)
  215. +#define ARCHER_C7_GPIO_LED_LAN3 (ARCHER_C7_74HC_GPIO_BASE + 3)
  216. +#define ARCHER_C7_GPIO_LED_LAN4 (ARCHER_C7_74HC_GPIO_BASE + 4)
  217. +#define ARCHER_C7_GPIO_LED_WAN_GREEN (ARCHER_C7_74HC_GPIO_BASE + 5)
  218. +#define ARCHER_C7_GPIO_LED_WAN_AMBER (ARCHER_C7_74HC_GPIO_BASE + 6)
  219. +#define ARCHER_C7_GPIO_LED_WLAN2 (ARCHER_C7_74HC_GPIO_BASE + 7)
  220. +
  221. +#define ARCHER_C7_KEYS_POLL_INTERVAL 20 /* msecs */
  222. +#define ARCHER_C7_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C7_KEYS_POLL_INTERVAL)
  223. +
  224. +#define ARCHER_C7_MAC0_OFFSET 0
  225. +#define ARCHER_C7_MAC1_OFFSET 6
  226. +#define ARCHER_C7_WMAC_CALDATA_OFFSET 0x1000
  227. +
  228. +#define ARCHER_C7_GPIO_MDC 3
  229. +#define ARCHER_C7_GPIO_MDIO 4
  230. +
  231. +static struct spi_gpio_platform_data archer_c7_v4_spi_data = {
  232. + .sck = ARCHER_C7_GPIO_SHIFT_SRCLK,
  233. + .miso = SPI_GPIO_NO_MISO,
  234. + .mosi = ARCHER_C7_GPIO_SHIFT_SER,
  235. + .num_chipselect = 1,
  236. +};
  237. +
  238. +static u8 archer_c7_v4_ssr_initdata __initdata = 0xff;
  239. +
  240. +static struct gen_74x164_chip_platform_data archer_c7_v4_ssr_data = {
  241. + .base = ARCHER_C7_74HC_GPIO_BASE,
  242. + .num_registers = 1,
  243. + .init_data = &archer_c7_v4_ssr_initdata,
  244. +};
  245. +
  246. +static struct platform_device archer_c7_v4_spi_device = {
  247. + .name = "spi_gpio",
  248. + .id = 1,
  249. + .dev = {
  250. + .platform_data = &archer_c7_v4_spi_data,
  251. + },
  252. +};
  253. +
  254. +static struct spi_board_info archer_c7_v4_spi_info[] = {
  255. + {
  256. + .bus_num = 1,
  257. + .chip_select = 0,
  258. + .max_speed_hz = 10000000,
  259. + .modalias = "74x164",
  260. + .platform_data = &archer_c7_v4_ssr_data,
  261. + .controller_data = (void *) ARCHER_C7_GPIO_SHIFT_RCLK,
  262. + },
  263. +};
  264. +
  265. +static struct gpio_led archer_c7_v4_leds_gpio[] __initdata = {
  266. + {
  267. + .name = "archer-c7-v4:green:power",
  268. + .gpio = ARCHER_C7_GPIO_LED_POWER,
  269. + .active_low = 1,
  270. + }, {
  271. + .name = "archer-c7-v4:green:wps",
  272. + .gpio = ARCHER_C7_GPIO_LED_WPS,
  273. + .active_low = 1,
  274. + }, {
  275. + .name = "archer-c7-v4:green:wlan2g",
  276. + .gpio = ARCHER_C7_GPIO_LED_WLAN2,
  277. + .active_low = 1,
  278. + }, {
  279. + .name = "archer-c7-v4:green:wlan5g",
  280. + .gpio = ARCHER_C7_GPIO_LED_WLAN5,
  281. + .active_low = 1,
  282. + }, {
  283. + .name = "archer-c7-v4:green:lan1",
  284. + .gpio = ARCHER_C7_GPIO_LED_LAN1,
  285. + .active_low = 1,
  286. + }, {
  287. + .name = "archer-c7-v4:green:lan2",
  288. + .gpio = ARCHER_C7_GPIO_LED_LAN2,
  289. + .active_low = 1,
  290. + }, {
  291. + .name = "archer-c7-v4:green:lan3",
  292. + .gpio = ARCHER_C7_GPIO_LED_LAN3,
  293. + .active_low = 1,
  294. + }, {
  295. + .name = "archer-c7-v4:green:lan4",
  296. + .gpio = ARCHER_C7_GPIO_LED_LAN4,
  297. + .active_low = 1,
  298. + }, {
  299. + .name = "archer-c7-v4:green:wan",
  300. + .gpio = ARCHER_C7_GPIO_LED_WAN_GREEN,
  301. + .active_low = 1,
  302. + }, {
  303. + .name = "archer-c7-v4:amber:wan",
  304. + .gpio = ARCHER_C7_GPIO_LED_WAN_AMBER,
  305. + .active_low = 1,
  306. + }, {
  307. + .name = "archer-c7-v4:green:usb1",
  308. + .gpio = ARCHER_C7_GPIO_LED_USB1,
  309. + .active_low = 1,
  310. + }, {
  311. + .name = "archer-c7-v4:green:usb2",
  312. + .gpio = ARCHER_C7_GPIO_LED_USB2,
  313. + .active_low = 1,
  314. + },
  315. +};
  316. +
  317. +static struct gpio_keys_button archer_c7_v4_gpio_keys[] __initdata = {
  318. + {
  319. + .desc = "WPS and WIFI button",
  320. + .type = EV_KEY,
  321. + .code = KEY_WPS_BUTTON,
  322. + .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL,
  323. + .gpio = ARCHER_C7_GPIO_BTN_WPS_WIFI,
  324. + .active_low = 1,
  325. + },
  326. + {
  327. + .desc = "Reset button",
  328. + .type = EV_KEY,
  329. + .code = KEY_RESTART,
  330. + .debounce_interval = ARCHER_C7_KEYS_DEBOUNCE_INTERVAL,
  331. + .gpio = ARCHER_C7_GPIO_BTN_RESET,
  332. + .active_low = 1,
  333. + },
  334. +};
  335. +
  336. +static struct ar8327_pad_cfg archer_c7_v4_ar8337_pad0_cfg = {
  337. + .mode = AR8327_PAD_MAC_SGMII,
  338. + .sgmii_delay_en = true,
  339. +};
  340. +
  341. +static struct ar8327_platform_data archer_c7_v4_ar8337_data = {
  342. + .pad0_cfg = &archer_c7_v4_ar8337_pad0_cfg,
  343. + .port0_cfg = {
  344. + .force_link = 1,
  345. + .speed = AR8327_PORT_SPEED_1000,
  346. + .duplex = 1,
  347. + .txpause = 1,
  348. + .rxpause = 1,
  349. + },
  350. +};
  351. +
  352. +static struct mdio_board_info archer_c7_v4_mdio0_info[] = {
  353. + {
  354. + .bus_id = "ag71xx-mdio.0",
  355. + .phy_addr = 0,
  356. + .platform_data = &archer_c7_v4_ar8337_data,
  357. + },
  358. +};
  359. +
  360. +
  361. +static void __init archer_c7_v4_setup(void)
  362. +{
  363. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  364. + u8 *mac = (u8 *) KSEG1ADDR(0x1ff00008);
  365. +
  366. + ath79_register_m25p80(NULL);
  367. +
  368. + spi_register_board_info(archer_c7_v4_spi_info,
  369. + ARRAY_SIZE(archer_c7_v4_spi_info));
  370. +
  371. + platform_device_register(&archer_c7_v4_spi_device);
  372. +
  373. + gpio_request_one(ARCHER_C7_GPIO_SHIFT_OE,
  374. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  375. + "LED control");
  376. +
  377. + gpio_request_one(ARCHER_C7_GPIO_SHIFT_SRCLR,
  378. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  379. + "LED reset");
  380. +
  381. + ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c7_v4_leds_gpio),
  382. + archer_c7_v4_leds_gpio);
  383. +
  384. + ath79_register_gpio_keys_polled(-1, ARCHER_C7_KEYS_POLL_INTERVAL,
  385. + ARRAY_SIZE(archer_c7_v4_gpio_keys),
  386. + archer_c7_v4_gpio_keys);
  387. +
  388. + ath79_register_usb();
  389. +
  390. + ath79_gpio_output_select(ARCHER_C7_GPIO_MDC, QCA956X_GPIO_OUT_MUX_GE0_MDC);
  391. + ath79_gpio_output_select(ARCHER_C7_GPIO_MDIO, QCA956X_GPIO_OUT_MUX_GE0_MDO);
  392. +
  393. + ath79_register_mdio(0, 0x0);
  394. +
  395. + mdiobus_register_board_info(archer_c7_v4_mdio0_info,
  396. + ARRAY_SIZE(archer_c7_v4_mdio0_info));
  397. +
  398. + ath79_register_wmac(art + ARCHER_C7_WMAC_CALDATA_OFFSET, mac);
  399. + ath79_register_pci();
  400. +
  401. + /* GMAC0 is connected to an AR8337 switch */
  402. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  403. + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  404. + ath79_eth0_data.speed = SPEED_1000;
  405. + ath79_eth0_data.duplex = DUPLEX_FULL;
  406. + ath79_eth0_data.phy_mask = BIT(0);
  407. + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  408. + ath79_register_eth(0);
  409. +}
  410. +
  411. +MIPS_MACHINE(ATH79_MACH_ARCHER_C7_V4, "ARCHER-C7-V4", "TP-LINK Archer C7 v4",
  412. + archer_c7_v4_setup);
  413. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  414. index 9cb4a7f2e1df641232289721b676a9b0149c76e5..e4623fd08836d59ad4e79e96f02e75e502a55ca6 100644
  415. --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  416. +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  417. @@ -44,6 +44,7 @@ enum ath79_mach_type {
  418. ATH79_MACH_ARCHER_C5, /* TP-LINK Archer C5 board */
  419. ATH79_MACH_ARCHER_C7, /* TP-LINK Archer C7 board */
  420. ATH79_MACH_ARCHER_C7_V2, /* TP-LINK Archer C7 V2 board */
  421. + ATH79_MACH_ARCHER_C7_V4, /* TP-LINK Archer C7 V4 board */
  422. ATH79_MACH_ARDUINO_YUN, /* Yun */
  423. ATH79_MACH_AW_NR580, /* AzureWave AW-NR580 */
  424. ATH79_MACH_BHR_4GRV2, /* Buffalo BHR-4GRV2 */
  425. diff --git a/target/linux/ar71xx/image/tp-link.mk b/target/linux/ar71xx/image/tp-link.mk
  426. index 5be7cbfbd4ab7d73d679d52d2581459250e04302..27d6c73454aef96e5da47033ec664d2caffca1d5 100644
  427. --- a/target/linux/ar71xx/image/tp-link.mk
  428. +++ b/target/linux/ar71xx/image/tp-link.mk
  429. @@ -298,6 +298,22 @@ define Device/archer-c7-v2
  430. IMAGE/factory-eu.bin := append-rootfs | mktplinkfw factory -C EU
  431. endef
  432. +define Device/archer-c7-v4
  433. + DEVICE_TITLE := TP-LINK Archer C7 v4
  434. + DEVICE_PACKAGES := kmod-ath10k ath10k-firmware-qca988x
  435. + BOARDNAME := ARCHER-C7-V4
  436. + TPLINK_BOARD_NAME := ARCHER-C7-V4
  437. + IMAGE_SIZE := 15104k
  438. + LOADER_TYPE := elf
  439. + KERNEL := kernel-bin | patch-cmdline | lzma | uImageArcher lzma
  440. + IMAGES := sysupgrade.bin factory.bin
  441. + IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \
  442. + append-metadata | check-size $$$$(IMAGE_SIZE)
  443. + IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  444. + MTDPARTS := spi0.0:128k(factory-uboot)ro,128k(u-boot)ro,1536k(kernel),13568k(rootfs),960k(config)ro,64k(art)ro,15104k@0x40000(firmware)
  445. + SUPPORTED_DEVICES := archer-c7-v4
  446. +endef
  447. +
  448. define Device/archer-c7-v2-il
  449. $(Device/tplink-16mlzma)
  450. DEVICE_TITLE := TP-LINK Archer C7 v2 IL
  451. @@ -316,7 +332,7 @@ define Device/tl-wdr7500-v3
  452. DEVICE_PROFILE := ARCHERC7
  453. TPLINK_HWID := 0x75000003
  454. endef
  455. -TARGET_DEVICES += archer-c5-v1 archer-c7-v1 archer-c7-v2 archer-c7-v2-il tl-wdr7500-v3
  456. +TARGET_DEVICES += archer-c5-v1 archer-c7-v1 archer-c7-v2 archer-c7-v2-il archer-c7-v4 tl-wdr7500-v3
  457. define Device/tl-mr10u-v1
  458. $(Device/tplink-4mlzma)
  459. diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
  460. index 478d5d8e9b43bbe37694732c138048c8fe8d807c..fec830c23ce6707755ddefc849f195872be1e877 100644
  461. --- a/tools/firmware-utils/src/tplink-safeloader.c
  462. +++ b/tools/firmware-utils/src/tplink-safeloader.c
  463. @@ -376,6 +376,49 @@ static struct device_info boards[] = {
  464. .last_sysupgrade_partition = "file-system"
  465. },
  466. + /** Firmware layout for the C7 */
  467. + {
  468. + .id = "ARCHER-C7-V4",
  469. + .support_list =
  470. + "SupportList:\n"
  471. + "{product_name:Archer C7,product_ver:4.0.0,special_id:45550000}\n"
  472. + "{product_name:Archer C7,product_ver:4.0.0,special_id:55530000}\n"
  473. + "{product_name:Archer C7,product_ver:4.0.0,special_id:43410000}\n",
  474. + .support_trail = '\x00',
  475. + .soft_ver = "soft_ver:1.0.0\n",
  476. +
  477. + /**
  478. + We use a bigger os-image partition than the stock images (and thus
  479. + smaller file-system), as our kernel doesn't fit in the stock firmware's
  480. + 1MB os-image.
  481. + */
  482. + .partitions = {
  483. + {"factory-boot", 0x00000, 0x20000},
  484. + {"fs-uboot", 0x20000, 0x20000},
  485. + {"os-image", 0x40000, 0x180000}, /* Stock: base 0x40000 size 0x120000 */
  486. + {"file-system", 0x1c0000, 0xd40000}, /* Stock: base 0x160000 size 0xda0000 */
  487. + {"default-mac", 0xf00000, 0x00200},
  488. + {"pin", 0xf00200, 0x00200},
  489. + {"device-id", 0xf00400, 0x00100},
  490. + {"product-info", 0xf00500, 0x0fb00},
  491. + {"soft-version", 0xf10000, 0x00100},
  492. + {"extra-para", 0xf11000, 0x01000},
  493. + {"support-list", 0xf12000, 0x0a000},
  494. + {"profile", 0xf1c000, 0x04000},
  495. + {"default-config", 0xf20000, 0x10000},
  496. + {"user-config", 0xf30000, 0x40000},
  497. + {"qos-db", 0xf70000, 0x40000},
  498. + {"certificate", 0xfb0000, 0x10000},
  499. + {"partition-table", 0xfc0000, 0x10000},
  500. + {"log", 0xfd0000, 0x20000},
  501. + {"radio", 0xff0000, 0x10000},
  502. + {NULL, 0, 0}
  503. + },
  504. +
  505. + .first_sysupgrade_partition = "os-image",
  506. + .last_sysupgrade_partition = "file-system",
  507. + },
  508. +
  509. /** Firmware layout for the C9 */
  510. {
  511. .id = "ARCHERC9",
  512. @@ -929,6 +972,9 @@ static void build_image(const char *output,
  513. strcasecmp(info->id, "TLWR1043NV5") == 0) {
  514. const char mdat[11] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  515. parts[5] = put_data("extra-para", mdat, 11);
  516. + } else if (strcasecmp(info->id, "ARCHER-C7-V4") == 0) {
  517. + const char mdat[11] = {0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0xca, 0x00, 0x01, 0x00, 0x00};
  518. + parts[5] = put_data("extra-para", mdat, 11);
  519. }
  520. size_t len;