Re: [PATCH] ath79: add support for Mikrotik SXT-R LTE

2022-03-07 Thread Sergey Ryazanov
Hello Mike,

On Fri, Mar 4, 2022 at 9:54 PM mk 378  wrote:
> This adds support for the Mikrotik SXT-R LTE device, which is an
> outdoor router that hosts an LTE modem mini PCIe card for its WAN
> connection.  The LTE antenna system claims a 9 dBi gain.
>
> Hardware:
> - SoC: QCA9531
> - Flash: 16 MiB SPI NOR
> - RAM: 64 MiB DDR2
> - WiFi: None (no antenna is connected to the SoC WiFi system)
> - Ethernet: 2 x 10/100 Mb.
> - PoE: Passive or 802.3af in on port 1.  Unit must be powered by PoE.
>GPIO switchable passive PoE out on port 2.
> - Modem support: Mini PCIe slot wired only for USB2, no PCIe bus.
>Dual LTE antennas, two MicroSIM slots-- SIM card in use is
>selected by a GPIO output.  GPIO control of the 3.3 volt power
>to the slot, and hardware control pins 22 and 20.
> - Serial: There is a set of 10 test pads on board near the flash chip.
>Pin 6 is RX and pin 7 is Tx.  Tx GPIO pin is shared with the
>yellow LED on the eth1 socket.  This DTS sets it as serial
>output for OpenWrt.  The bootloader does not use serial.
> - LEDs: Power, LTE, 2x Ethernet Link, PoE out, 5x LTE signal level
> - Buttons: Reset, Mode
>
> Installation:  Standard MikroTik-- RouterBOOT netboot the OpenWrt
> initramfs image, then flash the sysupgrade image from within OpenWrt.
> Under OpenWrt, the eth1 port (with PoE in) defaults to be LAN,
> and eth2 is WAN.
>
> Signed-off-by: Mike Keitz 

Please, do not mask the email address in the SoB line.

All whitespaces in the patch were mangled, probably by the gmail web
interface. Consider using git-send-email(1) to submit the patch.

> diff --git a/target/linux/ath79/image/mikrotik.mk
> b/target/linux/ath79/image/mikrotik.mk
> index ff3604f2fa..ad29158156 100644
> --- a/target/linux/ath79/image/mikrotik.mk
> +++ b/target/linux/ath79/image/mikrotik.mk
> @@ -64,6 +64,15 @@ define Device/mikrotik_routerboard-sxt-5nd-r2
>  endef
>  TARGET_DEVICES += mikrotik_routerboard-sxt-5nd-r2
>
> +define Device/mikrotik_routerboard-sxtr
> +  $(Device/mikrotik_nor)
> +  SOC := qca9531
> +  DEVICE_MODEL := RouterBOARD SXTR (SXT-LTE)
> +  DEVICE_PACKAGES += kmod-usb2 kmod-gpio-nxp-74hc164

If the only WAN interface is an LTE modem, should the firmware include
a package with a modem driver?

