360t7.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. From 0e0de4f8b35a36d170c80cd54498d65dacdade18 Mon Sep 17 00:00:00 2001
  2. From: Tianling Shen <[email protected]>
  3. Date: Fri, 12 May 2023 18:00:42 +0800
  4. Subject: [PATCH] mediatek: add Qihoo 360 T7 support
  5. Co-authored-by: Chen Minqiang <[email protected]>
  6. Signed-off-by: Tianling Shen <[email protected]>
  7. ---
  8. .../uboot-envtools/files/mediatek_filogic | 4 +-
  9. .../dts/mt7981b-qihoo-360-t7-stock.dts | 26 ++
  10. .../dts/mt7981b-qihoo-360-t7-ubootmod.dts | 16 ++
  11. .../mediatek/dts/mt7981b-qihoo-360-t7.dtsi | 238 ++++++++++++++++++
  12. .../filogic/base-files/etc/board.d/02_network | 9 +-
  13. .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 5 +
  14. target/linux/mediatek/image/filogic.mk | 32 +++
  15. 7 files changed, 328 insertions(+), 2 deletions(-)
  16. create mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts
  17. create mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts
  18. create mode 100644 target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi
  19. diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
  20. index 50b9cd0e4631c..739a6f007e23a 100644
  21. --- a/package/boot/uboot-envtools/files/mediatek_filogic
  22. +++ b/package/boot/uboot-envtools/files/mediatek_filogic
  23. @@ -37,6 +37,10 @@ bananapi,bpi-r3)
  24. ;;
  25. esac
  26. ;;
  27. +qihoo,360-t7-stock|\
  28. +qihoo,360-t7-ubootmod)
  29. + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" "1"
  30. + ;;
  31. xiaomi,redmi-router-ax6000-stock)
  32. ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
  33. ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x10000" "0x20000"
  34. diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts
  35. new file mode 100644
  36. index 00000000000..9311ccc6f01
  37. --- /dev/null
  38. +++ b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-stock.dts
  39. @@ -0,0 +1,26 @@
  40. +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
  41. +
  42. +/dts-v1/;
  43. +#include "mt7981b-qihoo-360-t7.dtsi"
  44. +
  45. +/ {
  46. + model = "Qihoo 360 T7 (stock layout)";
  47. + compatible = "qihoo,360-t7-stock", "mediatek,mt7981";
  48. +};
  49. +
  50. +&partitions {
  51. + partition@580000 {
  52. + label = "ubi";
  53. + reg = <0x580000 0x2400000>;
  54. + };
  55. +
  56. + partition@2980000 {
  57. + label = "firmware-1";
  58. + reg = <0x2980000 0x2400000>;
  59. + };
  60. +
  61. + partition@4D80000 {
  62. + label = "plugin";
  63. + reg = <0x4d80000 0x2400000>;
  64. + };
  65. +};
  66. diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts
  67. new file mode 100644
  68. index 00000000000..6e009509fd5
  69. --- /dev/null
  70. +++ b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7-ubootmod.dts
  71. @@ -0,0 +1,16 @@
  72. +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
  73. +
  74. +/dts-v1/;
  75. +#include "mt7981b-qihoo-360-t7.dtsi"
  76. +
  77. +/ {
  78. + model = "Qihoo 360 T7 (modified U-Boot layout)";
  79. + compatible = "qihoo,360-t7-ubootmod", "mediatek,mt7981";
  80. +};
  81. +
  82. +&partitions {
  83. + partition@580000 {
  84. + label = "ubi";
  85. + reg = <0x580000 0x6c00000>;
  86. + };
  87. +};
  88. diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi
  89. new file mode 100644
  90. index 00000000000..387712ec330
  91. --- /dev/null
  92. +++ b/target/linux/mediatek/dts/mt7981b-qihoo-360-t7.dtsi
  93. @@ -0,0 +1,242 @@
  94. +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
  95. +
  96. +/dts-v1/;
  97. +#include "mt7981.dtsi"
  98. +
  99. +/ {
  100. + aliases {
  101. + led-boot = &red_led;
  102. + led-failsafe = &red_led;
  103. + led-running = &green_led;
  104. + led-upgrade = &green_led;
  105. + serial0 = &uart0;
  106. + };
  107. +
  108. + chosen {
  109. + stdout-path = "serial0:115200n8";
  110. + };
  111. +
  112. + gpio-keys {
  113. + compatible = "gpio-keys";
  114. +
  115. + button-reset {
  116. + label = "reset";
  117. + linux,code = <KEY_RESTART>;
  118. + gpios = <&pio 1 GPIO_ACTIVE_LOW>;
  119. + };
  120. +
  121. + button-wps {
  122. + label = "wps";
  123. + linux,code = <KEY_WPS_BUTTON>;
  124. + gpios = <&pio 0 GPIO_ACTIVE_LOW>;
  125. + };
  126. + };
  127. +
  128. + gpio-leds {
  129. + compatible = "gpio-leds";
  130. +
  131. + red_led: led-0 {
  132. + label = "red:system";
  133. + gpios = <&pio 3 GPIO_ACTIVE_LOW>;
  134. + };
  135. +
  136. + green_led: led-1 {
  137. + label = "green:system";
  138. + gpios = <&pio 7 GPIO_ACTIVE_LOW>;
  139. + };
  140. + };
  141. +};
  142. +
  143. +&uart0 {
  144. + status = "okay";
  145. +};
  146. +
  147. +&watchdog {
  148. + status = "okay";
  149. +};
  150. +
  151. +&eth {
  152. + pinctrl-names = "default";
  153. + pinctrl-0 = <&mdio_pins>;
  154. +
  155. + status = "okay";
  156. +
  157. + gmac0: mac@0 {
  158. + compatible = "mediatek,eth-mac";
  159. + reg = <0>;
  160. + phy-mode = "2500base-x";
  161. +
  162. + nvmem-cells = <&macaddr_factory_14>;
  163. + nvmem-cell-names = "mac-address-ascii";
  164. +
  165. + fixed-link {
  166. + speed = <2500>;
  167. + full-duplex;
  168. + pause;
  169. + };
  170. + };
  171. +};
  172. +
  173. +&mdio_bus {
  174. + switch0: switch@0 {
  175. + compatible = "mediatek,mt7531";
  176. + reg = <31>;
  177. + dsa,member = <0 0>;
  178. + reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
  179. + interrupt-controller;
  180. + #interrupt-cells = <1>;
  181. + interrupt-parent = <&pio>;
  182. + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
  183. + };
  184. +};
  185. +
  186. +&switch0 {
  187. + ports {
  188. + #address-cells = <1>;
  189. + #size-cells = <0>;
  190. +
  191. + port@0 {
  192. + reg = <0>;
  193. + label = "lan1";
  194. + };
  195. +
  196. + port@1 {
  197. + reg = <1>;
  198. + label = "lan2";
  199. + };
  200. +
  201. + port@2 {
  202. + reg = <2>;
  203. + label = "lan3";
  204. + };
  205. +
  206. + port@3 {
  207. + reg = <3>;
  208. + label = "wan";
  209. +
  210. + nvmem-cells = <&macaddr_factory_14>;
  211. + nvmem-cell-names = "mac-address-ascii";
  212. + mac-address-increment = <1>;
  213. + };
  214. +
  215. + port@6 {
  216. + reg = <6>;
  217. + ethernet = <&gmac0>;
  218. + phy-mode = "2500base-x";
  219. +
  220. + fixed-link {
  221. + speed = <2500>;
  222. + full-duplex;
  223. + pause;
  224. + };
  225. + };
  226. + };
  227. +};
  228. +
  229. +&spi0 {
  230. + pinctrl-names = "default";
  231. + pinctrl-0 = <&spi0_flash_pins>;
  232. + status = "okay";
  233. +
  234. + spi_nand: flash@0 {
  235. + #address-cells = <1>;
  236. + #size-cells = <1>;
  237. + compatible = "spi-nand";
  238. + reg = <0>;
  239. + spi-max-frequency = <52000000>;
  240. +
  241. + spi-cal-enable;
  242. + spi-cal-mode = "read-data";
  243. + spi-cal-datalen = <7>;
  244. + spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
  245. + spi-cal-addrlen = <5>;
  246. + spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
  247. +
  248. + spi-tx-buswidth = <4>;
  249. + spi-rx-buswidth = <4>;
  250. + mediatek,nmbm;
  251. + mediatek,bmt-max-ratio = <1>;
  252. + mediatek,bmt-max-reserved-blocks = <64>;
  253. +
  254. + partitions: partitions {
  255. + compatible = "fixed-partitions";
  256. + #address-cells = <1>;
  257. + #size-cells = <1>;
  258. +
  259. + partition@0 {
  260. + label = "BL2";
  261. + reg = <0x00 0x100000>;
  262. + };
  263. +
  264. + partition@100000 {
  265. + label = "u-boot-env";
  266. + reg = <0x100000 0x80000>;
  267. + };
  268. +
  269. + factory: partition@180000 {
  270. + label = "Factory";
  271. + reg = <0x180000 0x200000>;
  272. + };
  273. +
  274. + partition@380000 {
  275. + label = "FIP";
  276. + reg = <0x380000 0x200000>;
  277. + };
  278. +
  279. + partition@7180000 {
  280. + label = "stock-config";
  281. + reg = <0x7180000 0x100000>;
  282. + };
  283. +
  284. + partition@7280000 {
  285. + label = "stock-factory";
  286. + reg = <0x7280000 0x80000>;
  287. +
  288. + compatible = "nvmem-cells";
  289. + #address-cells = <1>;
  290. + #size-cells = <1>;
  291. +
  292. + macaddr_factory_14: macaddr@14 {
  293. + reg = <0x14 0x11>;
  294. + };
  295. +
  296. + };
  297. +
  298. + partition@7300000 {
  299. + label = "stock-log";
  300. + reg = <0x7300000 0x400000>;
  301. + };
  302. + };
  303. + };
  304. +};
  305. +
  306. +&pio {
  307. + spi0_flash_pins: spi0-pins {
  308. + mux {
  309. + function = "spi";
  310. + groups = "spi0", "spi0_wp_hold";
  311. + };
  312. +
  313. + conf-pu {
  314. + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
  315. + drive-strength = <MTK_DRIVE_8mA>;
  316. + bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
  317. + };
  318. +
  319. + conf-pd {
  320. + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
  321. + drive-strength = <MTK_DRIVE_8mA>;
  322. + bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
  323. + };
  324. + };
  325. +};
  326. +
  327. +&wifi {
  328. + mediatek,mtd-eeprom = <&factory 0x0>;
  329. +
  330. + nvmem-cells = <&macaddr_factory_14>;
  331. + nvmem-cell-names = "mac-address-ascii";
  332. + mac-address-increment = <2>;
  333. +
  334. + status = "okay";
  335. +};
  336. 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
  337. index 2fca00921b8ca..983aa9a83aa86 100644
  338. --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  339. +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  340. @@ -36,6 +36,10 @@ mediatek_setup_interfaces()
  341. tplink,tl-xdr6086)
  342. ucidef_set_interfaces_lan_wan "lan1 lan2" eth1
  343. ;;
  344. + qihoo,360-t7-stock|\
  345. + qihoo,360-t7-ubootmod)
  346. + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan
  347. + ;;
  348. xiaomi,redmi-router-ax6000-stock|\
  349. xiaomi,redmi-router-ax6000-ubootmod)
  350. ucidef_set_interfaces_lan_wan "lan2 lan3 lan4" wan
  351. 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
  352. index 29edea9c502..32853dcef4a 100644
  353. --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
  354. +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
  355. @@ -28,6 +28,11 @@ case "$board" in
  356. addr=$(mtd_get_mac_ascii config2 wifi5gmac)
  357. [ "$PHYNBR" = "1" ] && echo $macaddr > /sys${DEVPATH}/macaddress
  358. ;;
  359. + qihoo,360-t7-stock|\
  360. + qihoo,360-t7-ubootmod)
  361. + addr=$(macaddr_add $(cat /sys/class/net/eth0/address) 2)
  362. + [ "$PHYNBR" = "1" ] && macaddr_setbit $addr 6 > /sys${DEVPATH}/macaddress
  363. + ;;
  364. tplink,tl-xdr4288|\
  365. tplink,tl-xdr6086|\
  366. tplink,tl-xdr6088)
  367. diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
  368. index 16c9ea2c130..d6fcb395dd9 100644
  369. --- a/target/linux/mediatek/image/filogic.mk
  370. +++ b/target/linux/mediatek/image/filogic.mk
  371. @@ -162,6 +162,38 @@ define Device/mediatek_mt7986b-rfb
  372. endef
  373. TARGET_DEVICES += mediatek_mt7986b-rfb
  374. +define Device/qihoo_360-t7-common
  375. + DEVICE_VENDOR := Qihoo
  376. + DEVICE_DTS_DIR := ../dts
  377. + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
  378. + UBINIZE_OPTS := -E 5
  379. + BLOCKSIZE := 128k
  380. + PAGESIZE := 2048
  381. + IMAGE_SIZE := 65536k
  382. + KERNEL_IN_UBI := 1
  383. + IMAGES += factory.bin
  384. + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
  385. + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  386. + KERNEL = kernel-bin | lzma | \
  387. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
  388. + KERNEL_INITRAMFS = kernel-bin | lzma | \
  389. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
  390. +endef
  391. +
  392. +define Device/qihoo_360-t7-stock
  393. + DEVICE_MODEL := 360 T7 (stock layout)
  394. + DEVICE_DTS := mt7981b-qihoo-360-t7-stock
  395. + $(call Device/qihoo_360-t7-common)
  396. +endef
  397. +TARGET_DEVICES += qihoo_360-t7-stock
  398. +
  399. +define Device/qihoo_360-t7-ubootmod
  400. + DEVICE_MODEL := 360 T7 (modified U-Boot layout)
  401. + DEVICE_DTS := mt7981b-qihoo-360-t7-ubootmod
  402. + $(call Device/qihoo_360-t7-common)
  403. +endef
  404. +TARGET_DEVICES += qihoo_360-t7-ubootmod
  405. +
  406. define Device/tplink_tl-xdr-common
  407. DEVICE_VENDOR := TP-Link
  408. DEVICE_DTS_DIR := ../dts