ramips: add support for MikroTik RouterBOARD 760iGS (hEX S)
authorJohn Thomson <git@johnthomson.fastmail.com.au>
Wed, 10 Jun 2020 22:15:40 +0000 (08:15 +1000)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Thu, 13 Aug 2020 10:47:45 +0000 (12:47 +0200)
This patch adds support for the MikroTik RouterBOARD 760iGS router.
It is similar to the already supported RouterBOARD 750Gr3.
The 760iGS device features an added SFP cage, and passive
PoE out on port 5 compared to the RB750Gr3.

https://mikrotik.com/product/hex_s

Specifications:

- SoC: MediaTek MT7621A
- CPU: 880MHz
- Flash: 16 MB
- RAM:  256 MB
- Ethernet: 5x 10/100/1000 Mbps
- SFP cage
- USB port
- microSD slot

Unsupported:

- Beeper (requires PWM driver)
- ZT2046Q (ADS7846 compatible) on SPI as slave 1 (CS1)
  The linux driver requires an interrupt, and pendown GPIO
  These are unknown, and not needed with the touchscreen
  only used for temperature and voltage monitoring.
  ads7846 hwmon:
  temp0 is degrees Celsius
  temp1 is voltage * 32

GPIOs:

- 07:  input passive PoE out (lan5) compatible (Mikrotik) device connected
- 17:  output passive PoE out (lan5) switch

Installation through RouterBoot follows the usual MikroTik method
https://openwrt.org/toh/mikrotik/common

To boot to intramfs image in RAM:

1. Setup TFTP server to serve intramfs image.
2. Plug Ethernet cable into WAN port.
3. Unplug power, hold reset button and plug power in.
   Wait (~25 seconds) for beep and then release reset button.
   The SFP LED will be lit in RouterBoot, but will not be lit in OpenWRT.
4. Wait for a minute. Router should be running OpenWrt,
   check by plugging in to port 2-5 and going to 192.168.1.1.

To install OpenWrt to flash:

1. Follow steps above to boot intramfs image in RAM.
2. Flash the sysupgrade.bin image with web interface or sysupgrade.
3. Once the router reboots you will be running OpenWrt from flash.

OEM firmware differences:

- RouterOS assigns a different MAC address for each port
- The first address (E01 on the sticker) is used for wan (ether1 in OEM).
- The next address is used for lan2.
- The last address (E06 on the sticker) is used for sfp.

[Initial port work, shared dtsi]
Signed-off-by: Vince Grassia <vincenzo.grassia@zionark.com>
[SFP support and GPIO identification]
Signed-off-by: Luka Logar <luka.logar@iname.com>
[Misc. fixes and submission]
Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
[rebase, drop uart3 from state_default on 750gr3, minor commit
title/message facelift]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
target/linux/ramips/dts/mt7621_mikrotik_routerboard-750gr3.dts
target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts [new file with mode: 0644]
target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh

index 60315a46e7200bf4a98054405e631d0ab05fdaf9..baa42ee8edd759206fabfee636c8ee8387ebaf0d 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /dts-v1/;
 
-#include "mt7621_mikrotik.dtsi"
+#include "mt7621_mikrotik_routerboard-7xx.dtsi"
 
 / {
        compatible = "mikrotik,routerboard-750gr3", "mediatek,mt7621-soc";
                        gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
                };
        };
-
-       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 15 GPIO_ACTIVE_HIGH>;
-               };
-
-               usb_power {
-                       gpio-export,name = "usb_power";
-                       gpio-export,output = <1>;
-                       gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
-               };
-       };
-};
-
-&keys {
-       mode {
-               label = "mode";
-               gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
-               linux,code = <BTN_0>;
-       };
-};
-
-&partitions {
-       partition@40000 {
-               compatible = "mikrotik,minor";
-               label = "firmware";
-               reg = <0x040000 0xfc0000>;
-       };
-};
-
-&switch0 {
-       ports {
-               port@0 {
-                       status = "okay";
-                       label = "wan";
-               };
-
-               port@1 {
-                       status = "okay";
-                       label = "lan2";
-               };
-
-               port@2 {
-                       status = "okay";
-                       label = "lan3";
-               };
-
-               port@3 {
-                       status = "okay";
-                       label = "lan4";
-               };
-
-               port@4 {
-                       status = "okay";
-                       label = "lan5";
-               };
-       };
 };
 
 &state_default {
        gpio {
-               /* via gpio7 (uart3 group) the PoE status can be read */
-               groups = "uart2", "uart3", "jtag", "wdt";
+               groups = "uart2", "jtag", "wdt";
                function = "gpio";
        };
 };
