mediatek: add support for Mercusys MR80X v3

This commit adds support for Mercusys MR80X(EU) v3 router.

Device specification:
 - SoC: Mediatek MT7981b, Cortex-A53, 64-bit
 - RAM: 512MB
 - Flash: SPI NAND GigaDevice GD5F1GQ5UEYIGY (128 MB)
 - Ethernet: 4x 100/1000 Mbps LAN1,LAN2,LAN3 & WAN
 - Wireless: 2.4GHz (802.11 b/g/n/ax)
 - Wireless: 5GHz (802.11 a/n/ac/ax)
 - LEDs: 1 orange and 1 green status LEDs, 4 green gpio-controlled LEDs
   on ethernet ports
 - Buttons: 1 (Reset)
 - Bootloader: Main U-Boot - U-Boot 2022.01-rc4. Additionally, both UBI
   slots contain "seconduboot" (also U-Boot 2022.01-rc4)

Installation (UART):
 - Place OpenWrt sysupgrade image on tftp server with IP 192.168.1.2
 - Attach UART, switch on the router and interrupt the boot process by
   pressing 'Ctrl-C'.
 - Upload the sysupgrade.bin via tftp.
   setenv serverip 192.168.1.2; setenv ipaddr 192.168.1.1; tftp
    0x40001000 sysupgrade.bin
 - Erase "ubi0" part, and write the image.
   nand erase.spread 0x300000 0x3200000; nand write.spread 0x40001000
    0x300000 0x3200000
 - Set the uboot environment for startup.
   setenv tp_boot_idx 0; setenv bootcmd bootm 0x46000000; saveenv
 - Reboot the router by reconnecting the power.

Recovery:
 - Press Reset button and power on the router.
 - Navigate to U-Boot recovery web server (http://192.168.1.1/) and
   upload the OEM firmware.

Stock layout:
0x000000000000-0x000000200000 : "boot"
0x000000200000-0x000000300000 : "u-boot-env"
0x000000300000-0x000003500000 : "ubi0"
0x000003500000-0x000006700000 : "ubi1"
0x000006700000-0x000006f00000 : "userconfig"
0x000006f00000-0x000007300000 : "tp_data"

ubi0/ubi1 format:
U-Boot at boot checks that all volumes are in place:
+-------------------------------+
| Volume Name: uboot   Vol ID: 0|
| Volume Name: kernel  Vol ID: 1|
| Volume Name: rootfs  Vol ID: 2|
+-------------------------------+

MAC addresses:
+---------+-------------------+-----------+
|         | MAC               | Algorithm |
+---------+-------------------+-----------+
| label   | 94:0C:xx:xx:xx:12 | label     |
| WLAN 2g | 94:0C:xx:xx:xx:11 | label-1   |
| WLAN 5g | 94:0C:xx:xx:xx:10 | label-2   |
+---------+-------------------+-----------+
label MAC address was found in UBI partition "tp_data", file
"default-mac".

Signed-off-by: zib zic <zibzicoooo@protonmail.com>
This commit is contained in:
zib zic 2024-12-17 15:02:22 -07:00
parent b4cc5743d9
commit 9be1fce0ce
5 changed files with 376 additions and 0 deletions

View File

@ -0,0 +1,350 @@
/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include "mt7981.dtsi"
/ {
model = "MediaTek MT7981 RFB";
compatible = "mercusys,mr80x-v3";
chosen {
bootargs = "console=ttyS0,115200n1 loglevel=8 \
earlycon=uart8250,mmio32,0x11002000 \
init=/etc/preinit";
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gpio-keys-polled {
compatible = "gpio-keys-polled";
poll-interval = <100>;
reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 1 GPIO_ACTIVE_LOW>;
linux,input-type = <1>;
};
};
leds {
compatible = "gpio-leds";
orange {
label = "orange";
default-state = "on";
gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
};
green {
label = "green";
default-state = "off";
gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
};
wan {
label = "wan";
default-state = "off";
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
};
lan1 {
label = "lan1";
default-state = "off";
gpios = <&pio 6 GPIO_ACTIVE_LOW>;
};
lan2 {
label = "lan2";
default-state = "off";
gpios = <&pio 7 GPIO_ACTIVE_LOW>;
};
lan3 {
label = "lan3";
default-state = "off";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
};
};
sound_wm8960 {
compatible = "mediatek,mt79xx-wm8960-machine";
mediatek,platform = <&afe>;
audio-routing = "Headphone", "HP_L",
"Headphone", "HP_R",
"LINPUT1", "AMIC",
"RINPUT1", "AMIC";
mediatek,audio-codec = <&wm8960>;
status = "disabled";
};
sound_si3218x {
compatible = "mediatek,mt79xx-si3218x-machine";
mediatek,platform = <&afe>;
mediatek,ext-codec = <&proslic_spi>;
status = "disabled";
};
};
&afe {
pinctrl-names = "default";
pinctrl-0 = <&pcm_pins>;
status = "okay";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "disabled";
wm8960: wm8960@1a {
compatible = "wlf,wm8960";
reg = <0x1a>;
};
};
&uart0 {
status = "okay";
};
&watchdog {
status = "okay";
};
&eth {
status = "okay";
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
gmac1: mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "gmii";
nick-index = <4>;
phy-handle = <&phy0>;
phy-link {
speed = <1000>;
full-duplex;
};
};
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
phy5: phy@5 {
compatible = "ethernet-phy-id67c9.de0a";
reg = <5>;
reset-gpios = <&pio 14 1>;
reset-assert-us = <600>;
reset-deassert-us = <20000>;
phy-mode = "2500base-x";
partner_gmac = <0>;
};
phy6: phy@6 {
compatible = "ethernet-phy-id67c9.de0a";
reg = <6>;
phy-mode = "2500base-x";
partner_gmac = <1>;
};
phy0: ethernet-phy@0 {
compatible = "ethernet-phy-id03a2.9461";
reg = <0>;
phy-mode = "gmii";
nvmem-cells = <&phy_calibration>;
nvmem-cell-names = "phy-cal-data";
};
switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 39 0>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@1 {
reg = <1>;
label = "lan1";
};
port@2 {
reg = <2>;
label = "lan2";
};
port@3 {
reg = <3>;
label = "lan3";
};
port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
};
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_flash_pins>;
status = "okay";
spi_nand: spi_nand@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <52000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
partition@0 {
label = "boot";
reg = <0x00000 0x0200000>;
read-only;
};
partition@200000 {
label = "u-boot-env";
reg = <0x0200000 0x0100000>;
};
partition@300000 {
label = "ubi0";
reg = <0x300000 0x3200000>;
};
partition@3500000 {
label = "ubi1";
reg = <0x3500000 0x3200000>;
};
partition@6700000 {
label = "userconfig";
reg = <0x6700000 0x800000>;
};
factory:partition@6f00000 {
label = "tp_data";
reg = <0x6f00000 0x800000>;
};
};
};
&spi1 {
pinctrl-names = "default";
pinctrl-0 = <&spic_pins>;
status = "okay";
proslic_spi: proslic_spi@0 {
compatible = "silabs,proslic_spi";
reg = <0>;
spi-max-frequency = <10000000>;
spi-cpha = <1>;
spi-cpol = <1>;
channel_count = <1>;
debug_level = <4>;
reset_gpio = <&pio 15 0>;
ig,enable-spi = <1>;
};
};
&pio {
i2c_pins: i2c-pins-g0 {
mux {
function = "i2c";
groups = "i2c0_0";
};
};
pcm_pins: pcm-pins-g0 {
mux {
function = "pcm";
groups = "pcm";
};
};
pwm0_pin: pwm0-pin-g0 {
mux {
function = "pwm";
groups = "pwm0_0";
};
};
pwm1_pin: pwm1-pin-g0 {
mux {
function = "pwm";
groups = "pwm1_0";
};
};
pwm2_pin: pwm2-pin {
mux {
function = "pwm";
groups = "pwm2";
};
};
spi0_flash_pins: spi0-pins {
mux {
function = "spi";
groups = "spi0", "spi0_wp_hold";
};
conf-pu {
pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
drive-strength = <MTK_DRIVE_8mA>;
bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
};
conf-pd {
pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
drive-strength = <MTK_DRIVE_8mA>;
bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
};
};
spic_pins: spi1-pins {
mux {
function = "spi";
groups = "spi1_1";
};
};
uart1_pins: uart1-pins-g1 {
mux {
function = "uart";
groups = "uart1_1";
};
};
uart2_pins: uart2-pins-g1 {
mux {
function = "uart";
groups = "uart2_1";
};
};
};
&wifi {
status = "okay";
};

