[openwrt/openwrt] mediatek: add support for ipTIME A6004MX Add basic support for ipTIME A6004MX.

LEDE Commits lede-commits at lists.infradead.org
Sun Sep 11 17:48:35 PDT 2022


dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/c27279dc26a26b8ad054882d4c5f86a85526fd16

commit c27279dc26a26b8ad054882d4c5f86a85526fd16
Author: Yoonji Park <koreapyj at dcmys.kr>
AuthorDate: Mon Jun 6 07:44:48 2022 +0000

    mediatek: add support for ipTIME A6004MX Add basic support for ipTIME A6004MX.
    
    Hardware:
    SoC: MediaTek MT7629 Cortex-A7 (ARMv7 1.25GHz, Dual-Core)
    RAM: DDR3 128MB
    Flash: Macronix MX35LF1GE4AB (SPI-NAND 128MB)
    WiFi: MediaTek MT7761N (2.4GHz) / MediaTek MT7762N (5GHz) - no driver
    Ethernet: SoC (WAN) / MediaTek MT7531 (LAN x4)
    UART: [GND, RX, TX, 3.3V] (115200)
    
    Installation:
    - Flash recovery image with TFTP recovery
    
    Revert to stock firmware:
    - Flash stock firmware with TFTP recovery
    
    TFTP Recovery method:
    1. Unplug the router
    2. Hold the reset button and plug in
    3. Release when the power LED stops flashing and go off
    4. Set your computer IP address manually to 192.168.0.x / 255.255.255.0
    5. Flash image with TFTP client to 192.168.0.1
    
    Signed-off-by: Yoonji Park <koreapyj at dcmys.kr>
---
 package/boot/uboot-envtools/files/mediatek_mt7629  |  23 ++
 .../linux/mediatek/dts/mt7629-iptime-a6004mx.dts   | 294 +++++++++++++++++++++
 target/linux/mediatek/image/mt7629.mk              |  17 ++
 .../mediatek/mt7629/base-files/etc/board.d/01_leds |  16 ++
 .../mt7629/base-files/etc/board.d/02_network       |   3 +
 .../mt7629/base-files/etc/init.d/bootcount         |  17 ++
 .../mt7629/base-files/lib/upgrade/platform.sh      |   3 +
 target/linux/mediatek/mt7629/config-5.15           |   6 +
 .../901-arm-add-cmdline-override.patch             |  37 +++
 9 files changed, 416 insertions(+)

