[RFC PATCH 2/5] ath79: add support for MikroTik RouterBOARD 960PGS (hEx PoE)

Oskari Lemmela oskari at lemmela.net
Sun Dec 26 10:41:23 PST 2021


This patch adds support for the MikroTik RouterBOARD 960PGS (hEx PoE)
router. The device has a USB 2.0 port and a SFP port for adding optical
fiber connectivity. The ports 2-5 can power other PoE capable devices
with the same voltage as applied to the unit.

Specifications:

- SoC: Qualcomm Atheros QCA9557
- Flash: 16 MB (SPI)
- RAM: 128 MB
- 1x Ethernet SFP: 1000
- 1x Ethernet RJ45: 10/100/1000 port with passive POE in
- 4x Ethernet RJ45: 10/100/1000 ports with 802.3af/at PoE out
- 1x USB 2.0 host port
- 1x reset button

See https://mikrotik.com/product/RB960PGS for more details.

Flashing:
 TFTP boot initramfs image and then perform sysupgrade. Follow common
 MikroTik procedure as in https://openwrt.org/toh/mikrotik/common.

Signed-off-by: Oskari Lemmela <oskari at lemmela.net>
---
 .../qca9557_mikrotik_routerboard-960pgs.dts   | 279 ++++++++++++++++++
 target/linux/ath79/image/mikrotik.mk          |   9 +
 .../base-files/etc/board.d/02_network         |  14 +
 .../lib/preinit/10_rename_interfaces.sh       |  11 +
 4 files changed, 313 insertions(+)
 create mode 100644 target/linux/ath79/dts/qca9557_mikrotik_routerboard-960pgs.dts
 create mode 100644 target/linux/ath79/mikrotik/base-files/lib/preinit/10_rename_interfaces.sh

diff --git a/target/linux/ath79/dts/qca9557_mikrotik_routerboard-960pgs.dts b/target/linux/ath79/dts/qca9557_mikrotik_routerboard-960pgs.dts
new file mode 100644
index 0000000000..273357cf39
--- /dev/null
+++ b/target/linux/ath79/dts/qca9557_mikrotik_routerboard-960pgs.dts
@@ -0,0 +1,279 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "qca955x.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	compatible = "mikrotik,routerboard-960pgs", "qca,qca9557";
+	model = "MikroTik RouterBOARD 960PGS";
+
+	aliases {
+		serial0 = &uart;
+	};
+
+	gpio_export {
+		compatible = "gpio-export";
+		#size-cells = <0>;
+
+		buzzer {
+			/* Beeper requires PWM for frequency selection */
+			gpio-export,name = "buzzer";
+			gpio-export,output = <0>;
+			gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	i2c: i2c {
+		compatible = "i2c-gpio";
+
+		i2c-gpio,delay-us = <5>;
+		i2c-gpio,timeout-ms = <1>;
+		sda-gpios = <&gpio 18 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+		scl-gpios = <&gpio 19 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
+
+		sfp_eeprom at 50 {
+			compatible = "at,24c04";
+			reg = <0x50>;
+		};
+
+		sfp_eeprom at 51 {
+			compatible = "at,24c04";
+			reg = <0x51>;
+		};
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			debounce-interval = <60>;
+			gpios = <&gpio 20 GPIO_ACTIVE_LOW>;
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led_user: user {
+			label = "green:user";
+			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+		};
+
+		led_sfp: sfp {
+			label = "green:sfp";
+			gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	sfp1: sfp {
+		compatible = "sff,sfp";
+
+		i2c-bus = <&i2c>;
+		maximum-power-milliwatt = <1000>;
+		los-gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
+		mod-def0-gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
+		tx-disable-gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
+	};
+
+	reg_usb_vbus {
+		compatible = "regulator-fixed";
+		regulator-always-on;
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-name = "usb_vbus";
+		gpio = <&gpio 13 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+};
+
+&mdio0 {
+	status = "okay";
+
+	switch at 0 {
+		compatible = "qca,qca8337";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		reg = <0>;
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port at 0 {
+				reg = <0>;
+				label = "cpu";
+				ethernet = <&eth0>;
+				phy-mode = "rgmii-id";
+				fixed-link {
+					speed = <1000>;
+					full-duplex;
+				};
+			};
+
+			port at 1 {
+				reg = <1>;
+				label = "lan1";
+				phy-mode = "internal";
+				phy-handle = <&phy_port1>;
+			};
+
+			port at 2 {
+				reg = <2>;
+				label = "lan2";
+				phy-mode = "internal";
+				phy-handle = <&phy_port2>;
+			};
+
+			port at 3 {
+				reg = <3>;
+				label = "lan3";
+				phy-mode = "internal";
+				phy-handle = <&phy_port3>;
+			};
+
+			port at 4 {
+				reg = <4>;
+				label = "lan4";
+				phy-mode = "internal";
+				phy-handle = <&phy_port4>;
+			};
+
+			port at 5 {
+				reg = <5>;
+				label = "lan5";
+				phy-mode = "internal";
+				phy-handle = <&phy_port5>;
+			};
+		};
+		mdio {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			phy_port1: phy at 0 {
+				reg = <0>;
+			};
+
+			phy_port2: phy at 1 {
+				reg = <1>;
+			};
+
+			phy_port3: phy at 2 {
+				reg = <2>;
+			};
+
+			phy_port4: phy at 3 {
+				reg = <3>;
+			};
+
+			phy_port5: phy at 4 {
+				reg = <4>;
+			};
+		};
+	};
+};
+
+&eth0 {
+	status = "okay";
+
+	pll-data = <0x8f000000 0xa0000101 0xa0001313>;
+
+	fixed-link {
+		speed = <1000>;
+		full-duplex;
+	};
+};
+
+&mdio1 {
+	status = "okay";
+
+	phy_sfp: ethernet-phy at 0 {
+		reg = <0>;
+		phy-mode = "sgmii";
+		sfp = <&sfp1>;
+	};
+};
+
+&eth1 {
+	status = "okay";
+
+	phy-handle = <&phy_sfp>;
+	pll-data = <0x03000000 0x00000101 0x00001616>;
+	qca955x-sgmii-fixup;
+
+	gmac-config {
+		device = <&gmac>;
+	};
+
+	fixed-link {
+		speed = <1000>;
+		full-duplex;
+	};
+};
+
+&spi {
+	status = "okay";
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				compatible = "mikrotik,routerboot-partitions";
+				label = "RouterBoot";
+				reg = <0x0 0x20000>;
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				partition at 0 {
+					label = "bootloader1";
+					reg = <0x0 0x0>;
+					read-only;
+				};
+
+				hard_config {
+					read-only;
+				};
+
+				bios {
+					size = <0x1000>;
+					read-only;
+				};
+
+				partition at 10000 {
+					label = "bootloader2";
+					reg = <0x10000 0x0>;
+					read-only;
+				};
+
+				soft_config {
+					label = "soft_config";
+				};
+			};
+
+			partition at 20000 {
+				compatible = "mikrotik,minor";
+				label = "firmware";
+				reg = <0x020000 0xfe0000>;
+			};
+		};
+	};
+};
+
+&usb0 {
+	status = "okay";
+};
+
+&usb_phy0 {
+	status = "okay";
+};
diff --git a/target/linux/ath79/image/mikrotik.mk b/target/linux/ath79/image/mikrotik.mk
index 095a1cbc84..44ea708f48 100644
--- a/target/linux/ath79/image/mikrotik.mk
+++ b/target/linux/ath79/image/mikrotik.mk
@@ -38,6 +38,15 @@ define Device/mikrotik_routerboard-922uags-5hpacd
 endef
 TARGET_DEVICES += mikrotik_routerboard-922uags-5hpacd
 
