mediatek: add support for Livinet ZR-3020 (#82)

* autocore: remove ethinfo for mtk arm boards

mediatek target uses legacy swconfig which is not supported by autocore.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>

* mediatek: add support for Livinet ZR-3020

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>

---------

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2023-07-03 02:27:36 +08:00 committed by GitHub
parent b1284fed11
commit 86dc811a7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 388 additions and 10 deletions

View File

@ -1,6 +1,7 @@
CONFIG_TARGET_mediatek=y
CONFIG_TARGET_mediatek_mt7981=y
CONFIG_TARGET_MULTI_PROFILE=y
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_livinet_zr-3020=y
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-360-t7=y
CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-360-t7-108M=y
CONFIG_DEVEL=y

View File

@ -13,7 +13,8 @@ touch /etc/config/ubootenv
board=$(board_name)
case "$board" in
*360,t7*)
*360,t7* |\
livinet,zr-3020*)
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1"
;;
xiaomi,redmi-router-ax6000*)

View File

@ -48,7 +48,7 @@ define Package/autocore/install/Default
$(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
$(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/
ifeq ($(filter ipq%, $(TARGETID)),)
ifeq ($(filter ipq% mediatek%, $(TARGETID)),)
$(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include

View File

@ -716,7 +716,8 @@ setup_model()
*mt3000* |\
*x3000* |\
*xe3000* |\
*mt2500* |\
*mt2500* |\
*zr-3020* |\
*360,t7* |\
*7981*)
MT7981_whnat $num_of_wifi

View File

@ -0,0 +1,337 @@
/dts-v1/;
#include "mt7981.dtsi"
/ {
model = "Livinet ZR-3020";
compatible = "livinet,zr-3020", "mediatek,mt7981";
aliases {
led-boot = &boot_led;
led-failsafe = &boot_led;
led-running = &running_led;
led-upgrade = &upgrade_led;
};
chosen {
bootargs = "console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000";
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gpio-leds {
compatible = "gpio-leds";
led-0 {
label = "red:d8";
gpios = <&pio 6 GPIO_ACTIVE_LOW>;
};
led-1 {
label = "blue:internet";
gpios = <&pio 7 GPIO_ACTIVE_LOW>;
};
running_led: led-2 {
label = "blue:running";
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
};
upgrade_led: led-3 {
label = "green:upgrade";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
};
boot_led: led-4 {
label = "red:boot";
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
};
led-6 {
label = "blue:d7";
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
};
led-7 {
label = "blue:wlan2g";
gpios = <&pio 34 GPIO_ACTIVE_LOW>;
};
led-8 {
label = "blue:wlan5g";
gpios = <&pio 35 GPIO_ACTIVE_LOW>;
};
};
gpio-keys {
compatible = "gpio-keys";
button-reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 1 GPIO_ACTIVE_LOW>;
};
button-wps {
label = "wps";
linux,code = <KEY_WPS_BUTTON>;
gpios = <&pio 0 GPIO_ACTIVE_LOW>;
};
};
gsw: gsw@0 {
compatible = "mediatek,mt753x";
mediatek,ethsys = <&ethsys>;
#address-cells = <1>;
#size-cells = <0>;
};
nmbm_spim_nand {
compatible = "generic,nmbm";
#address-cells = <1>;
#size-cells = <1>;
lower-mtd-device = <&spi_nand>;
forced-create;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "BL2";
reg = <0x00000 0x100000>;
read-only;
};
partition@100000 {
label = "u-boot-env";
reg = <0x100000 0x80000>;
};
partition@180000 {
label = "Factory";
reg = <0x180000 0x200000>;
};
partition@380000 {
label = "FIP";
reg = <0x380000 0x200000>;
};
partition@580000 {
label = "ubi";
reg = <0x580000 0x4000000>;
};
partition@4580000 {
label = "firmware_backup";
reg = <0x4580000 0x2000000>;
};
partition@6580000 {
label = "zrsave";
reg = <0x6580000 0x100000>;
};
partition@6680000 {
label = "config2";
reg = <0x6680000 0x100000>;
};
};
};
};
&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 = "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: 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>;
};
};
&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>; /* 1 = TRC, 2 = DBG, 4 = ERR */
reset_gpio = <&pio 15 0>;
ig,enable-spi = <1>; /* 1: Enable, 0: Disable */
};
};
&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";
};
};
};

View File

@ -255,3 +255,20 @@ define Device/glinet_gl-mt2500
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += glinet_gl-mt2500
define Device/livinet_zr-3020
DEVICE_VENDOR := Livinet
DEVICE_MODEL := ZR-3020
DEVICE_DTS := mt7981-zr-3020
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
SUPPORTED_DEVICES := livinet,zr-3020 mediatek,mt7981-spim-snand-gsw-rfb
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 65536k
KERNEL_IN_UBI := 1
IMAGES += factory.bin
IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += livinet_zr-3020

View File

@ -3,16 +3,21 @@
# Copyright © 2017 OpenWrt.org
#
. /lib/functions/leds.sh
. /lib/functions/uci-defaults.sh
board=$(board_name)
board_config_update
case "$(board_name)" in
*360,t7*)
ucidef_set_led_default "green" "GREEN" "360t7:green" "1"
ucidef_set_led_default "red" "RED" "360t7:red" "0"
case "$board" in
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"
;;
esac
board_config_flush
exit 0

View File

@ -33,6 +33,11 @@ mediatek_setup_interfaces()
*mt2500*)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
*zr-3020*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"2:lan" "3:lan" "4:lan" "0:wan" "6u@eth0" "5u@eth1"
;;
*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" eth1
;;
@ -82,9 +87,6 @@ mediatek_setup_macs()
local lan_mac_offset="0x2A"
local wan_mac_offset="0x24"
lan_mac=$(mtd_get_mac_binary $part_name $lan_mac_offset)
wan_mac=$(mtd_get_mac_binary $part_name $wan_mac_offset)
case $board in
*mt3000*)
wan_mac=$(mtd_get_mac_binary $part_name 0x0a)
@ -99,6 +101,14 @@ mediatek_setup_macs()
wan_mac=$(get_mac_binary /dev/mmcblk0p3 0x0a)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
*zr-3020*)
wan_mac=$(mtd_get_mac_ascii config2 wanmac)
lan_mac=$(mtd_get_mac_ascii config2 lanmac)
if [ "$(mtk_factory_get_byte Factory 4 2)" = "00-0c" ]; then
local wifi_mac="$(mtd_get_mac_ascii config2 wifi2gmac)"
mtk_facrory_write_mac Factory 4 "$wifi_mac"
fi
;;
*360,t7*)
local part=$(find_mtd_part "stock-factory")
if [ -n "$part" ]; then
@ -113,6 +123,10 @@ mediatek_setup_macs()
fi
fi
;;
*)
wan_mac=$(mtd_get_mac_binary $part_name $wan_mac_offset)
lan_mac=$(mtd_get_mac_binary $part_name $lan_mac_offset)
;;
esac
case "$lan_mac" in

View File

@ -8,6 +8,7 @@ platform_do_upgrade() {
*x3000* |\
*xe3000* |\
*mt2500* |\
*zr-3020* |\
*360,t7* |\
*snand*)
nand_do_upgrade "$1"
@ -34,6 +35,7 @@ platform_check_image() {
*x3000* |\
*xe3000* |\
*mt2500* |\
*zr-3020* |\
*360,t7* |\
*snand* |\
*emmc*)