ath79: add support for MikroTik RouterBOARD 493G (rb4xx series)

This patch adds support for the MikroTik RouterBOARD RB493G, ported
from the ar71xx target.

See https://routerboard.com/RB493G for details

Specification:
- SoC Qualcomm Atheros AR7161
- RAM: 256 MiB
- Storage: 128MiB NAND
- Ethernet: 9x 1000/100/10 Mbps
- USB 1x 2.0 / 1.0 type A
- PCIe: 3x Mini slot
- MicroSD slot

Working:
- Board/system detection
- Ethernet
- SPI
- NAND
- LEDs
- USB
- Sysupgrade

Enabled (but untested due to lack of hardware):
- PCIe - ath79_pci_irq struct has the slot/pin/IRQ mappings if needed

Installation methods:
- tftp boot initramfs image, scp then flash via "sysupgrade -n"
- nand boot existing OpenWrt, scp then flash via "sysupgrade -n"

Notes:
- initramfs image will not work if uncompressed image size over ~8.5Mb
- The "rb4xx" drivers have been enabled

Signed-off-by: Christopher Hill <ch6574@gmail.com>
master
Christopher Hill 2020-05-25 21:10:00 -04:00 committed by Adrian Schmutzler
parent fa70b3a4bb
commit b7a8a54542
7 changed files with 259 additions and 0 deletions

View File

@ -16,6 +16,7 @@ menu "Target Images"
prompt "Compression" prompt "Compression"
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ar71xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ath79_mikrotik
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_lantiq default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_lantiq
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips

View File

@ -0,0 +1,180 @@
// SPDX-License-Identifier: GPL-1.0-or-later OR MIT
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "ar7100.dtsi"
/ {
aliases {
led-boot = &led_user;
led-failsafe = &led_user;
led-running = &led_user;
};
chosen {
bootargs = "console=ttyS0,115200";
};
leds {
compatible = "gpio-leds";
led_user: user {
label = "mikrotik:yellow:user";
gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
led1 {
label = "mikrotik:green:led1";
gpios = <&cpld_gpio 0 GPIO_ACTIVE_LOW>;
};
led2 {
label = "mikrotik:green:led2";
gpios = <&cpld_gpio 2 GPIO_ACTIVE_LOW>;
};
led3 {
label = "mikrotik:green:led3";
gpios = <&cpld_gpio 1 GPIO_ACTIVE_LOW>;
};
led4 {
label = "mikrotik:green:led4";
gpios = <&cpld_gpio 3 GPIO_ACTIVE_LOW>;
};
led5 {
label = "mikrotik:green:led5";
gpios = <&cpld_gpio 8 GPIO_ACTIVE_LOW>;
};
};
};
&uart {
status = "okay";
};
&gpio {
ngpios = <31>;
gpio-line-names =
"", "", "", "", "LED", "RDY", "", "MDC",
"MDIO", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "";
};
&pcie0 {
status = "okay";
};
&spi {
status = "okay";
compatible = "mikrotik,rb4xx-spi";
flash@0 {
compatible = "pm25lv512", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
partitions {
compatible = "mikrotik,routerboot-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "routerboot1";
reg = <0x0 0x0>;
read-only;
};
hard_config {
label = "hard_config";
read-only;
};
bios {
label = "bios";
size = <0x1000>;
read-only;
};
routerboot2 {
label = "routerboot2";
read-only;
};
soft_config {
label = "soft_config";
};
};
};
cpld@1 {
compatible = "mikrotik,rb4xx-cpld";
reg = <1>;
spi-max-frequency = <25000000>;
cpld_gpio: gpio {
compatible = "mikrotik,rb4xx-gpio";
base = <32>;
gpio-controller;
#gpio-cells = <2>;
gpio-line-names =
"LED1", "LED2", "LED3", "LED4",
"FAN", "ALE", "CLE", "nCE",
"LED5";
};
nand {
compatible = "mikrotik,rb4xx-nand";
gpios = <&cpld_gpio 5 GPIO_ACTIVE_HIGH>, // ALE
<&cpld_gpio 6 GPIO_ACTIVE_HIGH>, // CLE
<&cpld_gpio 7 GPIO_ACTIVE_HIGH>, // nCE
<&gpio 5 GPIO_ACTIVE_HIGH>; // RDY
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "booter";
reg = <0x0000000 0x0040000>;
read-only;
};
partition@40000 {
label = "kernel";
reg = <0x0040000 0x0800000>;
};
partition@840000 {
label = "ubi";
reg = <0x0840000 0x77c0000>;
};
};
};
};
};
&eth0 {
status = "okay";
phy-handle = <&phy0>;
};
&mdio0 {
status = "okay";
phy0: ethernet-phy@0 {
reg = <0>;
};
};

View File

@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-1.0-or-later OR MIT
/dts-v1/;
#include "ar7100_mikrotik_routerboard-4xx.dtsi"
/ {
compatible = "mikrotik,routerboard-493g", "qca,ar7161";
model = "MikroTik RouterBOARD 493G";
aliases {
mdio-gpio0 = &mdio_gpio0;
};
};
&spi {
sdcard: mmc-slot@2 {
compatible = "mmc-spi-slot";
reg = <2>;
spi-max-frequency = <25000000>;
};
};
&eth1 {
status = "okay";
phy-handle = <&gpio_phy0>;
mdio_gpio0: mdio-gpio {
compatible = "virtual,mdio-gpio";
#address-cells = <1>;
#size-cells = <0>;
gpios = <&gpio 7 GPIO_ACTIVE_HIGH>, // MDC
<&gpio 8 GPIO_ACTIVE_HIGH>; // MDIO
gpio_phy0: ethernet-phy@0 {
reg = <0>;
};
};
};
&usb_phy {
status = "okay";
};
&usb2 {
status = "okay";
};
&usb1 {
status = "okay";
};