+define Device/mikrotik_routerboard-960pgs
+  $(Device/mikrotik_nor)
+  SOC := qca9557
+  DEVICE_MODEL := RouterBOARD 960PGS (hEX PoE)
+  IMAGE_SIZE := 16256k
+  DEVICE_PACKAGES += kmod-usb2 kmod-i2c-gpio kmod-sfp
+endef
+TARGET_DEVICES += mikrotik_routerboard-960pgs
+
 define Device/mikrotik_routerboard-lhg-2nd
   $(Device/mikrotik_nor)
   SOC := qca9533
diff --git a/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network b/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
index 4058742133..91a62e33c3 100644
--- a/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
@@ -14,6 +14,9 @@ ath79_setup_interfaces()
 		ucidef_add_switch "switch1" \
 			"0 at eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
 		;;
+	mikrotik,routerboard-960pgs)
+		ucidef_set_interface_lan "sfp lan1 lan2 lan3 lan4 lan5"
+		;;
 	mikrotik,routerboard-912uag-2hpnd|\
 	mikrotik,routerboard-lhg-2nd|\
 	mikrotik,routerboard-sxt-5nd-r2|\
@@ -50,6 +53,17 @@ ath79_setup_macs()
 		lan_mac="$mac_base"
 		wan_mac=$(macaddr_add $mac_base 1)
 		;;
+	mikrotik,routerboard-960pgs)
+		label_mac=$mac_base
+		ucidef_set_bridge_device switch
+		ucidef_set_bridge_mac "$mac_base"
+		ucidef_set_network_device_mac "sfp" "$mac_base"
+		ucidef_set_network_device_mac "lan1" "$(macaddr_add $mac_base 1)"
+		ucidef_set_network_device_mac "lan2" "$(macaddr_add $mac_base 2)"
+		ucidef_set_network_device_mac "lan3" "$(macaddr_add $mac_base 3)"
+		ucidef_set_network_device_mac "lan4" "$(macaddr_add $mac_base 4)"
+		ucidef_set_network_device_mac "lan5" "$(macaddr_add $mac_base 5)"
+		;;
 	*)
 		label_mac="$mac_base"
 		wan_mac="$mac_base"
diff --git a/target/linux/ath79/mikrotik/base-files/lib/preinit/10_rename_interfaces.sh b/target/linux/ath79/mikrotik/base-files/lib/preinit/10_rename_interfaces.sh
new file mode 100644
index 0000000000..66e7e24e5d
--- /dev/null
+++ b/target/linux/ath79/mikrotik/base-files/lib/preinit/10_rename_interfaces.sh
@@ -0,0 +1,11 @@
+. /lib/functions.sh
+
+set_interface_names() {
+	case $(board_name) in
+	mikrotik,routerboard-960pgs)
+		ip link set dev eth1 name sfp
+		;;
+	esac
+}
+
+boot_hook_add preinit_main set_interface_names
-- 
2.25.1




More information about the openwrt-devel mailing list