> +  IMAGE_SIZE := 16256k
> +endef
> +TARGET_DEVICES += mikrotik_routerboard-sxtr
> +
>  define Device/mikrotik_routerboard-wap-g-5hact2hnd
>$(Device/mikrotik_nor)
>SOC := qca9556
> diff --git a/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
> b/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
> index 25c0184568..1c91c57f38 100644
> --- a/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
> +++ b/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
> @@ -32,6 +32,10 @@ mikrotik,routerboard-sxt-5nd-r2)
>   ucidef_set_led_rssi "rssimediumhigh" "rssimediumhigh"
> "green:rssimediumhigh" "wlan0" "60" "100"
>   ucidef_set_led_rssi "rssihigh" "rssihigh" "green:rssihigh" "wlan0" "80" 
> "100"
>   ;;
> +mikrotik,routerboard-sxtr)
> +ucidef_set_led_netdev "eth1" "eth1" "green:eth1" "eth1"
> +ucidef_set_led_switch "eth2" "eth2" "green:eth2" "switch0"
> "4" "6" "link tx rx"
> +;;
>  esac
>
>  board_config_flush
> 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 1a205e439c..90a018658b 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
> @@ -22,6 +22,9 @@ ath79_setup_interfaces()
>   mikrotik,routerboard-wapr-2nd)
>   ucidef_set_interface_lan "eth0"
>   ;;
> +mikrotik,routerboard-sxtr)
> +ucidef_set_interfaces_lan_wan "eth1" "eth0"
> +;;
>   *)
>   ucidef_set_interfaces_lan_wan "eth0" "eth1"
>   ;;
> diff --git a/target/linux/ath79/dts/qca9531_mikrotik_routerboard-sxtr.dts
> b/target/linux/ath79/dts/qca9531_mikrotik_routerboard-sxtr.dts
> new file mode 100644
> index 00..acd8c3e4eb
> --- /dev/null
> +++ b/target/linux/ath79/dts/qca9531_mikrotik_routerboard-sxtr.dts
> @@ -0,0 +1,192 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
> +
> +#include "qca9533_mikrotik_routerboard-16m.dtsi"
> +
> +/ {
> + compatible = "mikrotik,routerboard-sxtr", "qca,qca9533";
> + model = "MikroTik RouterBOARD SXTR (SXT-LTE)";
> +
> + aliases {
> + led-boot = &led_power;
> + led-failsafe = &led_power;
> + led-upgrade = &led_power;
> + led-running = &led_power;
> + };
> +
> + leds {
> + compatible = "gpio-leds";
> + pinctrl-names = "default";
> +
> + led_power: power {
> + label = "green:power";
> + gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
> + };
> +
> + lte {
> + label = "green:lte";
> + gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
> + };
> +
> + eth1green {
> + label = "green:eth1";
> + gpios = <&gpio 2 GPIO_ACTIVE_LOW>;

[PATCH] ath79: add support for Mikrotik SXT-R LTE

2022-03-04 Thread mk 378
This adds support for the Mikrotik SXT-R LTE device, which is an
outdoor router that hosts an LTE modem mini PCIe card for its WAN
connection.  The LTE antenna system claims a 9 dBi gain.

Hardware:
- SoC: QCA9531
- Flash: 16 MiB SPI NOR
- RAM: 64 MiB DDR2
- WiFi: None (no antenna is connected to the SoC WiFi system)
- Ethernet: 2 x 10/100 Mb.
- PoE: Passive or 802.3af in on port 1.  Unit must be powered by PoE.
   GPIO switchable passive PoE out on port 2.
- Modem support: Mini PCIe slot wired only for USB2, no PCIe bus.
   Dual LTE antennas, two MicroSIM slots-- SIM card in use is
   selected by a GPIO output.  GPIO control of the 3.3 volt power
   to the slot, and hardware control pins 22 and 20.
- Serial: There is a set of 10 test pads on board near the flash chip.
   Pin 6 is RX and pin 7 is Tx.  Tx GPIO pin is shared with the
   yellow LED on the eth1 socket.  This DTS sets it as serial
   output for OpenWrt.  The bootloader does not use serial.
- LEDs: Power, LTE, 2x Ethernet Link, PoE out, 5x LTE signal level
- Buttons: Reset, Mode

Installation:  Standard MikroTik-- RouterBOOT netboot the OpenWrt
initramfs image, then flash the sysupgrade image from within OpenWrt.
Under OpenWrt, the eth1 port (with PoE in) defaults to be LAN,
and eth2 is WAN.

Signed-off-by: Mike Keitz 

diff --git a/target/linux/ath79/image/mikrotik.mk
b/target/linux/ath79/image/mikrotik.mk
index ff3604f2fa..ad29158156 100644
--- a/target/linux/ath79/image/mikrotik.mk
+++ b/target/linux/ath79/image/mikrotik.mk
@@ -64,6 +64,15 @@ define Device/mikrotik_routerboard-sxt-5nd-r2
 endef
 TARGET_DEVICES += mikrotik_routerboard-sxt-5nd-r2

+define Device/mikrotik_routerboard-sxtr
+  $(Device/mikrotik_nor)
+  SOC := qca9531
+  DEVICE_MODEL := RouterBOARD SXTR (SXT-LTE)
+  DEVICE_PACKAGES += kmod-usb2 kmod-gpio-nxp-74hc164
+  IMAGE_SIZE := 16256k
+endef
+TARGET_DEVICES += mikrotik_routerboard-sxtr
+
 define Device/mikrotik_routerboard-wap-g-5hact2hnd
   $(Device/mikrotik_nor)
   SOC := qca9556
diff --git a/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
b/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
index 25c0184568..1c91c57f38 100644
--- a/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
@@ -32,6 +32,10 @@ mikrotik,routerboard-sxt-5nd-r2)
  ucidef_set_led_rssi "rssimediumhigh" "rssimediumhigh"
"green:rssimediumhigh" "wlan0" "60" "100"
  ucidef_set_led_rssi "rssihigh" "rssihigh" "green:rssihigh" "wlan0" "80" "100"
  ;;
+mikrotik,routerboard-sxtr)
+ucidef_set_led_netdev "eth1" "eth1" "green:eth1" "eth1"
+ucidef_set_led_switch "eth2" "eth2" "green:eth2" "switch0"
"4" "6" "link tx rx"
+;;
 esac

 board_config_flush
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 1a205e439c..90a018658b 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
@@ -22,6 +22,9 @@ ath79_setup_interfaces()
  mikrotik,routerboard-wapr-2nd)
  ucidef_set_interface_lan "eth0"
  ;;
