mediatek:add suport for gl-mt6000 and tp-xdr608x

This commit is contained in:
padavanonly 2023-11-21 15:48:00 +08:00 committed by hanwckf
parent bcd46e3b1d
commit 7edbdbbf68
9 changed files with 788 additions and 4 deletions

View File

@ -712,6 +712,8 @@ setup_model()
xiaomi,redmi-router-ax6000* |\
bananapi,bpi-r3mini* |\
netcore,n60 |\
glinet,gl-mt6000|\
tplink,tl-xdr608* |\
*7986*)
MT7986_whnat $num_of_wifi
;;

View File

@ -0,0 +1,342 @@
/dts-v1/;
#include "mt7986a.dtsi"
#include "mt7986a-pinctrl.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
/ {
model = "GL.iNet GL-MT6000";
compatible = "glinet,gl-mt6000","mediatek,mt7986a-emmc-rfb";
chosen {
bootargs = "console=ttyS0,115200n1 loglevel=8 \
earlycon=uart8250,mmio32,0x11002000 \
root=PARTLABEL=rootfs rootwait";
};
aliases {
led-boot = &led_status_white;
led-failsafe = &led_status_white;
led-running = &led_status_blue;
led-upgrade = &led_status_blue;
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gpio-keys {
compatible = "gpio-keys";
button-reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
};
};
gpio-export {
compatible = "gpio-export";
usb_power {
gpio-export,name = "usb_power";
gpio-export,output = <1>;
gpios = <&pio 24 GPIO_ACTIVE_HIGH>;
};
};
leds {
compatible = "gpio-leds";
led_status_white: status_white {
label = "white:status";
gpios = <&pio 37 GPIO_ACTIVE_LOW>;
};
led_status_blue: status_blue {
label = "blue:status";
gpios = <&pio 38 GPIO_ACTIVE_LOW>;
};
};
reg_1p8v: regulator-1p8v {
compatible = "regulator-fixed";
regulator-name = "fixed-1.8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-boot-on;
regulator-always-on;
};
reg_3p3v: regulator-3p3v {
compatible = "regulator-fixed";
regulator-name = "fixed-3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sound {
compatible = "mediatek,mt7986-wm8960-machine";
mediatek,platform = <&afe>;
audio-routing = "Headphone", "HP_L",
"Headphone", "HP_R",
"LINPUT1", "AMIC",
"RINPUT1", "AMIC";
mediatek,audio-codec = <&wm8960>;
status = "okay";
};
};
&fan {
pwms = <&pwm 1 50000 0>;
status = "disabled";
};
&pwm {
pinctrl-names = "default";
pinctrl-0 = <&pwm0_pin &pwm1_pin_g1>;
status = "okay";
};
&uart0 {
status = "okay";
};
&uart1 {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
&uart2 {
pinctrl-names = "default";
pinctrl-0 = <&uart2_pins>;
status = "okay";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "okay";
wm8960: wm8960@1a {
compatible = "wlf,wm8960";
reg = <0x1a>;
};
};
&auxadc {
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;
};
ext-phy-reg = <1>;
ext-phy-reset-gpios = <&pio 10 0>;
};
gmac1: mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
ext-phy-reg = <7>;
ext-phy-reset-gpios = <&pio 19 0>;
};
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 5 0>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan0";
};
port@1 {
reg = <1>;
label = "lan1";
};
port@2 {
reg = <2>;
label = "lan2";
};
port@3 {
reg = <3>;
label = "lan3";
};
port@4 {
reg = <4>;
label = "lan4";
};
port@5 {
reg = <5>;
label = "lan5";
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
};
};
&xhci {
status = "okay";
};
&hnat {
mtketh-wan = "eth1";
mtketh-lan = "lan";
mtketh-ppe-num = <2>;
mtketh-max-gmac = <2>;
status = "okay";
};
&spi1 {
pinctrl-names = "default";
pinctrl-0 = <&spic_pins_g2>;
status = "okay";
};
&mmc0 {
pinctrl-names = "default", "state_uhs";
pinctrl-0 = <&mmc0_pins_default>;
pinctrl-1 = <&mmc0_pins_uhs>;
bus-width = <8>;
max-frequency = <200000000>;
cap-mmc-highspeed;
mmc-hs200-1_8v;
mmc-hs400-1_8v;
hs400-ds-delay = <0x14014>;
vmmc-supply = <&reg_3p3v>;
vqmmc-supply = <&reg_1p8v>;
non-removable;
no-sd;
no-sdio;
status = "okay";
};
&pcie0 {
pinctrl-names = "default";
pinctrl-0 = <&pcie0_pins>;
status = "okay";
};
&wbsys {
status = "okay";
};
&pio {
mmc0_pins_default: mmc0-pins-50-to-61-default {
mux {
function = "flash";
groups = "emmc_51";
};
conf-cmd-dat {
pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
"EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
"EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
input-enable;
drive-strength = <MTK_DRIVE_4mA>;
mediatek,pull-up-adv = <1>; /* pull-up 10K */
};
conf-clk {
pins = "EMMC_CK";
drive-strength = <MTK_DRIVE_6mA>;
mediatek,pull-down-adv = <2>; /* pull-down 50K */
};
conf-ds {
pins = "EMMC_DSL";
mediatek,pull-down-adv = <2>; /* pull-down 50K */
};
conf-rst {
pins = "EMMC_RSTB";
drive-strength = <MTK_DRIVE_4mA>;
mediatek,pull-up-adv = <1>; /* pull-up 10K */
};
};
mmc0_pins_uhs: mmc0-pins-50-to-61-uhs {
mux {
function = "flash";
groups = "emmc_51";
};
conf-cmd-dat {
pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
"EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
"EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
input-enable;
drive-strength = <MTK_DRIVE_4mA>;
mediatek,pull-up-adv = <1>; /* pull-up 10K */
};
conf-clk {
pins = "EMMC_CK";
drive-strength = <MTK_DRIVE_6mA>;
mediatek,pull-down-adv = <2>; /* pull-down 50K */
};
conf-ds {
pins = "EMMC_DSL";
mediatek,pull-down-adv = <2>; /* pull-down 50K */
};
conf-rst {
pins = "EMMC_RSTB";
drive-strength = <MTK_DRIVE_4mA>;
mediatek,pull-up-adv = <1>; /* pull-up 10K */
};
};
};

