siflower: sf21: add support for Bananapi BPI-RV2
authorChuanhong Guo <gch981213@gmail.com>
Tue, 14 Jan 2025 06:36:36 +0000 (14:36 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Wed, 5 Feb 2025 03:08:37 +0000 (11:08 +0800)
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@gmail.com>
target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nand.dts [new file with mode: 0644]
target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2-nor.dts [new file with mode: 0644]
target/linux/siflower/dts/sf21h8898_bananapi_bpi-rv2.dtsi [new file with mode: 0644]
target/linux/siflower/image/sf21.mk
target/linux/siflower/sf21/base-files/etc/board.d/02_network
target/linux/siflower/sf21/base-files/lib/upgrade/platform.sh

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 (file)
index 0000000..1a77990
--- /dev/null
@@ -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@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@0 {
+                               label = "fbl";
+                               reg = <0x0 0x20000>;
+                       };
+
+                       partition@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@0 {
+                                                               compatible = "mac-base";
+                                                               reg = <0x0 0x6>;
+                                                               #nvmem-cell-cells = <1>;
+                                                       };
+                                               };
+                                       };
+
+                                       rootdisk: ubi-volume-fit {
+                                               volname = "fit";
+                                       };
+                               };
+                       };
+               };
+       };
+
+       flash@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@0 {
+                               label = "bootloader-nor";
+                               reg = <0x0 0x90000>;
+                               read-only;
+                       };
+
+                       partition@90000 {
+                               label = "factory-nor";
+                               reg = <0x90000 0x10000>;
+                       };
+
+                       partition@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 (file)
index 0000000..7a87798
--- /dev/null
@@ -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@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@0 {
+                               label = "bootloader";
+                               reg = <0x0 0x90000>;
+                               read-only;
+                       };
+
+                       factory: partition@90000 {
+                               label = "factory";
+                               reg = <0x90000 0x10000>;
+
+                               nvmem-layout {
+                                       compatible = "fixed-layout";
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+
+                                       macaddr_factory_0: macaddr@0 {
+                                               compatible = "mac-base";
+                                               reg = <0x0 0x6>;
+                                               #nvmem-cell-cells = <1>;
+                                       };
+                               };
+                       };
+
+                       rootdisk: partition@a0000 {
+                               label = "firmware";
+                               reg = <0xa0000 0xf60000>;
+                               compatible = "denx,fit";
+                       };
+               };
+       };
+
+       flash@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@0 {
+                               label = "fbl-nand";
+                               reg = <0x0 0x20000>;
+                       };
+
+                       partition@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 (file)
index 0000000..aa309e3
--- /dev/null
@@ -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@20000000 {
+               device_type = "memory";
+               reg = <0x0 0x20000000 0x0 0x20000000>;
+       };
+
+       usb_vbus: regulator@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@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@1 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <0x1>;
+       };
+
+       phy2: ethernet-phy@2 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <0x2>;
+       };
+
+       phy3: ethernet-phy@3 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <0x3>;
+       };
+
+       phy4: ethernet-phy@4 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <0x4>;
+       };
+
+       phy6: ethernet-phy@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@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";
+};
index 6812303e29f3cfb2f322b9e6dd026cae90941eea..655083d686a160fcf036ad446b95e3ab2b81ea2b 100644 (file)
@@ -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
index 572dba03267e48daf9fdb27bd126ebed42bbe0b0..efa5d69fceba6366b889af31115dd80586e882bd 100644 (file)
@@ -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'
                ;;
index ab62c84cb49fc51b63284a0b20141a86637252c1..ac90f253b45987eb85313289ef713e962163c735 100644 (file)
@@ -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"
                ;;