From 2ecc92d67bb75cdc42fae14a6d8a5faefcc4e3b6 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 20 Jul 2020 21:00:29 +0100 Subject: [PATCH] target/mediatek: sync with upstream source --- package/boot/uboot-mediatek/Makefile | 20 +- ...ix-mmc_get_boot_dev-for-platforms-wi.patch | 51 +++ ...-Add-support-for-UniElec-U7623-board.patch | 310 ++++++++++++++++++ .../patches/010-update-u7623-defconfig.patch | 17 + target/linux/mediatek/Makefile | 1 - target/linux/mediatek/image/Config.in | 6 +- .../mediatek/image/gen_mt7623_emmc_img.sh | 22 +- .../linux/mediatek/image/gen_mtk_mmc_img.sh | 150 +++++++++ .../linux/mediatek/image/gen_scatterfile.sh | 75 +++++ target/linux/mediatek/image/mt7622.mk | 2 +- target/linux/mediatek/image/mt7623.mk | 74 ++++- .../image/mt7623a_unielec_u7623-uEnv.txt | 20 ++ target/linux/mediatek/mt7622/config-4.19 | 1 - target/linux/mediatek/mt7622/config-5.4 | 1 - target/linux/mediatek/mt7622/target.mk | 2 +- .../base-files/lib/preinit/07_set_iface_mac | 22 +- .../base-files/lib/preinit/79_move_config | 6 +- .../mt7623/base-files/lib/upgrade/platform.sh | 215 ++++++------ target/linux/mediatek/mt7623/config-4.19 | 1 - target/linux/mediatek/mt7623/config-5.4 | 1 + target/linux/mediatek/mt7629/config-4.19 | 1 - target/linux/mediatek/mt7629/config-5.4 | 1 - .../0227-arm-dts-Add-Unielec-U7623-DTS.patch | 16 +- ..._eth_soc-Always-call-mtk_gmac0_rgmii.patch | 62 ++++ ...ngs-PCI-Mediatek-Update-PCIe-binding.patch | 5 - ...e-regmap-to-get-shared-pcie-cfg-base.patch | 16 +- ...ek-Split-PCIe-node-for-MT2712-MT7622.patch | 18 +- ...dts-mediatek-Update-mt7629-PCIe-node.patch | 10 +- 28 files changed, 937 insertions(+), 189 deletions(-) create mode 100644 package/boot/uboot-mediatek/patches/008-board-mediatek-fix-mmc_get_boot_dev-for-platforms-wi.patch create mode 100644 package/boot/uboot-mediatek/patches/009-board-mediatek-Add-support-for-UniElec-U7623-board.patch create mode 100644 package/boot/uboot-mediatek/patches/010-update-u7623-defconfig.patch create mode 100755 target/linux/mediatek/image/gen_mtk_mmc_img.sh create mode 100755 target/linux/mediatek/image/gen_scatterfile.sh create mode 100644 target/linux/mediatek/image/mt7623a_unielec_u7623-uEnv.txt create mode 100644 target/linux/mediatek/patches-5.4/0402-net-ethernet-mtk_eth_soc-Always-call-mtk_gmac0_rgmii.patch mode change 100755 => 100644 target/linux/mediatek/patches-5.4/0991-dt-bindings-PCI-Mediatek-Update-PCIe-binding.patch mode change 100755 => 100644 target/linux/mediatek/patches-5.4/0992-PCI-mediatek-Use-regmap-to-get-shared-pcie-cfg-base.patch mode change 100755 => 100644 target/linux/mediatek/patches-5.4/0993-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch mode change 100755 => 100644 target/linux/mediatek/patches-5.4/0994-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index a7b47ecae5..8cb20075a3 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -15,18 +15,18 @@ define U-Boot/Default DEFAULT:=y endef -define U-Boot/mt7629 - NAME:=MT7629 - BUILD_SUBTARGET:=mt7629 - UBOOT_CONFIG:=mt7629_rfb -endef - define U-Boot/mt7622 NAME:=MT7622 BUILD_SUBTARGET:=mt7622 UBOOT_CONFIG:=mt7622_rfb endef +define U-Boot/mt7623a_unielec_u7623 + NAME:=UniElec U7623 (mt7623) + BUILD_SUBTARGET:=mt7623 + UBOOT_CONFIG:=mt7623a_unielec_u7623_02 +endef + define U-Boot/mt7623n_bpir2 NAME:=Banana Pi R2 (mt7623) BUILD_SUBTARGET:=mt7623 @@ -34,7 +34,13 @@ define U-Boot/mt7623n_bpir2 UBOOT_CONFIG:=mt7623n_bpir2 endef -UBOOT_TARGETS := mt7629 mt7622 mt7623n_bpir2 +define U-Boot/mt7629 + NAME:=MT7629 + BUILD_SUBTARGET:=mt7629 + UBOOT_CONFIG:=mt7629_rfb +endef + +UBOOT_TARGETS := mt7629 mt7622 mt7623n_bpir2 mt7623a_unielec_u7623 UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE) diff --git a/package/boot/uboot-mediatek/patches/008-board-mediatek-fix-mmc_get_boot_dev-for-platforms-wi.patch b/package/boot/uboot-mediatek/patches/008-board-mediatek-fix-mmc_get_boot_dev-for-platforms-wi.patch new file mode 100644 index 0000000000..e32114a880 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/008-board-mediatek-fix-mmc_get_boot_dev-for-platforms-wi.patch @@ -0,0 +1,51 @@ +From b0d1b85fb25a28a9532eaa9dda064b40a0e25f25 Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Sun, 12 Jul 2020 23:19:09 +0100 +Subject: [PATCH 1/3] board: mediatek: fix mmc_get_boot_dev() for platforms + without external SD + +On the UniElec U7623 board there is no external SD slot and the preloader +doesn't fill in the magic field at 0x81dffff0 to indicate that it was +booted from eMMC. + +Signed-off-by: David Woodhouse +--- + board/mediatek/mt7623/mt7623_rfb.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/board/mediatek/mt7623/mt7623_rfb.c b/board/mediatek/mt7623/mt7623_rfb.c +index 4ec2764976..984e75ccaf 100644 +--- a/board/mediatek/mt7623/mt7623_rfb.c ++++ b/board/mediatek/mt7623/mt7623_rfb.c +@@ -4,6 +4,7 @@ + */ + + #include ++#include + + DECLARE_GLOBAL_DATA_PTR; + +@@ -15,10 +16,15 @@ int board_init(void) + return 0; + } + ++#ifdef CONFIG_MMC + int mmc_get_boot_dev(void) + { + int g_mmc_devid = -1; + char *uflag = (char *)0x81DFFFF0; ++ ++ if (!find_mmc_device(1)) ++ return 0; ++ + if (strncmp(uflag,"eMMC",4)==0) { + g_mmc_devid = 0; + printf("Boot From Emmc(id:%d)\n\n", g_mmc_devid); +@@ -33,3 +39,4 @@ int mmc_get_env_dev(void) + { + return mmc_get_boot_dev(); + } ++#endif +-- +2.26.2 + diff --git a/package/boot/uboot-mediatek/patches/009-board-mediatek-Add-support-for-UniElec-U7623-board.patch b/package/boot/uboot-mediatek/patches/009-board-mediatek-Add-support-for-UniElec-U7623-board.patch new file mode 100644 index 0000000000..32bef358f4 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/009-board-mediatek-Add-support-for-UniElec-U7623-board.patch @@ -0,0 +1,310 @@ +From d13abe5b2c5b85228bdd34584fcbd642f1883668 Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Sun, 12 Jul 2020 23:23:05 +0100 +Subject: [PATCH 3/3] board: mediatek: Add support for UniElec U7623 board + +This is an MT7623A-based board, very similar to the Banana Pi R2. + +http://www.unielecinc.com/q/news/cn/p/product/detail.html?qd_guid=OjXwKCaRlN + +Signed-off-by: David Woodhouse +--- + arch/arm/dts/Makefile | 1 + + .../arm/dts/mt7623a-unielec-u7623-02-emmc.dts | 211 ++++++++++++++++++ + configs/mt7623a_unielec_u7623_02_defconfig | 54 +++++ + 3 files changed, 266 insertions(+) + create mode 100644 arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts + create mode 100644 configs/mt7623a_unielec_u7623_02_defconfig + +diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile +index 89fa448818..a140b1c8d4 100644 +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -938,6 +938,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \ + + dtb-$(CONFIG_ARCH_MEDIATEK) += \ + mt7622-rfb.dtb \ ++ mt7623a-unielec-u7623-02-emmc.dtb \ + mt7623n-bananapi-bpi-r2.dtb \ + mt7629-rfb.dtb \ + mt8512-bm1-emmc.dtb \ +diff --git a/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts b/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts +new file mode 100644 +index 0000000000..fdeec75b05 +--- /dev/null ++++ b/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts +@@ -0,0 +1,211 @@ ++/* ++ * Copyright (C) 2018 MediaTek Inc. ++ * Author: Ryder Lee ++ * ++ * SPDX-License-Identifier: (GPL-2.0 OR MIT) ++ */ ++ ++/dts-v1/; ++#include "mt7623.dtsi" ++#include "mt7623-u-boot.dtsi" ++ ++/ { ++ model = "UniElec U7623-02 eMMC"; ++ compatible = "unielec,u7623-02-emmc", "mediatek,mt7623"; ++ ++ memory@80000000 { ++ device_type = "memory"; ++ reg = <0 0x80000000 0 0x20000000>; ++ }; ++ ++ chosen { ++ stdout-path = &uart2; ++ tick-timer = &timer0; ++ }; ++ ++ 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; ++ }; ++ ++ reg_5v: regulator-5v { ++ compatible = "regulator-fixed"; ++ regulator-name = "fixed-5V"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ regulator-boot-on; ++ regulator-always-on; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ led3 { ++ label = "u7623-01:green:led3"; ++ gpios = <&gpio 14 GPIO_ACTIVE_LOW>; ++ default-state = "off"; ++ }; ++ ++ led4 { ++ label = "u7623-01:green:led4"; ++ gpios = <&gpio 15 GPIO_ACTIVE_LOW>; ++ default-state = "off"; ++ }; ++ }; ++}; ++ ++ð { ++ status = "okay"; ++ mediatek,gmac-id = <0>; ++ phy-mode = "rgmii"; ++ mediatek,switch = "mt7530"; ++ mediatek,mcm; ++ ++ fixed-link { ++ speed = <1000>; ++ full-duplex; ++ }; ++}; ++ ++&mmc0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mmc0_pins_default>; ++ status = "okay"; ++ bus-width = <8>; ++ max-frequency = <50000000>; ++ cap-mmc-highspeed; ++ vmmc-supply = <®_3p3v>; ++ vqmmc-supply = <®_1p8v>; ++ non-removable; ++}; ++ ++&pinctrl { ++ ephy_default: ephy_default { ++ mux { ++ function = "eth"; ++ groups = "mdc_mdio", "ephy"; ++ }; ++ ++ conf { ++ pins = "G2_TXEN", "G2_TXD0", "G2_TXD1", "G2_TXD2", ++ "G2_TXD3", "G2_TXC", "G2_RXC", "G2_RXD0", ++ "G2_RXD1", "G2_RXD2", "G2_RXD3", "G2_RXDV", ++ "MDC", "MDIO"; ++ drive-strength = <12>; ++ mediatek,tdsel = <5>; ++ }; ++ }; ++ ++ mmc0_pins_default: mmc0default { ++ mux { ++ function = "msdc"; ++ groups = "msdc0"; ++ }; ++ ++ conf-cmd-data { ++ pins = "MSDC0_CMD", "MSDC0_DAT0", "MSDC0_DAT1", ++ "MSDC0_DAT2", "MSDC0_DAT3", "MSDC0_DAT4", ++ "MSDC0_DAT5", "MSDC0_DAT6", "MSDC0_DAT7"; ++ input-enable; ++ bias-pull-up; ++ }; ++ ++ conf-clk { ++ pins = "MSDC0_CLK"; ++ bias-pull-down; ++ }; ++ ++ conf-rst { ++ pins = "MSDC0_RSTB"; ++ bias-pull-up; ++ }; ++ }; ++ ++ pcie_default: pcie-default { ++ mux { ++ function = "pcie"; ++ groups = "pcie0_0_perst", "pcie1_0_perst"; ++ }; ++ }; ++ ++ uart0_pins_a: uart0-default { ++ mux { ++ function = "uart"; ++ groups = "uart0_0_txd_rxd"; ++ }; ++ }; ++ ++ uart1_pins_a: uart1-default { ++ mux { ++ function = "uart"; ++ groups = "uart1_0_txd_rxd"; ++ }; ++ }; ++ ++ uart2_pins_a: uart2-default { ++ mux { ++ function = "uart"; ++ groups = "uart2_0_txd_rxd"; ++ }; ++ }; ++ ++ uart2_pins_b: uart2-alt { ++ mux { ++ function = "uart"; ++ groups = "uart2_1_txd_rxd"; ++ }; ++ }; ++}; ++ ++&pcie { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pcie_default>; ++ status = "okay"; ++ ++ pcie@0,0 { ++ status = "okay"; ++ }; ++ ++ pcie@1,0 { ++ status = "okay"; ++ }; ++}; ++ ++&pcie0_phy { ++ status = "okay"; ++}; ++ ++&pcie1_phy { ++ status = "okay"; ++}; ++ ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_pins_a>; ++ status = "okay"; ++}; ++ ++&uart1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart1_pins_a>; ++ status = "okay"; ++}; ++ ++&uart2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart2_pins_b>; ++ status = "okay"; ++}; +diff --git a/configs/mt7623a_unielec_u7623_02_defconfig b/configs/mt7623a_unielec_u7623_02_defconfig +new file mode 100644 +index 0000000000..72b5f31092 +--- /dev/null ++++ b/configs/mt7623a_unielec_u7623_02_defconfig +@@ -0,0 +1,54 @@ ++CONFIG_ARM=y ++CONFIG_SYS_THUMB_BUILD=y ++CONFIG_ARCH_MEDIATEK=y ++CONFIG_SYS_TEXT_BASE=0x81e00000 ++CONFIG_SYS_MALLOC_F_LEN=0x4000 ++CONFIG_ENV_SIZE=0x1000 ++CONFIG_ENV_OFFSET=0x100000 ++CONFIG_TARGET_MT7623=y ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_DISTRO_DEFAULTS=y ++CONFIG_FIT=y ++CONFIG_FIT_VERBOSE=y ++CONFIG_BOOTDELAY=3 ++CONFIG_SYS_CONSOLE_IS_IN_ENV=y ++CONFIG_DEFAULT_FDT_FILE="mt7623a-unielec-u7623-02-emmc.dtb" ++# CONFIG_DISPLAY_BOARDINFO is not set ++CONFIG_SYS_PROMPT="U-Boot> " ++CONFIG_CMD_BOOTMENU=y ++# CONFIG_CMD_ELF is not set ++# CONFIG_CMD_XIMG is not set ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_MMC=y ++CONFIG_CMD_READ=y ++# CONFIG_CMD_SETEXPR is not set ++# CONFIG_CMD_NFS is not set ++CONFIG_DEFAULT_DEVICE_TREE="mt7623a-unielec-u7623-02-emmc" ++CONFIG_ENV_IS_IN_MMC=y ++CONFIG_SYS_RELOC_GD_ENV_ADDR=y ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_REGMAP=y ++CONFIG_SYSCON=y ++CONFIG_CLK=y ++CONFIG_DM_MMC=y ++# CONFIG_MMC_QUIRKS is not set ++CONFIG_SUPPORT_EMMC_BOOT=y ++CONFIG_MMC_HS400_SUPPORT=y ++CONFIG_MMC_MTK=y ++CONFIG_PHY_FIXED=y ++CONFIG_DM_ETH=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7623=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_DM_SERIAL=y ++CONFIG_MTK_SERIAL=y ++CONFIG_SYSRESET=y ++CONFIG_SYSRESET_WATCHDOG=y ++CONFIG_TIMER=y ++CONFIG_MTK_TIMER=y ++CONFIG_WDT_MTK=y ++CONFIG_LZMA=y +-- +2.26.2 + diff --git a/package/boot/uboot-mediatek/patches/010-update-u7623-defconfig.patch b/package/boot/uboot-mediatek/patches/010-update-u7623-defconfig.patch new file mode 100644 index 0000000000..ec189f82dc --- /dev/null +++ b/package/boot/uboot-mediatek/patches/010-update-u7623-defconfig.patch @@ -0,0 +1,17 @@ +diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig +index 6b9fbd7e22..fb2a004803 100644 +--- a/configs/mt7623a_unielec_u7623_02_defconfig ++++ b/configs/mt7623a_unielec_u7623_02_defconfig +@@ -52,3 +52,12 @@ CONFIG_TIMER=y + CONFIG_MTK_TIMER=y + CONFIG_WDT_MTK=y + CONFIG_LZMA=y ++CONFIG_CMD_BOOTZ=y ++CONFIG_OF_LIBFDT_OVERLAY=y ++#enables savenenv-command ++CONFIG_ENV_IS_IN_FAT=y ++CONFIG_ENV_FAT_INTERFACE="mmc" ++CONFIG_ENV_FAT_DEVICE_AND_PART="0:2" ++CONFIG_ENV_FAT_FILE="uboot.env" ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_SETEXPR=y diff --git a/target/linux/mediatek/Makefile b/target/linux/mediatek/Makefile index 47461d49a1..b0e020bce0 100644 --- a/target/linux/mediatek/Makefile +++ b/target/linux/mediatek/Makefile @@ -7,7 +7,6 @@ BOARD:=mediatek BOARDNAME:=MediaTek Ralink ARM SUBTARGETS:=mt7622 mt7623 mt7629 FEATURES:=squashfs nand ramdisk fpu -MAINTAINER:=John Crispin KERNEL_PATCHVER:=4.19 KERNEL_TESTING_PATCHVER:=5.4 diff --git a/target/linux/mediatek/image/Config.in b/target/linux/mediatek/image/Config.in index 0e5449e2f9..ef8536ebab 100644 --- a/target/linux/mediatek/image/Config.in +++ b/target/linux/mediatek/image/Config.in @@ -1,4 +1,4 @@ -config BANANA_PI_BOOT_PARTSIZE - int "Boot (SD Card) filesystem partition size (in MiB)" - depends on TARGET_mediatek_mt7623_DEVICE_bpi_bananapi-r2 || TARGET_DEVICE_mediatek_mt7623_DEVICE_bpi_bananapi-r2 +config MTK_BOOT_PARTSIZE + int "Boot (SD Card/eMMC) filesystem partition size (in MiB)" + depends on TARGET_mediatek_mt7623_DEVICE_bpi_bananapi-r2 || TARGET_DEVICE_mediatek_mt7623_DEVICE_bpi_bananapi-r2 || TARGET_mediatek_mt7623_DEVICE_unielec_u7623-emmc || TARGET_DEVICE_mediatek_mt7623_DEVICE_unielec_u7623-emmc default 32 diff --git a/target/linux/mediatek/image/gen_mt7623_emmc_img.sh b/target/linux/mediatek/image/gen_mt7623_emmc_img.sh index a5f296ef14..b9eedf80b4 100755 --- a/target/linux/mediatek/image/gen_mt7623_emmc_img.sh +++ b/target/linux/mediatek/image/gen_mt7623_emmc_img.sh @@ -1,5 +1,8 @@ #!/bin/sh - +# +# This script is used only to create the "legacy" image for UniElec U7623, +# suitable for upgrading from the vendor OpenWrt or from OpenWrt 19.07. +# OUTPUT_FILE=$1 KERNEL_FILE=$2 RECOVERY_FILE=$3 @@ -7,10 +10,19 @@ ROOTFS_FILE=$4 BS=512 -#These to offsets are relative to the absolute location of the kernel on the mmc -#(0xA00), so their position in the image is -2560 blocks -RECOVERY_OFFSET=67072 -ROOTFS_OFFSET=87552 +# These two offsets are relative to the absolute location of the kernel on the mmc +# (0xA00), so their position in the image is -2560 blocks +# +# They must be kept in sync with the default command line for U7623. +# blkdevparts=mmcblk0:3M@6M(recovery),256M@9M(root)" +# +# For upgrading from the vendor firmware, the total image must fit in its +# MTD 'firmware' partition, which is typically 36MiB. + +# In the legacy image, the uImage starts at block 0xa00. Allow 4864 KiB (9728) blocks. +RECOVERY_OFFSET=9728 +# The recovery image is 3MiB, or 6144 blocks. +ROOTFS_OFFSET=15872 dd bs="$BS" of="$OUTPUT_FILE" if="$KERNEL_FILE" dd bs="$BS" of="$OUTPUT_FILE" if="$RECOVERY_FILE" seek="$RECOVERY_OFFSET" diff --git a/target/linux/mediatek/image/gen_mtk_mmc_img.sh b/target/linux/mediatek/image/gen_mtk_mmc_img.sh new file mode 100755 index 0000000000..ea8a9c63a1 --- /dev/null +++ b/target/linux/mediatek/image/gen_mtk_mmc_img.sh @@ -0,0 +1,150 @@ +#!/bin/sh +# +# Copyright © 2019 Alexey Loukianov +# Copyright © 2020 David Woodhouse +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# Generates a bootable SD card image for Banana Pi R2 (and probably +# other similar boards) as documented at +# http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:storage +# +# The first sector must contain the SDMMC_BOOT header shown +# below, and also contains the MBR partition table in the end +# of the sector. The partition table must contain no active +# partitions. +# +# The second sector must contain the BRLYT header, and the +# special preloader image goes in sector 4; 2KiB into the image. +# +# The preloader loads U-Boot from sector 640; 320KiB into the image. +# The location and the size (512KiB) are fixed and not read from +# the partition table. We set up a partition for it merely for +# our own convenience for upgrades, etc. +# +# The second partition is a FAT file system containing the kernel +# image and a uboot.env file, which is provided to this script as +# $4 (bootfs image). Its size is configurable with the +# CONFIG_MTK_BOOT_PARTSIZE option; by default 32MiB. +# +# The root filesystem comes next in the third partition. +# +# +# ------------------------ Sector Offset +# | MBR + SDMMC_BOOT | 0 0x0 +# |----------------------| +# | BRLYT header | 1 0x200 +# |----------------------| +# . . +# . . +# |----------------------| +# | | 4 0x800 +# | | +# | Preloader | +# . . +# . . +# | | 639 +# |----------------------| +# | MBR partition #1 | 640 0x50000 +# | | +# | U-Boot | +# . . +# . . +# | | 1663 +# |----------------------| +# | MBR partition #2 | +# | | +# | FAT partition | ( MTK_BOOT_PARTSIZE +# . . default 32MiB ) +# . (kernel, uEnv) . +# | | +# |----------------------| +# | MBR partition #3 | +# | | +# | Root partition | +# | | ( TARGET_ROOTFS_PARTSIZE +# | (squashfs+overlay | default 104MiB ) +# . or ext4, etc.) . +# . . +# | | +# ------------------------ +# +# For eMMC boot, everything up to and including the preloader must be +# written to /dev/mmcblk0boot0, with the SDMMC_BOOT header changed to +# read EMMC_BOOT\0 instead. +# +# The contents of the main eMMC are identical to the SD card layout, +# with the preloader loading 512KiB of U-Boot starting at 0x50000. + +usage() { + echo "SYNTAX: $0 sd " + echo " OR: $0 emmc " + exit 1 +} + +set -e + +PRELOADER_OFFSET=2 # 2KiB + +SDMMC_BOOT="SDMMC_BOOT\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00" +EMMC_BOOT="EMMC_BOOT\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00" +BRLYT="BRLYT\x00\x00\x00\x01\x00\x00\x00\x00\x08\x00\x00\ +\x00\x08\x00\x00\x42\x42\x42\x42\x08\x00\x01\x00\x00\x08\x00\x00\ +\x00\x08\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + +case $1 in + sd) + [ $# -eq 9 ] || usage + OUTPUT="$2" + PRELOADER="$3" + UBOOT="$4" + UBOOTOFS="$5" + BOOTFS="$6" + ROOTFS="$7" + BOOTFSSIZE="$8" + ROOTFSSIZE="$9" + + head=4 + sect=63 + + set $(ptgen -o $OUTPUT -h $head -s $sect -a 0 -l 1024 \ + -t 41 -p 512k@${UBOOTOFS} \ + -t c -p ${BOOTFSSIZE}M \ + -t 83 -p ${ROOTFSSIZE}M ) + + UBOOT_OFFSET="$(($1 / 512))" + UBOOT_SIZE="$(($2 / 512))" + BOOTFS_OFFSET="$(($3 / 512))" + BOOTFS_SIZE="$(($4 / 512))" + ROOTFS_OFFSET="$(($5 / 512))" + ROOTFS_SIZE="$(($6 / 512))" + + echo -en "${SDMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0 conv=notrunc + echo -en "${BRLYT}" | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc + + # For eMMC-only boards like U7623 the preloader doesn't need to be included in the + # main image as it's only ever needed in the eMMC boot partition. + if [ -r ${PRELOADER} ]; then + dd bs=1024 if="${PRELOADER}" of="${OUTPUT}" seek="${PRELOADER_OFFSET}" conv=notrunc + fi + dd bs=512 if="${UBOOT}" of="${OUTPUT}" seek="${UBOOT_OFFSET}" conv=notrunc + dd bs=512 if="${BOOTFS}" of="${OUTPUT}" seek="${BOOTFS_OFFSET}" conv=notrunc + dd bs=512 if="${ROOTFS}" of="${OUTPUT}" seek="${ROOTFS_OFFSET}" conv=notrunc + dd bs=128k if=/dev/zero of="${OUTPUT}" count=1 oflag=append conv=notrunc + ;; + emmc) + [ $# -eq 3 ] || usage + OUTPUT="$2" + PRELOADER="$3" + + echo -en "${EMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0 + echo -en "${BRLYT}" | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc + + dd bs=1024 if="${PRELOADER}" of="${OUTPUT}" seek="${PRELOADER_OFFSET}" conv=notrunc + ;; + *) + usage + ;; +esac diff --git a/target/linux/mediatek/image/gen_scatterfile.sh b/target/linux/mediatek/image/gen_scatterfile.sh new file mode 100755 index 0000000000..f23cf819b8 --- /dev/null +++ b/target/linux/mediatek/image/gen_scatterfile.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# +# Copyright © 2020 David Woodhouse +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# Generate as "scatter file" for use with the MediaTek SP Flash tool for +# writing images to MediaTek boards. This can be used to write images +# even on a bricked board which has no preloader installed, or broken +# U-Boot. +# +# NOTE: At the time of writing (2020-07-20), the Linux tool linked from +# the front page of https://spflashtool.com/ is out of date and does not +# support MT7623. The newer v5.1916 found on the download page at +# https://spflashtool.com/download/ has been tested on UniElec U7623 and +# Banana Pi R2 from Linux, and does work. +# + +SOC=$1 +IMAGE=${2%.gz} +PROJECT=${3%-scatter.txt} +DEVICENAME="$4" + +cat < $@ +endef + define Device/bpi_bananapi-r2 DEVICE_VENDOR := Bpi DEVICE_MODEL := Banana Pi R2 DEVICE_DTS := mt7623n-bananapi-bpi-r2 - KERNEL_NAME := zImage - KERNEL := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb - KERNEL_INITRAMFS := DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk + UBOOT_ENVSIZE := 0x2000 + UBOOT_OFFSET := 320k UBOOT_TARGET := mt7623n_bpir2 IMAGES := img.gz - IMAGE/img.gz := banana-pi-sdcard | gzip | append-metadata + IMAGE/img.gz := mtk-mmc-img | gzip | append-metadata + ARTIFACT/preloader.bin := preloader $$(UBOOT_TARGET) + ARTIFACT/scatter.txt := scatterfile $$(firstword $$(FILESYSTEMS))-$$(firstword $$(IMAGES)) + ARTIFACTS = preloader.bin scatter.txt SUPPORTED_DEVICES := bananapi,bpi-r2 endef TARGET_DEVICES += bpi_bananapi-r2 -define Device/unielec_u7623-02-emmc-512m +# Full eMMC image including U-Boot and partition table +define Device/unielec_u7623-emmc + DEVICE_VENDOR := UniElec + DEVICE_MODEL := U7623 + DEVICE_VARIANT := eMMC + # When we use FIT images, U-Boot will populate the /memory node with the correct + # memory size discovered from the preloader, so we don't need separate builds. + DEVICE_DTS := mt7623a-unielec-u7623-02-emmc-512m + SUPPORTED_DEVICES := unielec,u7623-02-emmc-512m + UBOOT_ENVSIZE := 0x1000 + UBOOT_OFFSET := 256k + UBOOT_TARGET := mt7623a_unielec_u7623 + IMAGES := img.gz + IMAGE/img.gz := mtk-mmc-img | gzip | append-metadata + DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ + mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk + ARTIFACT/scatter.txt := scatterfile $$(firstword $$(FILESYSTEMS))-$$(firstword $$(IMAGES)) + ARTIFACTS := scatter.txt +endef +TARGET_DEVICES += unielec_u7623-emmc + +# Legacy partial image for U7623 +# This preserves the vendor U-Boot and starts with a uImage at 0xA00 +define Device/unielec_u7623-02-emmc-512m-legacy DEVICE_VENDOR := UniElec DEVICE_MODEL := U7623-02 - DEVICE_VARIANT := eMMC/512MB RAM + DEVICE_VARIANT := eMMC/512MiB RAM (legacy image) DEVICE_DTS := mt7623a-unielec-u7623-02-emmc-512m KERNEL_NAME := zImage KERNEL := kernel-bin | append-dtb | uImage none @@ -53,5 +90,6 @@ define Device/unielec_u7623-02-emmc-512m mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk IMAGES := sysupgrade-emmc.bin.gz IMAGE/sysupgrade-emmc.bin.gz := sysupgrade-emmc | gzip | append-metadata + SUPPORTED_DEVICES := unielec,u7623-02-emmc-512m endef -TARGET_DEVICES += unielec_u7623-02-emmc-512m +TARGET_DEVICES += unielec_u7623-02-emmc-512m-legacy diff --git a/target/linux/mediatek/image/mt7623a_unielec_u7623-uEnv.txt b/target/linux/mediatek/image/mt7623a_unielec_u7623-uEnv.txt new file mode 100644 index 0000000000..5e5f8cae73 --- /dev/null +++ b/target/linux/mediatek/image/mt7623a_unielec_u7623-uEnv.txt @@ -0,0 +1,20 @@ +# Boot menu for UniElec U7623 +# Copyright © 2020 David Woodhouse + +kernel=uImage +loadaddr=0x88000000 +dtaddr=0x83f00000 +fdt_high=0xafffffff + +console=ttyS0,115200 +bootopts=rootfstype=squashfs,ext4 rootwait + +# Create the command line (with appropriate root=) and boot the Linux FIT image. +boot1=setenv bootargs "console=${console} root=${rootdev} ${bootopts}";printenv bootargs;\ + fatload mmc ${partition} ${loadaddr} ${kernel}; bootm + +bootmenu_0=Boot from eMMC.=setenv partition 0:2;setenv rootdev /dev/mmcblk0p3;run boot1 +bootmenu_default=0 + +bootdelay=0 +bootcmd=bootmenu diff --git a/target/linux/mediatek/mt7622/config-4.19 b/target/linux/mediatek/mt7622/config-4.19 index e102308a98..e72bff61e4 100644 --- a/target/linux/mediatek/mt7622/config-4.19 +++ b/target/linux/mediatek/mt7622/config-4.19 @@ -577,7 +577,6 @@ CONFIG_TREE_SRCU=y # CONFIG_UNMAP_KERNEL_AT_EL0 is not set CONFIG_USB=y CONFIG_USB_COMMON=y -# CONFIG_USB_EHCI_HCD is not set CONFIG_USB_SUPPORT=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_MTK=y diff --git a/target/linux/mediatek/mt7622/config-5.4 b/target/linux/mediatek/mt7622/config-5.4 index ce257fa9e0..92da879a82 100755 --- a/target/linux/mediatek/mt7622/config-5.4 +++ b/target/linux/mediatek/mt7622/config-5.4 @@ -580,7 +580,6 @@ CONFIG_UBIFS_FS_ZLIB=y # CONFIG_UNMAP_KERNEL_AT_EL0 is not set CONFIG_USB=y CONFIG_USB_COMMON=y -# CONFIG_USB_EHCI_HCD is not set CONFIG_USB_SUPPORT=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_MTK=y diff --git a/target/linux/mediatek/mt7622/target.mk b/target/linux/mediatek/mt7622/target.mk index d4ec3cb661..dd4459724e 100644 --- a/target/linux/mediatek/mt7622/target.mk +++ b/target/linux/mediatek/mt7622/target.mk @@ -2,7 +2,7 @@ ARCH:=aarch64 SUBTARGET:=mt7622 BOARDNAME:=MT7622 CPU_TYPE:=cortex-a53 -DEFAULT_PACKAGES += kmod-mt7615e wpad-basic +DEFAULT_PACKAGES += kmod-mt7615e kmod-mt7615-firmware wpad-basic KERNELNAME:=Image dtbs define Target/Description diff --git a/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac b/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac index 60b699d9c9..7b165df565 100644 --- a/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac +++ b/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac @@ -42,16 +42,22 @@ preinit_set_mac_address() { local rootpart case $(board_name) in - bananapi,bpi-r2) + bananapi,bpi-r2|\ + unielec,u7623-02-emmc-512m) rootpart=$(cat /proc/cmdline) rootpart="${rootpart##*root=}" - rootpart="${rootpart%%p3 *}" - if [ "$rootpart" = "/dev/mmcblk0" -o "$rootpart" = "/dev/mmcblk1" ]; then - set_recovery_mac_address ${rootpart}p2 - fi - ;; - unielec,u7623-02-emmc-512m) - set_recovery_mac_address /dev/mmcblk0p1 + rootpart="${rootpart%% *}" + case $rootpart in + /dev/mmcblk0p2) # Legacy U7623 image + set_recovery_mac_address /dev/mmcblk0p1 + ;; + /dev/mmcblk0p3) # U7623 or Banana Pi R2 eMMC + set_recovery_mac_address /dev/mmcblk0p2 + ;; + /dev/mmcblk1p3) # Banana Pi R2 SD + set_recovery_mac_address /dev/mmcblk1p2 + ;; + esac ;; esac } diff --git a/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config b/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config index cbb6c604c8..f47894c0fd 100644 --- a/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config +++ b/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config @@ -10,7 +10,11 @@ move_config() { partnum=2 ;; unielec,u7623-02-emmc-512m) - partnum=1 + if grep -q root=/dev/mmcblk0p2 /proc/cmdline; then + partnum=1; + else + partnum=2; + fi ;; *) return 1 diff --git a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh index 0dda59cdd3..d3da22d496 100755 --- a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh @@ -1,92 +1,113 @@ + +REQUIRE_IMAGE_METADATA=1 + +# Full system upgrade including preloader for MediaTek SoCs on eMMC or SD +mtk_mmc_full_upgrade() { + local diskdev partdev diff oldrecovery + + if grep -q root=/dev/mmcblk0p2 /proc/cmdline; then + oldrecovery=1 + else + oldrecovery=2 + fi + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + #Keep the persistent random mac address (if it exists) + mkdir -p /tmp/recovery + export_partdevice recoverydev $oldrecovery + if mount -o rw,noatime "/dev/$recoverydev" -tvfat /tmp/recovery; then + [ -f "/tmp/recovery/mac_addr" ] && cp /tmp/recovery/mac_addr /tmp/ + umount /tmp/recovery + fi + sync + + if [ "$SAVE_PARTITIONS" = "1" ]; then + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + else + diff=1 + fi + + if [ -n "$diff" ]; then + get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync + + # Separate removal and addition is necessary; otherwise, partition 1 + # will be missing if it overlaps with the old partition 2 + partx -d - "/dev/$diskdev" + partx -a - "/dev/$diskdev" + else + # iterate over each partition from the image and write it to the boot disk + while read part start size; do + part="$(($part - 2))" + if export_partdevice partdev $part; then + echo "Writing image to /dev/$partdev..." + get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync + else + echo "Unable to find partition $part device, skipped." + fi + done < /tmp/partmap.image + + #copy partition uuid + echo "Writing new UUID to /dev/$diskdev..." + get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync + fi + + export_partdevice recoverydev 2 + if mount -o rw,noatime "/dev/$recoverydev" -t vfat /tmp/recovery; then + [ -f "/tmp/mac_addr" ] && cp /tmp/mac_addr /tmp/recovery + + if [ "$diskdev" = "mmcblk0" -a -r /tmp/recovery/eMMCboot.bin ]; then + echo 0 > /sys/block/mmcblk0boot0/force_ro + dd if=/tmp/recovery/eMMCboot.bin of=/dev/mmcblk0boot0 conv=fsync + sync + echo 1 > /sys/block/mmcblk0boot0/force_ro + fi + sync + umount /tmp/recovery + fi +} + platform_do_upgrade() { local board=$(board_name) case "$board" in bananapi,bpi-r2) - local diskdev partdev diff - - export_bootdevice && export_partdevice diskdev 0 || { - echo "Unable to determine upgrade device" - return 1 - } - - #Keep the persistent random mac address (if it exists) - mkdir -p /tmp/recovery - export_partdevice recoverydev 2 - if mount -o rw,noatime "/dev/$recoverydev" -tvfat /tmp/recovery; then - [ -f "/tmp/recovery/mac_addr" ] && cp /tmp/recovery/mac_addr /tmp/ - umount /tmp/recovery - fi - sync - - if [ "$SAVE_PARTITIONS" = "1" ]; then - get_partitions "/dev/$diskdev" bootdisk - - #extract the boot sector from the image - get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b - - get_partitions /tmp/image.bs image - - #compare tables - diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" - else - diff=1 - fi - - if [ -n "$diff" ]; then - get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync - - # Separate removal and addtion is necessary; otherwise, partition 1 - # will be missing if it overlaps with the old partition 2 - partx -d - "/dev/$diskdev" - partx -a - "/dev/$diskdev" - else - #iterate over each partition from the image and write it to the boot disk - while read part start size; do - part="$(($part - 2))" - if export_partdevice partdev $part; then - echo "Writing image to /dev/$partdev..." - get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync - else - echo "Unable to find partition $part device, skipped." - fi - done < /tmp/partmap.image - - #copy partition uuid - echo "Writing new UUID to /dev/$diskdev..." - get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync - fi - - if mount -o rw,noatime "/dev/$recoverydev" -t vfat /tmp/recovery; then - [ -f "/tmp/mac_addr" ] && cp /tmp/mac_addr /tmp/recovery - - if [ "$diskdev" = "mmcblk0" -a -r /tmp/recovery/eMMCboot.bin ]; then - echo 0 > /sys/block/mmcblk0boot0/force_ro - dd if=/tmp/recovery/eMMCboot.bin of=/dev/mmcblk0boot0 conv=fsync - sync - echo 1 > /sys/block/mmcblk0boot0/force_ro - fi - sync - umount /tmp/recovery - fi + mtk_mmc_full_upgrade "$1" ;; unielec,u7623-02-emmc-512m) - #Keep the persisten random mac address (if it exists) - mkdir -p /tmp/recovery - mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery - [ -f "/tmp/recovery/mac_addr" ] && \ - mv -f /tmp/recovery/mac_addr /tmp/ - umount /tmp/recovery + local magic="$(get_magic_long "$1")" + if [ "$magic" = "53444d4d" ]; then + mtk_mmc_full_upgrade "$1" + else # Old partial image starting with uImage + # Keep the persistent random mac address (if it exists) + recoverydev=mmcblk0p1 + mkdir -p /tmp/recovery + mount -o rw,noatime /dev/$recoverydev /tmp/recovery + [ -f "/tmp/recovery/mac_addr" ] && \ + mv -f /tmp/recovery/mac_addr /tmp/ + umount /tmp/recovery - #1310720 is the offset in bytes from the start of eMMC and to - #the location of the kernel (2560 512 byte sectors) - get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync + # 1310720 is the offset in bytes from the start of eMMC and to + # the location of the kernel (2560 512 byte sectors) + get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync - mount -o rw,noatime /dev/mmcblk0p1 /tmp/recovery - [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery - sync - umount /tmp/recovery + mount -o rw,noatime /dev/$recoverydev /tmp/recovery + [ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery + sync + umount /tmp/recovery + fi ;; *) default_do_upgrade "$1" @@ -133,10 +154,21 @@ platform_check_image() { fi ;; unielec,u7623-02-emmc-512m) + # Can always upgrade to the new-style full image + [ "$magic" = "53444d4d" ] && return 0 + + # Legacy uImage directly at 0xA00 on the eMMC. [ "$magic" != "27051956" ] && { echo "Invalid image type." return 1 } + rootpart=$(cat /proc/cmdline) + rootpart="${rootpart##*root=}" + rootpart="${rootpart%% *}" + [ "$rootpart" != "/dev/mmcblk0p2" ] && { + echo "Cannot downgrade to legacy image." + return 1 + } return 0 ;; *) @@ -148,25 +180,18 @@ platform_check_image() { return 0 } -platform_copy_config_emmc() { - local partdev - - if export_bootdevice && export_partdevice partdev $1; then - mkdir -p /recovery - mount -o rw,noatime "/dev/$partdev" -t vfat /recovery - cp -af "$CONF_TAR" "/recovery/$CONF_TAR" - sync - umount /recovery - fi -} - platform_copy_config() { case "$(board_name)" in - bananapi,bpi-r2) - platform_copy_config_emmc 2 - ;; + bananapi,bpi-r2|\ unielec,u7623-02-emmc-512m) - platform_copy_config_emmc 1 + # platform_do_upgrade() will have set $recoverydev + if [ -n "$recoverydev" ]; then + mkdir -p /tmp/recovery + mount -o rw,noatime "/dev/$recoverydev" -t vfat /tmp/recovery + cp -af "$UPGRADE_BACKUP" "/tmp/recovery/$BACKUP_FILE" + sync + umount /tmp/recovery + fi ;; esac } diff --git a/target/linux/mediatek/mt7623/config-4.19 b/target/linux/mediatek/mt7623/config-4.19 index 57c0148199..994768bb64 100644 --- a/target/linux/mediatek/mt7623/config-4.19 +++ b/target/linux/mediatek/mt7623/config-4.19 @@ -496,7 +496,6 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_UNINLINE_SPIN_UNLOCK=y CONFIG_USB=y CONFIG_USB_COMMON=y -# CONFIG_USB_EHCI_HCD is not set CONFIG_USB_SUPPORT=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_MTK=y diff --git a/target/linux/mediatek/mt7623/config-5.4 b/target/linux/mediatek/mt7623/config-5.4 index 2ebdae7077..83ff7b3111 100644 --- a/target/linux/mediatek/mt7623/config-5.4 +++ b/target/linux/mediatek/mt7623/config-5.4 @@ -70,6 +70,7 @@ CONFIG_CLKSRC_MMIO=y CONFIG_CLONE_BACKWARDS=y CONFIG_CMDLINE="earlyprintk console=ttyS0,115200 rootfstype=squashfs,jffs2" CONFIG_CMDLINE_FROM_BOOTLOADER=y +CONFIG_CMDLINE_PARTITION=y CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_MEDIATEK=y CONFIG_COMMON_CLK_MT2701=y diff --git a/target/linux/mediatek/mt7629/config-4.19 b/target/linux/mediatek/mt7629/config-4.19 index 98d67a0fbd..7bf014d151 100644 --- a/target/linux/mediatek/mt7629/config-4.19 +++ b/target/linux/mediatek/mt7629/config-4.19 @@ -357,7 +357,6 @@ CONFIG_UBIFS_FS_ZLIB=y CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_USB=y CONFIG_USB_COMMON=y -# CONFIG_USB_EHCI_HCD is not set CONFIG_USB_SUPPORT=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_MTK=y diff --git a/target/linux/mediatek/mt7629/config-5.4 b/target/linux/mediatek/mt7629/config-5.4 index 3805eba40e..1dbf1787cb 100644 --- a/target/linux/mediatek/mt7629/config-5.4 +++ b/target/linux/mediatek/mt7629/config-5.4 @@ -362,7 +362,6 @@ CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_UNWINDER_ARM=y CONFIG_USB=y CONFIG_USB_COMMON=y -# CONFIG_USB_EHCI_HCD is not set CONFIG_USB_SUPPORT=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_MTK=y diff --git a/target/linux/mediatek/patches-5.4/0227-arm-dts-Add-Unielec-U7623-DTS.patch b/target/linux/mediatek/patches-5.4/0227-arm-dts-Add-Unielec-U7623-DTS.patch index 255445360f..7def128daf 100644 --- a/target/linux/mediatek/patches-5.4/0227-arm-dts-Add-Unielec-U7623-DTS.patch +++ b/target/linux/mediatek/patches-5.4/0227-arm-dts-Add-Unielec-U7623-DTS.patch @@ -44,7 +44,7 @@ Subject: [PATCH] arm: dts: Add Unielec U7623 DTS +}; --- /dev/null +++ b/arch/arm/boot/dts/mt7623a-unielec-u7623-02-emmc.dtsi -@@ -0,0 +1,349 @@ +@@ -0,0 +1,343 @@ +/* + * Copyright 2018 Kristian Evensen + * @@ -63,7 +63,7 @@ Subject: [PATCH] arm: dts: Add Unielec U7623 DTS + }; + + chosen { -+ bootargs = "root=/dev/mmcblk0p2 rootfstype=squashfs,f2fs"; ++ bootargs = "root=/dev/mmcblk0p2 rootfstype=squashfs,f2fs console=ttyS0,115200 blkdevparts=mmcblk0:3M@6M(recovery),256M@9M(root)"; + stdout-path = "serial2:115200n8"; + }; + @@ -141,12 +141,6 @@ Subject: [PATCH] arm: dts: Add Unielec U7623 DTS + default-state = "off"; + }; + }; -+ -+ mt7530: switch@0 { -+ compatible = "mediatek,mt7530"; -+ #address-cells = <1>; -+ #size-cells = <0>; -+ }; +}; + +&crypto { @@ -171,9 +165,9 @@ Subject: [PATCH] arm: dts: Add Unielec U7623 DTS + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; -+ phy5: ethernet-phy@5 { -+ reg = <5>; -+ phy-mode = "rgmii-rxid"; ++ ++ mt7530: switch@0 { ++ compatible = "mediatek,mt7530"; + }; + }; +}; diff --git a/target/linux/mediatek/patches-5.4/0402-net-ethernet-mtk_eth_soc-Always-call-mtk_gmac0_rgmii.patch b/target/linux/mediatek/patches-5.4/0402-net-ethernet-mtk_eth_soc-Always-call-mtk_gmac0_rgmii.patch new file mode 100644 index 0000000000..0dc50f28d8 --- /dev/null +++ b/target/linux/mediatek/patches-5.4/0402-net-ethernet-mtk_eth_soc-Always-call-mtk_gmac0_rgmii.patch @@ -0,0 +1,62 @@ +In-Reply-To: +References: +Subject: [PATCH] net: ethernet: mtk_eth_soc: Always call mtk_gmac0_rgmii_adjust() for mt7623 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: René van Dorst + +Modify mtk_gmac0_rgmii_adjust() so it can always be called. +mtk_gmac0_rgmii_adjust() sets-up the TRGMII clocks. + +Signed-off-by: René van Dorst +Signed-off-By: David Woodhouse +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 19 ++++++++++++++----- + 1 file changed, 14 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +index b5408c5b954a..f89f225ab144 100644 +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -171,11 +171,21 @@ static int mt7621_gmac0_rgmii_adjust(struct mtk_eth *eth, + return 0; + } + +-static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, int speed) ++static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, ++ phy_interface_t interface, int speed) + { + u32 val; + int ret; + ++ if (interface == PHY_INTERFACE_MODE_TRGMII) { ++ mtk_w32(eth, TRGMII_MODE, INTF_MODE); ++ val = 500000000; ++ ret = clk_set_rate(eth->clks[MTK_CLK_TRGPLL], val); ++ if (ret) ++ dev_err(eth->dev, "Failed to set trgmii pll: %d\n", ret); ++ return; ++ } ++ + val = (speed == SPEED_1000) ? + INTF_MODE_RGMII_1000 : INTF_MODE_RGMII_10_100; + mtk_w32(eth, val, INTF_MODE); +@@ -262,10 +272,9 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, + state->interface)) + goto err_phy; + } else { +- if (state->interface != +- PHY_INTERFACE_MODE_TRGMII) +- mtk_gmac0_rgmii_adjust(mac->hw, +- state->speed); ++ mtk_gmac0_rgmii_adjust(mac->hw, ++ state->interface, ++ state->speed); + + /* mt7623_pad_clk_setup */ + for (i = 0 ; i < NUM_TRGMII_CTRL; i++) +-- +2.26.2 + diff --git a/target/linux/mediatek/patches-5.4/0991-dt-bindings-PCI-Mediatek-Update-PCIe-binding.patch b/target/linux/mediatek/patches-5.4/0991-dt-bindings-PCI-Mediatek-Update-PCIe-binding.patch old mode 100755 new mode 100644 index 2c7e311836..02e4c130ea --- a/target/linux/mediatek/patches-5.4/0991-dt-bindings-PCI-Mediatek-Update-PCIe-binding.patch +++ b/target/linux/mediatek/patches-5.4/0991-dt-bindings-PCI-Mediatek-Update-PCIe-binding.patch @@ -143,9 +143,6 @@ Signed-off-by: chuanjia.liu 2 files changed, 129 insertions(+), 53 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/mediatek-pcie-cfg.yaml -diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie-cfg.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie-cfg.yaml -new file mode 100644 -index 000000000000..4d2835ab4858 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/mediatek-pcie-cfg.yaml @@ -0,0 +1,38 @@ @@ -187,8 +184,6 @@ index 000000000000..4d2835ab4858 + reg = <0 0x1a140000 0 0x1000>; + }; +... -diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie.txt b/Documentation/devicetree/bindings/pci/mediatek-pcie.txt -index 7468d666763a..ddae110d4379 100644 --- a/Documentation/devicetree/bindings/pci/mediatek-pcie.txt +++ b/Documentation/devicetree/bindings/pci/mediatek-pcie.txt @@ -8,7 +8,7 @@ Required properties: diff --git a/target/linux/mediatek/patches-5.4/0992-PCI-mediatek-Use-regmap-to-get-shared-pcie-cfg-base.patch b/target/linux/mediatek/patches-5.4/0992-PCI-mediatek-Use-regmap-to-get-shared-pcie-cfg-base.patch old mode 100755 new mode 100644 index e773e2e676..3e4d44f59e --- a/target/linux/mediatek/patches-5.4/0992-PCI-mediatek-Use-regmap-to-get-shared-pcie-cfg-base.patch +++ b/target/linux/mediatek/patches-5.4/0992-PCI-mediatek-Use-regmap-to-get-shared-pcie-cfg-base.patch @@ -132,8 +132,6 @@ Signed-off-by: chuanjia.liu drivers/pci/controller/pcie-mediatek.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) -diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c -index cb982891b22b..2268d6073eb6 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -14,6 +14,7 @@ @@ -167,8 +165,8 @@ index cb982891b22b..2268d6073eb6 100644 + struct regmap *cfg; struct clk *free_ck; - struct list_head ports; -@@ -650,7 +654,7 @@ static int mtk_pcie_setup_irq(struct mtk_pcie_port *port, + struct resource mem; +@@ -651,7 +655,7 @@ static int mtk_pcie_setup_irq(struct mtk return err; } @@ -177,9 +175,9 @@ index cb982891b22b..2268d6073eb6 100644 irq_set_chained_handler_and_data(port->irq, mtk_pcie_intr_handler, port); -@@ -673,12 +677,11 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) - if (!mem) - return -EINVAL; +@@ -666,12 +670,11 @@ static int mtk_pcie_startup_port_v2(stru + u32 val; + int err; - /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ - if (pcie->base) { @@ -195,7 +193,7 @@ index cb982891b22b..2268d6073eb6 100644 } /* Assert all reset signals */ -@@ -984,6 +987,7 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) +@@ -977,6 +980,7 @@ static int mtk_pcie_subsys_powerup(struc struct device *dev = pcie->dev; struct platform_device *pdev = to_platform_device(dev); struct resource *regs; @@ -203,7 +201,7 @@ index cb982891b22b..2268d6073eb6 100644 int err; /* get shared registers, which are optional */ -@@ -996,6 +1000,13 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) +@@ -989,6 +993,13 @@ static int mtk_pcie_subsys_powerup(struc } } diff --git a/target/linux/mediatek/patches-5.4/0993-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch b/target/linux/mediatek/patches-5.4/0993-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch old mode 100755 new mode 100644 index 7d3c55c0e4..48713ecc64 --- a/target/linux/mediatek/patches-5.4/0993-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch +++ b/target/linux/mediatek/patches-5.4/0993-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch @@ -144,11 +144,9 @@ Signed-off-by: chuanjia.liu arch/arm64/boot/dts/mediatek/mt7622.dtsi | 68 +++++++++++------ 4 files changed, 96 insertions(+), 69 deletions(-) -diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi -index 2cd8b33886e5..ab27ff4a869e 100644 --- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi -@@ -797,60 +797,73 @@ +@@ -791,60 +791,73 @@ }; }; @@ -253,11 +251,9 @@ index 2cd8b33886e5..ab27ff4a869e 100644 interrupt-controller; #address-cells = <0>; #interrupt-cells = <1>; -diff --git a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -index 83e10591e0e5..7574d88cc46a 100644 --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -207,18 +207,16 @@ +@@ -294,18 +294,16 @@ }; }; @@ -283,11 +279,9 @@ index 83e10591e0e5..7574d88cc46a 100644 }; &pio { -diff --git a/arch/arm64/boot/dts/mediatek/mt7622.dtsi b/arch/arm64/boot/dts/mediatek/mt7622.dtsi -index 339dc9f88f43..d5131c8b6a79 100644 --- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi -@@ -766,45 +766,41 @@ +@@ -790,45 +790,41 @@ #reset-cells = <1>; }; @@ -350,7 +344,7 @@ index 339dc9f88f43..d5131c8b6a79 100644 interrupt-map-mask = <0 0 0 7>; interrupt-map = <0 0 0 1 &pcie_intc0 0>, <0 0 0 2 &pcie_intc0 1>, -@@ -816,15 +812,39 @@ +@@ -840,15 +836,39 @@ #interrupt-cells = <1>; }; }; @@ -393,8 +387,8 @@ index 339dc9f88f43..d5131c8b6a79 100644 interrupt-map-mask = <0 0 0 7>; interrupt-map = <0 0 0 1 &pcie_intc1 0>, <0 0 0 2 &pcie_intc1 1>, ---- a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts 2020-06-15 18:52:25.092948824 +0800 -+++ b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts 2020-06-15 18:52:15.909094229 +0800 +--- a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts @@ -244,18 +244,16 @@ }; }; diff --git a/target/linux/mediatek/patches-5.4/0994-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch b/target/linux/mediatek/patches-5.4/0994-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch old mode 100755 new mode 100644 index 4ba99d89d0..b20e1fce6c --- a/target/linux/mediatek/patches-5.4/0994-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch +++ b/target/linux/mediatek/patches-5.4/0994-ARM-dts-mediatek-Update-mt7629-PCIe-node.patch @@ -133,11 +133,9 @@ Signed-off-by: chuanjia.liu arch/arm/boot/dts/mt7629.dtsi | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) -diff --git a/arch/arm/boot/dts/mt7629-rfb.dts b/arch/arm/boot/dts/mt7629-rfb.dts -index 9980c10c6e29..eb536cbebd9b 100644 --- a/arch/arm/boot/dts/mt7629-rfb.dts +++ b/arch/arm/boot/dts/mt7629-rfb.dts -@@ -140,9 +140,10 @@ +@@ -171,9 +171,10 @@ }; }; @@ -149,11 +147,9 @@ index 9980c10c6e29..eb536cbebd9b 100644 }; &pciephy1 { -diff --git a/arch/arm/boot/dts/mt7629.dtsi b/arch/arm/boot/dts/mt7629.dtsi -index 5cbb3d244c75..94567307b842 100644 --- a/arch/arm/boot/dts/mt7629.dtsi +++ b/arch/arm/boot/dts/mt7629.dtsi -@@ -360,16 +360,21 @@ +@@ -368,16 +368,21 @@ #reset-cells = <1>; }; @@ -181,7 +177,7 @@ index 5cbb3d244c75..94567307b842 100644 clocks = <&pciesys CLK_PCIE_P1_MAC_EN>, <&pciesys CLK_PCIE_P0_AHB_EN>, <&pciesys CLK_PCIE_P1_AUX_EN>, -@@ -390,21 +395,19 @@ +@@ -398,21 +403,19 @@ power-domains = <&scpsys MT7622_POWER_DOMAIN_HIF0>; bus-range = <0x00 0xff>; ranges = <0x82000000 0 0x20000000 0x20000000 0 0x10000000>;