View File

@ -0,0 +1,335 @@
// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
/dts-v1/;
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include "mt7986a.dtsi"
#include "mt7986a-pinctrl.dtsi"
/ {
aliases {
serial0 = &uart0;
led-boot = &led_status_red;
led-failsafe = &led_status_red;
led-running = &led_status_green;
led-upgrade = &led_status_green;
};
chosen {
bootargs = "console=ttyS0,115200n1 loglevel=8
earlycon=uart8250,mmio32,0x11002000";
};
memory {
reg = <0 0x40000000 0 0x10000000>;
};
gpio-keys {
compatible = "gpio-keys";
reset {
label = "reset";
linux,code = <KEY_RESTART>;
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
};
wps {
label = "wps";
linux,code = <KEY_WPS_BUTTON>;
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
};
turbo {
label = "turbo";
linux,code = <BTN_1>;
gpios = <&pio 11 GPIO_ACTIVE_LOW>;
};
};
leds {
compatible = "gpio-leds";
led_status_red: status_red {
label = "red:status";
gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
};
led_status_green: status_green {
label = "green:status";
gpios = <&pio 8 GPIO_ACTIVE_HIGH>;
};
turbo {
label = "green:turbo";
gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
};
};
};
&eth {
status = "okay";
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
ext-phy-reg = <5>;
ext-phy-reset-gpios = <&pio 13 0>;
};
gmac1: mac@1 {
compatible = "mediatek,eth-mac";
reg = <1>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
ext-phy-reg = <7>;
ext-phy-reset-gpios = <&pio 17 0>;
};
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
switch@0 {
compatible = "mediatek,mt7531";
reg = <31>;
reset-gpios = <&pio 5 0>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan0";
};
port@1 {
reg = <1>;
label = "lan1";
};
port@2 {
reg = <2>;
label = "lan2";
};
port@3 {
reg = <3>;
label = "lan3";
};
port@4 {
reg = <4>;
label = "lan4";
};
port@5 {
reg = <5>;
label = "lan5";
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
phy-mode = "2500base-x";
fixed-link {
speed = <2500>;
full-duplex;
pause;
};
};
};
};
};
};
&hnat {
mtketh-wan = "eth1";
mtketh-lan = "lan";
mtketh-max-gmac = <2>;
mtketh-ppe-num = <2>;
status = "okay";
};
&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>;
};
};
};
&pcie0 {
pinctrl-names = "default";
pinctrl-0 = <&pcie0_pins>;
status = "okay";
};
&uart0 {
status = "okay";
};
&xhci {
status = "okay";
};
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi_flash_pins>;
status = "okay";
cs-gpios = <0>, <0>;
spi_nand: spi_nand@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spi-nand";
reg = <1>;
spi-max-frequency = <20000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "bl2";
reg = <0x000000 0x0100000>;
// read-only;
};
partition@100000 {
label = "config";
reg = <0x100000 0x0060000>;
read-only;
};
Factory: partition@160000 {
label = "Factory";
reg = <0x160000 0x00a0000>;
read-only;
};
partition@200000 {
label = "reserved";
reg = <0x200000 0x0180000>;
read-only;
};
partition@380000 {
label = "fip";
reg = <0x380000 0x0180000>;
// read-only;
};
partition@500000 {
label = "ubi";
reg = <0x500000 0x7300000>;
};
};
};
};
&wbsys {
status = "okay";
mediatek,mtd-eeprom = <&Factory 0x0000>;
/*
pinctrl-names = "default", "dbdc";
pinctrl-0 = <&wf_2g_5g_pins>;
pinctrl-1 = <&wf_dbdc_pins>;
*/
};
&watchdog {
status = "okay";
};
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c_pins>;
status = "okay";
wm8960: wm8960@1a {
compatible = "wlf,wm8960";
reg = <0x1a>;
};
};
&auxadc {
status = "okay";
};