+mikrotik,routerboard-sxtr)
+ucidef_set_interfaces_lan_wan "eth1" "eth0"
+;;
  *)
  ucidef_set_interfaces_lan_wan "eth0" "eth1"
  ;;
diff --git a/target/linux/ath79/dts/qca9531_mikrotik_routerboard-sxtr.dts
b/target/linux/ath79/dts/qca9531_mikrotik_routerboard-sxtr.dts
new file mode 100644
index 00..acd8c3e4eb
--- /dev/null
+++ b/target/linux/ath79/dts/qca9531_mikrotik_routerboard-sxtr.dts
@@ -0,0 +1,192 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "qca9533_mikrotik_routerboard-16m.dtsi"
+
+/ {
+ compatible = "mikrotik,routerboard-sxtr", "qca,qca9533";
+ model = "MikroTik RouterBOARD SXTR (SXT-LTE)";
+
+ aliases {
+ led-boot = &led_power;
+ led-failsafe = &led_power;
+ led-upgrade = &led_power;
+ led-running = &led_power;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ pinctrl-names = "default";
+
+ led_power: power {
+ label = "green:power";
+ gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+ };
+
+ lte {
+ label = "green:lte";
+ gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ eth1green {
+ label = "green:eth1";
+ gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
+ };
+
+ eth2green {
+ label = "green:eth2";
+ gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
+ };
+
+ eth2yellow {
+ label = "yellow:eth2";
+ gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
+ };
+
+ signal0 {
+ label = "green:rssilow";
+ gpios = <&gpio_ext 2 GPIO_ACTIVE_LOW>;
+ };
+
+ signal1 {
+ label = "green:rssimediumlow";
+ gpios = <&gpio_ext 3 GPIO_ACTIVE_LOW>;
+ };
+
+ signal2 {
+ label = "green:rssimedium";
+ gpios = <&gpio_ext 4 GPIO_ACTIVE_LOW>;
+ };
+
+ signal3 {
+ label = "green:rssimediumhigh";
+ gpios = <&gpio_ext 5 GPIO_ACTIVE_LOW>;
+ };
+
+ signal4 {
+ label = "green:rssihigh";
+ gpios = <&gpio_e