diff --git a/package/boot/uboot-envtools/files/mediatek_mt7629 b/package/boot/uboot-envtools/files/mediatek_mt7629
new file mode 100644
index 0000000000..a5aa2b58a6
--- /dev/null
+++ b/package/boot/uboot-envtools/files/mediatek_mt7629
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2021 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(board_name)
+
+case "$board" in
+iptime,a6004mx)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000"
+	;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts b/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts
new file mode 100644
index 0000000000..b40ac52848
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts
@@ -0,0 +1,294 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include "mt7629.dtsi"
+
+/ {
+	model = "ipTIME A6004MX";
+	compatible = "iptime,a6004mx", "mediatek,mt7629";
+
+	aliases {
+		led-boot = &led_cpu;
+		led-failsafe = &led_cpu;
+		led-running = &led_cpu;
+		led-upgrade = &led_cpu;
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+		bootargs-override = "console=ttyS0,115200n8";
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led_cpu: cpu {
+			label = "orange:cpu";
+			gpios = <&pio 57 GPIO_ACTIVE_LOW>;
+		};
+
+		wlan5g {
+			label = "orange:wlan5g";
+			gpios = <&pio 22 GPIO_ACTIVE_LOW>;
+			// linux,default-trigger = "phy0radio";
+		};
+
+		wlan2g {
+			label = "orange:wlan2g";
+			gpios = <&pio 21 GPIO_ACTIVE_LOW>;
+			// linux,default-trigger = "phy1radio";
+		};
+
+		wan {
+			label = "orange:wan";
+			gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "factory";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 60 GPIO_ACTIVE_LOW>;
+		};
+
+		wps {
+			label = "wps";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&pio 58 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	memory at 40000000 {
+		device_type = "memory";
+		reg = <0x40000000 0x10000000>;
+	};
+
+	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;
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-boot-on;
+		regulator-always-on;
+	};
+};
+
+&eth {
+	pinctrl-names = "default";
+	pinctrl-0 = <&eth_pins>;
+	pinctrl-1 = <&ephy_leds_pins>;
+	status = "okay";
+
+	gmac0: mac at 0 {
+		compatible = "mediatek,eth-mac";
+		reg = <0>;
+		phy-mode = "2500base-x";
+		nvmem-cells = <&macaddr_factory_4>;
+		nvmem-cell-names = "mac-address";
+		mac-address-increment = <3>;
+
+		fixed-link {
+			speed = <2500>;
+			full-duplex;
+			pause;
+		};
+	};
+
+	gmac1: mac at 1 {
+		compatible = "mediatek,eth-mac";
+		reg = <1>;
+		phy-mode = "gmii";
+		phy-handle = <&phy0>;
+		nvmem-cells = <&macaddr_factory_4>;
+		nvmem-cell-names = "mac-address";
+		mac-address-increment = <1>;
+	};
+
+	mdio: mdio-bus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		phy0: ethernet-phy at 0 {
+			reg = <0>;
+		};
+
+		switch at 2 {
+			compatible = "mediatek,mt7531";
+			reg = <2>;
+			reset-gpios = <&pio 28 0>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			interrupt-parent = <&pio>;
+			interrupts = <6 IRQ_TYPE_LEVEL_HIGH>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port at 0 {
+					reg = <0>;
+					label = "lan1";
+				};
+
+				port at 1 {
+					reg = <1>;
+					label = "lan2";
+				};
+
+				port at 2 {
+					reg = <2>;
+					label = "lan3";
+				};
+
+				port at 3 {
+					reg = <3>;
+					label = "lan4";
+				};
+
+				port at 6 {
+					reg = <6>;
+					label = "cpu";
+					ethernet = <&gmac0>;
+					phy-mode = "2500base-x";
+
+					fixed-link {
+						speed = <2500>;
+						full-duplex;
+						pause;
+					};
+				};
+			};
+		};
+	};
+};
+
+&bch {
+	status = "okay";
+};
+
+&snfi {
+	pinctrl-names = "default";
+	pinctrl-0 = <&serial_nand_pins>;
+	status = "okay";
+	flash at 0 {
+		compatible = "spi-nand";
+		reg = <0>;
+		spi-tx-bus-width = <4>;
+		spi-rx-bus-width = <4>;
+		nand-ecc-engine = <&snfi>;
+		mediatek,bmt-v2;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "Bootloader";
+				reg = <0x0 0x100000>;
+				read-only;
+			};
+
+			partition at 100000 {
+				label = "Config";
+				reg = <0x100000 0x40000>;
+			};
+
+			partition at 140000 {
+				label = "factory";
+				reg = <0x140000 0x80000>;
+				read-only;
+
+				compatible = "nvmem-cells";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				macaddr_factory_4: macaddr at 4 {
+					reg = <0x4 0x6>;
+				};
+			};
+
+			partition at 1c0000 {
+				label = "firmware";
+				reg = <0x1c0000 0x7400000>;
+				compatible = "denx,fit";
+				openwrt,fit-offset = <0x800>;
+			};
+		};
+	};
+};
+
+&pio {
+	eth_pins: eth-pins {
+		mux {
+			function = "eth";
+			groups = "mdc_mdio";
+		};
+	};
+
+	ephy_leds_pins: ephy-leds-pins {
+		mux {
+			function = "led";
+			groups = "ephy_leds";
+		};
+	};
+
+	/* Serial NAND is shared pin with SPI-NOR */
+	serial_nand_pins: serial-nand-pins {
+		mux {
+			function = "flash";
+			groups = "snfi";
+		};
+	};
+
+	uart0_pins: uart0-pins {
+		mux {
+			function = "uart";
+			groups = "uart0_txd_rxd" ;
+		};
+	};
+
+	watchdog_pins: watchdog-pins {
+		mux {
+			function = "watchdog";
+			groups = "watchdog";
+		};
+	};
+};
+
+&ssusb {
+	vusb33-supply = <&reg_3p3v>;
+	vbus-supply = <&reg_5v>;
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins>;
+	status = "okay";
+};
+
+&watchdog {
+	pinctrl-names = "default";
+	pinctrl-0 = <&watchdog_pins>;
+	status = "okay";
+
+	interrupt-controller;
+	#interrupt-cells = <1>;
+	interrupt-parent = <&pio>;
+	interrupts = <GIC_SPI 0x80 IRQ_TYPE_EDGE_FALLING>;
+};
diff --git a/target/linux/mediatek/image/mt7629.mk b/target/linux/mediatek/image/mt7629.mk
index 754ce974b1..891b65c4e7 100644
--- a/target/linux/mediatek/image/mt7629.mk
+++ b/target/linux/mediatek/image/mt7629.mk
@@ -7,3 +7,20 @@ define Device/mediatek_mt7629-rfb
   DEVICE_PACKAGES := swconfig
 endef
 TARGET_DEVICES += mediatek_mt7629-rfb
