12-asr3000.patch 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. From 02f7ea25d6612180b3a97b688d6e69cfe7af2f0d Mon Sep 17 00:00:00 2001
  2. From: Tianling Shen <[email protected]>
  3. Date: Thu, 19 Oct 2023 15:14:45 +0800
  4. Subject: [PATCH] mediatek: add ABT ASR3000 support
  5. Signed-off-by: Tianling Shen <[email protected]>
  6. ---
  7. .../dts/mt7981b-abt-asr3000.dts | 267 ++++++++++++++++++
  8. .../filogic/base-files/etc/board.d/01_leds | 5 +
  9. .../filogic/base-files/etc/board.d/02_network | 17 +-
  10. .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 5 +
  11. target/linux/mediatek/image/filogic.mk | 21 ++
  12. 5 files changed, 307 insertions(+), 8 deletions(-)
  13. create mode 100644 target/linux/mediatek/dts/mt7981b-abt-asr3000.dts
  14. diff --git a/target/linux/mediatek/dts/mt7981b-abt-asr3000.dts b/target/linux/mediatek/dts/mt7981b-abt-asr3000.dts
  15. new file mode 100644
  16. index 00000000000..605721f2d08
  17. --- /dev/null
  18. +++ b/target/linux/mediatek/dts/mt7981b-abt-asr3000.dts
  19. @@ -0,0 +1,268 @@
  20. +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
  21. +/*
  22. + * Copyright (C) 2023 Tianling Shen <[email protected]>
  23. + */
  24. +
  25. +/dts-v1/;
  26. +#include <dt-bindings/gpio/gpio.h>
  27. +#include <dt-bindings/input/input.h>
  28. +
  29. +#include "mt7981.dtsi"
  30. +
  31. +/ {
  32. + model = "ABT ASR3000 (custom U-Boot layout)";
  33. + compatible = "abt,asr3000", "mediatek,mt7981";
  34. +
  35. + aliases {
  36. + led-boot = &mesh_led;
  37. + led-failsafe = &mesh_led;
  38. + led-upgrade = &mesh_led;
  39. + serial0 = &uart0;
  40. + label-mac-device = &gmac1;
  41. + };
  42. +
  43. + chosen {
  44. + stdout-path = "serial0:115200n8";
  45. + };
  46. +
  47. + memory {
  48. + reg = <0 0x40000000 0 0x10000000>;
  49. + };
  50. +
  51. + gpio-keys {
  52. + compatible = "gpio-keys";
  53. +
  54. + button-reset {
  55. + label = "reset";
  56. + linux,code = <KEY_RESTART>;
  57. + gpios = <&pio 1 GPIO_ACTIVE_LOW>;
  58. + };
  59. +
  60. + button-mesh {
  61. + label = "mesh";
  62. + linux,code = <BTN_9>;
  63. + linux,input-type = <EV_SW>;
  64. + gpios = <&pio 0 GPIO_ACTIVE_HIGH>;
  65. + };
  66. + };
  67. +
  68. + gpio-leds {
  69. + compatible = "gpio-leds";
  70. +
  71. + led-0 {
  72. + label = "red:wan";
  73. + gpios = <&pio 4 GPIO_ACTIVE_LOW>;
  74. + };
  75. +
  76. + led-1 {
  77. + label = "green:wan";
  78. + gpios = <&pio 8 GPIO_ACTIVE_LOW>;
  79. + };
  80. +
  81. + mesh_led: led-2 {
  82. + label = "green:mesh";
  83. + gpios = <&pio 15 GPIO_ACTIVE_HIGH>;
  84. + };
  85. +
  86. + led-3 {
  87. + label = "green:wlan2g";
  88. + gpios = <&pio 34 GPIO_ACTIVE_LOW>;
  89. + };
  90. +
  91. + led-4 {
  92. + label = "green:wlan5g";
  93. + gpios = <&pio 35 GPIO_ACTIVE_LOW>;
  94. + };
  95. + };
  96. +};
  97. +
  98. +&eth {
  99. + pinctrl-names = "default";
  100. + pinctrl-0 = <&mdio_pins>;
  101. +
  102. + status = "okay";
  103. +
  104. + gmac0: mac@0 {
  105. + compatible = "mediatek,eth-mac";
  106. + reg = <0>;
  107. + phy-mode = "2500base-x";
  108. +
  109. + nvmem-cells = <&macaddr_art_0 0>;
  110. + nvmem-cell-names = "mac-address";
  111. +
  112. + fixed-link {
  113. + speed = <2500>;
  114. + full-duplex;
  115. + pause;
  116. + };
  117. + };
  118. +
  119. + gmac1: mac@1 {
  120. + compatible = "mediatek,eth-mac";
  121. + reg = <1>;
  122. + phy-mode = "gmii";
  123. + phy-handle = <&int_gbe_phy>;
  124. +
  125. + nvmem-cells = <&macaddr_art_0 0>;
  126. + nvmem-cell-names = "mac-address";
  127. + };
  128. +};
  129. +
  130. +&mdio_bus {
  131. + switch: switch@0 {
  132. + compatible = "mediatek,mt7531";
  133. + reg = <31>;
  134. + reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
  135. + interrupt-controller;
  136. + #interrupt-cells = <1>;
  137. + interrupt-parent = <&pio>;
  138. + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
  139. + };
  140. +};
  141. +
  142. +&spi0 {
  143. + pinctrl-names = "default";
  144. + pinctrl-0 = <&spi0_flash_pins>;
  145. + status = "okay";
  146. +
  147. + spi_nand: flash@0 {
  148. + #address-cells = <1>;
  149. + #size-cells = <1>;
  150. + compatible = "spi-nand";
  151. + reg = <0>;
  152. + spi-max-frequency = <52000000>;
  153. +
  154. + spi-cal-enable;
  155. + spi-cal-mode = "read-data";
  156. + spi-cal-datalen = <7>;
  157. + spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
  158. + spi-cal-addrlen = <5>;
  159. + spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
  160. +
  161. + spi-tx-bus-width = <4>;
  162. + spi-rx-bus-width = <4>;
  163. + mediatek,nmbm;
  164. + mediatek,bmt-max-ratio = <1>;
  165. + mediatek,bmt-max-reserved-blocks = <64>;
  166. +
  167. + partitions: partitions {
  168. + compatible = "fixed-partitions";
  169. + #address-cells = <1>;
  170. + #size-cells = <1>;
  171. +
  172. + partition@0 {
  173. + label = "BL2";
  174. + reg = <0x00000 0x100000>;
  175. + read-only;
  176. + };
  177. +
  178. + partition@100000 {
  179. + label = "u-boot-env";
  180. + reg = <0x100000 0x80000>;
  181. + };
  182. +
  183. + partition@180000 {
  184. + label = "art";
  185. + reg = <0x180000 0x100000>;
  186. + read-only;
  187. +
  188. + compatible = "nvmem-cells";
  189. + nvmem-layout {
  190. + compatible = "fixed-layout";
  191. + #address-cells = <1>;
  192. + #size-cells = <1>;
  193. +
  194. + macaddr_art_0: macaddr@0 {
  195. + compatible = "mac-base";
  196. + reg = <0x0 0x6>;
  197. + #nvmem-cell-cells = <1>;
  198. + };
  199. + };
  200. + };
  201. +
  202. + factory: partition@280000 {
  203. + label = "Factory";
  204. + reg = <0x280000 0x100000>;
  205. + };
  206. +
  207. + partition@380000 {
  208. + label = "FIP";
  209. + reg = <0x380000 0x200000>;
  210. + };
  211. +
  212. + partition@580000 {
  213. + label = "ubi";
  214. + reg = <0x580000 0x6e80000>;
  215. + };
  216. + };
  217. + };
  218. +};
  219. +
  220. +&switch {
  221. + ports {
  222. + #address-cells = <1>;
  223. + #size-cells = <0>;
  224. +
  225. + port@0 {
  226. + reg = <0>;
  227. + label = "lan1";
  228. + };
  229. +
  230. + port@1 {
  231. + reg = <1>;
  232. + label = "lan2";
  233. + };
  234. +
  235. + port@2 {
  236. + reg = <2>;
  237. + label = "lan3";
  238. + };
  239. +
  240. + port@6 {
  241. + reg = <6>;
  242. + ethernet = <&gmac0>;
  243. + phy-mode = "2500base-x";
  244. +
  245. + fixed-link {
  246. + speed = <2500>;
  247. + full-duplex;
  248. + pause;
  249. + };
  250. + };
  251. + };
  252. +};
  253. +
  254. +&pio {
  255. + spi0_flash_pins: spi0-pins {
  256. + mux {
  257. + function = "spi";
  258. + groups = "spi0", "spi0_wp_hold";
  259. + };
  260. +
  261. + conf-pu {
  262. + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
  263. + drive-strength = <MTK_DRIVE_8mA>;
  264. + bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
  265. + };
  266. +
  267. + conf-pd {
  268. + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
  269. + drive-strength = <MTK_DRIVE_8mA>;
  270. + bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
  271. + };
  272. + };
  273. +};
  274. +
  275. +&uart0 {
  276. + status = "okay";
  277. +};
  278. +
  279. +&watchdog {
  280. + status = "okay";
  281. +};
  282. +
  283. +&wifi {
  284. + status = "okay";
  285. +
  286. + mediatek,mtd-eeprom = <&factory 0x0>;
  287. +};
  288. diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  289. index 2e978be6804bf..429c6f359fed4 100644
  290. --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  291. +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  292. @@ -34,6 +34,7 @@ mediatek_setup_interfaces()
  293. bananapi,bpi-r3)
  294. ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 sfp2" "eth1 wan"
  295. ;;
  296. + abt,asr3000|\
  297. cmcc,rax3000m*|\
  298. h3c,magic-nx30-pro)
  299. ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1
  300. diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
  301. index 3d625a820d6..9290afe4c31 100644
  302. --- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
  303. +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
  304. @@ -6,6 +6,11 @@ board=$(board_name)
  305. board_config_update
  306. case $board in
  307. +abt,asr3000)
  308. + ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
  309. + ucidef_set_led_netdev "wlan2g" "WLAN2G" "green:wlan2g" "phy0-ap0"
  310. + ucidef_set_led_netdev "wlan5g" "WLAN5G" "green:wlan5g" "phy1-ap0"
  311. + ;;
  312. confiabits,mt7981)
  313. ucidef_set_led_netdev "lan1" "lan1" "blue:lan-1" "lan1" "link tx rx"
  314. ucidef_set_led_netdev "lan2" "lan2" "blue:lan-2" "lan2" "link tx rx"
  315. diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
  316. index 6a513c74fb9..f586edf525f 100644
  317. --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
  318. +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
  319. @@ -10,6 +10,11 @@ PHYNBR=${DEVPATH##*/phy}
  320. board=$(board_name)
  321. case "$board" in
  322. + abt,asr3000)
  323. + addr=$(get_mac_label)
  324. + [ "$PHYNBR" = "0" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
  325. + [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
  326. + ;;
  327. acer,predator-w6)
  328. key_path="/var/qcidata/data"
  329. [ "$PHYNBR" = "0" ] && cat $key_path/2gMAC > /sys${DEVPATH}/macaddress
  330. diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
  331. index 95aee51b689..7f28be90a7b 100644
  332. --- a/target/linux/mediatek/image/filogic.mk
  333. +++ b/target/linux/mediatek/image/filogic.mk
  334. @@ -105,6 +105,27 @@ define Build/cetron-header
  335. rm [email protected]
  336. endef
  337. +define Device/abt_asr3000
  338. + DEVICE_VENDOR := ABT
  339. + DEVICE_MODEL := ASR3000
  340. + DEVICE_DTS := mt7981b-abt-asr3000
  341. + DEVICE_DTS_DIR := ../dts
  342. + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
  343. + UBINIZE_OPTS := -E 5
  344. + BLOCKSIZE := 128k
  345. + PAGESIZE := 2048
  346. + IMAGE_SIZE := 113152k
  347. + KERNEL_IN_UBI := 1
  348. + IMAGES += factory.bin
  349. + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
  350. + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  351. + KERNEL = kernel-bin | lzma | \
  352. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
  353. + KERNEL_INITRAMFS = kernel-bin | lzma | \
  354. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
  355. +endef
  356. +TARGET_DEVICES += abt_asr3000
  357. +
  358. define Device/asus_tuf-ax4200
  359. DEVICE_VENDOR := ASUS
  360. DEVICE_MODEL := TUF-AX4200