View File

@ -0,0 +1,8 @@
/dts-v1/;
#include "mt7986a-tl-xdr-common.dtsi"
/
{
model = "TP-Link TL-XDR6086";
compatible = "tplink,tl-xdr6086", "mediatek,mt7986a";
};

View File

@ -0,0 +1,8 @@
/dts-v1/;
#include "mt7986a-tl-xdr-common.dtsi"
/
{
model = "TP-Link TL-XDR6088";
compatible = "tplink,tl-xdr6088", "mediatek,mt7986a";
};

View File

@ -434,3 +434,43 @@ define Device/netcore_n60
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += netcore_n60
define Device/glinet_gl-mt6000
DEVICE_VENDOR := GL.iNet
DEVICE_MODEL := GL-MT6000
DEVICE_DTS := mt7986a-glinet-gl-mt6000
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
DEVICE_PACKAGES := automount blkid blockdev f2fsck fdisk losetup mkf2fs \
kmod-fs-f2fs kmod-mmc kmod-nls-cp437 kmod-nls-iso8859-1 kmod-usb3 \
e2fsprogs kmod-fs-ext4 kmod-fs-vfat
IMAGES += factory.bin
IMAGE/factory.bin := append-kernel | pad-to 32M | append-rootfs
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
TARGET_DEVICES += glinet_gl-mt6000
define Device/tplink_tl-common
DEVICE_VENDOR := TP-Link
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
DEVICE_PACKAGES := automount blkid blockdev f2fsck fdisk losetup mkf2fs \
kmod-fs-f2fs kmod-nls-cp437 kmod-nls-iso8859-1 kmod-usb3
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
KERNEL_IN_UBI := 1
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
endef
define Device/tplink_tl-xdr6086
DEVICE_MODEL := TL-XDR6086
DEVICE_DTS := mt7986a-tl-xdr6086
$(call Device/tplink_tl-common)
endef
TARGET_DEVICES += tplink_tl-xdr6086
define Device/tplink_tl-xdr6088
DEVICE_MODEL := TL-XDR6088
DEVICE_DTS := mt7986a-tl-xdr6088
$(call Device/tplink_tl-common)
endef
TARGET_DEVICES += tplink_tl-xdr6088

