[openwrt/openwrt] ramips: add support for Ubiquiti USW-Flex

LEDE Commits lede-commits at lists.infradead.org
Sat Sep 25 12:09:43 PDT 2021


blocktrron pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/a9839697896c4fdf8c44a06bbce466ce52493069

commit a9839697896c4fdf8c44a06bbce466ce52493069
Author: David Bauer <mail at david-bauer.net>
AuthorDate: Fri Aug 20 13:23:42 2021 +0200

    ramips: add support for Ubiquiti USW-Flex
    
    Hardware
    --------
    MediaTek MT7621AT
    16M SPI-NOR Macronix MX25L12835FMI
    Microchip PD69104B1 4-Channel PoE-PSE controller
    TI TPS2373 PoE-PD controller
    
    PoE-Controller
    --------------
    
    By default, the PoE outputs do not work with OpenWrt. To make them output
    power, install the "poemgr" package from the packages feed.
    This package can control the PD69104B1 PSE controller.
    
    Installation
    ------------
    
    1. Connect to the booted device at 192.168.1.20 using username/password
       "ubnt" via SSH.
    
    2. Add the uboot-envtools configuration file /etc/fw_env.config with the
       following content
    
       $ echo "/dev/mtd1 0x0 0x1000 0x10000 1" > /etc/fw_env.config
    
    3. Update the bootloader environment.
    
       $ fw_setenv boot_openwrt "fdt addr \$(fdtcontroladdr);
         fdt rm /signature; bootubnt"
       $ fw_setenv bootcmd "run boot_openwrt"
    
    4. Transfer the OpenWrt sysupgrade image to the device using SCP.
    
    5. Check the mtd partition number for bs / kernel0 / kernel1
    
       $ cat /proc/mtd
    
    6. Set the bootselect flag to boot from kernel0
    
       $ dd if=/dev/zero bs=1 count=1 of=/dev/mtdblock4
    
    7. Write the OpenWrt sysupgrade image to both kernel0 as well as kernel1
    
       $ dd if=openwrt.bin of=/dev/mtdblock6
       $ dd if=openwrt.bin of=/dev/mtdblock7
    
    8. Reboot the device. It should boot into OpenWrt.
    
    Restore to UniFi
    ----------------
    
    To restore the vendor firmware, follow the Ubiquiti UniFi TFTP
    recovery guide for access points. The process is the same for
    the Flex switch.
    
    Signed-off-by: David Bauer <mail at david-bauer.net>
---
 target/linux/ramips/dts/mt7621_ubnt_usw-flex.dts   | 172 +++++++++++++++++++++
 target/linux/ramips/image/mt7621.mk                |  10 ++
 .../mt7621/base-files/etc/board.d/02_network       |   3 +
 3 files changed, 185 insertions(+)

diff --git a/target/linux/ramips/dts/mt7621_ubnt_usw-flex.dts b/target/linux/ramips/dts/mt7621_ubnt_usw-flex.dts
new file mode 100644
index 0000000000..de5491bf1b
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_ubnt_usw-flex.dts
@@ -0,0 +1,172 @@
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "Ubiquiti UniFi Switch Flex";
+	compatible = "ubnt,usw-flex", "mediatek,mt7621-soc";
+
+	aliases {
+		led-boot = &led_white;
+		led-failsafe = &led_white;
+		led-running = &led_blue;
+		led-upgrade = &led_blue;
+		label-mac-device = &gmac0;
+	};
+
+	chosen {
+		bootargs-override = "console=ttyS0,115200";
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led_blue: status_blue {
+			label = "blue:status";
+			gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
+		};
+
+		led_white: status_white {
+			label = "white:status";
+			gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	i2c-gpio {
+		compatible = "i2c-gpio";
+
+		sda-gpios = <&gpio 3 GPIO_ACTIVE_HIGH>;
+		scl-gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
+
+		i2c-gpio,delay-us = <50>;
+
+		/* Microsemi PD69104B1 PSE controller */
+	};
+};
+
+&gmac0 {
+	nvmem-cells = <&macaddr_eeprom>;
+	nvmem-cell-names = "mac-address";
+	label = "dsa";
+};
+
+&switch0 {
+	ports {
+		port at 0 {
+			status = "okay";
+			label = "lan1";
+		};
+
+		port at 1 {
+			status = "okay";
+			label = "lan2";
+		};
+
+		port at 2 {
+			status = "okay";
+			label = "lan3";
+		};
+
+		port at 3 {
+			status = "okay";
+			label = "lan4";
+		};
+
+		port at 4 {
+			status = "okay";
+			label = "lan5";
+		};
+	};
+};
+
+&state_default {
+	gpio {
+		groups = "i2c", "uart2", "uart3", "jtag";
+		function = "gpio";
+	};
+};
+
+&spi0 {
+	status = "okay";
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <30000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "u-boot";
+				reg = <0x0 0x60000>;
+				read-only;
+			};
+
+			partition at 60000 {
+				label = "u-boot-env";
+				reg = <0x60000 0x10000>;
+			};
+
+			partition at 70000 {
+				label = "factory";
+				reg = <0x70000 0x10000>;
+				read-only;
+			};
+
+			part_eeprom: partition at 80000 {
+				compatible = "nvmem-cells";
+
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				label = "eeprom";
+				reg = <0x80000 0x10000>;
+				read-only;
+
+				macaddr_eeprom: macaddr at 0 {
+					reg = <0x0 0x6>;
+				};
+			};
+
+			partition at 90000 {
+				label = "bs";
+				reg = <0x90000 0x10000>;
+			};
+
+			partition at a0000 {
+				label = "cfg";
+				reg = <0xa0000 0x100000>;
+				read-only;
+			};
+
+			partition at 1a0000 {
+				compatible = "denx,fit";
+				label = "firmware";
+				reg = <0x1a0000 0x730000>;
+			};
+
+			partition at 8d0000 {
+				label = "kernel1";
+				reg = <0x8d0000 0x730000>;
+			};
+		};
+	};
+};
+
+&xhci {
+	status = "disabled";
+};
diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index d28aa96224..68993a02fb 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -1408,6 +1408,16 @@ define Device/ubnt_unifi-nanohd
 endef
 TARGET_DEVICES += ubnt_unifi-nanohd
 
+define Device/ubnt_usw-flex
+  $(Device/dsa-migration)
+  DEVICE_VENDOR := Ubiquiti
+  DEVICE_MODEL := UniFi Switch Flex
+  DEVICE_DTS_CONFIG := config at 1
+  KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
+  IMAGE_SIZE := 7360k
+endef
+TARGET_DEVICES += ubnt_usw-flex
+
 define Device/unielec_u7621-01-16m
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
index 16148547f7..47f978baf8 100644
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -67,6 +67,9 @@ ramips_setup_interfaces()
 	ubnt,edgerouter-x-sfp)
 		ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
 		;;
+	ubnt,usw-flex)
+		ucidef_set_interface_lan "lan1 lan2 lan3 lan4 lan5"
+		;;
 	zyxel,nr7101)
 		ucidef_set_interfaces_lan_wan "lan" "wan"
 		;;



More information about the lede-commits mailing list