mediatek: bpi-r4: add support for 2.5GE PoE variant
authorMartin Schiller <ms@dev.tdt.de>
Tue, 30 Apr 2024 08:50:51 +0000 (10:50 +0200)
committerMartin Schiller <ms@dev.tdt.de>
Mon, 6 May 2024 07:12:05 +0000 (09:12 +0200)
This adds support for the bpi-r4 variant with internal 2.5G PHY and
additional ethernet port instead of second sfp.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-poe.dts [new file with mode: 0644]
target/linux/mediatek/files-6.6/drivers/net/phy/mediatek-2p5ge.c
target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mediatek/image/filogic.mk

diff --git a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-poe.dts b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4-poe.dts
new file mode 100644 (file)
index 0000000..efcf0ec
--- /dev/null
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ * Author: Sam.Shih <sam.shih@mediatek.com>
+ */
+
+#include "mt7988a-bananapi-bpi-r4.dtsi"
+
+/ {
+       model = "Bananapi BPI-R4 2.5GE PoE";
+       compatible = "bananapi,bpi-r4-poe",
+                    "mediatek,mt7988a";
+};
+
+&gmac1 {
+       phy-mode = "internal";
+       phy-connection-type = "internal";
+       phy = <&int_2p5g_phy>;
+       status = "okay";
+};
+
+&int_2p5g_phy {
+       pinctrl-names = "i2p5gbe-led";
+       pinctrl-0 = <&i2p5gbe_led0_pins>;
+};
index e2e06d1ecac8cf359c50689ee5b2c29b414aa93a..d1d01190ede2b2c5be27792d0d3f06cb8fbf4253 100644 (file)
@@ -137,6 +137,11 @@ static int mt7988_2p5ge_phy_config_init(struct phy_device *phydev)
        }
 
        /* Setup LED */
+
+       /* Set polarity of led0 to active-high for BPI-R4 */
+       phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_ON_CTRL,
+                        MTK_PHY_LED0_POLARITY);
+
        phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_ON_CTRL,
                         MTK_PHY_LED0_ON_LINK10 |
                         MTK_PHY_LED0_ON_LINK100 |
index 7f75de8b3b961c427d25e82f872b5fe390f646c5..b5a25546717acdeab83e0cf91ecd1bdc5d94c736 100644 (file)
@@ -20,7 +20,8 @@ bananapi,bpi-r3-mini)
        ucidef_set_led_netdev "wlan2g" "WLAN2G" "blue:wlan-1" "phy0-ap0"
        ucidef_set_led_netdev "wlan5g" "WLAN5G" "blue:wlan-2" "phy1-ap0"
        ;;
-bananapi,bpi-r4)
+bananapi,bpi-r4|\
+bananapi,bpi-r4-poe)
        ucidef_set_led_netdev "wan" "wan" "mt7530-0:00:green:lan" "wan" "link tx rx"
        ucidef_set_led_netdev "lan1" "lan1" "mt7530-0:01:green:lan" "lan1" "link tx rx"
        ucidef_set_led_netdev "lan2" "lan2" "mt7530-0:02:green:lan" "lan2" "link tx rx"
index c9fd8d96e69a1fc7af7762de3b229479935db9f0..a161a86462792358d79de09dd7aff5f28b2b5fd7 100644 (file)
@@ -41,7 +41,8 @@ mediatek_setup_interfaces()
        edgecore,eap111)
                ucidef_set_interfaces_lan_wan eth0 eth1
                ;;
-       bananapi,bpi-r4)
+       bananapi,bpi-r4|\
+       bananapi,bpi-r4-poe)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 eth1" "wan eth2"
                ;;
        cmcc,rax3000m|\
