medtatek: add support for redmi ax6000

See: ff558034ea
This commit is contained in:
hanwckf
2022-11-29 09:06:11 +08:00
parent f57d0285ee
commit 1cc396e96b
11 changed files with 546 additions and 27 deletions

View File

@@ -16,6 +16,9 @@ case "$board" in
*360,t7*)
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1"
;;
xiaomi,redmi-router-ax6000*)
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x10000" "0x20000" "1"
;;
esac
config_load ubootenv

View File

@@ -709,11 +709,12 @@ setup_model()
mt_whnat_en=$(module_exist "mt_whnat")
case $board in
xiaomi,redmi-router-ax6000* |\
*7986*)
MT7986_whnat $num_of_wifi
;;
*7981* |\
*360,t7*)
*360,t7* |\
*7981*)
MT7981_whnat $num_of_wifi
;;
*)

View File

@@ -0,0 +1,69 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include "mt7986a-xiaomi-redmi-router-ax6000.dtsi"
/ {
model = "Xiaomi Redmi Router AX6000 (stock layout)";
compatible = "xiaomi,redmi-router-ax6000-stock", "mediatek,mt7986a";
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 = <0x01>;
#size-cells = <0x01>;
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@600000 {
label = "ubi_kernel";
reg = <0x600000 0x1e00000>;
};
partition@2400000 {
label = "ubi";
reg = <0x2400000 0x5000000>;
};
};
};
};

View File

@@ -0,0 +1,61 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include "mt7986a-xiaomi-redmi-router-ax6000.dtsi"
/ {
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 = <0x01>;
#size-cells = <0x01>;
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@600000 {
label = "ubi";
reg = <0x600000 0x6e00000>;
};
};
};
};

View File

@@ -0,0 +1,207 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include "mt7986a.dtsi"
/ {
model = "Xiaomi Redmi Router AX6000";
compatible = "xiaomi,redmi-router-ax6000", "mediatek,mt7986a";
chosen {
bootargs = "console=ttyS0,115200n1 loglevel=8 earlycon=uart8250,mmio32,0x11002000";
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gsw: gsw@0 {
compatible = "mediatek,mt753x";
mediatek,ethsys = <&ethsys>;
#address-cells = <1>;
#size-cells = <0>;
};
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
mesh {
label = "mesh";
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
linux,code = <BTN_9>;
linux,input-type = <EV_SW>;
};
};
};
&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 5 0>;
interrupt-parent = <&pio>;
interrupts = <66 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 = <&spi_flash_pins>;
cs-gpios = <0>, <0>;
status = "okay";
spi_nand: spi_nand@1 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <1>;
spi-max-frequency = <52000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
spi-cal-enable;
spi-cal-mode = "read-data";
spi-cal-datalen = <7>;
spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>; /* 'SPINAND' */
spi-cal-addrlen = <5>;
spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
};
};
&wbsys {
status = "okay";
pinctrl-names = "default", "dbdc";
pinctrl-0 = <&wf_2g_5g_pins>;
pinctrl-1 = <&wf_dbdc_pins>;
};
&pio {
spi_flash_pins: spi-flash-pins-33-to-38 {
mux {
function = "flash";
groups = "spi0", "spi0_wp_hold";
};
conf-pu {
pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
drive-strength = <8>;
mediatek,pull-up-adv = <0>;
};
conf-pd {
pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
drive-strength = <8>;
mediatek,pull-down-adv = <0>;
};
};
wf_2g_5g_pins: wf_2g_5g-pins {
mux {
function = "wifi";
groups = "wf_2g", "wf_5g";
};
conf {
pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
"WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
"WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
"WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
"WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
"WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
"WF1_TOP_CLK", "WF1_TOP_DATA";
drive-strength = <MTK_DRIVE_4mA>;
};
};
wf_dbdc_pins: wf_dbdc-pins {
mux {
function = "wifi";
groups = "wf_dbdc";
};
conf {
pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
"WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
"WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
"WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
"WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
"WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
"WF1_TOP_CLK", "WF1_TOP_DATA";
drive-strength = <MTK_DRIVE_4mA>;
};
};
};

View File

@@ -353,3 +353,33 @@ define Device/mediatek_mt7986-fpga-ubi
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += mediatek_mt7986-fpga-ubi
define Device/xiaomi_redmi-router-ax6000
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Redmi Router AX6000
DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
SUPPORTED_DEVICES := xiaomi,redmi-router-ax6000
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 112640k
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 += xiaomi_redmi-router-ax6000
define Device/xiaomi_redmi-router-ax6000-stock
DEVICE_VENDOR := Xiaomi
DEVICE_MODEL := Redmi Router AX6000 (stock layout)
DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000-stock
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
SUPPORTED_DEVICES := xiaomi,redmi-router-ax6000-stock
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += xiaomi_redmi-router-ax6000-stock

View File

