0050-ar71xx-add-support-to-TP-Link-Archer-C59v1-and-C60v1.patch 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. From: Henryk Heisig <hyniu@o2.pl>
  2. Date: Tue, 27 Dec 2016 22:41:41 +0100
  3. Subject: ar71xx: add support to TP-Link Archer C59v1 and C60v1
  4. TP-Link Archer C59v1 is a dual-band AC1350 router, based on Qualcomm/Atheros
  5. QCA9561+QCA9886.
  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. - 2T2R 5 GHz
  12. - 5x 10/100 Mbps Ethernet
  13. - USB 2.0 port
  14. - 8x LED (controled by 74HC595), 3x button
  15. - UART header on PCB
  16. TP-Link Archer C60v1 is a dual-band AC1350 router, based on Qualcomm/Atheros
  17. QCA9561+QCA9886.
  18. Specification:
  19. - 775/650/258 MHz (CPU/DDR/AHB)
  20. - 64 MB of RAM (DDR2)
  21. - 8 MB of FLASH (SPI NOR)
  22. - 3T3R 2.4 GHz
  23. - 2T2R 5 GHz
  24. - 5x 10/100 Mbps Ethernet
  25. - 7x LED, 2x button
  26. - UART header on PCB
  27. Currently not working:
  28. - Port LAN1 on C59, LAN4 on C60
  29. - WiFi 5GHz (missing ath10k firmware for QCA9886 chip)
  30. - Update from oficial web interface ( tplink-saveloader not support "product-info")
  31. Flash instruction:
  32. 1. Set PC to fixed ip address 192.168.0.66
  33. 2. Download lede-ar71xx-generic-archer-cXX-v1-squashfs-factory.bin
  34. and rename it to tp_recovery.bin
  35. 3. Start a tftp server with the file tp_recovery.bin in its root directory
  36. 4. Turn off the router
  37. 5. Press and hold Reset button
  38. 6. Turn on router with the reset button pressed and wait ~15 seconds
  39. 7. Release the reset button and after a short time
  40. the firmware should be transferred from the tftp server
  41. 8. Wait ~30 second to complete recovery.
  42. Flash instruction under U-Boot, using UART:
  43. 1. tftp 0x81000000 lede-ar71xx-...-sysupgrade.bin
  44. 2. erase 0x9f020000 +$filesize
  45. 3. cp.b $fileaddr 0x9f020000 $filesize
  46. 4. reset
  47. Signed-off-by: Henryk Heisig <hyniu@o2.pl>
  48. [Jo-Philipp Wich: remove duplicate ATH79_MACH_ARCHER_C59/C60_V1 entries]
  49. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  50. diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
  51. index 47b90d9cb2f81936aed22cdf7d1f6d870d23c16e..8552cde564b3fbed9425f42d5331f95fe5c3aaa8 100755
  52. --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
  53. +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
  54. @@ -62,6 +62,19 @@ archer-c25-v1)
  55. ucidef_set_led_switch "lan3" "LAN3" "$board:green:lan3" "switch0" "0x04"
  56. ucidef_set_led_switch "lan4" "LAN4" "$board:green:lan4" "switch0" "0x02"
  57. ;;
  58. +archer-c59-v1|\
  59. +archer-c60-v1)
  60. + ucidef_set_led_switch "lan" "LAN" "$board:green:lan" "switch0" "0x3C"
  61. + ucidef_set_led_switch "wan" "WAN" "$board:green:wan" "switch0" "0x02"
  62. + ucidef_set_led_wlan "wlan" "WLAN" "$board:green:wlan2g" "phy1tpt"
  63. + ucidef_set_led_wlan "wlan5g" "WLAN5G" "$board:green:wlan5g" "phy0tpt"
  64. +
  65. + case "$board" in
  66. + archer-c59-v1)
  67. + ucidef_set_led_usbdev "usb" "USB" "$board:green:usb" "1-1"
  68. + ;;
  69. + esac
  70. + ;;
  71. arduino-yun)
  72. ucidef_set_led_wlan "wlan" "WLAN" "arduino:blue:wlan" "phy0tpt"
  73. ucidef_set_led_usbdev "usb" "USB" "arduino:white:usb" "1-1.1"
  74. diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network
  75. index 86ac949bca12561536ce2c8adb190eb004c162e4..3abe1114ee31c79abb125b85119876c3d75bb7c0 100755
  76. --- a/target/linux/ar71xx/base-files/etc/board.d/02_network
  77. +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
  78. @@ -205,6 +205,11 @@ ar71xx_setup_interfaces()
  79. ucidef_add_switch "switch0" \
  80. "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
  81. ;;
  82. + archer-c59-v1|\
  83. + archer-c60-v1)
  84. + ucidef_add_switch "switch0" \
  85. + "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
  86. + ;;
  87. arduino-yun|\
  88. dir-505-a1|\
  89. tl-wa801nd-v3)
  90. diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
  91. index 97372bed0ea2fadfab10f22916a1e0d6a9c65725..3aa1f054d4f791545a8b6644f7bd24f64ed546a3 100644
  92. --- a/target/linux/ar71xx/base-files/etc/diag.sh
  93. +++ b/target/linux/ar71xx/base-files/etc/diag.sh
  94. @@ -52,6 +52,8 @@ get_status_led() {
  95. ;;
  96. archer-c25-v1|\
  97. archer-c7-v4|\
  98. + archer-c59-v1|\
  99. + archer-c60-v1|\
  100. mr12|\
  101. mr16|\
  102. nbg6616|\
  103. 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
  104. index 607bbd2c0ec4b59ba569550e9e0e87b80c7ddddb..5dd1d69e7e163c938759ce476846e4d985184b7b 100644
  105. --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  106. +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
  107. @@ -97,6 +97,8 @@ case "$FIRMWARE" in
  108. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth0/address) -2)
  109. ;;
  110. archer-c25-v1|\
  111. + archer-c59-v1|\
  112. + archer-c60-v1|\
  113. tl-wdr6500-v2)
  114. ath10kcal_extract "art" 20480 2116
  115. ath10kcal_patch_mac $(macaddr_add $(cat /sys/class/net/eth1/address) -2)
  116. diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  117. index ddb8f0db80ed6eab39c832bfd893182d9f591ad4..780eda30d04b9bae0bf8dcf47a9cc49b19b810ca 100755
  118. --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
  119. +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  120. @@ -469,6 +469,12 @@ ar71xx_board_detect() {
  121. *"Archer C7 v4")
  122. name="archer-c7-v4"
  123. ;;
  124. + *"Archer C59 v1")
  125. + name="archer-c59-v1"
  126. + ;;
  127. + *"Archer C60 v1")
  128. + name="archer-c60-v1"
  129. + ;;
  130. *"Archer C7")
  131. name="archer-c7"
  132. ;;
  133. diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  134. index d414af969912894574e73e286ed5a3998532d34e..31b293ca3c07d2f26ff96037fab5a51bbe9e834c 100755
  135. --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  136. +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  137. @@ -208,6 +208,8 @@ platform_check_image() {
  138. ap90q|\
  139. archer-c25-v1|\
  140. archer-c7-v4|\
  141. + archer-c59-v1|\
  142. + archer-c60-v1|\
  143. bullet-m|\
  144. c-55|\
  145. carambola2|\
  146. diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
  147. index 57b6d2e541d7ef9dea8570ba8de72164d97b9775..5b33d48e52309b807dbdf2697524809ad08072ae 100644
  148. --- a/target/linux/ar71xx/config-4.4
  149. +++ b/target/linux/ar71xx/config-4.4
  150. @@ -52,6 +52,8 @@ CONFIG_ATH79_MACH_AP152=y
  151. CONFIG_ATH79_MACH_AP90Q=y
  152. CONFIG_ATH79_MACH_AP96=y
  153. CONFIG_ATH79_MACH_ARCHER_C25_V1=y
  154. +CONFIG_ATH79_MACH_ARCHER_C59_V1=y
  155. +CONFIG_ATH79_MACH_ARCHER_C60_V1=y
  156. CONFIG_ATH79_MACH_ARCHER_C7=y
  157. CONFIG_ATH79_MACH_ARDUINO_YUN=y
  158. CONFIG_ATH79_MACH_AW_NR580=y
  159. @@ -272,6 +274,7 @@ CONFIG_GENERIC_SMP_IDLE_THREAD=y
  160. CONFIG_GENERIC_TIME_VSYSCALL=y
  161. CONFIG_GPIOLIB=y
  162. CONFIG_GPIOLIB_IRQCHIP=y
  163. +CONFIG_GPIO_74X164=y
  164. CONFIG_GPIO_DEVRES=y
  165. CONFIG_GPIO_74X164=y
  166. # CONFIG_GPIO_LATCH is not set
  167. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  168. index 0a25294c40b5e2d3be825554ec7246a50b9c029b..468d9b333e43814cbadec8d85a20ab94e5cd6d01 100644
  169. --- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  170. +++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
  171. @@ -1244,6 +1244,27 @@ config ATH79_MACH_ARCHER_C25_V1
  172. select ATH79_DEV_M25P80
  173. select ATH79_DEV_WMAC
  174. +config ATH79_MACH_ARCHER_C59_V1
  175. + bool "TP-LINK Archer C59 v1 support"
  176. + select SOC_QCA956X
  177. + select ATH79_DEV_AP9X_PCI if PCI
  178. + select ATH79_DEV_ETH
  179. + select ATH79_DEV_GPIO_BUTTONS
  180. + select ATH79_DEV_LEDS_GPIO
  181. + select ATH79_DEV_M25P80
  182. + select ATH79_DEV_USB
  183. + select ATH79_DEV_WMAC
  184. +
  185. +config ATH79_MACH_ARCHER_C60_V1
  186. + bool "TP-LINK Archer C60 v1 support"
  187. + select SOC_QCA956X
  188. + select ATH79_DEV_AP9X_PCI if PCI
  189. + select ATH79_DEV_ETH
  190. + select ATH79_DEV_GPIO_BUTTONS
  191. + select ATH79_DEV_LEDS_GPIO
  192. + select ATH79_DEV_M25P80
  193. + select ATH79_DEV_WMAC
  194. +
  195. config ATH79_MACH_ARCHER_C7
  196. bool "TP-LINK Archer C5/C7/TL-WDR4900 v2 board support"
  197. select SOC_QCA955X
  198. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Makefile b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
  199. index a0c73550eb0d5bf07ee731171be9e5ef9ff073e7..fbe7fcb0aebb6577b96c27088a158eb025f201cb 100644
  200. --- a/target/linux/ar71xx/files/arch/mips/ath79/Makefile
  201. +++ b/target/linux/ar71xx/files/arch/mips/ath79/Makefile
  202. @@ -57,6 +57,8 @@ obj-$(CONFIG_ATH79_MACH_AP152) += mach-ap152.o
  203. obj-$(CONFIG_ATH79_MACH_AP90Q) += mach-ap90q.o
  204. obj-$(CONFIG_ATH79_MACH_AP96) += mach-ap96.o
  205. obj-$(CONFIG_ATH79_MACH_ARCHER_C25_V1) += mach-archer-c25-v1.o
  206. +obj-$(CONFIG_ATH79_MACH_ARCHER_C59_V1) += mach-archer-c59-v1.o
  207. +obj-$(CONFIG_ATH79_MACH_ARCHER_C60_V1) += mach-archer-c60-v1.o
  208. obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7.o
  209. obj-$(CONFIG_ATH79_MACH_ARCHER_C7) += mach-archer-c7-v4.o
  210. obj-$(CONFIG_ATH79_MACH_ARDUINO_YUN) += mach-arduino-yun.o
  211. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
  212. new file mode 100644
  213. index 0000000000000000000000000000000000000000..28353aa77b05078b895ab48cf6b1ae53abe98ce2
  214. --- /dev/null
  215. +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c59-v1.c
  216. @@ -0,0 +1,223 @@
  217. +/*
  218. + * TP-Link Archer C59 v1 board support
  219. + *
  220. + * Copyright (C) 2016 Henryk Heisig <hyniu@o2.pl>
  221. + *
  222. + * This program is free software; you can redistribute it and/or modify it
  223. + * under the terms of the GNU General Public License version 2 as published
  224. + * by the Free Software Foundation.
  225. + */
  226. +#include <linux/platform_device.h>
  227. +#include <linux/ath9k_platform.h>
  228. +#include <linux/ar8216_platform.h>
  229. +#include <asm/mach-ath79/ar71xx_regs.h>
  230. +#include <linux/gpio.h>
  231. +#include <linux/init.h>
  232. +#include <linux/spi/spi_gpio.h>
  233. +#include <linux/spi/74x164.h>
  234. +
  235. +#include "common.h"
  236. +#include "dev-m25p80.h"
  237. +#include "machtypes.h"
  238. +#include "pci.h"
  239. +#include "dev-ap9x-pci.h"
  240. +#include "dev-eth.h"
  241. +#include "dev-gpio-buttons.h"
  242. +#include "dev-leds-gpio.h"
  243. +#include "dev-spi.h"
  244. +#include "dev-usb.h"
  245. +#include "dev-wmac.h"
  246. +
  247. +#define ARCHER_C59_V1_KEYS_POLL_INTERVAL 20
  248. +#define ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C59_V1_KEYS_POLL_INTERVAL)
  249. +
  250. +#define ARCHER_C59_V1_GPIO_BTN_RESET 21
  251. +#define ARCHER_C59_V1_GPIO_BTN_RFKILL 2
  252. +#define ARCHER_C59_V1_GPIO_BTN_WPS 1
  253. +
  254. +#define ARCHER_C59_V1_GPIO_USB_POWER 22
  255. +
  256. +#define ARCHER_C59_GPIO_SHIFT_OE 16
  257. +#define ARCHER_C59_GPIO_SHIFT_SER 17
  258. +#define ARCHER_C59_GPIO_SHIFT_SRCLK 18
  259. +#define ARCHER_C59_GPIO_SHIFT_SRCLR 19
  260. +#define ARCHER_C59_GPIO_SHIFT_RCLK 20
  261. +
  262. +#define ARCHER_C59_74HC_GPIO_BASE QCA956X_GPIO_COUNT
  263. +#define ARCHER_C59_74HC_GPIO_LED_POWER 23
  264. +#define ARCHER_C59_74HC_GPIO_LED_WLAN2 24
  265. +#define ARCHER_C59_74HC_GPIO_LED_WLAN5 25
  266. +#define ARCHER_C59_74HC_GPIO_LED_LAN 26
  267. +#define ARCHER_C59_74HC_GPIO_LED_WAN_GREEN 27
  268. +#define ARCHER_C59_74HC_GPIO_LED_WAN_AMBER 28
  269. +#define ARCHER_C59_74HC_GPIO_LED_WPS 29
  270. +#define ARCHER_C59_74HC_GPIO_LED_USB 30
  271. +
  272. +#define ARCHER_C59_V1_SSR_BIT_0 0
  273. +#define ARCHER_C59_V1_SSR_BIT_1 1
  274. +#define ARCHER_C59_V1_SSR_BIT_2 2
  275. +#define ARCHER_C59_V1_SSR_BIT_3 3
  276. +#define ARCHER_C59_V1_SSR_BIT_4 4
  277. +#define ARCHER_C59_V1_SSR_BIT_5 5
  278. +#define ARCHER_C59_V1_SSR_BIT_6 6
  279. +#define ARCHER_C59_V1_SSR_BIT_7 7
  280. +
  281. +#define ARCHER_C59_V1_WMAC_CALDATA_OFFSET 0x1000
  282. +#define ARCHER_C59_V1_PCI_CALDATA_OFFSET 0x5000
  283. +
  284. +static struct gpio_led archer_c59_v1_leds_gpio[] __initdata = {
  285. + {
  286. + .name = "archer-c59-v1:green:power",
  287. + .gpio = ARCHER_C59_74HC_GPIO_LED_POWER,
  288. + .active_low = 1,
  289. + },
  290. + {
  291. + .name = "archer-c59-v1:green:wlan2g",
  292. + .gpio = ARCHER_C59_74HC_GPIO_LED_WLAN2,
  293. + .active_low = 1,
  294. + },
  295. + {
  296. + .name = "archer-c59-v1:green:wlan5g",
  297. + .gpio = ARCHER_C59_74HC_GPIO_LED_WLAN5,
  298. + .active_low = 1,
  299. + },
  300. + {
  301. + .name = "archer-c59-v1:green:lan",
  302. + .gpio = ARCHER_C59_74HC_GPIO_LED_LAN,
  303. + .active_low = 1,
  304. + },
  305. + {
  306. + .name = "archer-c59-v1:green:wan",
  307. + .gpio = ARCHER_C59_74HC_GPIO_LED_WAN_GREEN,
  308. + .active_low = 1,
  309. + },
  310. + {
  311. + .name = "archer-c59-v1:amber:wan",
  312. + .gpio = ARCHER_C59_74HC_GPIO_LED_WAN_AMBER,
  313. + .active_low = 1,
  314. + },
  315. + {
  316. + .name = "archer-c59-v1:green:wps",
  317. + .gpio = ARCHER_C59_74HC_GPIO_LED_WPS,
  318. + .active_low = 1,
  319. + },
  320. + {
  321. + .name = "archer-c59-v1:green:usb",
  322. + .gpio = ARCHER_C59_74HC_GPIO_LED_USB,
  323. + .active_low = 1,
  324. + },
  325. +};
  326. +
  327. +static struct gpio_keys_button archer_c59_v1_gpio_keys[] __initdata = {
  328. + {
  329. + .desc = "Reset button",
  330. + .type = EV_KEY,
  331. + .code = KEY_RESTART,
  332. + .debounce_interval = ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL,
  333. + .gpio = ARCHER_C59_V1_GPIO_BTN_RESET,
  334. + .active_low = 1,
  335. + },
  336. + {
  337. + .desc = "RFKILL button",
  338. + .type = EV_KEY,
  339. + .code = KEY_RFKILL,
  340. + .debounce_interval = ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL,
  341. + .gpio = ARCHER_C59_V1_GPIO_BTN_RFKILL,
  342. + .active_low = 1,
  343. + },
  344. + {
  345. + .desc = "WPS button",
  346. + .type = EV_KEY,
  347. + .code = KEY_WPS_BUTTON,
  348. + .debounce_interval = ARCHER_C59_V1_KEYS_DEBOUNCE_INTERVAL,
  349. + .gpio = ARCHER_C59_V1_GPIO_BTN_WPS,
  350. + .active_low = 1,
  351. + },
  352. +};
  353. +
  354. +static struct spi_gpio_platform_data archer_c59_v1_spi_data = {
  355. + .sck = ARCHER_C59_GPIO_SHIFT_SRCLK,
  356. + .miso = SPI_GPIO_NO_MISO,
  357. + .mosi = ARCHER_C59_GPIO_SHIFT_SER,
  358. + .num_chipselect = 1,
  359. +};
  360. +
  361. +static u8 archer_c59_v1_ssr_initdata[] __initdata = {
  362. + BIT(ARCHER_C59_V1_SSR_BIT_7) |
  363. + BIT(ARCHER_C59_V1_SSR_BIT_6) |
  364. + BIT(ARCHER_C59_V1_SSR_BIT_5) |
  365. + BIT(ARCHER_C59_V1_SSR_BIT_4) |
  366. + BIT(ARCHER_C59_V1_SSR_BIT_3) |
  367. + BIT(ARCHER_C59_V1_SSR_BIT_2) |
  368. + BIT(ARCHER_C59_V1_SSR_BIT_1)
  369. +};
  370. +
  371. +static struct gen_74x164_chip_platform_data archer_c59_v1_ssr_data = {
  372. + .base = ARCHER_C59_74HC_GPIO_BASE,
  373. + .num_registers = ARRAY_SIZE(archer_c59_v1_ssr_initdata),
  374. + .init_data = archer_c59_v1_ssr_initdata,
  375. +};
  376. +
  377. +static struct platform_device archer_c59_v1_spi_device = {
  378. + .name = "spi_gpio",
  379. + .id = 1,
  380. + .dev = {
  381. + .platform_data = &archer_c59_v1_spi_data,
  382. + },
  383. +};
  384. +
  385. +static struct spi_board_info archer_c59_v1_spi_info[] = {
  386. + {
  387. + .bus_num = 1,
  388. + .chip_select = 0,
  389. + .max_speed_hz = 10000000,
  390. + .modalias = "74x164",
  391. + .platform_data = &archer_c59_v1_ssr_data,
  392. + .controller_data = (void *) ARCHER_C59_GPIO_SHIFT_RCLK,
  393. + },
  394. +};
  395. +
  396. +static void __init archer_c59_v1_setup(void)
  397. +{
  398. + u8 *mac = (u8 *) KSEG1ADDR(0x1f010008);
  399. + u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  400. +
  401. + ath79_register_m25p80(NULL);
  402. + spi_register_board_info(archer_c59_v1_spi_info,
  403. + ARRAY_SIZE(archer_c59_v1_spi_info));
  404. + platform_device_register(&archer_c59_v1_spi_device);
  405. +
  406. + ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c59_v1_leds_gpio),
  407. + archer_c59_v1_leds_gpio);
  408. +
  409. + ath79_register_gpio_keys_polled(-1, ARCHER_C59_V1_KEYS_POLL_INTERVAL,
  410. + ARRAY_SIZE(archer_c59_v1_gpio_keys),
  411. + archer_c59_v1_gpio_keys);
  412. +
  413. + ath79_register_mdio(1, 0x0);
  414. +
  415. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  416. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  417. + ath79_eth1_data.speed = SPEED_1000;
  418. + ath79_eth1_data.duplex = DUPLEX_FULL;
  419. + ath79_eth1_data.phy_mask = BIT(4);
  420. + ath79_register_eth(1);
  421. +
  422. + ath79_register_wmac(art + ARCHER_C59_V1_WMAC_CALDATA_OFFSET, mac);
  423. + ap91_pci_init(art + ARCHER_C59_V1_PCI_CALDATA_OFFSET, NULL);
  424. +
  425. +
  426. + ath79_register_usb();
  427. + gpio_request_one(ARCHER_C59_V1_GPIO_USB_POWER,
  428. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  429. + "USB power");
  430. + gpio_request_one(ARCHER_C59_GPIO_SHIFT_OE,
  431. + GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  432. + "LED control");
  433. + gpio_request_one(ARCHER_C59_GPIO_SHIFT_SRCLR,
  434. + GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  435. + "LED reset");
  436. +}
  437. +
  438. +MIPS_MACHINE(ATH79_MACH_ARCHER_C59_V1, "ARCHER-C59-V1",
  439. + "TP-LINK Archer C59 v1", archer_c59_v1_setup);
  440. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c60-v1.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c60-v1.c
  441. new file mode 100644
  442. index 0000000000000000000000000000000000000000..78186f02cda0a231afda4e53a1d6ff696ecb6b4a
  443. --- /dev/null
  444. +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-archer-c60-v1.c
  445. @@ -0,0 +1,135 @@
  446. +/*
  447. + * TP-Link Archer C60 v1 board support
  448. + *
  449. + * Copyright (C) 2016 Henryk Heisig <hyniu@o2.pl>
  450. + *
  451. + * This program is free software; you can redistribute it and/or modify it
  452. + * under the terms of the GNU General Public License version 2 as published
  453. + * by the Free Software Foundation.
  454. + */
  455. +#include <linux/platform_device.h>
  456. +#include <linux/ath9k_platform.h>
  457. +#include <linux/ar8216_platform.h>
  458. +#include <asm/mach-ath79/ar71xx_regs.h>
  459. +#include <linux/gpio.h>
  460. +
  461. +#include "common.h"
  462. +#include "dev-m25p80.h"
  463. +#include "machtypes.h"
  464. +#include "pci.h"
  465. +#include "dev-ap9x-pci.h"
  466. +#include "dev-eth.h"
  467. +#include "dev-gpio-buttons.h"
  468. +#include "dev-leds-gpio.h"
  469. +#include "dev-spi.h"
  470. +#include "dev-usb.h"
  471. +#include "dev-wmac.h"
  472. +
  473. +#define ARCHER_C60_V1_GPIO_LED_LAN 2
  474. +#define ARCHER_C60_V1_GPIO_LED_POWER 16
  475. +#define ARCHER_C60_V1_GPIO_LED_WLAN2 17
  476. +#define ARCHER_C60_V1_GPIO_LED_WLAN5 18
  477. +#define ARCHER_C60_V1_GPIO_LED_WPS 19
  478. +#define ARCHER_C60_V1_GPIO_LED_WAN_GREEN 20
  479. +#define ARCHER_C60_V1_GPIO_LED_WAN_AMBER 22
  480. +
  481. +
  482. +#define ARCHER_C60_V1_KEYS_POLL_INTERVAL 20
  483. +#define ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C60_V1_KEYS_POLL_INTERVAL)
  484. +
  485. +#define ARCHER_C60_V1_GPIO_BTN_RESET 21
  486. +#define ARCHER_C60_V1_GPIO_BTN_RFKILL 1
  487. +
  488. +
  489. +
  490. +#define ARCHER_C60_V1_WMAC_CALDATA_OFFSET 0x1000
  491. +#define ARCHER_C60_V1_PCI_CALDATA_OFFSET 0x5000
  492. +
  493. +static struct gpio_led archer_c60_v1_leds_gpio[] __initdata = {
  494. + {
  495. + .name = "archer-c60-v1:green:power",
  496. + .gpio = ARCHER_C60_V1_GPIO_LED_POWER,
  497. + .active_low = 1,
  498. + },
  499. + {
  500. + .name = "archer-c60-v1:green:wlan2g",
  501. + .gpio = ARCHER_C60_V1_GPIO_LED_WLAN2,
  502. + .active_low = 1,
  503. + },
  504. + {
  505. + .name = "archer-c60-v1:green:wlan5g",
  506. + .gpio = ARCHER_C60_V1_GPIO_LED_WLAN5,
  507. + .active_low = 1,
  508. + },
  509. + {
  510. + .name = "archer-c60-v1:green:lan",
  511. + .gpio = ARCHER_C60_V1_GPIO_LED_LAN,
  512. + .active_low = 1,
  513. + },
  514. + {
  515. + .name = "archer-c60-v1:green:wan",
  516. + .gpio = ARCHER_C60_V1_GPIO_LED_WAN_GREEN,
  517. + .active_low = 1,
  518. + },
  519. + {
  520. + .name = "archer-c60-v1:amber:wan",
  521. + .gpio = ARCHER_C60_V1_GPIO_LED_WAN_AMBER,
  522. + .active_low = 1,
  523. + },
  524. + {
  525. + .name = "archer-c60-v1:green:wps",
  526. + .gpio = ARCHER_C60_V1_GPIO_LED_WPS,
  527. + .active_low = 1,
  528. + },
  529. +};
  530. +
  531. +static struct gpio_keys_button archer_c60_v1_gpio_keys[] __initdata = {
  532. + {
  533. + .desc = "Reset button",
  534. + .type = EV_KEY,
  535. + .code = KEY_RESTART,
  536. + .debounce_interval = ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL,
  537. + .gpio = ARCHER_C60_V1_GPIO_BTN_RESET,
  538. + .active_low = 1,
  539. + },
  540. + {
  541. + .desc = "RFKILL button",
  542. + .type = EV_KEY,
  543. + .code = KEY_RFKILL,
  544. + .debounce_interval = ARCHER_C60_V1_KEYS_DEBOUNCE_INTERVAL,
  545. + .gpio = ARCHER_C60_V1_GPIO_BTN_RFKILL,
  546. + .active_low = 1,
  547. + },
  548. +};
  549. +
  550. +static void __init archer_c60_v1_setup(void)
  551. +{
  552. + u8 *mac = (u8 *) KSEG1ADDR(0x1f010008);
  553. + u8 *art = (u8 *) KSEG1ADDR(0x1f7f0000);
  554. +
  555. + ath79_register_m25p80(NULL);
  556. +
  557. + ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c60_v1_leds_gpio),
  558. + archer_c60_v1_leds_gpio);
  559. +
  560. + ath79_register_gpio_keys_polled(-1, ARCHER_C60_V1_KEYS_POLL_INTERVAL,
  561. + ARRAY_SIZE(archer_c60_v1_gpio_keys),
  562. + archer_c60_v1_gpio_keys);
  563. +
  564. + ath79_setup_qca956x_eth_cfg(QCA956X_ETH_CFG_SW_PHY_SWAP |
  565. + QCA956X_ETH_CFG_SW_PHY_ADDR_SWAP);
  566. + ath79_register_mdio(1, 0x0);
  567. +
  568. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  569. +
  570. + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  571. + ath79_eth1_data.speed = SPEED_1000;
  572. + ath79_eth1_data.duplex = DUPLEX_FULL;
  573. + ath79_register_eth(1);
  574. +
  575. + ath79_register_wmac(art + ARCHER_C60_V1_WMAC_CALDATA_OFFSET, mac);
  576. + ap91_pci_init(art + ARCHER_C60_V1_PCI_CALDATA_OFFSET, NULL);
  577. +}
  578. +
  579. +MIPS_MACHINE(ATH79_MACH_ARCHER_C60_V1, "ARCHER-C60-V1",
  580. + "TP-LINK Archer C60 v1", archer_c60_v1_setup);
  581. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  582. index e4623fd08836d59ad4e79e96f02e75e502a55ca6..9fbf354e44992f4dff43df0fb0ea99c344801d97 100644
  583. --- a/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  584. +++ b/target/linux/ar71xx/files/arch/mips/ath79/machtypes.h
  585. @@ -42,6 +42,8 @@ enum ath79_mach_type {
  586. ATH79_MACH_AP96, /* Atheros AP96 */
  587. ATH79_MACH_ARCHER_C25_V1, /* TP-LINK Archer C25 V1 board */
  588. ATH79_MACH_ARCHER_C5, /* TP-LINK Archer C5 board */
  589. + ATH79_MACH_ARCHER_C59_V1, /* TP-LINK Archer C59 V1 board */
  590. + ATH79_MACH_ARCHER_C60_V1, /* TP-LINK Archer C60 V1 board */
  591. ATH79_MACH_ARCHER_C7, /* TP-LINK Archer C7 board */
  592. ATH79_MACH_ARCHER_C7_V2, /* TP-LINK Archer C7 V2 board */
  593. ATH79_MACH_ARCHER_C7_V4, /* TP-LINK Archer C7 V4 board */
  594. diff --git a/target/linux/ar71xx/image/tp-link.mk b/target/linux/ar71xx/image/tp-link.mk
  595. index 27d6c73454aef96e5da47033ec664d2caffca1d5..9e4aa8ea30aedba8050a77ebdcfc8f0034cc14d1 100644
  596. --- a/target/linux/ar71xx/image/tp-link.mk
  597. +++ b/target/linux/ar71xx/image/tp-link.mk
  598. @@ -119,6 +119,36 @@ define Device/archer-c25-v1
  599. endef
  600. TARGET_DEVICES += archer-c25-v1
  601. +define Device/archer-c59-v1
  602. + DEVICE_TITLE := TP-LINK Archer C59 v1
  603. + DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport kmod-ath10k
  604. + BOARDNAME := ARCHER-C59-V1
  605. + TPLINK_BOARD_NAME := ARCHER-C59-V1
  606. + DEVICE_PROFILE := ARCHERC59V1
  607. + IMAGE_SIZE := 14528k
  608. + KERNEL := kernel-bin | patch-cmdline | lzma | uImageArcher lzma
  609. + IMAGES := sysupgrade.bin factory.bin
  610. + IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade
  611. + IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  612. + MTDPARTS := spi0.0:64k(u-boot)ro,64k(mac)ro,1536k(kernel),12992k(rootfs),1664k(tplink)ro,64k(art)ro,14528k@0x20000(firmware)
  613. +endef
  614. +TARGET_DEVICES += archer-c59-v1
  615. +
  616. +define Device/archer-c60-v1
  617. + DEVICE_TITLE := TP-LINK Archer C60 v1
  618. + DEVICE_PACKAGES := kmod-ath10k
  619. + BOARDNAME := ARCHER-C60-V1
  620. + TPLINK_BOARD_NAME := ARCHER-C60-V1
  621. + DEVICE_PROFILE := ARCHERC60V1
  622. + IMAGE_SIZE := 7936k
  623. + KERNEL := kernel-bin | patch-cmdline | lzma | uImageArcher lzma
  624. + IMAGES := sysupgrade.bin factory.bin
  625. + IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade
  626. + IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  627. + MTDPARTS := spi0.0:64k(u-boot)ro,64k(mac)ro,1344k(kernel),6592k(rootfs),64k(tplink)ro,64k(art)ro,7936k@0x20000(firmware)
  628. +endef
  629. +TARGET_DEVICES += archer-c60-v1
  630. +
  631. define Device/cpe510-520
  632. DEVICE_TITLE := TP-LINK CPE510/520
  633. DEVICE_PACKAGES := rssileds
  634. diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
  635. index f5af38a726f5ce33391223a4dbeb2fc0a8cac613..3f6884dcf44c83f9867e4e9936caa79c0abc5dc1 100644
  636. --- a/target/linux/ar71xx/mikrotik/config-default
  637. +++ b/target/linux/ar71xx/mikrotik/config-default
  638. @@ -17,6 +17,8 @@
  639. # CONFIG_ATH79_MACH_AP90Q is not set
  640. # CONFIG_ATH79_MACH_AP96 is not set
  641. # CONFIG_ATH79_MACH_ARCHER_C25_V1 is not set
  642. +# CONFIG_ATH79_MACH_ARCHER_C59_V1 is not set
  643. +# CONFIG_ATH79_MACH_ARCHER_C60_V1 is not set
  644. # CONFIG_ATH79_MACH_ARCHER_C7 is not set
  645. # CONFIG_ATH79_MACH_ARDUINO_YUN is not set
  646. # CONFIG_ATH79_MACH_AW_NR580 is not set
  647. diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
  648. index 5c18f5d594d625f91ff10e21ddc5af2b3b4d768f..a50099aca12aafdcb27f4f2b77ca2a5ce4b4d6f2 100644
  649. --- a/target/linux/ar71xx/nand/config-default
  650. +++ b/target/linux/ar71xx/nand/config-default
  651. @@ -10,6 +10,8 @@
  652. # CONFIG_ATH79_MACH_AP147 is not set
  653. # CONFIG_ATH79_MACH_AP96 is not set
  654. # CONFIG_ATH79_MACH_ARCHER_C25_V1 is not set
  655. +# CONFIG_ATH79_MACH_ARCHER_C59_V1 is not set
  656. +# CONFIG_ATH79_MACH_ARCHER_C60_V1 is not set
  657. # CONFIG_ATH79_MACH_ARCHER_C7 is not set
  658. # CONFIG_ATH79_MACH_AW_NR580 is not set
  659. # CONFIG_ATH79_MACH_CAP324 is not set
  660. diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
  661. index fec830c23ce6707755ddefc849f195872be1e877..aeebf8e0bbdc3ec53c42d5cc01a3ffe892b46804 100644
  662. --- a/tools/firmware-utils/src/tplink-safeloader.c
  663. +++ b/tools/firmware-utils/src/tplink-safeloader.c
  664. @@ -376,6 +376,79 @@ static struct device_info boards[] = {
  665. .last_sysupgrade_partition = "file-system"
  666. },
  667. + /** Firmware layout for the C59v1 */
  668. + {
  669. + .id = "ARCHER-C59-V1",
  670. + .vendor = "",
  671. + .support_list =
  672. + "SupportList:\r\n"
  673. + "{product_name:Archer C59,product_ver:1.0.0,special_id:00000000}\r\n"
  674. + "{product_name:Archer C59,product_ver:1.0.0,special_id:45550000}\r\n"
  675. + "{product_name:Archer C59,product_ver:1.0.0,special_id:55530000}\r\n",
  676. + .support_trail = '\x00',
  677. + .soft_ver = "soft_ver:1.0.0\n",
  678. +
  679. + .partitions = {
  680. + {"fs-uboot", 0x00000, 0x10000},
  681. + {"default-mac", 0x10000, 0x00200},
  682. + {"pin", 0x10200, 0x00200},
  683. + {"device-id", 0x10400, 0x00100},
  684. + {"product-info", 0x10500, 0x0fb00},
  685. + {"os-image", 0x20000, 0x180000},
  686. + {"file-system", 0x1a0000, 0xcb0000},
  687. + {"partition-table", 0xe50000, 0x10000},
  688. + {"soft-version", 0xe60000, 0x10000},
  689. + {"support-list", 0xe70000, 0x10000},
  690. + {"profile", 0xe80000, 0x10000},
  691. + {"default-config", 0xe90000, 0x10000},
  692. + {"user-config", 0xea0000, 0x40000},
  693. + {"usb-config", 0xee0000, 0x10000},
  694. + {"certificate", 0xef0000, 0x10000},
  695. + {"qos-db", 0xf00000, 0x40000},
  696. + {"log", 0xfe0000, 0x10000},
  697. + {"radio", 0xff0000, 0x10000},
  698. + {NULL, 0, 0}
  699. + },
  700. +
  701. + .first_sysupgrade_partition = "os-image",
  702. + .last_sysupgrade_partition = "file-system",
  703. + },
  704. +
  705. + /** Firmware layout for the C60v1 */
  706. + {
  707. + .id = "ARCHER-C60-V1",
  708. + .vendor = "",
  709. + .support_list =
  710. + "SupportList:\r\n"
  711. + "{product_name:Archer C60,product_ver:1.0.0,special_id:00000000}\r\n"
  712. + "{product_name:Archer C60,product_ver:1.0.0,special_id:45550000}\r\n"
  713. + "{product_name:Archer C60,product_ver:1.0.0,special_id:55530000}\r\n",
  714. + .support_trail = '\x00',
  715. + .soft_ver = "soft_ver:1.0.0\n",
  716. +
  717. + .partitions = {
  718. + {"fs-uboot", 0x00000, 0x10000},
  719. + {"default-mac", 0x10000, 0x00200},
  720. + {"pin", 0x10200, 0x00200},
  721. + {"product-info", 0x10400, 0x00100},
  722. + {"partition-table", 0x10500, 0x00800},
  723. + {"soft-version", 0x11300, 0x00200},
  724. + {"support-list", 0x11500, 0x00100},
  725. + {"device-id", 0x11600, 0x00100},
  726. + {"profile", 0x11700, 0x03900},
  727. + {"default-config", 0x15000, 0x04000},
  728. + {"user-config", 0x19000, 0x04000},
  729. + {"os-image", 0x20000, 0x150000},
  730. + {"file-system", 0x170000, 0x678000},
  731. + {"certyficate", 0x7e8000, 0x08000},
  732. + {"radio", 0x7f0000, 0x10000},
  733. + {NULL, 0, 0}
  734. + },
  735. +
  736. + .first_sysupgrade_partition = "os-image",
  737. + .last_sysupgrade_partition = "file-system",
  738. + },
  739. +
  740. /** Firmware layout for the C7 */
  741. {
  742. .id = "ARCHER-C7-V4",