0083-ar71xx-generic-add-Support-for-TP-LINK-TL-WR940N-v4.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. From: David Lutz <kpanic@hirnduenger.de>
  2. Date: Sun, 11 Dec 2016 21:06:14 +0100
  3. Subject: ar71xx-generic: add Support for TP-LINK TL-WR940N v4
  4. Signed-off-by: David Lutz <kpanic@hirnduenger.de>
  5. diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
  6. index 6b0caa676e6fc23be94c5eae77ae72e76f07fec3..67043d432cf7a469bf1ded14bc354274ab16e3e6 100644
  7. --- a/target/linux/ar71xx/base-files/etc/diag.sh
  8. +++ b/target/linux/ar71xx/base-files/etc/diag.sh
  9. @@ -296,6 +296,7 @@ get_status_led() {
  10. tl-wr703n | \
  11. tl-wr710n | \
  12. tl-wr720n-v3 | \
  13. + tl-wr940n-v4 | \
  14. tl-wr941nd-v6)
  15. status_led="tp-link:blue:system"
  16. ;;
  17. diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
  18. index 849755fb752c62a6fabf0ec609381b5d22991f1a..e47cbb0b01ef4a335c059a74af66d9f8999b3b3d 100644
  19. --- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
  20. +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
  21. @@ -486,6 +486,7 @@ tl-wr941nd-v5)
  22. ucidef_set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
  23. ;;
  24. +tl-wr940n-v4 | \
  25. tl-wr941nd-v6)
  26. ucidef_set_led_netdev "wan" "WAN" "tp-link:blue:wan" "eth0"
  27. ucidef_set_led_switch "lan1" "LAN1" "tp-link:blue:lan1" "switch0" "0x10"
  28. diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
  29. index 027a671215e5acd70cee06620c6648506ad6be47..878623ce3fd8b7c585da73c7bd72794a144096a3 100755
  30. --- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
  31. +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
  32. @@ -229,6 +229,7 @@ tl-wr841n-v8 |\
  33. tl-wr842n-v2 |\
  34. tl-wr941nd-v5 |\
  35. tl-wr941nd-v6 |\
  36. +tl-wr940n-v4 |\
  37. wnr2000-v3 |\
  38. wnr2000-v4 |\
  39. wnr2200 |\
  40. diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  41. index 5e93ba628e4644eedbad98cf7a7766775a088f14..63f8dc630bf8c10c6b6224f934a86e922e0bcc43 100755
  42. --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
  43. +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
  44. @@ -235,6 +235,9 @@ tplink_board_detect() {
  45. "090100"*)
  46. model="TP-Link TL-WA901N/ND"
  47. ;;
  48. + "094000"*)
  49. + model="TP-Link TL-WR940N"
  50. + ;;
  51. "094100"*)
  52. if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
  53. model="Rosewill RNX-N360RT"
  54. @@ -884,6 +887,9 @@ ar71xx_board_detect() {
  55. *"TL-WR941N/ND v6")
  56. name="tl-wr941nd-v6"
  57. ;;
  58. + *"TL-WR940N v4")
  59. + name="tl-wr940n-v4"
  60. + ;;
  61. *"TL-WR703N v1")
  62. name="tl-wr703n"
  63. ;;
  64. diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx
  65. index f552453e43363c5ab687116eee1889af8171dbb6..e5e4abd547f38ecda4a0cb67858df8f5d3477d59 100644
  66. --- a/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx
  67. +++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx
  68. @@ -36,6 +36,7 @@ set_preinit_iface() {
  69. tl-wr841n-v8 |\
  70. tl-wr842n-v2 |\
  71. tl-wr941nd-v6 |\
  72. + tl-wr940n-v4 |\
  73. wnr2000-v3 |\
  74. wnr2200 |\
  75. wnr612-v2 |\
  76. diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  77. index ee2e596e1f5e462e544a919ca8ebca525e43cec9..76c252ccb14db970aac63ea1d2eaddca3d867867 100755
  78. --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  79. +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
  80. @@ -373,6 +373,7 @@ platform_check_image() {
  81. tl-wr941nd | \
  82. tl-wr941nd-v5 | \
  83. tl-wr941nd-v6 | \
  84. + tl-wr940n-v4 | \
  85. tl-wr1041n-v2 | \
  86. tl-wr1043nd | \
  87. tl-wr1043nd-v2 | \
  88. diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18
  89. index d7cbe2e79af31a0ff88d946323e237f3215620a0..050362614a464b56d3740a7954686fe4e5b37803 100644
  90. --- a/target/linux/ar71xx/config-3.18
  91. +++ b/target/linux/ar71xx/config-3.18
  92. @@ -141,6 +141,7 @@ CONFIG_ATH79_MACH_TL_WR841N_V8=y
  93. CONFIG_ATH79_MACH_TL_WR841N_V9=y
  94. CONFIG_ATH79_MACH_TL_WR941ND=y
  95. CONFIG_ATH79_MACH_TL_WR941ND_V6=y
  96. +CONFIG_ATH79_MACH_TL_WR940N_V4=y
  97. CONFIG_ATH79_MACH_TUBE2H=y
  98. CONFIG_ATH79_MACH_UBNT=y
  99. CONFIG_ATH79_MACH_UBNT_UNIFIAC=y
  100. diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr940n-v4.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr940n-v4.c
  101. new file mode 100644
  102. index 0000000000000000000000000000000000000000..d693b947c843d2a74cd252503fa8bf68b20da4ab
  103. --- /dev/null
  104. +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-tl-wr940n-v4.c
  105. @@ -0,0 +1,149 @@
  106. +/*
  107. + * TP-LINK TL-WR940N v4 board support
  108. + *
  109. + * Copyright (C) 2016 David Lutz <kpanic@ff3l.net>
  110. + *
  111. + * This program is free software; you can redistribute it and/or modify it
  112. + * under the terms of the GNU General Public License version 2 as published
  113. + * by the Free Software Foundation.
  114. + */
  115. +
  116. +#include <linux/gpio.h>
  117. +#include <linux/platform_device.h>
  118. +
  119. +#include <asm/mach-ath79/ath79.h>
  120. +#include <asm/mach-ath79/ar71xx_regs.h>
  121. +
  122. +#include "common.h"
  123. +#include "dev-eth.h"
  124. +#include "dev-gpio-buttons.h"
  125. +#include "dev-leds-gpio.h"
  126. +#include "dev-m25p80.h"
  127. +#include "dev-wmac.h"
  128. +#include "machtypes.h"
  129. +
  130. +
  131. +#define TL_WR940N_V4_GPIO_LED_QSS 3
  132. +#define TL_WR940N_V4_GPIO_LED_WAN 14
  133. +#define TL_WR940N_V4_GPIO_LED_WAN_RED 15
  134. +#define TL_WR940N_V4_GPIO_LED_LAN4 4
  135. +#define TL_WR940N_V4_GPIO_LED_LAN3 18
  136. +#define TL_WR940N_V4_GPIO_LED_LAN2 6
  137. +#define TL_WR940N_V4_GPIO_LED_LAN1 8
  138. +#define TL_WR940N_V4_GPIO_LED_WLAN 7
  139. +#define TL_WR940N_V4_GPIO_LED_SYSTEM 5
  140. +
  141. +#define TL_WR940N_V4_GPIO_BTN_RESET 1
  142. +#define TL_WR940N_V4_GPIO_BTN_RFKILL 2
  143. +
  144. +#define TL_WR940N_V4_KEYS_POLL_INTERVAL 20
  145. +#define TL_WR940N_V4_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR940N_V4_KEYS_POLL_INTERVAL)
  146. +
  147. +
  148. +static struct gpio_led tl_wr940n_v4_leds_gpio[] __initdata = {
  149. + {
  150. + .name = "tp-link:blue:qss",
  151. + .gpio = TL_WR940N_V4_GPIO_LED_QSS,
  152. + .active_low = 1,
  153. + },
  154. + {
  155. + .name = "tp-link:blue:wan",
  156. + .gpio = TL_WR940N_V4_GPIO_LED_WAN,
  157. + .active_low = 1,
  158. + },
  159. + {
  160. + .name = "tp-link:red:wan",
  161. + .gpio = TL_WR940N_V4_GPIO_LED_WAN_RED,
  162. + .active_low = 0,
  163. + },
  164. + {
  165. + .name = "tp-link:blue:lan1",
  166. + .gpio = TL_WR940N_V4_GPIO_LED_LAN1,
  167. + .active_low = 1,
  168. + },
  169. + {
  170. + .name = "tp-link:blue:lan2",
  171. + .gpio = TL_WR940N_V4_GPIO_LED_LAN2,
  172. + .active_low = 1,
  173. + },
  174. + {
  175. + .name = "tp-link:blue:lan3",
  176. + .gpio = TL_WR940N_V4_GPIO_LED_LAN3,
  177. + .active_low = 1,
  178. + },
  179. + {
  180. + .name = "tp-link:blue:lan4",
  181. + .gpio = TL_WR940N_V4_GPIO_LED_LAN4,
  182. + .active_low = 1,
  183. + },
  184. + {
  185. + .name = "tp-link:blue:wlan",
  186. + .gpio = TL_WR940N_V4_GPIO_LED_WLAN,
  187. + .active_low = 1,
  188. + },
  189. + {
  190. + .name = "tp-link:blue:system",
  191. + .gpio = TL_WR940N_V4_GPIO_LED_SYSTEM,
  192. + .active_low = 1,
  193. + },
  194. +};
  195. +
  196. +static struct gpio_keys_button tl_wr940n_v4_gpio_keys[] __initdata = {
  197. + {
  198. + .desc = "Reset button",
  199. + .type = EV_KEY,
  200. + .code = KEY_RESTART,
  201. + .debounce_interval = TL_WR940N_V4_KEYS_DEBOUNCE_INTERVAL,
  202. + .gpio = TL_WR940N_V4_GPIO_BTN_RESET,
  203. + .active_low = 1,
  204. + }, {
  205. + .desc = "RFKILL button",
  206. + .type = EV_KEY,
  207. + .code = KEY_RFKILL,
  208. + .debounce_interval = TL_WR940N_V4_KEYS_DEBOUNCE_INTERVAL,
  209. + .gpio = TL_WR940N_V4_GPIO_BTN_RFKILL,
  210. + .active_low = 1,
  211. + }
  212. +};
  213. +
  214. +
  215. +static const char *tl_wr940n_v4_part_probes[] = {
  216. + "tp-link",
  217. + NULL,
  218. +};
  219. +
  220. +static struct flash_platform_data tl_wr940n_v4_flash_data = {
  221. + .part_probes = tl_wr940n_v4_part_probes,
  222. +};
  223. +
  224. +
  225. +static void __init tl_wr940n_v4_setup(void)
  226. +{
  227. + u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  228. + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  229. +
  230. + ath79_register_m25p80(&tl_wr940n_v4_flash_data);
  231. +
  232. + ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr940n_v4_leds_gpio),
  233. + tl_wr940n_v4_leds_gpio);
  234. +
  235. + ath79_register_gpio_keys_polled(-1, TL_WR940N_V4_KEYS_POLL_INTERVAL,
  236. + ARRAY_SIZE(tl_wr940n_v4_gpio_keys),
  237. + tl_wr940n_v4_gpio_keys);
  238. +
  239. + ath79_register_mdio(0, 0x0);
  240. +
  241. + ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  242. + ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
  243. +
  244. + ath79_switch_data.phy4_mii_en = 1;
  245. +
  246. + ath79_register_eth(0);
  247. + ath79_register_eth(1);
  248. +
  249. + ath79_register_wmac(ee, mac);
  250. +
  251. +}
  252. +
  253. +MIPS_MACHINE(ATH79_MACH_TL_WR940N_V4, "TL-WR940N-v4", "TP-LINK TL-WR940N v4",
  254. + tl_wr940n_v4_setup);
  255. diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
  256. index 6346eb9ffa6c9bbeb1eaa5de229cf69ce12c1f83..b35c713f3c92c3d02f26f4bf535aeec34fd71b12 100644
  257. --- a/target/linux/ar71xx/image/Makefile
  258. +++ b/target/linux/ar71xx/image/Makefile
  259. @@ -650,6 +650,16 @@ define Device/tl-wr941nd-v6
  260. TPLINK_HWID := 0x09410006
  261. endef
  262. +define Device/tl-wr940n-v4
  263. + $(Device/tplink-4mlzma)
  264. + BOARDNAME := TL-WR940N-v4
  265. + DEVICE_PROFILE := TLWR941
  266. + TPLINK_HWID := 0x09400004
  267. + IMAGES += factory-us.bin factory-eu.bin
  268. + IMAGE/factory-us.bin := append-rootfs | mktplinkfw factory -C US
  269. + IMAGE/factory-eu.bin := append-rootfs | mktplinkfw factory -C EU
  270. +endef
  271. +
  272. # Chinese version (unlike European) is similar to the TL-WDR3500
  273. define Device/tl-wr941nd-v6-cn
  274. $(Device/tplink-4mlzma)
  275. @@ -657,7 +667,7 @@ define Device/tl-wr941nd-v6-cn
  276. DEVICE_PROFILE := TLWR941
  277. TPLINK_HWID := 0x09410006
  278. endef
  279. -TARGET_DEVICES += tl-wr941nd-v5 tl-wr941nd-v6 tl-wr941nd-v6-cn
  280. +TARGET_DEVICES += tl-wr941nd-v5 tl-wr941nd-v6 tl-wr941nd-v6-cn tl-wr940n-v4
  281. define Device/tl-wr1041n-v2
  282. $(Device/tplink-4mlzma)
  283. diff --git a/target/linux/ar71xx/mikrotik/config-default b/target/linux/ar71xx/mikrotik/config-default
  284. index 2b1fe2491c7a00449453efdc4969015ec1b28291..75155b22489a60748b3b1357a1d9c549092255ba 100644
  285. --- a/target/linux/ar71xx/mikrotik/config-default
  286. +++ b/target/linux/ar71xx/mikrotik/config-default
  287. @@ -94,6 +94,7 @@ CONFIG_ATH79_MACH_RBSXTLITE=y
  288. # CONFIG_ATH79_MACH_TL_WR841N_V8 is not set
  289. # CONFIG_ATH79_MACH_TL_WR841N_V9 is not set
  290. # CONFIG_ATH79_MACH_TL_WR941ND is not set
  291. +# CONFIG_ATH79_MACH_TL_WR940N_V4 is not set
  292. # CONFIG_ATH79_MACH_TUBE2H is not set
  293. # CONFIG_ATH79_MACH_UBNT is not set
  294. # CONFIG_ATH79_MACH_UBNT_XM is not set
  295. diff --git a/target/linux/ar71xx/nand/config-default b/target/linux/ar71xx/nand/config-default
  296. index f62cf1a4399718b2f4e94a974d26ddaf8d46a8ec..802d6e0502b51a4ecf2259c20e9b6667cd255680 100644
  297. --- a/target/linux/ar71xx/nand/config-default
  298. +++ b/target/linux/ar71xx/nand/config-default
  299. @@ -57,6 +57,7 @@
  300. # CONFIG_ATH79_MACH_TL_WR841N_V1 is not set
  301. # CONFIG_ATH79_MACH_TL_WR841N_V8 is not set
  302. # CONFIG_ATH79_MACH_TL_WR941ND is not set
  303. +# CONFIG_ATH79_MACH_TL_WR940N_V4 is not set
  304. # CONFIG_ATH79_MACH_UBNT is not set
  305. # CONFIG_ATH79_MACH_UBNT_XM is not set
  306. # CONFIG_ATH79_MACH_UBNT_UNIFIAC is not set
  307. diff --git a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
  308. index d23f0cf33e50da891e7135861f1defda047ff2c8..b7517464742679b66c3bd916b9b2a2fcc34b65e1 100644
  309. --- a/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
  310. +++ b/target/linux/ar71xx/patches-3.18/610-MIPS-ath79-openwrt-machines.patch
  311. @@ -1,6 +1,6 @@
  312. --- a/arch/mips/ath79/machtypes.h
  313. +++ b/arch/mips/ath79/machtypes.h
  314. -@@ -16,22 +16,205 @@
  315. +@@ -16,22 +16,206 @@
  316. enum ath79_mach_type {
  317. ATH79_MACH_GENERIC = 0,
  318. @@ -154,6 +154,7 @@
  319. + ATH79_MACH_TL_WR941ND, /* TP-LINK TL-WR941ND */
  320. + ATH79_MACH_TL_WR941ND_V5, /* TP-LINK TL-WR941ND v5 */
  321. + ATH79_MACH_TL_WR941ND_V6, /* TP-LINK TL-WR941ND v6 */
  322. ++ ATH79_MACH_TL_WR940N_V4, /* TP-LINK TL-WR940N v4 */
  323. + ATH79_MACH_TUBE2H, /* Alfa Network Tube2H */
  324. + ATH79_MACH_UBNT_AIRGW, /* Ubiquiti AirGateway */
  325. ATH79_MACH_UBNT_AIRROUTER, /* Ubiquiti AirRouter */
  326. @@ -354,7 +355,7 @@
  327. config ATH79_MACH_PB44
  328. bool "Atheros PB44 reference board"
  329. select SOC_AR71XX
  330. -@@ -68,6 +178,967 @@ config ATH79_MACH_PB44
  331. +@@ -68,6 +178,976 @@ config ATH79_MACH_PB44
  332. Say 'Y' here if you want your kernel to support the
  333. Atheros PB44 reference board.
  334. @@ -1229,6 +1230,15 @@
  335. + select ATH79_DEV_M25P80
  336. + select ATH79_DEV_WMAC
  337. +
  338. ++config ATH79_MACH_TL_WR940N_V4
  339. ++ bool "TP-LINK TL-WR940N v4 support"
  340. ++ select SOC_QCA956X
  341. ++ select ATH79_DEV_ETH
  342. ++ select ATH79_DEV_GPIO_BUTTONS
  343. ++ select ATH79_DEV_LEDS_GPIO
  344. ++ select ATH79_DEV_M25P80
  345. ++ select ATH79_DEV_WMAC
  346. ++
  347. +config ATH79_MACH_TL_WR1041N_V2
  348. + bool "TP-LINK TL-WR1041N v2 support"
  349. + select SOC_AR934X
  350. @@ -1322,7 +1332,7 @@
  351. config ATH79_MACH_UBNT_XM
  352. bool "Ubiquiti Networks XM/UniFi boards"
  353. select SOC_AR724X
  354. -@@ -83,6 +1154,117 @@ config ATH79_MACH_UBNT_XM
  355. +@@ -83,6 +1163,117 @@ config ATH79_MACH_UBNT_XM
  356. Say 'Y' here if you want your kernel to support the
  357. Ubiquiti Networks XM (rev 1.0) board.
  358. @@ -1440,7 +1450,7 @@
  359. endmenu
  360. config SOC_AR71XX
  361. -@@ -124,7 +1306,10 @@ config ATH79_DEV_DSA
  362. +@@ -124,7 +1315,10 @@ config ATH79_DEV_DSA
  363. config ATH79_DEV_ETH
  364. def_bool n
  365. @@ -1452,7 +1462,7 @@
  366. def_bool n
  367. config ATH79_DEV_GPIO_BUTTONS
  368. -@@ -154,6 +1339,11 @@ config ATH79_PCI_ATH9K_FIXUP
  369. +@@ -154,6 +1348,11 @@ config ATH79_PCI_ATH9K_FIXUP
  370. def_bool n
  371. config ATH79_ROUTERBOOT
  372. @@ -1466,7 +1476,7 @@
  373. endif
  374. --- a/arch/mips/ath79/Makefile
  375. +++ b/arch/mips/ath79/Makefile
  376. -@@ -38,9 +38,130 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route
  377. +@@ -38,9 +47,131 @@ obj-$(CONFIG_ATH79_ROUTERBOOT) += route
  378. #
  379. # Machines
  380. #
  381. @@ -1561,6 +1571,7 @@
  382. +obj-$(CONFIG_ATH79_MACH_TL_WR841N_V9) += mach-tl-wr841n-v9.o
  383. +obj-$(CONFIG_ATH79_MACH_TL_WR941ND) += mach-tl-wr941nd.o
  384. +obj-$(CONFIG_ATH79_MACH_TL_WR941ND_V6) += mach-tl-wr941nd-v6.o
  385. ++obj-$(CONFIG_ATH79_MACH_TL_WR940N_V4) += mach-tl-wr940n-v4.o
  386. +obj-$(CONFIG_ATH79_MACH_TL_WR1041N_V2) += mach-tl-wr1041n-v2.o
  387. +obj-$(CONFIG_ATH79_MACH_TL_WR1043ND) += mach-tl-wr1043nd.o
  388. +obj-$(CONFIG_ATH79_MACH_TL_WR1043ND_V2) += mach-tl-wr1043nd-v2.o