@@ -19,6 +19,11 @@ mediatek_setup_interfaces()
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "6u@eth0"
;;
xiaomi,redmi-router-ax6000*)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "3:lan" "4:wan" "6u@eth0" "5u@eth1"
;;
*)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4 lan5" eth1
;;
@@ -28,22 +33,20 @@ mediatek_setup_interfaces()
mediatek_setup_macs()
{
local board="$1"
local part_name="Factory"
local lan_mac=""
local wan_mac=""
local lan_mac_offset=""
local wan_mac_offset=""
case $board in
xiaomi,redmi-router-ax6000*)
wan_mac=$(mtd_get_mac_ascii Bdata ethaddr_wan)
lan_mac=$(mtd_get_mac_ascii Bdata ethaddr)
;;
*)
lan_mac_offset="0x2A"
wan_mac_offset="0x24"
lan_mac=$(mtd_get_mac_binary "Factory" "0x2A")
wan_mac=$(mtd_get_mac_binary "Factory" "0x24")
;;
esac
lan_mac=$(mtd_get_mac_binary $part_name $lan_mac_offset)
wan_mac=$(mtd_get_mac_binary $part_name $wan_mac_offset)
case "$lan_mac" in
00:00:00:00:00:00);;
ff:ff:ff:ff:ff:ff);;

View File

