Skip to content

Commit

Permalink
mediatek: add support for Xiaomi WR30U
Browse files Browse the repository at this point in the history
Signed-off-by: hank9999 <mchank9999@gmail.com>
  • Loading branch information
hank9999 authored and hanwckf committed Jul 12, 2023
1 parent 6a3939a commit d66f475
Show file tree
Hide file tree
Showing 8 changed files with 400 additions and 0 deletions.
1 change: 1 addition & 0 deletions target/linux/mediatek/base-files/sbin/smp.sh
Expand Up @@ -719,6 +719,7 @@ setup_model()
*mt2500* |\
*zr-3020* |\
*360,t7* |\
xiaomi,mi-router-wr30u* |\
*7981*)
MT7981_whnat $num_of_wifi
;;
Expand Down
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

/dts-v1/;
#include "mt7981-xiaomi-mi-router-wr30u-base.dtsi"

/ {
model = "Xiaomi Mi Router WR30U (112M UBI layout)";
compatible = "xiaomi,mi-router-wr30u-112m", "mediatek,mt7981";
};

&partitions {
partition@600000 {
label = "ubi";
reg = <0x600000 0x7000000>;
};
};
@@ -0,0 +1,249 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>

#include "mt7981.dtsi"

/ {
aliases {
serial0 = &uart0;
led-boot = &led_system_yellow;
led-failsafe = &led_system_yellow;
led-running = &led_system_blue;
led-upgrade = &led_system_yellow;
};

chosen {
stdout-path = "serial0:115200n8";
};

memory {
reg = <0 0x40000000 0 0x10000000>;
};

gpio-keys {
compatible = "gpio-keys";

reset {
label = "reset";
gpios = <&pio 1 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};

mesh {
label = "mesh";
gpios = <&pio 0 GPIO_ACTIVE_LOW>;
linux,code = <BTN_9>;
linux,input-type = <EV_SW>;
};
};

leds {
compatible = "gpio-leds";

led_system_blue: system_blue {
label = "blue:system";
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
};

led_system_yellow: system_yellow {
label = "yellow:system";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
};

led_network_blue {
label = "blue:network";
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
};

led_network_yellow {
label = "yellow:network";
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
};
};

gsw: gsw@0 {
compatible = "mediatek,mt753x";
mediatek,ethsys = <&ethsys>;
#address-cells = <1>;
#size-cells = <0>;
};

nmbm_spim_nand: nmbm_spim_nand {
compatible = "generic,nmbm";

#address-cells = <1>;
#size-cells = <1>;

lower-mtd-device = <&spi_nand>;
forced-create;
};
};

&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 = "2500base-x";

fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};

mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
};
};

&gsw {
mediatek,mdio = <&mdio>;
mediatek,mdio_master_pinmux = <0>;
reset-gpios = <&pio 39 0>;
interrupt-parent = <&pio>;
interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
status = "okay";

port5: port@5 {
compatible = "mediatek,mt753x-port";
reg = <5>;
phy-mode = "sgmii";

fixed-link {
speed = <2500>;
full-duplex;
};
};

port6: port@6 {
compatible = "mediatek,mt753x-port";
mediatek,ssc-on;
reg = <6>;
phy-mode = "sgmii";

fixed-link {
speed = <2500>;
full-duplex;
};
};
};

&hnat {
mtketh-wan = "eth1";
mtketh-lan = "eth0";
mtketh-max-gmac = <2>;
status = "okay";
};

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_flash_pins>;
status = "okay";

spi_nand: flash@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <0>;

spi-max-frequency = <52000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
};
};

&nmbm_spim_nand {
partitions: partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "BL2";
reg = <0x00 0x100000>;
};

partition@100000 {
label = "Nvram";
reg = <0x100000 0x40000>;
};

partition@140000 {
label = "Bdata";
reg = <0x140000 0x40000>;
};

