17-lc-hx3001.patch 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. From 5eacf09258839ccda9172962287727ab8825f90b Mon Sep 17 00:00:00 2001
  2. From: Chen Minqiang <[email protected]>
  3. Date: Sat, 16 Dec 2023 07:39:20 +0800
  4. Subject: [PATCH] mediatek: add IMOU LC-HX3001 (uboot layout)
  5. ---
  6. .../mt7981b-imou-lc-hx3001.dts | 239 ++++++++++++++++++
  7. .../filogic/base-files/etc/board.d/01_leds | 5 +
  8. .../filogic/base-files/etc/board.d/02_network | 7 +
  9. .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 6 +
  10. target/linux/mediatek/image/filogic.mk | 23 ++
  11. 5 files changed, 280 insertions(+)
  12. create mode 100644 target/linux/mediatek/dts/mt7981b-imou-lc-hx3001.dts
  13. diff --git a/target/linux/mediatek/dts/mt7981b-imou-lc-hx3001.dts b/target/linux/mediatek/dts/mt7981b-imou-lc-hx3001.dts
  14. new file mode 100644
  15. index 0000000000000..857f2a534e112
  16. --- /dev/null
  17. +++ b/target/linux/mediatek/dts/mt7981b-imou-lc-hx3001.dts
  18. @@ -0,0 +1,239 @@
  19. +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
  20. +
  21. +/dts-v1/;
  22. +#include <dt-bindings/gpio/gpio.h>
  23. +#include <dt-bindings/input/input.h>
  24. +
  25. +#include "mt7981.dtsi"
  26. +
  27. +/ {
  28. + model = "IMOU LC-HX3001 (uboot layout)";
  29. + compatible = "imou,lc-hx3001", "mediatek,mt7981";
  30. +
  31. + aliases {
  32. + led-boot = &power_led;
  33. + led-failsafe = &power_led;
  34. + led-running = &power_led;
  35. + led-upgrade = &power_led;
  36. + serial0 = &uart0;
  37. + };
  38. +
  39. + chosen {
  40. + stdout-path = "serial0:115200n8";
  41. + };
  42. +
  43. + memory {
  44. + reg = <0 0x40000000 0 0x10000000>;
  45. + };
  46. +
  47. + gpio-keys {
  48. + compatible = "gpio-keys";
  49. +
  50. + button-reset {
  51. + label = "reset";
  52. + linux,code = <KEY_RESTART>;
  53. + gpios = <&pio 1 GPIO_ACTIVE_LOW>;
  54. + };
  55. +
  56. + button-mesh {
  57. + label = "mesh";
  58. + linux,code = <BTN_9>;
  59. + linux,input-type = <EV_SW>;
  60. + gpios = <&pio 0 GPIO_ACTIVE_LOW>;
  61. + };
  62. + };
  63. +
  64. + gpio-leds {
  65. + compatible = "gpio-leds";
  66. +
  67. + power_led: led-0 {
  68. + label = "green:power";
  69. + gpios = <&pio 4 GPIO_ACTIVE_LOW>;
  70. + };
  71. +
  72. + led-1 {
  73. + label = "green:wlan";
  74. + gpios = <&pio 5 GPIO_ACTIVE_LOW>;
  75. + };
  76. +
  77. + led-2 {
  78. + label = "red:wan";
  79. + gpios = <&pio 6 GPIO_ACTIVE_LOW>;
  80. + };
  81. +
  82. + led-3 {
  83. + label = "green:wan";
  84. + gpios = <&pio 7 GPIO_ACTIVE_LOW>;
  85. + };
  86. +
  87. + led-4 {
  88. + label = "green:lan";
  89. + gpios = <&pio 8 GPIO_ACTIVE_LOW>;
  90. + };
  91. + };
  92. +};
  93. +
  94. +&eth {
  95. + pinctrl-names = "default";
  96. + pinctrl-0 = <&mdio_pins>;
  97. +
  98. + status = "okay";
  99. +
  100. + gmac0: mac@0 {
  101. + compatible = "mediatek,eth-mac";
  102. + reg = <0>;
  103. + phy-mode = "2500base-x";
  104. +
  105. + fixed-link {
  106. + speed = <2500>;
  107. + full-duplex;
  108. + pause;
  109. + };
  110. + };
  111. +
  112. + gmac1: mac@1 {
  113. + compatible = "mediatek,eth-mac";
  114. + reg = <1>;
  115. + phy-mode = "gmii";
  116. + phy-handle = <&int_gbe_phy>;
  117. + };
  118. +};
  119. +
  120. +&mdio_bus {
  121. + switch: switch@1f {
  122. + compatible = "mediatek,mt7531";
  123. + reg = <31>;
  124. + reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
  125. + interrupt-controller;
  126. + #interrupt-cells = <1>;
  127. + interrupt-parent = <&pio>;
  128. + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
  129. + };
  130. +};
  131. +
  132. +&spi0 {
  133. + pinctrl-names = "default";
  134. + pinctrl-0 = <&spi0_flash_pins>;
  135. + status = "okay";
  136. +
  137. + spi_nand: flash@0 {
  138. + #address-cells = <1>;
  139. + #size-cells = <1>;
  140. + compatible = "spi-nand";
  141. + reg = <0>;
  142. + spi-max-frequency = <52000000>;
  143. +
  144. + spi-cal-enable;
  145. + spi-cal-mode = "read-data";
  146. + spi-cal-datalen = <7>;
  147. + spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
  148. + spi-cal-addrlen = <5>;
  149. + spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
  150. +
  151. + spi-tx-bus-width = <4>;
  152. + spi-rx-bus-width = <4>;
  153. + mediatek,nmbm;
  154. + mediatek,bmt-max-ratio = <1>;
  155. + mediatek,bmt-max-reserved-blocks = <64>;
  156. +
  157. + partitions {
  158. + compatible = "fixed-partitions";
  159. + #address-cells = <1>;
  160. + #size-cells = <1>;
  161. +
  162. + partition@0 {
  163. + label = "BL2";
  164. + reg = <0x00000 0x100000>;
  165. + };
  166. +
  167. + partition@100000 {
  168. + label = "u-boot-env";
  169. + reg = <0x100000 0x80000>;
  170. + };
  171. +
  172. + factory: partition@180000 {
  173. + label = "Factory";
  174. + reg = <0x180000 0x200000>;
  175. + };
  176. +
  177. + partition@380000 {
  178. + label = "FIP";
  179. + reg = <0x380000 0x200000>;
  180. + };
  181. +
  182. + partition@580000 {
  183. + label = "ubi";
  184. + reg = <0x580000 0x7280000>;
  185. + };
  186. + };
  187. + };
  188. +};
  189. +
  190. +&switch {
  191. + ports {
  192. + #address-cells = <1>;
  193. + #size-cells = <0>;
  194. +
  195. + port@0 {
  196. + reg = <0>;
  197. + label = "lan1";
  198. + };
  199. +
  200. + port@1 {
  201. + reg = <1>;
  202. + label = "lan2";
  203. + };
  204. +
  205. + port@2 {
  206. + reg = <2>;
  207. + label = "lan3";
  208. + };
  209. +
  210. + port@6 {
  211. + reg = <6>;
  212. + ethernet = <&gmac0>;
  213. + phy-mode = "2500base-x";
  214. +
  215. + fixed-link {
  216. + speed = <2500>;
  217. + full-duplex;
  218. + pause;
  219. + };
  220. + };
  221. + };
  222. +};
  223. +
  224. +&pio {
  225. + spi0_flash_pins: spi0-pins {
  226. + mux {
  227. + function = "spi";
  228. + groups = "spi0", "spi0_wp_hold";
  229. + };
  230. +
  231. + conf-pu {
  232. + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
  233. + drive-strength = <8>;
  234. + bias-pull-up = <103>;
  235. + };
  236. +
  237. + conf-pd {
  238. + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
  239. + drive-strength = <8>;
  240. + bias-pull-down = <103>;
  241. + };
  242. + };
  243. +};
  244. +
  245. +&uart0 {
  246. + status = "okay";
  247. +};
  248. +
  249. +&watchdog {
  250. + status = "okay";
  251. +};
  252. +
  253. +&wifi {
  254. + status = "okay";
  255. +
  256. + mediatek,mtd-eeprom = <&factory 0x0>;
  257. +};
  258. 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
  259. index 0a1f642c70924..fda3d4b98d875 100644
  260. --- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
  261. +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
  262. @@ -20,6 +20,14 @@ confiabits,mt7981)
  263. cudy,wr3000-v1)
  264. ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan"
  265. ;;
  266. +imou,lc-hx3001)
  267. + ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1" "link"
  268. + ucidef_set_led_netdev "lan" "LAN" "green:lan" "br-lan" "link"
  269. + ucidef_set_led_netdev "wlan" "WLAN" "green:wlan" "phy1-ap0" "link"
  270. + ;;
  271. +konka,komi-a31)
  272. + ucidef_set_led_netdev "eth1" "eth1" "blue:status" "eth1" "link"
  273. + ;;
  274. mercusys,mr90x-v1)
  275. ucidef_set_led_netdev "lan-0" "lan-0" "green:lan-0" "lan0" "link tx rx"
  276. ucidef_set_led_netdev "lan-1" "lan-1" "green:lan-1" "lan1" "link tx rx"
  277. 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
  278. index 61637e09c7f0e..4048eddadb45a 100644
  279. --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  280. +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  281. @@ -130,6 +130,12 @@
  282. wan_mac=$label_mac
  283. lan_mac=$(macaddr_add "$label_mac" 2)
  284. ;;
  285. + imou,lc-hx3001)
  286. + lan_mac=$(mtd_get_mac_ascii u-boot-env mac)
  287. + [ -n "$lan_mac" ] || lan_mac=$(macaddr_add $(mtd_get_mac_binary Factory 0x4) -1)
  288. + wan_mac=$(macaddr_add $lan_mac 2)
  289. + label_mac="$lan_mac"
  290. + ;;
  291. h3c,magic-nx30-pro)
  292. wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
  293. lan_mac=$(macaddr_add "$wan_mac" 1)
  294. diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
  295. index 83428f0d981e7..6d2e9d713be02 100644
  296. --- a/target/linux/mediatek/image/filogic.mk
  297. +++ b/target/linux/mediatek/image/filogic.mk
  298. @@ -589,6 +589,50 @@ endif
  299. endef
  300. TARGET_DEVICES += h3c_magic-nx30-pro-nmbm
  301. +define Device/imou_lc-hx3001
  302. + DEVICE_VENDOR := IMOU
  303. + DEVICE_MODEL := LC-HX3001
  304. + DEVICE_DTS := mt7981b-imou-lc-hx3001
  305. + DEVICE_DTS_DIR := ../dts
  306. + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
  307. + SUPPORTED_DEVICES += imou,lc-hx3001
  308. + UBINIZE_OPTS := -E 5
  309. + BLOCKSIZE := 128k
  310. + PAGESIZE := 2048
  311. + IMAGE_SIZE := 113152k
  312. + KERNEL_IN_UBI := 1
  313. + IMAGES += factory.bin
  314. + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
  315. + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  316. + KERNEL = kernel-bin | lzma | \
  317. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
  318. + KERNEL_INITRAMFS = kernel-bin | lzma | \
  319. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
  320. +endef
  321. +TARGET_DEVICES += imou_lc-hx3001
  322. +
  323. +define Device/konka_komi-a31
  324. + DEVICE_VENDOR := KONKA
  325. + DEVICE_MODEL := KOMI A31
  326. + DEVICE_DTS := mt7981b-konka-komi-a31
  327. + DEVICE_DTS_DIR := ../dts
  328. + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
  329. + SUPPORTED_DEVICES := konka,komi-a31
  330. + UBINIZE_OPTS := -E 5
  331. + BLOCKSIZE := 128k
  332. + PAGESIZE := 2048
  333. + IMAGE_SIZE := 114688k
  334. + KERNEL_IN_UBI := 1
  335. + IMAGES += factory.bin
  336. + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
  337. + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
  338. + KERNEL = kernel-bin | lzma | \
  339. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
  340. + KERNEL_INITRAMFS = kernel-bin | lzma | \
  341. + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
  342. +endef
  343. +TARGET_DEVICES += konka_komi-a31
  344. +
  345. define Device/jcg_q30-pro
  346. DEVICE_VENDOR := JCG
  347. DEVICE_MODEL := Q30 PRO