View File

@ -28,7 +28,13 @@ mediatek_setup_interfaces()
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
netcore,n60)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" eth1
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4" eth1
;;
glinet,gl-mt6000)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4 lan5" eth1
;;
tplink,tl-xdr608*)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4 lan5" eth1
;;
*)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3 lan4 lan5" eth1
@ -49,6 +55,16 @@ mediatek_setup_macs()
lan_mac="$(macaddr_add $wifi_mac -1)"
wan_mac="$(macaddr_add $wifi_mac -2)"
;;
glinet,gl-mt6000)
label_mac=$(mmc_get_mac_binary factory 0x0a)
wan_mac=$label_mac
lan_mac=$(macaddr_add "$label_mac" 2)
;;
tplink,tl-xdr6086|\
tplink,tl-xdr6088)
wan_mac=$(mtd_get_mac_binary config 0x1c)
lan_mac=$(macaddr_add "$wan_mac" 1)
;;
xiaomi,redmi-router-ax6000*)
wan_mac=$(mtd_get_mac_ascii Bdata ethaddr_wan)
lan_mac=$(mtd_get_mac_ascii Bdata ethaddr)

View File

@ -0,0 +1,27 @@
. /lib/functions/caldata.sh
. /lib/functions/system.sh
caldata_validate() {
local macprefix
[ -e "/lib/firmware/$FIRMWARE" ] || return 1
macprefix=$(hexdump -v -n 2 -s 4 -e '1/1 "%02x:" "%02x"' "/lib/firmware/$FIRMWARE" 2>"/dev/null")
if [ "$macprefix" = "00:0c" ] || [ -z "$macprefix" ]; then
return 1
else
return 0
fi
}
do_extract_caldata() {
case $(board_name) in
glinet,gl-mt6000)
FIRMWARE=MT7986_ePAeLNA_EEPROM_AX6000.bin
caldata_validate && exit 0
caldata_extract_mmc "factory" 0x0 0x1000
;;
esac
}
boot_hook_add preinit_main do_extract_caldata

View File

@ -148,15 +148,19 @@ platform_do_upgrade() {
xiaomi,redmi-router-ax6000 |\
bananapi,bpi-r3mini |\
netcore,n60|\
tplink,tl-xdr608*|\
*snand*)
nand_do_upgrade "$1"
;;
bananapi,bpi-r3mini-emmc)
emmc_do_upgrade "$1"
;;
bananapi,bpi-r3mini-emmc |\
*emmc*)
mtk_mmc_do_upgrade "$1"
;;
glinet,gl-mt6000)
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
emmc_do_upgrade "$1"
;;
*)
default_do_upgrade "$1"
;;
@ -176,6 +180,8 @@ platform_check_image() {
bananapi,bpi-r3mini* |\
netcore,n60|\
*snand* |\
glinet,gl-mt6000|\
tplink,tl-xdr608*|\
*emmc*)
# tar magic `ustar`
magic="$(dd if="$1" bs=1 skip=257 count=5 2>/dev/null)"