@@ -1,10 +1,151 @@
RAMFS_COPY_BIN='mkfs.f2fs blkid blockdev fw_printenv fw_setenv'
RAMFS_COPY_DATA="/etc/fw_env.config /var/lock/fw_printenv.lock"
nand_remove_ubiblock() {
local ubivol="$1"
local ubiblk="ubiblock${ubivol:3}"
if [ -e "/dev/$ubiblk" ]; then
umount "/dev/$ubiblk" && echo "unmounted /dev/$ubiblk" || :
if ! ubiblock -r "/dev/$ubivol"; then
echo "cannot remove $ubiblk"
return 1
fi
fi
}
redmi_ax6000_nand_upgrade_tar()
{
CI_UBIPART=ubi
local tar_file="$1"
local board_dir="$(tar tf "$tar_file" | grep -m 1 '^sysupgrade-.*/$')"
board_dir="${board_dir%/}"
local kernel_length=$( (tar xf "$tar_file" "$board_dir/kernel" -O | wc -c) 2> /dev/null)
[ "$kernel_length" = 0 ] && kernel_length=
local rootfs_length=$( (tar xf "$tar_file" "$board_dir/root" -O | wc -c) 2> /dev/null)
[ "$rootfs_length" = 0 ] && rootfs_length=
local rootfs_type
[ "$rootfs_length" ] && rootfs_type="$(identify_tar "$tar_file" "$board_dir/root")"
[ -n "$rootfs_length" -o -n "$kernel_length" ] || return 1
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
if [ ! "$mtdnum" ]; then
echo "cannot find ubi mtd partition ubi"
return 1
fi
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
#cleanup old data volume if exist
if [ "$ubidev" ] && [ "$( nand_find_volume $ubidev data )" ]; then
ubidetach -m "$mtdnum"
ubiformat /dev/mtd$mtdnum -y
ubiattach -m "$mtdnum"
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
fi
if [ ! "$ubidev" ]; then
ubiattach -m "$mtdnum"
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
if [ ! "$ubidev" ]; then
ubiformat /dev/mtd$mtdnum -y
ubiattach -m "$mtdnum"
ubidev="$( nand_find_ubi "$CI_UBIPART" )"
if [ ! "$ubidev" ]; then
echo "cannot attach ubi mtd partition ubi"
return 1
fi
fi
fi
local kern_mtdnum="$( find_mtd_index "ubi_kernel" )"
if [ ! "$kern_mtdnum" ]; then
echo "cannot find ubi_kernel mtd partition ubi_kernel"
return 1
fi
local kern_ubidev="$( nand_find_ubi "ubi_kernel" )"
if [ ! "$kern_ubidev" ]; then
ubiattach -m "$kern_mtdnum"
kern_ubidev="$( nand_find_ubi "ubi_kernel" )"
if [ ! "$kern_ubidev" ]; then
ubiformat /dev/mtd$kern_mtdnum -y
ubiattach -m "$kern_mtdnum"
kern_ubidev="$( nand_find_ubi "ubi_kernel" )"
if [ ! "$kern_ubidev" ]; then
echo "cannot attach ubi_kernel mtd partition ubi_kernel"
return 1
fi
fi
fi
local kern_ubivol="$( nand_find_volume $kern_ubidev "kernel" )"
local root_ubivol="$( nand_find_volume $ubidev "rootfs" )"
local data_ubivol="$( nand_find_volume $ubidev rootfs_data )"
[ "$kern_ubivol" ] && { nand_remove_ubiblock $kern_ubivol || return 1; }
[ "$root_ubivol" ] && { nand_remove_ubiblock $root_ubivol || return 1; }
[ "$data_ubivol" ] && { nand_remove_ubiblock $data_ubivol || return 1; }
[ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || :
[ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N "rootfs" || :
ubirmvol /dev/$kern_ubidev -N rootfs_data 2>/dev/null || :
ubirmvol /dev/$kern_ubidev -N rootfs 2>/dev/null || :
[ "$kern_ubivol" ] && ubirmvol /dev/$kern_ubidev -N "kernel" || :
# create kernel vol in ubi_kernel
if ! ubimkvol /dev/$kern_ubidev -N "kernel" -s $kernel_length; then
echo "cannot create kernel volume"
return 1
fi
# create rootfs vol in ubi
local rootfs_size_param
if [ "$rootfs_type" = "ubifs" ]; then
rootfs_size_param="-m"
else
rootfs_size_param="-s $rootfs_length"
fi
if ! ubimkvol /dev/$ubidev -N "rootfs" $rootfs_size_param; then
echo "cannot create rootfs volume"
return 1;
fi
# create rootfs_data vol for non-ubifs rootfs in ubi
if [ "$rootfs_type" != "ubifs" ]; then
local rootfs_data_size_param="-m"
if ! ubimkvol /dev/$ubidev -N rootfs_data $rootfs_data_size_param; then
if ! ubimkvol /dev/$ubidev -N rootfs_data -m; then
echo "cannot initialize rootfs_data volume"
return 1
fi
fi
fi
root_ubivol="$( nand_find_volume $ubidev "rootfs" )"
if [ "$root_ubivol" ]; then
tar xf "$tar_file" "$board_dir/root" -O | \
ubiupdatevol /dev/$root_ubivol -s $rootfs_length -
fi
kern_ubivol="$( nand_find_volume $kern_ubidev "kernel" )"
if [ "$kern_ubivol" ]; then
tar xf "$tar_file" "$board_dir/kernel" -O | \
ubiupdatevol /dev/$kern_ubivol -s $kernel_length -
fi
nand_do_upgrade_success
}
platform_do_upgrade() {
local board=$(board_name)
case "$board" in
xiaomi,redmi-router-ax6000-stock)
redmi_ax6000_nand_upgrade_tar "$1"
;;
xiaomi,redmi-router-ax6000 |\
*snand*)
nand_do_upgrade "$1"
;;
@@ -26,6 +167,7 @@ platform_check_image() {
[ "$#" -gt 1 ] && return 1
case "$board" in
xiaomi,redmi-router-ax6000* |\
*snand* |\
*emmc*)
# tar magic `ustar`

View File

@@ -156,7 +156,10 @@ CONFIG_CRYPTO_RNG_DEFAULT=y
CONFIG_CRYPTO_SHA1=y
CONFIG_CRYPTO_SHA256=y
CONFIG_CRYPTO_SHA512=y
CONFIG_CRYPTO_TEST=m
CONFIG_CRYPTO_USER=y
CONFIG_CRYPTO_USER_API=y
CONFIG_CRYPTO_USER_API_AEAD=y
CONFIG_CRYPTO_USER_API_HASH=y
CONFIG_DCACHE_WORD_ACCESS=y
CONFIG_DEBUG_MISC=y
CONFIG_DEVTMPFS=y
@@ -404,6 +407,19 @@ CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_SYSCON=y
CONFIG_POWER_SUPPLY=y
CONFIG_PRINTK_TIME=y
CONFIG_PSTORE=y
# CONFIG_PSTORE_842_COMPRESS is not set
CONFIG_PSTORE_COMPRESS=y
CONFIG_PSTORE_COMPRESS_DEFAULT="deflate"
# CONFIG_PSTORE_CONSOLE is not set
CONFIG_PSTORE_DEFLATE_COMPRESS=y
CONFIG_PSTORE_DEFLATE_COMPRESS_DEFAULT=y
# CONFIG_PSTORE_LZ4HC_COMPRESS is not set
# CONFIG_PSTORE_LZ4_COMPRESS is not set
# CONFIG_PSTORE_LZO_COMPRESS is not set
# CONFIG_PSTORE_PMSG is not set
CONFIG_PSTORE_RAM=y
# CONFIG_PSTORE_ZSTD_COMPRESS is not set
CONFIG_PWM=y
CONFIG_PWM_MEDIATEK=y
# CONFIG_PWM_MTK_DISP is not set
@@ -416,7 +432,9 @@ CONFIG_RATIONAL=y
CONFIG_RCU_NEED_SEGCBLIST=y
CONFIG_RCU_STALL_COMMON=y
CONFIG_REALTEK_PHY=y
CONFIG_REFCOUNT_FULL=y
CONFIG_REED_SOLOMON=y
CONFIG_REED_SOLOMON_DEC8=y
CONFIG_REED_SOLOMON_ENC8=y
CONFIG_REGMAP=y
CONFIG_REGMAP_MMIO=y
CONFIG_REGULATOR=y

View File

@@ -1,15 +0,0 @@
#
# Copyright (C) 2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Profile/Default
NAME:=Default Profile (minimum package set)
endef
define Profile/Default/Description
Default package set compatible with most boards.
endef
$(eval $(call Profile,Default))

0
target/linux/mediatek/mt7986/target.mk Executable file → Normal file
View File