-
-&sdhci {
-       status = "okay";
-};
diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-760igs.dts
new file mode 100644 (file)
index 0000000..dd2de11
--- /dev/null
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "mt7621_mikrotik_routerboard-7xx.dtsi"
+
+/ {
+       compatible = "mikrotik,routerboard-760igs", "mediatek,mt7621-soc";
+       model = "MikroTik RouterBOARD 760iGS";
+
+       aliases {
+               led-boot = &led_pwr;
+               led-failsafe = &led_pwr;
+               led-running = &led_pwr;
+               led-upgrade = &led_pwr;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_pwr: pwr {
+                       label = "routerboard-760igs:blue:pwr";
+                       gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
+                       default-state = "on";
+               };
+
+               sfp {
+                       label = "routerboard-760igs:blue:sfp";
+                       gpios = <&gpio 9 GPIO_ACTIVE_HIGH>;
+               };
+       };
+
+       sfp1: sfp1 {
+               compatible = "sff,sfp";
+               i2c-bus = <&i2c>;
+               los-gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
+               mod-def0-gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+               tx-disable-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+               maximum-power-milliwatt = <1000>;
+       };
+};
+
+&mdio {
+       ephy7: ethernet-phy@7 {
+               reg = <7>;
+               sfp = <&sfp1>;
+       };
+};
+
+&gmac1 {
+       status = "okay";
+
+       label = "sfp";
+       phy-handle = <&ephy7>;
+};
+
+&i2c {
+       status = "okay";
+};
+
+&state_default {
+       gpio {
+               /* gpio7 (uart3 group) goes high when
+                * port5 (PoE out) is cabled to a
+                * Mikrotik PoE-in capable port,
+                * such as port1 on another rb760iGS */
+               groups = "uart2", "uart3", "jtag", "wdt";
+               function = "gpio";
+       };
+};
diff --git a/target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi b/target/linux/ramips/dts/mt7621_mikrotik_routerboard-7xx.dtsi
new file mode 100644 (file)
index 0000000..b8fae51
--- /dev/null
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7621_mikrotik.dtsi"
+
+/ {
+       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 15 GPIO_ACTIVE_HIGH>;
+               };
+
+               usb_power {
+                       gpio-export,name = "usb_power";
+                       gpio-export,output = <1>;
+                       gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
+               };
+       };
+};
+
+&keys {
+       mode {
+               label = "mode";
+               gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+               linux,code = <BTN_0>;
+       };
+};
+
+&partitions {
+       partition@40000 {
+               compatible = "mikrotik,minor";
+               label = "firmware";
+               reg = <0x040000 0xfc0000>;
+       };
+};
+
+&switch0 {
+       ports {
+               port@0 {
+                       status = "okay";
+                       label = "wan";
+               };
+
+               port@1 {
+                       status = "okay";
+                       label = "lan2";
+               };
+
+               port@2 {
+                       status = "okay";
+                       label = "lan3";
+               };
+
+               port@3 {
+                       status = "okay";
+                       label = "lan4";
+               };
+
+               port@4 {
+                       status = "okay";
+                       label = "lan5";
+               };
+       };
+};
+
+&sdhci {
+       status = "okay";
+};
index 16b74c7b3e658db2844d1cca019d9ae8013e758c..060b322ea0835a909a32ad483e0adbaba337f752 100644 (file)
@@ -708,6 +708,13 @@ define Device/mikrotik_routerboard-750gr3
 endef
 TARGET_DEVICES += mikrotik_routerboard-750gr3
 
+define Device/mikrotik_routerboard-760igs
+  $(Device/MikroTik)
+  DEVICE_MODEL := RouterBOARD 760iGS
+  DEVICE_PACKAGES += kmod-sfp -wpad-basic
+endef
+TARGET_DEVICES += mikrotik_routerboard-760igs
+
 define Device/mikrotik_routerboard-m11g
   $(Device/MikroTik)
   DEVICE_MODEL := RouterBOARD M11G
index 63c0bce083c3e520495f5ac7072e7a218f824d62..8708de33c111ee3c4c28ecb9ad18bc7e18848089 100755 (executable)
@@ -48,6 +48,9 @@ linksys,ea7500-v2)
        ucidef_set_led_netdev "lan4" "lan4 link" "$boardname:green:lan4" "lan4" "link"
        ucidef_set_led_netdev "wan" "wan link" "$boardname:green:wan" "wan" "link"
        ;;
+mikrotik,routerboard-760igs)
+       ucidef_set_led_netdev "sfp" "SFP" "$boardname:blue:sfp" "sfp"
+       ;;
 mikrotik,routerboard-m11g)
        ucidef_set_rssimon "wlan0" "200000" "1"
        ucidef_set_led_rssi "rssilow" "RSSILOW" "$boardname:green:rssi0" "wlan0" "1" "100"
index b9f2740a1b6c0b84e251ec96a9f82af4aac4daca..cf3df76c08d0df90162f12df40a2ebc56239b071 100755 (executable)
@@ -48,6 +48,9 @@ ramips_setup_interfaces()
        mikrotik,routerboard-750gr3)
                ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
                ;;
+       mikrotik,routerboard-760igs)
+               ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan sfp"
+               ;;
        ubnt,edgerouter-x)
                ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4" "eth0"
                ;;
@@ -108,6 +111,7 @@ ramips_setup_macs()
                label_mac=$lan_mac
                ;;
        mikrotik,routerboard-750gr3|\
+       mikrotik,routerboard-760igs|\
        mikrotik,routerboard-m11g|\
        mikrotik,routerboard-m33g)
                label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
index 7787ddcbc7a7a9317019398fbacbe4357d599e2b..f809df7f2f94791d9c0dae25eb8b431e6b347356 100755 (executable)
@@ -7,6 +7,9 @@ board_config_update
 board=$(board_name)
 
 case "$board" in
+mikrotik,routerboard-760igs)
+       ucidef_add_gpio_switch "poe_passthrough" "PoE Passthrough" "497"
+       ;;
 telco-electronics,x1)
        ucidef_add_gpio_switch "modem_reset" "Modem Reset" "16"
        ;;
index a411a7a033db3eaa20b797083f2e4c075addc2cf..90749f589b93b154ecfc10a7dfd13a1532a49cca 100755 (executable)
@@ -28,6 +28,7 @@ platform_do_upgrade() {
                }
                ;;
        mikrotik,routerboard-750gr3|\
+       mikrotik,routerboard-760igs|\
        mikrotik,routerboard-m11g|\
        mikrotik,routerboard-m33g)
                [ -z "$(rootfs_type)" ] && mtd erase firmware