[openwrt/openwrt] mediatek: add support for BananaPi BPi-R4 Lite

LEDE Commits lede-commits at lists.infradead.org
Wed Nov 5 06:23:11 PST 2025


dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/8b6c6978d6d301270052bdf544bd58901ff24a70

commit 8b6c6978d6d301270052bdf544bd58901ff24a70
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Sun Oct 5 04:23:29 2025 +0100

    mediatek: add support for BananaPi BPi-R4 Lite
    
    The BPi-R4 Lite is a WiFi-7 router board based on the MT7987 SoC.
    
    Specification :
     - SOC: Mediatek MT7987A (4x Cortex-A53
     - RAM: 2GB
     - Flash: 32MB SPI NOR, 256MB SPI NAND, 8GB eMMC
     - Switch: MediaTek MT7531AE
     - Ports : 4x LAN (1G), 1x SFP (via MT7531), 1x WAN (2.5G)
     - Buttons : Reset & WPS/Mesh
     - LEDs : Status (PWM), SFP
     - USB: on-board VIA VL817 USB3.1/USB2.0 hub
        * 1 - mPCIe B (SIM3)
        * 2 - NGFF-KEYB (SIM1)
        * 3 - USB-A connector
        * 4 - mPCIe A (SIM4)
     - mPCIe: 1x 8GT/s x2 or 2x 8GT/s x1 (configurable via bootloader)
     - RTC: PCF8563
     - mikroBUS socket with SPI, I2C and full UART
     - on-board HT42B534 USB-to-serial for Type-C console port
     - Power: USB Type-C PD 20V, or DC via barrel connector or JST-VH 3.96
    
    Installation:
    Uncompress *sdcard.img.gz and write to microSD card, eg. using 'dd'.
    Use bootloader menu on the serial console to install SPI-NAND or SPI-NOR,
    once installed to SPI-NAND you can use the bootloader menu to install to
    eMMC. See instructions for BananaPi R3 for details.
    
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 .../etc/uci-defaults/99_fwenv-store-ethaddr.sh     |   1 +
 .../dts/mt7987a-bananapi-bpi-r4-lite-1pcie-2L.dtso |  35 +++
 .../dts/mt7987a-bananapi-bpi-r4-lite-2pcie-1L.dtso |  36 +++
 .../dts/mt7987a-bananapi-bpi-r4-lite-emmc.dtso     |  54 ++++
 .../dts/mt7987a-bananapi-bpi-r4-lite-mikrobus.dtsi | 134 +++++++++
 .../dts/mt7987a-bananapi-bpi-r4-lite-nand.dtso     |  61 ++++
 .../dts/mt7987a-bananapi-bpi-r4-lite-nor.dtso      |  63 ++++
 .../dts/mt7987a-bananapi-bpi-r4-lite-sd.dtso       |  53 ++++
 .../mediatek/dts/mt7987a-bananapi-bpi-r4-lite.dts  | 321 +++++++++++++++++++++
 .../filogic/base-files/etc/board.d/01_leds         |   3 +
 .../filogic/base-files/etc/board.d/02_network      |   3 +
 .../filogic/base-files/lib/upgrade/platform.sh     |   3 +
 target/linux/mediatek/image/filogic.mk             |  61 ++++
 13 files changed, 828 insertions(+)

diff --git a/target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh b/target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh
index 1a9ddc679d..593cd10add 100644
--- a/target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh
+++ b/target/linux/mediatek/base-files/etc/uci-defaults/99_fwenv-store-ethaddr.sh
@@ -13,6 +13,7 @@ bananapi,bpi-r3|\
 bananapi,bpi-r3-mini|\
 bananapi,bpi-r4|\
 bananapi,bpi-r4-2g5|\
+bananapi,bpi-r4-lite|\
 bananapi,bpi-r4-poe)
 	[ -z "$(fw_printenv -n ethaddr 2>/dev/null)" ] &&
 		fw_setenv ethaddr "$(cat /sys/class/net/eth0/address)"
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-1pcie-2L.dtso b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-1pcie-2L.dtso
new file mode 100644
index 0000000000..abeca35a42
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-1pcie-2L.dtso
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2025 MediaTek Inc.
+ * Author: Sam.Shih <sam.shih at mediatek.com>
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+};
+
+/ {
+	fragment at 0 {
+		target-path = "/soc/pinctrl at 1001f000";
+		__overlay__ {
+			pcie_sel: aw35710qnr_sel {
+				gpio-hog;
+				gpios = <11 GPIO_ACTIVE_HIGH>;
+				output-high;
+			};
+		};
+	};
+
+	fragment at 1 {
+		target-path = "/soc/pcie at 11290000";
+		__overlay__ {
+			status = "disabled";
+		};
+	};
+};
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-2pcie-1L.dtso b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-2pcie-1L.dtso
new file mode 100644
index 0000000000..177e4c2b76
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-2pcie-1L.dtso
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2025 MediaTek Inc.
+ * Author: Sam.Shih <sam.shih at mediatek.com>
+ */
+
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+};
+
+/ {
+	fragment at 0 {
+		target-path = "/soc/pinctrl at 1001f000";
+		__overlay__ {
+			pcie_sel: aw35710qnr_sel {
+				gpio-hog;
+				gpios = <11 GPIO_ACTIVE_HIGH>;
+				output-low;
+			};
+		};
+	};
+
+	fragment at 1 {
+		target-path = "/soc/pcie at 11290000";
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
+
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-emmc.dtso b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-emmc.dtso
new file mode 100644
index 0000000000..0174de0d1f
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-emmc.dtso
@@ -0,0 +1,54 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+};
+
+&{/soc/mmc at 11230000} {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc_pins_default>;
+	pinctrl-1 = <&mmc_pins_uhs>;
+	reset-gpios = <&pio 14 GPIO_ACTIVE_LOW>;
+
+	bus-width = <4>; /* interference from shared DAT5<->SD-CD pin */
+	max-frequency = <48000000>;
+	cap-mmc-highspeed;
+	non-removable;
+	no-sd;
+	no-sdio;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_3p3v>;
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	status = "okay";
+
+	card at 0 {
+		compatible = "mmc-card";
+		reg = <0>;
+
+		partitions {
+			compatible = "gpt-partitions";
+
+			block-partition-env {
+				partname = "ubootenv";
+				nvmem-layout {
+					compatible = "u-boot,env-layout";
+				};
+			};
+
+			emmc_rootfs: block-partition-production {
+				partname = "production";
+			};
+		};
+	};
+};
+
+&{/chosen} {
+	rootdisk-emmc = <&emmc_rootfs>;
+};
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-mikrobus.dtsi b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-mikrobus.dtsi
new file mode 100644
index 0000000000..5a2b86d5b0
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-mikrobus.dtsi
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2025 MediaTek Inc.
+ * Author: Sam.Shih <sam.shih at mediatek.com>
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+
+/*
+ * --------------- Bananapi Bpi R4 Lite MikroBus ----------------
+ * | 9  |                           GPIO7/PWM1              | 8 |
+ * | 10 | GPIO6/PCM_FS/UART1_RTS    GPIO5/PCM_CLK/UART1_CTS | 7 |
+ * | 11 | GPIO49/SPI1_CS            GPIO3/PCM_DTX/UART1_RXD | 6 |
+ * | 12 | GPIO46/SPI1_CLK           GPIO4/PCM_DRX/UART1_TXD | 5 |
+ * | 13 | GPIO48/SPI1_MISO          I2C3 SCL (PCA9548)      | 4 |
+ * | 14 | GPIO47/SPI1_MOSI          I2C3 SDA (PCA9548)      | 3 |
+ * | 15 | +3.3V                     +5V                     | 2 |
+ * | 16 | GND                       GND                     | 1 |
+ * --------------------------------------------------------------
+ */
+
+/ {
+	mikrobus: MikroBus {
+		compatible = "simple-bus";
+
+		/* MikroBus pins 5,6,7,8 as GPIOs */
+		mikrobus_gpios_0: gpio-export at 0 {
+			compatible = "gpio-export";
+			status = "disabled";
+
+			gpio-3 {
+				gpio-export,name = "mikrobus-gpio-RX";
+				gpio-export,output = <1>;
+				gpios = <&pio 3 GPIO_ACTIVE_HIGH>;
+			};
+
+			gpio-4 {
+				gpio-export,name = "mikrobus-gpio-TX";
+				gpio-export,output = <1>;
+				gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
+			};
+
+			gpio-5 {
+				gpio-export,name = "mikrobus-gpio-INT";
+				gpio-export,output = <1>;
+				gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+			};
+
+			gpio-6 {
+				gpio-export,name = "mikrobus-gpio-INT";
+				gpio-export,output = <1>;
+				gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+			};
+		};
+
+		/* MikroBus pins 11,12,13,14 as GPIOs */
+		mikrobus_gpios_1: gpio-export at 1 {
+			compatible = "gpio-export";
+			status = "disabled";
+
+			gpio-46 {
+				gpio-export,name = "mikrobus-gpio-CS";
+				gpio-export,output = <1>;
+				gpios = <&pio 46 GPIO_ACTIVE_HIGH>;
+			};
+
+			gpio-47 {
+				gpio-export,name = "mikrobus-gpio-MOSI";
+				gpio-export,output = <1>;
+				gpios = <&pio 47 GPIO_ACTIVE_HIGH>;
+			};
+
+			gpio-48 {
+				gpio-export,name = "mikrobus-gpio-MISO";
+				gpio-export,output = <1>;
+				gpios = <&pio 48 GPIO_ACTIVE_HIGH>;
+			};
+
+			gpio-49 {
+				gpio-export,name = "mikrobus-gpio-SCK";
+				gpio-export,output = <1>;
+				gpios = <&pio 49 GPIO_ACTIVE_HIGH>;
+			};
+		};
+	};
+};
+
+/* MikroBus pins 3,4 as I2C3 (Provided by PCA9548 i2c-mux) */
+/* Please refer to &imux2_MikroBus device tree node */
+
+/* MikroBus pins 5,6,7,10 as PCM function */
+&afe {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcm_pins>;
+	status = "disabled";
+};
+
+&pcm_pins {
+	mux {
+		function = "pcm";
+		groups = "pcm0_0";
+	};
+};
+
+/* MikroBus pins 5,6,7,10 as UART1 function */
+&uart1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart1_pins>;
+	status = "okay";
+};
+
+&uart1_pins {
+	mux {
+		function = "uart";
+		groups = "uart1_0";
+	};
+};
+
+/* MikroBus pins 8 as PWM1 */
+/* Please refer to &pwm device tree node */
+
+/* MikroBus pins 11,12,13,14 as SPI1 function */
+&spi1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spic_pins>;
+	status = "okay";
+};
+
+&spic_pins {
+	mux {
+		function = "spi";
+		groups = "spi1_1";
+	};
+};
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-nand.dtso b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-nand.dtso
new file mode 100644
index 0000000000..b56e0d4706
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-nand.dtso
@@ -0,0 +1,61 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+};
+
+&{/soc/spi at 11009800} {
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	flash at 0 {
+		compatible = "spi-nand";
+		reg = <0>;
+		spi-max-frequency = <52000000>;
+		spi-rx-bus-width = <4>;
+		spi-tx-bus-width = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "bl2-nand";
+				reg = <0x0 0x200000>;
+			};
+
+			partition at 200000 {
+				label = "ubi";
+				reg = <0x200000 0xfe00000>;
+				compatible = "linux,ubi";
+
+				volumes {
+					ubi-volume-ubootenv {
+						volname = "ubootenv";
+						nvmem-layout {
+							compatible = "u-boot,env-redundant-bool-layout";
+						};
+					};
+
+					ubi-volume-ubootenv2 {
+						volname = "ubootenv2";
+						nvmem-layout {
+							compatible = "u-boot,env-redundant-bool-layout";
+						};
+					};
+
+					ubi_rootfs: ubi-volume-fit {
+						volname = "fit";
+					};
+				};
+			};
+		};
+	};
+};
+
+&{/chosen} {
+	rootdisk-spim-nand = <&ubi_rootfs>;
+};
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-nor.dtso b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-nor.dtso
new file mode 100644
index 0000000000..2434bb7ce7
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-nor.dtso
@@ -0,0 +1,63 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+};
+
+&{/soc/spi at 11009800} {
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <52000000>;
+		spi-rx-bus-width = <4>;
+		spi-tx-bus-width = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "bl2-nor";
+				reg = <0x0 0x40000>;
+				read-only;
+			};
+
+			partition at 40000 {
+				label = "u-boot-env";
+				reg = <0x40000 0x40000>;
+			};
+
+			partition at 50000 {
+				label = "factory";
+				reg = <0x80000 0x80000>;
+				read-only;
+			};
+
+			partition at 100000 {
+				label = "fip";
+				reg = <0x100000 0x80000>;
+			};
+
+			partition at 180000 {
+				label = "recovery";
+				reg = <0x180000 0xe80000>;
+			};
+
+			nor_rootfs: partition at 1000000 {
+				label = "fit";
+				reg = <0x1000000 0x1000000>;
+				compatible = "denx,fit";
+			};
+		};
+	};
+};
+
+&{/chosen} {
+	rootdisk-nor = <&nor_rootfs>;
+};
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-sd.dtso b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-sd.dtso
new file mode 100644
index 0000000000..5abbf14c37
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite-sd.dtso
@@ -0,0 +1,53 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+};
+
+&{/soc/mmc at 11230000} {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&sd_pins_default>;
+	pinctrl-1 = <&sd_pins_uhs>;
+	cd-gpios = <&pio 20 GPIO_ACTIVE_LOW>;
+
+	bus-width = <4>;
+	max-frequency = <48000000>;
+	cap-sd-highspeed;
+	no-mmc;
+	no-sdio;
+	vmmc-supply = <&reg_3p3v>;
+	vqmmc-supply = <&reg_3p3v>;
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	status = "okay";
+
+	card at 0 {
+		compatible = "mmc-card";
+		reg = <0>;
+
+		partitions {
+			compatible = "gpt-partitions";
+
+			block-partition-env {
+				partname = "ubootenv";
+				nvmem-layout {
+					compatible = "u-boot,env-layout";
+				};
+			};
+
+			sd_rootfs: block-partition-production {
+				partname = "production";
+			};
+		};
+	};
+};
+
+&{/chosen} {
+	rootdisk-sd = <&sd_rootfs>;
+};
diff --git a/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite.dts b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite.dts
new file mode 100644
index 0000000000..a6765a8b77
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7987a-bananapi-bpi-r4-lite.dts
@@ -0,0 +1,321 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2025 MediaTek Inc.
+ * Author: Sam.Shih <sam.shih at mediatek.com>
+ */
+
+/dts-v1/;
+#include "mt7987a.dtsi"
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+#include "mt7987a-bananapi-bpi-r4-lite-mikrobus.dtsi"
+
+/ {
+	model = "Bananapi BPI-R4-LITE";
+	compatible = "bananapi,bpi-r4-lite",
+		     "mediatek,mt7987a", "mediatek,mt7987";
+
+	aliases {
+		/* mt7987 I2C0 */
+		i2c0 = &i2c0;
+		/* PCA9548 (0-0070) provides 4 i2c channels */
+		i2c1 = &imux0_rtc;
+		i2c2 = &imux1_sfp;
+		i2c3 = &imux2_MikroBus;
+		i2c4 = &imux3;
+		led-boot = &sys_led_blue;
+		led-failsafe = &sys_led_blue;
+		led-running = &sys_led_blue;
+		led-upgrade = &sys_led_blue;
+		serial0 = &uart0;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11000000 \
+			    ubi.block=0,firmware root=/dev/fit0 rootwait";
+		stdout-path = "serial0:115200n8";
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+			debounce-interval = <10>;
+		};
+
+		wps {
+			label = "wps";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+			debounce-interval = <10>;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		sfp-led {
+			gpios = <&pca9555 11 GPIO_ACTIVE_LOW>;
+			function = "sfp";
+			color = <LED_COLOR_ID_GREEN>;
+		};
+	};
+
+	pwm-leds {
+		compatible = "pwm-leds";
+		status = "okay";
+
+		/* ACT LED on bpi-r4-lite */
+		sys_led_blue: sys-led {
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_STATUS;
+			pwms = <&pwm 0 50000>;
+			max-brightness = <255>;
+			active-high;
+			linux,default-trigger = "default-on";
+		};
+	};
+
+	sfp: sfp at 0 {
+		compatible = "sff,sfp";
+		i2c-bus = <&imux1_sfp>;
+		los-gpios = <&pio 10 GPIO_ACTIVE_HIGH>;
+		mod-def0-gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+		tx-disable-gpios = <&pio 8 GPIO_ACTIVE_HIGH>;
+		tx-fault-gpios = <&pca9555 12 GPIO_ACTIVE_HIGH>;
+		rate-select0-gpios = <&pca9555 13 GPIO_ACTIVE_HIGH>;
+		rate-select1-gpios = <&pca9555 14 GPIO_ACTIVE_HIGH>;
+		maximum-power-milliwatt = <3000>;
+	};
+
+	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_usb_5v: regulator-usb-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "usb-5v";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&pca9555 9 GPIO_ACTIVE_HIGH>;
+	};
+
+	usb-vbus-regulator {
+		compatible = "regulator-output";
+		vout-supply = <&reg_usb_5v>;
+	};
+};
+
+&fan {
+	pwms = <&pwm 2 50000>;
+	status = "okay";
+};
+
+&gmac0 {
+	phy-mode = "2500base-x";
+	status = "okay";
+	fixed-link {
+		speed = <2500>;
+		full-duplex;
+		pause;
+	};
+};
+
+&gmac1 {
+	phy-mode = "internal";
+	phy-handle = <&phy15>;
+	status = "okay";
+};
+
+&pwm {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pwm_pins>;
+	status = "okay";
+};
+
+&pwm_pins {
+	mux {
+		/*
+		 * - pwm0   : PWM0 at PIN13
+		 * - pwm1_0 : PWM at PIN7  (share with JTAG)
+		 * - pwm2_0 : PWM2 at PIN12 (share with PCM)
+		 */
+		function = "pwm";
+		groups = "pwm0", "pwm1_0", "pwm2_0";
+	};
+};
+
+&i2c0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c0_pins>;
+	status = "okay";
+
+	pca9545 at 70 {
+		compatible = "nxp,pca9545";
+		reg = <0x70>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		imux0_rtc: i2c at 0 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x0>;
+
+			rtc at 51 {
+				compatible = "nxp,pcf8563";
+				reg = <0x51>;
+			};
+
+			eeprom at 57 {
+				compatible = "atmel,24c02";
+				reg = <0x57>;
+				address-bits = <8>;
+				page-size = <8>;
+				size = <256>;
+			};
+		};
+
+		imux1_sfp: i2c at 1 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x1>;
+		};
+
+		imux2_MikroBus: i2c at 2 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x2>;
+		};
+
+		imux3: i2c at 3 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x3>;
+
+			pca9555: i2c-gpio-expander at 20 {
+				compatible = "nxp,pca9555";
+				interrupt-controller;
+				interrupt-parent = <&pio>;
+				interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				reg = <0x20>;
+			};
+
+			wifi_eeprom at 50 {
+				compatible = "atmel,24c02";
+				reg = <0x50>;
+				wp-gpios = <&pca9555 10 GPIO_ACTIVE_LOW>;
+				address-bits = <8>;
+				page-size = <8>;
+				size = <256>;
+			};
+		};
+	};
+};
+
+&mdio {
+	/* built-in 2.5G Ethernet PHY */
+	phy15: phy at 15 {
+		pinctrl-names = "i2p5gbe-led";
+		pinctrl-0 = <&i2p5gbe_led0_pins>;
+		compatible = "ethernet-phy-ieee802.3-c45";
+		reg = <15>;
+		phy-mode = "internal";
+	};
+
+	switch31: switch at 31 {
+		compatible = "mediatek,mt7531";
+		reg = <31>;
+		reset-gpios = <&pio 42 GPIO_ACTIVE_HIGH>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		interrupt-parent = <&pio>;
+		interrupts = <41 IRQ_TYPE_LEVEL_HIGH>;
+		status = "okay";
+	};
+};
+
+&ssusb {
+	mediatek,u3p-dis-msk=<0>;
+	phys = <&tphyu2port0 PHY_TYPE_USB2>,
+	       <&tphyu3port0 PHY_TYPE_USB3>;
+
+	/*
+	 * VIA VL817 USB3.1/USB2.0 hub
+	 * ports:
+	 * 1 - mPCIe B (SIM3)
+	 * 2 - NGFF-KEYB (SIM1)
+	 * 3 - USB-A connector
+	 * 4 - mPCIe A (SIM4)
+	 */
+
+	// reset-gpios = <&pca9555 8 GPIO_ACTIVE_HIGH>;
+};
+
+&switch31 {
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port at 0 {
+			reg = <0>;
+			label = "lan0";
+		};
+
+		port at 1 {
+			reg = <1>;
+			label = "lan1";
+		};
+
+		port at 2 {
+			reg = <2>;
+			label = "lan2";
+		};
+
+		port at 3 {
+			reg = <3>;
+			label = "lan3";
+		};
+
+		port at 5 {
+			reg = <5>;
+			label = "sfp0";
+			phy-mode = "2500base-x";
+			sfp = <&sfp>;
+			managed = "in-band-status";
+		};
+
+		port at 6 {
+			reg = <6>;
+			label = "cpu";
+			ethernet = <&gmac0>;
+			phy-mode = "2500base-x";
+
+			fixed-link {
+				speed = <2500>;
+				full-duplex;
+				pause;
+			};
+		};
+	};
+};
+
+&tphyu3port0 {
+	status = "okay";
+};
+
+&spi2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi2_flash_pins>;
+
+	status = "okay";
+};
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
index 8a00ec3b94..6b5c92086c 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
@@ -53,6 +53,9 @@ bananapi,bpi-r4-poe)
 	ucidef_set_led_netdev "lan2" "lan2" "mt7530-0:02:green:lan" "lan2" "link tx rx"
 	ucidef_set_led_netdev "lan3" "lan3" "mt7530-0:03:green:lan" "lan3" "link tx rx"
 	;;