partition@180000 {
label = "Factory";
reg = <0x180000 0x200000>;
};

partition@380000 {
label = "FIP";
reg = <0x380000 0x200000>;
};

partition@580000 {
label = "crash";
reg = <0x580000 0x40000>;
};

partition@5c0000 {
label = "crash_log";
reg = <0x5c0000 0x40000>;
};

partition@7600000 {
label = "KF";
reg = <0x7600000 0x40000>;
};
};
};

&pio {
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>;
};
};
};

&uart0 {
status = "okay";
};

&watchdog {
status = "okay";
};
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

/dts-v1/;
#include "mt7981-xiaomi-mi-router-wr30u-base.dtsi"

/ {
model = "Xiaomi Mi Router WR30U (stock layout)";
compatible = "xiaomi,mi-router-wr30u-stock", "mediatek,mt7981";
};

&partitions {
// ubi_kernel is the ubi partition in stock.
partition@600000 {
label = "ubi_kernel";
reg = <0x600000 0x2200000>;
};

/* ubi is the result of squashing
* consecutive stock partitions:
* - ubi1
* - overlay
* - data
*/
partition@2800000 {
label = "ubi";
reg = <0x2800000 0x4e00000>;
};
};
29 changes: 29 additions & 0 deletions target/linux/mediatek/image/mt7981.mk
Expand Up @@ -223,6 +223,35 @@ define Device/cetron_ct3003
endef
TARGET_DEVICES += cetron_ct3003

define Device/xiaomi_mi-router-wr30u-stock
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Mi Router WR30U (stock layout)
DEVICE_DTS := mt7981-xiaomi-mi-router-wr30u-stock
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 34816k
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += xiaomi_mi-router-wr30u-stock

define Device/xiaomi_mi-router-wr30u-112m
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Mi Router WR30U (112M UBI layout)
DEVICE_DTS := mt7981-xiaomi-mi-router-wr30u-112m
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 114688k
KERNEL_IN_UBI := 1
IMAGES += factory.ubi
IMAGE/factory.ubi := append-ubi | check-size $$$$(IMAGE_SIZE)
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += xiaomi_mi-router-wr30u-112m

define Device/glinet_gl-mt3000
DEVICE_VENDOR := GL.iNet
DEVICE_MODEL := GL-MT3000
Expand Down
6 changes: 6 additions & 0 deletions target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
Expand Up @@ -15,6 +15,12 @@ livinet,zr-3020)
ucidef_set_led_netdev "internet" "INTERNET" "blue:internet" "eth1"
ucidef_set_led_netdev "wlan2g" "WLAN2G" "blue:wlan2g" "ra0" "link"
ucidef_set_led_netdev "wlan5g" "WLAN5G" "blue:wlan5g" "rax0" "link"
xiaomi,mi-router-wr30u*)
ucidef_set_led_netdev "wan" "wan" "blue:network" "wan"
;;
*360,t7*)
ucidef_set_led_default "green" "GREEN" "360t7:green" "1"
ucidef_set_led_default "red" "RED" "360t7:red" "0"
;;
esac

Expand Down
Expand Up @@ -22,6 +22,11 @@ mediatek_setup_interfaces()
*2500wan-p5*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan
;;
xiaomi,mi-router-wr30u*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "0:wan" "6u@eth0" "5u@eth1"
;;
*360,t7*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
Expand Down Expand Up @@ -119,6 +124,10 @@ mediatek_setup_macs()
mtk_facrory_write_mac Factory 4 "$wifi_mac"
fi
;;
xiaomi,mi-router-wr30u*)
wan_mac=$(mtd_get_mac_ascii Bdata ethaddr_wan)
lan_mac=$(mtd_get_mac_ascii Bdata ethaddr)
;;
*360,t7*)
local part=$(find_mtd_part "stock-factory")
if [ -n "$part" ]; then
Expand Down

0 comments on commit d66f475

Please sign in to comment.