View File

@ -106,6 +106,9 @@ mediatek_setup_interfaces()
mediatek,mt7988a-rfb)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 eth2" eth1
;;
mercusys,mr80x-v3)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1
;;
mercusys,mr90x-v1|\
mercusys,mr90x-v1-ubi)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2" eth1

View File

@ -119,6 +119,13 @@ case "$board" in
[ "$PHYNBR" = "1" ] && \
macaddr_setbit_la "$(mtd_get_mac_binary rf-eeprom 0x4)" > /sys${DEVPATH}/macaddress
;;
mercusys,mr80x-v3)
prefix_addr=$(cat /tmp/tp_data/default-mac)
addr=${prefix_addr#MAC:}
formatted_addr=${addr//-/:}
[ "$PHYNBR" = "0" ] && macaddr_add $formatted_addr -1 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $formatted_addr -2 > /sys${DEVPATH}/macaddress
;;
mercusys,mr90x-v1|\
tplink,re6000xd)
addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)

View File

@ -12,6 +12,7 @@ mount_ubi_part() {
preinit_mount_cfg_part() {
case $(board_name) in
mercusys,mr80x-v3|\
mercusys,mr90x-v1|\
tplink,re6000xd)
mount_ubi_part "tp_data"

View File

@ -1692,3 +1692,18 @@ define Device/zyxel_nwa50ax-pro
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += zyxel_nwa50ax-pro
define Device/mercusys_mr80x-v3
DEVICE_VENDOR := mercusys
DEVICE_MODEL := mr80x-v3
DEVICE_DTS := mt7981b-mercusys-mr80x-v3
DEVICE_DTS_DIR := ../dts
DEVICE_PACKAGES := kmod-mt7981-firmware
BLOCKSIZE := 128k
PAGESIZE := 2048
UBINIZE_OPTS := -E 5
KERNEL_IN_UBI := 1
UBINIZE_PARTS := uboot=$$(TMPDIR)/second-uboot.bin=1
IMAGE/sysupgrade.bin := append-ubi | pad-to 128K | check-size 50m | append-metadata
endef
TARGET_DEVICES += mercusys_mr80x-v3