+
+define Device/iptime_a6004mx
+  DEVICE_VENDOR := ipTIME
+  DEVICE_MODEL := A6004MX
+  DEVICE_DTS := mt7629-iptime-a6004mx
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_PACKAGES := kmod-usb3 uboot-envtools
+  UBINIZE_OPTS := -E 5
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  KERNEL := $$(KERNEL) | pad-offset 128k 2048 | iptime-crc32 a6004mx
+  KERNEL_INITRAMFS := $$(KERNEL_INITRAMFS) | pad-offset 128k 2048 | iptime-crc32 a6004mx
+  IMAGES += recovery.bin
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+  IMAGE/recovery.bin := append-kernel | pad-to 128k | append-ubi | append-metadata
+endef
+TARGET_DEVICES += iptime_a6004mx
diff --git a/target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds
new file mode 100644
index 0000000000..42b6fcbbb3
--- /dev/null
+++ b/target/linux/mediatek/mt7629/base-files/etc/board.d/01_leds
@@ -0,0 +1,16 @@
+. /lib/functions/leds.sh
+. /lib/functions/uci-defaults.sh
+
+board=$(board_name)
+
+board_config_update
+
+case $board in
+iptime,a6004mx)
+	ucidef_set_led_netdev "wan" "WAN" "orange:wan" "eth1"
+	;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network
index c39417abbc..4254f39ca0 100644
--- a/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7629/base-files/etc/board.d/02_network
@@ -8,6 +8,9 @@ mediatek_setup_interfaces()
 	local board="$1"
 
 	case $board in
+	iptime,a6004mx)
+		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth1"
+		;;
 	mediatek,mt7629-rfb)
 		ucidef_set_interface_wan "eth1"
 		ucidef_add_switch "switch0" \
diff --git a/target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount b/target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount
new file mode 100755
index 0000000000..a6b8fac1d9
--- /dev/null
+++ b/target/linux/mediatek/mt7629/base-files/etc/init.d/bootcount
@@ -0,0 +1,17 @@
+#!/bin/sh /etc/rc.common
+# SPDX-License-Identifier: GPL-2.0-only
+
+START=99
+
+boot() {
+	case $(board_name) in
+	iptime,a6004mx)
+		if [ `fw_printenv boot_sector` = "boot_sector=B" ]; then
+			echo "bootcount: boot_sector must be A. Rebooting..."
+			fw_setenv boot_sector A
+			reboot
+			exit 1
+		fi
+		;;
+	esac
+}
diff --git a/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh
index 9a613c43b1..f10ad14b49 100755
--- a/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7629/base-files/lib/upgrade/platform.sh
@@ -9,6 +9,9 @@ platform_do_upgrade() {
 	local board=$(board_name)
 
 	case "$board" in
+	iptime,a6004mx)
+		nand_do_upgrade "$1"
+		;;
 	*)
 		default_do_upgrade "$1"
 		;;
