[RFC v2 3/3] ath79: add support for Mikrotik RouterBoard 912G

Sergey Ryazanov ryazanov.s.a at gmail.com
Sun May 23 18:37:28 PDT 2021


On Fri, May 21, 2021 at 2:05 PM Denis Kalashnikov <denis281089 at gmail.com> wrote:
>
> This board has been supported in the ar71xx.
>
> Links:
> * https://mikrotik.com/product/RB912UAG-2HPnD
> * https://mikrotik.com/product/RB912UAG-5HPnD
> * https://openwrt.org/toh/hwdata/mikrotik/mikrotik_rb912uag-2hpnd
> * https://openwrt.org/toh/hwdata/mikrotik/mikrotik_rb912uag-5hpnd
>
> Hardware:
> * SoC: Atheros AR9342,
> * RAM: DDR 64MB,
> * SPI NOR: 64KB,
> * NAND: 128MB,
> * Ethernet: x1 10/100/1000 port with passive POE in,
> * Wi-Fi: 802.11bgn,
> * PCIe,
> * USB: 2.0 EHCI controller, connected to mPCIe slot and a Type-A
>   port -- both can be used for LTE modem. But only one can be used.
> * LEDs: 5 general purpose LEDs (led1..led5), power LED, user LED,
>   Ethernet phy LED,
> * Button,
> * Beeper.
>
> Not working:
> * Button: it shares gpio line 15 with NAND ALE and NAND IO7,
>   and current drivers doesn't easily support this configuration,
> * Beeper: it is connected to bit 5 of a serial shift register
>   (tested with sysfs led trigger timer). But kmod-gpio-beeper
>   doesn't work -- we left this as is for now.
>
> You can flash image by sysupgrade utility or load it by net
> (by DHCP/TFTP, hold the button while booting).
>
> Co-Developed-by: Koen Vandeputte <koen.vandeputte at citymesh.com>
> Signed-off-by: Denis Kalashnikov <denis281089 at gmail.com>
> ---
>
> Changelog:
>
> v1->v2:
> - Delete uneeded comments from DTS,
> - Delete ascii-art of board scheme near NAND latch from DTS,
> - Rewrite gpio_latch and nand_gpio nodes to be consistent with the
>   new versions of drivers,
> - Fix SPI NOR flash and SPI serial shift register maximum speeds
>   (thanks to Koen Vandeputte),
> - Add UART, PCIe, USB support and gpio exports (thanks to Koen Vandeputte),
> - Fix Ethernet node (thanks to Koen Vandeputte),
> - Add key and beeper nodes in disabled state just to be documented.
>
> ---
>  .../dts/ar9342_mikrotik_routerboard-912g.dts  | 233 ++++++++++++++++++
>  target/linux/ath79/image/mikrotik.mk          |   9 +
>  .../base-files/etc/board.d/02_network         |   2 +
>  .../etc/hotplug.d/firmware/10-ath9k-eeprom    |   1 +
>  .../base-files/lib/upgrade/platform.sh        |   1 +
>  5 files changed, 246 insertions(+)
>  create mode 100644 target/linux/ath79/dts/ar9342_mikrotik_routerboard-912g.dts
>
> diff --git a/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912g.dts b/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912g.dts
> new file mode 100644
> index 0000000000..a23fc04a99
> --- /dev/null
> +++ b/target/linux/ath79/dts/ar9342_mikrotik_routerboard-912g.dts
> @@ -0,0 +1,233 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +#include "ar9344.dtsi"
> +
> +#include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/input/input.h>
> +
> +/ {
> +       compatible = "mikrotik,routerboard-912g", "qca,ar9342";
> +       model = "Mikrotik RouterBoard 912G";
> +
> +       leds {
> +               compatible = "gpio-leds";
> +
> +               led_power {
> +                       label = "green:power";
> +                       gpios = <&gpio_latch 1 GPIO_ACTIVE_HIGH>;
> +                       default-state = "on";
> +               };
> +
> +               led_user {
> +                       label = "green:user";
> +                       gpios = <&gpio_latch 2 GPIO_ACTIVE_HIGH>;
> +               };
> +
> +               led1 {
> +                       label = "green:led1";
> +                       gpios = <&ssr 0 GPIO_ACTIVE_HIGH>;
> +               };
> +
> +               led2 {
> +                       label = "green:led2";
> +                       gpios = <&ssr 1 GPIO_ACTIVE_HIGH>;
> +               };
> +
> +               led3 {
> +                       label = "green:led3";
> +                       gpios = <&ssr 2 GPIO_ACTIVE_HIGH>;
> +               };
> +
> +               led4 {
> +                       label = "green:led4";
> +                       gpios = <&ssr 3 GPIO_ACTIVE_HIGH>;
> +               };
> +
> +               led5 {
> +                       label = "green:led5";
> +                       gpios = <&ssr 4 GPIO_ACTIVE_HIGH>;
> +               };
> +       };
> +
> +       beeper {
> +               status = "disabled";
> +               compatible = "gpio-beeper";
> +               gpios = <&ssr 5 GPIO_ACTIVE_HIGH>;
> +       };
> +
> +       keys {
> +               status = "disabled";
> +               compatible = "gpio-keys";
> +               reset {
> +                       label = "reset";
> +                       linux,code = <KEY_RESTART>;
> +                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
> +                       debounce-interval = <60>;
> +               };
> +       };
> +
> +       gpio_export {
> +               compatible = "gpio-export";
> +
> +               usb_select {
> +                       label = "select:usb";
> +                       gpio-export,name = "mikrotik:select:usb";
> +                       gpio-export,output = <0>; /* 0: mini-pcie, 1: Type-A port */
> +                       gpios = <&ssr 6 GPIO_ACTIVE_LOW>;
> +               };
> +
> +               pcie_power {
> +                       label = "power:pcie";
> +                       gpio-export,name = "mikrotik:power:pcie";
> +                       gpio-export,output = <1>;
> +                       gpios = <&ssr 7 GPIO_ACTIVE_LOW>;
> +               };
> +       };
> +};
> +
> +&ahb {

I am just curious, why did you place beeper and LEDs in the root node,
but specify latch and NAND as the AHB bus child nodes?

> +       gpio_latch: gpio_latch {
> +               compatible = "gpio-latch";
> +               gpio-controller;
> +               #gpio-cells = <2>;
> +               gpios = <&gpio 0 0>,
> +                       <&gpio 1 0>,
> +                       <&gpio 2 0>,
> +                       <&gpio 3 0>,
> +                       <&gpio 4 0>,
> +                       <&gpio 13 0>,
> +                       <&gpio 14 0>,
> +                       <&gpio 15 0>,
> +                       <&gpio 11 0>;
> +               latch-enable-gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
> +       };
> +
> +       nand_gpio {
> +               compatible = "rb91x-nand";

Should this be "mikrotik,rb91x-nand"?

> +               /* NAND control gpios */
> +               read-gpios = <&gpio_latch 3 GPIO_ACTIVE_HIGH>;
> +               rdy-gpios  = <&gpio_latch 4 GPIO_ACTIVE_HIGH>;
> +               nce-gpios  = <&gpio_latch 5 GPIO_ACTIVE_LOW>; /* Chip Enable */
> +               cle-gpios  = <&gpio_latch 6 GPIO_ACTIVE_HIGH>; /* Command Latch */
> +               ale-gpios  = <&gpio_latch 7 GPIO_ACTIVE_HIGH>; /* Address Latch */
> +               nrw-gpios  = <&gpio 12 GPIO_ACTIVE_LOW>; /* Read/Write */

Why did you use so complex set of properties for configuration? You
anyway add comments to a large portion of properties. So why do not
follow the 'gpio-control-nand' driver approach and simply use a single
'gpios' array?

> +
> +               latch-enable-gpios = <&gpio_latch 8 GPIO_ACTIVE_LOW>;
> +
> +               partitions {
> +                       compatible = "fixed-partitions";
> +                       #size-cells = <1>;
> +
> +                       partition at 0 {
> +                               label = "booter";
> +                               reg = <0x0 0x0040000>;
> +                               read-only;
> +                       };
> +
> +                       partition at 40000 {
> +                               label = "kernel";
> +                               reg = <0x0040000 0x03c0000>;
> +                       };
> +
> +                       partition at 400000 {
> +                               label = "ubi";
> +                               reg = <0x0400000 0x7c00000>;
> +                       };
> +               };
> +       };
> +};
> +
> +&spi {
> +       status = "okay";
> +
> +       compatible = "qca,ar7100-spi";
> +
> +       cs-gpios = <0>, <&gpio_latch 0 GPIO_ACTIVE_LOW>;
> +
> +       flash at 0 {
> +               compatible = "jedec,spi-nor";
> +               reg = <0>;
> +               spi-max-frequency = <80000000>;
> +
> +               partitions {
> +                       compatible = "mikrotik,routerboot-partitions";
> +                       #address-cells = <1>;
> +                       #size-cells = <1>;
> +
> +                       partition at 0 {
> +                               label = "routerboot";
> +                               reg = <0x0 0x0>;
> +                               read-only;
> +                       };
> +
> +                       hard_config: hard_config {
> +                               read-only;
> +                       };
> +
> +                       bios {
> +                               size = <0x1000>;
> +                               read-only;
> +                       };
> +
> +                       soft_config {
> +                       };
> +               };
> +       };
> +
> +       ssr: ssr at 1 {
> +               compatible = "fairchild,74hc595";
> +               gpio-controller;
> +               #gpio-cells = <2>;
> +               registers-number = <1>;
> +               reg = <1>;
> +               spi-max-frequency = <50000000>;
> +       };
> +};
> +
> +&pcie {
> +       status = "okay";
> +};
> +
> +&uart {
> +       status = "okay";
> +};
> +
> +&mdio0 {
> +       status = "okay";
> +
> +       phy-mask = <0>;
> +
> +       phy0: ethernet-phy at 0 {
> +               reg = <0>;
> +       };
> +};
> +
> +&eth0 {
> +       status = "okay";
> +
> +       phy-mode = "rgmii-id";
> +       phy-handle = <&phy0>;
> +       pll-data = <0x02000000 0x00000101 0x00001313>;
> +
> +       gmac-config {
> +               device = <&gmac>;
> +               rgmii-gmac0 = <1>;
> +               rgmii-enabled = <1>;
> +               rxd-delay = <1>;
> +               txd-delay = <1>;
> +       };
> +};
> +
> +&wmac {
> +       status = "okay";
> +       qca,no-eeprom;
> +};
> +
> +&usb {
> +       status = "okay";
> +};
> +
> +&usb_phy {
> +       status = "okay";
> +};

--
Sergey



More information about the openwrt-devel mailing list