* [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL
@ 2026-11-06 21:35 David Lechner
2026-11-06 21:35 ` [PATCH 1/7] tools: mtk_image: add UFS support David Lechner
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Add support for booting the Genio 520 and 720 EVKs from UFS when U-Boot
SPL replaces the platform BL2.
mkimage gains the UFS BootROM image header, and the MediaTek UFS driver
skips its secure monitor calls when running at EL3, as it does in SPL.
SPL can then load the firmware FIT from UFS. A new config fragment,
mt8189-genio-spl-ufs.config, selects the UFS boot and sets the BootROM
image header to UFS. The DDR loader that runs before SPL must also be
built for UFS.
This series depends on:
- "spl: ufs: add UFS boot support for Qualcomm" v4, which adds the
generic SPL UFS loader:
https://lore.kernel.org/u-boot/20261019-spl_ufs-v4-0-61432d0b258c@oss.qualcomm.com/
- "mediatek: mt8189: add U-Boot SPL boot for Genio 520 and 720" v2
Tested on the Genio 720 EVK booting from UFS.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
David Lechner (6):
ufs: mediatek: skip SiP calls when running at EL3
arm: dts: mediatek: prepare Genio 520 and 720 UFS for SPL
arm: mediatek: load the next stage from UFS in SPL
arm: mediatek: make the BootROM header info configurable
board: mediatek: add a Genio 520/720 UFS boot config fragment
doc: board: mediatek: describe booting Genio 520 and 720 from UFS
Fabien Parent (1):
tools: mtk_image: add UFS support
arch/arm/dts/mt8371-genio-common-u-boot.dtsi | 17 ++++-
arch/arm/mach-mediatek/Kconfig | 7 +-
arch/arm/mach-mediatek/spl.c | 2 +
board/mediatek/MAINTAINERS | 1 +
board/mediatek/mt8189-genio-spl-ufs.config | 10 +++
doc/README.mediatek | 1 +
doc/board/mediatek/mt8189-genio-evk.rst | 39 +++++++++--
drivers/ufs/ufs-mediatek-sip.h | 5 ++
tools/mtk_image.c | 97 ++++++++++++++++++++++++++++
tools/mtk_image.h | 16 ++++-
10 files changed, 185 insertions(+), 10 deletions(-)
---
base-commit: d1d45c926a571fb6c1e6d7105c280833646915ea
base-tree: https://git.u-boot-project.org/u-boot/u-boot.git main
change-id: 20261013-mtk-genio-720-spl-ufs-4ac6af78de70
prerequisite-message-id: <20261019-spl_ufs-v4-0-61432d0b258c@oss.qualcomm.com>
prerequisite-patch-id: 8adf07351c5a4eb61976ceeced2d0ab0eadf235d
prerequisite-patch-id: 55ead548e0a7c82c4296cc9b9fa047f110c1e306
prerequisite-patch-id: 34bbdb130ae694420b954f41a536b8eb8df77791
prerequisite-patch-id: 5a62f8304a1790b31accf47af84815bffaa92b89
prerequisite-patch-id: d2e87bf5a992d19bde372fb230f4589242f12d40
prerequisite-patch-id: 0429aaac18b3a3d564662f2b93aa3af755c880db
prerequisite-patch-id: a577a9e2266f5b16dd0bf1b8b4312952f736380d
prerequisite-patch-id: 3223b00fa7e9c330054e19f256b4e601008160f2
prerequisite-patch-id: f1cf16250799f803bde22d6dae704cc5338ec76c
prerequisite-change-id: 20261013-mtk-genio-720-spl-1620416c6224:v2
prerequisite-patch-id: f109e3e09ffe96d42ba64923f72a2081764a0837
prerequisite-patch-id: 1b7d8c90462884a830b2c4e43bbc7b7d698d7410
prerequisite-patch-id: 8f4cb6976f7c28cf7c2acf3e81ce240e47dcb113
prerequisite-patch-id: 789a3616e548a97eb48ffd62cd59f114bda6d94b
prerequisite-patch-id: 521533b5bb8d1e145d036ea7f9f9e8a7f0856e78
prerequisite-patch-id: 7debdd01277d15f23a983475c7b7bbf05af82175
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/7] tools: mtk_image: add UFS support
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
@ 2026-11-06 21:35 ` David Lechner
2026-11-11 19:04 ` Carlo Caione
2026-11-06 21:35 ` [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3 David Lechner
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
From: Fabien Parent <fparent@baylibre.com>
Add support for generating images that can boot on UFS storage for
MediaTek SoCs.
The UFS device header is 4 KiB instead of 1.5 KiB, and the size field
of its generic boot header covers the whole device header.
Signed-off-by: Fabien Parent <fparent@baylibre.com>
[dlechner: rebase, fix header size check when verifying, document the
ufs media type, use mtk_image_verify_gfh()]
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
doc/README.mediatek | 1 +
tools/mtk_image.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/mtk_image.h | 16 +++++++--
3 files changed, 112 insertions(+), 2 deletions(-)
diff --git a/doc/README.mediatek b/doc/README.mediatek
index 246579d4be2..d38709408b7 100644
--- a/doc/README.mediatek
+++ b/doc/README.mediatek
@@ -107,6 +107,7 @@ To generate these two headers with mkimage:
nor : Serial NOR
emmc : eMMC
sdmmc: SD
+ ufs : UFS
nandinfo: Desired NAND device type, a combination of page size, oob size and
optional device capacity. Valid types are:
diff --git a/tools/mtk_image.c b/tools/mtk_image.c
index 1b1aed59924..ac9c86df6bd 100644
--- a/tools/mtk_image.c
+++ b/tools/mtk_image.c
@@ -36,6 +36,9 @@ static const struct brom_img_type {
}, {
.name = "spim-nand",
.type = BRLYT_TYPE_SNAND
+ }, {
+ .name = "ufs",
+ .type = BRLYT_TYPE_UFS
}
};
@@ -262,6 +265,8 @@ static int mtk_image_vrec_header(struct image_tool_params *params,
if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND)
tparams->header_size = hdr_nand_size;
+ else if (hdr_media == BRLYT_TYPE_UFS)
+ tparams->header_size = sizeof(struct ufs_device_header);
else
tparams->header_size = sizeof(struct gen_device_header);
@@ -357,6 +362,65 @@ static int mtk_image_verify_gen_header(const uint8_t *ptr, int print)
return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_GEN, print);
}
+static int mtk_image_verify_ufs_header(const uint8_t *ptr, int print)
+{
+ union gen_boot_header *gbh = (union gen_boot_header *)ptr;
+ uint32_t gfh_offset, total_size, devh_size;
+ struct brom_layout_header *bh;
+ struct gfh_header *gfh;
+ const char *bootmedia;
+
+ if (!strcmp(gbh->name, UFS_BOOT_NAME))
+ bootmedia = "UFS";
+ else
+ return -1;
+
+ if (print)
+ printf("Boot Media: %s\n", bootmedia);
+
+ devh_size = sizeof(struct ufs_device_header);
+
+ if (le32_to_cpu(gbh->version) != 1 ||
+ le32_to_cpu(gbh->size) != devh_size)
+ return -1;
+
+ bh = (struct brom_layout_header *)(ptr + sizeof(union gen_boot_header));
+
+ if (strcmp(bh->name, BRLYT_NAME))
+ return -1;
+
+ if (le32_to_cpu(bh->magic) != BRLYT_MAGIC ||
+ le32_to_cpu(bh->type) != BRLYT_TYPE_UFS)
+ return -1;
+
+ if (img_gen) {
+ gfh_offset = devh_size;
+ } else {
+ gfh_offset = le32_to_cpu(bh->header_size);
+
+ if (gfh_offset + sizeof(struct gfh_header) > img_size) {
+ /*
+ * This may happen if the hdr_offset used to generate
+ * this image is not zero.
+ * Since device header size is not fixed, we can't
+ * cover all possible cases.
+ * Assuming the image is valid only if the real
+ * device header size equals to devh_size.
+ */
+ total_size = le32_to_cpu(bh->total_size);
+
+ if (total_size - gfh_offset > img_size - devh_size)
+ return -1;
+
+ gfh_offset = devh_size;
+ }
+ }
+
+ gfh = (struct gfh_header *)(ptr + gfh_offset);
+
+ return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_GEN, print);
+}
+
static int mtk_image_verify_nand_header(const uint8_t *ptr, int print)
{
struct brom_layout_header *bh;
@@ -504,6 +568,8 @@ static int mtk_image_verify_header(unsigned char *ptr, int image_size,
if (is_mtk_nand_header(ptr))
return mtk_image_verify_nand_header(ptr, 0);
+ else if (!strcmp((char *)ptr, UFS_BOOT_NAME))
+ return mtk_image_verify_ufs_header(ptr, 0);
else
return mtk_image_verify_gen_header(ptr, 0);
@@ -530,6 +596,8 @@ static void mtk_image_print_header(const void *ptr, struct image_tool_params *pa
if (is_mtk_nand_header(ptr))
mtk_image_verify_nand_header(ptr, 1);
+ else if (!strcmp((char *)ptr, UFS_BOOT_NAME))
+ mtk_image_verify_ufs_header(ptr, 1);
else
mtk_image_verify_gen_header(ptr, 1);
}
@@ -658,6 +726,33 @@ static void mtk_image_set_gen_header(void *ptr, off_t filesize,
filesize - sizeof(struct gen_device_header) - SHA256_SUM_LEN);
}
+static void mtk_image_set_ufs_header(void *ptr, off_t filesize,
+ uint32_t loadaddr)
+{
+ struct ufs_device_header *hdr = (struct ufs_device_header *)ptr;
+ struct gfh_header *gfh;
+
+ /* Generic device header */
+ snprintf(hdr->boot.name, sizeof(hdr->boot.name), "%s", UFS_BOOT_NAME);
+ hdr->boot.version = cpu_to_le32(1);
+ hdr->boot.size = cpu_to_le32(sizeof(*hdr));
+
+ /* BRLYT header */
+ put_brom_layout_header(&hdr->brlyt, hdr_media);
+ hdr->brlyt.header_size = cpu_to_le32(hdr_offset + sizeof(*hdr));
+ hdr->brlyt.total_size = cpu_to_le32(hdr_offset + filesize);
+ hdr->brlyt.header_size_2 = hdr->brlyt.header_size;
+ hdr->brlyt.total_size_2 = hdr->brlyt.total_size;
+
+ /* GFH header */
+ gfh = (struct gfh_header *)(ptr + sizeof(*hdr));
+ put_ghf_header(gfh, filesize, sizeof(*hdr),
+ loadaddr, GFH_FLASH_TYPE_GEN);
+
+ /* Generate SHA256 hash */
+ put_hash((uint8_t *)gfh, filesize - sizeof(*hdr) - SHA256_SUM_LEN);
+}
+
static void mtk_image_set_nand_header(void *ptr, off_t filesize,
uint32_t loadaddr)
{
@@ -754,6 +849,8 @@ static void mtk_image_set_header(void *ptr, struct stat *sbuf, int ifd,
if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND)
mtk_image_set_nand_header(ptr, sbuf->st_size, params->addr);
+ else if (hdr_media == BRLYT_TYPE_UFS)
+ mtk_image_set_ufs_header(ptr, sbuf->st_size, params->addr);
else
mtk_image_set_gen_header(ptr, sbuf->st_size, params->addr);
}
diff --git a/tools/mtk_image.h b/tools/mtk_image.h
index 54a838de863..8b4a601aec6 100644
--- a/tools/mtk_image.h
+++ b/tools/mtk_image.h
@@ -11,7 +11,7 @@
/* Device header definitions, all fields are little-endian */
-/* Header for NOR/SD/eMMC */
+/* Header for NOR/SD/eMMC/UFS */
union gen_boot_header {
struct {
char name[12];
@@ -25,6 +25,7 @@ union gen_boot_header {
#define EMMC_BOOT_NAME "EMMC_BOOT"
#define SF_BOOT_NAME "SF_BOOT"
#define SDMMC_BOOT_NAME "SDMMC_BOOT"
+#define UFS_BOOT_NAME "UFS_BOOT"
/* BootROM layout header */
struct brom_layout_header {
@@ -48,7 +49,8 @@ enum brlyt_img_type {
BRLYT_TYPE_EMMC = 0x10005,
BRLYT_TYPE_NOR = 0x10007,
BRLYT_TYPE_SDMMC = 0x10008,
- BRLYT_TYPE_SNAND = 0x10009
+ BRLYT_TYPE_SNAND = 0x10009,
+ BRLYT_TYPE_UFS = 0x1000c
};
/* Combined device header for NOR/SD/eMMC */
@@ -61,6 +63,16 @@ struct gen_device_header {
};
};
+/* Device header for UFS */
+struct ufs_device_header {
+ union gen_boot_header boot;
+
+ union {
+ struct brom_layout_header brlyt;
+ uint8_t brlyt_pad[0xE00];
+ };
+};
+
/* BootROM header definitions */
struct gfh_common_header {
uint32_t magic_version;
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
2026-11-06 21:35 ` [PATCH 1/7] tools: mtk_image: add UFS support David Lechner
@ 2026-11-06 21:35 ` David Lechner
2026-11-11 19:04 ` Carlo Caione
2026-11-06 21:35 ` [PATCH 3/7] arm: dts: mediatek: prepare Genio 520 and 720 UFS for SPL David Lechner
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Do not issue the UFS SiP SMCs when U-Boot itself runs at EL3. There is
no secure monitor to handle them then, e.g. in SPL before BL31 has been
loaded, and an SMC would trap into U-Boot's own exception vectors.
The SiP calls only notify the secure world about the reference clock
and drive the device reset pin. The firmware stage that ran before SPL
has already brought up the UFS device, so the host can still be
initialized without them.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/ufs/ufs-mediatek-sip.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/ufs/ufs-mediatek-sip.h b/drivers/ufs/ufs-mediatek-sip.h
index 6a61f7bac69..cb27da1458c 100644
--- a/drivers/ufs/ufs-mediatek-sip.h
+++ b/drivers/ufs/ufs-mediatek-sip.h
@@ -9,6 +9,7 @@
#ifndef _UFS_MEDIATEK_SIP_H
#define _UFS_MEDIATEK_SIP_H
+#include <asm/system.h>
#include <linux/arm-smccc.h>
/*
@@ -37,6 +38,10 @@ struct ufs_mtk_smc_arg {
static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
{
+ /* No secure monitor to call yet, e.g. in SPL before BL31. */
+ if (current_el() == 3)
+ return;
+
arm_smccc_smc(MTK_SIP_UFS_CONTROL,
s.cmd,
s.v1, s.v2, s.v3, s.v4, s.v5, s.v6, s.res);
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/7] arm: dts: mediatek: prepare Genio 520 and 720 UFS for SPL
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
2026-11-06 21:35 ` [PATCH 1/7] tools: mtk_image: add UFS support David Lechner
2026-11-06 21:35 ` [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3 David Lechner
@ 2026-11-06 21:35 ` David Lechner
2026-11-06 21:35 ` [PATCH 4/7] arm: mediatek: load the next stage from UFS in SPL David Lechner
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Mark the UFS host controller and its UFS configuration clock
controllers for SPL, so that SPL can load the firmware FIT from UFS when
the UFS devicetree overlay enables the controller.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
arch/arm/dts/mt8371-genio-common-u-boot.dtsi | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/mt8371-genio-common-u-boot.dtsi b/arch/arm/dts/mt8371-genio-common-u-boot.dtsi
index 70c538a690e..7f614323c93 100644
--- a/arch/arm/dts/mt8371-genio-common-u-boot.dtsi
+++ b/arch/arm/dts/mt8371-genio-common-u-boot.dtsi
@@ -32,7 +32,10 @@
};
&gic {
- /* Retain the eMMC interrupt parent even though SPL uses polling. */
+ /*
+ * Retain the storage controllers' interrupt parent even though SPL
+ * uses polling.
+ */
bootph-pre-ram;
};
@@ -64,6 +67,18 @@
bootph-pre-ram;
};
+&ufshci {
+ bootph-pre-ram;
+};
+
+&ufscfg_ao_reg_clk {
+ bootph-pre-ram;
+};
+
+&ufscfg_pdn_reg_clk {
+ bootph-pre-ram;
+};
+
&mmc0_default_pins {
bootph-pre-ram;
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/7] arm: mediatek: load the next stage from UFS in SPL
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
` (2 preceding siblings ...)
2026-11-06 21:35 ` [PATCH 3/7] arm: dts: mediatek: prepare Genio 520 and 720 UFS for SPL David Lechner
@ 2026-11-06 21:35 ` David Lechner
2026-11-06 21:35 ` [PATCH 5/7] arm: mediatek: make the BootROM header info configurable David Lechner
` (2 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Return BOOT_DEVICE_UFS from spl_boot_device() when SPL is built with UFS
support, so that SPL can load the next stage from UFS. Check it after
MMC, like the other storage types, so that configurations which enable
SPL MMC keep booting from MMC.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
arch/arm/mach-mediatek/spl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-mediatek/spl.c b/arch/arm/mach-mediatek/spl.c
index cd7841f1a87..b829f5e7450 100644
--- a/arch/arm/mach-mediatek/spl.c
+++ b/arch/arm/mach-mediatek/spl.c
@@ -71,6 +71,8 @@ u32 spl_boot_device(void)
return BOOT_DEVICE_SPI;
if (CONFIG_IS_ENABLED(MMC))
return BOOT_DEVICE_MMC1;
+ if (CONFIG_IS_ENABLED(UFS))
+ return BOOT_DEVICE_UFS;
if (CONFIG_IS_ENABLED(NAND_SUPPORT))
return BOOT_DEVICE_NAND;
if (CONFIG_IS_ENABLED(NOR_SUPPORT))
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 5/7] arm: mediatek: make the BootROM header info configurable
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
` (3 preceding siblings ...)
2026-11-06 21:35 ` [PATCH 4/7] arm: mediatek: load the next stage from UFS in SPL David Lechner
@ 2026-11-06 21:35 ` David Lechner
2026-11-11 19:04 ` Carlo Caione
2026-11-06 21:35 ` [PATCH 6/7] board: mediatek: add a Genio 520/720 UFS boot config fragment David Lechner
2026-11-06 21:35 ` [PATCH 7/7] doc: board: mediatek: describe booting Genio 520 and 720 from UFS David Lechner
6 siblings, 1 reply; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Add a prompt to MTK_BROM_HEADER_INFO so that a configuration can
override the per-SoC default. Some SoCs can boot from more than one type
of storage, and the BootROM image header has to name the one that the
image is written to.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
arch/arm/mach-mediatek/Kconfig | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
index fec9601e80c..4f7bedcb28b 100644
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -221,11 +221,16 @@ config SYS_CONFIG_NAME
default "mt8518" if TARGET_MT8518
config MTK_BROM_HEADER_INFO
- string
+ string "MediaTek BootROM image header options"
default "media=nor" if TARGET_MT8518 || TARGET_MT8512 || TARGET_MT7629
default "media=emmc;arm64=1" if TARGET_MT8188 || TARGET_MT8189
default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8366 || TARGET_MT8183 || TARGET_MT8195
default "lk=1" if TARGET_MT7623
+ help
+ Option string passed to mkimage -n when generating the MediaTek
+ BootROM image (mtk_image). The media key must name the storage
+ that the image is written to, for example "media=emmc" or
+ "media=ufs". See doc/README.mediatek for the supported keys.
config SPL_MTK_FIRMWARE_AB
bool "MediaTek firmware A/B boot in SPL"
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 6/7] board: mediatek: add a Genio 520/720 UFS boot config fragment
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
` (4 preceding siblings ...)
2026-11-06 21:35 ` [PATCH 5/7] arm: mediatek: make the BootROM header info configurable David Lechner
@ 2026-11-06 21:35 ` David Lechner
2026-11-06 21:35 ` [PATCH 7/7] doc: board: mediatek: describe booting Genio 520 and 720 from UFS David Lechner
6 siblings, 0 replies; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Add a config fragment that builds SPL for booting the Genio 520 and 720
EVKs from UFS. It sets the BootROM image header to UFS and makes SPL
load the firmware FIT from the bootloaders partition (partition 1) on
the main UFS LUN, which holds the GPT and is SCSI device 2.
Disable MMC in SPL, since SPL would otherwise pick MMC as its boot
device. This also keeps SPL small.
Use the fragment together with the board defconfig, for example:
make mt8391_genio_720_evk_defconfig mt8189-genio-spl-ufs.config
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
board/mediatek/MAINTAINERS | 1 +
board/mediatek/mt8189-genio-spl-ufs.config | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS
index fa8a3ca086c..601e1c5c89a 100644
--- a/board/mediatek/MAINTAINERS
+++ b/board/mediatek/MAINTAINERS
@@ -6,6 +6,7 @@ F: arch/arm/dts/mt8371-genio-*
F: arch/arm/dts/mt8391-genio-*
F: arch/arm/dts/mtk-genio-*-binman-u-boot.dtsi
F: arch/arm/dts/mtk-genio-binman-u-boot.dtsi
+F: board/mediatek/mt8189-genio-spl-ufs.config
F: configs/mt8189.config
F: configs/mt8371_genio_*
F: configs/mt8391_genio_*
diff --git a/board/mediatek/mt8189-genio-spl-ufs.config b/board/mediatek/mt8189-genio-spl-ufs.config
new file mode 100644
index 00000000000..884b9b97a44
--- /dev/null
+++ b/board/mediatek/mt8189-genio-spl-ufs.config
@@ -0,0 +1,10 @@
+# Boot the Genio 520 and 720 EVKs from UFS instead of eMMC when using SPL.
+# Use with the board defconfig and the -ufs devicetree, for example:
+# make mt8391_genio_720_evk_defconfig mt8189-genio-spl-ufs.config
+# make DEVICE_TREE=mt8391-genio-720-evk-ufs
+CONFIG_SPL_UFS=y
+CONFIG_SPL_UFS_RAW_U_BOOT_DEVNUM=2
+CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION=y
+CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM=1
+# CONFIG_SPL_MMC is not set
+CONFIG_MTK_BROM_HEADER_INFO="media=ufs;arm64=1"
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 7/7] doc: board: mediatek: describe booting Genio 520 and 720 from UFS
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
` (5 preceding siblings ...)
2026-11-06 21:35 ` [PATCH 6/7] board: mediatek: add a Genio 520/720 UFS boot config fragment David Lechner
@ 2026-11-06 21:35 ` David Lechner
6 siblings, 0 replies; 15+ messages in thread
From: David Lechner @ 2026-11-06 21:35 UTC (permalink / raw)
To: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas
Cc: u-boot, Carlo Caione, David Lechner
Describe how to build and install the firmware images for booting the
Genio 520 and 720 EVKs from UFS with U-Boot SPL. This needs the UFS
config fragment, the UFS devicetree and a DDR loader built for UFS.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
doc/board/mediatek/mt8189-genio-evk.rst | 39 ++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/doc/board/mediatek/mt8189-genio-evk.rst b/doc/board/mediatek/mt8189-genio-evk.rst
index 637aa21e271..6879a1e9060 100644
--- a/doc/board/mediatek/mt8189-genio-evk.rst
+++ b/doc/board/mediatek/mt8189-genio-evk.rst
@@ -99,6 +99,13 @@ by name.
Make sure the DIP switches and jumpers are set for eMMC, and use the default
devicetree.
+To boot from UFS instead, set the DIP switches and jumpers for UFS, add the
+``mt8189-genio-spl-ufs.config`` fragment to the configuration and use the UFS
+variant of the devicetree, as shown below. The BootROM then loads
+``mtk-boot.bin`` from the UFS boot logical unit, and SPL loads
+``bootloaders.img`` from GPT partition 1 of the main UFS logical unit, which
+is SCSI device 2. SPL is built without MMC support in this configuration.
+
DRAM description
~~~~~~~~~~~~~~~~
@@ -188,6 +195,8 @@ Setting Value Size
The DDR loader must:
* initialize and train DRAM,
+* when booting from UFS, leave the UFS device powered, out of reset and
+ with its reference clock enabled,
* copy the complete ``CONFIG_SPL_MAX_SIZE`` byte SPL region from
``CONFIG_MTK_GENIO_BROM_LOAD_ADDR + CONFIG_MTK_GENIO_DDR_LOADER_SIZE``
(``0x20a1000``) to ``CONFIG_SPL_TEXT_BASE``,
@@ -200,8 +209,8 @@ The DDR loader must:
register convention.
SPL obtains platform information from its embedded control devicetree and
-initializes the console, clocks, pinctrl, watchdog and eMMC through U-Boot
-drivers.
+initializes the console, clocks, pinctrl, watchdog and boot storage through
+U-Boot drivers.
The MT8189 BootROM loads at most about 930 KiB from eMMC boot0 and does not
start a larger image. The loader and SPL regions together occupy 896 KiB,
@@ -221,7 +230,9 @@ firmware images:
``ddr-loader.bin``
A MediaTek DDR loader which initializes the DRAM fitted to the target board
and satisfies the handoff contract above. The input may be shorter than the
- configured loader region; binman pads it with zeros.
+ configured loader region; binman pads it with zeros. The DDR loader reads
+ its DRAM calibration data from the boot storage, so it must be built for
+ the storage that the board boots from.
``BL31``
The U-Boot build variable naming the Arm Trusted Firmware-A BL31 binary
@@ -258,11 +269,23 @@ Use ``mt8371_genio_520_evk_defconfig`` instead for Genio 520. ``TEE`` must be
set for both configuration and compilation. Do not deploy images if binman
reports that it used fake or missing external blobs.
+To boot from UFS, merge the UFS fragment into the configuration, select the
+UFS devicetree and pass the directory holding the DDR loader built for UFS::
+
+ $ make mt8391_genio_720_evk_defconfig mt8189-genio-spl-ufs.config
+ $ scripts/config --file "${KBUILD_OUTPUT}/.config" \
+ --enable MTK_GENIO_BOOT_IMAGES
+ $ make olddefconfig
+ $ make DEVICE_TREE=mt8391-genio-720-evk-ufs \
+ BINMAN_INDIRS=/path/to/ufs-firmware
+
+Use ``DEVICE_TREE=mt8371-genio-520-evk-ufs`` for Genio 520.
+
Binman produces two deployable images and one intermediate payload in the
build directory:
``mtk-boot.bin``
- A MediaTek eMMC image with load and entry address
+ A MediaTek BootROM image for the boot storage, with load and entry address
``CONFIG_MTK_GENIO_BROM_LOAD_ADDR``. It contains the DDR loader, padded to
``CONFIG_MTK_GENIO_DDR_LOADER_SIZE``, followed by U-Boot SPL padded to
``CONFIG_SPL_MAX_SIZE``.
@@ -287,8 +310,10 @@ Use the board provisioning tools to place the images as follows:
=================== ================================================
Image Destination
=================== ================================================
-``mtk-boot.bin`` Start of the eMMC boot0 hardware partition
-``bootloaders.img`` GPT partition 1 in the eMMC user area
+``mtk-boot.bin`` Start of the eMMC boot0 hardware partition, or of
+ the UFS boot logical unit
+``bootloaders.img`` GPT partition 1 in the eMMC user area, or on the
+ main UFS logical unit
=================== ================================================
For example, with `Genio Tools
@@ -299,6 +324,8 @@ a prebuilt Genio image for the target board::
mmc0boot0:/absolute/path/to/build/mtk-boot.bin \
bootloaders:/absolute/path/to/build/bootloaders.img
+With a Genio image built for UFS, the same command writes the images to UFS.
+
Writing an invalid image to eMMC boot0 can make the board unbootable. Preserve
the platform recovery path while testing.
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] tools: mtk_image: add UFS support
2026-11-06 21:35 ` [PATCH 1/7] tools: mtk_image: add UFS support David Lechner
@ 2026-11-11 19:04 ` Carlo Caione
0 siblings, 0 replies; 15+ messages in thread
From: Carlo Caione @ 2026-11-11 19:04 UTC (permalink / raw)
To: David Lechner
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot,
Carlo Caione
> Add support for generating images that can boot on UFS storage for
> MediaTek SoCs.
>
> The UFS device header is 4 KiB instead of 1.5 KiB, and the size field
> of its generic boot header covers the whole device header.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> [dlechner: rebase, fix header size check when verifying, document the
> ufs media type, use mtk_image_verify_gfh()]
> Signed-off-by: David Lechner <dlechner@baylibre.com>
>
> diff --git a/doc/README.mediatek b/doc/README.mediatek
> index 246579d4be2..d38709408b7 100644
> --- a/doc/README.mediatek
> +++ b/doc/README.mediatek
> @@ -107,6 +107,7 @@ To generate these two headers with mkimage:
> nor : Serial NOR
> emmc : eMMC
> sdmmc: SD
> + ufs : UFS
>
> nandinfo: Desired NAND device type, a combination of page size, oob size and
> optional device capacity. Valid types are:
> diff --git a/tools/mtk_image.c b/tools/mtk_image.c
> index 1b1aed59924..ac9c86df6bd 100644
> --- a/tools/mtk_image.c
> +++ b/tools/mtk_image.c
> @@ -36,6 +36,9 @@ static const struct brom_img_type {
> }, {
> .name = "spim-nand",
> .type = BRLYT_TYPE_SNAND
> + }, {
> + .name = "ufs",
> + .type = BRLYT_TYPE_UFS
> }
> };
>
> @@ -262,6 +265,8 @@ static int mtk_image_vrec_header(struct image_tool_params *params,
>
> if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND)
> tparams->header_size = hdr_nand_size;
> + else if (hdr_media == BRLYT_TYPE_UFS)
> + tparams->header_size = sizeof(struct ufs_device_header);
> else
> tparams->header_size = sizeof(struct gen_device_header);
>
> @@ -357,6 +362,65 @@ static int mtk_image_verify_gen_header(const uint8_t *ptr, int print)
> return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_GEN, print);
> }
>
> +static int mtk_image_verify_ufs_header(const uint8_t *ptr, int print)
> +{
> + union gen_boot_header *gbh = (union gen_boot_header *)ptr;
> + uint32_t gfh_offset, total_size, devh_size;
> + struct brom_layout_header *bh;
> + struct gfh_header *gfh;
> + const char *bootmedia;
> +
> + if (!strcmp(gbh->name, UFS_BOOT_NAME))
> + bootmedia = "UFS";
> + else
> + return -1;
This function is almost the same of mtk_image_verify_gen_header() is it
possible to unify both?
> +
> + if (print)
> + printf("Boot Media: %s\n", bootmedia);
> +
> + devh_size = sizeof(struct ufs_device_header);
> +
> + if (le32_to_cpu(gbh->version) != 1 ||
> + le32_to_cpu(gbh->size) != devh_size)
> + return -1;
> +
> + bh = (struct brom_layout_header *)(ptr + sizeof(union gen_boot_header));
> +
> + if (strcmp(bh->name, BRLYT_NAME))
> + return -1;
> +
> + if (le32_to_cpu(bh->magic) != BRLYT_MAGIC ||
> + le32_to_cpu(bh->type) != BRLYT_TYPE_UFS)
> + return -1;
> +
> + if (img_gen) {
> + gfh_offset = devh_size;
> + } else {
> + gfh_offset = le32_to_cpu(bh->header_size);
> +
> + if (gfh_offset + sizeof(struct gfh_header) > img_size) {
> + /*
> + * This may happen if the hdr_offset used to generate
> + * this image is not zero.
> + * Since device header size is not fixed, we can't
> + * cover all possible cases.
> + * Assuming the image is valid only if the real
> + * device header size equals to devh_size.
> + */
> + total_size = le32_to_cpu(bh->total_size);
> +
> + if (total_size - gfh_offset > img_size - devh_size)
> + return -1;
> +
> + gfh_offset = devh_size;
> + }
> + }
> +
> + gfh = (struct gfh_header *)(ptr + gfh_offset);
> +
> + return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_GEN, print);
> +}
> +
> static int mtk_image_verify_nand_header(const uint8_t *ptr, int print)
> {
> struct brom_layout_header *bh;
> @@ -504,6 +568,8 @@ static int mtk_image_verify_header(unsigned char *ptr, int image_size,
>
> if (is_mtk_nand_header(ptr))
> return mtk_image_verify_nand_header(ptr, 0);
> + else if (!strcmp((char *)ptr, UFS_BOOT_NAME))
> + return mtk_image_verify_ufs_header(ptr, 0);
> else
> return mtk_image_verify_gen_header(ptr, 0);
>
> @@ -530,6 +596,8 @@ static void mtk_image_print_header(const void *ptr, struct image_tool_params *pa
>
> if (is_mtk_nand_header(ptr))
> mtk_image_verify_nand_header(ptr, 1);
> + else if (!strcmp((char *)ptr, UFS_BOOT_NAME))
> + mtk_image_verify_ufs_header(ptr, 1);
> else
> mtk_image_verify_gen_header(ptr, 1);
> }
> @@ -658,6 +726,33 @@ static void mtk_image_set_gen_header(void *ptr, off_t filesize,
> filesize - sizeof(struct gen_device_header) - SHA256_SUM_LEN);
> }
>
> +static void mtk_image_set_ufs_header(void *ptr, off_t filesize,
> + uint32_t loadaddr)
> +{
> + struct ufs_device_header *hdr = (struct ufs_device_header *)ptr;
> + struct gfh_header *gfh;
> +
> + /* Generic device header */
> + snprintf(hdr->boot.name, sizeof(hdr->boot.name), "%s", UFS_BOOT_NAME);
> + hdr->boot.version = cpu_to_le32(1);
> + hdr->boot.size = cpu_to_le32(sizeof(*hdr));
> +
> + /* BRLYT header */
> + put_brom_layout_header(&hdr->brlyt, hdr_media);
> + hdr->brlyt.header_size = cpu_to_le32(hdr_offset + sizeof(*hdr));
> + hdr->brlyt.total_size = cpu_to_le32(hdr_offset + filesize);
> + hdr->brlyt.header_size_2 = hdr->brlyt.header_size;
> + hdr->brlyt.total_size_2 = hdr->brlyt.total_size;
> +
> + /* GFH header */
> + gfh = (struct gfh_header *)(ptr + sizeof(*hdr));
> + put_ghf_header(gfh, filesize, sizeof(*hdr),
> + loadaddr, GFH_FLASH_TYPE_GEN);
> +
> + /* Generate SHA256 hash */
> + put_hash((uint8_t *)gfh, filesize - sizeof(*hdr) - SHA256_SUM_LEN);
> +}
Same here, this is almost the same as mtk_image_set_gen_header()
> +
> static void mtk_image_set_nand_header(void *ptr, off_t filesize,
> uint32_t loadaddr)
> {
> @@ -754,6 +849,8 @@ static void mtk_image_set_header(void *ptr, struct stat *sbuf, int ifd,
>
> if (hdr_media == BRLYT_TYPE_NAND || hdr_media == BRLYT_TYPE_SNAND)
> mtk_image_set_nand_header(ptr, sbuf->st_size, params->addr);
> + else if (hdr_media == BRLYT_TYPE_UFS)
> + mtk_image_set_ufs_header(ptr, sbuf->st_size, params->addr);
> else
> mtk_image_set_gen_header(ptr, sbuf->st_size, params->addr);
> }
> diff --git a/tools/mtk_image.h b/tools/mtk_image.h
> index 54a838de863..8b4a601aec6 100644
> --- a/tools/mtk_image.h
> +++ b/tools/mtk_image.h
> @@ -11,7 +11,7 @@
>
> /* Device header definitions, all fields are little-endian */
>
> -/* Header for NOR/SD/eMMC */
> +/* Header for NOR/SD/eMMC/UFS */
> union gen_boot_header {
> struct {
> char name[12];
> @@ -25,6 +25,7 @@ union gen_boot_header {
> #define EMMC_BOOT_NAME "EMMC_BOOT"
> #define SF_BOOT_NAME "SF_BOOT"
> #define SDMMC_BOOT_NAME "SDMMC_BOOT"
> +#define UFS_BOOT_NAME "UFS_BOOT"
>
> /* BootROM layout header */
> struct brom_layout_header {
> @@ -48,7 +49,8 @@ enum brlyt_img_type {
> BRLYT_TYPE_EMMC = 0x10005,
> BRLYT_TYPE_NOR = 0x10007,
> BRLYT_TYPE_SDMMC = 0x10008,
> - BRLYT_TYPE_SNAND = 0x10009
> + BRLYT_TYPE_SNAND = 0x10009,
> + BRLYT_TYPE_UFS = 0x1000c
> };
>
> /* Combined device header for NOR/SD/eMMC */
> @@ -61,6 +63,16 @@ struct gen_device_header {
> };
> };
>
> +/* Device header for UFS */
> +struct ufs_device_header {
> + union gen_boot_header boot;
> +
> + union {
> + struct brom_layout_header brlyt;
> + uint8_t brlyt_pad[0xE00];
Can you add a comment about the odd size 0xE00?
--
Carlo Caione <ccaione@baylibre.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3
2026-11-06 21:35 ` [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3 David Lechner
@ 2026-11-11 19:04 ` Carlo Caione
2026-11-16 22:40 ` David Lechner
0 siblings, 1 reply; 15+ messages in thread
From: Carlo Caione @ 2026-11-11 19:04 UTC (permalink / raw)
To: David Lechner
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot,
Carlo Caione
> Do not issue the UFS SiP SMCs when U-Boot itself runs at EL3. There is
> no secure monitor to handle them then, e.g. in SPL before BL31 has been
> loaded, and an SMC would trap into U-Boot's own exception vectors.
>
> The SiP calls only notify the secure world about the reference clock
> and drive the device reset pin. The firmware stage that ran before SPL
> has already brought up the UFS device, so the host can still be
> initialized without them.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
>
> diff --git a/drivers/ufs/ufs-mediatek-sip.h b/drivers/ufs/ufs-mediatek-sip.h
> index 6a61f7bac69..cb27da1458c 100644
> --- a/drivers/ufs/ufs-mediatek-sip.h
> +++ b/drivers/ufs/ufs-mediatek-sip.h
> @@ -9,6 +9,7 @@
> #ifndef _UFS_MEDIATEK_SIP_H
> #define _UFS_MEDIATEK_SIP_H
>
> +#include <asm/system.h>
> #include <linux/arm-smccc.h>
>
> /*
> @@ -37,6 +38,10 @@ struct ufs_mtk_smc_arg {
>
> static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
> {
> + /* No secure monitor to call yet, e.g. in SPL before BL31. */
> + if (current_el() == 3)
> + return;
Can we return an error from here? Otherwise functions like
ufs_mtk_device_reset() are going to assume that the function is
successful.
--
Carlo Caione <ccaione@baylibre.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 5/7] arm: mediatek: make the BootROM header info configurable
2026-11-06 21:35 ` [PATCH 5/7] arm: mediatek: make the BootROM header info configurable David Lechner
@ 2026-11-11 19:04 ` Carlo Caione
2026-11-11 20:03 ` David Lechner
0 siblings, 1 reply; 15+ messages in thread
From: Carlo Caione @ 2026-11-11 19:04 UTC (permalink / raw)
To: David Lechner
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot,
Carlo Caione
> Add a prompt to MTK_BROM_HEADER_INFO so that a configuration can
> override the per-SoC default. Some SoCs can boot from more than one type
> of storage, and the BootROM image header has to name the one that the
> image is written to.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
>
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> index fec9601e80c..4f7bedcb28b 100644
> --- a/arch/arm/mach-mediatek/Kconfig
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -221,11 +221,16 @@ config SYS_CONFIG_NAME
> default "mt8518" if TARGET_MT8518
>
> config MTK_BROM_HEADER_INFO
> - string
> + string "MediaTek BootROM image header options"
> default "media=nor" if TARGET_MT8518 || TARGET_MT8512 || TARGET_MT7629
> default "media=emmc;arm64=1" if TARGET_MT8188 || TARGET_MT8189
> default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8366 || TARGET_MT8183 || TARGET_MT8195
> default "lk=1" if TARGET_MT7623
> + help
> + Option string passed to mkimage -n when generating the MediaTek
> + BootROM image (mtk_image). The media key must name the storage
> + that the image is written to, for example "media=emmc" or
> + "media=ufs". See doc/README.mediatek for the supported keys.
Should we have `default "media=ufs;arm64=1" if ...` as well?
--
Carlo Caione <ccaione@baylibre.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 5/7] arm: mediatek: make the BootROM header info configurable
2026-11-11 19:04 ` Carlo Caione
@ 2026-11-11 20:03 ` David Lechner
0 siblings, 0 replies; 15+ messages in thread
From: David Lechner @ 2026-11-11 20:03 UTC (permalink / raw)
To: Carlo Caione
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot
On 11/11/26 1:04 PM, Carlo Caione wrote:
>> Add a prompt to MTK_BROM_HEADER_INFO so that a configuration can
>> override the per-SoC default. Some SoCs can boot from more than one type
>> of storage, and the BootROM image header has to name the one that the
>> image is written to.
>>
>> Signed-off-by: David Lechner <dlechner@baylibre.com>
>>
>> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
>> index fec9601e80c..4f7bedcb28b 100644
>> --- a/arch/arm/mach-mediatek/Kconfig
>> +++ b/arch/arm/mach-mediatek/Kconfig
>> @@ -221,11 +221,16 @@ config SYS_CONFIG_NAME
>> default "mt8518" if TARGET_MT8518
>>
>> config MTK_BROM_HEADER_INFO
>> - string
>> + string "MediaTek BootROM image header options"
>> default "media=nor" if TARGET_MT8518 || TARGET_MT8512 || TARGET_MT7629
>> default "media=emmc;arm64=1" if TARGET_MT8188 || TARGET_MT8189
>> default "media=emmc" if TARGET_MT8516 || TARGET_MT8365 || TARGET_MT8366 || TARGET_MT8183 || TARGET_MT8195
>> default "lk=1" if TARGET_MT7623
>> + help
>> + Option string passed to mkimage -n when generating the MediaTek
>> + BootROM image (mtk_image). The media key must name the storage
>> + that the image is written to, for example "media=emmc" or
>> + "media=ufs". See doc/README.mediatek for the supported keys.
>
> Should we have `default "media=ufs;arm64=1" if ...` as well?
>
I thought about it, but I couldn't find anything that really made sense
for the ... part.
Since all of the Genio boards are going to be using binman and I have some
plans to fix that up so we can use binman devicetree fragments or overlays
a bit easier, I was hoping we could eventually leave MTK_BROM_HEADER_INFO
for the non-binman boards. Then we wouldn't need anything here at all for
this case because we wouldn't use MTK_BROM_HEADER_INFO anymore in the
binman devicetree.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3
2026-11-11 19:04 ` Carlo Caione
@ 2026-11-16 22:40 ` David Lechner
2026-11-17 6:24 ` Carlo Caione
0 siblings, 1 reply; 15+ messages in thread
From: David Lechner @ 2026-11-16 22:40 UTC (permalink / raw)
To: Carlo Caione
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot
On 11/11/26 1:04 PM, Carlo Caione wrote:
>> Do not issue the UFS SiP SMCs when U-Boot itself runs at EL3. There is
>> no secure monitor to handle them then, e.g. in SPL before BL31 has been
>> loaded, and an SMC would trap into U-Boot's own exception vectors.
>>
>> The SiP calls only notify the secure world about the reference clock
>> and drive the device reset pin. The firmware stage that ran before SPL
>> has already brought up the UFS device, so the host can still be
>> initialized without them.
>>
>> Signed-off-by: David Lechner <dlechner@baylibre.com>
>>
>> diff --git a/drivers/ufs/ufs-mediatek-sip.h b/drivers/ufs/ufs-mediatek-sip.h
>> index 6a61f7bac69..cb27da1458c 100644
>> --- a/drivers/ufs/ufs-mediatek-sip.h
>> +++ b/drivers/ufs/ufs-mediatek-sip.h
>> @@ -9,6 +9,7 @@
>> #ifndef _UFS_MEDIATEK_SIP_H
>> #define _UFS_MEDIATEK_SIP_H
>>
>> +#include <asm/system.h>
>> #include <linux/arm-smccc.h>
>>
>> /*
>> @@ -37,6 +38,10 @@ struct ufs_mtk_smc_arg {
>>
>> static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
>> {
>> + /* No secure monitor to call yet, e.g. in SPL before BL31. */
>> + if (current_el() == 3)
>> + return;
>
> Can we return an error from here? Otherwise functions like
> ufs_mtk_device_reset() are going to assume that the function is
> successful.
>
I don't think we should consider this an error. We return early because
there is nothing to do, not because we can't do something that is required.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3
2026-11-16 22:40 ` David Lechner
@ 2026-11-17 6:24 ` Carlo Caione
2026-11-17 14:36 ` David Lechner
0 siblings, 1 reply; 15+ messages in thread
From: Carlo Caione @ 2026-11-17 6:24 UTC (permalink / raw)
To: David Lechner
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot
On Mon, Nov 16, 2026 at 16:40:05 +0100, David Lechner wrote:
> >> @@ -37,6 +38,10 @@ struct ufs_mtk_smc_arg {
> >>
> >> static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
> >> {
> >> + /* No secure monitor to call yet, e.g. in SPL before BL31. */
> >> + if (current_el() == 3)
> >> + return;
> >
> > Can we return an error from here? Otherwise functions like
> > ufs_mtk_device_reset() are going to assume that the function is
> > successful.
> >
>
> I don't think we should consider this an error. We return early because
> there is nothing to do, not because we can't do something that is required.
Yes, but for example in ufs_mtk_device_reset_ctrl() we are waiting 26ms
for nothing and printing a now misleading "device reset done".
--
Carlo Caione
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3
2026-11-17 6:24 ` Carlo Caione
@ 2026-11-17 14:36 ` David Lechner
0 siblings, 0 replies; 15+ messages in thread
From: David Lechner @ 2026-11-17 14:36 UTC (permalink / raw)
To: Carlo Caione
Cc: Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan,
GSS_MTK_Uboot_upstream, Tom Rini, Neil Armstrong, Bhupesh Sharma,
Neha Malcom Francis, Macpaul Lin, Ilias Apalodimas, u-boot
On 11/17/26 12:24 AM, Carlo Caione wrote:
> On Mon, Nov 16, 2026 at 16:40:05 +0100, David Lechner wrote:
>>>> @@ -37,6 +38,10 @@ struct ufs_mtk_smc_arg {
>>>>
>>>> static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s)
>>>> {
>>>> + /* No secure monitor to call yet, e.g. in SPL before BL31. */
>>>> + if (current_el() == 3)
>>>> + return;
>>>
>>> Can we return an error from here? Otherwise functions like
>>> ufs_mtk_device_reset() are going to assume that the function is
>>> successful.
>>>
>>
>> I don't think we should consider this an error. We return early because
>> there is nothing to do, not because we can't do something that is required.
>
> Yes, but for example in ufs_mtk_device_reset_ctrl() we are waiting 26ms
> for nothing and printing a now misleading "device reset done".
>
> --
> Carlo Caione
I see. So we need to make a macro for the check and put it at higher level
in a few different places to make it more obvious that SPL requires UFS to
already be up and running.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-11-17 14:36 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 21:35 [PATCH 0/7] mediatek: mt8189: add UFS boot for Genio 520 and 720 SPL David Lechner
2026-11-06 21:35 ` [PATCH 1/7] tools: mtk_image: add UFS support David Lechner
2026-11-11 19:04 ` Carlo Caione
2026-11-06 21:35 ` [PATCH 2/7] ufs: mediatek: skip SiP calls when running at EL3 David Lechner
2026-11-11 19:04 ` Carlo Caione
2026-11-16 22:40 ` David Lechner
2026-11-17 6:24 ` Carlo Caione
2026-11-17 14:36 ` David Lechner
2026-11-06 21:35 ` [PATCH 3/7] arm: dts: mediatek: prepare Genio 520 and 720 UFS for SPL David Lechner
2026-11-06 21:35 ` [PATCH 4/7] arm: mediatek: load the next stage from UFS in SPL David Lechner
2026-11-06 21:35 ` [PATCH 5/7] arm: mediatek: make the BootROM header info configurable David Lechner
2026-11-11 19:04 ` Carlo Caione
2026-11-11 20:03 ` David Lechner
2026-11-06 21:35 ` [PATCH 6/7] board: mediatek: add a Genio 520/720 UFS boot config fragment David Lechner
2026-11-06 21:35 ` [PATCH 7/7] doc: board: mediatek: describe booting Genio 520 and 720 from UFS David Lechner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.