riscv: Add support for Metanoia MT2824 SoC and MT5824 EVB
Subsystems (6)
cover riscv: Add support for Metanoia MT2824 SoC and MT5824 EVB
The MT2824 is a RISC-V SoC integrating a dual-core Andes AX45MP with 256 KB of L2 cache, Andes PLIC/PLICSW/PLMT interrupt and timer controllers, an ATCSPI200 QSPI controller, a DesignWare-derived SDHCI controller and a DDR controller that is initialized by firmware loaded by the SPL from the boot device.
The SoC is used together with two MT3812 5G transceivers to form the MT5824 reference design [1]. The evaluation board allows testing this reference design and provides a 32 MiB SPI-NOR flash as well as an SD card port for booting.
This series adds support for the platform: the SoC drivers (SDHCI, DDR controller and a simple reset controller), the SPL boot flow (GPT partition lookup with A/B slot selection driven by the ROM one-shot boot registers), the environment backend selected at runtime from the boot source, and SPI-NOR support (an nvmxip memory-mapped device plus spi-mem operations for the Metanoia variant of the ATCSPI200 controller).
The series is organized as follows:
- patches 1-5: generic fixes and helpers (16-bit iopoll variant, simple reset controller driver, GPT parsing in SPL, NVM XIP devices in SPL, Andes erratum #35102 Kconfig option)
- patches 6-8: spi-mem support for the ATCSPI200 QSPI controller and the MT2824 DDR and SDHCI drivers
- patches 9-10: device trees and MT5824 EVB platform support
The series was built and tested on the MT5824 EVB:
- boot from SD card and from QSPI NOR
- environment loaded from the boot device (MMC and SPI flash)
- SPL A/B boot from the GPT partitions
- sf probe/read/erase on the Macronix NOR flash
[1]: https://metanoia-comm.com/products/5g/mt5824/
Base commit: a06e89ab05e ("Prepare v2026.10-rc5")
---
Benoît Monin (9):
iopoll: Add readw_poll_sleep_timeout
reset: Add a driver for simple controller
disk: efi: Reuse the GPT entries buffer with simple malloc
nvmxip: Make NVM XIP devices available in SPL
mmc: metanoia_sdhci: Add SDHCI driver for Metanoia MT2824 SoC
ram: metanoia: Add driver for MT2824 DDR controller
spi: atcspi200_spi: Add spi-mem support for the Metanoia ATCSPI200 variant
riscv: dts: add MT2824 SoC and MT5824 EVB device trees
riscv: metanoia: Add support for the MT5824 EVB platform
Jun Chang (1):
riscv: andes: Add Kconfig option for Andes erratum #35102
MAINTAINERS | 5 + arch/riscv/Kconfig | 4 + arch/riscv/cpu/andes/Kconfig | 3 + arch/riscv/cpu/andes/cpu.c | 7 +- arch/riscv/dts/Makefile | 1 + arch/riscv/dts/mt2824-u-boot.dtsi | 66 +++ arch/riscv/dts/mt2824.dtsi | 219 ++++++++++ arch/riscv/dts/mt5824-evb.dts | 34 ++ board/metanoia/mt5824-evb/Kconfig | 45 ++ board/metanoia/mt5824-evb/MAINTAINERS | 11 + board/metanoia/mt5824-evb/Makefile | 7 + board/metanoia/mt5824-evb/board.c | 61 +++ board/metanoia/mt5824-evb/board.h | 35 ++ board/metanoia/mt5824-evb/mt5824-evb.env | 6 + board/metanoia/mt5824-evb/spl.c | 388 +++++++++++++++++ common/spl/Kconfig | 8 + configs/metanoia-mt5824-evb_defconfig | 73 ++++ disk/part_efi.c | 25 +- doc/board/index.rst | 1 + doc/board/metanoia/index.rst | 9 + doc/board/metanoia/mt5824-evb.rst | 232 ++++++++++ drivers/mmc/Kconfig | 11 + drivers/mmc/Makefile | 1 + drivers/mmc/metanoia_sdhci.c | 494 +++++++++++++++++++++ drivers/mtd/Makefile | 1 + drivers/ram/Kconfig | 7 + drivers/ram/Makefile | 2 + drivers/ram/mt2824-ddr.c | 706 +++++++++++++++++++++++++++++++ drivers/reset/Kconfig | 8 + drivers/reset/Makefile | 1 + drivers/reset/reset-simple.c | 115 +++++ drivers/spi/atcspi200_spi.c | 176 +++++++- include/configs/metanoia-mt5824-evb.h | 28 ++ include/linux/iopoll.h | 3 + 34 files changed, 2780 insertions(+), 13 deletions(-)
---
base-commit: a06e89ab05eaa2b8344d521319399333cd760ae5
change-id: 20260622-mt2824-97193f1fbe29
Best regards,
Signature · 3 lines
Benoît Monin, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/10 iopoll: Add readw_poll_sleep_timeout
The readl poll API with sleep and timeout support was introduced by commit ce786ae3913f ("iopoll: Add readl_poll_sleep_timeout"), add the 16-bit variant.
--- include/linux/iopoll.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/iopoll.h +3 -0
@@ -46,6 +46,9 @@#define readx_poll_sleep_timeout (op, addr, val, cond, sleep_us, timeout_us) \ read_poll_timeout(op, val, cond, sleep_us, timeout_us, addr) +#define readw_poll_sleep_timeout (addr, val, cond, sleep_us, timeout_us) \ + readx_poll_sleep_timeout(readw, addr, val, cond, sleep_us, timeout_us) +#define readl_poll_sleep_timeout (addr, val, cond, sleep_us, timeout_us) \ readx_poll_sleep_timeout(readl, addr, val, cond, sleep_us, timeout_us)
Signature · 1 line
2.55.0
Re: [PATCH 01/10] iopoll: Add readw_poll_sleep_timeout
Quoted 3 lines · Benoît Monin
The readl poll API with sleep and timeout support was introduced by commit
ce786ae3913f("iopoll: Addreadl_poll_sleep_timeout"), add the 16-bit variant.
Please be clearer that you're referring to the linux kernel commit this came from.
Signature · 1 line
Tom
Re: [PATCH 01/10] iopoll: Add readw_poll_sleep_timeout
Quoted 9 lines · Tom Rini
Quoted 3 lines · Benoît Monin
The readl poll API with sleep and timeout support was introduced by commit
ce786ae3913f("iopoll: Addreadl_poll_sleep_timeout"), add the 16-bit variant.Please be clearer that you're referring to the linux kernel commit this came from.
Yes I will clarify the commit message, as ce786ae3913f is a u-boot commit and it refers to kernel commit 5f5323a14cad.
Signature · 1 line
Benoît
PATCH 2/10 reset: Add a driver for simple controller
In reply to Benoît MoninAdd a driver for simple reset controllers, where each reset line is controlled by a single bit in a memory-mapped register range.
The implementation is derived from the Linux reset-simple driver. The controller logic itself is generic; the driver currently matches the Metanoia MT2824 instance and further controllers can be supported by adding their compatible to the match table.
--- MAINTAINERS | 5 ++ drivers/reset/Kconfig | 8 +++ drivers/reset/Makefile | 1 + drivers/reset/reset-simple.c | 115 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+)
MAINTAINERS +5 -0
@@ -1570,6 +1570,11 @@ S: Maintained T: git https://git.u-boot-project.org/u-boot/custodians/u-boot-nand-flash.git F: drivers/mtd/nand/raw/ +RESET SIMPLE DRIVER +M: Benoît Monin <[email protected]> +S: Maintained +F: drivers/reset/reset-simple.c + RISC-V M: Tim Ouyang <[email protected]> M: Leo Liang <[email protected]>
drivers/reset/Kconfig +8 -0
@@ -149,6 +149,14 @@ config RESET_MESON help Support for reset controller on Amlogic Meson SoC. +config RESET_SIMPLE + bool "Generic driver for simple reset controller" + depends on DM_RESET + help + This enables the reset driver for simple controllers where + each reset line is controlled by a single bit in a memory + mapped region. + config RESET_SOCFPGA bool "Reset controller driver for SoCFPGA" depends on DM_RESET && ARCH_SOCFPGA
drivers/reset/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_RESET_AST2600) += reset-ast2600.o obj-$(CONFIG_RESET_AST2700) += reset-ast2700.o obj-$(CONFIG_$(PHASE_)RESET_ROCKCHIP) += reset-rockchip.o rst-rk3506.o rst-rk3528.o rst-rk3576.o rst-rk3588.o obj-$(CONFIG_RESET_MESON) += reset-meson.o +obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o obj-$(CONFIG_RESET_MTMIPS) += reset-mtmips.o
drivers/reset/reset-simple.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 3/10 disk: efi: Reuse the GPT entries buffer with simple malloc
In reply to Benoît MoninThe simple malloc used in SPL has a no-op free(), so allocating the GPT partition entries buffer on every partition table read leaks memory. With repeated lookups, SPL can exhaust its small heap.
Keep a single cached buffer and reuse it while the allocation size does not change. The entries are re-read on every call, so the buffer is device- and LBA-agnostic.
It is safe to reuse the same buffer in the single-threaded xPL context as the returned pointer is only ever handed out within a single partition-table lookup and every caller consumes or copies the entries before the next lookup.
The change is gated on CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE), so builds with a real free() (U-Boot proper) keep the original malloc/free behavior.
--- disk/part_efi.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
disk/part_efi.c +21 -4
@@ -1141,7 +1141,7 @@ static int find_valid_gpt(struct blk_desc *desc, gpt_header *gpt_head,static gpt_entry *alloc_read_gpt_entries (struct blk_desc *desc,gpt_header *pgpt_head) { -size_t count =0 , blk_cnt; +size_t count =0 , blk_cnt, size;lbaint_t blk;gpt_entry *pte =NULL ;
@@ -1158,10 +1158,27 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc, (u32 )le32_to_cpu (pgpt_head->sizeof_partition_entry), (ulong)count); + size =PAD_TO_BLOCKSIZE (count, desc); +/* Allocate memory for PTE, remember to FREE */ -if (count !=0 ) { - pte =memalign (ARCH_DMA_MINALIGN , -PAD_TO_BLOCKSIZE (count, desc)); +if (CONFIG_IS_ENABLED (SYS_MALLOC_SIMPLE )) { +/* +* The simple malloc has a no-op free(): keep one +* buffer and reuse it. The entries are re-read on +* every call, so the buffer is device- and LBA-agnostic. +*/ +static gpt_entry *cache; +static size_t cache_size; + +if (cache && cache_size == size) { + pte = cache; + }else { + pte =memalign (ARCH_DMA_MINALIGN , size); + cache = pte; + cache_size = size; + } + }else { + pte =memalign (ARCH_DMA_MINALIGN , size); }if (count ==0 || pte ==NULL ) {
Signature · 1 line
2.55.0
Re: [PATCH 03/10] disk: efi: Reuse the GPT entries buffer with simple malloc
Quoted 55 lines · Benoît Monin
The simple malloc used in SPL has a no-op
free(), so allocating the GPT partition entries buffer on every partition table read leaks memory. With repeated lookups, SPL can exhaust its small heap.Keep a single cached buffer and reuse it while the allocation size does not change. The entries are re-read on every call, so the buffer is device- and LBA-agnostic.
It is safe to reuse the same buffer in the single-threaded xPL context as the returned pointer is only ever handed out within a single partition-table lookup and every caller consumes or copies the entries before the next lookup.
The change is gated on
CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE), so builds with a realfree()(U-Boot proper) keep the original malloc/free behavior.Signed-off-by Benoît Monin <[email protected]>--- disk/part_efi.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)disk/part_efi.c +14
-4@@ -1141,7 +1141,7 @@ static int find_valid_gpt(struct blk_desc *desc, gpt_header *gpt_head,static gpt_entry *alloc_read_gpt_entries (struct blk_desc *desc,gpt_header *pgpt_head) { -size_t count =0 , blk_cnt; +size_t count =0 , blk_cnt, size;lbaint_t blk;gpt_entry *pte =NULL ;@@ -1158,10 +1158,27 @@ static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc, (u32 )le32_to_cpu (pgpt_head->sizeof_partition_entry), (ulong)count); + size =PAD_TO_BLOCKSIZE (count, desc); +/* Allocate memory for PTE, remember to FREE */ -if (count !=0 ) { - pte =memalign (ARCH_DMA_MINALIGN , -PAD_TO_BLOCKSIZE (count, desc)); +if (CONFIG_IS_ENABLED (SYS_MALLOC_SIMPLE )) { +/* +* The simple malloc has a no-op free(): keep one +* buffer and reuse it. The entries are re-read on +* every call, so the buffer is device- and LBA-agnostic. +*/ +static gpt_entry *cache; +static size_t cache_size; + +if (cache && cache_size == size) { + pte = cache;
disk/part_efi.c static gpt_entry *alloc_read_gpt_entries(struct blk_desc *desc, · line 1184
Quoted 10 lines
disk/part_efi.c +7
-0+ }else { + pte =memalign (ARCH_DMA_MINALIGN , size); + cache = pte; + cache_size = size; + } + }else { + pte =memalign (ARCH_DMA_MINALIGN , size); }if (count ==0 || pte ==NULL ) {
This doesn't seem identical in the non-SPL case, since now pte is always assigned. Or am I missing something?
Signature · 1 line
Tom
Re: [PATCH 03/10] disk: efi: Reuse the GPT entries buffer with simple malloc
On Friday, 2 October 2026 at 17:26:05 CEST, Tom Rini wrote:
[...]
Quoted 26 lines
Quoted 26 lines
disk/part_efi.c +20
-3+ size =PAD_TO_BLOCKSIZE (count, desc); +/* Allocate memory for PTE, remember to FREE */ -if (count !=0 ) { - pte =memalign (ARCH_DMA_MINALIGN , -PAD_TO_BLOCKSIZE (count, desc)); +if (CONFIG_IS_ENABLED (SYS_MALLOC_SIMPLE )) { +/* +* The simple malloc has a no-op free(): keep one +* buffer and reuse it. The entries are re-read on +* every call, so the buffer is device- and LBA-agnostic. +*/ +static gpt_entry *cache; +static size_t cache_size; + +if (cache && cache_size == size) { + pte = cache; + }else { + pte =memalign (ARCH_DMA_MINALIGN , size); + cache = pte; + cache_size = size; + } + }else { + pte =memalign (ARCH_DMA_MINALIGN , size); }
Quoted 5 lines
Quoted 1 line
if (count == 0 || pte == NULL) {This doesn't seem identical in the non-SPL case, since now pte is always assigned. Or am I missing something?
I did overlook the count==0 case, will fix that.
Signature · 1 line
Benoît
PATCH 4/10 nvmxip: Make NVM XIP devices available in SPL
In reply to Benoît MoninAdd the SPL variant of the NVMXIP option and build the driver when it is enabled for the current phase. This allows the SPL to use the block devices emulated on top of a directly mapped non-volatile memory (XIP) to read data, such as the next stage image or a firmware, from the memory-mapped flash.
--- common/spl/Kconfig | 8 ++++++++ drivers/mtd/Makefile | 1 + 2 files changed, 9 insertions(+)
common/spl/Kconfig +8 -0
@@ -1605,6 +1605,14 @@ config SYS_SPI_ARGS_SIZE hex "Falcon mode: size of args payload in SPI flash" depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT_ARGS +config SPL_NVMXIP + bool "NVM XIP devices support" + select SPL_BLK + help + This option allows the emulation of a block storage device + on top of a direct access non volatile memory XIP flash devices. + This support provides the read operation. + config SPL_THERMAL bool "Driver support for thermal devices" help
drivers/mtd/Makefile +1 -0
@@ -38,5 +38,6 @@ obj-$(CONFIG_$(PHASE_)NAND_SUPPORT) += nand/ obj-$(CONFIG_SPL_ONENAND_SUPPORT) += onenand/ obj-$(CONFIG_$(PHASE_)SPI_FLASH_SUPPORT) += spi/ obj-$(CONFIG_SPL_UBI) += ubispl/ +obj-$(CONFIG_$(PHASE_)NVMXIP) += nvmxip/ endif
Signature · 1 line
2.55.0
Re: [PATCH 04/10] nvmxip: Make NVM XIP devices available in SPL
Quoted 7 lines · Benoît Monin
Add the SPL variant of the NVMXIP option and build the driver when it is enabled for the current phase. This allows the SPL to use the block devices emulated on top of a directly mapped non-volatile memory (XIP) to read data, such as the next stage image or a firmware, from the memory-mapped flash.
Signed-off-by Benoît Monin <[email protected]>
Ugh, I wish drivers/mtd/Makefile was more like the rest of the Makefiles, but it's not, and so adding the line there as this patch does is correct.
Signature · 1 line
Tom
PATCH 5/10 riscv: andes: Add Kconfig option for Andes erratum #35102
In reply to Benoît MoninFrom: Jun Chang <[email protected]>
Add the ANDES_ERRATA_35102 config option to control the workaround for Andes CPU erratum #35102. When enabled, non-blocking load is disabled in the MMISC_CTL register during harts_early_init() to prevent potential data corruption.
--- arch/riscv/cpu/andes/Kconfig | 3 +++ arch/riscv/cpu/andes/cpu.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
arch/riscv/cpu/andes/Kconfig +3 -0
@@ -15,3 +15,6 @@ config RISCV_ANDES help Run U-Boot on AndeStar V5 platforms and use some specific features which are provided by Andes Technology AndeStar V5 families. + +config ANDES_ERRATA_35102 + bool
arch/riscv/cpu/andes/cpu.c +6 -1
@@ -57,7 +57,12 @@ void harts_early_init(void) } } - mmisc_ctl_val |=MMISC_CTL_NON_BLOCKING_EN ; +if (IS_ENABLED (CONFIG_ANDES_ERRATA_35102 )) { +/* Errata #35102: Disable non-blocking load */ + mmisc_ctl_val &= ~MMISC_CTL_NON_BLOCKING_EN ; + }else { + mmisc_ctl_val |=MMISC_CTL_NON_BLOCKING_EN ; + }csr_write (CSR_MMISC_CTL , mmisc_ctl_val); }
Signature · 1 line
2.55.0
PATCH 6/10 mmc: metanoia_sdhci: Add SDHCI driver for Metanoia MT2824 SoC
In reply to Benoît MoninAdd an SDHCI driver for the DesignWare Mobile Storage Host Controller (DWC MSHC) integrated in the Metanoia MT2824 SoC. It supports eMMC up to HS400/HS400ES and SD cards, and implements the MMC driver model.
The controller is a DWC MSHC instance, but its PHY programming, voltage/speed-mode handling and tuning model are silicon-specific and differ from the existing DWC MSHC drivers.
The PHY pad drive strength, receiver select and weak-pull settings depend on the card type (eMMC vs SD) and are re-applied on every ios, whereas snps_sdhci.c uses fixed pad values.
High-speed modes force 1.8V signalling and HS400 uses an explicit PHY DLL lock sequence (set_control_reg()/set_ios_post()), which snps_sdhci.c does not implement.
Tuning relies on the generic SDHCI core tuner, whereas snps_sdhci.c uses the hardware auto-tuning block.
Keeping a dedicated driver avoids per-variant branches in the shared DWC MSHC drivers, matching how snps_sdhci.c, adi_sdhci.c and cv1800b_sdhci.c are already split in U-Boot.
--- drivers/mmc/Kconfig | 11 + drivers/mmc/Makefile | 1 + drivers/mmc/metanoia_sdhci.c | 494 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 506 insertions(+)
drivers/mmc/Kconfig +11 -0
@@ -654,6 +654,17 @@ config MMC_SDHCI_F_SDH30 If you have a controller with this interface, say Y here. If unsure, say N. +config MMC_SDHCI_METANOIA + bool "SDHCI support for Metanoia MT2824 SoC" + depends on MMC_SDHCI + depends on OF_CONTROL + help + Support for SDHCI host controller on Metanoia MT2824 SoC platform. + + If you have a controller with this interface, say Y here. + + If unsure, say N. + config MMC_SDHCI_MSM bool "Qualcomm SDHCI controller" depends on MMC_SDHCI && ARCH_SNAPDRAGON
drivers/mmc/Makefile +1 -0
@@ -63,6 +63,7 @@ obj-$(CONFIG_MMC_SDHCI_CADENCE) += sdhci-cadence6.o obj-$(CONFIG_MMC_SDHCI_CV1800B) += cv1800b_sdhci.o obj-$(CONFIG_MMC_SDHCI_AM654) += am654_sdhci.o obj-$(CONFIG_MMC_SDHCI_IPROC) += iproc_sdhci.o +obj-$(CONFIG_MMC_SDHCI_METANOIA) += metanoia_sdhci.o obj-$(CONFIG_MMC_SDHCI_MSM) += msm_sdhci.o obj-$(CONFIG_MMC_SDHCI_MV) += mv_sdhci.o obj-$(CONFIG_MMC_SDHCI_NPCM) += npcm_sdhci.o
drivers/mmc/metanoia_sdhci.c new file +494 -0
494 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH 06/10] mmc: metanoia_sdhci: Add SDHCI driver for Metanoia MT2824 SoC
Quoted 24 lines · Benoît Monin
Add an SDHCI driver for the DesignWare Mobile Storage Host Controller (DWC MSHC) integrated in the Metanoia MT2824 SoC. It supports eMMC up to HS400/HS400ES and SD cards, and implements the MMC driver model.
The controller is a DWC MSHC instance, but its PHY programming, voltage/speed-mode handling and tuning model are silicon-specific and differ from the existing DWC MSHC drivers.
The PHY pad drive strength, receiver select and weak-pull settings depend on the card type (eMMC vs SD) and are re-applied on every ios, whereas
snps_sdhci.cuses fixed pad values.High-speed modes force 1.8V signalling and HS400 uses an explicit PHY DLL lock sequence (set_control_reg()/set_ios_post()), which
snps_sdhci.cdoes not implement.Tuning relies on the generic SDHCI core tuner, whereas
snps_sdhci.cuses the hardware auto-tuning block.Keeping a dedicated driver avoids per-variant branches in the shared DWC MSHC drivers, matching how
snps_sdhci.c,adi_sdhci.candcv1800b_sdhci.care already split in U-Boot.Signed-off-by Benoît Monin <[email protected]>
[snip]
drivers/mmc/metanoia_sdhci.c line 482
Quoted 4 lines
drivers/mmc/metanoia_sdhci.c new file +4
-0+static const struct udevice_id metanoia_sdhci_ids[] = { + { .compatible ="metanoia,mt2824-dwcmshc" }, + {/* sentinel */ } +};
I don't see this compatible in Linus' tree currently, so what's the status on upstreaming all of the device tree parts? Thanks.
Signature · 1 line
Tom
Re: [PATCH 06/10] mmc: metanoia_sdhci: Add SDHCI driver for Metanoia MT2824 SoC
Quoted 26 lines · Tom Rini
Quoted 16 lines · Benoît Monin
Add an SDHCI driver for the DesignWare Mobile Storage Host Controller (DWC MSHC) integrated in the Metanoia MT2824 SoC. It supports eMMC up to HS400/HS400ES and SD cards, and implements the MMC driver model.
The controller is a DWC MSHC instance, but its PHY programming, voltage/speed-mode handling and tuning model are silicon-specific and differ from the existing DWC MSHC drivers.
The PHY pad drive strength, receiver select and weak-pull settings depend on the card type (eMMC vs SD) and are re-applied on every ios, whereas
snps_sdhci.cuses fixed pad values.High-speed modes force 1.8V signalling and HS400 uses an explicit PHY DLL lock sequence (set_control_reg()/set_ios_post()), which
snps_sdhci.cdoes not implement.Quoted 8 lines
Tuning relies on the generic SDHCI core tuner, whereas
snps_sdhci.cuses the hardware auto-tuning block.Keeping a dedicated driver avoids per-variant branches in the shared DWC MSHC drivers, matching how
snps_sdhci.c,adi_sdhci.candcv1800b_sdhci.care already split in U-Boot.Signed-off-by Benoît Monin <[email protected]>
Quoted 9 lines
[snip]
drivers/mmc/metanoia_sdhci.c line 482
Quoted 4 lines
drivers/mmc/metanoia_sdhci.c new file +4
-0+static const struct udevice_id metanoia_sdhci_ids[] = { + { .compatible ="metanoia,mt2824-dwcmshc" }, + {/* sentinel */ } +};I don't see this compatible in Linus' tree currently, so what's the status on upstreaming all of the device tree parts? Thanks.
We are currently preparing a first patch series for Linux, but it has not been posted yet.
Signature · 1 line
Benoît
Re: [PATCH 06/10] mmc: metanoia_sdhci: Add SDHCI driver for Metanoia MT2824 SoC
Quoted 36 lines · Benoît Monin
Quoted 26 lines · Tom Rini
Quoted 16 lines · Benoît Monin
Add an SDHCI driver for the DesignWare Mobile Storage Host Controller (DWC MSHC) integrated in the Metanoia MT2824 SoC. It supports eMMC up to HS400/HS400ES and SD cards, and implements the MMC driver model.
The controller is a DWC MSHC instance, but its PHY programming, voltage/speed-mode handling and tuning model are silicon-specific and differ from the existing DWC MSHC drivers.
The PHY pad drive strength, receiver select and weak-pull settings depend on the card type (eMMC vs SD) and are re-applied on every ios, whereas
snps_sdhci.cuses fixed pad values.High-speed modes force 1.8V signalling and HS400 uses an explicit PHY DLL lock sequence (set_control_reg()/set_ios_post()), which
snps_sdhci.cdoes not implement.Quoted 8 lines
Tuning relies on the generic SDHCI core tuner, whereas
snps_sdhci.cuses the hardware auto-tuning block.Keeping a dedicated driver avoids per-variant branches in the shared DWC MSHC drivers, matching how
snps_sdhci.c,adi_sdhci.candcv1800b_sdhci.care already split in U-Boot.Signed-off-by Benoît Monin <[email protected]>Quoted 9 lines
[snip]
drivers/mmc/metanoia_sdhci.c line 482
Quoted 4 lines
drivers/mmc/metanoia_sdhci.c new file +4
-0+static const struct udevice_id metanoia_sdhci_ids[] = { + { .compatible ="metanoia,mt2824-dwcmshc" }, + {/* sentinel */ } +};I don't see this compatible in Linus' tree currently, so what's the status on upstreaming all of the device tree parts? Thanks.
Quoted 2 lines
We are currently preparing a first patch series for Linux, but it has not been posted yet.
I'd really like to see that get posted and commented on, so we don't have to have churn here later if there's changes requested.
Signature · 1 line
Tom
Re: [PATCH 06/10] mmc: metanoia_sdhci: Add SDHCI driver for Metanoia MT2824 SoC
On Tuesday, 13 October 2026 at 17:05:34 CEST, Tom Rini wrote:
[...]
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
I don't see this compatible in Linus' tree currently, so what's the status on upstreaming all of the device tree parts? Thanks.
We are currently preparing a first patch series for Linux, but it has not been posted yet.
I'd really like to see that get posted and commented on, so we don't have to have churn here later if there's changes requested.
Understood. I'll finish and post the series for Linux before doing a v2.
Signature · 1 line
Benoît
PATCH 7/10 ram: metanoia: Add driver for MT2824 DDR controller
In reply to Benoît MoninAdd a DDR controller driver for the Metanoia MT2824 SoC, supporting initialization and training of the DDR subsystem in SPL, and implementing the driver-model for the RAM uclass.
The driver relies on a firmware to configure the DDR controller, and expects the firmware to be found via a device tree reg entry named "fw".
The driver expects the DDR firmware to be packaged inside a FIT image, as the firmware node of the default configuration, and it supports signed FIT image.
--- drivers/ram/Kconfig | 7 + drivers/ram/Makefile | 2 + drivers/ram/mt2824-ddr.c | 706 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 715 insertions(+)
drivers/ram/Kconfig +7 -0
@@ -139,6 +139,13 @@ config K3_MULTI_DDR responsible for interleaving between the controllers. default y if SOC_K3_J721S2 || SOC_K3_J784S4 +config SPL_METANOIA_MT2824_DDR + bool "Metanoia MT2824 DDR driver in SPL" + depends on SPL_RAM + help + Enable support for the internal DDR Memory Controller + of the Metanoia MT2824 SoC in the SPL. + source "drivers/ram/aspeed/Kconfig" source "drivers/ram/cadence/Kconfig" source "drivers/ram/octeon/Kconfig"
drivers/ram/Makefile +2 -0
@@ -19,6 +19,8 @@ obj-$(CONFIG_K3_DDRSS) += k3-ddrss/ obj-$(CONFIG_IMXRT_SDRAM) += imxrt_sdram.o +obj-$(CONFIG_SPL_METANOIA_MT2824_DDR) += mt2824-ddr.o + obj-$(CONFIG_RAM_SIFIVE) += sifive/ ifdef CONFIG_XPL_BUILD obj-$(CONFIG_SPL_STARFIVE_DDR) += starfive/
drivers/ram/mt2824-ddr.c new file +706 -0
706 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 8/10 spi: atcspi200_spi: Add spi-mem support for the Metanoia ATCSPI200 variant
In reply to Benoît MoninThe Metanoia variant of the ATCSPI200 core adds hardware command and address phases along with the dual and quad I/O data formats. Expose them through the spi-mem operations, which is required to use SPI NOR flash devices at full speed.
The Metanoia variant is detected at probe time with device_is_compatible() and gets the mem_ops assigned, following the same pattern as the Octeon driver. The Andes instances keep the generic spi-mem fallback built on top of the .xfer operation, unchanged.
--- drivers/spi/atcspi200_spi.c | 176 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 168 insertions(+), 8 deletions(-)
drivers/spi/atcspi200_spi.c +168 -8
@@ -10,6 +10,7 @@#include <log.h> #include <malloc.h> #include <spi.h> +#include <spi-mem.h> #include <asm/global_data.h> #include <asm/io.h> #include <dm.h>
@@ -30,6 +31,7 @@ struct atcspi200_spi_regs {u32 reserve1[3 ];u32 format;/* 0x10 */ #define DATA_LENGTH (x) ((x-1)<<8) +#define ADDR_LENGTH (x) ((x-1)<<16)u32 pio;u32 reserve2[2 ];u32 tctrl;/* 0x20 */
@@ -49,6 +51,10 @@ struct atcspi200_spi_regs {#define WCNT_MASK (0x1FF<<WCNT_OFFSET)#define RCNT_OFFSET 0#define RCNT_MASK (0x1FF<<RCNT_OFFSET) +#define CMD_EN (1<<30) +#define ADDR_EN (1<<29) +#define DUAL_QUAD (x) ((x)<<22) +#define DUMMY_CNT (x) (((x)-1)<<9)u32 cmd;u32 addr;u32 data;
@@ -364,6 +370,164 @@ static int atcspi200_spi_get_clk(struct udevice *bus)return 0 ; } +/* +* The dummy phase is generated in units of 8 bits: one unit takes +* (8 / data buswidth) SCLK cycles. The unit count is programmed in the +* 2-bit DummyCnt field of the TransCtrl register. +*/ +static unsigned int atcspi200_mem_dummy_units (const struct spi_mem_op *op) +{ +unsigned int cycles; + + cycles = op->dummy.nbytes *8 / + max_t(unsigned int, op->dummy.buswidth, 1U); + +return cycles * op->data.buswidth /8 ; +} + +static int atcspi200_mem_adjust_op_size (struct spi_slave *slave, +struct spi_mem_op *op) +{ + op->data.nbytes =min (op->data.nbytes, (unsigned int )MAX_TRANSFER_LEN ); + +return 0 ; +} + +static bool atcspi200_mem_supports_op (struct spi_slave *slave, +const struct spi_mem_op *op) +{ +unsigned int cycles, units; + +if (!spi_mem_default_supports_op (slave, op)) +return false; + +/* the address phase is always transferred on a single line */ +if (op->addr.nbytes >4 || (op->addr.nbytes && op->addr.buswidth !=1 )) +return false; + +/* a dummy phase without data cannot be expressed by the controller */ +if (op->dummy.nbytes && !op->data.nbytes) +return false; + +if (!op->data.nbytes) +return true; + +if (op->data.buswidth !=1 && op->data.buswidth !=2 && + op->data.buswidth !=4 ) +return false; + +/* the write and read counters are 9-bit fields */ +if (op->data.nbytes >MAX_TRANSFER_LEN ) +return false; + +/* reject dummy cycles which cannot be represented by DummyCnt */ + cycles = op->dummy.nbytes *8 / + max_t(unsigned int, op->dummy.buswidth, 1U); +if (cycles * op->data.buswidth %8 ) +return false; + + units = cycles * op->data.buswidth /8 ; + +return units <=4 ; +} + +static int atcspi200_mem_exec_op (struct spi_slave *slave, +const struct spi_mem_op *op) +{ +struct udevice *bus = slave->dev->parent; +struct nds_spi_slave *ns =dev_get_priv (bus); +unsigned int format, tc =0 , units; +unsigned int len = op->data.nbytes; +const u8 *dout = op->data.buf.out; +u8 *din = op->data.buf.in; +int timeout =SPI_TIMEOUT ; + +/* reprogram the address length for this operation */ + format =in_le32 (&ns->regs->format) & ~(0x3 <<16 ); +if (op->addr.nbytes) + format |=ADDR_LENGTH (op->addr.nbytes); +out_le32 (&ns->regs->format, format); + +if (op->cmd.nbytes) + tc |=CMD_EN ; +if (op->addr.nbytes) { + tc |=ADDR_EN ; +out_le32 (&ns->regs->addr, op->addr.val); + } + +if (op->data.nbytes) { +if (op->data.buswidth ==2 ) + tc |=DUAL_QUAD (1 ); +else if (op->data.buswidth ==4 ) + tc |=DUAL_QUAD (2 ); + +if (op->data.dir ==SPI_MEM_DATA_IN ) { + units =atcspi200_mem_dummy_units (op); + tc |= units ?TRAMODE_DR :TRAMODE_RO ; +if (units) + tc |=DUMMY_CNT (units); + tc |= (op->data.nbytes -1 ) &0x1FF ; + }else { + tc |=TRAMODE_WO ; + tc |= ((op->data.nbytes -1 ) &0x1FF ) <<WCNT_OFFSET ; + } + }else { + tc |=TRAMODE_NONE ; + } + +out_le32 (&ns->regs->tctrl, tc); +out_le32 (&ns->regs->cmd, op->cmd.opcode); + +while (len) { +unsigned int event =in_le32 (&ns->regs->status); + +if (op->data.dir ==SPI_MEM_DATA_OUT ) { +if (!(event &TXFFL )) { +out_le32 (&ns->regs->data, *dout++); + len--; + } + }else { +if (event &RXFVE_MASK ) { + *din++ =in_le32 (&ns->regs->data); + len--; + } + } + +if (!timeout--) +return -ETIMEDOUT ; + } + +while (in_le32 (&ns->regs->status) &SPIBSY ) { +if (!timeout--) +return -ETIMEDOUT ; + } + +/* restore the timing register like the legacy path does */ +out_le32 (&ns->regs->timing, ns->mtiming); + +return 0 ; +} + +/* +* The Metanoia variant of the ATCSPI200 core adds the command and address +* phases along with the dual and quad I/O data formats, exposed through the +* spi-mem operations assigned at probe time below. The other instances keep +* using the generic spi-mem fallback on top of .xfer. +*/ +static struct dm_spi_ops atcspi200_spi_ops = { + .claim_bus = atcspi200_spi_claim_bus, + .release_bus = atcspi200_spi_release_bus, + .xfer = atcspi200_spi_xfer, + .set_speed = atcspi200_spi_set_speed, + .set_mode = atcspi200_spi_set_mode, +}; + +static const struct spi_controller_mem_ops atcspi200_mem_ops = { + .adjust_op_size = atcspi200_mem_adjust_op_size, + .supports_op = atcspi200_mem_supports_op, + .exec_op = atcspi200_mem_exec_op, +}; +static int atcspi200_spi_probe (struct udevice *bus) {struct nds_spi_slave *ns =dev_get_priv (bus);
@@ -373,6 +537,9 @@ static int atcspi200_spi_probe(struct udevice *bus) ns->mtiming = ns->regs->timing;atcspi200_spi_get_clk (bus); +if (device_is_compatible (bus,"metanoia,mt2824-spi" )) + atcspi200_spi_ops.mem_ops = &atcspi200_mem_ops; +return 0 ; }
@@ -394,16 +561,9 @@ static int atcspi200_ofdata_to_platadata(struct udevice *bus)return 0 ; } -static const struct dm_spi_ops atcspi200_spi_ops = { - .claim_bus = atcspi200_spi_claim_bus, - .release_bus = atcspi200_spi_release_bus, - .xfer = atcspi200_spi_xfer, - .set_speed = atcspi200_spi_set_speed, - .set_mode = atcspi200_spi_set_mode, -}; -static const struct udevice_id atcspi200_spi_ids[] = { { .compatible ="andestech,atcspi200" }, + { .compatible ="metanoia,mt2824-spi" }, { } };
Signature · 1 line
2.55.0
PATCH 9/10 riscv: dts: add MT2824 SoC and MT5824 EVB device trees
In reply to Benoît MoninAdd the device trees for the MT2824 SoC (mt2824.dtsi) and the MT5824 EVB board (mt5824-evb.dts). The SoC integrates:
- a dual-core Andes AX45MP with 256 KB unified L2 cache
- PLIC, PLIC SW and PLMT interrupt and timer controllers
- a DesignWare-derived SDHCI controller
- an ATCSPI200 QSPI controller with a 32 MiB Macronix NOR flash exposed as a memory-mapped device through nvmxip
- a DDR controller with its firmware mapped through a "fw" reg entry
The u-boot.dtsi overlay marks the nodes used by the SPL with bootph-pre-ram and describes the binman FIT image packing OpenSBI, U-Boot and the device tree.
--- arch/riscv/dts/Makefile | 1 + arch/riscv/dts/mt2824-u-boot.dtsi | 66 ++++++++++++ arch/riscv/dts/mt2824.dtsi | 219 ++++++++++++++++++++++++++++++++++++++ arch/riscv/dts/mt5824-evb.dts | 34 ++++++ 4 files changed, 320 insertions(+)
arch/riscv/dts/Makefile +1 -0
@@ -3,6 +3,7 @@ dtb-$(CONFIG_TARGET_ANDES_AE350) += ae350_32.dtb ae350_64.dtb dtb-$(CONFIG_TARGET_ANDES_VOYAGER) += qilai-voyager.dtb dtb-$(CONFIG_TARGET_K230_CANMV) += k230-canmv.dtb +dtb-$(CONFIG_TARGET_METANOIA_MT5824_EVB) += mt5824-evb.dtb dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb dtb-$(CONFIG_TARGET_MILKV_DUO_256M) += sg2002-milkv-duo256m.dtb
arch/riscv/dts/mt2824-u-boot.dtsi new file +66 -0
66 lines not on this page · raw message
arch/riscv/dts/mt2824.dtsi new file +219 -0
219 lines not on this page · raw message
arch/riscv/dts/mt5824-evb.dts new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (C) 2026 Metanoia Communications Inc. All rights reserved. + */ +/dts-v1/; + +#include "mt2824.dtsi" + +/ { + #address-cells = <0x02>; + #size-cells = <0x02>; + model = "Metanoia MT5824 EVB"; + compatible = "metanoia,mt5824-evb", "metanoia,mt2824"; + + chosen { + stdout-path = "uart0:115200n8"; + }; + + ddr: memory@0 { + device_type = "memory"; + reg = <0x0 0x0000000080000000 0x00000000 0x80000000>, + <0x1 0x0000000000000000 0x00000000 0x80000000>; + }; +}; + +&qspi { + flash@0 { + compatible = "jedec,spi-nor"; + spi-rx-bus-width = <0x4>; + spi-tx-bus-width = <0x4>; + spi-max-frequency = <100000000>; + reg = <0x0>; + }; +};
Signature · 1 line
2.55.0
PATCH 10/10 riscv: metanoia: Add support for the MT5824 EVB platform
In reply to Benoît MoninAdd board, configuration and SPL support for the Metanoia MT5824 Evaluation Board, built around the MT2824 SoC.
Boot flow: the ROM loads the SPL from the SD card or the QSPI NOR. The SPL initializes the SoC PLL, loads and validates the DDR firmware from the boot device and initializes the DDR controller through the MT2824 DDR driver, then sets up the SDHCI controller and starts U-Boot proper via OpenSBI.
On both boot media, the SPL locates its payloads by name in the GPT partition table ("uboot", "ddrfw"). The A/B slot is selected by the ROM one-shot boot: the boot source and the slot selection are left in scratch registers by the ROM, and the SPL reads them to pick the matching partition (the FIP flag partition attribute selects the slot within the "uboot" partitions).
The environment backend (MMC or SPI flash) is selected at runtime following the boot source. On MMC devices, the environment is stored in a "u-boot-env" type-GPT partition, with a fixed offset fallback; on the SPI-NOR, it is stored at a fixed offset.
--- arch/riscv/Kconfig | 4 + board/metanoia/mt5824-evb/Kconfig | 45 ++++ board/metanoia/mt5824-evb/MAINTAINERS | 11 + board/metanoia/mt5824-evb/Makefile | 7 + board/metanoia/mt5824-evb/board.c | 61 +++++ board/metanoia/mt5824-evb/board.h | 35 +++ board/metanoia/mt5824-evb/mt5824-evb.env | 6 + board/metanoia/mt5824-evb/spl.c | 388 +++++++++++++++++++++++++++++++ configs/metanoia-mt5824-evb_defconfig | 73 ++++++ doc/board/index.rst | 1 + doc/board/metanoia/index.rst | 9 + doc/board/metanoia/mt5824-evb.rst | 232 ++++++++++++++++++ include/configs/metanoia-mt5824-evb.h | 28 +++ 13 files changed, 900 insertions(+)
arch/riscv/Kconfig +4 -0
@@ -23,6 +23,9 @@ config TARGET_K230_CANMV config TARGET_LICHEERV_NANO bool "Support LicheeRV Nano Board" +config TARGET_METANOIA_MT5824_EVB + bool "Support Metanoia MT5824 Evaluation Board" + config TARGET_MICROCHIP_GENERIC bool "Support Microchip PolarFire-SoC Boards"
@@ -115,6 +118,7 @@ source "board/aspeed/ibex_ast2700/Kconfig" source "board/beagle/beaglev_fire/Kconfig" source "board/canaan/k230_canmv/Kconfig" source "board/emulation/qemu-riscv/Kconfig" +source "board/metanoia/mt5824-evb/Kconfig" source "board/microchip/mpfs_generic/Kconfig" source "board/openpiton/riscv64/Kconfig" source "board/sifive/unleashed/Kconfig"
board/metanoia/mt5824-evb/Kconfig new file +45 -0
45 lines not on this page · raw message
board/metanoia/mt5824-evb/MAINTAINERS new file +11 -0
@@ -0,0 +1,11 @@ +Metanoia MT5824 EVB +M: Jun Chang <[email protected]> +S: Maintained +F: arch/riscv/dts/mt2824* +F: arch/riscv/dts/mt5824-evb* +F: board/metanoia/mt5824-evb/ +F: configs/metanoia-mt5824-evb_defconfig +F: doc/board/metanoia/ +F: drivers/mmc/metanoia_sdhci.c +F: drivers/ram/mt2824-ddr.c +F: include/configs/metanoia-mt5824-evb.h
board/metanoia/mt5824-evb/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Metanoia Communications Inc., +# Jun Chang, Metanoia Communications Inc. <[email protected]> + +obj-y := board.o +obj-$(CONFIG_SPL_BUILD) += spl.o
board/metanoia/mt5824-evb/board.c new file +61 -0
61 lines not on this page · raw message
board/metanoia/mt5824-evb/board.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Metanoia Communications Inc., +* Jun Chang, Metanoia Communications Inc. <[email protected]> +*/ + +#ifndef _METANOIA_MT5824_BOARD_H +#define _METANOIA_MT5824_BOARD_H + +#include <asm/io.h> +#include <linux/bitfield.h> +#include <linux/bitops.h> + +#define RST_PINSTRAP phys_to_virt(0x10000018) + +#define CFG_SCRATCH_POR1 phys_to_virt(0x10010504) +#define CFG_SCRATCH_POR1_OSB GENMASK(23, 0) +#define CFG_SCRATCH_POR1_PARTSEL BIT(24) +#define CFG_SCRATCH_POR1_BOOTSRC GENMASK(27, 25) + +#define RST_PINSTRAP_BOOTSRC GENMASK(7, 6) + +#define OSB_ROM_SIG 0x0062734F +#define OSB_ACK 0x0042534F + +enum boot_source { +BOOT_SOURCE_RESERVED =0 , +BOOT_SOURCE_QSPI_NOR , +BOOT_SOURCE_SD_MMC ,/* SD */ +BOOT_SOURCE_SD_MMC2 ,/* eMMC */ +}; + +enum boot_source mt2824_get_boot_source (void ); + +#endif
board/metanoia/mt5824-evb/mt5824-evb.env new file +6 -0
@@ -0,0 +1,6 @@ +kernel_addr_r=0x82000000 +fdt_addr_r=0x87000000 +fdtoverlay_addr_r=0x87100000 +pxefile_addr_r=0x87200000 +scriptaddr=0x87300000 +ramdisk_addr_r=0x88000000
board/metanoia/mt5824-evb/spl.c new file +388 -0
388 lines not on this page · raw message
configs/metanoia-mt5824-evb_defconfig new file +73 -0
73 lines not on this page · raw message
doc/board/index.rst +1 -0
@@ -41,6 +41,7 @@ Board-specific doc lg/index liebherr/index mediatek/index + metanoia/index microchip/index microsoft/index motorola/index
doc/board/metanoia/index.rst new file +9 -0
@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Metanoia +======== + +.. toctree:: + :maxdepth: 2 + + mt5824-evb
doc/board/metanoia/mt5824-evb.rst new file +232 -0
232 lines not on this page · raw message
include/configs/metanoia-mt5824-evb.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2026 Metanoia Communication Inc., +* Jun Chang, Metanoia Communication Inc. <[email protected]> +*/ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#define RISCV_MMODE_TIMERBASE 0x0c400000 + +#define RISCV_MMODE_TIMER_FREQ 20000000 +#define RISCV_SMODE_TIMER_FREQ 20000000 + +/* Init Heap Pointer */ +#define CFG_MALLOC_F_ADDR 0x68180000 + +/* +* Serial console configuration +*/ +#define CFG_SYS_NS16550_CLK 225000000 + +#define MT2824_NOR_FLASH_BASE 0x20000000 +#define CFG_SYS_UBOOT_BASE (MT2824_NOR_FLASH_BASE + 0x2800 * 512) + +#define CFG_DDRFW_OFFSET 0x300000 + +#endif /* __CONFIG_H */
Signature · 1 line
2.55.0