+bananapi,bpi-r4-lite)
+	ucidef_set_led_netdev "sfp0" "sfp0" "green:sfp" "sfp0" "link tx rx"
+	;;
 cudy,re3000-v1|\
 wavlink,wl-wn573hx3)
 	ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0" "link tx rx"
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
index faa06a5057..ba1465d83d 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -91,6 +91,9 @@ mediatek_setup_interfaces()
 	bananapi,bpi-r4)
 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 sfp-lan" "wan sfp-wan"
 		;;
+	bananapi,bpi-r4-lite)
+		ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 sfp0" "eth1"
+		;;
 	bananapi,bpi-r4-2g5|\
 	bananapi,bpi-r4-poe)
 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan sfp-wan"
diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
index 24388b0336..71e99dc78f 100755
--- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
@@ -86,6 +86,7 @@ platform_do_upgrade() {
 	bananapi,bpi-r4|\
 	bananapi,bpi-r4-2g5|\
 	bananapi,bpi-r4-poe|\
+	bananapi,bpi-r4-lite|\
 	cmcc,a10-ubootmod|\
 	cmcc,rax3000m|\
 	cudy,tr3000-v1-ubootmod|\
@@ -252,6 +253,7 @@ platform_check_image() {
 	bananapi,bpi-r4|\
 	bananapi,bpi-r4-2g5|\
 	bananapi,bpi-r4-poe|\
+	bananapi,bpi-r4-lite|\
 	cmcc,a10-ubootmod|\
 	cmcc,rax3000m|\
 	cudy,tr3000-v1-ubootmod|\
@@ -308,6 +310,7 @@ platform_copy_config() {
 	bananapi,bpi-r4|\
 	bananapi,bpi-r4-2g5|\
 	bananapi,bpi-r4-poe|\
+	bananapi,bpi-r4-lite|\
 	cmcc,rax3000m|\
 	gatonetworks,gdsp|\
 	mediatek,mt7988a-rfb)
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 51fe387dea..cc97a38673 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -638,6 +638,67 @@ endif
 endef
 TARGET_DEVICES += bananapi_bpi-r4-poe
 
+define Device/bananapi_bpi-r4-lite
+  DEVICE_VENDOR := Bananapi
+  DEVICE_MODEL := BPi-R4 Lite
+  DEVICE_DTS := mt7987a-bananapi-bpi-r4-lite
+  DEVICE_DTS_OVERLAY:= mt7987a-bananapi-bpi-r4-lite-1pcie-2L mt7987a-bananapi-bpi-r4-lite-2pcie-1L \
+		       mt7987a-bananapi-bpi-r4-lite-emmc mt7987a-bananapi-bpi-r4-lite-sd \
+		       mt7987a-bananapi-bpi-r4-lite-nand mt7987a-bananapi-bpi-r4-lite-nor
+  DEVICE_DTS_CONFIG := config-mt7987a-bananapi-bpi-r4-lite
+  DEVICE_DTC_FLAGS := --pad 4096
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_DTS_LOADADDR := 0x4ff00000
+  DEVICE_PACKAGES := mt7987-2p5g-phy-firmware-internal kmod-eeprom-at24 \
+		     kmod-gpio-pca953x kmod-i2c-mux-pca954x kmod-rtc-pcf8563 \
+		     kmod-sfp e2fsprogs mkf2fs
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  KERNEL_IN_UBI := 1
+  UBOOTENV_IN_UBI := 1
+  KERNEL_LOADADDR := 0x40000000
+  KERNEL := kernel-bin | gzip
+  KERNEL_INITRAMFS := kernel-bin | lzma | \
+        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
+  IMAGES := sysupgrade.itb
+  KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+  KERNEL_IN_UBI := 1
+  IMAGES := sysupgrade.itb
+  IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-with-rootfs | pad-rootfs | append-metadata
+  ARTIFACTS := \
+	       emmc-preloader.bin emmc-bl31-uboot.fip \
+	       nor-preloader.bin nor-bl31-uboot.fip \
+	       sdcard.img.gz \
+	       snand-preloader.bin snand-bl31-uboot.fip
+  ARTIFACT/emmc-preloader.bin	:= mt7987-bl2 emmc-comb
+  ARTIFACT/emmc-bl31-uboot.fip	:= mt7987-bl31-uboot bananapi_bpi-r4-lite-emmc
+  ARTIFACT/nor-preloader.bin	:= mt7987-bl2 nor-comb
+  ARTIFACT/nor-bl31-uboot.fip	:= mt7987-bl31-uboot bananapi_bpi-r4-lite-nor
+  ARTIFACT/snand-preloader.bin	:= mt7987-bl2 spim-nand2-ubi-comb
+  ARTIFACT/snand-bl31-uboot.fip	:= mt7987-bl31-uboot bananapi_bpi-r4-lite-snand
+  ARTIFACT/sdcard.img.gz	:= mt798x-gpt sdmmc |\
+				   pad-to 17k | mt7987-bl2 sdmmc-comb |\
+				   pad-to 6656k | mt7987-bl31-uboot bananapi_bpi-r4-lite-sdmmc |\
+				$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),\
+				   pad-to 12M | append-image-stage initramfs-recovery.itb | check-size 44m |\
+				) \
+				   pad-to 44M | mt7987-bl2 spim-nand2-ubi-comb |\
+				   pad-to 45M | mt7987-bl31-uboot bananapi_bpi-r4-lite-snand |\
+				   pad-to 49M | mt7987-bl2 nor-comb |\
+				   pad-to 50M | mt7987-bl31-uboot bananapi_bpi-r4-lite-nor |\
+				   pad-to 51M | mt7987-bl2 emmc-comb |\
+				   pad-to 52M | mt7987-bl31-uboot bananapi_bpi-r4-lite-emmc |\
+				   pad-to 56M | mt798x-gpt emmc |\
+				$(if $(CONFIG_TARGET_ROOTFS_SQUASHFS),\
+				   pad-to 64M | append-image squashfs-sysupgrade.itb | check-size |\
+				) \
+				  gzip
+ifeq ($(DUMP),)
+  IMAGE_SIZE := $$(shell expr 64 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
+endif
+endef
+TARGET_DEVICES += bananapi_bpi-r4-lite
+
 define Device/buffalo_wsr-6000ax8
   DEVICE_MODEL := WSR-6000AX8
   DEVICE_VENDOR := Buffalo




More information about the lede-commits mailing list