View File

@ -1,5 +1,16 @@
include ./common-mikrotik.mk include ./common-mikrotik.mk
define Device/mikrotik_routerboard-493g
$(Device/mikrotik)
SOC := ar7161
DEVICE_MODEL := RouterBOARD 493G
IMAGE/sysupgrade.bin = append-kernel | kernel2minor -s 2048 -e -c | \
sysupgrade-tar kernel=$$$$@ | append-metadata
DEVICE_PACKAGES += kmod-usb-ohci kmod-usb2 nand-utils
SUPPORTED_DEVICES += rb-493g
endef
TARGET_DEVICES += mikrotik_routerboard-493g
define Device/mikrotik_routerboard-922uags-5hpacd define Device/mikrotik_routerboard-922uags-5hpacd
$(Device/mikrotik) $(Device/mikrotik)
SOC := qca9558 SOC := qca9558

View File

@ -8,6 +8,13 @@ ath79_setup_interfaces()
local board="$1" local board="$1"
case "$board" in case "$board" in
mikrotik,routerboard-493g)
ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth0.2"
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:4" "2:lan:1" "3:lan:3" "4:lan:2" "5:wan"
ucidef_add_switch "switch1" \
"0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
;;
mikrotik,routerboard-922uags-5hpacd|\ mikrotik,routerboard-922uags-5hpacd|\
mikrotik,routerboard-wap-g-5hact2hnd) mikrotik,routerboard-wap-g-5hact2hnd)
ucidef_set_interface_lan "eth0" ucidef_set_interface_lan "eth0"

View File

@ -31,6 +31,7 @@ platform_do_upgrade() {
local board=$(board_name) local board=$(board_name)
case "$board" in case "$board" in
mikrotik,routerboard-493g|\
mikrotik,routerboard-922uags-5hpacd) mikrotik,routerboard-922uags-5hpacd)
platform_do_upgrade_mikrotik_nand "$1" platform_do_upgrade_mikrotik_nand "$1"
;; ;;

View File

@ -2,16 +2,20 @@ CONFIG_AT803X_PHY=y
CONFIG_CRC16=y CONFIG_CRC16=y
CONFIG_CRYPTO_DEFLATE=y CONFIG_CRYPTO_DEFLATE=y
CONFIG_GPIO_LATCH=y CONFIG_GPIO_LATCH=y
CONFIG_GPIO_RB4XX=y
CONFIG_GPIO_WATCHDOG=y CONFIG_GPIO_WATCHDOG=y
CONFIG_GPIO_WATCHDOG_ARCH_INITCALL=y CONFIG_GPIO_WATCHDOG_ARCH_INITCALL=y
CONFIG_LEDS_RESET=y CONFIG_LEDS_RESET=y
CONFIG_LZO_DECOMPRESS=y CONFIG_LZO_DECOMPRESS=y
CONFIG_MDIO_GPIO=y
CONFIG_MFD_RB4XX_CPLD=y
CONFIG_MIKROTIK=y CONFIG_MIKROTIK=y
CONFIG_MIKROTIK_RB_SYSFS=y CONFIG_MIKROTIK_RB_SYSFS=y
CONFIG_MTD_NAND=y CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_AR934X=y CONFIG_MTD_NAND_AR934X=y
CONFIG_MTD_NAND_CORE=y CONFIG_MTD_NAND_CORE=y
CONFIG_MTD_NAND_ECC=y CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_NAND_RB4XX=y
CONFIG_MTD_RAW_NAND=y CONFIG_MTD_RAW_NAND=y
CONFIG_MTD_ROUTERBOOT_PARTS=y CONFIG_MTD_ROUTERBOOT_PARTS=y
CONFIG_MTD_SPI_NAND=y CONFIG_MTD_SPI_NAND=y
@ -24,10 +28,12 @@ CONFIG_MTD_UBI_BEB_LIMIT=20
# CONFIG_MTD_UBI_FASTMAP is not set # CONFIG_MTD_UBI_FASTMAP is not set
# CONFIG_MTD_UBI_GLUEBI is not set # CONFIG_MTD_UBI_GLUEBI is not set
CONFIG_NET_SWITCHDEV=y CONFIG_NET_SWITCHDEV=y
CONFIG_PCI_AR71XX=y
CONFIG_PHY_AR7100_USB=y CONFIG_PHY_AR7100_USB=y
CONFIG_PHY_AR7200_USB=y CONFIG_PHY_AR7200_USB=y
CONFIG_REGULATOR=y CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_SPI_RB4XX=y
CONFIG_UBIFS_FS=y CONFIG_UBIFS_FS=y
CONFIG_UBIFS_FS_ADVANCED_COMPR=y CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_UBIFS_FS_LZO=y CONFIG_UBIFS_FS_LZO=y