[openwrt/openwrt] siflower: sf21: add support for Bananapi BPI-RV2

LEDE Commits lede-commits at lists.infradead.org
Tue Feb 4 19:09:04 PST 2025


981213 pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b8a8bf53e94c07b4c2cb85005d9598f9f6d7b87e

commit b8a8bf53e94c07b4c2cb85005d9598f9f6d7b87e
Author: Chuanhong Guo <gch981213 at gmail.com>
AuthorDate: Tue Jan 14 14:36:36 2025 +0800

    siflower: sf21: add support for Bananapi BPI-RV2
    
    Specification:
     - Siflower SF21H8898
     - 512MB DDR3, 128MB SPI-NAND and 16MB SPI-NOR
     - 5x Gigabit ports (SF23P1240 QSGMII PHY and SF23P1211F RGMII PHY)
     - 1x 2.5G port (Airoha EN8811H PHY)
     - M.2 Key B slot with USB2.0, PCIEx1 and a NanoSIM card slot
     - MiniPCIe slot with USB2.0 and PCIEx1
     - 1x USB2.0 port through USB Hub
     - PCF8563-compatible RTC
    
    The SoC can only boot from SPI0. Two SPI flash chipselects are connected
    to GPIO5 (SPI0 CS) and GPIO36 through a 2x2 jumper. It boots from
    SPI-NOR or SPI-NAND depending on how the jumpers are connected.
    
    The firmware can be flashed using U-boot web recovery from Siflower
    vendor U-boot.
    
    Link: https://github.com/openwrt/openwrt/pull/17115
    Signed-off-by: Chuanhong Guo <gch981213 at gmail.com>
---
 .../dts/sf21h8898_bananapi_bpi-rv2-nand.dts        |  92 ++++++++++
 .../dts/sf21h8898_bananapi_bpi-rv2-nor.dts         |  82 +++++++++
 .../siflower/dts/sf21h8898_bananapi_bpi-rv2.dtsi   | 204 +++++++++++++++++++++
 target/linux/siflower/image/sf21.mk                |  19 ++
 .../sf21/base-files/etc/board.d/02_network         |   3 +
 .../sf21/base-files/lib/upgrade/platform.sh        |   3 +
 6 files changed, 403 insertions(+)

