11-gl-mt2500.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. From 12396686484a488dff1c4a1ee8b5197c552572fe Mon Sep 17 00:00:00 2001
  2. From: David Bauer <[email protected]>
  3. Date: Thu, 20 Apr 2023 19:49:55 +0200
  4. Subject: [PATCH] mediatek: add support for GL.iNet GL-MT2500
  5. Hardware
  6. --------
  7. SoC: MediaTek MT7981BA
  8. RAM: 1GB DDR4 (NANYA NT5AD512M16C4-JR)
  9. MMC: 8GB eMMC (Samsung 8GTF4R)
  10. ETH: 1000Base-T LAN (ePHY)
  11. 2500Base-T WAN (MaxLinear GPY211C)
  12. BTN: 1x Reset Button
  13. LED: System (blue/white)
  14. VPN (white)
  15. USB: 1x USB-A (USB 3.0)
  16. UART: 115200 8N1 - Pinout on board next to LAN port
  17. Don't connect 3.3V!
  18. Known Issues
  19. ------------
  20. U-Boot vendor recovery does not seem to accept any images, neither
  21. GL.iNet images nor OpenWrt images. Recovery requires serial access!
  22. Installation
  23. ------------
  24. Upload the OpenWrt sysupgrade image to the Gl.iNet Web-UI. Make sure to
  25. not retain existing settings.
  26. Signed-off-by: David Bauer <[email protected]>
  27. ---
  28. .../uboot-envtools/files/mediatek_filogic | 4 +
  29. .../mediatek/dts/mt7981b-glinet-gl-mt2500.dts | 151 ++++++++++++++++++
  30. .../filogic/base-files/etc/board.d/02_network | 6 +
  31. .../base-files/lib/upgrade/platform.sh | 2 +
  32. target/linux/mediatek/image/filogic.mk | 17 ++
  33. 5 files changed, 180 insertions(+)
  34. create mode 100644 target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts
  35. diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
  36. index ae8e1589a024b..4d37828f1db95 100644
  37. --- a/package/boot/uboot-envtools/files/mediatek_filogic
  38. +++ b/package/boot/uboot-envtools/files/mediatek_filogic
  39. @@ -74,6 +74,10 @@ xiaomi,redmi-router-ax6000-ubootmod)
  40. ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x20000" "1"
  41. ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x20000" "1"
  42. ;;
  43. +glinet,gl-mt2500)
  44. + local envdev=$(find_mmc_part "u-boot-env")
  45. + ubootenv_add_uci_config "$envdev" "0x400000" "0x80000"
  46. + ;;
  47. glinet,gl-mt3000)
  48. ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000"
  49. ;;
  50. diff --git a/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts b/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts
  51. new file mode 100644
  52. index 0000000000000..068dd0f236e28
  53. --- /dev/null
  54. +++ b/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts
  55. @@ -0,0 +1,151 @@
  56. +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
  57. +
  58. +/dts-v1/;
  59. +#include "mt7981.dtsi"
  60. +
  61. +/ {
  62. + model = "GL.iNet GL-MT2500";
  63. + compatible = "glinet,gl-mt2500", "mediatek,mt7981";
  64. +
  65. + aliases {
  66. + label-mac-device = &gmac0;
  67. + led-boot = &led_sys_white;
  68. + led-failsafe = &led_sys_blue;
  69. + led-running = &led_sys_white;
  70. + led-upgrade = &led_sys_blue;
  71. + serial0 = &uart0;
  72. + };
  73. +
  74. + chosen {
  75. + stdout-path = "serial0:115200n8";
  76. + bootargs-append = " root=PARTLABEL=rootfs rootwait";
  77. + };
  78. +
  79. + gpio-keys {
  80. + compatible = "gpio-keys";
  81. +
  82. + reset {
  83. + label = "reset";
  84. + linux,code = <KEY_RESTART>;
  85. + gpios = <&pio 1 GPIO_ACTIVE_LOW>;
  86. + };
  87. + };
  88. +
  89. + leds {
  90. + compatible = "gpio-leds";
  91. +
  92. + led-vpn {
  93. + label = "white:vpn";
  94. + gpios = <&pio 31 GPIO_ACTIVE_LOW>;
  95. + };
  96. +
  97. + led_sys_white: led-system-white {
  98. + label = "white:system";
  99. + gpios = <&pio 30 GPIO_ACTIVE_LOW>;
  100. + };
  101. +
  102. + led_sys_blue: led-system-blue {
  103. + label = "blue:system";
  104. + gpios = <&pio 29 GPIO_ACTIVE_LOW>;
  105. + };
  106. + };
  107. +
  108. + usb_vbus: regulstor-usb {
  109. + compatible = "regulator-fixed";
  110. +
  111. + regulator-name = "usb-vbus";
  112. + regulator-min-microvolt = <5000000>;
  113. + regulator-max-microvolt = <5000000>;
  114. +
  115. + gpio = <&pio 12 GPIO_ACTIVE_HIGH>;
  116. + enable-active-high;
  117. + regulator-boot-on;
  118. + };
  119. +
  120. + reg_3p3v: regulator-3p3v {
  121. + compatible = "regulator-fixed";
  122. + regulator-name = "fixed-3.3V";
  123. + regulator-min-microvolt = <3300000>;
  124. + regulator-max-microvolt = <3300000>;
  125. + regulator-boot-on;
  126. + regulator-always-on;
  127. + };
  128. +};
  129. +
  130. +&pio {
  131. + mmc0_pins_default: mmc0-pins-default {
  132. + mux {
  133. + function = "flash";
  134. + groups = "emmc_45";
  135. + };
  136. + };
  137. + mmc0_pins_uhs: mmc0-pins-uhs {
  138. + mux {
  139. + function = "flash";
  140. + groups = "emmc_45";
  141. + };
  142. + };
  143. +};
  144. +
  145. +&uart0 {
  146. + status = "okay";
  147. +};
  148. +
  149. +&watchdog {
  150. + status = "okay";
  151. +};
  152. +
  153. +&eth {
  154. + status = "okay";
  155. +
  156. + pinctrl-names = "default";
  157. + pinctrl-0 = <&mdio_pins>;
  158. +
  159. + gmac0: mac@0 {
  160. + compatible = "mediatek,eth-mac";
  161. + reg = <0>;
  162. +
  163. + phy-mode = "2500base-x";
  164. + phy-handle = <&phy5>;
  165. + };
  166. +
  167. + gmac1: mac@1 {
  168. + compatible = "mediatek,eth-mac";
  169. + reg = <1>;
  170. + phy-mode = "gmii";
  171. + phy-handle = <&int_gbe_phy>;
  172. + };
  173. +};
  174. +
  175. +&mdio_bus {
  176. + reset-gpios = <&pio 14 GPIO_ACTIVE_LOW>;
  177. + reset-delay-us = <600>;
  178. + reset-post-delay-us = <20000>;
  179. +
  180. + phy5: ethernet-phy@5 {
  181. + reg = <5>;
  182. + compatible = "ethernet-phy-ieee802.3-c45";
  183. + };
  184. +};
  185. +
  186. +&usb_phy {
  187. + status = "okay";
  188. +};
  189. +
  190. +&xhci {
  191. + status = "okay";
  192. + vbus-supply = <&usb_vbus>;
  193. +};
  194. +
  195. +&mmc0 {
  196. + status = "okay";
  197. +
  198. + pinctrl-names = "default", "state_uhs";
  199. + pinctrl-0 = <&mmc0_pins_default>;
  200. + pinctrl-1 = <&mmc0_pins_uhs>;
  201. + bus-width = <8>;
  202. + max-frequency = <52000000>;
  203. + vmmc-supply = <&reg_3p3v>;
  204. + cap-mmc-highspeed;
  205. + non-removable;
  206. +};
  207. 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
  208. index 5153c156f65bd..0675e87853ac7 100644
  209. --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  210. +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
  211. @@ -32,6 +32,7 @@ mediatek_setup_interfaces()
  212. h3c,magic-nx30-pro)
  213. ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1
  214. ;;
  215. + glinet,gl-mt2500|\
  216. glinet,gl-mt3000)
  217. ucidef_set_interfaces_lan_wan eth1 eth0
  218. ;;
  219. @@ -109,6 +110,11 @@ mediatek_setup_macs()
  220. ;;
  221. esac
  222. ;;
  223. + glinet,gl-mt2500)
  224. + label_mac="$(get_mac_binary "/dev/mmcblk0boot1" 0xA)"
  225. + wan_mac="$label_mac"
  226. + lan_mac="$(macaddr_add $label_mac 1)"
  227. + ;;
  228. glinet,gl-mt6000)
  229. label_mac=$(mmc_get_mac_binary factory 0x0a)
  230. wan_mac=$label_mac
  231. diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
  232. index 3c278d5faf2c4..6130768cb4c66 100755
  233. --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
  234. +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
  235. @@ -97,6 +97,7 @@ platform_do_upgrade() {
  236. cudy,wr3000-v1)
  237. default_do_upgrade "$1"
  238. ;;
  239. + glinet,gl-mt2500|\
  240. glinet,gl-mt6000)
  241. CI_KERNPART="kernel"
  242. CI_ROOTPART="rootfs"
  243. @@ -176,6 +177,7 @@ platform_copy_config() {
  244. ;;
  245. esac
  246. ;;
  247. + glinet,gl-mt2500|\
  248. glinet,gl-mt6000|\
  249. ubnt,unifi-6-plus)
  250. emmc_copy_config
  251. diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
  252. index 4886db11419e5..a0a5f944a8f69 100644
  253. --- a/target/linux/mediatek/image/filogic.mk
  254. +++ b/target/linux/mediatek/image/filogic.mk
  255. @@ -274,6 +274,19 @@ define Device/cudy_wr3000-v1
  256. endef
  257. TARGET_DEVICES += cudy_wr3000-v1
  258. +define Device/glinet_gl-mt2500
  259. + DEVICE_VENDOR := GL.iNet
  260. + DEVICE_MODEL := GL-MT2500
  261. + DEVICE_DTS := mt7981b-glinet-gl-mt2500
  262. + DEVICE_DTS_DIR := ../dts
  263. + DEVICE_DTS_LOADADDR := 0x47000000
  264. + DEVICE_PACKAGES := -kmod-mt7915e -wpad-basic-mbedtls e2fsprogs f2fsck mkf2fs kmod-usb3
  265. + SUPPORTED_DEVICES += glinet,mt2500-emmc
  266. + IMAGES := sysupgrade.bin
  267. + IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata
  268. +endef
  269. +TARGET_DEVICES += glinet_gl-mt2500
  270. +
  271. define Device/glinet_gl-mt3000
  272. DEVICE_VENDOR := GL.iNet
  273. DEVICE_MODEL := GL-MT3000