diff --git a/target/linux/mediatek/mt7629/config-5.15 b/target/linux/mediatek/mt7629/config-5.15
index 010151d4b3..39596717ae 100644
--- a/target/linux/mediatek/mt7629/config-5.15
+++ b/target/linux/mediatek/mt7629/config-5.15
@@ -44,6 +44,7 @@ CONFIG_CLKSRC_MMIO=y
 CONFIG_CLONE_BACKWARDS=y
 CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
 CONFIG_CMDLINE_FROM_BOOTLOADER=y
+CONFIG_CMDLINE_OVERRIDE=y
 CONFIG_COMMON_CLK=y
 CONFIG_COMMON_CLK_MEDIATEK=y
 # CONFIG_COMMON_CLK_MT2701 is not set
@@ -195,11 +196,16 @@ CONFIG_MTK_TIMER=y
 CONFIG_MUTEX_SPIN_ON_OWNER=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NETFILTER=y
+CONFIG_NET_DEVLINK=y
+CONFIG_NET_DSA=y
+CONFIG_NET_DSA_MT7530=y
+CONFIG_NET_DSA_TAG_MTK=y
 CONFIG_NET_FLOW_LIMIT=y
 CONFIG_NET_MEDIATEK_SOC=y
 CONFIG_NET_MEDIATEK_SOC_WED=y
 CONFIG_NET_SELFTESTS=y
 CONFIG_NET_SOCK_MSG=y
+CONFIG_NET_SWITCHDEV=y
 CONFIG_NET_VENDOR_MEDIATEK=y
 CONFIG_NLS=y
 CONFIG_NO_HZ_COMMON=y
diff --git a/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch b/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch
new file mode 100644
index 0000000000..a11219d353
--- /dev/null
+++ b/target/linux/mediatek/patches-5.15/901-arm-add-cmdline-override.patch
@@ -0,0 +1,37 @@
+--- a/arch/arm/Kconfig
++++ b/arch/arm/Kconfig
+@@ -1794,6 +1794,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGL
+ 
+ endchoice
+ 
++config CMDLINE_OVERRIDE
++	bool "Use alternative cmdline from device tree"
++	help
++	  Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
++	  be used, this is not a good option for kernels that are shared across
++	  devices. This setting enables using "chosen/cmdline-override" as the
++	  cmdline if it exists in the device tree.
++
+ config CMDLINE
+ 	string "Default kernel command string"
+ 	default ""
+--- a/drivers/of/fdt.c
++++ b/drivers/of/fdt.c
+@@ -1059,6 +1059,17 @@ int __init early_init_dt_scan_chosen(uns
+ 	if (p != NULL && l > 0)
+ 		strlcat(data, p, min_t(int, strlen(data) + (int)l, COMMAND_LINE_SIZE));
+ 
++	/* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
++	 * device tree option of chosen/bootargs-override. This is
++	 * helpful on boards where u-boot sets bootargs, and is unable
++	 * to be modified.
++	 */
++#ifdef CONFIG_CMDLINE_OVERRIDE
++	p = of_get_flat_dt_prop(node, "bootargs-override", &l);
++	if (p != NULL && l > 0)
++		strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
++#endif
++
+ 	/*
+ 	 * CONFIG_CMDLINE is meant to be a default in case nothing else
+ 	 * managed to set the command line, unless CONFIG_CMDLINE_FORCE




More information about the lede-commits mailing list