diff --git a/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nand.dts b/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nand.dts
new file mode 100644
index 0000000000..1a77990dd7
--- /dev/null
+++ b/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nand.dts
@@ -0,0 +1,92 @@
+/dts-v1/;
+#include "sf21h8898_bananapi_bpi-rv2.dtsi"
+
+/ {
+	model = "Bananapi BPI-RV2 (Booting from NAND)";
+	compatible = "bananapi,bpi-rv2-nand", "siflower,sf21h8898";
+};
+
+&spi0 {
+	status = "okay";
+	num-cs = <2>;
+	cs-gpios = <&gpio 5 GPIO_ACTIVE_LOW>, <&gpio 36 GPIO_ACTIVE_LOW>;
+
+	flash at 0 {
+		compatible = "spi-nand";
+		reg = <0>;
+		spi-max-frequency = <35000000>;
+		spi-tx-bus-width = <2>;
+		spi-rx-bus-width = <2>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+	        partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "fbl";
+				reg = <0x0 0x20000>;
+			};
+
+			partition at 20000 {
+				label = "ubi";
+				reg = <0x20000 0x0>;
+				compatible = "linux,ubi";
+
+				volumes {
+					factory: ubi-volume-factory {
+						volname = "factory";
+						
+						nvmem-layout {
+							compatible = "fixed-layout";
+							#address-cells = <1>;
+							#size-cells = <1>;
+
+							macaddr_factory_0: macaddr at 0 {
+								compatible = "mac-base";
+								reg = <0x0 0x6>;
+								#nvmem-cell-cells = <1>;
+							};
+						};
+					};
+
+					rootdisk: ubi-volume-fit {
+						volname = "fit";
+					};
+				};
+			};
+		};
+	};
+
+	flash at 1 {
+		compatible = "jedec,spi-nor";
+		reg = <1>;
+		spi-max-frequency = <35000000>;
+		spi-tx-bus-width = <2>;
+		spi-rx-bus-width = <2>;
+
+	        partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "bootloader-nor";
+				reg = <0x0 0x90000>;
+				read-only;
+			};
+
+			partition at 90000 {
+				label = "factory-nor";
+				reg = <0x90000 0x10000>;
+			};
+
+			partition at a0000 {
+				label = "firmware-nor";
+				reg = <0xa0000 0xf60000>;
+			};
+		};
+	};
+};
diff --git a/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nor.dts b/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nor.dts
new file mode 100644
index 0000000000..7a87798e33
--- /dev/null
+++ b/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nor.dts
@@ -0,0 +1,82 @@
+/dts-v1/;
+#include "sf21h8898_bananapi_bpi-rv2.dtsi"
+
+/ {
+	model = "Bananapi BPI-RV2 (Booting from NOR)";
+	compatible = "bananapi,bpi-rv2-nor", "siflower,sf21h8898";
+};
+
+&spi0 {
+	status = "okay";
+	num-cs = <2>;
+	cs-gpios = <&gpio 5 GPIO_ACTIVE_LOW>, <&gpio 36 GPIO_ACTIVE_LOW>;
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <35000000>;
+		spi-tx-bus-width = <2>;
+		spi-rx-bus-width = <2>;
+
+	        partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "bootloader";
+				reg = <0x0 0x90000>;
+				read-only;
+			};
+
+			factory: partition at 90000 {
+				label = "factory";
+				reg = <0x90000 0x10000>;
+
+				nvmem-layout {
+					compatible = "fixed-layout";
+					#address-cells = <1>;
+					#size-cells = <1>;
+
+					macaddr_factory_0: macaddr at 0 {
+						compatible = "mac-base";
+						reg = <0x0 0x6>;
+						#nvmem-cell-cells = <1>;
+					};
+				};
+			};
+
+			rootdisk: partition at a0000 {
+				label = "firmware";
+				reg = <0xa0000 0xf60000>;
+				compatible = "denx,fit";
+			};
+		};
+	};
+
+	flash at 1 {
+		compatible = "spi-nand";
+		reg = <1>;
+		spi-max-frequency = <35000000>;
+		spi-tx-bus-width = <2>;
+		spi-rx-bus-width = <2>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+	        partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "fbl-nand";
+				reg = <0x0 0x20000>;
+			};
+
+			partition at 20000 {
+				label = "ubi-nand";
+				reg = <0x20000 0x0>;
+			};
+		};
+	};
+};
diff --git a/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2.dtsi b/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2.dtsi
new file mode 100644
index 0000000000..aa309e37c1
--- /dev/null
+++ b/target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2.dtsi
@@ -0,0 +1,204 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/dts-v1/;
+#include "sf21h8898.dtsi"
+
+/ {
+	chosen {
+		bootargs = "root=/dev/fit0 rootwait";
+		stdout-path = "serial1:115200n8";
+		rootdisk = <&rootdisk>;
+	};
+
+	memory at 20000000 {
+		device_type = "memory";
+		reg = <0x0 0x20000000 0x0 0x20000000>;
+	};
+
+	usb_vbus: regulator at 0 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio 37 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+};
+
+&spi0_pins {
+	pinctrl-single,pins = <
+		SPI0_TXD	FUNC_MODE0
+		SPI0_RXD	FUNC_MODE0
+		SPI0_CLK	FUNC_MODE0
+		SPI0_HOLD	FUNC_MODE0
+		SPI0_WP		FUNC_MODE0
+	>;
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&uart1 {
+	status = "okay";
+};
+
+&iomux {
+	rtc_int_gpio: rtc-int-pins {
+		pinctrl-single,pins = <PHY_INT GPIO_MODE>;
+		// disable internal bias as it's externally (and weakly) pulled up
+		pinctrl-single,bias-pullup = <0 SW_PU 0 SW_PU>;
+		pinctrl-single,bias-pulldown = <0 SW_PD 0 SW_PD>;
+	};
+};
+
+&i2c0 {
+	status = "okay";
+
+	rtc: rtc at 51 {
+		compatible = "analogtek,at8563", "nxp,pcf8563";
+		reg = <0x51>;
+		#clock-cells = <0>;
+		interrupts-extended = <&gpio 40 IRQ_TYPE_LEVEL_LOW>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&rtc_int_gpio>;
+	};
+};
+
+&xgmac0 {
+	status = "okay";
+	phy-handle = <&phy1>;
+	nvmem-cells = <&macaddr_factory_0 0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&xgmac1 {
+	status = "okay";
+	phy-handle = <&phy2>;
+	nvmem-cells = <&macaddr_factory_0 0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&xgmac2 {
+	status = "okay";
+	phy-handle = <&phy3>;
+	nvmem-cells = <&macaddr_factory_0 0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&xgmac3 {
+	status = "okay";
+	phy-handle = <&phy4>;
+	nvmem-cells = <&macaddr_factory_0 0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&xgmac4 {
+	status = "okay";
+	phy-handle = <&phy15>;
+	nvmem-cells = <&macaddr_factory_0 1>;
+	nvmem-cell-names = "mac-address";
+	mac-address-increment = <1>;
+	/delete-property/ pinctrl-0;
+};
+
+&xgmac5 {
+	status = "okay";
+	tx-internal-delay-ps = <2499>;
+	rx-internal-delay-ps = <1519>;
+	phy-mode = "rgmii-txid";
+	phy-handle = <&phy6>;
+	nvmem-cells = <&macaddr_factory_0 0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&mdio0 {
+	reset-gpios = <&gpio 30 GPIO_ACTIVE_LOW>;
+	reset-delay-us = <10000>;
+	reset-post-delay-us = <100000>;
+
+	phy1: ethernet-phy at 1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0x1>;
+	};
+
+	phy2: ethernet-phy at 2 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0x2>;
+	};
+
+	phy3: ethernet-phy at 3 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0x3>;
+	};
+
+	phy4: ethernet-phy at 4 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0x4>;
+	};
+
+	phy6: ethernet-phy at 6 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0x6>;
+		reset-gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+		reset-assert-us = <10000>;
+		reset-deassert-us = <100000>;
+	};
+
+	phy15: ethernet-phy at f {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0xf>;
+		reset-gpios = <&gpio 39 GPIO_ACTIVE_LOW>;
+		reset-assert-us = <10000>;
+		reset-deassert-us = <100000>;
+	};
+};
+
+&pcie_phy {
+	status = "okay";
+};
+
+/*
+ * M.2 Key B slot. Other GPIO pins connected to the slot:
+ *  GPIO0: WAKEUP
+ *  GPIO8: W_DISABLE
+ *  GPIO10: CLKREQ_N
+ *  GPIO38: FULL_CARD_POFF
+ */
+&pcie0 {
+	reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>;
+	status = "okay";
+};
+
+/*
+ * MiniPCIE slot. Other GPIO pins connected to the slot:
+ *  GPIO11: PEWAKE
+ *  GPIO12: CLKREQ_N
+ */
+&pcie1 {
+	reset-gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
+	status = "okay";
+};
+
+&usb_phy {
+	status = "okay";
+};
+
+&usb {
+	status = "okay";
+};
+
+&dpns {
+	status = "okay";
+};
+
+&edma {
+	status = "okay";
+};
+
+&qsgmii_pcs {
+	status = "okay";
+};
+
+&sgmii_pcs {
+	status = "okay";
+};
diff --git a/target/linux/siflower/image/sf21.mk b/target/linux/siflower/image/sf21.mk
index 6812303e29..655083d686 100644
--- a/target/linux/siflower/image/sf21.mk
+++ b/target/linux/siflower/image/sf21.mk
@@ -18,3 +18,22 @@ define Device/NAND
 	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 128k
   IMAGE/sysupgrade.bin = append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata
 endef
+
+define Device/bananapi_bpi-rv2
+  DEVICE_VENDOR := Bananapi
+  DEVICE_PACKAGES := kmod-usb-dwc2 kmod-phy-sf21-usb kmod-phy-airoha-en8811h kmod-rtc-pcf8563
+endef
+
+define Device/bananapi_bpi-rv2-nand
+  DEVICE_MODEL := BPi-RV2 (Booting from NAND)
+  DEVICE_DTS := sf21h8898_bananapi_bpi-rv2-nand
+  $(call Device/bananapi_bpi-rv2)
+endef
+TARGET_DEVICES += bananapi_bpi-rv2-nand
+
+define Device/bananapi_bpi-rv2-nor
+  DEVICE_MODEL := BPi-RV2 (Booting from NOR)
+  DEVICE_DTS := sf21h8898_bananapi_bpi-rv2-nor
+  $(call Device/bananapi_bpi-rv2)
+endef
+TARGET_DEVICES += bananapi_bpi-rv2-nor
diff --git a/target/linux/siflower/sf21/base-files/etc/board.d/02_network b/target/linux/siflower/sf21/base-files/etc/board.d/02_network
index 572dba0326..efa5d69fce 100644
--- a/target/linux/siflower/sf21/base-files/etc/board.d/02_network
+++ b/target/linux/siflower/sf21/base-files/etc/board.d/02_network
@@ -8,6 +8,9 @@ siflower_setup_interfaces()
 	local board="$1"
 
 	case $board in
+	bananapi,bpi-rv2-n*)
+		ucidef_set_interfaces_lan_wan 'eth0 eth1 eth2 eth3 eth5' 'eth4'
+		;;
 	*)
 		ucidef_set_interfaces_lan_wan 'eth0 eth1 eth2' 'eth3'
 		;;
diff --git a/target/linux/siflower/sf21/base-files/lib/upgrade/platform.sh b/target/linux/siflower/sf21/base-files/lib/upgrade/platform.sh
index ab62c84cb4..ac90f253b4 100644
--- a/target/linux/siflower/sf21/base-files/lib/upgrade/platform.sh
+++ b/target/linux/siflower/sf21/base-files/lib/upgrade/platform.sh
@@ -5,6 +5,9 @@ platform_do_upgrade() {
 	local board=$(board_name)
 
 	case "$board" in
+	bananapi,bpi-rv2-nand)
+		fit_do_upgrade "$1"
+		;;
 	*)
 		default_do_upgrade "$1"
 		;;




More information about the lede-commits mailing list