index 62860390ebb2e67cd4f8a74b6f808a5cd4293dd6..0c5f66c02910c33794cc0daeebd341f540ae18ee 100644 (file)
@@ -42,7 +42,8 @@ case "$board" in
                [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
                ;;
-       bananapi,bpi-r4)
+       bananapi,bpi-r4|\
+       bananapi,bpi-r4-poe)
                addr=$(cat /sys/class/net/eth0/address)
                [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
index ee0e8b62d752dbbded05ff75ce2c5539c06d916e..ff791a600a3442101219657f96875abfe9d1cdc5 100755 (executable)
@@ -83,6 +83,7 @@ platform_do_upgrade() {
        bananapi,bpi-r3|\
        bananapi,bpi-r3-mini|\
        bananapi,bpi-r4|\
+       bananapi,bpi-r4-poe|\
        jdcloud,re-cp-03|\
        tplink,tl-xdr4288|\
        tplink,tl-xdr6086|\
@@ -196,6 +197,7 @@ platform_check_image() {
        case "$board" in
        bananapi,bpi-r3|\
        bananapi,bpi-r4|\
+       bananapi,bpi-r4-poe|\
        cmcc,rax3000m)
                [ "$magic" != "d00dfeed" ] && {
                        echo "Invalid image type."
@@ -223,7 +225,8 @@ platform_copy_config() {
                ;;
        bananapi,bpi-r3|\
        bananapi,bpi-r3-mini|\
-       bananapi,bpi-r4)
+       bananapi,bpi-r4|\
+       bananapi,bpi-r4-poe)
                case "$(fitblk_get_bootdev)" in
                mmcblk*)
                        emmc_copy_config
index f99a73ac74c887d782c543e48973bc287bc82742..13426f4f3acace4d89304b064d9138671a22e75a 100644 (file)
@@ -318,11 +318,8 @@ endif
 endef
 TARGET_DEVICES += bananapi_bpi-r3-mini
 
-define Device/bananapi_bpi-r4
+define Device/bananapi_bpi-r4-common
   DEVICE_VENDOR := Bananapi
-  DEVICE_MODEL := BPi-R4
-  DEVICE_DTS := mt7988a-bananapi-bpi-r4
-  DEVICE_DTS_CONFIG := config-mt7988a-bananapi-bpi-r4
   DEVICE_DTS_DIR := $(DTS_DIR)/
   DEVICE_DTS_LOADADDR := 0x45f00000
   DEVICE_DTS_OVERLAY:= mt7988a-bananapi-bpi-r4-emmc mt7988a-bananapi-bpi-r4-rtc mt7988a-bananapi-bpi-r4-sd mt7988a-bananapi-bpi-r4-wifi-mt7996a
@@ -337,19 +334,19 @@ define Device/bananapi_bpi-r4
               sdcard.img.gz \
               snand-preloader.bin snand-bl31-uboot.fip
   ARTIFACT/emmc-preloader.bin  := mt7988-bl2 emmc-comb
-  ARTIFACT/emmc-bl31-uboot.fip := mt7988-bl31-uboot bananapi_bpi-r4-emmc
+  ARTIFACT/emmc-bl31-uboot.fip := mt7988-bl31-uboot $$(DEVICE_NAME)-emmc
   ARTIFACT/snand-preloader.bin := mt7988-bl2 spim-nand-ubi-comb
-  ARTIFACT/snand-bl31-uboot.fip        := mt7988-bl31-uboot bananapi_bpi-r4-snand
+  ARTIFACT/snand-bl31-uboot.fip        := mt7988-bl31-uboot $$(DEVICE_NAME)-snand
   ARTIFACT/sdcard.img.gz       := mt798x-gpt sdmmc |\
                                   pad-to 17k | mt7988-bl2 sdmmc-comb |\
-                                  pad-to 6656k | mt7988-bl31-uboot bananapi_bpi-r4-sdmmc |\
+                                  pad-to 6656k | mt7988-bl31-uboot $$(DEVICE_NAME)-sdmmc |\
                                $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),\
                                   pad-to 12M | append-image-stage initramfs-recovery.itb | check-size 44m |\
                                ) \
                                   pad-to 44M | mt7988-bl2 spim-nand-ubi-comb |\
-                                  pad-to 45M | mt7988-bl31-uboot bananapi_bpi-r4-snand |\
+                                  pad-to 45M | mt7988-bl31-uboot $$(DEVICE_NAME)-snand |\
                                   pad-to 51M | mt7988-bl2 emmc-comb |\
-                                  pad-to 52M | mt7988-bl31-uboot bananapi_bpi-r4-emmc |\
+                                  pad-to 52M | mt7988-bl31-uboot $$(DEVICE_NAME)-emmc |\
                                   pad-to 56M | mt798x-gpt emmc |\
                                $(if $(CONFIG_TARGET_ROOTFS_SQUASHFS),\
                                   pad-to 64M | append-image squashfs-sysupgrade.itb | check-size |\
@@ -361,8 +358,24 @@ define Device/bananapi_bpi-r4
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
   IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-with-rootfs | pad-rootfs | append-metadata
 endef
+
+define Device/bananapi_bpi-r4
+  DEVICE_MODEL := BPi-R4
+  DEVICE_DTS := mt7988a-bananapi-bpi-r4
+  DEVICE_DTS_CONFIG := config-mt7988a-bananapi-bpi-r4
+  $(call Device/bananapi_bpi-r4-common)
+endef
 TARGET_DEVICES += bananapi_bpi-r4
 
+define Device/bananapi_bpi-r4-poe
+  DEVICE_MODEL := BPi-R4 2.5GE
+  DEVICE_DTS := mt7988a-bananapi-bpi-r4-poe
+  DEVICE_DTS_CONFIG := config-mt7988a-bananapi-bpi-r4-poe
+  $(call Device/bananapi_bpi-r4-common)
+  DEVICE_PACKAGES += mt7988-2p5g-phy-firmware
+endef
+TARGET_DEVICES += bananapi_bpi-r4-poe
+
 define Device/cetron_ct3003
   DEVICE_VENDOR := Cetron
   DEVICE_MODEL := CT3003