gl-infra-builder-FUjr/patches-mt798x-7.6.6.1/0103-target-mediatek-amend-board-for-GL.iNet-GL-X3000.patch
Li Zhang cd17b889b3 block2mtd: support multi partition map
Signed-off-by: Li Zhang <li.zhang@gl-inet.com>
2022-12-22 18:23:19 +08:00

439 lines
12 KiB
Diff

From 143512bba3454468815e56432b9a08833c5650a8 Mon Sep 17 00:00:00 2001
From: lincolnzh <hongjian.zhang@gl-inet.com>
Date: Wed, 21 Dec 2022 15:45:28 +0800
Subject: [PATCH] target/mediatek: amend board for GL.iNet GL-X3000
---
.../boot/dts/mediatek/mt7981-gl-x3000.dts | 307 +++++++++++++++++-
target/linux/mediatek/image/mt7981.mk | 11 +-
.../mt7981/base-files/etc/board.d/01_leds | 20 ++
.../mt7981/base-files/etc/board.d/02_network | 6 +-
.../patches-5.4/403-support-x3000-emmc.patch | 30 ++
5 files changed, 358 insertions(+), 16 deletions(-)
create mode 100755 target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
create mode 100644 target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts
index 769a9416e6..25647db01d 100755
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts
@@ -1,8 +1,307 @@
/dts-v1/;
-
-#include "mt7981-gl-mt3000.dts"
-
+#include "mt7981.dtsi"
/ {
model = "GL.iNet GL-X3000";
- compatible = "glinet,x3000-snand", "mediatek,mt7981";
+ compatible = "glinet,x3000-emmc", "mediatek,mt7981";
+
+ chosen {
+ bootargs = "console=ttyS0,115200n1 loglevel=8 \
+ earlycon=uart8250,mmio32,0x11002000 \
+ root=PARTLABEL=rootfs rootwait rootfstype=squashfs,f2fs \
+ block2mtd.block2mtd=/dev/mmcblk0p1,65536,log;/dev/mmcblk0p5,65536,custom";
+ };
+
+ reg_3p3v: regulator-3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ gl-hw {
+ compatible = "gl-hw-info";
+ model = "x3000";
+ wan = "eth0";
+ lan = "eth1";
+ build-in-modem = "0001:01:00.0";
+ pcie-bus = "0001:01:00.0";
+ usb-port = "1-1.3";
+ fan = "pwmchip0";
+ flash_size = <7456>;
+ temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp";
+ reset-button = "gpio-456";
+ radio = "mt798111 mt798112";
+ dfs;
+ factory_data {
+ device_mac = "/dev/mmcblk0boot1", "0x0a";
+ device_ddns = "/dev/mmcblk0boot1", "0x10";
+ device_sn_bak = "/dev/mmcblk0boot1", "0x20";
+ device_sn = "/dev/mmcblk0boot1", "0x30";
+ country_code = "/dev/mmcblk0boot1", "0x88";
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ reset {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ };
+
+ gpio-export {
+ compatible = "gpio-export";
+
+ usb_power {
+ gpio-export,name = "usb_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
+ };
+
+ hub_power {
+ gpio-export,name = "hub_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_power {
+ gpio-export,name = "5G_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_control {
+ gpio-export,name = "5G_control";
+ gpio-export,output = <1>;
+ gpios = <&pio 9 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_reset {
+ gpio-export,name = "5G_reset";
+ gpio-export,output = <1>;
+ gpios = <&pio 10 GPIO_ACTIVE_HIGH>;
+ };
+
+ thread_reset {
+ gpio-export,name = "thread_reset";
+ gpio-export,output = <1>;
+ gpios = <&pio 26 GPIO_ACTIVE_HIGH>;
+ };
+
+ fan_power {
+ gpio-export,name = "fan_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 28 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led@0 {
+ label = "wifi:2g";
+ gpios = <&pio 30 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@1 {
+ label = "wifi:5g";
+ gpios = <&pio 31 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@2 {
+ label = "5G:signal:led1";
+ gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@3 {
+ label = "5G:signal:led2";
+ gpios = <&pio 7 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@4 {
+ label = "5G:signal:led3";
+ gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@5 {
+ label = "5G:signal:led4";
+ gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
+ default-state = "off";
+ };
+
+ led@6 {
+ label = "power";
+ gpios = <&pio 39 GPIO_ACTIVE_LOW>;
+ default-state = "on";
+ };
+
+ led@7 {
+ label = "internet";
+ gpios = <&pio 38 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+ };
+
+ gl_fan {
+ compatible = "gl-fan";
+ interrupt-parent = <&pio>;
+ interrupts = <29 IRQ_TYPE_EDGE_RISING>;
+ };
+
+ pwm-fan {
+ compatible = "pwm-fan";
+ cooling-min-state = <0>;
+ cooling-max-state = <255>;
+ #cooling-cells = <2>;
+ pwms = <&pwm 0 40000 0>;
+ cooling-levels = <0 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 37 38 39
+ 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
+ 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
+ 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
+ 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
+ 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
+ 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
+ 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
+ 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
+ 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
+ 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255>;
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&watchdog {
+ status = "okay";
+};
+
+&mmc0 {
+ pinctrl-names = "default", "state_uhs";
+ pinctrl-0 = <&mmc0_pins_default>;
+ pinctrl-1 = <&mmc0_pins_uhs>;
+ bus-width = <8>;
+ max-frequency = <52000000>;
+ cap-mmc-highspeed;
+ vmmc-supply = <&reg_3p3v>;
+ non-removable;
+ status = "okay";
+};
+
+&eth {
+ status = "okay";
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+ phy-mode = "2500base-x";
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ gmac1: mac@1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+ phy-mode = "gmii";
+ phy-handle = <&phy0>;
+ };
+
+ mdio: mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ phy0: ethernet-phy@0 {
+ compatible = "ethernet-phy-id03a2.9461";
+ reg = <0>;
+ phy-mode = "gmii";
+ nvmem-cells = <&phy_calibration>;
+ nvmem-cell-names = "phy-cal-data";
+ };
+
+ phy5: phy@5 {
+ compatible = "ethernet-phy-id67c9.de0a";
+ reg = <5>;
+ reset-gpios = <&pio 14 1>;
+ reset-assert-us = <600>;
+ reset-deassert-us = <20000>;
+ };
+ };
+};
+
+&hnat {
+ mtketh-wan = "eth0";
+ mtketh-lan = "eth1";
+ mtketh-ppd = "eth1";
+ mtketh-max-gmac = <2>;
+ status = "okay";
+};
+
+&spi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spic_pins>;
+ status = "disabled";
+};
+
+&pio {
+ spic_pins: spi1-pins {
+ mux {
+ function = "spi";
+ groups = "spi1_1";
+ };
+ };
+ mmc0_pins_default: mmc0-pins-default {
+ mux {
+ function = "flash";
+ groups = "emmc";
+ };
+ };
+ mmc0_pins_uhs: mmc0-pins-uhs {
+ mux {
+ function = "flash";
+ groups = "emmc";
+ };
+ };
+ pcie_pins: pcie-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie_pereset", "pcie_clk", "pcie_wake";
+ };
+ };
+ pwm0_pin: pwm0-pin-g0 {
+ mux {
+ function = "pwm";
+ groups = "pwm0_1";
+ };
+ };
+};
+
+&xhci {
+ phys = <&u2port0 PHY_TYPE_USB2>;
+ status = "okay";
+};
+
+&pcie {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie_pins>;
+ status = "okay";
+};
+
+&pwm {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm0_pin>;
};
diff --git a/target/linux/mediatek/image/mt7981.mk b/target/linux/mediatek/image/mt7981.mk
index 043ac1f35e..7aa981e3d6 100755
--- a/target/linux/mediatek/image/mt7981.mk
+++ b/target/linux/mediatek/image/mt7981.mk
@@ -195,15 +195,8 @@ define Device/glinet_gl-x3000
DEVICE_MODEL := GL-X3000
DEVICE_DTS := mt7981-gl-x3000
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
- SUPPORTED_DEVICES := glinet,x3000-snand
- DEVICE_PACKAGES := kmod-hwmon-pwmfan
- UBINIZE_OPTS := -E 5
- BLOCKSIZE := 128k
- PAGESIZE := 2048
- IMAGE_SIZE := 65536k
- KERNEL_IN_UBI := 1
- IMAGES += factory.bin
- IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
+ SUPPORTED_DEVICES := glinet,x3000-emmc
+ DEVICE_PACKAGES := kmod-hwmon-pwmfan mkf2fs kmod-mmc kmod-fs-f2fs gdisk
IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata
endef
TARGET_DEVICES += glinet_gl-x3000
diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
new file mode 100755
index 0000000000..7e1f8bf8a4
--- /dev/null
+++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
@@ -0,0 +1,20 @@
+
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+board=$(board_name)
+
+case "$board" in
+glinet,x3000-emmc)
+ ucidef_set_led_netdev "wlan2g" "WLAN2G" "wifi:2g" "ra0"
+ ucidef_set_led_netdev "wlan5g" "WLAN5G" "wifi:5g" "rax0"
+ ucidef_set_led_netdev "wan" "WAN" "internet" "eth0"
+ ucidef_set_led_default "power" "POWER" "power" "1"
+ ;;
+esac
+
+board_config_flush
+
+exit 0
+
diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network
index fdb25296f4..fcb05fdf5d 100755
--- a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network
@@ -41,12 +41,12 @@ mediatek_setup_macs()
local wan_mac=""
case $board in
- *mt3000*|\
- *x3000*)
+ *mt3000*)
wan_mac=$(mtd_get_mac_binary $part_name 0x0a)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
- *mt2500*)
+ *mt2500*|\
+ *x3000*)
wan_mac=$(get_mac_binary /dev/mmcblk0boot1 0x0a)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
diff --git a/target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch b/target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch
new file mode 100644
index 0000000000..afa8309b2a
--- /dev/null
+++ b/target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch
@@ -0,0 +1,30 @@
+--- linux-origin/drivers/pinctrl/mediatek/pinctrl-mt7981.c 2022-12-02 16:58:14.809104549 +0800
++++ linux/drivers/pinctrl/mediatek/pinctrl-mt7981.c 2022-12-05 19:42:57.559519783 +0800
+@@ -668,6 +668,9 @@
+ static int mt7981_emmc_45_pins[] = { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
+ static int mt7981_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
+
++static int mt7981_emmc_pins[] = { 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
++static int mt7981_emmc_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
++
+ /* SNFI */
+ static int mt7981_snfi_pins[] = { 16, 17, 18, 19, 20, 21, };
+ static int mt7981_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, };
+@@ -813,6 +816,8 @@
+ PINCTRL_PIN_GROUP("drv_vbus", mt7981_drv_vbus),
+ /* @GPIO(15,25): EMMC(2) */
+ PINCTRL_PIN_GROUP("emmc_45", mt7981_emmc_45),
++ /* @GPIO(0.16,25): EMMC(2) */
++ PINCTRL_PIN_GROUP("emmc", mt7981_emmc),
+ /* @GPIO(16,21): SNFI(3) */
+ PINCTRL_PIN_GROUP("snfi", mt7981_snfi),
+ /* @GPIO(16,19): SPI0(1) */
+@@ -910,7 +915,7 @@
+ static const char *mt7981_pcm_groups[] = { "pcm", };
+ static const char *mt7981_udi_groups[] = { "udi", };
+ static const char *mt7981_usb_groups[] = { "drv_vbus", };
+-static const char *mt7981_flash_groups[] = { "emmc_45", "snfi", };
++static const char *mt7981_flash_groups[] = { "emmc_45", "emmc", "snfi", };
+ static const char *mt7981_ethernet_groups[] = { "smi_mdc_mdio", "gbe_ext_mdc_mdio",
+ "wf0_mode1", "wf0_mode3", "mt7531_int", };
+ static const char *mt7981_ant_groups[] = { "ant_sel", };
--
2.17.1