Re: [PATCH 3/4] efi_loader: use INCLUDE in EFI linker scripts

2025-01-15 Thread Ilias Apalodimas
On Tue, 14 Jan 2025 at 12:30, Heinrich Schuchardt
 wrote:
>
> Except for the architecture specific lines ARM and RISC-V can use the same
> linker script. Move the common lines to an include.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  arch/arm/lib/elf_aarch64_efi.lds   | 68 +--
>  arch/riscv/lib/elf_riscv32_efi.lds | 68 +--
>  arch/riscv/lib/elf_riscv64_efi.lds | 68 +--
>  lib/efi_loader/elf_efi.ldsi| 74 ++
>  4 files changed, 77 insertions(+), 201 deletions(-)
>  create mode 100644 lib/efi_loader/elf_efi.ldsi
>
> diff --git a/arch/arm/lib/elf_aarch64_efi.lds 
> b/arch/arm/lib/elf_aarch64_efi.lds
> index e382254a6cf..453d3511c28 100644
> --- a/arch/arm/lib/elf_aarch64_efi.lds
> +++ b/arch/arm/lib/elf_aarch64_efi.lds
> @@ -8,70 +8,4 @@
>  OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", 
> "elf64-littleaarch64")
>  OUTPUT_ARCH(aarch64)
>
> -PHDRS
> -{
> -   data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
> -}
> -
> -ENTRY(_start)
> -SECTIONS
> -{
> -   .text 0x0 : {
> -   _text = .;
> -   *(.text.head)
> -   *(.text)
> -   *(.text.*)
> -   *(.gnu.linkonce.t.*)
> -   *(.srodata)
> -   *(.rodata*)
> -   . = ALIGN(16);
> -   *(.dynamic);
> -   . = ALIGN(512);
> -   }
> -   .rela.dyn : { *(.rela.dyn) }
> -   .rela.plt : { *(.rela.plt) }
> -   .rela.got : { *(.rela.got) }
> -   .rela.data : { *(.rela.data) *(.rela.data*) }
> -   . = ALIGN(4096);
> -   _etext = .;
> -   _text_size = . - _text;
> -   .data : {
> -   _data = .;
> -   *(.sdata)
> -   *(.data)
> -   *(.data1)
> -   *(.data.*)
> -   *(.got.plt)
> -   *(.got)
> -
> -   /*
> -* The EFI loader doesn't seem to like a .bss section, so we
> -* stick it all into .data:
> -*/
> -   . = ALIGN(16);
> -   _bss = .;
> -   *(.sbss)
> -   *(.scommon)
> -   *(.dynbss)
> -   *(.bss)
> -   *(.bss.*)
> -   *(COMMON)
> -   . = ALIGN(512);
> -   _bss_end = .;
> -   _edata = .;
> -   } :data
> -   _data_size = _edata - _data;
> -
> -   . = ALIGN(4096);
> -   .dynsym   : { *(.dynsym) }
> -   . = ALIGN(4096);
> -   .dynstr   : { *(.dynstr) }
> -   . = ALIGN(4096);
> -   .note.gnu.build-id : { *(.note.gnu.build-id) }
> -   /DISCARD/ : {
> -   *(.rel.reloc)
> -   *(.eh_frame)
> -   *(.note.GNU-stack)
> -   }
> -   .comment 0 : { *(.comment) }
> -}
> +INCLUDE lib/efi_loader/elf_efi.ldsi
> diff --git a/arch/riscv/lib/elf_riscv32_efi.lds 
> b/arch/riscv/lib/elf_riscv32_efi.lds
> index 7b9bd7b7f15..e23521c4931 100644
> --- a/arch/riscv/lib/elf_riscv32_efi.lds
> +++ b/arch/riscv/lib/elf_riscv32_efi.lds
> @@ -8,70 +8,4 @@
>  OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
>  OUTPUT_ARCH(riscv)
>
> -PHDRS
> -{
> -   data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */
> -}
> -
> -ENTRY(_start)
> -SECTIONS
> -{
> -   .text 0x0 : {
> -   _text = .;
> -   *(.text.head)
> -   *(.text)
> -   *(.text.*)
> -   *(.gnu.linkonce.t.*)
> -   *(.srodata)
> -   *(.rodata*)
> -   . = ALIGN(16);
> -   *(.dynamic);
> -   . = ALIGN(512);
> -   }
> -   .rela.dyn : { *(.rela.dyn) }
> -   .rela.plt : { *(.rela.plt) }
> -   .rela.got : { *(.rela.got) }
> -   .rela.data : { *(.rela.data) *(.rela.data*) }
> -   _etext = .;
> -   _text_size = . - _text;
> -   . = ALIGN(4096);
> -   .data : {
> -   _data = .;
> -   *(.sdata)
> -   *(.data)
> -   *(.data1)
> -   *(.data.*)
> -   *(.got.plt)
> -   *(.got)
> -
> -   /*
> -* The EFI loader doesn't seem to like a .bss section, so we
> -* stick it all into .data:
> -*/
> -   . = ALIGN(16);
> -   _bss = .;
> -   *(.sbss)
> -   *(.scommon)
> -   *(.dynbss)
> -   *(.bss)
> -   *(.bss.*)
> -   *(COMMON)
> -   . = ALIGN(512);
> -   _bss_end = .;
> -   _edata = .;
> -   } :data
> -   _data_size = _edata - _data;
> -
> -   . = ALIGN(4096);
> -   .dynsym   : { *(.dynsym) }
> -   . = ALIGN(4096);
> -   .dynstr   : { *(.dynstr) }
> -   . = ALIGN(4096);
> -   .note.gnu.build-id : { *(.note.gnu.build-id) }
> -   /DISCARD/ : {
> -   *(.r

Re: [PATCH 4/4] efi_loader: use include in ARM EFI linker script

2025-01-15 Thread Ilias Apalodimas
On Wed, 15 Jan 2025 at 10:53, Heinrich Schuchardt
 wrote:
>
> On 15.01.25 09:06, Ilias Apalodimas wrote:
> > Hi Heinrich
> >
> >
> > On Tue, 14 Jan 2025 at 12:30, Heinrich Schuchardt
> >  wrote:
> >>
> >> Use the same include as arm64 for the linker script.
> >>
> >> Adjust the 32-bit ARM PE-COFF header accordingly and harmonize it with the
> >> 64-bit ARM header.
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>   arch/arm/lib/crt0_arm_efi.S  | 37 ++-
> >>   arch/arm/lib/elf_arm_efi.lds | 71 +---
> >>   2 files changed, 20 insertions(+), 88 deletions(-)
> >>
> >> diff --git a/arch/arm/lib/crt0_arm_efi.S b/arch/arm/lib/crt0_arm_efi.S
> >> index b5dfd4e3819..590fcf515da 100644
> >> --- a/arch/arm/lib/crt0_arm_efi.S
> >> +++ b/arch/arm/lib/crt0_arm_efi.S
> >> @@ -14,11 +14,11 @@
> >>  /*
> >>   * Magic "MZ" signature for PE/COFF
> >>   */
> >> -   .globl  image_base
> >> -image_base:
> >> +   .globl  ImageBase
> >> +ImageBase:
> >>  .short  IMAGE_DOS_SIGNATURE /* 'MZ' */
> >>  .skip   58  /* 'MZ' + pad + offset == 
> >> 64 */
> >> -   .long   pe_header - image_base  /* Offset to the PE header 
> >> */
> >> +   .long   pe_header - ImageBase   /* Offset to the PE header 
> >> */
> >>   pe_header:
> >>  .long   IMAGE_NT_SIGNATURE  /* 'PE' */
> >>   coff_header:
> >> @@ -38,16 +38,16 @@ optional_header:
> >>  .short  IMAGE_NT_OPTIONAL_HDR32_MAGIC   /* PE32 format */
> >>  .byte   0x02/* MajorLinkerVersion */
> >>  .byte   0x14/* MinorLinkerVersion */
> >> -   .long   _edata - _start /* SizeOfCode */
> >> +   .long   _etext - _start /* SizeOfCode */
> >
> > Was that an error all along? Or the boundaries changed by using the
> > include file?
>
> According to https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
>
> SizeOfCode:
> "The size of the code (text) section, or the sum of all code sections if
> there are multiple sections."
>
> We only have one code section.
>
> Looking at EDK2's Shell.efi SizeOfCode equals the VirtualSize of the
> .text section. It does not include the .data section.
>

Hmm that's interesting. gnu-efi includes .data AFAICT.
Looking at the pe/coff spec there's SizeOfCode and
SizeOfInitializedData (for .data) and SizeOfUninitializedData (for
.bss).
But in both gnu-efi and U-Boot we define those two as 0 though. So I
think we should either keep SizeOfData as is, or define it as you
propose and also define SizeOfInitializedData and
SizeOfUninitializedData correctly -- and I don't know if the latter
will have any implication on loaders.

Cheers
/Ilias
> Best regards
>
> Heinrich
>
> >
> >>  .long   0   /* SizeOfInitializedData 
> >> */
> >>  .long   0   /* 
> >> SizeOfUninitializedData */
> >> -   .long   _start - image_base /* AddressOfEntryPoint */
> >> -   .long   _start - image_base /* BaseOfCode */
> >> +   .long   _start - ImageBase  /* AddressOfEntryPoint */
> >> +   .long   _start - ImageBase  /* BaseOfCode */
> >>  .long   0   /* BaseOfData */
> > [...]
> >
> > Other than that it looks ok
> >
> > Thanks for cleaning this up!
> > /Ilias
>


Re: [PATCH 03/10] usb: dwc3-generic: Reorder include

2025-01-15 Thread Patrice CHOTARD



On 1/14/25 15:51, Marek Vasut wrote:
> On 1/14/25 3:45 PM, Patrice Chotard wrote:
>> Reorder include following rules available here :
>> https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files
>>
>> Signed-off-by: Patrice Chotard 
>> Cc: Marek Vasut 
>> ---
>>
>>   drivers/usb/dwc3/dwc3-generic.c | 21 ++---
>>   1 file changed, 10 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-generic.c 
>> b/drivers/usb/dwc3/dwc3-generic.c
>> index 2ab41cbae45..cb96e1f344f 100644
>> --- a/drivers/usb/dwc3/dwc3-generic.c
>> +++ b/drivers/usb/dwc3/dwc3-generic.c
>> @@ -7,29 +7,28 @@
>>    * Based on dwc3-omap.c.
>>    */
>>   +#include 
>>   #include 
>> -#include 
>>   #include 
>> -#include 
>> -#include 
>>   #include 
>>   #include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>>   #include 
>> -#include 
>>   #include 
>> -#include 
>> -#include "core.h"
>> -#include "gadget.h"
>> -#include 
>> -#include 
>>   #include 
>> -#include 
> Can you remove some of them too ?
Hi Marek

Effectively, some seems useless, i will fix this in v2

Thanks
Patrice


[PATCH] board: phytec: phycore-am62x: Add DDR size fixups if ECC is enabled

2025-01-15 Thread Wadim Egorov
With commit 22ce56a3ebdb ("ram: k3-ddrss: Add k3_ddrss_ddr_bank_base_size_calc()
to solve 'calculations restricted to 32 bits' issue") we need to provide the
detected RAM size in the device tree node prio to K3 DDRSS driver probe.
This is done by calling fdt_fixup_memory_banks() in do_board_detect().

After probing, call into k3-ddrss driver to fixup device tree and resize
the available amount of DDR if ECC is enabled.

A third fixup is required from A53 SPL to take the fixup
as done from R5 SPL and apply it to DT passed to A53 U-boot,
which in turn passes this to the OS.

Signed-off-by: Wadim Egorov 
---
 board/phytec/phycore_am62x/phycore-am62x.c | 31 +++---
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/board/phytec/phycore_am62x/phycore-am62x.c 
b/board/phytec/phycore_am62x/phycore-am62x.c
index a0e098e010e..b199fdaa59b 100644
--- a/board/phytec/phycore_am62x/phycore-am62x.c
+++ b/board/phytec/phycore_am62x/phycore-am62x.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "phycore-ddr-data.h"
@@ -97,6 +98,8 @@ int dram_init_banksize(void)
 {
u8 ram_size;
 
+   memset(gd->bd->bi_dram, 0, sizeof(gd->bd->bi_dram[0]) * 
CONFIG_NR_DRAM_BANKS);
+
if (!IS_ENABLED(CONFIG_CPU_V7R))
return fdtdec_setup_memory_banksize();
 
@@ -178,17 +181,11 @@ int update_ddrss_timings(void)
 
 int do_board_detect(void)
 {
-   return update_ddrss_timings();
-}
-#endif
-
-#if IS_ENABLED(CONFIG_XPL_BUILD)
-void spl_perform_fixups(struct spl_image_info *spl_image)
-{
+   int ret;
+   void *fdt = (void *)gd->fdt_blob;
+   int bank;
u64 start[CONFIG_NR_DRAM_BANKS];
u64 size[CONFIG_NR_DRAM_BANKS];
-   int bank;
-   int ret;
 
dram_init();
dram_init_banksize();
@@ -198,7 +195,21 @@ void spl_perform_fixups(struct spl_image_info *spl_image)
size[bank] = gd->bd->bi_dram[bank].size;
}
 
-   ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size, 
CONFIG_NR_DRAM_BANKS);
+   ret = fdt_fixup_memory_banks(fdt, start, size, CONFIG_NR_DRAM_BANKS);
+   if (ret)
+   return ret;
+
+   return update_ddrss_timings();
+}
+#endif
+
+#if IS_ENABLED(CONFIG_XPL_BUILD)
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+   if (IS_ENABLED(CONFIG_K3_DDRSS) && IS_ENABLED(CONFIG_K3_INLINE_ECC))
+   fixup_ddr_driver_for_ecc(spl_image);
+   else
+   fixup_memory_node(spl_image);
 }
 #endif
 
-- 
2.34.1



Re: [PATCH 2/3] image: Add support for starting TFA BL31 as fitImage loadables

2025-01-15 Thread Quentin Schulz

Hi Marek, Biju,

On 1/13/25 2:31 PM, Biju Das wrote:

Hi Marex,


-Original Message-
From: Marek Vasut 
Sent: 13 January 2025 12:40
Subject: Re: [PATCH 2/3] image: Add support for starting TFA BL31 as fitImage 
loadables

On 1/13/25 1:15 PM, Biju Das wrote:

Hi Marex,

Thanks for the patch


-Original Message-
From: U-Boot  On Behalf Of Marek Vasut
Sent: 12 January 2025 22:37
Subject: [PATCH 2/3] image: Add support for starting TFA BL31 as
fitImage loadables

Add support for starting TFA from U-Boot running in EL3 as part of
fitImage boot, so the user can start U-Boot in the highest privilege
level on the platform, bundle TFA, Linux, DT into a single fitImage and boot 
such a bundle as a

whole.


There are two main benefits of this approach. First is the ability to
run U-Boot in EL3, where it has unrestricted access to the entire
system and can act as a useful debug tool, as it was always intendedSecure)
to be used. Second is the ability to easily and safely update of any component 
in the fitImage, be

it TFA, Linux or DT.


In this case, who will do switching from secure world to normal world, u-boot?
Do you have any link to the u-boot patch from secure to normal world
switching with kernel entry point passed to BL31?

Otherwise, kernel, also will be executing in secure world mode.

See 3/3 , U-Boot runs in EL3 , before starting kernel it jumps into TFA
BL31 , TFA BL31 does its setup and switches from EL3 to EL2 , TFA BL31 returns 
to U-Boot
armv8_switch_to_el2 which checks if this code is running in EL2 (it is) and 
does the last few steps
before starting kernel, and then finally jumps to the kernel .


Thanks for the explanation. I missed the details in 3/3.

BL2(Secure)->U-boot(Secure)->BL31(Secure)-->U-boot(Normal)->Linux Kernel(Normal)



If the fit image is missing the TF-A loadable property for example (and 
maybe in other corner case scenario?) the kernel will start in EL3 
though and fail very early since it needs TF-A BL31 for a few things. 
However, part of the kernel code will actually run in EL3 and that could 
be enough to mess things up with a carefully crafted kernel image.


Is this actually possible or am I making stuff up? If it is possible, 
isn't that an issue?


Currently, this is already possible and has happened a few times already 
at my company with people forgetting to bundle TF-A in U-Boot and then 
the kernel would boot but stops early (no console output even IIRC). But 
the bootloader is not THAT often updated in the field compared to kernel 
(especially if coming from distros) which would now allow to store the 
TF-A, so this opens an even bigger can of worms? In a way, it allows to 
update TF-A likely more securely (which is VERY welcome on Rockchip for 
example, where we usually start new SoC bringups with a blob from 
Rockchip and then have upstream TF-A catch up a few years later. Having 
BL31 part of U-Boot is a huge pain because it is difficult for some 
devices to do safe updates of U-Boot) but may introduce some bigger 
security issues?


Finally, another question, what happens if we have a U-Boot with bundled 
TF-A BL31 AND it tries to boot a fitimage with a TF-A BL31 loadable? 
Should we only allow to load tf-a BL31 if running from EL3 (meaning if 
in EL2, TF-A is expected to be already running)?


Cheers,
Quentin


Re: [PATCH 3/5] pxe_utils: Allow the FDT to be missing

2025-01-15 Thread Quentin Schulz

Hi Simon,

On 1/15/25 2:16 AM, Simon Glass wrote:

Hi Quentin,

On Tue, 14 Jan 2025 at 08:13, Quentin Schulz  wrote:


Hi Simon,

On 12/20/24 5:01 AM, Simon Glass wrote:

The devicetree file may not be provided, so avoid a failure in that
case.



Can you provide a bit more information on when/why this shouldn't be a
failure? I assume likely x86? or Aarch64 with ACPI instead of OF?


Yes, either of those, but also, even on platforms which use a
devicetree, some don't have it in the extlinux file. For example rpi
passes it through to U-Boot from its own closed-source firmware.



Ah yes, I had forgotten about platforms using one DTB and passing it 
through stages, I believe Qualcomm does this as well?


Could you please add what you just said to the commit log so that we 
have an idea which scenario this intends to support (for future 
reference if this introduces a regression or we want to do refactoring 
in the future).


I'm wondering if this isn't going to allow booting FDT systems without 
an FDT at all, which really isn't great? Is there something we 
could/should do to prevent that from happening (or at least notify the 
user of such a scenario so it's easier to debug)?



Somewhat related: my opinion with extlinux (and EFI for that matter)
is that we should be using FIT.



FIT images are not really developer-friendly though :/ I've been asked 
to ditch FIT images to allow easy replacement of customer Device 
Trees/kernel images. Much easier to say "copy your file there, modify 
extlinux.conf to point at the new filepath for the FDT" rather than "so 
this is the ITS, change the path here, and there, don't forget to have 
those binaries in the current path, use mkimage, then copy this itb file 
there".


In any case, I don't believe we could remove non-FIT support, so here we 
are :)


Cheers,
Quentin


[PATCH 1/2] .mailmap: update email address for Christopher Obbard

2025-01-15 Thread Christopher Obbard
Update my email address.

Signed-off-by: Christopher Obbard 
---
 .mailmap | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.mailmap b/.mailmap
index 
005e965b84f8ec441f7868664eeaf394076264a0..dc11775d4e7f8294f77f5bef55214c7f743e3202
 100644
--- a/.mailmap
+++ b/.mailmap
@@ -36,6 +36,7 @@ Bin Meng  
 Boris Brezillon  
 Boris Brezillon  
 Christian Kohn  
+Christopher Obbard  
 Dirk Behme 
 Durga Challa  
 Eugen Hristev  

-- 
2.47.1



[PATCH v2 4/4] board: vexpress64: enable bloblist for SPL handoff

2025-01-15 Thread Harrison Mutai
Enable bloblist on vexpress64 platforms to facilitate information
passing from TF-A using the firmware handoff framework.

Signed-off-by: Harrison Mutai 

---
 board/armltd/vexpress64/Makefile|  3 ++-
 board/armltd/vexpress64/vexpress64.c|  4 
 configs/vexpress_fvp_bloblist_defconfig |  5 +
 doc/board/armltd/vexpress64.rst | 16 
 4 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 configs/vexpress_fvp_bloblist_defconfig

diff --git a/board/armltd/vexpress64/Makefile b/board/armltd/vexpress64/Makefile
index 1878fbed4e..4729787c5e 100644
--- a/board/armltd/vexpress64/Makefile
+++ b/board/armltd/vexpress64/Makefile
@@ -3,5 +3,6 @@
 # (C) Copyright 2000-2004
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
-obj-y  := vexpress64.o lowlevel_init.o
+obj-y  := vexpress64.o
+obj-$(CONFIG_OF_HAS_PRIOR_STAGE)   := lowlevel_init.o
 obj-$(CONFIG_TARGET_VEXPRESS64_JUNO)   += pcie.o
diff --git a/board/armltd/vexpress64/vexpress64.c 
b/board/armltd/vexpress64/vexpress64.c
index b5ede58757..0b75c1358f 100644
--- a/board/armltd/vexpress64/vexpress64.c
+++ b/board/armltd/vexpress64/vexpress64.c
@@ -100,7 +100,9 @@ int dram_init_banksize(void)
  * Push the variable into the .data section so that it
  * does not get cleared later.
  */
+#ifdef CONFIG_OF_HAS_PRIOR_STAGE
 unsigned long __section(".data") prior_stage_fdt_address[2];
+#endif
 
 #ifdef CONFIG_OF_BOARD
 
@@ -151,6 +153,7 @@ static phys_addr_t find_dtb_in_nor_flash(const char 
*partname)
 }
 #endif
 
+#ifdef CONFIG_OF_HAS_PRIOR_STAGE
 /*
  * Filter for a valid DTB, as TF-A happens to provide a pointer to some
  * data structure using the DTB format, which we cannot use.
@@ -201,6 +204,7 @@ int board_fdt_blob_setup(void **fdtp)
return -ENXIO;
 }
 #endif
+#endif
 
 /* Actual reset is done via PSCI. */
 void reset_cpu(void)
diff --git a/configs/vexpress_fvp_bloblist_defconfig 
b/configs/vexpress_fvp_bloblist_defconfig
new file mode 100644
index 00..dcc87db872
--- /dev/null
+++ b/configs/vexpress_fvp_bloblist_defconfig
@@ -0,0 +1,5 @@
+#include 
+
+CONFIG_BLOBLIST=y
+CONFIG_BLOBLIST_PASSAGE=y
+CONFIG_BLOBLIST_SIZE_RELOC=0x1
diff --git a/doc/board/armltd/vexpress64.rst b/doc/board/armltd/vexpress64.rst
index a7f771d266..4dadadb53d 100644
--- a/doc/board/armltd/vexpress64.rst
+++ b/doc/board/armltd/vexpress64.rst
@@ -43,6 +43,22 @@ Juno is an Arm development board with the following features:
 
 More details can be found in the board documentation [3]_.
 
+Bloblist Support
+
+
+The ``vexpress_fvp_bloblist_defconfig`` configures U-Boot to be compiled for
+Vexpress64 with Bloblist as the primary method for information handoff between
+boot stages. U-Boot offers three methods to set up a bloblist: using a
+predefined bloblist at a specified address, dynamically allocating memory for a
+bloblist, or utilizing a standard passage-provided bloblist with automatic size
+detection.
+
+By default, ``vexpress_fvp_bloblist_defconfig`` uses the standard passage 
method
+(CONFIG_BLOBLIST_PASSAGE) because TF-A provides a Transfer List in non-secure
+memory that U-Boot can utilise. This Bloblist, which is referred to as a 
Transfer List in
+TF-A, contains all necessary data for the handoff process, including DT and 
ACPI
+tables.
+
 References
 --
 
-- 
2.46.2



[PATCH v2 1/4] bloblist: fix typo in code comments

2025-01-15 Thread Harrison Mutai
Fix the two typos in the spelling of same and set in common/Kconfig and
include/bloblist.h.

Signed-off-by: Harrison Mutai 
---
 common/Kconfig | 2 +-
 include/bloblist.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 0e8c44f3f7..7a80b797df 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1083,7 +1083,7 @@ config BLOBLIST_SIZE
  Sets the size of the bloblist in bytes. This must include all
  overhead (alignment, bloblist header, record header). The bloblist
  is set up in the first part of U-Boot to run (TPL, SPL or U-Boot
- proper), and this sane bloblist is used for subsequent phases.
+ proper), and this same bloblist is used for subsequent phases.
 
 config BLOBLIST_SIZE_RELOC
hex "Size of bloblist after relocation"
diff --git a/include/bloblist.h b/include/bloblist.h
index f999391f74..03d9862c0f 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -463,7 +463,7 @@ int bloblist_init(void);
 /**
  * bloblist_maybe_init() - Init the bloblist system if not already done
  *
- * Calls bloblist_init() if the GD_FLG_BLOBLIST_READY flag is not et
+ * Calls bloblist_init() if the GD_FLG_BLOBLIST_READY flag is not set
  *
  * Return: 0 if OK, -ve on error
  */
-- 
2.46.2



[PATCH v2 3/4] bloblist: add support for CONFIG_BLOBLIST_PASSAGE

2025-01-15 Thread Harrison Mutai
When the configuration option CONFIG_BLOBLIST_PASSAGE is selected, the
bloblist present in the incoming standard passage is utilised in-place.
There is no need to specify the size of the bloblist as the system
automatically detects it using the header information.

Signed-off-by: Harrison Mutai 
---
 common/Kconfig| 8 +++-
 common/bloblist.c | 5 -
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 7a80b797df..49fe04ffca 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1064,6 +1064,12 @@ config BLOBLIST_ALLOC
  specify a fixed address on systems where this is unknown or can
  change at runtime.
 
+config BLOBLIST_PASSAGE
+   bool "Use bloblist in-place"
+   help
+ Use a bloblist in the incoming standard passage. The size is detected
+ automatically so CONFIG_BLOBLIST_SIZE can be 0.
+
 endchoice
 
 config BLOBLIST_ADDR
@@ -1078,6 +1084,7 @@ config BLOBLIST_ADDR
 
 config BLOBLIST_SIZE
hex "Size of bloblist"
+   default 0x0 if BLOBLIST_PASSAGE
default 0x400
help
  Sets the size of the bloblist in bytes. This must include all
@@ -1088,7 +1095,6 @@ config BLOBLIST_SIZE
 config BLOBLIST_SIZE_RELOC
hex "Size of bloblist after relocation"
default BLOBLIST_SIZE if BLOBLIST_FIXED || BLOBLIST_ALLOC
-   default 0x0 if BLOBLIST_PASSAGE
default 0x2 if (ARM && EFI_LOADER && GENERATE_ACPI_TABLE)
help
  Sets the size of the bloblist in bytes after relocation. Since U-Boot
diff --git a/common/bloblist.c b/common/bloblist.c
index 110bb9dc44..f52f1eaca9 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -475,6 +475,9 @@ int bloblist_reloc(void *to, uint to_size)
 {
struct bloblist_hdr *hdr;
 
+   if (to_size == 0)
+   return 0;
+
if (to_size < gd->bloblist->total_size)
return -ENOSPC;
 
@@ -510,7 +513,7 @@ int bloblist_init(void)
 * install the bloblist passed from previous loader to this fixed
 * address.
 */
-   bool from_boot_arg = fixed && xpl_is_first_phase();
+   bool from_boot_arg = xpl_is_first_phase();
 
if (xpl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
from_addr = false;
-- 
2.46.2



[PATCH v2 2/4] board: vexpress64: default to hardware device tree

2025-01-15 Thread Harrison Mutai
When booting into the Linux kernel with semi-hosting, use the device
tree provided by hardware unless one is provided in the current
directory.

Signed-off-by: Harrison Mutai 
---
 include/configs/vexpress_aemv8.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/configs/vexpress_aemv8.h b/include/configs/vexpress_aemv8.h
index 8020689e39..2341b3a938 100644
--- a/include/configs/vexpress_aemv8.h
+++ b/include/configs/vexpress_aemv8.h
@@ -169,12 +169,14 @@
"  if load hostfs - ${kernel_addr_r} ${kernel_name}; then"  
\
"setenv fdt_high 0x;"   \
"setenv initrd_high 0x;"\
-   "load hostfs - ${fdt_addr_r} ${fdtfile};"   
\
+   "if test -n load hostfs - ${fdt_addr_r} ${fdtfile}; then"   
\
+   "fdt move $fdtcontroladdr $fdt_addr_r;" 
\
+   "fi;"   \
"load hostfs - ${ramdisk_addr_r} ${ramdisk_name};" \
"fdt addr ${fdt_addr_r};"   \
"fdt resize;"   \
"fdt chosen ${ramdisk_addr_r} ${filesize};" \
-   "booti $kernel_addr_r - $fdt_addr_r;"   \
+   "booti $kernel_addr_r - ${fdt_addr_r};" \
"  fi;" \
"fi\0"
 #define BOOTENV_DEV_NAME_SMH(devtypeu, devtypel, instance) "smh "
-- 
2.46.2



[PATCH v2 0/4] Enable bloblist support on Vexpress64

2025-01-15 Thread Harrison Mutai
This series of patches enhances the vexpress64 platform by enabling bloblist
support. It also introduces support for CONFIG_BLOBLIST_PASSAGE. This is
necessary to boot vexpress64 and other boards without manually specifying a
fixed address and size for the bloblist.

After this change, all the bloblist init modes are supported (i.e., fixed,
alloc, passage) and Vexpress64 boots with CONFIG_BLOBLIST_PASSAGE.

Changes in v2:

* The commit body for the typo fix was expanded.
* The default BLOBLIST_RELOC_SIZE was removed when CONFIG_BLOBLIST_PASSAGE is
  enabled, the relocation size depends on the size of bloblist received.

Harrison Mutai (4):
  bloblist: fix typo in code comments
  board: vexpress64: default to hardware device tree
  bloblist: add support for CONFIG_BLOBLIST_PASSAGE
  board: vexpress64: enable bloblist for SPL handoff

 board/armltd/vexpress64/Makefile|  3 ++-
 board/armltd/vexpress64/vexpress64.c|  4 
 common/Kconfig  | 10 --
 common/bloblist.c   |  5 -
 configs/vexpress_fvp_bloblist_defconfig |  5 +
 doc/board/armltd/vexpress64.rst | 16 
 include/bloblist.h  |  2 +-
 include/configs/vexpress_aemv8.h|  6 --
 8 files changed, 44 insertions(+), 7 deletions(-)
 create mode 100644 configs/vexpress_fvp_bloblist_defconfig

-- 
2.46.2



Re: [PATCH 1/3] clk: rockchip: rk3328: use HDMIPHY PLL as a clock parent for VOP_DCLK

2025-01-15 Thread Matwey V. Kornilov
Thanks. Very interesting. I'll test it on my Rock64 at the weekend.

вт, 14 янв. 2025 г. в 08:26, Vasily Khoruzhick :
>
> The only video mode that currently works on rk3328 in u-boot is 1080p,
> because it uses GPLL for VOP_DCLK clock parent.
>
> Linux driver uses HDMIPHY PLL as a clock parent for VOP_DCLK, since using
> GPLL or CPLL is not feasible due these PLL being used as a clock parent
> for other devices. It would be cumbersome to recalculate dividers
> for the rest of the devices, and u-boot doesn't do it anyway. As a
> result, u-boot is not able to set desired dot clock for most
> resolutions.
>
> Switch to using HDMIPHY as a clock parent for VOP_DCLK
>
> Tested with 768p, 1080p, 1440p monitors.
>
> Fixes: 92edae779f8c ("clk: rockchip: rk3328: Add VOP clk support")
> Signed-off-by: Vasily Khoruzhick 
> ---
>  drivers/clk/rockchip/clk_rk3328.c | 76 +++
>  1 file changed, 16 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/clk/rockchip/clk_rk3328.c 
> b/drivers/clk/rockchip/clk_rk3328.c
> index 7701a9734ee..537af6b3290 100644
> --- a/drivers/clk/rockchip/clk_rk3328.c
> +++ b/drivers/clk/rockchip/clk_rk3328.c
> @@ -79,6 +79,12 @@ enum {
> PLL_MODE_SLOW   = 0,
> PLL_MODE_NORM,
>
> +   /* MISC_CON */
> +   HDMIPHY_24M_SEL_SHIFT   = 13,
> +   HDMIPHY_24M_SEL_MASK= 1 << HDMIPHY_24M_SEL_SHIFT,
> +   HDMIPHY_24M_SEL_PCLK= 0,
> +   HDMIPHY_24M_SEL_24MHZ   = 1,
> +
> /* CLKSEL_CON0 */
> CLK_CORE_PLL_SEL_APLL   = 0,
> CLK_CORE_PLL_SEL_GPLL,
> @@ -583,41 +589,11 @@ static ulong rk3328_spi_set_clk(struct rk3328_cru *cru, 
> uint hz)
>  }
>
>  #ifndef CONFIG_XPL_BUILD
> -static ulong rk3328_vop_get_clk(struct rk3328_clk_priv *priv, ulong clk_id)
> -{
> -   struct rk3328_cru *cru = priv->cru;
> -   u32 div, con, parent;
> -
> -   switch (clk_id) {
> -   case ACLK_VOP_PRE:
> -   con = readl(&cru->clksel_con[39]);
> -   div = (con & ACLK_VOP_DIV_CON_MASK) >> ACLK_VOP_DIV_CON_SHIFT;
> -   parent = GPLL_HZ;
> -   break;
> -   case ACLK_VIO_PRE:
> -   con = readl(&cru->clksel_con[37]);
> -   div = (con & ACLK_VIO_DIV_CON_MASK) >> ACLK_VIO_DIV_CON_SHIFT;
> -   parent = GPLL_HZ;
> -   break;
> -   case DCLK_LCDC:
> -   con = readl(&cru->clksel_con[40]);
> -   div = (con & DCLK_LCDC_DIV_CON_MASK) >> 
> DCLK_LCDC_DIV_CON_SHIFT;
> -   parent = GPLL_HZ;
> -   break;
> -   default:
> -   printf("%s: Unsupported vop get clk#%ld\n", __func__, clk_id);
> -   return -ENOENT;
> -   }
> -
> -   return DIV_TO_RATE(parent, div);
> -}
> -
>  static ulong rk3328_vop_set_clk(struct rk3328_clk_priv *priv,
> ulong clk_id, uint hz)
>  {
> struct rk3328_cru *cru = priv->cru;
> int src_clk_div;
> -   u32 con, parent;
>
> src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
> assert(src_clk_div - 1 < 31);
> @@ -636,42 +612,25 @@ static ulong rk3328_vop_set_clk(struct rk3328_clk_priv 
> *priv,
>  (src_clk_div - 1) << ACLK_VIO_DIV_CON_SHIFT);
> break;
> case DCLK_LCDC:
> -   con = readl(&cru->clksel_con[40]);
> -   con = (con & DCLK_LCDC_SEL_MASK) >> DCLK_LCDC_SEL_SHIFT;
> -   if (con) {
> -   parent = readl(&cru->clksel_con[40]);
> -   parent = (parent & DCLK_LCDC_PLL_SEL_MASK) >>
> -DCLK_LCDC_PLL_SEL_SHIFT;
> -   if (parent)
> -   src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
> -   else
> -   src_clk_div = DIV_ROUND_UP(GPLL_HZ, hz);
> -
> -   rk_clrsetreg(&cru->clksel_con[40],
> -DCLK_LCDC_DIV_CON_MASK,
> -(src_clk_div - 1) <<
> -DCLK_LCDC_DIV_CON_SHIFT);
> -   }
> +   /* Set HDMIPHY clock output to pixel clock */
> +   rk_clrsetreg(&cru->misc, HDMIPHY_24M_SEL_MASK,
> +HDMIPHY_24M_SEL_PCLK << HDMIPHY_24M_SEL_SHIFT);
> +   /* Set HDMIPHY as a parent of DCLK_LCDC, and set all divisors 
> to 1 */
> +   rk_clrsetreg(&cru->clksel_con[40],
> +DCLK_LCDC_DIV_CON_MASK | DCLK_LCDC_SEL_MASK | 
> CLK_HDMIPHY_DIV_CON_MASK,
> +(1 - 1) << CLK_HDMIPHY_DIV_CON_SHIFT |
> +DCLK_LCDC_SEL_HDMIPHY << DCLK_LCDC_SEL_SHIFT |
> +(1 - 1) << DCLK_LCDC_DIV_CON_SHIFT);
> break;
> default:
> printf("%s: Unable to set vop clk#%ld\n", __func__, clk_id);
> 

Re: [PATCH 1/8] ARM: renesas: Rename board/renesas/rcar-common to board/renesas/common

2025-01-15 Thread Quentin Schulz

Hi Marek,

On 1/12/25 11:34 PM, Marek Vasut wrote:

Rename directory board/renesas/rcar-common to board/renesas/common and
move files. This allows the build system to use HAVE_VENDOR_COMMON_LIB
which automatically includes board/$(VENDOR)/common/Makefile . This is


Please mention this is NOT sufficient to make use of 
HAVE_VENDOR_COMMON_LIB as board/renesas/common is missing a Makefile.


Something like:

This will allow the build system to use HAVE_VENDOR_COMMON_LIB once a 
Makefile is added in a later commit. This mechanism automatically 
includes board/$(VENDOR)/common/Makefile.


or something like that.


a preparatory patch for board Makefile simplification. No functional
change so far.

Signed-off-by: Marek Vasut 


The change is fine, but please make the commit log a bit less confusing 
around the use of HAVE_VENDOR_COMMON_LIB in this commit.


Reviewed-by: Quentin Schulz 

Thanks!
Quentin


Re: [PATCH 2/4] scripts/Makefile.lib: add -L option to LD command for EFI binaries

2025-01-15 Thread Ilias Apalodimas
On Tue, 14 Jan 2025 at 12:30, Heinrich Schuchardt
 wrote:
>
> The linker uses the path specified with -L to search for linker scripts
> and for linker script includes.
>
> For out-of-tree builds specify the build directory with -L instead of
> the absolute path of the linker script. This allows using an INCLUDE
> statement.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  scripts/Makefile.lib | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 54403040f00..18993435eae 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -523,10 +523,10 @@ $(obj)/%.efi: $(obj)/%_efi.so
>  KBUILD_EFILDFLAGS = -nostdlib -zexecstack -znocombreloc -znorelro
>  KBUILD_EFILDFLAGS += $(call ld-option,--no-warn-rwx-segments)
>  quiet_cmd_efi_ld = LD  $@
> -cmd_efi_ld = $(LD) $(KBUILD_EFILDFLAGS) -T $(EFI_LDS_PATH) \
> +cmd_efi_ld = $(LD) $(KBUILD_EFILDFLAGS) -L $(srctree) -T $(EFI_LDS_PATH) \
> -shared -Bsymbolic -s $^ -o $@
>
> -EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)
> +EFI_LDS_PATH = arch/$(ARCH)/lib/$(EFI_LDS)
>
>  $(obj)/efi_crt0.o: $(srctree)/arch/$(ARCH)/lib/$(EFI_CRT0:.o=.S) FORCE
> $(call if_changed_dep,as_o_S)
> --
> 2.47.1
>

Reviewed-by: Ilias Apalodimas 


Re: [PATCH] arm: Remove redundant loading of image copy start offset.Because the beginning is already computed

2025-01-15 Thread Quentin Schulz

Hi Liya,

On 1/15/25 2:56 AM, 1425075...@qq.com wrote:

[You don't often get email from 1425075...@qq.com. Learn why this is important 
at https://aka.ms/LearnAboutSenderIdentification ]

From: Liya Huang <1425075...@qq.com>



Please have some commit log in there justifying the change. There seems 
to be some issues with the commit title so probably part of it should be 
in the commit log rather than in the title (one needs an empty line 
between the commit title and the start of the commit log when editing 
the commit "description" with a text editor).



Reviewed-by: Simon Glass 
Reviewed-by: Pali Rohár 


Same remark as for your other patch 
(https://lore.kernel.org/u-boot/3d51107a-4761-4de8-9bae-a462c2a8e...@cherry.de/), 
pasting here what I said there:


"""
This... is odd. I don't see an earlier version of that patch and your
name/mail only returns two patches on the U-Boot mailing list. I believe
Reviewed-by needs to be publicly given on the ML as they are a proof of
review by the mentioned person and is usually a trust mark for
maintainers to merge code. Here it may have been added without Simon's
consent. Now imagine Simon is not answering for a few days/weeks, the
maintainer could still believe Simon went through a proper review and
merge that patch taking that into account while no review may actually
have been conducted. This is making me uncomfortable.

[...]

I'm not saying review wasn't done properly, but its acknowledgment
should be made public by the mentioned person instead of being put into
the v1.

Have I missed an earlier version or discussion maybe?
"""

Even odder is that Pali has explicitly requested to not be receiving any 
mail from the U-Boot project anymore, c.f. 
https://lore.kernel.org/u-boot/20231106090908.7938-1-xypron.g...@gmx.de/. 
That doesn't exclude him for doing reviews of course but that is still 
odd. I'm explicitly keeping him in Cc here as I am not sure this went 
through the proper review process and he may not want his name put in 
there acknowledging something he might not have done.


Cheers,
Quentin


Re: [PATCH] linker_lists: Update the alignment using CONFIG_LINKER_LIST_ALIGN

2025-01-15 Thread Simon Glass
Hi Quentin,

On Wed, 15 Jan 2025 at 03:58, Quentin Schulz  wrote:
>
> Hi Liya,
>
> On 1/14/25 8:09 AM, 1425075...@qq.com wrote:
> > [You don't often get email from 1425075...@qq.com. Learn why this is 
> > important at https://aka.ms/LearnAboutSenderIdentification ]
> >
> > From: Liya Huang <1425075...@qq.com>
> >
> > This patch updates the alignment of linker lists to use the
> > CONFIG_LINKER_LIST_ALIGN macro instead of a hardcoded value.
> > This ensures that the alignment is consistent with the configuration.
> > Replace __attribute__((unused)) with __maybe_unused and
> > __always_unused to eliminate the warning of checkpatch.pl.
> >
> > Reviewed-by: Simon Glass 
>
> This... is odd. I don't see an earlier version of that patch and your
> name/mail only returns two patches on the U-Boot mailing list. I believe
> Reviewed-by needs to be publicly given on the ML as they are a proof of
> review by the mentioned person and is usually a trust mark for
> maintainers to merge code. Here it may have been added without Simon's
> consent. Now imagine Simon is not answering for a few days/weeks, the
> maintainer could still believe Simon went through a proper review and
> merge that patch taking that into account while no review may actually
> have been conducted. This is making me uncomfortable.
>
> Same issue for
> https://lore.kernel.org/u-boot/tencent_cce8303926957c427aae06f9d91282458...@qq.com/.
>
> I'm not saying review wasn't done properly, but its acknowledgment
> should be made public by the mentioned person instead of being put into
> the v1.
>
> Have I missed an earlier version or discussion maybe?

I was wondering the same thing, actually.

I don't see anything wrong with the code in this patch, though.

The docs are here:
https://docs.u-boot.org/en/latest/develop/sending_patches.html

Regards,
Simon


Re: [PATCH v3 05/13] power-domain: Add refcounting

2025-01-15 Thread Simon Glass
Hi Miquel,

On Fri, 10 Jan 2025 at 11:43, Miquel Raynal  wrote:
>
> It is very surprising that such an uclass, specifically designed to
> handle resources that may be shared by different devices, is not keeping
> the count of the number of times a power domain has been
> enabled/disabled to avoid shutting it down unexpectedly or disabling it
> several times.
>
> Doing this causes troubles on eg. i.MX8MP because disabling power
> domains can be done in recursive loops were the same power domain
> disabled up to 4 times in a row. PGCs seem to have tight FSM internal
> timings to respect and it is easy to produce a race condition that puts
> the power domains in an unstable state, leading to ADB400 errors and
> later crashes in Linux.
>
> CI tests using power domains are slightly updated to make sure the count
> of on/off calls is even and the results match what we *now* expect.
>
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/firmware/scmi/sandbox-scmi_devices.c |  1 +
>  drivers/power/domain/power-domain-uclass.c   | 37 
> ++--
>  drivers/power/domain/sandbox-power-domain-test.c |  1 +
>  include/power-domain.h   |  4 +--
>  test/dm/power-domain.c   |  2 +-
>  5 files changed, 40 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c 
> b/drivers/firmware/scmi/sandbox-scmi_devices.c
> index 
> 96c2922b067e2886b3fa963bcd7e396f4569a569..9f253b0fd40f703a5ec11d34c197423d27ad8b01
>  100644
> --- a/drivers/firmware/scmi/sandbox-scmi_devices.c
> +++ b/drivers/firmware/scmi/sandbox-scmi_devices.c
> @@ -163,4 +163,5 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = {
> .priv_auto = sizeof(struct sandbox_scmi_device_priv),
> .remove = sandbox_scmi_devices_remove,
> .probe = sandbox_scmi_devices_probe,
> +   .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
>  };
> diff --git a/drivers/power/domain/power-domain-uclass.c 
> b/drivers/power/domain/power-domain-uclass.c
> index 
> 938bd8cbc9ffd1ba2109d702f886b6a99288d063..55a3d95d83c5aaac31acbd877199c87f8f6fb880
>  100644
> --- a/drivers/power/domain/power-domain-uclass.c
> +++ b/drivers/power/domain/power-domain-uclass.c
> @@ -12,6 +12,10 @@
>  #include 
>  #include 
>
> +struct power_domain_priv {
> +   int on_count;
> +};
> +
>  static inline struct power_domain_ops *power_domain_dev_ops(struct udevice 
> *dev)
>  {
> return (struct power_domain_ops *)dev->driver->ops;
> @@ -110,19 +114,47 @@ int power_domain_free(struct power_domain *power_domain)
>  int power_domain_on(struct power_domain *power_domain)
>  {
> struct power_domain_ops *ops = 
> power_domain_dev_ops(power_domain->dev);
> +   struct power_domain_priv *priv = 
> dev_get_uclass_priv(power_domain->dev);
> +   int ret;
>
> debug("%s(power_domain=%p)\n", __func__, power_domain);
>
> -   return ops->on ? ops->on(power_domain) : 0;
> +   if (priv->on_count++ > 0)
> +   return 0;

-EALREADY

> +
> +   ret = ops->on ? ops->on(power_domain) : 0;
> +   if (ret) {
> +   priv->on_count--;
> +   return ret;
> +   }
> +
> +   return 0;
>  }
>
>  int power_domain_off(struct power_domain *power_domain)
>  {
> struct power_domain_ops *ops = 
> power_domain_dev_ops(power_domain->dev);
> +   struct power_domain_priv *priv = 
> dev_get_uclass_priv(power_domain->dev);
> +   int ret;
>
> debug("%s(power_domain=%p)\n", __func__, power_domain);
>
> -   return ops->off ? ops->off(power_domain) : 0;
> +   if (priv->on_count <= 0) {
> +   debug("Power domain %s already off.\n", 
> power_domain->dev->name);
> +   priv->on_count--;
> +   return 0;
> +   }
> +
> +   if (priv->on_count-- > 1)
> +   return 0;

-EBUSY

See how the regulator uclass does it.

> +
> +   ret = ops->off ? ops->off(power_domain) : 0;
> +   if (ret) {
> +   priv->on_count++;
> +   return ret;
> +   }
> +
> +   return 0;
>  }
>
>  #if CONFIG_IS_ENABLED(OF_REAL)
> @@ -180,4 +212,5 @@ int dev_power_domain_off(struct udevice *dev)
>  UCLASS_DRIVER(power_domain) = {
> .id = UCLASS_POWER_DOMAIN,
> .name   = "power_domain",
> +   .per_device_auto = sizeof(struct power_domain_priv),
>  };
> diff --git a/drivers/power/domain/sandbox-power-domain-test.c 
> b/drivers/power/domain/sandbox-power-domain-test.c
> index 
> 08c15ef342b3dd3ce01807ee59b7e97337f7dde5..5b530974e942ffcba453e53be330baaf3a113a13
>  100644
> --- a/drivers/power/domain/sandbox-power-domain-test.c
> +++ b/drivers/power/domain/sandbox-power-domain-test.c
> @@ -51,4 +51,5 @@ U_BOOT_DRIVER(sandbox_power_domain_test) = {
> .id = UCLASS_MISC,
> .of_match = sandbox_power_domain_test_ids,
> .priv_auto  = sizeof(struct sandbox_power_domain_test),
> +   .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
>  };
> di

Re: [PATCH 04/10] usb: dwc3-generic: Add STih407 support

2025-01-15 Thread Patrice CHOTARD



On 1/14/25 15:53, Marek Vasut wrote:
> On 1/14/25 3:45 PM, Patrice Chotard wrote:
> 
>> +    /* glue init */
>> +    reg = readl(glue_base + CLKRST_CTRL);
>> +
>> +    reg |= AUX_CLK_EN | EXT_CFG_RESET_N | XHCI_REVISION;
>> +    reg &= ~SW_PIPEW_RESET_N;
>> +
>> +    writel(reg, glue_base + CLKRST_CTRL);
>> +
>> +    /* configure mux for vbus, powerpresent and bvalid signals */
>> +    reg = readl(glue_base + USB2_VBUS_MNGMNT_SEL1);
>> +
>> +    reg |= SEL_OVERRIDE_VBUSVALID(USB2_VBUS_UTMIOTG) |
>> +   SEL_OVERRIDE_POWERPRESENT(USB2_VBUS_UTMIOTG) |
>> +   SEL_OVERRIDE_BVALID(USB2_VBUS_UTMIOTG);
>> +
>> +    writel(reg, glue_base + USB2_VBUS_MNGMNT_SEL1);
> setbits_le32() , please fix globally.

Ok

> 
> Also, I am wondering if we're not overstuffing the dwc3-generic.c with too 
> many disparate glue code shreds, and whether it isn't just about time to 
> split the glue code parts out of it, into separate .c files. Thoughts ?

OK i will introduce a specific dwc3-sti.c glue wrapper. I just notice that 
dwc3-am62.c or dwc3-uniphier.c are typically what i have to do.
By the same occasion, it removes the need of patch 06/10 with REGMAP/SYSCON 
dependencies

Thanks
Patrice


Re: [PATCH 1/2] efi_loader: efi_setup: Add efi_start_obj_list() to efi_setup.c

2025-01-15 Thread Simon Glass
Hi Heinrich,

On Fri, 10 Jan 2025 at 08:13, Heinrich Schuchardt  wrote:
>
> On 10.01.25 14:40, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Fri, 3 Jan 2025 at 12:55, Heinrich Schuchardt  wrote:
> >>
> >> On 06.12.24 18:30, Adriano Cordova wrote:
> >>> The command bootefi calls efi_init_obj_list to do the efi set up
> >>> before launching an .efi payload, but efi_init_obj_list is called
> >>> only once. There are some initializations which depend on the
> >>> environment and should be done each time a payload gets launched and
> >>> not only once and can now be done in efi_start_obj_list(). A motivation
> >>> for this change is the following order of events:
> >>>
> >>> 1. Launch an EFI application (e.g. bootefi hello)
> >>> 2. Change the ip address
> >>> 3. Launch another application which uses the pxe protocol
> >>
> >> Hello Adriano,
> >>
> >> Thanks for addressing this issue.
> >>
> >> There are a number of events that can lead to updating the IP address:
> >>
> >> * EFI_PXE_BASE_CODE_PROTOCOL.Dhcp()
> >> * EFI_PXE_BASE_CODE_PROTOCOL.SetStationIp()
> >> * EFI_HTTP_PROTOCOL.Configure()
> >> * command set env ethaddr#
> >> * command dhcp
> >>
> >> All of these events require:
> >>
> >> * Updating the relevant ethaddr* variable.
> >> * Updating any other references to the IP address.
> >>
> >> When not only considering EFI applications but also EFI drivers
> >> installed via the bootefi command all of these events can occur during
> >> the runtime of EFI binaries.
> >>
> >> Function efi_init_obj_list() is used for setups that are needed only
> >> once before accessing the UEFI sub-system. It is not able to handle events.
> >>
> >> If we need to update any internal UEFI data structures, we should do
> >> this instantaneously when the event occurs and not when executing a UEFI
> >> related shell command.
> >>
> >> U-Boot already has callbacks invoked when variables are changed. These
> >> are set up with U_BOOT_ENV_CALLBACK(). There is even a command 'env
> >> callbacks' to list these callbacks.
> >>
> >> You could define a new function to handle changes of the IP address and
> >> invoke it via U_BOOT_ENV_CALLBACK(ipaddr, ) or
> >> U_BOOT_ENV_CALLBACK(netmask, ).
> >>
> >> With lwIP we can have multiple network interfaces. Each has a different
> >> variable ipaddr# assigned to it. We will have to extend the concept of
> >> U_BOOT_ENV_CALLBACK() to allow for wildcard matches by adjusting
> >> find_env_callback(). With CONFIG_REGEX=y regular expressions could be
> >> used for this purpose (cf. include/slre.h) but we should better avoid
> >> the code size increase.
> >>
> >
> > I have been saying for some time that EFI_LOADER should make use of
> > U-Boot's existing tables, rather than creating its own duplicate ones
> > with extra info.
>
> What structures are you referring to concerning this patch?

I gave the example of efi_cout_modes[]. I suspect quite a lot of
structures could be relationalised.

>
> >
> > This seems to have been understood as 'hang the EFI tables onto
> > existing data structures', e.g. efi_disk_create_part(). But this leads
> > to duplication.
>
> We have to present the U-Boot DM devices in a way that an EFI binary can
> consume.
>
> Unless U-Boot's DM-layer is re-implemented via EFI structures we will
> end up with two representations.

I believe we can reduce the amount of duplication, in general. I'm not
just thinking about driver model. The EFI loader was originally
designed to avoid dependence on driver model (I can provide the thread
if you like), so even there, I believe improvement is possible.

>
> >
> > Perhaps the EFI_LOADER init should be quite small, and be done each
> > time an app starts, to deal with the 'current' state of U-Boot?
>
> No, we can load both EFI apps and EFI drivers with the bootefi command.
> In the case of EFI drivers we must not remove the handles and protocols
> representing U-Boot DM devices after the binaries return.

My question is whether these can be generated based on the available
objects, with just a small amount of data kept in the dm struct, or
whether they must be in a separate data structure?

Regards,
SImon


Re: [PATCH v5 4/8] RFC: Revert "bootstd: Make efi_mgr bootmeth work for non-sandbox setups"

2025-01-15 Thread Simon Glass
Hi Tom,

On Fri, 10 Jan 2025 at 10:05, Tom Rini  wrote:
>
> On Fri, Jan 10, 2025 at 06:41:00AM -0700, Simon Glass wrote:
> > Hi Tom,
> >
> > On Thu, 9 Jan 2025 at 08:22, Tom Rini  wrote:
> > >
> > > On Thu, Jan 09, 2025 at 08:11:58AM -0700, Simon Glass wrote:
> > > > Hi Tom,
> > > >
> > > > On Thu, 9 Jan 2025 at 08:05, Tom Rini  wrote:
> > > > >
> > > > > On Thu, Jan 09, 2025 at 08:01:13AM -0700, Simon Glass wrote:
> > > > > > Hi Heinrich,
> > > > > >
> > > > > > On Sat, 4 Jan 2025 at 19:50, Heinrich Schuchardt 
> > > > > >  wrote:
> > > > > > >
> > > > > > > On 11/13/24 16:09, Simon Glass wrote:
> > > > > > > > This is another option to fix sunxi booting with bootstd, which 
> > > > > > > > may be
> > > > > > > > better since it will work for all boards. We can then figure 
> > > > > > > > out how to
> > > > > > > > automatically and deterministicaly decide when bootmgr should 
> > > > > > > > be used.
> > > > > > > >
> > > > > > > > This reverts commit f2bfa0cb17948aa4a0fa20fdf9014296b9c4d9c7.
> > > > > > > >
> > > > > > > > Signed-off-by: Simon Glass 
> > > > > > > > ---
> > > > > > > > If this patch is applied, we don't need to drop bootmgr for 
> > > > > > > > sunxi
> > > > > > > >
> > > > > > > > (no changes since v1)
> > > > > > > >
> > > > > > > >   boot/bootmeth_efi_mgr.c | 18 +-
> > > > > > > >   1 file changed, 1 insertion(+), 17 deletions(-)avilable
> > > > > > > >
> > > > > > > > diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
> > > > > > > > index 23ae1e610ac..095fa74fc60 100644
> > > > > > > > --- a/boot/bootmeth_efi_mgr.c
> > > > > > > > +++ b/boot/bootmeth_efi_mgr.c
> > > > > > > > @@ -14,8 +14,6 @@
> > > > > > > >   #include 
> > > > > > > >   #include 
> > > > > > > >   #include 
> > > > > > > > -#include 
> > > > > > > > -#include 
> > > > > > > >
> > > > > > > >   /**
> > > > > > > >* struct efi_mgr_priv - private info for the efi-mgr driver
> > > > > > > > @@ -48,27 +46,13 @@ static int efi_mgr_check(struct udevice 
> > > > > > > > *dev, struct bootflow_iter *iter)
> > > > > > > >   static int efi_mgr_read_bootflow(struct udevice *dev, struct 
> > > > > > > > bootflow *bflow)
> > > > > > > >   {
> > > > > > > >   struct efi_mgr_priv *priv = dev_get_priv(dev);
> > > > > > > > - efi_status_t ret;
> > > > > > > > - efi_uintn_t size;
> > > > > > > > - u16 *bootorder;
> > > > > > > >
> > > > > > > >   if (priv->fake_dev) {
> > > > > > > >   bflow->state = BOOTFLOWST_READY;
> > > > > > > >   return 0;
> > > > > > > >   }
> > > > > > > >
> > > > > > > > - ret = efi_init_obj_list();
> > > > > > > > - if (ret)
> > > > > > > > - return log_msg_ret("init", ret);
> > > > > > > > -
> > > > > > > > - /* Enable this method if the "BootOrder" UEFI exists. */
> > > > > > > > - bootorder = efi_get_var(u"BootOrder", 
> > > > > > > > &efi_global_variable_guid,
> > > > > > > > - &size);
> > > > > > > > - if (bootorder) {
> > > > > > > > - free(bootorder);
> > > > > > > > - bflow->state = BOOTFLOWST_READY;
> > > > > > > > - return 0;
> > > > > > > > - }
> > > > > > > > + /* To be implemented */
> > > > > > >
> > > > > > > The EFI boot manager can boot based on:
> > > > > > >
> > > > > > > * variable BootOrder
> > > > > > > * variable BootNext
> > > > > > > * an existing file EFI/BOOT/BOOT.EFI
> > > > > > >
> > > > > > > It obsoletes bootsmeth_efi.
> > > > > > >
> > > > > > > >
> > > > > > > >   return -EINVAL;
> > > > > > >
> > > > > > > We must always run the EFI boot manager if it is enabled. So 
> > > > > > > -EINVAL is
> > > > > > > wrong here.
> > > > > >
> > > > > > Well, I don't believe you have a solution, then.
> > > > > >
> > > > > > You did suggest putting bootmgr later, as we discussed on irc.
> > > > > >
> > > > > > For now, I think we should apply this patch (and series), while we
> > > > > > sort out how to make bootmgr more incremental. It should not be
> > > > > > scanning every available device before it starts, since that can be
> > > > > > very slow.
> > > > >
> > > > > Heinrich and I talked the other day, and we think the right path is 
> > > > > the
> > > > > "later" path, where we don't try and use efi bootmanager until
> > > > > everything has been probed, and also drop the single "efi" option. 
> > > > > This
> > > > > should mean that by the time we would be trying efi bootmanager most 
> > > > > if
> > > > > not everything that needs to be probed has been probed. It doesn't 
> > > > > make
> > > > > any sense to have "efi bootmanger" be more incremental as conceptually
> > > > > it's point is to show the user all the options.
> > > >
> > > > What is the single 'efi' option? I hope you don't mean the EFI bootmeth.
> > >
> > > Yes, the single EFI bootmeth. Because part of the issue with that is to
> > > be compliant a bunch of things need to be probed. And rather than have
> > > an option to be

[PATCH v4 03/20] pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol

2025-01-15 Thread Alice Guo
From: Alice Guo 

This patch provides a pinctrl driver based on SCMI pin control protocol.
Currently, only the PINCTRL_CONFIG_SET command is implemented.

Signed-off-by: Ranjani Vaidyanathan 
Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 drivers/pinctrl/nxp/Kconfig|  13 
 drivers/pinctrl/nxp/Makefile   |   1 +
 drivers/pinctrl/nxp/pinctrl-imx.c  |   7 +-
 drivers/pinctrl/nxp/pinctrl-imx.h  |  11 +++
 drivers/pinctrl/nxp/pinctrl-scmi.c | 136 +
 include/scmi_protocols.h   |  34 ++
 6 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/nxp/Kconfig b/drivers/pinctrl/nxp/Kconfig
index 
06c26f156f6c8f63204604d6065485629cfd9b61..ec63ab595650d0dfab7e3a7dc01d4af7814b6773
 100644
--- a/drivers/pinctrl/nxp/Kconfig
+++ b/drivers/pinctrl/nxp/Kconfig
@@ -1,6 +1,19 @@
 config PINCTRL_IMX
bool
 
+config PINCTRL_IMX_SCMI
+   bool "IMX pinctrl SCMI driver"
+   depends on ARCH_IMX9 && PINCTRL_FULL
+   select PINCTRL_IMX
+   help
+ Say Y here to enable the imx pinctrl SCMI driver
+
+ This provides a simple pinctrl driver for i.MX SoC which supports
+ SCMI. This feature depends on device tree configuration. This driver
+ is different from the linux one, this is a simple implementation,
+ only parses the 'fsl,pins' property and configure related
+ registers.
+
 config PINCTRL_IMX_SCU
bool
 
diff --git a/drivers/pinctrl/nxp/Makefile b/drivers/pinctrl/nxp/Makefile
index 
f10aa6ef188e37583b181bdf9d70ac191e506d75..3ec3e2a9c6fdb875da4ae9bf151df5666256883b
 100644
--- a/drivers/pinctrl/nxp/Makefile
+++ b/drivers/pinctrl/nxp/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_PINCTRL_IMX6)  += pinctrl-imx6.o
 obj-$(CONFIG_PINCTRL_IMX7) += pinctrl-imx7.o
 obj-$(CONFIG_PINCTRL_IMX7ULP)  += pinctrl-imx7ulp.o
 obj-$(CONFIG_PINCTRL_IMX8ULP)  += pinctrl-imx8ulp.o
+obj-$(CONFIG_PINCTRL_IMX_SCMI) += pinctrl-scmi.o
 obj-$(CONFIG_PINCTRL_IMX_SCU)  += pinctrl-scu.o
 obj-$(CONFIG_PINCTRL_IMX8) += pinctrl-imx8.o
 obj-$(CONFIG_PINCTRL_IMX8M)+= pinctrl-imx8m.o
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c 
b/drivers/pinctrl/nxp/pinctrl-imx.c
index 
b1960c56b512cc113a810304dc3ac3f99b237a7e..0026aae00afe2b0aff40c3288c231b3065ef656a
 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Peng Fan 
+ * Copyright 2025 NXP
  */
 
 #include 
@@ -65,7 +66,9 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct 
udevice *config)
 
npins = size / pin_size;
 
-   if (info->flags & IMX8_USE_SCU) {
+   if (info->flags & IMX_USE_SCMI) {
+   return imx_pinctrl_scmi_conf_pins(dev, pin_data, npins);
+   } else if (info->flags & IMX8_USE_SCU) {
imx_pinctrl_scu_conf_pins(info, pin_data, npins);
} else {
/*
@@ -216,7 +219,7 @@ int imx_pinctrl_probe(struct udevice *dev,
priv->dev = dev;
priv->info = info;
 
-   if (info->flags & IMX8_USE_SCU)
+   if (info->flags & (IMX8_USE_SCU | IMX_USE_SCMI))
return 0;
 
addr = ofnode_get_addr_size_index(dev_ofnode(dev), 0, &size);
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.h 
b/drivers/pinctrl/nxp/pinctrl-imx.h
index 
fa4c084e2fc067fcb4e92c33312d4f430081fffd..f120e32d9da678d6e9ce583f0ba3c6c17d050f36
 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.h
+++ b/drivers/pinctrl/nxp/pinctrl-imx.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * Copyright (C) 2016 Peng Fan 
+ * Copyright 2025 NXP
  */
 
 #ifndef __DRIVERS_PINCTRL_IMX_H
@@ -47,6 +48,7 @@ extern const struct pinctrl_ops imx_pinctrl_ops;
 #define ZERO_OFFSET_VALID  0x2
 #define CFG_IBE_OBE0x4
 #define IMX8_USE_SCU   0x8
+#define IMX_USE_SCMI   0x10
 
 #define IOMUXC_CONFIG_SION (0x1 << 4)
 
@@ -65,4 +67,13 @@ static inline int imx_pinctrl_scu_conf_pins(struct 
imx_pinctrl_soc_info *info,
 }
 #endif
 
+#if IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI)
+int imx_pinctrl_scmi_conf_pins(struct udevice *dev, u32 *pin_data, int npins);
+#else
+static inline int imx_pinctrl_scmi_conf_pins(struct udevice *dev, u32 
*pin_data, int npins)
+{
+   return 0;
+}
+#endif
+
 #endif /* __DRIVERS_PINCTRL_IMX_H */
diff --git a/drivers/pinctrl/nxp/pinctrl-scmi.c 
b/drivers/pinctrl/nxp/pinctrl-scmi.c
new file mode 100644
index 
..7d2ed6542dc5166ebb07ade6e931b83b370af386
--- /dev/null
+++ b/drivers/pinctrl/nxp/pinctrl-scmi.c
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pinctrl-imx.h"
+
+#if IS_ENABLED(CONFIG_IMX93)
+#define DAISY_OFFSET   0x360
+#endif
+#if I

[PATCH v4 05/20] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data

2025-01-15 Thread Alice Guo
From: Peng Fan 

SCMI misc protocol is intended for miscellaneous functions which are
device specific and are usually defined to access bit fields. This patch
adds SCMI misc protocol protocol_id and message_id for getting the ROM
passover data.

Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 include/scmi_protocols.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
index 
2367467512a6b65253317e51bea71de396aa96f9..6cda1f00df1f6baf6db65a28b4cab114f8540a4b
 100644
--- a/include/scmi_protocols.h
+++ b/include/scmi_protocols.h
@@ -25,6 +25,7 @@ enum scmi_std_protocol {
SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
SCMI_PROTOCOL_ID_PINCTRL = 0x19,
+   SCMI_PROTOCOL_ID_IMX_MISC = 0x84,
 };
 
 enum scmi_status_code {
@@ -50,6 +51,10 @@ enum scmi_discovery_id {
SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
 };
 
+enum scmi_imx_misc_message_id {
+   SCMI_MISC_ROM_PASSOVER_GET = 0x7
+};
+
 /*
  * SCMI Base Protocol
  */

-- 
2.34.1



[PATCH v4 06/20] scmi_protocols: add SCMI Performance domain management protocol message IDs

2025-01-15 Thread Alice Guo
From: Peng Fan 

SCMI Performance domain management protocol is intended for performance
management of groups of devices or APs that run in the same performance
domain. The functionality provided by the callee-side can be used by
passing the corresponding message_id.

Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 include/scmi_protocols.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
index 
6cda1f00df1f6baf6db65a28b4cab114f8540a4b..08c86a642844570424dddbfcf9670d1e6757d8d1
 100644
--- a/include/scmi_protocols.h
+++ b/include/scmi_protocols.h
@@ -1044,4 +1044,22 @@ struct scmi_pinctrl_config_set_out {
s32 status;
 };
 
+/* SCMI Perf Protocol */
+enum scmi_perf_message_id {
+   SCMI_PERF_DOMAIN_ATTRIBUTES = 0x3,
+   SCMI_PERF_DESCRIBE_LEVELS = 0x4,
+   SCMI_PERF_LIMITS_SET = 0x5,
+   SCMI_PERF_LIMITS_GET = 0x6,
+   SCMI_PERF_LEVEL_SET = 0x7,
+   SCMI_PERF_LEVEL_GET = 0x8
+};
+
+struct scmi_perf_in {
+   u32 domain_id;
+   u32 perf_level;
+};
+
+struct scmi_perf_out {
+   s32 status;
+};
 #endif /* _SCMI_PROTOCOLS_H */

-- 
2.34.1



[PATCH v4 01/20] mailbox: add i.MX95 Messaging Unit (MU) driver

2025-01-15 Thread Alice Guo
From: Peng Fan 

i.MX95 Messaging Unit (MU) enables 2 processors on a chip to communicate
and coordinate by passing messages (e.g. frame information, event
notices and requests) through the MU interface. This patch provides a
driver for i.MX95 MU using the common mailbox framework. Currently, SCMI
exchanges on i.MX95 uses a mailbox transport with SMT format, and the
hardware used is this MU.

This id ported from Linux (v6.12.8) driver
drivers/mailbox/imx-mailbox.c.

Signed-off-by: Viorel Suman 
Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 MAINTAINERS   |   1 +
 drivers/mailbox/Kconfig   |   7 +
 drivers/mailbox/Makefile  |   1 +
 drivers/mailbox/imx-mailbox.c | 417 ++
 4 files changed, 426 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 
ba31f86feb6da266cddd160a041d0594ac86d274..5ab2b72d0f93afaf70c4c2dcb8fc48210683b749
 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -313,6 +313,7 @@ F:  board/freescale/*mx*/
 F: board/freescale/common/
 F: common/spl/spl_imx_container.c
 F: doc/imx/
+F: drivers/mailbox/imx-mailbox.c
 F: drivers/serial/serial_mxc.c
 F: include/imx_container.h
 
diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
index 
67d5ac1a74228ccd82b2725c0bb745354d099948..4d9f004ebad7f57034a6cdae3bff9645fa0ee67d
 100644
--- a/drivers/mailbox/Kconfig
+++ b/drivers/mailbox/Kconfig
@@ -21,6 +21,13 @@ config APPLE_MBOX
  such as the System Management Controller (SMC) and NVMe and this
  driver is required to get that functionality up and running.
 
+config IMX_MU_MBOX
+   bool "Enable i.MX MU MBOX support"
+   depends on DM_MAILBOX
+   help
+ Enable support for i.MX Messaging Unit for communication with other
+ processors on the SoC using mailbox interface
+
 config SANDBOX_MBOX
bool "Enable the sandbox mailbox test driver"
depends on DM_MAILBOX && SANDBOX
diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile
index 
6072fa1956b793636c35aa0d1419c9dcaae27095..574add60005fe73d2beba715a12e0157fe4b0552
 100644
--- a/drivers/mailbox/Makefile
+++ b/drivers/mailbox/Makefile
@@ -5,6 +5,7 @@
 
 obj-$(CONFIG_$(XPL_)DM_MAILBOX) += mailbox-uclass.o
 obj-$(CONFIG_APPLE_MBOX) += apple-mbox.o
+obj-$(CONFIG_IMX_MU_MBOX) += imx-mailbox.o
 obj-$(CONFIG_SANDBOX_MBOX) += sandbox-mbox.o
 obj-$(CONFIG_SANDBOX_MBOX) += sandbox-mbox-test.o
 obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o
diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
new file mode 100644
index 
..931844135325c5758e0adcd55d19f5837aa49609
--- /dev/null
+++ b/drivers/mailbox/imx-mailbox.c
@@ -0,0 +1,417 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* This driver only exposes the status bits to keep with the
+ * polling methodology of u-boot.
+ */
+DECLARE_GLOBAL_DATA_PTR;
+
+#define IMX_MU_CHANS   24
+
+#define IMX_MU_V2_PAR_OFF  0x4
+#define IMX_MU_V2_TR_MASK  GENMASK(7, 0)
+#define IMX_MU_V2_RR_MASK  GENMASK(15, 8)
+
+enum imx_mu_chan_type {
+   IMX_MU_TYPE_TX  = 0, /* Tx */
+   IMX_MU_TYPE_RX  = 1, /* Rx */
+   IMX_MU_TYPE_TXDB= 2, /* Tx doorbell */
+   IMX_MU_TYPE_RXDB= 3, /* Rx doorbell */
+   IMX_MU_TYPE_RST = 4, /* Reset */
+   IMX_MU_TYPE_TXDB_V2 = 5, /* Tx doorbell with S/W ACK */
+};
+
+enum imx_mu_xcr {
+   IMX_MU_CR,
+   IMX_MU_GIER,
+   IMX_MU_GCR,
+   IMX_MU_TCR,
+   IMX_MU_RCR,
+   IMX_MU_xCR_MAX,
+};
+
+enum imx_mu_xsr {
+   IMX_MU_SR,
+   IMX_MU_GSR,
+   IMX_MU_TSR,
+   IMX_MU_RSR,
+   IMX_MU_xSR_MAX,
+};
+
+struct imx_mu_con_priv {
+   unsigned intidx;
+   enum imx_mu_chan_type   type;
+   struct mbox_chan*chan;
+};
+
+enum imx_mu_type {
+   IMX_MU_V1,
+   IMX_MU_V2 = BIT(1),
+   IMX_MU_V2_S4 = BIT(15),
+   IMX_MU_V2_IRQ = BIT(16),
+};
+
+struct imx_mu {
+   void __iomem *base;
+   const struct imx_mu_dcfg *dcfg;
+   u32 num_tr;
+   u32 num_rr;
+   /* use pointers to channel as a way to reserve channels */
+   struct mbox_chan *channels[IMX_MU_CHANS];
+   struct imx_mu_con_priv  con_priv[IMX_MU_CHANS];
+};
+
+struct imx_mu_dcfg {
+   int (*tx)(struct imx_mu *plat, struct imx_mu_con_priv *cp, const void 
*data);
+   int (*rx)(struct imx_mu *plat, struct imx_mu_con_priv *cp);
+   int (*rxdb)(struct imx_mu *plat, struct imx_mu_con_priv *cp);
+   int (*init)(struct imx_mu *plat);
+   int (*of_xlate)(struct mbox_chan *chan, struct ofnode_phandle_args 
*args);
+   enum imx_mu_type type;
+   u32 xTR;/* Transmit Register0 */
+   u32 xRR;/* Receive Register0 */
+   u32 xSR[IMX_MU_x

[PATCH v4 00/20] imx: add i.MX95 support

2025-01-15 Thread Alice Guo
Changes in v4:
- split the SCMI pin controller driver and SCMI agent code
- update i.MX95 SoC and clock related code, board basic support code 
  and so on according to comments
- move the function that loads ATF and tee.bin to spl_imx_container.c
- add document for i.MX95 image container format

Signed-off-by: Alice Guo 
---
Alice Guo (8):
  pinctrl: nxp: add a pin controller driver based on SCMI pin control 
protocol
  firmware: scmi: add pin control protocol support to SCMI agent
  clk: scmi: check the clock state/parent/rate control permissions
  sandbox: add SCMI clock control permissions to sandbox
  imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95
  binman: add a new entry type for packing DDR PHY firmware images
  tools: imx8image: add i.MX95 support
  doc: imx: add document for i.MX95 Image Container Format

Peng Fan (6):
  mailbox: add i.MX95 Messaging Unit (MU) driver
  scmi_protocols: add SCMI misc protocol protocol_id and message_id for 
getting the ROM passover data
  scmi_protocols: add SCMI Performance domain management protocol message 
IDs
  clk: scmi: add the command CLOCK_PARENT_SET
  scmi: add the macro SCMI_MSG
  imx9: scmi: add i.MX95 SoC and clock related code

Teo Hall (1):
  imx: add V2X container support on i.MX95

Viorel Suman (1):
  firmware: scmi: smt: Interrupt communication enable

Ye Li (4):
  scmi_protocols: update struct scmi_base_discover_list_protocols_out
  spl: imx: use trampoline buffer to load images to secure region
  imx9: add i.MX95 Kconfig and Makefile
  imx95_evk: add i.MX95 19x19 EVK board basic support

 MAINTAINERS   |   1 +
 arch/arm/dts/imx95-19x19-evk-u-boot.dtsi  |  68 +++
 arch/arm/dts/imx95-u-boot.dtsi| 157 +
 arch/arm/include/asm/arch-imx/cpu.h   |   2 +
 arch/arm/include/asm/arch-imx9/clock.h|  10 +
 arch/arm/include/asm/arch-imx9/imx-regs.h |   5 +
 arch/arm/include/asm/arch-imx9/sys_proto.h|   1 +
 arch/arm/include/asm/mach-imx/sys_proto.h |  39 ++
 arch/arm/mach-imx/Kconfig |   2 +-
 arch/arm/mach-imx/image-container.c   |  63 +-
 arch/arm/mach-imx/imx9/Kconfig|  14 +
 arch/arm/mach-imx/imx9/Makefile   |   9 +-
 arch/arm/mach-imx/imx9/scmi/Makefile  |   6 +
 arch/arm/mach-imx/imx9/scmi/clock.c   | 105 
 arch/arm/mach-imx/imx9/scmi/clock_scmi.c  | 135 +
 arch/arm/mach-imx/imx9/scmi/container.cfg |  10 +
 arch/arm/mach-imx/imx9/scmi/imximage.cfg  |  15 +
 arch/arm/mach-imx/imx9/scmi/soc.c | 827 ++
 arch/sandbox/include/asm/scmi_test.h  |   4 +-
 board/freescale/imx95_evk/Kconfig |  12 +
 board/freescale/imx95_evk/MAINTAINERS |   6 +
 board/freescale/imx95_evk/Makefile|  11 +
 board/freescale/imx95_evk/imx95_19x19_evk.env |  90 +++
 board/freescale/imx95_evk/imx95_evk.c |  54 ++
 board/freescale/imx95_evk/spl.c   |  72 +++
 common/spl/Kconfig|   6 +
 common/spl/spl_imx_container.c|  41 +-
 configs/imx95_19x19_evk_defconfig | 177 ++
 doc/board/nxp/imx95_evk.rst   | 114 
 doc/board/nxp/index.rst   |   1 +
 doc/imx/imx95_container.txt   | 136 +
 drivers/clk/clk_scmi.c| 191 +-
 drivers/firmware/scmi/Kconfig |   6 +
 drivers/firmware/scmi/sandbox-scmi_agent.c|  56 +-
 drivers/firmware/scmi/scmi_agent-uclass.c |  11 +
 drivers/firmware/scmi/smt.c   |   3 +
 drivers/firmware/scmi/smt.h   |  10 +
 drivers/mailbox/Kconfig   |   7 +
 drivers/mailbox/Makefile  |   1 +
 drivers/mailbox/imx-mailbox.c | 417 +
 drivers/pinctrl/nxp/Kconfig   |  13 +
 drivers/pinctrl/nxp/Makefile  |   1 +
 drivers/pinctrl/nxp/pinctrl-imx.c |   7 +-
 drivers/pinctrl/nxp/pinctrl-imx.h |  11 +
 drivers/pinctrl/nxp/pinctrl-scmi.c| 136 +
 include/configs/imx95_evk.h   |  27 +
 include/imx8image.h   |  19 +-
 include/scmi_agent-uclass.h   |   2 +
 include/scmi_agent.h  |  11 +
 include/scmi_protocols.h  | 105 +++-
 tools/binman/entries.rst  |  10 +
 tools/binman/etype/nxp_header_ddrfw.py|  32 +
 tools/binman/ftest.py |  11 +
 tools/binman/test/346_nxp_ddrfw_imx95.dts |  24 +
 tools/imx8image.c | 143 -
 tools/imx9_image.sh   |   8 +
 56 files changed, 3390 insertions(+), 65 deletions(-)
---
base-commit: d6da3dbaef57fc1d319b6b552efa009e2489d7d9
change-id: 20250114-imx95-ac8bbccd71e5

Best regard

[PATCH v4 04/20] firmware: scmi: add pin control protocol support to SCMI agent

2025-01-15 Thread Alice Guo
From: Alice Guo 

This patch adds SCMI pin control protocol support so that the pin
controller driver based on SCMI, such as
drivers/pinctrl/nxp/pinctrl-scmi.c, can be bound to the SCMI agent
device whose protocol id is 0x19.

Signed-off-by: Alice Guo 
---
 drivers/firmware/scmi/scmi_agent-uclass.c | 11 +++
 include/scmi_agent-uclass.h   |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c 
b/drivers/firmware/scmi/scmi_agent-uclass.c
index 
8c907c3b0328095c4b35ba089ed608fcda48b567..5f101f4ede8b585f8c562a42886ea7be4ef09953
 100644
--- a/drivers/firmware/scmi/scmi_agent-uclass.c
+++ b/drivers/firmware/scmi/scmi_agent-uclass.c
@@ -97,6 +97,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev,
case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
proto = priv->voltagedom_dev;
break;
+   case SCMI_PROTOCOL_ID_PINCTRL:
+   proto = priv->pinctrl_dev;
+   break;
default:
dev_err(dev, "Protocol not supported\n");
proto = NULL;
@@ -147,6 +150,9 @@ static int scmi_add_protocol(struct udevice *dev,
case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN:
priv->voltagedom_dev = proto;
break;
+   case SCMI_PROTOCOL_ID_PINCTRL:
+   priv->pinctrl_dev = proto;
+   break;
default:
dev_err(dev, "Protocol not supported\n");
return -EPROTO;
@@ -436,6 +442,11 @@ static int scmi_bind_protocols(struct udevice *dev)
drv = DM_DRIVER_GET(scmi_voltage_domain);
}
break;
+   case SCMI_PROTOCOL_ID_PINCTRL:
+   if (IS_ENABLED(CONFIG_PINCTRL_IMX_SCMI) &&
+   scmi_protocol_is_supported(dev, protocol_id))
+   drv = DM_DRIVER_GET(scmi_pinctrl_imx);
+   break;
default:
break;
}
diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h
index 
33e0e18c30d4ae4ddaaa2cb3830c03cd7a559cc0..4beec43cb080b14a777cac1cb0f18ef53433596c
 100644
--- a/include/scmi_agent-uclass.h
+++ b/include/scmi_agent-uclass.h
@@ -27,6 +27,7 @@ struct scmi_channel;
  * @clock_dev: SCMI clock protocol device
  * @resetdom_dev:  SCMI reset domain protocol device
  * @voltagedom_dev:SCMI voltage domain protocol device
+ * @pinctrl_dev:   SCMI pin control protocol device
  */
 struct scmi_agent_priv {
u32 version;
@@ -43,6 +44,7 @@ struct scmi_agent_priv {
struct udevice *clock_dev;
struct udevice *resetdom_dev;
struct udevice *voltagedom_dev;
+   struct udevice *pinctrl_dev;
 };
 
 static inline u32 scmi_version(struct udevice *dev)

-- 
2.34.1



[PATCH v4 02/20] firmware: scmi: smt: Interrupt communication enable

2025-01-15 Thread Alice Guo
From: Viorel Suman 

i.MX95 System Manager uses interrupt driven communication which requires
the caller to set Bit[0] of channel flags to 1. When transmission
completes and the previous general purpose interrupt has been processed
by the other core, i.MX95 System Manager will set General Purpose
Interrupt Control Register (GCR). U-Boot polls General-purpose Status
(GSR) to check if the operation is finished.

Signed-off-by: Viorel Suman 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 drivers/firmware/scmi/Kconfig |  6 ++
 drivers/firmware/scmi/smt.c   |  3 +++
 drivers/firmware/scmi/smt.h   | 10 ++
 3 files changed, 19 insertions(+)

diff --git a/drivers/firmware/scmi/Kconfig b/drivers/firmware/scmi/Kconfig
index 
8cf85f0d7a12c9e58dc249539727081ec25dd7b3..eb62b88615b5cd95635571556e79ba40d1a387e9
 100644
--- a/drivers/firmware/scmi/Kconfig
+++ b/drivers/firmware/scmi/Kconfig
@@ -41,3 +41,9 @@ config SCMI_AGENT_OPTEE
help
  Enable the SCMI communication channel based on OP-TEE transport
  for compatible "linaro,scmi-optee".
+
+config SCMI_TRANSPORT_SMT_INTR
+   bool
+   depends on SCMI_FIRMWARE
+   help
+ Enable interrupt communication of shared memory based transport.
diff --git a/drivers/firmware/scmi/smt.c b/drivers/firmware/scmi/smt.c
index 
67d2f45002490ab64a6bc997eda93a8f4681d99b..ee7ae5d50b226b92a3961c181de83c730a621401
 100644
--- a/drivers/firmware/scmi/smt.c
+++ b/drivers/firmware/scmi/smt.c
@@ -48,6 +48,9 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct 
scmi_smt *smt)
if (!smt->buf)
return -ENOMEM;
 
+   if (IS_ENABLED(CONFIG_SCMI_TRANSPORT_SMT_INTR))
+   scmi_smt_enable_intr(smt, true);
+
 #ifdef CONFIG_ARM
if (dcache_status())
mmu_set_region_dcache_behaviour(ALIGN_DOWN((uintptr_t)smt->buf, 
MMU_SECTION_SIZE),
diff --git a/drivers/firmware/scmi/smt.h b/drivers/firmware/scmi/smt.h
index 
9d669a6c922666c48e7dce4c0affd7b47cb137e4..768b0f4c8a8d1cc7966530e724d278d72c2a167b
 100644
--- a/drivers/firmware/scmi/smt.h
+++ b/drivers/firmware/scmi/smt.h
@@ -84,6 +84,16 @@ static inline void scmi_smt_put_channel(struct scmi_smt *smt)
hdr->channel_status &= ~SCMI_SHMEM_CHAN_STAT_CHANNEL_ERROR;
 }
 
+static inline void scmi_smt_enable_intr(struct scmi_smt *smt, bool enable)
+{
+   struct scmi_smt_header *hdr = (void *)smt->buf;
+
+   if (enable)
+   hdr->flags |= SCMI_SHMEM_FLAG_INTR_ENABLED;
+   else
+   hdr->flags &= ~SCMI_SHMEM_FLAG_INTR_ENABLED;
+}
+
 int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt);
 
 /*

-- 
2.34.1



[PATCH v4 17/20] tools: imx8image: add i.MX95 support

2025-01-15 Thread Alice Guo
From: Alice Guo 

i.MX95 uses binman to invoke mkimage to create image container. 2 image
containers are needed currently. The first one is composed of
ahab-container.img, LPDDR firmware images, OEI images, System Manager
image and u-boot-spl.bin. The second one is comsisted of ARM Trusted
firmware and u-boot.bin.

Because DDR OEI image and LPDDR firmware images have to be packaged
together and named as m33-oei-ddrfw.bin by binman, so imx9_image.sh does
not check if m33-oei-ddrfw.bin exists.

When using "make imx95_19x19_evk_defconfig; make", imx9_image.sh will
delete the line for u-boot.bin in container.cfg. In fact, binman is
always called after the u-boot.bin is built, so imx9_image.sh does not
check if u-boot.bin exists.

Signed-off-by: Alice Guo 
---
 include/imx8image.h |  19 +--
 tools/imx8image.c   | 143 +++-
 tools/imx9_image.sh |   8 +++
 3 files changed, 153 insertions(+), 17 deletions(-)

diff --git a/include/imx8image.h b/include/imx8image.h
index 
6b95e93fb50980f9e86099b3103142dcbe38764a..b48e2b039698a225e152bddfe4b29be2fcbdc730
 100644
--- a/include/imx8image.h
+++ b/include/imx8image.h
@@ -157,7 +157,9 @@ enum imx8image_cmd {
CMD_SOC_TYPE,
CMD_CONTAINER,
CMD_IMAGE,
-   CMD_DATA
+   CMD_DATA,
+   CMD_DUMMY_V2X,
+   CMD_HOLD
 };
 
 enum imx8image_core_type {
@@ -169,7 +171,9 @@ enum imx8image_core_type {
CFG_A35,
CFG_A55,
CFG_A53,
-   CFG_A72
+   CFG_A72,
+   CFG_M33,
+   CFG_OEI
 };
 
 enum imx8image_fld_types {
@@ -208,7 +212,10 @@ typedef enum option_type {
FILEOFF,
MSG_BLOCK,
SENTINEL,
-   UPOWER
+   UPOWER,
+   OEI,
+   DUMMY_V2X,
+   HOLD
 } option_type_t;
 
 typedef struct {
@@ -227,12 +234,16 @@ typedef struct {
 #define CORE_CA35   4
 #define CORE_CA72   5
 #define CORE_SECO   6
+#define CORE_M337
 
 #define CORE_ULP_CM33  0x1
 #define CORE_ULP_CA35  0x2
 #define CORE_ULP_UPOWER0x4
 #define CORE_ULP_SENTINEL  0x6
 
+#define CORE_IMX95_M33P0
+#define CORE_IMX95_A55C0   2
+
 #define SC_R_OTP   357U
 #define SC_R_DEBUG 354U
 #define SC_R_ROM_0 236U
@@ -246,10 +257,12 @@ typedef struct {
 #define IMG_TYPE_EXEC0x03   /* Executable image type */
 #define IMG_TYPE_DATA0x04   /* Data image type */
 #define IMG_TYPE_DCD_DDR 0x05   /* DCD/DDR image type */
+#define IMG_TYPE_OEI 0x05   /* Optional Executable image type */
 #define IMG_TYPE_SECO0x06   /* SECO image type */
 #define IMG_TYPE_SENTINEL 0x06 /* SENTINEL image type */
 #define IMG_TYPE_PROV0x07   /* Provisioning image type */
 #define IMG_TYPE_DEK 0x08   /* DEK validation type */
+#define IMG_TYPE_V2X_DUMMY 0x0E /* V2X Dummy image */
 
 #define IMG_TYPE_SHIFT   0
 #define IMG_TYPE_MASK0x1f
diff --git a/tools/imx8image.c b/tools/imx8image.c
index 
15510d3e712495c3508e130fcb2b4df42b07136b..9c4b43174558ec669f9a196c08756bcc6522b752
 100644
--- a/tools/imx8image.c
+++ b/tools/imx8image.c
@@ -7,6 +7,7 @@
 
 #include "imx8image.h"
 #include 
+#include 
 
 static int p_idx;
 static int sector_size;
@@ -54,6 +55,8 @@ static table_entry_t imx8image_cmds[] = {
{CMD_CONTAINER, "CONTAINER","new container",  },
{CMD_IMAGE, "IMAGE","new image",  },
{CMD_DATA,  "DATA", "new data",   },
+   {CMD_DUMMY_V2X, "DUMMY_V2X","v2x",},
+   {CMD_HOLD,  "HOLD", "hold",   },
{-1,"", "",   },
 };
 
@@ -66,6 +69,8 @@ static table_entry_t imx8image_core_entries[] = {
{CFG_A55,   "A55",  "A55 core", },
{CFG_A53,   "A53",  "A53 core", },
{CFG_A72,   "A72",  "A72 core", },
+   {CFG_OEI,   "OEI",  "OEI", },
+   {CFG_M33,   "M33",  "M33 core", },
{-1,"", "", },
 };
 
@@ -144,6 +149,14 @@ static void parse_cfg_cmd(image_t *param_stack, int32_t 
cmd, char *token,
exit(EXIT_FAILURE);
}
break;
+   case CMD_DUMMY_V2X:
+   param_stack[p_idx].option = DUMMY_V2X;
+   param_stack[p_idx++].entry = (uint32_t)strtoll(token, NULL, 0);
+   break;
+   case CMD_HOLD:
+   param_stack[p_idx].option = HOLD;
+   param_stack[p_idx].entry = (uint32_t)strtoll(token, NULL, 0);
+   param_stack[p_idx++].filename = NULL;
default:
break;
}
@@ -221,6 +234,16 @@ static void parse_cfg_fld(image_t *param_stack, int32_t 
*cmd, char *token,
(*cmd == CMD_DATA) ? DATA : AP;
 

[PATCH v4 12/20] imx9: scmi: add i.MX95 SoC and clock related code

2025-01-15 Thread Alice Guo
From: Peng Fan 

This patch adds i.MX95 SoC and clock related code. Because they are
based on SCMI, put them in the scmi subfolder.

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Peng Fan 
---
 arch/arm/include/asm/arch-imx/cpu.h|   2 +
 arch/arm/include/asm/arch-imx9/clock.h |  10 +
 arch/arm/include/asm/arch-imx9/imx-regs.h  |   5 +
 arch/arm/include/asm/arch-imx9/sys_proto.h |   1 +
 arch/arm/include/asm/mach-imx/sys_proto.h  |  39 ++
 arch/arm/mach-imx/imx9/scmi/Makefile   |   6 +
 arch/arm/mach-imx/imx9/scmi/clock.c| 105 
 arch/arm/mach-imx/imx9/scmi/clock_scmi.c   | 135 +
 arch/arm/mach-imx/imx9/scmi/soc.c  | 809 +
 arch/sandbox/include/asm/scmi_test.h   |   2 +-
 10 files changed, 1113 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-imx/cpu.h 
b/arch/arm/include/asm/arch-imx/cpu.h
index 
0d7a573461690046b27498c7174459110a73689c..1f669c72d00833f07ca7a2563ae24536af9dc418
 100644
--- a/arch/arm/include/asm/arch-imx/cpu.h
+++ b/arch/arm/include/asm/arch-imx/cpu.h
@@ -76,6 +76,8 @@
 #define MXC_CPU_IMX91110xCD /* dummy ID */
 #define MXC_CPU_IMX91010xCE /* dummy ID */
 
+#define MXC_CPU_IMX95  0x1C1 /* dummy ID */
+
 #define MXC_SOC_MX60x60
 #define MXC_SOC_MX70x70
 #define MXC_SOC_IMX8M  0x80
diff --git a/arch/arm/include/asm/arch-imx9/clock.h 
b/arch/arm/include/asm/arch-imx9/clock.h
index 
60d48b13b11f274c9e4c8caf20954de0431d9d6a..ffaf6b5f7d81d73af1702dff64cf9b15ea521ad9
 100644
--- a/arch/arm/include/asm/arch-imx9/clock.h
+++ b/arch/arm/include/asm/arch-imx9/clock.h
@@ -255,5 +255,15 @@ int ccm_shared_gpr_tz_access(u32 gpr, bool non_secure, 
bool user_mode, bool lock
 void enable_usboh3_clk(unsigned char enable);
 int set_clk_enet(enum enet_freq type);
 int set_clk_eqos(enum enet_freq type);
+
+int imx_clk_scmi_enable(u32 clock_id, bool enable);
+ulong imx_clk_scmi_set_rate(u32 clock_id, ulong rate);
+ulong imx_clk_scmi_get_rate(u32 clock_id);
+int imx_clk_scmi_set_parent(u32 clock_id, u32 parent_id);
 void set_arm_clk(ulong freq);
+
+int imx_clk_scmi_enable(u32 clock_id, bool enable);
+ulong imx_clk_scmi_set_rate(u32 clock_id, ulong rate);
+ulong imx_clk_scmi_get_rate(u32 clock_id);
+int imx_clk_scmi_set_parent(u32 clock_id, u32 parent_id);
 #endif
diff --git a/arch/arm/include/asm/arch-imx9/imx-regs.h 
b/arch/arm/include/asm/arch-imx9/imx-regs.h
index 
ef9538bd42e8b2972d7e6829a402bc4f661e3cbb..f7f9c706e13e63df7ff0a90b3964e04bc15959bf
 100644
--- a/arch/arm/include/asm/arch-imx9/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx9/imx-regs.h
@@ -20,6 +20,11 @@
 #define WDG4_BASE_ADDR  0x424aUL
 #define WDG5_BASE_ADDR  0x424bUL
 
+#define GPIO2_BASE_ADDR0x4381UL
+#define GPIO3_BASE_ADDR0x4382UL
+#define GPIO4_BASE_ADDR0x4384UL
+#define GPIO5_BASE_ADDR0x4385UL
+
 #define FSB_BASE_ADDR   0x4751UL
 
 #define ANATOP_BASE_ADDR0x4448UL
diff --git a/arch/arm/include/asm/arch-imx9/sys_proto.h 
b/arch/arm/include/asm/arch-imx9/sys_proto.h
index 
e4bf6a63424f7c54c1dcdf6b882a908940e5fdb1..df2148a53c7e43fcacad0798090df23e24347dbe
 100644
--- a/arch/arm/include/asm/arch-imx9/sys_proto.h
+++ b/arch/arm/include/asm/arch-imx9/sys_proto.h
@@ -12,6 +12,7 @@ enum imx9_soc_voltage_mode {
VOLT_LOW_DRIVE = 0,
VOLT_NOMINAL_DRIVE,
VOLT_OVER_DRIVE,
+   VOLT_SUPER_OVER_DRIVE,
 };
 
 void soc_power_init(void);
diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h 
b/arch/arm/include/asm/mach-imx/sys_proto.h
index 
109a806852ab42d018ce45a4e96af5b57adb6a9c..0780f99b49a7768d77ed688157e3287195c857b1
 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -97,6 +97,8 @@ struct bd_info;
 #define is_imx9302() (is_cpu_type(MXC_CPU_IMX9302))
 #define is_imx9301() (is_cpu_type(MXC_CPU_IMX9301))
 
+#define is_imx95() (is_cpu_type(MXC_CPU_IMX95))
+
 #define is_imx9121() (is_cpu_type(MXC_CPU_IMX9121))
 #define is_imx9111() (is_cpu_type(MXC_CPU_IMX9111))
 #define is_imx9101() (is_cpu_type(MXC_CPU_IMX9101))
@@ -216,6 +218,43 @@ ulong spl_romapi_get_uboot_base(u32 image_offset, u32 
rom_bt_dev);
 u32 rom_api_download_image(u8 *dest, u32 offset, u32 size);
 u32 rom_api_query_boot_infor(u32 info_type, u32 *info);
 
+#if IS_ENABLED(CONFIG_SCMI_FIRMWARE)
+typedef struct rom_passover {
+   u16 tag;   // Tag
+   u8  len;   // Fixed value of 0x80
+   u8  ver;   // Version
+   u32 boot_mode; // Boot mode
+   u32 card_addr_mode;// SD card address mode
+   u32 bad_blks_of_img_set0;  // NAND bad block count skipped 1
+   u32 ap_mu_id;  // AP MU ID
+   u32 bad_blks_of_img_set1;  // NAND bad block count skipped 1
+   u8  boot_stage;// Boot stage
+   u8  img

[PATCH v4 14/20] imx9: add i.MX95 Kconfig and Makefile

2025-01-15 Thread Alice Guo
From: Ye Li 

This patch adds i.MX95 Kconfig and Makefile. i.MX95 uses SCMI.

Signed-off-by: Ye Li 
Signed-off-by: Alice Guo 
Reviewed-by: Peng Fan 
---
 arch/arm/mach-imx/imx9/Kconfig  | 8 
 arch/arm/mach-imx/imx9/Makefile | 9 +++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx9/Kconfig b/arch/arm/mach-imx/imx9/Kconfig
index 
54c6b117fcff21be5c3800ebd1dc30f8ea12ac42..660529555e9b3d38a6fb70c77858bd9de7473461
 100644
--- a/arch/arm/mach-imx/imx9/Kconfig
+++ b/arch/arm/mach-imx/imx9/Kconfig
@@ -21,6 +21,14 @@ config IMX91
select IMX9
select ARMV8_SPL_EXCEPTION_VECTORS
 
+config IMX95
+   bool
+   select IMX9
+   select ARMV8_SPL_EXCEPTION_VECTORS
+   select SCMI_FIRMWARE
+   select DM_MAILBOX
+   select SCMI_TRANSPORT_SMT_INTR
+   select SPL_IMX_CONTAINER_USE_TRAMPOLINE
 
 config SYS_SOC
default "imx9"
diff --git a/arch/arm/mach-imx/imx9/Makefile b/arch/arm/mach-imx/imx9/Makefile
index 
45a9105a75a558dada3c328ed0878050da2a41e1..53cc97c6b471f1bdc3f55b198788ca42e4ad9558
 100644
--- a/arch/arm/mach-imx/imx9/Makefile
+++ b/arch/arm/mach-imx/imx9/Makefile
@@ -3,8 +3,13 @@
 # Copyright 2022 NXP
 
 obj-y += lowlevel_init.o
+
+ifeq ($(CONFIG_SCMI_FIRMWARE),y)
+obj-y += scmi/
+else
 obj-y += soc.o clock.o clock_root.o trdc.o
+endif
 
-#ifndef CONFIG_XPL_BUILD
+ifneq ($(CONFIG_SPL_BUILD),y)
 obj-y += imx_bootaux.o
-#endif
+endif
\ No newline at end of file

-- 
2.34.1



[PATCH v4 16/20] binman: add a new entry type for packing DDR PHY firmware images

2025-01-15 Thread Alice Guo
From: Alice Guo 

i.MX95 needs to combine DDR PHY firmware images and their byte counts
together, so add a new entry type nxp-header-ddrfw for this requirement.

Signed-off-by: Alice Guo 
---
 tools/binman/entries.rst  | 10 ++
 tools/binman/etype/nxp_header_ddrfw.py| 32 +++
 tools/binman/ftest.py | 11 +++
 tools/binman/test/346_nxp_ddrfw_imx95.dts | 24 +++
 4 files changed, 77 insertions(+)

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 
780e9817fb6496b5f2a4aef6ed1c0b4c8d9a4ba2..6da3f0b904643360ca11da32e31129f5f54d279c
 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -1663,6 +1663,16 @@ Properties / Entry arguments:
 
 
 
+.. _etype_nxp_header_ddrfw:
+
+Entry: nxp-header-ddrfw: add a header to DDR PHY firmware images
+---
+
+This entry is used to combine DDR PHY firmware images and their byte counts
+together. See imx95_evk.rst for how to get DDR PHY Firmware Images.
+
+
+
 .. _etype_opensbi:
 
 Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
diff --git a/tools/binman/etype/nxp_header_ddrfw.py 
b/tools/binman/etype/nxp_header_ddrfw.py
new file mode 100644
index 
..80e0611df609107d6e092a5a6d8aec05b80a6347
--- /dev/null
+++ b/tools/binman/etype/nxp_header_ddrfw.py
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2025 NXP
+
+from binman.etype.section import Entry_section
+
+class Entry_nxp_header_ddrfw(Entry_section):
+"""Add a header to DDR PHY firmware images
+
+This entry is used for i.MX95 to combine DDR PHY firmware images and their
+byte counts together.
+
+See imx95_evk.rst for how to get DDR PHY Firmware Images.
+"""
+
+def __init__(self, section, etype, node):
+super().__init__(section, etype, node)
+
+def BuildSectionData(self, required):
+section_data = bytearray()
+header_data = bytearray()
+
+for entry in self._entries.values():
+entry_data = entry.GetData(required)
+
+if not required and entry_data is None:
+return None
+
+section_data += entry_data
+header_data += entry.contents_size.to_bytes(4, 'little')
+
+return header_data + section_data
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 
a553ca9e5642b685b908e817972b42bfba1d8a0a..62acc1d885cf6565999672d25584602929c3c4c3
 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -104,6 +104,8 @@ PRE_LOAD_VERSION  = 0x11223344.to_bytes(4, 'big')
 PRE_LOAD_HDR_SIZE = 0x1000.to_bytes(4, 'big')
 TI_BOARD_CONFIG_DATA  = 
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 TI_UNSECURE_DATA  = b'unsecuredata'
+IMX_LPDDR_IMEM_DATA   = b'qwertyuiop1234567890'
+IMX_LPDDR_DMEM_DATA   = b'asdfghjklzxcvbnm'
 
 # Subdirectory of the input dir to use to put test FDTs
 TEST_FDT_SUBDIR   = 'fdts'
@@ -202,6 +204,8 @@ class TestFunctional(unittest.TestCase):
 TestFunctional._MakeInputFile('fsp_m.bin', FSP_M_DATA)
 TestFunctional._MakeInputFile('fsp_s.bin', FSP_S_DATA)
 TestFunctional._MakeInputFile('fsp_t.bin', FSP_T_DATA)
+TestFunctional._MakeInputFile('lpddr5_imem.bin', IMX_LPDDR_IMEM_DATA)
+TestFunctional._MakeInputFile('lpddr5_dmem.bin', IMX_LPDDR_DMEM_DATA)
 
 cls._elf_testdir = os.path.join(cls._indir, 'elftest')
 elf_test.BuildElfTestFiles(cls._elf_testdir)
@@ -7826,6 +7830,13 @@ fdt fdtmapExtract the devicetree 
blob from the fdtmap
 """Test that binman can produce an iMX8 image"""
 self._DoTestFile('339_nxp_imx8.dts')
 
+def testNxpHeaderDdrfw(self):
+"""Test that binman can add a header to DDR PHY firmware images"""
+data = self._DoReadFile('346_nxp_ddrfw_imx95.dts')
+self.assertEqual(len(IMX_LPDDR_IMEM_DATA).to_bytes(4, 'little') +
+ len(IMX_LPDDR_DMEM_DATA).to_bytes(4, 'little') +
+ IMX_LPDDR_IMEM_DATA + IMX_LPDDR_DMEM_DATA, data)
+
 def testFitSignSimple(self):
 """Test that image with FIT and signature nodes can be signed"""
 if not elf.ELF_TOOLS:
diff --git a/tools/binman/test/346_nxp_ddrfw_imx95.dts 
b/tools/binman/test/346_nxp_ddrfw_imx95.dts
new file mode 100644
index 
..889f6f29860746c09a91aaad7658976559760d9c
--- /dev/null
+++ b/tools/binman/test/346_nxp_ddrfw_imx95.dts
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   imx-lpddr {
+   type = "nxp-header-ddrfw";
+
+   imx-lpddr-imem {
+   filename = "lpddr5_imem.bin";
+   type = "blob-ext";
+   };
+

[PATCH v4 11/20] scmi: add the macro SCMI_MSG

2025-01-15 Thread Alice Guo
From: Peng Fan 

This patch adds the macro SCMI_MSG for protocols that do not need
_in_array.

Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 include/scmi_agent.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/scmi_agent.h b/include/scmi_agent.h
index 
755986d6c424ccc881ac0943a88735cbcfacb001..5508a126a6dc504afa6d896c78c760b1af0d3deb
 100644
--- a/include/scmi_agent.h
+++ b/include/scmi_agent.h
@@ -54,6 +54,17 @@ struct scmi_msg {
.out_msg_sz = sizeof(_out_array),   \
}
 
+/* Helper macro to match a message on output array references */
+#define SCMI_MSG(_protocol, _message, _out_array)  \
+   (struct scmi_msg){  \
+   .protocol_id = (_protocol), \
+   .message_id = (_message),   \
+   .in_msg = (uint8_t *)NULL,  \
+   .in_msg_sz = 0, \
+   .out_msg = (uint8_t *)&(_out_array),\
+   .out_msg_sz = sizeof(_out_array),   \
+   }
+
 /**
  * devm_scmi_of_get_channel() - Get SCMI channel handle from SCMI agent DT node
  *

-- 
2.34.1



[PATCH v4 13/20] spl: imx: use trampoline buffer to load images to secure region

2025-01-15 Thread Alice Guo
From: Ye Li 

When SPL loading image to secure region, for example, ATF and tee to
DDR secure region. Because the USDHC controller is non-secure master,
it can't access this region and will cause loading issue.

So use a trampoline buffer in non-secure region, then use CPU to copy the
image from trampoline buffer to destination secure region.

Signed-off-by: Ye Li 
Signed-off-by: Alice Guo 
Reviewed-by: Peng Fan 
---
 arch/arm/mach-imx/imx9/scmi/soc.c | 18 +
 common/spl/Kconfig|  6 ++
 common/spl/spl_imx_container.c| 41 +--
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c 
b/arch/arm/mach-imx/imx9/scmi/soc.c
index 
f1683b0484b84bf18b8612abc4daacf2f69d5e0b..f3840761e1bb1f5f6b4ebbced26d8a8f41eb4867
 100644
--- a/arch/arm/mach-imx/imx9/scmi/soc.c
+++ b/arch/arm/mach-imx/imx9/scmi/soc.c
@@ -807,3 +807,21 @@ enum boot_device get_boot_device(void)
return boot_dev;
 }
 #endif
+
+bool arch_check_dst_in_secure(void *start, ulong size)
+{
+   ulong ns_end = CFG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE;
+#ifdef PHYS_SDRAM_2_SIZE
+   ns_end += PHYS_SDRAM_2_SIZE;
+#endif
+
+   if ((ulong)start < CFG_SYS_SDRAM_BASE || (ulong)start + size > ns_end)
+   return true;
+
+   return false;
+}
+
+void *arch_get_container_trampoline(void)
+{
+   return (void *)((ulong)CFG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE - SZ_16M);
+}
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 
4e56d9909c80f8e888034df4a5098d1bb288d9a0..fc8175c853af4b0855e1854f0bb5f9a5002bbbae
 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -362,6 +362,12 @@ config SPL_LOAD_IMX_CONTAINER
  Support booting U-Boot from an i.MX8 container image. If you are not
  using i.MX8, say 'n'.
 
+config SPL_IMX_CONTAINER_USE_TRAMPOLINE
+   bool
+   depends on SPL
+   help
+ Enable SPL load reader to load data to a trampoline buffer.
+
 config IMX_CONTAINER_CFG
string "i.MX8 Container config file"
depends on SPL && SPL_LOAD_IMX_CONTAINER
diff --git a/common/spl/spl_imx_container.c b/common/spl/spl_imx_container.c
index 
2c31777fcd3af2bc5c738f492a465df280197933..47fb2e65e34829cf3a1a107a5910d73edffe40bd
 100644
--- a/common/spl/spl_imx_container.c
+++ b/common/spl/spl_imx_container.c
@@ -14,6 +14,16 @@
 #include 
 #endif
 
+__weak bool arch_check_dst_in_secure(void *start, ulong size)
+{
+   return false;
+}
+
+__weak void *arch_get_container_trampoline(void)
+{
+   return NULL;
+}
+
 static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image,
  struct spl_load_info *info,
  struct container_hdr *container,
@@ -22,6 +32,7 @@ static struct boot_img_t *read_auth_image(struct 
spl_image_info *spl_image,
 {
struct boot_img_t *images;
ulong offset, overhead, size;
+   void *buf, *trampoline;
 
if (image_index > container->num_images) {
debug("Invalid image number\n");
@@ -42,12 +53,30 @@ static struct boot_img_t *read_auth_image(struct 
spl_image_info *spl_image,
 
debug("%s: container: %p offset: %lu size: %lu\n", __func__,
  container, offset, size);
-   if (info->read(info, offset, size,
-  map_sysmem(images[image_index].dst - overhead,
- images[image_index].size)) <
-   images[image_index].size) {
-   printf("%s wrong\n", __func__);
-   return NULL;
+
+   buf = map_sysmem(images[image_index].dst - overhead, 
images[image_index].size);
+   if (IS_ENABLED(CONFIG_SPL_IMX_CONTAINER_USE_TRAMPOLINE) &&
+   arch_check_dst_in_secure(buf, size)) {
+   trampoline = arch_get_container_trampoline();
+   if (!trampoline) {
+   printf("%s: trampoline size is zero\n", __func__);
+   return NULL;
+   }
+
+   if (info->read(info, offset, size, trampoline) < 
images[image_index].size) {
+   printf("%s wrong\n", __func__);
+   return NULL;
+   }
+
+   memcpy(buf, trampoline, images[image_index].size);
+   } else {
+   if (info->read(info, offset, size,
+  map_sysmem(images[image_index].dst - overhead,
+ images[image_index].size)) <
+   images[image_index].size) {
+   printf("%s wrong\n", __func__);
+   return NULL;
+   }
}
 
 #ifdef CONFIG_AHAB_BOOT

-- 
2.34.1



[PATCH v4 15/20] imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95

2025-01-15 Thread Alice Guo
From: Alice Guo 

i.MX95 only supports low power boot, which means A55 is kicked by M33.
There is no ROM runs on A55 in such case so that deselect IMX8_ROMAPI
for i.MX95.

Signed-off-by: Alice Guo 
---
 arch/arm/mach-imx/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 
134e42028c3787d78e28af03d40c41a8b2b1981b..daf6443aa5b40b6410f2645937239a4ec785fa34
 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -180,7 +180,7 @@ config DDRMC_VF610_CALIBRATION
 
 config IMX8_ROMAPI
def_bool y
-   depends on IMX8MN || IMX8MP || IMX8ULP || IMX9
+   depends on IMX8MN || IMX8MP || IMX8ULP || (IMX9 && !IMX95)
 
 config SPL_IMX_ROMAPI_LOADADDR
hex "Default load address to load image through ROM API"

-- 
2.34.1



Re: [PATCH 3/5] pxe_utils: Allow the FDT to be missing

2025-01-15 Thread Simon Glass
Hi Quentin,

On Wed, 15 Jan 2025 at 04:59, Quentin Schulz  wrote:
>
> Hi Simon,
>
> On 1/15/25 2:16 AM, Simon Glass wrote:
> > Hi Quentin,
> >
> > On Tue, 14 Jan 2025 at 08:13, Quentin Schulz  
> > wrote:
> >>
> >> Hi Simon,
> >>
> >> On 12/20/24 5:01 AM, Simon Glass wrote:
> >>> The devicetree file may not be provided, so avoid a failure in that
> >>> case.
> >>>
> >>
> >> Can you provide a bit more information on when/why this shouldn't be a
> >> failure? I assume likely x86? or Aarch64 with ACPI instead of OF?
> >
> > Yes, either of those, but also, even on platforms which use a
> > devicetree, some don't have it in the extlinux file. For example rpi
> > passes it through to U-Boot from its own closed-source firmware.
> >
>
> Ah yes, I had forgotten about platforms using one DTB and passing it
> through stages, I believe Qualcomm does this as well?
>
> Could you please add what you just said to the commit log so that we
> have an idea which scenario this intends to support (for future
> reference if this introduces a regression or we want to do refactoring
> in the future).

OK

>
> I'm wondering if this isn't going to allow booting FDT systems without
> an FDT at all, which really isn't great? Is there something we
> could/should do to prevent that from happening (or at least notify the
> user of such a scenario so it's easier to debug)?

It shouldn't make any difference to the current code. Passing a
bootflow just allows the information to be recorded. The logic of
whether to use the FDT is not changed by this patch.

>
> > Somewhat related: my opinion with extlinux (and EFI for that matter)
> > is that we should be using FIT.
> >
>
> FIT images are not really developer-friendly though :/ I've been asked
> to ditch FIT images to allow easy replacement of customer Device
> Trees/kernel images. Much easier to say "copy your file there, modify
> extlinux.conf to point at the new filepath for the FDT" rather than "so
> this is the ITS, change the path here, and there, don't forget to have
> those binaries in the current path, use mkimage, then copy this itb file
> there".

Yes we need to keep that flow working, of course.

Re FIT, well, we could write a tool. Would that help? If someone did
that, what would it look like?

I've been happy with FIT for a long time, but particularly recently
due to all the workarounds and gymnastics people are doing to make
single files work, e.g. figuring out which devicetree to use.

There is 'u-boot-menu' which works on the running system.

>
> In any case, I don't believe we could remove non-FIT support, so here we
> are :)

Regards,
SImon


[PATCH v4 08/20] clk: scmi: check the clock state/parent/rate control permissions

2025-01-15 Thread Alice Guo
From: Alice Guo 

Clock driver based on SCMI clock management protocol in Linux checks
clock state, parent and rate control permissions. To be consistent with
the kernel driver, add this check here.

When using common clock framework (CCF), use the clock signal ID to get
the clock registered by clk_register() in scmi_clk_probe(), and then
obatin the struct clk_scmi variable with container_of().

Signed-off-by: Alice Guo 
Signed-off-by: Ye Li 
Reviewed-by: Peng Fan 
---
 drivers/clk/clk_scmi.c   | 173 ---
 include/scmi_protocols.h |  26 ++-
 2 files changed, 188 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
index 
84333cdd0ccfe566c269f776f39725c69883c25c..0654f0cbf5fcca9c82b840c2fabd057ce1907979
 100644
--- a/drivers/clk/clk_scmi.c
+++ b/drivers/clk/clk_scmi.c
@@ -12,6 +12,56 @@
 #include 
 #include 
 
+struct clk_scmi {
+   struct clk clk;
+   u32 ctrl_flags;
+};
+
+static int scmi_clk_get_permissions(struct udevice *dev, int clkid, u32 *perm)
+{
+   u32 version;
+   int ret;
+
+   ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK, 
&version);
+   if (ret) {
+   debug("get SCMI clock management protocol version failed\n");
+   return ret;
+   }
+
+   if (version >= CLOCK_PROTOCOL_VERSION_3_0) {
+   struct scmi_clk_get_permissions_in in = {
+   .clock_id = clkid,
+   };
+   struct scmi_clk_get_permissions_out out;
+   struct scmi_msg msg = {
+   .protocol_id = SCMI_PROTOCOL_ID_CLOCK,
+   .message_id = SCMI_CLOCK_GET_PERMISSIONS,
+   .in_msg = (u8 *)&in,
+   .in_msg_sz = sizeof(in),
+   .out_msg = (u8 *)&out,
+   .out_msg_sz = sizeof(out),
+   };
+
+   ret = devm_scmi_process_msg(dev, &msg);
+   if (ret) {
+   debug("get SCMI clock management protocol permissions 
failed\n");
+   return ret;
+   }
+
+   ret = scmi_to_linux_errno(out.status);
+   if (ret < 0) {
+   debug("the status code of getting permissions: %d\n", 
ret);
+   return ret;
+   }
+
+   *perm = out.permissions;
+   return 0;
+   }
+
+   debug("SCMI clock management protocol version is less than 3.0.\n");
+   return -EINVAL;
+}
+
 static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks)
 {
struct scmi_clk_protocol_attr_out out;
@@ -32,7 +82,8 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t 
*num_clocks)
return 0;
 }
 
-static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name)
+static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name,
+u32 *attr)
 {
struct scmi_clk_attribute_in in = {
.clock_id = clkid,
@@ -53,6 +104,7 @@ static int scmi_clk_get_attibute(struct udevice *dev, int 
clkid, char **name)
return ret;
 
*name = strdup(out.clock_name);
+   *attr = out.attributes;
 
return 0;
 }
@@ -78,11 +130,49 @@ static int scmi_clk_gate(struct clk *clk, int enable)
 
 static int scmi_clk_enable(struct clk *clk)
 {
+   struct clk_scmi *clkscmi;
+   struct clk *c;
+   int ret;
+
+   if (CONFIG_IS_ENABLED(CLK_CCF)) {
+   ret = clk_get_by_id(clk->id, &c);
+   if (ret)
+   return ret;
+
+   clkscmi = container_of(c, struct clk_scmi, clk);
+
+   if (clkscmi->ctrl_flags & SUPPORT_CLK_STAT_CONTROL)
+   return scmi_clk_gate(clk, 1);
+
+   /* Following Linux drivers/clk/clk-scmi.c, directly return 0 if 
agent has no permission. */
+   debug("SCMI CLOCK: the clock cannot be enabled by the 
agent.\n");
+   return 0;
+   }
+
return scmi_clk_gate(clk, 1);
 }
 
 static int scmi_clk_disable(struct clk *clk)
 {
+   struct clk_scmi *clkscmi;
+   struct clk *c;
+   int ret;
+
+   if (CONFIG_IS_ENABLED(CLK_CCF)) {
+   ret = clk_get_by_id(clk->id, &c);
+   if (ret)
+   return ret;
+
+   clkscmi = container_of(c, struct clk_scmi, clk);
+
+   if (clkscmi->ctrl_flags & SUPPORT_CLK_STAT_CONTROL)
+   return scmi_clk_gate(clk, 0);
+
+   /* Following Linux drivers/clk/clk-scmi.c, directly return 0 if 
agent has no permission. */
+   debug("SCMI CLOCK: the clock cannot be disabled by the 
agent.\n");
+   return 0;
+   }
+
return scmi_clk_gate(clk, 0);
 }
 
@@ -108,7 +198,7 @@ static ulong scmi_clk_get_rate(struct clk *clk)
return (ulong)(((u64)out.rat

Re: dtc: "syntax error" linked to &{label/subnode} syntax

2025-01-15 Thread Simon Glass
Hi Patrice,

On Wed, 15 Jan 2025 at 03:19, Patrice CHOTARD
 wrote:
>
> Hi
>
> I am currently converting STM32MP platforms to OF_UPSTREAM.
> As we use same binary for several boards, flags 
> CONFIG_OF_UPSTREAM_BUILD_VENDOR=y
> and CONFIG_OF_UPSTREAM_VENDOR="st" are set.
>
> So all dts/upstream/src/arm/st/* dts files are compiled.
>
> I am facing an issue with dts/upstream/src/arm/st/stm32mp151a-prtt1* and
> dts/upstream/src/arm/st/stm32mp15*-mec*.* files.
>
> To be more precise, these files are using a syntax which follows this
> format &{label/subnode} to override some nodes.
>
> This leads to DTC error:
>
>  AR  drivers/usb/gadget/built-in.o
>   LD  u-boot
>   OBJCOPY u-boot.srec
>   OBJCOPY u-boot-nodtb.bin
>   SYM u-boot.sym
>   DTC dts/upstream/src/arm/st/stm32mp157c-dhcom-picoitx.dtb
>   DTC dts/upstream/src/arm/st/stm32h750i-art-pi.dtb
>   DTC 
> dts/upstream/src/arm/st/stm32mp157a-microgea-stm32mp1-microdev2.0-of7.dtb
>   DTC dts/upstream/src/arm/st/stm32mp157a-iot-box.dtb
>   DTC dts/upstream/src/arm/st/stm32746g-eval.dtb
>   DTC dts/upstream/src/arm/st/stm32mp151c-mecio1r0.dtb
>   DTC dts/upstream/src/arm/st/stm32mp157a-dhcor-avenger96.dtb
>   DTC dts/upstream/src/arm/st/ste-nomadik-s8815.dtb
> Error: ../dts/upstream/src/arm/st/stm32mp15x-mecio1-io.dtsi:338.1-2 syntax 
> error
> FATAL ERROR: Unable to parse input tree
>
>
> At line 338 in dts/upstream/src/arm/st/stm32mp15x-mecio1-io.dtsi we got :
>
> &{qspi_bk1_pins_a/pins} {
> pinmux = , /* QSPI_BK1_IO0 */
>  , /* QSPI_BK1_IO1 */
>  , /* QSPI_BK1_IO2 */
>  ; /* QSPI_BK1_IO3 */
> /delete-property/ bias-disable;
> bias-pull-up;
> };
>
> If i update it as following , the DTC compilation is OK :
>
> &qspi_bk1_pins_a {
> pins {
> pinmux = , /* QSPI_BK1_IO0 */
>  , /* QSPI_BK1_IO1 */
>  , /* QSPI_BK1_IO2 */
>  ; /* QSPI_BK1_IO3 */
> /delete-property/ bias-disable;
> bias-pull-up;
> };
> };
>
> On kernel side, the DTC compilation is ok, but not on U-Boot side. I am not 
> able to understand the difference.
>

Could it be that the kernel dtc is newer?

You could try DTC=`which dtc` if you already have that in your system.

Regards,
Simon


[PATCH v4 07/20] clk: scmi: add the command CLOCK_PARENT_SET

2025-01-15 Thread Alice Guo
From: Peng Fan 

This patch adds the command CLOCK_PARENT_SET that can be used to set the
parent of a clock. ARM SCMI Version 3.2 supports to change the parent of
a clock device.

Signed-off-by: Peng Fan 
Signed-off-by: Alice Guo 
Reviewed-by: Ye Li 
---
 drivers/clk/clk_scmi.c   | 20 
 include/scmi_protocols.h | 19 +++
 2 files changed, 39 insertions(+)

diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
index 
e42d2032d45e011b751c19b395b6f99d5c54e78e..84333cdd0ccfe566c269f776f39725c69883c25c
 100644
--- a/drivers/clk/clk_scmi.c
+++ b/drivers/clk/clk_scmi.c
@@ -178,11 +178,31 @@ static int scmi_clk_probe(struct udevice *dev)
return 0;
 }
 
+static int scmi_clk_set_parent(struct clk *clk, struct clk *parent)
+{
+   struct scmi_clk_parent_set_in in = {
+   .clock_id = clk->id,
+   .parent_clk = parent->id,
+   };
+   struct scmi_clk_parent_set_out out;
+   struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_CLOCK,
+ SCMI_CLOCK_PARENT_SET,
+ in, out);
+   int ret;
+
+   ret = devm_scmi_process_msg(clk->dev, &msg);
+   if (ret < 0)
+   return ret;
+
+   return scmi_to_linux_errno(out.status);
+}
+
 static const struct clk_ops scmi_clk_ops = {
.enable = scmi_clk_enable,
.disable = scmi_clk_disable,
.get_rate = scmi_clk_get_rate,
.set_rate = scmi_clk_set_rate,
+   .set_parent = scmi_clk_set_parent,
 };
 
 U_BOOT_DRIVER(scmi_clock) = {
diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
index 
08c86a642844570424dddbfcf9670d1e6757d8d1..d529f8e2697472e60d0cb9c275f34ef0ecaed3ca
 100644
--- a/include/scmi_protocols.h
+++ b/include/scmi_protocols.h
@@ -737,6 +737,7 @@ enum scmi_clock_message_id {
SCMI_CLOCK_RATE_SET = 0x5,
SCMI_CLOCK_RATE_GET = 0x6,
SCMI_CLOCK_CONFIG_SET = 0x7,
+   SCMI_CLOCK_PARENT_SET = 0xD
 };
 
 #define SCMI_CLK_PROTO_ATTR_COUNT_MASK GENMASK(15, 0)
@@ -839,6 +840,24 @@ struct scmi_clk_rate_set_out {
s32 status;
 };
 
+/**
+ * struct scmi_clk_parent_state_in - Message payload for CLOCK_PARENT_SET 
command
+ * @clock_id:  SCMI clock ID
+ * @parent_clk:SCMI clock ID
+ */
+struct scmi_clk_parent_set_in {
+   u32 clock_id;
+   u32 parent_clk;
+};
+
+/**
+ * struct scmi_clk_parent_set_out - Response payload for CLOCK_PARENT_SET 
command
+ * @status:SCMI command status
+ */
+struct scmi_clk_parent_set_out {
+   s32 status;
+};
+
 /*
  * SCMI Reset Domain Protocol
  */

-- 
2.34.1



[PATCH v4 09/20] sandbox: add SCMI clock control permissions to sandbox

2025-01-15 Thread Alice Guo
This patch is used to add SCMI clock control permissions to sandbox for
testing.

Signed-off-by: Alice Guo 
---
 arch/sandbox/include/asm/scmi_test.h   |  2 ++
 drivers/firmware/scmi/sandbox-scmi_agent.c | 56 --
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/include/asm/scmi_test.h 
b/arch/sandbox/include/asm/scmi_test.h
index 
619f8f5098cdd82ba2343897166c34c82c753422..b30e536a35771ec3e1439c1e64fd09de3728dc50
 100644
--- a/arch/sandbox/include/asm/scmi_test.h
+++ b/arch/sandbox/include/asm/scmi_test.h
@@ -27,10 +27,12 @@ struct sandbox_scmi_pwd {
  * @id:Identifier of the clock used in the SCMI protocol
  * @enabled:   Clock state: true if enabled, false if disabled
  * @rate:  Clock rate in Hertz
+ * @perm:  Indicating state/parent/rate permission
  */
 struct sandbox_scmi_clk {
bool enabled;
ulong rate;
+   u32 perm;
 };
 
 /**
diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c 
b/drivers/firmware/scmi/sandbox-scmi_agent.c
index 
19be280ec44845369d1f46509978ec9b5b59c60b..74a87832dcb14d63550e450f4bea2632844199e9
 100644
--- a/drivers/firmware/scmi/sandbox-scmi_agent.c
+++ b/drivers/firmware/scmi/sandbox-scmi_agent.c
@@ -80,9 +80,9 @@ static struct sandbox_scmi_pwd scmi_pwdom[] = {
 };
 
 static struct sandbox_scmi_clk scmi_clk[] = {
-   { .rate = 333 },
-   { .rate = 200 },
-   { .rate = 1000 },
+   { .rate = 333, .perm = 0xE000 },
+   { .rate = 200, .perm = 0xE000 },
+   { .rate = 1000, .perm = 0xE000 },
 };
 
 static struct sandbox_scmi_reset scmi_reset[] = {
@@ -700,6 +700,21 @@ static int sandbox_scmi_pwd_name_get(struct udevice *dev, 
struct scmi_msg *msg)
 
 /* Clock Protocol */
 
+static int sandbox_scmi_clock_protocol_version(struct udevice *dev,
+  struct scmi_msg *msg)
+{
+   struct scmi_protocol_version_out *out = NULL;
+
+   if (!msg->out_msg || msg->out_msg_sz < sizeof(*out))
+   return -EINVAL;
+
+   out = (struct scmi_protocol_version_out *)msg->out_msg;
+   out->version = 0x3;
+   out->status = SCMI_SUCCESS;
+
+   return 0;
+}
+
 static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev,
   struct scmi_msg *msg)
 {
@@ -740,6 +755,9 @@ static int sandbox_scmi_clock_attribs(struct udevice *dev, 
struct scmi_msg *msg)
if (clk_state->enabled)
out->attributes = 1;
 
+   /* Restricted clock */
+   out->attributes |= BIT(1);
+
ret = snprintf(out->clock_name, sizeof(out->clock_name),
   "clk%u", in->clock_id);
assert(ret > 0 && ret < sizeof(out->clock_name));
@@ -837,6 +855,34 @@ static int sandbox_scmi_clock_gate(struct udevice *dev, 
struct scmi_msg *msg)
return 0;
 }
 
+static int sandbox_scmi_clock_permissions_get(struct udevice *dev,
+ struct scmi_msg *msg)
+{
+   struct scmi_clk_get_permissions_in *in = NULL;
+   struct scmi_clk_get_permissions_out *out = NULL;
+   struct sandbox_scmi_clk *clk_state = NULL;
+
+   if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) ||
+   !msg->out_msg || msg->out_msg_sz < sizeof(*out))
+   return -EINVAL;
+
+   in = (struct scmi_clk_get_permissions_in *)msg->in_msg;
+   out = (struct scmi_clk_get_permissions_out *)msg->out_msg;
+
+   clk_state = get_scmi_clk_state(in->clock_id);
+   if (!clk_state) {
+   dev_err(dev, "Unexpected clock ID %u\n", in->clock_id);
+
+   out->status = SCMI_NOT_FOUND;
+   } else {
+   out->permissions = clk_state->perm;
+
+   out->status = SCMI_SUCCESS;
+   }
+
+   return 0;
+}
+
 static int sandbox_scmi_rd_attribs(struct udevice *dev, struct scmi_msg *msg)
 {
struct scmi_rd_attr_in *in = NULL;
@@ -1193,6 +1239,8 @@ static int sandbox_scmi_test_process_msg(struct udevice 
*dev,
return sandbox_proto_not_supported(msg);
 
switch (msg->message_id) {
+   case SCMI_PROTOCOL_VERSION:
+   return sandbox_scmi_clock_protocol_version(dev, msg);
case SCMI_PROTOCOL_ATTRIBUTES:
return sandbox_scmi_clock_protocol_attribs(dev, msg);
case SCMI_CLOCK_ATTRIBUTES:
@@ -1203,6 +1251,8 @@ static int sandbox_scmi_test_process_msg(struct udevice 
*dev,
return sandbox_scmi_clock_rate_get(dev, msg);
case SCMI_CLOCK_CONFIG_SET:
return sandbox_scmi_clock_gate(dev, msg);
+   case SCMI_CLOCK_GET_PERMISSIONS:
+   return sandbox_scmi_clock_permissions_get(dev, msg);
default:
break;
}

-- 
2.34.1



[PATCH v4 10/20] scmi_protocols: update struct scmi_base_discover_list_protocols_out

2025-01-15 Thread Alice Guo
From: Ye Li 

@protocols is an array of protocol identifiers that are implemented,
excluding the Base protocol. The number of elements of @protocols is
specified by callee-side. Currently, set it to 4 is enough for i.MX95.

Signed-off-by: Ye Li 
Signed-off-by: Alice Guo 
---
 include/scmi_protocols.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
index 
9607433c3276f9aa18044c414a5bde3143726cf4..3c55d228cb641bc6c0e5ca7ac885efe84b41c66d
 100644
--- a/include/scmi_protocols.h
+++ b/include/scmi_protocols.h
@@ -141,11 +141,14 @@ struct scmi_base_discover_impl_version_out {
  * @status:SCMI command status
  * @num_protocols: Number of SCMI protocols in @protocol
  * @protocols: Array of packed SCMI protocol ID's
+ *
+ * The number of elements of @protocols is specified by callee-side. Currently,
+ * set it to 4 is enough for i.MX95.
  */
 struct scmi_base_discover_list_protocols_out {
s32 status;
u32 num_protocols;
-   u32 protocols[3];
+   u32 protocols[4];
 };
 
 /**

-- 
2.34.1



[PATCH v4 20/20] imx95_evk: add i.MX95 19x19 EVK board basic support

2025-01-15 Thread Alice Guo
From: Ye Li 

This patch adds i.MX95 19x19 EVK board basic support.

Messaging unit for EdgeLock Secure Enclave, messaging unit for System
Manager, uSDHC for SD Card, gpio, lpuart are supported now.

Signed-off-by: Ye Li 
Signed-off-by: Alice Guo 
Reviewed-by: Peng Fan 
---
 arch/arm/dts/imx95-19x19-evk-u-boot.dtsi  |  68 ++
 arch/arm/dts/imx95-u-boot.dtsi| 157 +++
 arch/arm/mach-imx/imx9/Kconfig|   6 +
 arch/arm/mach-imx/imx9/scmi/container.cfg |  10 ++
 arch/arm/mach-imx/imx9/scmi/imximage.cfg  |  15 +++
 board/freescale/imx95_evk/Kconfig |  12 ++
 board/freescale/imx95_evk/MAINTAINERS |   6 +
 board/freescale/imx95_evk/Makefile|  11 ++
 board/freescale/imx95_evk/imx95_19x19_evk.env |  90 +
 board/freescale/imx95_evk/imx95_evk.c |  54 
 board/freescale/imx95_evk/spl.c   |  72 +++
 configs/imx95_19x19_evk_defconfig | 177 ++
 doc/board/nxp/imx95_evk.rst   | 114 +
 doc/board/nxp/index.rst   |   1 +
 include/configs/imx95_evk.h   |  27 
 15 files changed, 820 insertions(+)

diff --git a/arch/arm/dts/imx95-19x19-evk-u-boot.dtsi 
b/arch/arm/dts/imx95-19x19-evk-u-boot.dtsi
new file mode 100644
index 
..2902e8f711c3ef705df27ca4fc7a89d1bd7ffc71
--- /dev/null
+++ b/arch/arm/dts/imx95-19x19-evk-u-boot.dtsi
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+#include "imx95-u-boot.dtsi"
+
+&gpio1 {
+   reg = <0 0x4740 0 0x1000>, <0 0x47400040 0 0x40>;
+};
+
+&lpuart1 {
+   clocks = <&scmi_clk IMX95_CLK_LPUART1>, <&scmi_clk IMX95_CLK_LPUART1>;
+   clock-names = "ipg", "per";
+   bootph-pre-ram;
+};
+
+®_usdhc2_vmmc {
+   bootph-pre-ram;
+};
+
+&usdhc1 {
+   bootph-pre-ram;
+};
+
+&usdhc2 {
+   bootph-pre-ram;
+};
+
+&wdog3 {
+   status = "disabled";
+};
+
+&pinctrl_uart1 {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc1 {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc1_100mhz {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc1_200mhz {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc2 {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc2_100mhz {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc2_200mhz {
+   bootph-pre-ram;
+};
+
+&pinctrl_usdhc2_gpio {
+   bootph-pre-ram;
+};
+
+&pinctrl_reg_usdhc2_vmmc {
+   bootph-pre-ram;
+};
diff --git a/arch/arm/dts/imx95-u-boot.dtsi b/arch/arm/dts/imx95-u-boot.dtsi
new file mode 100644
index 
..b0dcf765a779e5cbf63911c12f089370fc886dbf
--- /dev/null
+++ b/arch/arm/dts/imx95-u-boot.dtsi
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2025 NXP
+ */
+
+/ {
+   binman {
+   multiple-images;
+
+   m33-oei-ddrfw {
+   pad-byte = <0x00>;
+   align-size = <0x8>;
+   filename = "m33-oei-ddrfw.bin";
+
+   oei-m33-ddr {
+   align-size = <0x4>;
+   filename = "oei-m33-ddr.bin";
+   type = "blob-ext";
+   };
+
+   imx-lpddr {
+   type = "nxp-header-ddrfw";
+
+   imx-lpddr-imem {
+   filename = "lpddr5_imem_v202311.bin";
+   type = "blob-ext";
+   };
+
+   imx-lpddr-dmem {
+   filename = "lpddr5_dmem_v202311.bin";
+   type = "blob-ext";
+   };
+   };
+
+   imx-lpddr-qb {
+   type = "nxp-header-ddrfw";
+
+   imx-lpddr-imem-qb {
+   filename = "lpddr5_imem_qb_v202311.bin";
+   type = "blob-ext";
+   };
+
+   imx-lpddr-dmem-qb {
+   filename = "lpddr5_dmem_qb_v202311.bin";
+   type = "blob-ext";
+   };
+   };
+   };
+
+   imx-boot {
+   filename = "flash.bin";
+   pad-byte = <0x00>;
+
+   spl {
+   align = <0x400>;
+   align-size = <0x400>;
+   type = "mkimage";
+   args = "-n spl/u-boot-spl.cfgout -T imx8image";
+   };
+
+   u-boot {
+   type = "mkimage";
+   

[PATCH v4 19/20] doc: imx: add document for i.MX95 Image Container Format

2025-01-15 Thread Alice Guo
From: Alice Guo 

This patch add a document for i.MX95 Image Container Format.

Signed-off-by: Alice Guo 
---
 doc/imx/imx95_container.txt | 136 
 1 file changed, 136 insertions(+)

diff --git a/doc/imx/imx95_container.txt b/doc/imx/imx95_container.txt
new file mode 100644
index 
..2ad573450697ae344d8703f43d050ddd1fef7a85
--- /dev/null
+++ b/doc/imx/imx95_container.txt
@@ -0,0 +1,136 @@
+i.MX95 Image Container Format
+-
+
+The image container set consists of some image containers, and image container
+contains boot images. Each image container has its own container header which 
is
+defined in Figure 1. All container headers are placed together in a continuous
+8KB space at the beginning of the image container set - image container set 
header.
+
+ROM code addresses image containers in image container set one by one based on
+their headers’ order in image container set header.
+
+If ELE container exists, its container header must be the 1st one in the image
+container set header.
+
+If V2X container exists, its container header must be the 2nd one in the image
+container set header. V2X must be combined with ELE container.
+
+The information of boot images are recorded in image container header. System
+ROM code needs to retrieve the information from the image container header, 
like
+the offset on boot source, the target address in RAM, the length of boot image.
+The order of ROM code handling these boot images is based on the order of each
+boot image information present in image container header.
+
+Figure 1:
+--- 
+--+--+--+--+
+  ^ |Tag   |Length|Length|Version  
 |
+  | 
+--+--+--+--+
+  | |   Flags  
 |
+  | 
+--+--+--+--+
+  | |# of Images   |Fuse version  |SW version  
 |
+Image | 
+--+--+--+--+
+Conatiner | |Reserved |Signature Block Offset  
 |
+Header| --- 
+--+--+--+--+
+  |   ^ |Image0: Offset, Size, LoadAddr, EntryPoint, Flags, Hash, 
IV|
+  |   | 
+--+--+--+--+
+  | Image | |Image1: Offset, Size, LoadAddr, EntryPoint, Flags, Hash, 
IV|
+  | Array | 
+--+--+--+--+
+  |   | |...   
 |
+  |   | 
+--+--+--+--+
+  v   v |ImageN: Offset, Size, LoadAddr, EntryPoint, Flags, Hash, 
IV|
+--- 
+--+--+--+--+
+|...   
 |
+--- 
+--+--+--+--+ <-- SignOffset
+  ^ |Tag   |Length|Length|Version  
 |
+  | 
+--+--+--+--+
+  | |SRK table offset |Certificate Offset  
 |
+  | 
+--+--+--+--+
+  | |Blob Offset  |Signature Offset
 |
+  | 
+--+--+--+--+
+Signature | | SRK Table
 |
+Block | 
+--+--+--+--+
+  | | Signature
 |
+  | 
+--+--+--+--+
+  | |   Certificate (optional) 
 |
+  | 
+--+--+--+--+
+  v |  Blob (optional) 
 |
+--- 
+--+--+--+--+
+|...   
 |
+
+--+--+--+--+ <-- Image0Offset
+|   Image0 
 |
+
+--+--+--+--+
+|...   
 |
+
+--+--+--+--+ <-- ImageNOffset
+|  

[PATCH v4 18/20] imx: add V2X container support on i.MX95

2025-01-15 Thread Alice Guo
From: Teo Hall 

This patch adds V2X container support on i.MX95.

Signed-off-by: Ye Li 
Signed-off-by: Teo Hall 
Signed-off-by: Alice Guo 
---
 arch/arm/mach-imx/image-container.c | 63 +++--
 1 file changed, 40 insertions(+), 23 deletions(-)

diff --git a/arch/arm/mach-imx/image-container.c 
b/arch/arm/mach-imx/image-container.c
index 
2afe9d38a0681862098a6566a873873f24069b88..54ae7721888dbc93fdaba8e5aedc52c4506bb1c1
 100644
--- a/arch/arm/mach-imx/image-container.c
+++ b/arch/arm/mach-imx/image-container.c
@@ -231,45 +231,62 @@ static unsigned long get_boot_device_offset(void *dev, 
int dev_type)
return offset;
 }
 
-static int get_imageset_end(void *dev, int dev_type)
+static ulong get_imageset_end(void *dev, int dev_type)
 {
-   unsigned long offset1 = 0, offset2 = 0;
-   int value_container[2];
+   unsigned long offset[3] = {};
+   int value_container[3] = {};
u16 hdr_length;
 
-   offset1 = get_boot_device_offset(dev, dev_type);
-   offset2 = CONTAINER_HDR_ALIGNMENT + offset1;
+   offset[0] = get_boot_device_offset(dev, dev_type);
 
-   value_container[0] = get_dev_container_size(dev, dev_type, offset1, 
&hdr_length);
+   value_container[0] = get_dev_container_size(dev, dev_type, offset[0], 
&hdr_length);
if (value_container[0] < 0) {
printf("Parse seco container failed %d\n", value_container[0]);
-   return value_container[0];
+   return 0;
}
 
debug("seco container size 0x%x\n", value_container[0]);
 
-   value_container[1] = get_dev_container_size(dev, dev_type, offset2, 
&hdr_length);
-   if (value_container[1] < 0) {
-   debug("Parse scu container failed %d, only seco container\n",
- value_container[1]);
-   /* return seco container total size */
-   return value_container[0] + offset1;
+   if (is_imx95()) {
+   offset[1] = ALIGN(hdr_length, CONTAINER_HDR_ALIGNMENT) + 
offset[0];
+
+   value_container[1] = get_dev_container_size(dev, dev_type, 
offset[1], &hdr_length);
+   if (value_container[1] < 0) {
+   printf("Parse v2x container failed %d\n", 
value_container[1]);
+   return value_container[0] + offset[0]; /* return seco 
container total size */
+   }
+
+   debug("v2x container size 0x%x\n", value_container[1]);
+
+   offset[2] = ALIGN(hdr_length, CONTAINER_HDR_ALIGNMENT) + 
offset[1];
+   } else {
+   /* Skip offset[1] */
+   offset[2] = ALIGN(hdr_length, CONTAINER_HDR_ALIGNMENT) + 
offset[0];
}
 
-   debug("scu container size 0x%x\n", value_container[1]);
+   value_container[2] = get_dev_container_size(dev, dev_type, offset[2], 
&hdr_length);
+   if (value_container[2] < 0) {
+   debug("Parse scu container image failed %d, only seco 
container\n", value_container[2]);
+   if (is_imx95())
+   return value_container[1] + offset[1]; /* return seco + 
v2x container total size */
+   else
+   return value_container[0] + offset[0]; /* return seco 
container total size */
+   }
 
-   return value_container[1] + offset2;
+   debug("scu container size 0x%x\n", value_container[2]);
+
+   return value_container[2] + offset[2];
 }
 
 #ifdef CONFIG_SPL_SPI_LOAD
 unsigned int spl_spi_get_uboot_offs(struct spi_flash *flash)
 {
-   int end;
+   ulong end;
 
end = get_imageset_end(flash, QSPI_DEV);
end = ROUND(end, SZ_1K);
 
-   printf("Load image from QSPI 0x%x\n", end);
+   printf("Load image from QSPI 0x%lx\n", end);
 
return end;
 }
@@ -279,12 +296,12 @@ unsigned int spl_spi_get_uboot_offs(struct spi_flash 
*flash)
 unsigned long arch_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
unsigned long raw_sect)
 {
-   int end;
+   ulong end;
 
end = get_imageset_end(mmc, MMC_DEV);
end = ROUND(end, SZ_1K);
 
-   printf("Load image from MMC/SD 0x%x\n", end);
+   printf("Load image from MMC/SD 0x%lx\n", end);
 
return end / mmc->read_bl_len;
 }
@@ -312,12 +329,12 @@ int spl_mmc_emmc_boot_partition(struct mmc *mmc)
 #ifdef CONFIG_SPL_NAND_SUPPORT
 uint32_t spl_nand_get_uboot_raw_page(void)
 {
-   int end;
+   ulong end;
 
end = get_imageset_end((void *)NULL, NAND_DEV);
end = ROUND(end, SZ_16K);
 
-   printf("Load image from NAND 0x%x\n", end);
+   printf("Load image from NAND 0x%lx\n", end);
 
return end;
 }
@@ -326,7 +343,7 @@ uint32_t spl_nand_get_uboot_raw_page(void)
 #ifdef CONFIG_SPL_NOR_SUPPORT
 unsigned long spl_nor_get_uboot_base(void)
 {
-   int end;
+   ulong end;
 
/* Calculate the image set end,
 * if it is less than CFG_SYS_UBOOT_BASE(0x8281000),
@@ -33

[PATCH 01/43] test: Drop unused suite prototypes

2025-01-15 Thread Simon Glass
Drop some the prototypes for functions which were removed in earlier
series.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 2ceef577f7f..e40ad634702 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -36,8 +36,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
 int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[]);
-int do_ut_compression(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
@@ -55,14 +53,9 @@ int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_print(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_time(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
 int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
-- 
2.34.1



[PATCH 03/43] test: Add functions to init and uninit the test state

2025-01-15 Thread Simon Glass
Move these operations into separate functions so that it is clearer what
is needed. These functions can also be called from somewhere other than
ut_run_list().

Signed-off-by: Simon Glass 
---

 test/test-main.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/test/test-main.c b/test/test-main.c
index cfb3504941d..871fc1f22b4 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -73,6 +73,19 @@ void ut_set_state(struct unit_test_state *uts)
cur_test_state = uts;
 }
 
+void ut_init_state(struct unit_test_state *uts)
+{
+   memset(uts, '\0', sizeof(*uts));
+}
+
+void ut_uninit_state(struct unit_test_state *uts)
+{
+   if (IS_ENABLED(CONFIG_SANDBOX)) {
+   os_free(uts->fdt_copy);
+   os_free(uts->other_fdt);
+   }
+}
+
 /**
  * dm_test_pre_run() - Get ready to run a driver model test
  *
@@ -664,10 +677,11 @@ int ut_run_list(const char *category, const char *prefix,
struct unit_test *tests, int count, const char *select_name,
int runs_per_test, bool force_run, const char *test_insert)
 {
-   struct unit_test_state uts = { .fail_count = 0 };
+   struct unit_test_state uts;
bool has_dm_tests = false;
int ret;
 
+   ut_init_state(&uts);
if (!CONFIG_IS_ENABLED(OF_PLATDATA) &&
ut_list_has_dm_tests(tests, count, prefix, select_name)) {
has_dm_tests = true;
@@ -703,10 +717,6 @@ int ut_run_list(const char *category, const char *prefix,
/* Best efforts only...ignore errors */
if (has_dm_tests)
dm_test_restore(uts.of_root);
-   if (IS_ENABLED(CONFIG_SANDBOX)) {
-   os_free(uts.fdt_copy);
-   os_free(uts.other_fdt);
-   }
 
if (uts.skip_count)
printf("Skipped: %d, ", uts.skip_count);
@@ -714,6 +724,7 @@ int ut_run_list(const char *category, const char *prefix,
printf("Test '%s' not found\n", select_name);
else
printf("Failures: %d\n", uts.fail_count);
+   ut_uninit_state(&uts);
 
return ret;
 }
-- 
2.34.1



[PATCH 00/43] test: Improvements to ut command and test-suite running

2025-01-15 Thread Simon Glass
The current method of running unit tests relies on subcommands of the
ut command. Only the code in each subcommand knows how to find the tests
related to that subcomand.

This is not ideal and we now have quite a few subcommands which do
nothing but locate the relevant tests in a linker list, then call a
common function to run them.

This series adds a list of test suites, so that these subcommands can be
removed.

An issue with 'ut all' is that it doesn't record how many tests failed
overall, so it is necessary to examine copious amounts of output to look
for failures. This series adds a new 'total' feature allow recording the
total number of failed tests.

To help with 'ut all' a new pytest is created which runs it (as well as
'ut info') and makes sure that all is well. Due to the 'ut all' failures
this does not pass, so the test is disabled for now. It is here because
it provides security against misnaming a test suite and causing it not
to run.

Future work may:
- get 'ut all' passing
- enable test_suite() in CL, to ensure that 'ut all' keeps passing
- record duration of each suite
- allow running the tests in random order to tease out dependencies
- tweak the output to remove common prefixes
- getting rid of bootstd, optee and seame 'ut' subcommands


Simon Glass (43):
  test: Drop unused suite prototypes
  test: Rename test_get_state() to ut_get_state()
  test: Add functions to init and uninit the test state
  test: Pass the test-state into ut_run_list()
  Improve support for linker lists in data structures
  test: Add newlines to hush-test messages
  test: Rename test suites to match their linker-list name
  test: Update ut info to show suites
  test/py: Add a test which runs all unit tests
  test: Drop the _test suffix on linker lists
  test: Introduce a better array of test suites
  test: Drop the function for running bdinfo tests
  test: Drop the function for running cmd tests
  test: Drop the function for running common tests
  test: Drop the function for running dm tests
  test: Drop the function for running env tests
  test: Drop the function for running exit tests
  test: Drop the function for running fdt tests
  test: Drop the function for running font tests
  test: Drop the function for running lib tests
  test: Drop the function for running log tests
  test: Drop the function for running mbr tests
  test: Drop the function for running mem tests
  test: Drop the function for running setexpr tests
  test: Drop the function for running measurement tests
  test: Drop the function for running bloblist tests
  test: Drop the function for running bootm tests
  test: Drop the function for running addrmap tests
  test: Drop the function for running hush tests
  test: Drop the function for running loadm tests
  test: Drop the function for running pci_mps tests
  test: Drop the function for running seama tests
  test: Drop the function for running upl tests
  test: Drop the info test from the list
  test: Drop conditional compilation for suites
  test: Pass the test state to cmd_ut_category()
  test: Move stats into a struct
  test: Keep a track of the numbers of tests run
  test: Move stat-printing into its own function
  test: Record and show the totals for all test runs
  test: Sort the test suites
  test: Disable test_suite
  test: Move help into the suite declaration

 arch/sandbox/cpu/spl.c|   6 +-
 include/dm/test.h |   2 +-
 include/linker_lists.h|  51 +
 include/test/cmd.h|   2 +-
 include/test/common.h |   2 +-
 include/test/env.h|   2 +-
 include/test/hush.h   |   2 +-
 include/test/lib.h|   2 +-
 include/test/log.h|   4 +-
 include/test/optee.h  |   2 +-
 include/test/overlay.h|   2 +-
 include/test/suites.h |  53 ++---
 include/test/test.h   |  23 ++-
 include/test/ut.h |  45 -
 test/boot/bootm.c |  11 +-
 test/boot/bootstd_common.c|   9 +-
 test/boot/bootstd_common.h|   3 +-
 test/boot/measurement.c   |  12 +-
 test/boot/upl.c   |  11 +-
 test/cmd/Makefile |   4 +-
 test/cmd/addrmap.c|  11 +-
 test/cmd/bdinfo.c |  10 +-
 test/cmd/cmd_ut_cmd.c |  20 --
 test/cmd/exit.c   |  11 +-
 test/cmd/fdt.c|  10 +-
 test/cmd/font.c   |  10 +-
 test/cmd/loadm.c  |  11 +-
 test/cmd/mbr.c|  10 +-
 test/cmd/mem.c|  19 --
 test/cmd/mem_copy.c   |   2 +-
 test/cmd/mem_search.c |   2 +-
 test/cmd/pci_mps.c|  12 +-
 test/cmd/seama.c  |  11 +-
 test/cmd/setexpr.c|  11 +-
 test/cmd_ut.c | 361 +-
 test/common/Makefile  |   1 -
 test/common/bloblist.c|  12 +-
 test/common/cmd_ut_common.c   |  21 --
 test/dm/Makefile  |   2 -
 test/dm/test-dm.c |  16 --
 test/dm/test-drive

[PATCH 04/43] test: Pass the test-state into ut_run_list()

2025-01-15 Thread Simon Glass
Pass this into the function so that callers can inspect the state
afterwards.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/spl.c |  5 -
 include/test/ut.h  | 29 ++---
 test/cmd_ut.c  |  5 -
 test/test-main.c   | 35 +--
 4 files changed, 51 insertions(+), 23 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 7056cfd0180..0ad23e4ba95 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -147,10 +147,13 @@ void spl_board_init(void)
if (state->run_unittests) {
struct unit_test *tests = UNIT_TEST_ALL_START();
const int count = UNIT_TEST_ALL_COUNT();
+   struct unit_test_state uts;
int ret;
 
-   ret = ut_run_list("spl", NULL, tests, count,
+   ut_init_state(&uts);
+   ret = ut_run_list(&uts, "spl", NULL, tests, count,
  state->select_unittests, 1, false, NULL);
+   ut_uninit_state(&uts);
/* continue execution into U-Boot */
}
 }
diff --git a/include/test/ut.h b/include/test/ut.h
index 2e4d8edf826..a51defc3b90 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -479,12 +479,34 @@ struct unit_test_state *ut_get_state(void);
  */
 void ut_set_state(struct unit_test_state *uts);
 
+/**
+ * ut_init_state() - Set up a new test state
+ *
+ * This must be called before using the test state with ut_run_tests()
+ *
+ * @uts: Test state to init
+ */
+void ut_init_state(struct unit_test_state *uts);
+
+/**
+ * ut_uninit_state() - Free memory used by test state
+ *
+ * This must be called before after the test state with ut_run_tests(). To 
later
+ * reuse the test state to run more tests, call test_state_init() first
+ *
+ * @uts: Test state to uninit
+ */
+void ut_uninit_state(struct unit_test_state *uts);
+
 /**
  * ut_run_tests() - Run a set of tests
  *
  * This runs the test, handling any preparation and clean-up needed. It prints
  * the name of each test before running it.
  *
+ * @uts: Unit-test state, which must be ready for use, i.e. ut_init_state()
+ * has been called. The caller is responsible for calling
+ * ut_uninit_state() after this function returns
  * @category: Category of these tests. This is a string printed at the start to
  * announce the the number of tests
  * @prefix: String prefix for the tests. Any tests that have this prefix will 
be
@@ -503,8 +525,9 @@ void ut_set_state(struct unit_test_state *uts);
  * Pass NULL to disable this
  * Return: 0 if all tests passed, -1 if any failed
  */
-int ut_run_list(const char *name, const char *prefix, struct unit_test *tests,
-   int count, const char *select_name, int runs_per_test,
-   bool force_run, const char *test_insert);
+int ut_run_list(struct unit_test_state *uts, const char *category,
+   const char *prefix, struct unit_test *tests, int count,
+   const char *select_name, int runs_per_test, bool force_run,
+   const char *test_insert);
 
 #endif
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 195b7ea50ac..d25c2c37e7a 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -21,6 +21,7 @@ int cmd_ut_category(const char *name, const char *prefix,
struct unit_test *tests, int n_ents,
int argc, char *const argv[])
 {
+   struct unit_test_state uts;
const char *test_insert = NULL;
int runs_per_text = 1;
bool force_run = false;
@@ -44,9 +45,11 @@ int cmd_ut_category(const char *name, const char *prefix,
argc--;
}
 
-   ret = ut_run_list(name, prefix, tests, n_ents,
+   ut_init_state(&uts);
+   ret = ut_run_list(&uts, name, prefix, tests, n_ents,
  cmd_arg1(argc, argv), runs_per_text, force_run,
  test_insert);
+   ut_uninit_state(&uts);
 
return ret ? CMD_RET_FAILURE : 0;
 }
diff --git a/test/test-main.c b/test/test-main.c
index 871fc1f22b4..e12c5a95e45 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -673,15 +673,15 @@ static int ut_run_tests(struct unit_test_state *uts, 
const char *prefix,
return uts->fail_count ? -EBADF : 0;
 }
 
-int ut_run_list(const char *category, const char *prefix,
-   struct unit_test *tests, int count, const char *select_name,
-   int runs_per_test, bool force_run, const char *test_insert)
+int ut_run_list(struct unit_test_state *uts, const char *category,
+   const char *prefix, struct unit_test *tests, int count,
+   const char *select_name, int runs_per_test, bool force_run,
+   const char *test_insert)
 {
-   struct unit_test_state uts;
+   ;
bool has_dm_tests = false;
int ret;
 
-   ut_init_state(&uts);
if (!CONFIG_IS_ENABLED(OF_PLATDATA) &&
ut_list_has_dm_tests(tests

[PATCH 02/43] test: Rename test_get_state() to ut_get_state()

2025-01-15 Thread Simon Glass
Rename this function and test_set_state() so use the same ut_ prefix as
other functions in ut.h

Signed-off-by: Simon Glass 
---

 include/test/ut.h |  8 
 test/dm/test-driver.c | 10 +-
 test/dm/test-uclass.c |  8 
 test/test-main.c  |  8 
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/test/ut.h b/include/test/ut.h
index c8838dad096..2e4d8edf826 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -466,18 +466,18 @@ void ut_unsilence_console(struct unit_test_state *uts);
 void ut_set_skip_delays(struct unit_test_state *uts, bool skip_delays);
 
 /**
- * test_get_state() - Get the active test state
+ * ut_state_get() - Get the active test state
  *
  * Return: the currently active test state, or NULL if none
  */
-struct unit_test_state *test_get_state(void);
+struct unit_test_state *ut_get_state(void);
 
 /**
- * test_set_state() - Set the active test state
+ * ut_set_state() - Set the active test state
  *
  * @uts: Test state to use as currently active test state, or NULL if none
  */
-void test_set_state(struct unit_test_state *uts);
+void ut_set_state(struct unit_test_state *uts);
 
 /**
  * ut_run_tests() - Run a set of tests
diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c
index 851177c3018..759de3a5f77 100644
--- a/test/dm/test-driver.c
+++ b/test/dm/test-driver.c
@@ -35,7 +35,7 @@ static const struct test_ops test_ops = {
 
 static int test_bind(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
 
/* Private data should not be allocated */
ut_assert(!dev_get_priv(dev));
@@ -46,7 +46,7 @@ static int test_bind(struct udevice *dev)
 
 static int test_probe(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
struct dm_test_priv *priv = dev_get_priv(dev);
 
/* Private data should be allocated */
@@ -59,7 +59,7 @@ static int test_probe(struct udevice *dev)
 
 static int test_remove(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
 
/* Private data should still be allocated */
ut_assert(dev_get_priv(dev));
@@ -70,7 +70,7 @@ static int test_remove(struct udevice *dev)
 
 static int test_unbind(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
 
/* Private data should not be allocated */
ut_assert(!dev_get_priv(dev));
@@ -121,7 +121,7 @@ static int test_manual_bind(struct udevice *dev)
 
 static int test_manual_probe(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
 
dm_testdrv_op_count[DM_TEST_OP_PROBE]++;
if (!uts->force_fail_alloc)
diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c
index 9a80cc63667..be4108bbecb 100644
--- a/test/dm/test-uclass.c
+++ b/test/dm/test-uclass.c
@@ -28,7 +28,7 @@ int test_ping(struct udevice *dev, int pingval, int *pingret)
 
 static int test_post_bind(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
struct dm_test_perdev_uc_pdata *uc_pdata;
 
dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
@@ -54,7 +54,7 @@ static int test_pre_unbind(struct udevice *dev)
 static int test_pre_probe(struct udevice *dev)
 {
struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev);
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
 
dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++;
ut_assert(priv);
@@ -65,7 +65,7 @@ static int test_pre_probe(struct udevice *dev)
 
 static int test_post_probe(struct udevice *dev)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
struct udevice *prev = list_entry(dev->uclass_node.prev,
struct udevice, uclass_node);
 
@@ -100,7 +100,7 @@ static int test_pre_remove(struct udevice *dev)
 
 static int test_init(struct uclass *uc)
 {
-   struct unit_test_state *uts = test_get_state();
+   struct unit_test_state *uts = ut_get_state();
 
dm_testdrv_op_count[DM_TEST_OP_INIT]++;
ut_assert(uclass_get_priv(uc));
diff --git a/test/test-main.c b/test/test-main.c
index 8d764892fa6..cfb3504941d 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -63,12 +63,12 @@ static enum fdtchk_t fdt_action(void)
 /* This is valid when a test is running, NULL otherwise */
 static struct unit_test_state *cur_test_state;
 
-struct unit_test_state *test_get_state(void)
+struct unit_test_state *ut_get_state(void)
 {
return cur_test_state;
 }
 
-void test_set_state(struct unit_test_state 

[PATCH 05/43] Improve support for linker lists in data structures

2025-01-15 Thread Simon Glass
A limitation of most linker_list macros is that they cannot easily be
used in data structures. This is because they include code inside their
expressions.

Provide a way to support this, with new ll_start_decl() and
ll_end_decl() macros.

Signed-off-by: Simon Glass 
---

 include/linker_lists.h | 51 ++
 1 file changed, 51 insertions(+)

diff --git a/include/linker_lists.h b/include/linker_lists.h
index f9a2ee0c762..c05b99c886f 100644
--- a/include/linker_lists.h
+++ b/include/linker_lists.h
@@ -186,6 +186,57 @@
_ll_result; \
})
 
+/**
+ * Declares a symbol that points to the start/end of the list. The name of the
+ * (new) symbol is arbitrary and can be anything that is not already declared 
in
+ * the file where it appears. It is provided in _sym and can then be used 
(later
+ * in the same file) within a data structure.
+ *
+ * The _type and _list arguments must match those passed to 
ll_entry_start/end()
+ *
+ * Example:
+ *
+ * ::
+ *   Here we want to record the start of each sub-command in a list. We have 
two
+ *   sub-commands, 'bob' and 'mary'.
+ *
+ *   In bob.c:
+ * ll_entry_declare(struct my_sub_cmd, bob_cmd, cmd_sub) = {...}
+ *
+ *   In mary.c:
+ * ll_entry_declare(struct my_sub_cmd, mary_cmd, cmd_sub) = {...}
+ *
+ *   In a different file where we want a list the start of all sub-commands.
+ *   It is not possible to use ll_entry_start() in a data structure, due to its
+ *   use of code inside expressions - ({ ... }) - so this fails to compile:
+ *
+ *   In sub_cmds.c:
+ * struct cmd_sub *my_list[] = {
+ *   ll_entry_start(cmd_sub, bob),
+ *   ll_entry_start(cmd_sub, bob),
+ * }
+ *
+ *   Instead, we can use:
+ *
+ * ll_start_decl(bob, struct my_sub_cmd, cmd_sub);
+ * ll_start_decl(mary, struct my_sub_cmd, cmd_sub);
+ *
+ * struct cmd_sub *my_list[] = {
+ *   bob,
+ *   mary,
+ * }
+ *
+ * So 'bob' is declared as symbol, a struct my_list * which points to the
+ * start of the bob sub-commands. It is then used in my_list[]
+ */
+#define ll_start_decl(_sym, _type, _list)  
\
+   static _type _sym[0] __aligned(CONFIG_LINKER_LIST_ALIGN)\
+   __maybe_unused __section("__u_boot_list_2_" #_list "_1")
+
+#define ll_end_decl(_sym, _type, _list)
\
+   static _type _sym[0] __aligned(CONFIG_LINKER_LIST_ALIGN)\
+   __maybe_unused __section("__u_boot_list_2_" #_list "_3")
+
 /**
  * ll_entry_get() - Retrieve entry from linker-generated array by name
  * @_type: Data type of the entry
-- 
2.34.1



[PATCH 06/43] test: Add newlines to hush-test messages

2025-01-15 Thread Simon Glass
A few messages lack a newline so the test output shows the next
test-name on the same line. For example:

   Beware: this test sets local variable dollar_bar and dollar_quux
  and they cannot be unset!Test: hush_test_env_dollar: dollar.c

This is confusing, so fix it.

Signed-off-by: Simon Glass 
---

 test/hush/dollar.c | 7 ---
 test/hush/loop.c   | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/test/hush/dollar.c b/test/hush/dollar.c
index 077dcd62c0e..820110799a2 100644
--- a/test/hush/dollar.c
+++ b/test/hush/dollar.c
@@ -108,7 +108,7 @@ static int hush_test_simple_dollar(struct unit_test_state 
*uts)
/* Reset local variable. */
ut_assertok(run_command("dollar_foo=", 0));
} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-   puts("Beware: this test set local variable dollar_foo and it 
cannot be unset!");
+   puts("Beware: this test set local variable dollar_foo and it 
cannot be unset!\n");
}
 
return 0;
@@ -140,7 +140,7 @@ static int hush_test_env_dollar(struct unit_test_state *uts)
/* Reset local variable. */
ut_assertok(run_command("env_foo=", 0));
} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-   puts("Beware: this test set local variable env_foo and it 
cannot be unset!");
+   puts("Beware: this test set local variable env_foo and it 
cannot be unset!\n");
}
 
return 0;
@@ -206,7 +206,8 @@ static int hush_test_command_dollar(struct unit_test_state 
*uts)
ut_assertok(run_command("dollar_bar=", 0));
ut_assertok(run_command("dollar_quux=", 0));
} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-   puts("Beware: this test sets local variable dollar_bar and 
dollar_quux and they cannot be unset!");
+   puts("Beware: this test sets local variable dollar_bar and "
+"dollar_quux and they cannot be unset!\n");
}
 
return 0;
diff --git a/test/hush/loop.c b/test/hush/loop.c
index a9b6a8edf24..7154b9bc0ae 100644
--- a/test/hush/loop.c
+++ b/test/hush/loop.c
@@ -25,7 +25,7 @@ static int hush_test_for(struct unit_test_state *uts)
/* Reset local variable. */
ut_assertok(run_command("loop_i=", 0));
} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-   puts("Beware: this test set local variable loop_i and it cannot 
be unset!");
+   puts("Beware: this test set local variable loop_i and it cannot 
be unset!\n");
}
 
return 0;
@@ -56,7 +56,7 @@ static int hush_test_while(struct unit_test_state *uts)
/* Reset local variable. */
ut_assertok(run_command("loop_foo=", 0));
} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-   puts("Beware: this test set local variable loop_foo and it 
cannot be unset!");
+   puts("Beware: this test set local variable loop_foo and it 
cannot be unset!\n");
}
 
return 0;
-- 
2.34.1



[PATCH 09/43] test/py: Add a test which runs all unit tests

2025-01-15 Thread Simon Glass
Add a Python test which runs 'ut all' and then checks that the expected
suites are present and all tests in each suite are run.

This can help to check that nothing is missing.

Update 'ut info' to ignore the 'all' suite when counting the number of
suites, since that is really just a combination of all the other suites.

Adjust the message for skipped tests so that appears even if no
particular test was selected. This helps the new 'test_suite' test see
what is going on.

Signed-off-by: Simon Glass 
---

 test/cmd_ut.c   |   2 +-
 test/py/tests/test_suite.py | 175 
 test/test-main.c|   6 +-
 3 files changed, 178 insertions(+), 5 deletions(-)
 create mode 100644 test/py/tests/test_suite.py

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index b6ceeb94a30..b81708b3e57 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -153,7 +153,7 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int 
argc,
 {
const char *flags;
 
-   printf("Test suites: %d\n", (int)ARRAY_SIZE(cmd_ut_sub));
+   printf("Test suites: %d\n", (int)ARRAY_SIZE(cmd_ut_sub) - 1);
printf("Total tests: %d\n", (int)UNIT_TEST_ALL_COUNT());
 
flags = cmd_arg1(argc, argv);
diff --git a/test/py/tests/test_suite.py b/test/py/tests/test_suite.py
new file mode 100644
index 000..ed636bbde74
--- /dev/null
+++ b/test/py/tests/test_suite.py
@@ -0,0 +1,175 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2024 Google LLC
+
+import pytest
+import re
+
+# List of test suites we expect to find with 'ut info' and 'ut all'
+EXPECTED_SUITES = [
+'addrmap', 'bdinfo', 'bloblist', 'bootm', 'bootstd',
+'cmd', 'common', 'dm', 'env', 'exit',
+'fdt', 'font', 'hush', 'info', 'lib',
+'loadm', 'log', 'mbr', 'measurement', 'mem',
+'overlay', 'pci_mps', 'setexpr', 'upl',
+]
+
+
+# Set this to True to aid debugging of tests
+DEBUG_ME = True
+
+
+def collect_info(cons, output):
+"""Run all unit tests and check the resulting output
+
+Args:
+cons: U-Boot console object
+output: Output from running 'ut all'
+
+Returns:
+tuple:
+set: suite names that were found in output
+set: test names that were found in output
+dict: test count for each suite:
+key: suite name
+value: number of tests for the suite found in output
+set: missing suites (compared to EXPECTED_SUITES)
+set: extra suites (compared to EXPECTED_SUITES)
+"""
+suites = set()
+tests = set()
+cur_suite = None
+test_count = None
+exp_test_count = {}
+
+# Collect suites{}
+for line in output.splitlines():
+m = re.search('Running ([^ ]*) tests', line)
+if m:
+if DEBUG_ME and cur_suite and cur_suite != 'info':
+cons.log.info(f'suite: {cur_suite} expected 
{exp_test_count[cur_suite]} found {test_count}')
+
+cur_suite = m.group(1)
+if DEBUG_ME:
+cons.log.info(f'cur_suite: {cur_suite}')
+suites.add(cur_suite)
+
+test_count = 0
+m = re.match(rf'Running (\d+) {cur_suite} tests', line)
+if m:
+exp_test_count[cur_suite] = int(m.group(1))
+m = re.search(r'Test: (\w*): ([-a-z0-9_]*\.c)?( .*)?', line)
+if m:
+test_name = m.group(1)
+msg = m.group(3)
+if DEBUG_ME:
+cons.log.info(f"test_name {test_name} msg '{msg}'")
+if msg == ' (flat tree)' and test_name not in tests:
+tests.add(test_name)
+test_count += 1
+if not msg or 'skipped as it is manual' in msg:
+tests.add(test_name)
+test_count += 1
+if DEBUG_ME:
+cons.log.info(f'suite: {cur_suite} expected 
{exp_test_count[cur_suite]} found {test_count}')
+cons.log.info(f"Tests: {' '.join(sorted(list(tests)))}")
+
+# Figure out what is missing, or extra
+missing = set()
+extra = set(suites)
+for suite in EXPECTED_SUITES:
+if suite in extra:
+extra.remove(suite)
+else:
+missing.add(suite)
+
+return suites, tests, exp_test_count, missing, extra
+
+
+def process_ut_info(cons, output):
+"""Process the output of the 'ut info' command
+
+Args:
+cons: U-Boot console object
+output: Output from running 'ut all'
+
+Returns:
+tuple:
+int: Number of suites reported
+int: Number of tests reported
+dict: test count for each suite:
+key: suite name
+value: number of tests reported for the suite
+
+"""
+suite_count = None
+total_test_count = None
+test_count = {}
+for line in output.splitlines():
+if DEBUG_ME:
+cons.log.info(f'line: {line}')
+m = re.match(r'Test suites: (.*)', line)
+if m:
+   

[PATCH 10/43] test: Drop the _test suffix on linker lists

2025-01-15 Thread Simon Glass
Most test suites have a _test suffix. This is not necessary as there is
also a ut_ prefix.

Drop the suffix so that (with future work) the suite name can be used as
the linker-list name.

Remove the suffix from the pytest regex as well, moving it to the top of
the file, as it is a constant.

Signed-off-by: Simon Glass 
---

 include/dm/test.h | 2 +-
 include/test/common.h | 2 +-
 include/test/env.h| 2 +-
 include/test/hush.h   | 2 +-
 include/test/lib.h| 2 +-
 include/test/log.h| 4 ++--
 include/test/optee.h  | 2 +-
 include/test/overlay.h| 2 +-
 test/boot/bootm.c | 6 +++---
 test/boot/bootstd_common.c| 8 
 test/boot/bootstd_common.h| 3 +--
 test/boot/measurement.c   | 6 +++---
 test/boot/upl.c   | 6 +++---
 test/cmd/addrmap.c| 6 +++---
 test/cmd/bdinfo.c | 6 +++---
 test/cmd/exit.c   | 6 +++---
 test/cmd/fdt.c| 6 +++---
 test/cmd/font.c   | 6 +++---
 test/cmd/loadm.c  | 6 +++---
 test/cmd/mbr.c| 6 +++---
 test/cmd/mem.c| 4 ++--
 test/cmd/mem_copy.c   | 2 +-
 test/cmd/mem_search.c | 2 +-
 test/cmd/pci_mps.c| 6 +++---
 test/cmd/seama.c  | 6 +++---
 test/cmd/setexpr.c| 6 +++---
 test/common/bloblist.c| 6 +++---
 test/common/cmd_ut_common.c   | 4 ++--
 test/dm/test-dm.c | 4 ++--
 test/env/cmd_ut_env.c | 4 ++--
 test/hush/cmd_ut_hush.c   | 4 ++--
 test/lib/cmd_ut_lib.c | 4 ++--
 test/log/log_ut.c | 4 ++--
 test/optee/cmd_ut_optee.c | 4 ++--
 test/overlay/cmd_ut_overlay.c | 4 ++--
 test/py/conftest.py   | 7 +--
 36 files changed, 81 insertions(+), 79 deletions(-)

diff --git a/include/dm/test.h b/include/dm/test.h
index 3cbf2c740d4..4aabb4603b9 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -143,7 +143,7 @@ extern struct unit_test_state global_dm_test_state;
 
 /* Declare a new driver model test */
 #define DM_TEST(_name, _flags) \
-   UNIT_TEST(_name, UTF_DM | UTF_CONSOLE | (_flags), dm_test)
+   UNIT_TEST(_name, UTF_DM | UTF_CONSOLE | (_flags), dm)
 
 /*
  * struct sandbox_sdl_plat - Platform data for the SDL video driver
diff --git a/include/test/common.h b/include/test/common.h
index 81260d06ad6..d5a65d5b50b 100644
--- a/include/test/common.h
+++ b/include/test/common.h
@@ -10,6 +10,6 @@
 #include 
 
 /* Declare a new common function test */
-#define COMMON_TEST(_name, _flags) UNIT_TEST(_name, _flags, common_test)
+#define COMMON_TEST(_name, _flags) UNIT_TEST(_name, _flags, common)
 
 #endif /* __TEST_COMMON_H__ */
diff --git a/include/test/env.h b/include/test/env.h
index f45e33d71a4..6a63cc972e9 100644
--- a/include/test/env.h
+++ b/include/test/env.h
@@ -10,6 +10,6 @@
 #include 
 
 /* Declare a new environment test */
-#define ENV_TEST(_name, _flags)UNIT_TEST(_name, _flags, env_test)
+#define ENV_TEST(_name, _flags)UNIT_TEST(_name, _flags, env)
 
 #endif /* __TEST_ENV_H__ */
diff --git a/include/test/hush.h b/include/test/hush.h
index cca66544a06..e57bf13ea61 100644
--- a/include/test/hush.h
+++ b/include/test/hush.h
@@ -10,6 +10,6 @@
 #include 
 
 /* Declare a new environment test */
-#define HUSH_TEST(_name, _flags)   UNIT_TEST(_name, _flags, hush_test)
+#define HUSH_TEST(_name, _flags)   UNIT_TEST(_name, _flags, hush)
 
 #endif /* __TEST_HUSH_H__ */
diff --git a/include/test/lib.h b/include/test/lib.h
index 04b6241e54a..b19eb863a33 100644
--- a/include/test/lib.h
+++ b/include/test/lib.h
@@ -9,6 +9,6 @@
 #include 
 
 /* Declare a new library function test */
-#define LIB_TEST(_name, _flags)UNIT_TEST(_name, _flags, lib_test)
+#define LIB_TEST(_name, _flags)UNIT_TEST(_name, _flags, lib)
 
 #endif /* __TEST_LIB_H__ */
diff --git a/include/test/log.h b/include/test/log.h
index e3362b85e99..0921c0c1cbc 100644
--- a/include/test/log.h
+++ b/include/test/log.h
@@ -13,8 +13,8 @@
 #define LOGF_TEST (BIT(LOGF_FUNC) | BIT(LOGF_MSG))
 
 /* Declare a new logging test */
-#define LOG_TEST(_name) UNIT_TEST(_name, UTF_CONSOLE, log_test)
+#define LOG_TEST(_name) UNIT_TEST(_name, UTF_CONSOLE, log)
 #define LOG_TEST_FLAGS(_name, _flags) \
-   UNIT_TEST(_name, _flags | UTF_CONSOLE, log_test)
+   UNIT_TEST(_name, _flags | UTF_CONSOLE, log)
 
 #endif /* __TEST_LOG_H__ */
diff --git a/include/test/optee.h b/include/test/optee.h
index a8c6e6395f5..f4255b39ee3 100644
--- a/include/test/optee.h
+++ b/include/test/optee.h
@@ -9,6 +9,6 @@
 #include 
 
 /* Declare a new environment test */
-#define OPTEE_TEST(_name, _flags)  UNIT_TEST(_name, _flags, optee_test)
+#define OPTEE_TEST(_name, _flags)  UNIT_TEST(_name, _flags, optee)
 
 #endif /* __TEST_OPTEE_H__ */
diff --git a/include/test/overlay.h b/include/test/overlay.h
index c13f4d66e09..5dc98399ce7 100644
--- a/include/test/overlay.h
+++ b/inc

[PATCH 08/43] test: Update ut info to show suites

2025-01-15 Thread Simon Glass
It is helpful to see a list of available suites. At present this is
handled by the longhelp for the 'ut' command, but this is not in a
format which can be easily parsed by python tests.

Add a -s option to show this. At present it is not possible to show the
number of tests in each suite, but future work will address this. For
now, show a ?

Signed-off-by: Simon Glass 
---

 test/cmd_ut.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index d25c2c37e7a..b6ceeb94a30 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -151,9 +151,21 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int 
argc,
 static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
+   const char *flags;
+
printf("Test suites: %d\n", (int)ARRAY_SIZE(cmd_ut_sub));
printf("Total tests: %d\n", (int)UNIT_TEST_ALL_COUNT());
 
+   flags = cmd_arg1(argc, argv);
+   if (flags && !strcmp("-s", flags)) {
+   int i;
+
+   puts("\nTests  Suite\n");
+   puts("-  -\n");
+   for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++)
+   printf("%5s  %s\n", "?", cmd_ut_sub[i].name);
+   }
+
return 0;
 }
 
@@ -184,7 +196,7 @@ U_BOOT_LONGHELP(ut,
"\n"
"\nOptions for :"
"\nall - execute all enabled tests"
-   "\ninfo - show info about tests"
+   "\ninfo [-s] - show info about tests [and suites]"
 #ifdef CONFIG_CMD_ADDRMAP
"\naddrmap - very basic test of addrmap command"
 #endif
-- 
2.34.1



[PATCH 07/43] test: Rename test suites to match their linker-list name

2025-01-15 Thread Simon Glass
Some suites have a different name from that used in the linker list.
That makes it hard to programmatically match the name printed when the
suite runs to the linker-list name it has.

Update the names so they are the same.

Signed-off-by: Simon Glass 
---

 include/test/cmd.h| 2 +-
 test/boot/upl.c   | 3 +--
 test/cmd/addrmap.c| 2 +-
 test/cmd/cmd_ut_cmd.c | 4 ++--
 test/cmd/exit.c   | 2 +-
 test/cmd/mem.c| 2 +-
 test/cmd/pci_mps.c| 2 +-
 test/cmd/setexpr.c| 2 +-
 test/dm/test-dm.c | 3 +--
 test/env/cmd_ut_env.c | 3 +--
 10 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/include/test/cmd.h b/include/test/cmd.h
index c200570e423..3d1e3e3bddb 100644
--- a/include/test/cmd.h
+++ b/include/test/cmd.h
@@ -10,6 +10,6 @@
 #include 
 
 /* Declare a new command test */
-#define CMD_TEST(_name, _flags) UNIT_TEST(_name, _flags, cmd_test)
+#define CMD_TEST(_name, _flags) UNIT_TEST(_name, _flags, cmd)
 
 #endif /* __TEST_CMD_H__ */
diff --git a/test/boot/upl.c b/test/boot/upl.c
index 99f02b7951b..ef65cf34055 100644
--- a/test/boot/upl.c
+++ b/test/boot/upl.c
@@ -432,6 +432,5 @@ int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
struct unit_test *tests = UNIT_TEST_SUITE_START(upl_test);
const int n_ents = UNIT_TEST_SUITE_COUNT(upl_test);
 
-   return cmd_ut_category("cmd_upl", "cmd_upl_", tests, n_ents, argc,
-  argv);
+   return cmd_ut_category("upl", "cmd_upl_", tests, n_ents, argc, argv);
 }
diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c
index b34be895f5d..43897615aa9 100644
--- a/test/cmd/addrmap.c
+++ b/test/cmd/addrmap.c
@@ -30,6 +30,6 @@ int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap_test);
const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap_test);
 
-   return cmd_ut_category("cmd_addrmap", "cmd_addrmap_", tests, n_ents,
+   return cmd_ut_category("addrmap", "cmd_addrmap_", tests, n_ents,
   argc, argv);
 }
diff --git a/test/cmd/cmd_ut_cmd.c b/test/cmd/cmd_ut_cmd.c
index e77fa1c7f01..ad192563c5a 100644
--- a/test/cmd/cmd_ut_cmd.c
+++ b/test/cmd/cmd_ut_cmd.c
@@ -13,8 +13,8 @@
 
 int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-   struct unit_test *tests = UNIT_TEST_SUITE_START(cmd_test);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(cmd_test);
+   struct unit_test *tests = UNIT_TEST_SUITE_START(cmd);
+   const int n_ents = UNIT_TEST_SUITE_COUNT(cmd);
 
return cmd_ut_category("cmd", "cmd_test_", tests, n_ents, argc, argv);
 }
diff --git a/test/cmd/exit.c b/test/cmd/exit.c
index af58a57fca7..cf65c05e283 100644
--- a/test/cmd/exit.c
+++ b/test/cmd/exit.c
@@ -116,6 +116,6 @@ int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
struct unit_test *tests = UNIT_TEST_SUITE_START(exit_test);
const int n_ents = UNIT_TEST_SUITE_COUNT(exit_test);
 
-   return cmd_ut_category("cmd_exit", "exit_test_", tests, n_ents,
+   return cmd_ut_category("exit", "exit_test_", tests, n_ents,
   argc, argv);
 }
diff --git a/test/cmd/mem.c b/test/cmd/mem.c
index f1bbab6055b..d6f2544a4e9 100644
--- a/test/cmd/mem.c
+++ b/test/cmd/mem.c
@@ -14,6 +14,6 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char 
*const argv[])
struct unit_test *tests = UNIT_TEST_SUITE_START(mem_test);
const int n_ents = UNIT_TEST_SUITE_COUNT(mem_test);
 
-   return cmd_ut_category("cmd_mem", "mem_test_", tests, n_ents, argc,
+   return cmd_ut_category("mem", "mem_test_", tests, n_ents, argc,
   argv);
 }
diff --git a/test/cmd/pci_mps.c b/test/cmd/pci_mps.c
index a265105600c..0c57d15d636 100644
--- a/test/cmd/pci_mps.c
+++ b/test/cmd/pci_mps.c
@@ -35,6 +35,6 @@ int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps_test);
const int n = UNIT_TEST_SUITE_COUNT(pci_mps_test);
 
-   return cmd_ut_category("cmd_pci_mps", "pci_mps_test_", tests, n,
+   return cmd_ut_category("pci_mps", "pci_mps_test_", tests, n,
   argc, argv);
 }
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index 21a3268bd81..9b3277f2ad9 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -485,6 +485,6 @@ int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr_test);
const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr_test);
 
-   return cmd_ut_category("cmd_setexpr", "setexpr_test_", tests, n_ents,
+   return cmd_ut_category("setexpr", "setexpr_test_", tests, n_ents,
   argc, argv);
 }
diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c
index 4bc2c45db61..7cfbefe02da 100644
--- a/test/dm/

[PATCH 11/43] test: Introduce a better array of test suites

2025-01-15 Thread Simon Glass
The current cmd_ut_sub[] array was fine when there were only a few test
suites. But is quite unwieldy now:

- it requires a separate do_ut_xxx for each suite, even though the code
  for most is almost identical
- running more than one suite requires running multiple commands, and
  there is no record of which suites passed or failed
- 'ut all' runs all suites but reports their results individually
- we need lots of #ifdefs in the array, mirroring those in the makefile
  but maintained in a separate place

In fact the tests are all in the same linker list. The suites are
grouped, so it is possible to access the information without a command.

Introduce a 'suite' array, which holds the cmd_ut_...() function to
call, but can also support running a suite without that function. This
means that the array of struct cmd_tbl is transformed into an array of
'struct suite'.

This will allow removal of many of the functions, particularly those
without test-specific init.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |   4 +
 test/cmd_ut.c | 205 +-
 2 files changed, 166 insertions(+), 43 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index e40ad634702..c1119e44999 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -10,6 +10,10 @@
 struct cmd_tbl;
 struct unit_test;
 
+/* 'command' functions normally called do_xxx where xxx is the command name */
+typedef int (*ut_cmd_func)(struct cmd_tbl *cmd, int flags, int argc,
+  char *const argv[]);
+
 /**
  * cmd_ut_category() - Run a category of unit tests
  *
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index b81708b3e57..10557be6d6d 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -11,6 +11,24 @@
 #include 
 #include 
 
+/**
+ * struct suite - A set of tests for a certain topic
+ *
+ * All tests end up in a single 'struct unit_test' linker-list array, in order
+ * of the suite they are in
+ *
+ * @name: Name of suite
+ * @start: First test in suite
+ * end: End test in suite (points to the first test in the next suite
+ * cmd: Command to use to run the suite
+ */
+struct suite {
+   const char *name;
+   struct unit_test *start;
+   struct unit_test *end;
+   ut_cmd_func cmd;
+};
+
 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
 char *const argv[]);
 
@@ -54,83 +72,147 @@ int cmd_ut_category(const char *name, const char *prefix,
return ret ? CMD_RET_FAILURE : 0;
 }
 
-static struct cmd_tbl cmd_ut_sub[] = {
-   U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
-   U_BOOT_CMD_MKENT(info, 1, 1, do_ut_info, "", ""),
+/* declare linker-list symbols for the start and end of a suite */
+#define SUITE_DECL(_name) \
+   ll_start_decl(suite_start_ ## _name, struct unit_test, ut_ ## _name); \
+   ll_end_decl(suite_end_ ## _name, struct unit_test, ut_ ## _name)
+
+/* declare a test suite which uses a subcommand to run */
+#define SUITE_CMD(_name, _cmd_func) { \
+   #_name, \
+   suite_start_ ## _name, \
+   suite_end_ ## _name, \
+   _cmd_func, \
+   }
+
+/* declare a test suite which can be run directly without a subcommand */
+#define SUITE(_name) { \
+   #_name, \
+   suite_start_ ## _name, \
+   suite_end_ ## _name, \
+   NULL, \
+   }
+
+SUITE_DECL(info);
+SUITE_DECL(bdinfo);
+SUITE_DECL(bootstd);
+SUITE_DECL(cmd);
+SUITE_DECL(common);
+SUITE_DECL(dm);
+SUITE_DECL(env);
+SUITE_DECL(exit);
+SUITE_DECL(fdt);
+SUITE_DECL(font);
+SUITE_DECL(optee);
+SUITE_DECL(overlay);
+SUITE_DECL(lib);
+SUITE_DECL(log);
+SUITE_DECL(mbr);
+SUITE_DECL(mem);
+SUITE_DECL(setexpr);
+SUITE_DECL(measurement);
+SUITE_DECL(bloblist);
+SUITE_DECL(bootm);
+SUITE_DECL(addrmap);
+SUITE_DECL(hush);
+SUITE_DECL(loadm);
+SUITE_DECL(pci_mps);
+SUITE_DECL(seama);
+SUITE_DECL(upl);
+
+static struct suite suites[] = {
+   SUITE_CMD(info, do_ut_info),
 #ifdef CONFIG_CMD_BDI
-   U_BOOT_CMD_MKENT(bdinfo, CONFIG_SYS_MAXARGS, 1, do_ut_bdinfo, "", ""),
+   SUITE_CMD(bdinfo, do_ut_bdinfo),
 #endif
 #ifdef CONFIG_UT_BOOTSTD
-   U_BOOT_CMD_MKENT(bootstd, CONFIG_SYS_MAXARGS, 1, do_ut_bootstd,
-"", ""),
+   SUITE_CMD(bootstd, do_ut_bootstd),
 #endif
 #ifdef CONFIG_CMDLINE
-   U_BOOT_CMD_MKENT(cmd, CONFIG_SYS_MAXARGS, 1, do_ut_cmd, "", ""),
+   SUITE_CMD(cmd, do_ut_cmd),
 #endif
-   U_BOOT_CMD_MKENT(common, CONFIG_SYS_MAXARGS, 1, do_ut_common, "", ""),
+   SUITE_CMD(common, do_ut_common),
 #if defined(CONFIG_UT_DM)
-   U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
+   SUITE_CMD(dm, do_ut_dm),
 #endif
 #if defined(CONFIG_UT_ENV)
-   U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""),
+   SUITE_CMD(env, do_ut_env),
 #endif
-   U_BOOT_CMD_MKENT(exit, CONFIG_SYS_MAXARGS, 1, do_ut_exit, "", ""),
+   SUITE_CMD(exit, do_ut_exit),
 #ifdef CONFIG_CMD_FDT
-   U_BOOT_CMD_MKENT(

[PATCH 12/43] test: Drop the function for running bdinfo tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/bdinfo.c | 8 
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index c1119e44999..b6af9295424 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix,
 
 int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[]);
 int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
index 46482b1f56b..11f717bf43e 100644
--- a/test/cmd/bdinfo.c
+++ b/test/cmd/bdinfo.c
@@ -282,11 +282,3 @@ static int bdinfo_test_eth(struct unit_test_state *uts)
return 0;
 }
 BDINFO_TEST(bdinfo_test_eth, UTF_CONSOLE);
-
-int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(bdinfo);
-
-   return cmd_ut_category("bdinfo", "bdinfo_test_", tests, n_ents, argc, 
argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 10557be6d6d..2ee9b589b52 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -123,7 +123,7 @@ SUITE_DECL(upl);
 static struct suite suites[] = {
SUITE_CMD(info, do_ut_info),
 #ifdef CONFIG_CMD_BDI
-   SUITE_CMD(bdinfo, do_ut_bdinfo),
+   SUITE(bdinfo),
 #endif
 #ifdef CONFIG_UT_BOOTSTD
SUITE_CMD(bootstd, do_ut_bootstd),
-- 
2.34.1



[PATCH 14/43] test: Drop the function for running common tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h   |  1 -
 test/cmd_ut.c   |  2 +-
 test/common/Makefile|  1 -
 test/common/cmd_ut_common.c | 21 -
 4 files changed, 1 insertion(+), 24 deletions(-)
 delete mode 100644 test/common/cmd_ut_common.c

diff --git a/include/test/suites.h b/include/test/suites.h
index 21158692e9b..d6c0061ff87 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 761556cc763..4b529cbd699 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -131,7 +131,7 @@ static struct suite suites[] = {
 #ifdef CONFIG_CMDLINE
SUITE(cmd),
 #endif
-   SUITE_CMD(common, do_ut_common),
+   SUITE(common),
 #if defined(CONFIG_UT_DM)
SUITE_CMD(dm, do_ut_dm),
 #endif
diff --git a/test/common/Makefile b/test/common/Makefile
index 53c4f16164d..9cfb5585d78 100644
--- a/test/common/Makefile
+++ b/test/common/Makefile
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
-obj-y += cmd_ut_common.o
 obj-$(CONFIG_AUTOBOOT) += test_autoboot.o
 ifneq ($(CONFIG_$(XPL_)BLOBLIST),)
 obj-$(CONFIG_$(XPL_)CMDLINE) += bloblist.o
diff --git a/test/common/cmd_ut_common.c b/test/common/cmd_ut_common.c
deleted file mode 100644
index 0724c9361b8..000
--- a/test/common/cmd_ut_common.c
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2019 Heinrich Schuchardt 
- * Copyright (c) 2021 Steffen Jaeckel 
- *
- * Unit tests for common functions
- */
-
-#include 
-#include 
-#include 
-#include 
-
-int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(common);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(common);
-
-   return cmd_ut_category("common", "common_test_", tests, n_ents, argc,
-  argv);
-}
-- 
2.34.1



[PATCH 15/43] test: Drop the function for running dm tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  1 -
 test/cmd_ut.c |  2 +-
 test/dm/Makefile  |  2 --
 test/dm/test-dm.c | 15 ---
 4 files changed, 1 insertion(+), 19 deletions(-)
 delete mode 100644 test/dm/test-dm.c

diff --git a/include/test/suites.h b/include/test/suites.h
index d6c0061ff87..414613c593e 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 4b529cbd699..a3dcbef1740 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -133,7 +133,7 @@ static struct suite suites[] = {
 #endif
SUITE(common),
 #if defined(CONFIG_UT_DM)
-   SUITE_CMD(dm, do_ut_dm),
+   SUITE(dm),
 #endif
 #if defined(CONFIG_UT_ENV)
SUITE_CMD(env, do_ut_env),
diff --git a/test/dm/Makefile b/test/dm/Makefile
index bcb52ef1067..e44f3d89e77 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -3,8 +3,6 @@
 # Copyright (c) 2013 Google, Inc
 # Copyright 2022-2023 Arm Limited and/or its affiliates 

 
-obj-$(CONFIG_UT_DM) += test-dm.o
-
 # Tests for particular subsystems - when enabling driver model for a new
 # subsystem you must add sandbox tests here.
 ifeq ($(CONFIG_XPL_BUILD),y)
diff --git a/test/dm/test-dm.c b/test/dm/test-dm.c
deleted file mode 100644
index 8f83110163a..000
--- a/test/dm/test-dm.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2013 Google, Inc
- */
-
-#include 
-#include 
-
-int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(dm);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(dm);
-
-   return cmd_ut_category("dm", "dm_test_", tests, n_ents, argc, argv);
-}
-- 
2.34.1



[PATCH 16/43] test: Drop the function for running env tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd_ut.c | 2 +-
 test/env/cmd_ut_env.c | 9 -
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 414613c593e..b78436fe2b2 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index a3dcbef1740..a34998605cc 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -136,7 +136,7 @@ static struct suite suites[] = {
SUITE(dm),
 #endif
 #if defined(CONFIG_UT_ENV)
-   SUITE_CMD(env, do_ut_env),
+   SUITE(env),
 #endif
SUITE_CMD(exit, do_ut_exit),
 #ifdef CONFIG_CMD_FDT
diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c
index 332139bb803..81d1bb2f80d 100644
--- a/test/env/cmd_ut_env.c
+++ b/test/env/cmd_ut_env.c
@@ -4,7 +4,6 @@
  * Joe Hershberger, National Instruments, joe.hershber...@ni.com
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -74,11 +73,3 @@ static int env_test_env_cmd(struct unit_test_state *uts)
return 0;
 }
 ENV_TEST(env_test_env_cmd, UTF_CONSOLE);
-
-int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(env);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(env);
-
-   return cmd_ut_category("env", "env_test_", tests, n_ents, argc, argv);
-}
-- 
2.34.1



[PATCH 18/43] test: Drop the function for running fdt tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/fdt.c| 8 
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 70b9af1fd05..bf3a9851322 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c
index 74fd603bb02..ab6dbd45e54 100644
--- a/test/cmd/fdt.c
+++ b/test/cmd/fdt.c
@@ -1462,11 +1462,3 @@ static int fdt_test_apply(struct unit_test_state *uts)
return 0;
 }
 FDT_TEST(fdt_test_apply, UTF_CONSOLE);
-
-int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(fdt);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(fdt);
-
-   return cmd_ut_category("fdt", "fdt_test_", tests, n_ents, argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 88a32129f0a..f6c28c73981 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -140,7 +140,7 @@ static struct suite suites[] = {
 #endif
SUITE(exit),
 #ifdef CONFIG_CMD_FDT
-   SUITE_CMD(fdt, do_ut_fdt),
+   SUITE(fdt),
 #endif
 #ifdef CONFIG_CONSOLE_TRUETYPE
SUITE_CMD(font, do_ut_font),
-- 
2.34.1



[PATCH 13/43] test: Drop the function for running cmd tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  1 -
 test/cmd/Makefile |  2 --
 test/cmd/cmd_ut_cmd.c | 20 
 test/cmd_ut.c |  2 +-
 4 files changed, 1 insertion(+), 24 deletions(-)
 delete mode 100644 test/cmd/cmd_ut_cmd.c

diff --git a/include/test/suites.h b/include/test/suites.h
index b6af9295424..21158692e9b 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[]);
 int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 583e7c2eec4..f83c53696d0 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -3,8 +3,6 @@
 # Copyright (c) 2013 Google, Inc
 # Copyright 2022-2023 Arm Limited and/or its affiliates 

 
-obj-y += cmd_ut_cmd.o
-
 obj-$(CONFIG_$(XPL_)CMDLINE) += command.o
 ifdef CONFIG_HUSH_PARSER
 obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
diff --git a/test/cmd/cmd_ut_cmd.c b/test/cmd/cmd_ut_cmd.c
deleted file mode 100644
index ad192563c5a..000
--- a/test/cmd/cmd_ut_cmd.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright 2023 Google LLC
- * Written by Simon Glass 
- *
- * Unit tests for command functions
- */
-
-#include 
-#include 
-#include 
-#include 
-
-int do_ut_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(cmd);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(cmd);
-
-   return cmd_ut_category("cmd", "cmd_test_", tests, n_ents, argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 2ee9b589b52..761556cc763 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -129,7 +129,7 @@ static struct suite suites[] = {
SUITE_CMD(bootstd, do_ut_bootstd),
 #endif
 #ifdef CONFIG_CMDLINE
-   SUITE_CMD(cmd, do_ut_cmd),
+   SUITE(cmd),
 #endif
SUITE_CMD(common, do_ut_common),
 #if defined(CONFIG_UT_DM)
-- 
2.34.1



[PATCH 17/43] test: Drop the function for running exit tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/exit.c   | 9 -
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index b78436fe2b2..70b9af1fd05 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/exit.c b/test/cmd/exit.c
index d1eacdc36c2..71c37edcdf6 100644
--- a/test/cmd/exit.c
+++ b/test/cmd/exit.c
@@ -110,12 +110,3 @@ static int cmd_exit_test(struct unit_test_state *uts)
return 0;
 }
 EXIT_TEST(cmd_exit_test, UTF_CONSOLE);
-
-int do_ut_exit(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(exit);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(exit);
-
-   return cmd_ut_category("exit", "exit_test_", tests, n_ents,
-  argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index a34998605cc..88a32129f0a 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -138,7 +138,7 @@ static struct suite suites[] = {
 #if defined(CONFIG_UT_ENV)
SUITE(env),
 #endif
-   SUITE_CMD(exit, do_ut_exit),
+   SUITE(exit),
 #ifdef CONFIG_CMD_FDT
SUITE_CMD(fdt, do_ut_fdt),
 #endif
-- 
2.34.1



[PATCH 23/43] test: Drop the function for running mem tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  1 -
 test/cmd/Makefile |  2 +-
 test/cmd/mem.c| 19 ---
 test/cmd_ut.c |  2 +-
 4 files changed, 2 insertions(+), 22 deletions(-)
 delete mode 100644 test/cmd/mem.c

diff --git a/include/test/suites.h b/include/test/suites.h
index 612167fe053..cb6b6fba240 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -40,7 +40,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[]);
-int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index f83c53696d0..d8a5e77402d 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -10,7 +10,7 @@ endif
 ifdef CONFIG_CONSOLE_RECORD
 obj-$(CONFIG_CMD_PAUSE) += test_pause.o
 endif
-obj-y += exit.o mem.o
+obj-y += exit.o
 obj-$(CONFIG_X86) += cpuid.o msr.o
 obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
diff --git a/test/cmd/mem.c b/test/cmd/mem.c
deleted file mode 100644
index 2b78e421a9c..000
--- a/test/cmd/mem.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Executes tests for memory-related commands
- *
- * Copyright 2020 Google LLC
- */
-
-#include 
-#include 
-#include 
-
-int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(mem);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(mem);
-
-   return cmd_ut_category("mem", "mem_test_", tests, n_ents, argc,
-  argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f5fbcf0d686..4e57fcf0005 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -161,7 +161,7 @@ static struct suite suites[] = {
 && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE)
SUITE(mbr),
 #endif
-   SUITE_CMD(mem, do_ut_mem),
+   SUITE(mem),
 #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
SUITE_CMD(setexpr, do_ut_setexpr),
 #endif
-- 
2.34.1



[PATCH 21/43] test: Drop the function for running log tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  1 -
 test/cmd_ut.c |  2 +-
 test/log/Makefile |  2 --
 test/log/log_ut.c | 20 
 4 files changed, 1 insertion(+), 24 deletions(-)
 delete mode 100644 test/log/log_ut.c

diff --git a/include/test/suites.h b/include/test/suites.h
index 08b35b276be..72f98eb3558 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -39,7 +39,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[]);
 int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index ba101a48b98..c490498b4c5 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -155,7 +155,7 @@ static struct suite suites[] = {
SUITE(lib),
 #endif
 #ifdef CONFIG_UT_LOG
-   SUITE_CMD(log, do_ut_log),
+   SUITE(log),
 #endif
 #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && 
defined(CONFIG_CMD_MMC) \
 && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE)
diff --git a/test/log/Makefile b/test/log/Makefile
index 08eea70e344..24b7c46786d 100644
--- a/test/log/Makefile
+++ b/test/log/Makefile
@@ -7,8 +7,6 @@ obj-$(CONFIG_CMD_LOG) += log_filter.o
 
 ifdef CONFIG_UT_LOG
 
-obj-y += log_ut.o
-
 ifdef CONFIG_SANDBOX
 obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o
 obj-$(CONFIG_LOG_SYSLOG) += syslog_test_ndebug.o
diff --git a/test/log/log_ut.c b/test/log/log_ut.c
deleted file mode 100644
index 2aa3afe286a..000
--- a/test/log/log_ut.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2020, Heinrich Schuchardt 
- *
- * Logging function tests.
- */
-
-#include 
-#include 
-#include 
-#include 
-
-int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(log);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(log);
-
-   return cmd_ut_category("log", "log_test_",
-  tests, n_ents, argc, argv);
-}
-- 
2.34.1



[PATCH 22/43] test: Drop the function for running mbr tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/mbr.c| 8 
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 72f98eb3558..612167fe053 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -39,7 +39,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[]);
 int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c
index ad859921ce5..45bab04923a 100644
--- a/test/cmd/mbr.c
+++ b/test/cmd/mbr.c
@@ -471,11 +471,3 @@ static int mbr_test_run(struct unit_test_state *uts)
 
 /* Declare mbr test */
 UNIT_TEST(mbr_test_run, UTF_CONSOLE, mbr);
-
-int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(mbr);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(mbr);
-
-   return cmd_ut_category("mbr", "mbr_test_", tests, n_ents, argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index c490498b4c5..f5fbcf0d686 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -159,7 +159,7 @@ static struct suite suites[] = {
 #endif
 #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && 
defined(CONFIG_CMD_MMC) \
 && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE)
-   SUITE_CMD(mbr, do_ut_mbr),
+   SUITE(mbr),
 #endif
SUITE_CMD(mem, do_ut_mem),
 #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
-- 
2.34.1



[PATCH 19/43] test: Drop the function for running font tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/font.c   | 8 
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index bf3a9851322..587d6a5b473 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -37,7 +37,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
-int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/font.c b/test/cmd/font.c
index d860efe8ce5..af88d1b5459 100644
--- a/test/cmd/font.c
+++ b/test/cmd/font.c
@@ -85,11 +85,3 @@ static int font_test_base(struct unit_test_state *uts)
 }
 FONT_TEST(font_test_base, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_CONSOLE |
  UTF_DM);
-
-int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(font);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(font);
-
-   return cmd_ut_category("font", "font_test_", tests, n_ents, argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f6c28c73981..f9cf7b93412 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -143,7 +143,7 @@ static struct suite suites[] = {
SUITE(fdt),
 #endif
 #ifdef CONFIG_CONSOLE_TRUETYPE
-   SUITE_CMD(font, do_ut_font),
+   SUITE(font),
 #endif
 #ifdef CONFIG_UT_OPTEE
SUITE_CMD(optee, do_ut_optee),
-- 
2.34.1



[PATCH 20/43] test: Drop the function for running lib tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  1 -
 test/cmd_ut.c |  2 +-
 test/lib/Makefile |  1 -
 test/lib/cmd_ut_lib.c | 19 ---
 4 files changed, 1 insertion(+), 22 deletions(-)
 delete mode 100644 test/lib/cmd_ut_lib.c

diff --git a/include/test/suites.h b/include/test/suites.h
index 587d6a5b473..08b35b276be 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -38,7 +38,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f9cf7b93412..ba101a48b98 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -152,7 +152,7 @@ static struct suite suites[] = {
SUITE_CMD(overlay, do_ut_overlay),
 #endif
 #ifdef CONFIG_UT_LIB
-   SUITE_CMD(lib, do_ut_lib),
+   SUITE(lib),
 #endif
 #ifdef CONFIG_UT_LOG
SUITE_CMD(log, do_ut_log),
diff --git a/test/lib/Makefile b/test/lib/Makefile
index 3556c4d199c..f38f4947157 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -6,7 +6,6 @@
 obj-$(CONFIG_$(XPL_)UT_COMPRESSION) += compression.o
 
 ifeq ($(CONFIG_XPL_BUILD),)
-obj-y += cmd_ut_lib.o
 obj-y += abuf.o
 obj-y += alist.o
 obj-$(CONFIG_EFI_LOADER) += efi_device_path.o
diff --git a/test/lib/cmd_ut_lib.c b/test/lib/cmd_ut_lib.c
deleted file mode 100644
index 90a8c0728b7..000
--- a/test/lib/cmd_ut_lib.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2019 Heinrich Schuchardt 
- *
- * Unit tests for library functions
- */
-
-#include 
-#include 
-#include 
-#include 
-
-int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(lib);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(lib);
-
-   return cmd_ut_category("lib", "lib_test_", tests, n_ents, argc, argv);
-}
-- 
2.34.1



[PATCH 27/43] test: Drop the function for running bootm tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/boot/bootm.c | 9 -
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 32b7e8e3d5a..77af692be3c 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix,
 
 int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/boot/bootm.c b/test/boot/bootm.c
index c8e32023acb..1ce5c3cd6bf 100644
--- a/test/boot/bootm.c
+++ b/test/boot/bootm.c
@@ -256,12 +256,3 @@ static int bootm_test_subst_both(struct unit_test_state 
*uts)
return 0;
 }
 BOOTM_TEST(bootm_test_subst_both, 0);
-
-int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(bootm);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(bootm);
-
-   return cmd_ut_category("bootm", "bootm_test_", tests, n_ents,
-  argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index e0e01510016..eb5ef099cb8 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -170,7 +170,7 @@ static struct suite suites[] = {
 #endif
 #ifdef CONFIG_SANDBOX
SUITE(bloblist),
-   SUITE_CMD(bootm, do_ut_bootm),
+   SUITE(bootm),
 #endif
 #ifdef CONFIG_CMD_ADDRMAP
SUITE_CMD(addrmap, do_ut_addrmap),
-- 
2.34.1



[PATCH 24/43] test: Drop the function for running setexpr tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 2 --
 test/cmd/setexpr.c| 9 -
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index cb6b6fba240..775b0a5a131 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -46,8 +46,6 @@ int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
 int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c
index 49eac5890aa..7f318a42ead 100644
--- a/test/cmd/setexpr.c
+++ b/test/cmd/setexpr.c
@@ -479,12 +479,3 @@ static int setexpr_test_fmt(struct unit_test_state *uts)
 }
 SETEXPR_TEST(setexpr_test_fmt, UTF_CONSOLE);
 #endif
-
-int do_ut_setexpr(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(setexpr);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(setexpr);
-
-   return cmd_ut_category("setexpr", "setexpr_test_", tests, n_ents,
-  argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 4e57fcf0005..c53b24bfde9 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -163,7 +163,7 @@ static struct suite suites[] = {
 #endif
SUITE(mem),
 #if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
-   SUITE_CMD(setexpr, do_ut_setexpr),
+   SUITE(setexpr),
 #endif
 #ifdef CONFIG_MEASURED_BOOT
SUITE_CMD(measurement, do_ut_measurement),
-- 
2.34.1



[PATCH 30/43] test: Drop the function for running loadm tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/loadm.c  | 9 -
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index b96a78f7129..f6b33da5a28 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix,
 
 int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
diff --git a/test/cmd/loadm.c b/test/cmd/loadm.c
index 78bb12ce88c..3c623aa655f 100644
--- a/test/cmd/loadm.c
+++ b/test/cmd/loadm.c
@@ -58,12 +58,3 @@ static int loadm_test_load (struct unit_test_state *uts)
return 0;
 }
 LOADM_TEST(loadm_test_load, UTF_CONSOLE);
-
-int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(loadm);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(loadm);
-
-   return cmd_ut_category("loadm", "loadm_test_", tests, n_ents, argc,
-  argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 39489ba0811..0a6284e4962 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -179,7 +179,7 @@ static struct suite suites[] = {
SUITE(hush),
 #endif
 #ifdef CONFIG_CMD_LOADM
-   SUITE_CMD(loadm, do_ut_loadm),
+   SUITE(loadm),
 #endif
 #ifdef CONFIG_CMD_PCI_MPS
SUITE_CMD(pci_mps, do_ut_pci_mps),
-- 
2.34.1



[PATCH 33/43] test: Drop the function for running upl tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

It is not clear that these actually work, since they are not enabled on
sandbox for some reason.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/boot/upl.c   | 8 
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index cd758b8c464..20e6a2a113b 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -35,6 +35,5 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/test/boot/upl.c b/test/boot/upl.c
index 2c9b8bc8bc0..aa58cdf083b 100644
--- a/test/boot/upl.c
+++ b/test/boot/upl.c
@@ -426,11 +426,3 @@ static int upl_test_info_norun(struct unit_test_state *uts)
return 0;
 }
 UPL_TEST(upl_test_info_norun, UTF_CONSOLE | UTF_MANUAL);
-
-int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(upl);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(upl);
-
-   return cmd_ut_category("upl", "cmd_upl_", tests, n_ents, argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index c6b7ccdedbd..0d055119ce3 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -188,7 +188,7 @@ static struct suite suites[] = {
SUITE(seama),
 #endif
 #ifdef CONFIG_CMD_UPL
-   SUITE_CMD(upl, do_ut_upl),
+   SUITE(upl),
 #endif
 };
 
-- 
2.34.1



[PATCH 31/43] test: Drop the function for running pci_mps tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h |  2 --
 test/cmd/pci_mps.c| 10 --
 test/cmd_ut.c |  2 +-
 3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index f6b33da5a28..49c18ebf456 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -35,8 +35,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
 int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
diff --git a/test/cmd/pci_mps.c b/test/cmd/pci_mps.c
index 2595ea103ff..8b3ea4a6134 100644
--- a/test/cmd/pci_mps.c
+++ b/test/cmd/pci_mps.c
@@ -28,13 +28,3 @@ static int test_pci_mps_safe(struct unit_test_state *uts)
return 0;
 }
 PCI_MPS_TEST(test_pci_mps_safe, UTF_CONSOLE);
-
-int do_ut_pci_mps(struct cmd_tbl *cmdtp, int flag, int argc,
- char * const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(pci_mps);
-   const int n = UNIT_TEST_SUITE_COUNT(pci_mps);
-
-   return cmd_ut_category("pci_mps", "pci_mps_test_", tests, n,
-  argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 0a6284e4962..7caf41da096 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -182,7 +182,7 @@ static struct suite suites[] = {
SUITE(loadm),
 #endif
 #ifdef CONFIG_CMD_PCI_MPS
-   SUITE_CMD(pci_mps, do_ut_pci_mps),
+   SUITE(pci_mps),
 #endif
 #ifdef CONFIG_CMD_SEAMA
SUITE_CMD(seama, do_ut_seama),
-- 
2.34.1



[PATCH 29/43] test: Drop the function for running hush tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h   |  1 -
 test/cmd_ut.c   |  2 +-
 test/hush/Makefile  |  1 -
 test/hush/cmd_ut_hush.c | 19 ---
 4 files changed, 1 insertion(+), 22 deletions(-)
 delete mode 100644 test/hush/cmd_ut_hush.c

diff --git a/include/test/suites.h b/include/test/suites.h
index 54fddaa6bac..b96a78f7129 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -32,7 +32,6 @@ int cmd_ut_category(const char *name, const char *prefix,
 
 int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f68da4dcf76..39489ba0811 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -176,7 +176,7 @@ static struct suite suites[] = {
SUITE(addrmap),
 #endif
 #if CONFIG_IS_ENABLED(HUSH_PARSER)
-   SUITE_CMD(hush, do_ut_hush),
+   SUITE(hush),
 #endif
 #ifdef CONFIG_CMD_LOADM
SUITE_CMD(loadm, do_ut_loadm),
diff --git a/test/hush/Makefile b/test/hush/Makefile
index 4c3a0be857a..febdc82e8aa 100644
--- a/test/hush/Makefile
+++ b/test/hush/Makefile
@@ -3,7 +3,6 @@
 # (C) Copyright 2021
 # Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
 
-obj-y += cmd_ut_hush.o
 obj-y += if.o
 ifdef CONFIG_CONSOLE_RECORD
 obj-y += dollar.o
diff --git a/test/hush/cmd_ut_hush.c b/test/hush/cmd_ut_hush.c
deleted file mode 100644
index 141203d766b..000
--- a/test/hush/cmd_ut_hush.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * (C) Copyright 2021
- * Francis Laniel, Amarula Solutions, francis.lan...@amarulasolutions.com
- */
-
-#include 
-#include 
-#include 
-#include 
-
-int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(hush);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(hush);
-
-   return cmd_ut_category("hush", "hush_test_",
-  tests, n_ents, argc, argv);
-}
-- 
2.34.1



[PATCH 32/43] test: Drop the function for running seama tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

It is not clear that these actually work, since they are not enabled on
sandbox for some reason.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 1 -
 test/cmd/seama.c  | 9 -
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 49c18ebf456..cd758b8c464 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -35,7 +35,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_upl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/test/cmd/seama.c b/test/cmd/seama.c
index 39590d162ac..1edc3fcac5a 100644
--- a/test/cmd/seama.c
+++ b/test/cmd/seama.c
@@ -56,12 +56,3 @@ static int seama_test_index(struct unit_test_state *uts)
return 0;
 }
 SEAMA_TEST(seama_test_index, UTF_CONSOLE);
-
-int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(seama);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(seama);
-
-   return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc,
-  argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 7caf41da096..c6b7ccdedbd 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -185,7 +185,7 @@ static struct suite suites[] = {
SUITE(pci_mps),
 #endif
 #ifdef CONFIG_CMD_SEAMA
-   SUITE_CMD(seama, do_ut_seama),
+   SUITE(seama),
 #endif
 #ifdef CONFIG_CMD_UPL
SUITE_CMD(upl, do_ut_upl),
-- 
2.34.1



[PATCH 28/43] test: Drop the function for running addrmap tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 2 --
 test/cmd/addrmap.c| 9 -
 test/cmd_ut.c | 2 +-
 3 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 77af692be3c..54fddaa6bac 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -30,8 +30,6 @@ int cmd_ut_category(const char *name, const char *prefix,
struct unit_test *tests, int n_ents,
int argc, char *const argv[]);
 
-int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
 int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c
index fd0117102e2..1f2deb15052 100644
--- a/test/cmd/addrmap.c
+++ b/test/cmd/addrmap.c
@@ -24,12 +24,3 @@ static int addrmap_test_basic(struct unit_test_state *uts)
return 0;
 }
 ADDRMAP_TEST(addrmap_test_basic, UTF_CONSOLE);
-
-int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap);
-
-   return cmd_ut_category("addrmap", "cmd_addrmap_", tests, n_ents,
-  argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index eb5ef099cb8..f68da4dcf76 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -173,7 +173,7 @@ static struct suite suites[] = {
SUITE(bootm),
 #endif
 #ifdef CONFIG_CMD_ADDRMAP
-   SUITE_CMD(addrmap, do_ut_addrmap),
+   SUITE(addrmap),
 #endif
 #if CONFIG_IS_ENABLED(HUSH_PARSER)
SUITE_CMD(hush, do_ut_hush),
-- 
2.34.1



[PATCH 26/43] test: Drop the function for running bloblist tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h  |  2 --
 test/cmd_ut.c  |  2 +-
 test/common/bloblist.c | 10 --
 3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 1a40af6599a..32b7e8e3d5a 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -35,8 +35,6 @@ int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
-int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
-  char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 6f5aa7e4924..e0e01510016 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -169,7 +169,7 @@ static struct suite suites[] = {
SUITE(measurement),
 #endif
 #ifdef CONFIG_SANDBOX
-   SUITE_CMD(bloblist, do_ut_bloblist),
+   SUITE(bloblist),
SUITE_CMD(bootm, do_ut_bootm),
 #endif
 #ifdef CONFIG_CMD_ADDRMAP
diff --git a/test/common/bloblist.c b/test/common/bloblist.c
index f5d98774862..9467abfa8e1 100644
--- a/test/common/bloblist.c
+++ b/test/common/bloblist.c
@@ -602,13 +602,3 @@ static int bloblist_test_blob_maxsize(struct 
unit_test_state *uts)
return 0;
 }
 BLOBLIST_TEST(bloblist_test_blob_maxsize, UFT_BLOBLIST);
-
-int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
-  char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(bloblist);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(bloblist);
-
-   return cmd_ut_category("bloblist", "bloblist_test_",
-  tests, n_ents, argc, argv);
-}
-- 
2.34.1



[PATCH 25/43] test: Drop the function for running measurement tests

2025-01-15 Thread Simon Glass
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass 
---

 include/test/suites.h   |  1 -
 test/boot/measurement.c | 10 --
 test/cmd_ut.c   |  2 +-
 3 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 775b0a5a131..1a40af6599a 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -39,7 +39,6 @@ int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[]);
 int do_ut_hush(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const 
argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
diff --git a/test/boot/measurement.c b/test/boot/measurement.c
index 018e8af45f0..5a49c7a6b23 100644
--- a/test/boot/measurement.c
+++ b/test/boot/measurement.c
@@ -53,13 +53,3 @@ static int measure(struct unit_test_state *uts)
return 0;
 }
 MEASUREMENT_TEST(measure, 0);
-
-int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
-{
-   struct unit_test *tests = UNIT_TEST_SUITE_START(measurement);
-   const int n_ents = UNIT_TEST_SUITE_COUNT(measurement);
-
-   return cmd_ut_category("measurement", "measurement_test_", tests,
-  n_ents, argc, argv);
-}
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index c53b24bfde9..6f5aa7e4924 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -166,7 +166,7 @@ static struct suite suites[] = {
SUITE(setexpr),
 #endif
 #ifdef CONFIG_MEASURED_BOOT
-   SUITE_CMD(measurement, do_ut_measurement),
+   SUITE(measurement),
 #endif
 #ifdef CONFIG_SANDBOX
SUITE_CMD(bloblist, do_ut_bloblist),
-- 
2.34.1



[PATCH 37/43] test: Move stats into a struct

2025-01-15 Thread Simon Glass
Use a struct to hold the stats, since we also want to have the same
stats for all runs as we have for each suite.

Signed-off-by: Simon Glass 
---

 include/test/test.h | 17 +
 test/test-main.c| 29 +++--
 test/ut.c   |  4 ++--
 3 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/include/test/test.h b/include/test/test.h
index 21c0478befe..bc8f0bbe501 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -9,11 +9,21 @@
 #include 
 #include 
 
-/*
- * struct unit_test_state - Entire state of test system
+/**
+ * struct ut_stats - Statistics about tests run
  *
  * @fail_count: Number of tests that failed
  * @skip_count: Number of tests that were skipped
+ */
+struct ut_stats {
+   int fail_count;
+   int skip_count;
+};
+
+/*
+ * struct unit_test_state - Entire state of test system
+ *
+ * @cur: Statistics for the current run
  * @start: Store the starting mallinfo when doing leak test
  * @of_live: true to use livetree if available, false to use flattree
  * @of_root: Record of the livetree root node (used for setting up tests)
@@ -34,8 +44,7 @@
  * @actual_str: Temporary string used to hold actual string value
  */
 struct unit_test_state {
-   int fail_count;
-   int skip_count;
+   struct ut_stats cur;
struct mallinfo start;
struct device_node *of_root;
bool of_live;
diff --git a/test/test-main.c b/test/test-main.c
index 391d4e7bb0e..e8aecd267c7 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -448,7 +448,7 @@ static int test_post_run(struct unit_test_state *uts, 
struct unit_test *test)
  */
 static int skip_test(struct unit_test_state *uts)
 {
-   uts->skip_count++;
+   uts->cur.skip_count++;
 
return -EAGAIN;
 }
@@ -460,7 +460,7 @@ static int skip_test(struct unit_test_state *uts)
  * the name of each test before running it.
  *
  * @uts: Test state to update. The caller should ensure that this is zeroed for
- * the first call to this function. On exit, @uts->fail_count is
+ * the first call to this function. On exit, @uts->cur.fail_count is
  * incremented by the number of failures (0, one hopes)
  * @test_name: Test to run
  * @name: Name of test, possibly skipping a prefix that should not be displayed
@@ -510,7 +510,7 @@ static int ut_run_test(struct unit_test_state *uts, struct 
unit_test *test,
  * SPL.
  *
  * @uts: Test state to update. The caller should ensure that this is zeroed for
- * the first call to this function. On exit, @uts->fail_count is
+ * the first call to this function. On exit, @uts->cur.fail_count is
  * incremented by the number of failures (0, one hopes)
  * @test: Test to run
  * Return: 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if
@@ -574,7 +574,7 @@ static int ut_run_test_live_flat(struct unit_test_state 
*uts,
  * the name of each test before running it.
  *
  * @uts: Test state to update. The caller should ensure that this is zeroed for
- * the first call to this function. On exit, @uts->fail_count is
+ * the first call to this function. On exit, @uts->cur.fail_count is
  * incremented by the number of failures (0, one hopes)
  * @prefix: String prefix for the tests. Any tests that have this prefix will 
be
  * printed without the prefix, so that it is easier to see the unique part
@@ -632,7 +632,7 @@ static int ut_run_tests(struct unit_test_state *uts, const 
char *prefix,
if (len < 6 || strcmp(test_name + len - 6, "_norun")) {
printf("Test '%s' is manual so must have a name 
ending in _norun\n",
   test_name);
-   uts->fail_count++;
+   uts->cur.fail_count++;
return -EBADF;
}
if (!uts->force_run) {
@@ -641,23 +641,24 @@ static int ut_run_tests(struct unit_test_state *uts, 
const char *prefix,
continue;
}
}
-   old_fail_count = uts->fail_count;
+   old_fail_count = uts->cur.fail_count;
 
if (one && upto == pos) {
ret = ut_run_test_live_flat(uts, one);
-   if (uts->fail_count != old_fail_count) {
+   if (uts->cur.fail_count != old_fail_count) {
printf("Test '%s' failed %d times (position 
%d)\n",
   one->name,
-  uts->fail_count - old_fail_count, pos);
+  uts->cur.fail_count - old_fail_count,
+  pos);
}
return -EBADF;
}
 
for (i = 0; i < uts->runs_per_test; i++)
ret = ut_run_test_live_flat(uts, test

[PATCH 36/43] test: Pass the test state to cmd_ut_category()

2025-01-15 Thread Simon Glass
Update this function to access a unit-test state, so that the caller can
collect results from running multiple suites.

Signed-off-by: Simon Glass 
---

 include/test/suites.h | 20 +++
 test/boot/bootstd_common.c|  7 ---
 test/cmd_ut.c | 37 ++-
 test/overlay/cmd_ut_overlay.c | 10 +++---
 4 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/include/test/suites.h b/include/test/suites.h
index 20e6a2a113b..774dd893378 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -9,14 +9,18 @@
 
 struct cmd_tbl;
 struct unit_test;
+struct unit_test_state;
 
 /* 'command' functions normally called do_xxx where xxx is the command name */
-typedef int (*ut_cmd_func)(struct cmd_tbl *cmd, int flags, int argc,
-  char *const argv[]);
+typedef int (*ut_cmd_func)(struct unit_test_state *uts, struct cmd_tbl *cmd,
+  int flags, int argc, char *const argv[]);
 
 /**
  * cmd_ut_category() - Run a category of unit tests
  *
+ * @uts: Unit-test state, which must be ready for use, i.e. ut_init_state()
+ * has been called. The caller is responsible for calling
+ * ut_uninit_state() after this function returns
  * @name:  Category name
  * @prefix:Prefix of test name
  * @tests: List of tests to run
@@ -26,14 +30,14 @@ typedef int (*ut_cmd_func)(struct cmd_tbl *cmd, int flags, 
int argc,
  * @argv:  Arguments: argv[1] is the test to run (if @argc >= 2)
  * Return: 0 if OK, CMD_RET_FAILURE on failure
  */
-int cmd_ut_category(const char *name, const char *prefix,
-   struct unit_test *tests, int n_ents,
+int cmd_ut_category(struct unit_test_state *uts, const char *name,
+   const char *prefix, struct unit_test *tests, int n_ents,
int argc, char *const argv[]);
 
-int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
+int do_ut_bootstd(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[]);
 int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
-int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[]);
+int do_ut_overlay(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[]);
 
 #endif /* __TEST_SUITES_H__ */
diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c
index 6bd9bb65a40..724e3d9bdd2 100644
--- a/test/boot/bootstd_common.c
+++ b/test/boot/bootstd_common.c
@@ -94,7 +94,8 @@ void bootstd_reset_usb(void)
usb_started = false;
 }
 
-int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
+int do_ut_bootstd(struct unit_test_state *uts, struct cmd_tbl *cmdtp, int flag,
+ int argc, char *const argv[])
 {
struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd);
const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd);
@@ -106,6 +107,6 @@ int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
return CMD_RET_FAILURE;
}
 
-   return cmd_ut_category("bootstd", "bootstd_", tests, n_ents,
-  argc, argv);
+   return cmd_ut_category(uts, "bootstd", "bootstd_",
+  tests, n_ents, argc, argv);
 }
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 2ba99a26c63..f315c442abf 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -29,17 +29,16 @@ struct suite {
ut_cmd_func cmd;
 };
 
-static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
-char *const argv[]);
+static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp,
+int flag, int argc, char *const argv[]);
 
 static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[]);
 
-int cmd_ut_category(const char *name, const char *prefix,
-   struct unit_test *tests, int n_ents,
+int cmd_ut_category(struct unit_test_state *uts, const char *name,
+   const char *prefix, struct unit_test *tests, int n_ents,
int argc, char *const argv[])
 {
-   struct unit_test_state uts;
const char *test_insert = NULL;
int runs_per_text = 1;
bool force_run = false;
@@ -63,11 +62,9 @@ int cmd_ut_category(const char *name, const char *prefix,
argc--;
}
 
-   ut_init_state(&uts);
-   ret = ut_run_list(&uts, name, prefix, tests, n_ents,
+   ret = ut_run_list(uts, name, prefix, tests, n_ents,
  cmd_arg1(argc, argv), runs_per_text, force_run,
  test_insert);
-   ut_uninit_state(&uts);
 
return ret ? CMD_RET_FAILURE : 0;
 }
@@ -170,28 +167,29 @@ static bool has_tests(struct suite *ste)
 }
 
 /** run_suite() - Run a su

[PATCH 35/43] test: Drop conditional compilation for suites

2025-01-15 Thread Simon Glass
This is not needed anymore. If a test suite is not built, then it will
have no linker-list entries. So we can just check for that and know that
the suite is not present.

This allows removal of the #ifdefs and the need to keep them in sync
with the associated Makefile rules, which has actually failed, since the
help does not match what commands are actually present.

Signed-off-by: Simon Glass 
---

 test/cmd_ut.c   | 75 -
 test/py/tests/test_suite.py | 19 +++---
 2 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 798710972e5..2ba99a26c63 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -120,76 +120,55 @@ SUITE_DECL(seama);
 SUITE_DECL(upl);
 
 static struct suite suites[] = {
-#ifdef CONFIG_CMD_BDI
SUITE(bdinfo),
-#endif
 #ifdef CONFIG_UT_BOOTSTD
SUITE_CMD(bootstd, do_ut_bootstd),
 #endif
-#ifdef CONFIG_CMDLINE
SUITE(cmd),
-#endif
SUITE(common),
-#if defined(CONFIG_UT_DM)
SUITE(dm),
-#endif
-#if defined(CONFIG_UT_ENV)
SUITE(env),
-#endif
SUITE(exit),
-#ifdef CONFIG_CMD_FDT
SUITE(fdt),
-#endif
-#ifdef CONFIG_CONSOLE_TRUETYPE
SUITE(font),
-#endif
 #ifdef CONFIG_UT_OPTEE
SUITE_CMD(optee, do_ut_optee),
 #endif
 #ifdef CONFIG_UT_OVERLAY
SUITE_CMD(overlay, do_ut_overlay),
 #endif
-#ifdef CONFIG_UT_LIB
SUITE(lib),
-#endif
-#ifdef CONFIG_UT_LOG
SUITE(log),
-#endif
-#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && 
defined(CONFIG_CMD_MMC) \
-&& defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE)
SUITE(mbr),
-#endif
SUITE(mem),
-#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
SUITE(setexpr),
-#endif
-#ifdef CONFIG_MEASURED_BOOT
SUITE(measurement),
-#endif
-#ifdef CONFIG_SANDBOX
SUITE(bloblist),
SUITE(bootm),
-#endif
-#ifdef CONFIG_CMD_ADDRMAP
SUITE(addrmap),
-#endif
-#if CONFIG_IS_ENABLED(HUSH_PARSER)
SUITE(hush),
-#endif
-#ifdef CONFIG_CMD_LOADM
SUITE(loadm),
-#endif
-#ifdef CONFIG_CMD_PCI_MPS
SUITE(pci_mps),
-#endif
-#ifdef CONFIG_CMD_SEAMA
SUITE(seama),
-#endif
-#ifdef CONFIG_CMD_UPL
SUITE(upl),
-#endif
 };
 
+/**
+ * has_tests() - Check if a suite has tests, i.e. is supported in this build
+ *
+ * If the suite is run using a command, we have to assume that tests may be
+ * present, since we have no visibility
+ *
+ * @ste: Suite to check
+ * Return: true if supported, false if not
+ */
+static bool has_tests(struct suite *ste)
+{
+   int n_ents = ste->end - ste->start;
+
+   return n_ents || ste->cmd;
+}
+
 /** run_suite() - Run a suite of tests */
 static int run_suite(struct suite *ste, struct cmd_tbl *cmdtp, int flag,
 int argc, char *const argv[])
@@ -222,10 +201,12 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int 
argc,
struct suite *ste = &suites[i];
char *const argv[] = {(char *)ste->name, NULL};
 
-   printf("Running %s tests\n", ste->name);
-   retval = run_suite(ste, cmdtp, flag, 1, argv);
-   if (!any_fail)
-   any_fail = retval;
+   if (has_tests(ste)) {
+   printf("Running %s tests\n", ste->name);
+   retval = run_suite(ste, cmdtp, flag, 1, argv);
+   if (!any_fail)
+   any_fail = retval;
+   }
}
 
return any_fail;
@@ -234,9 +215,17 @@ static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int 
argc,
 static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
+   int suite_count, i;
const char *flags;
 
-   printf("Test suites: %d\n", (int)ARRAY_SIZE(suites));
+   for (suite_count = 0, i = 0; i < ARRAY_SIZE(suites); i++) {
+   struct suite *ste = &suites[i];
+
+   if (has_tests(ste))
+   suite_count++;
+   }
+
+   printf("Test suites: %d\n", suite_count);
printf("Total tests: %d\n", (int)UNIT_TEST_ALL_COUNT());
 
flags = cmd_arg1(argc, argv);
@@ -251,7 +240,7 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
if (n_ent)
printf("%5ld  %s\n", n_ent, ste->name);
-   else
+   else if (ste->cmd)
printf("%5s  %s\n", "?", ste->name);
}
}
diff --git a/test/py/tests/test_suite.py b/test/py/tests/test_suite.py
index 938dfb468f6..1c248602199 100644
--- a/test/py/tests/test_suite.py
+++ b/test/py/tests/test_suite.py
@@ -106,7 +106,7 @@ def process_ut_info(cons, output):
 test_count = {}
 for line in output.splitlines():
 if DEBUG_ME:
-cons.log.info(f'line: {line}')
+cons

[PATCH 38/43] test: Keep a track of the numbers of tests run

2025-01-15 Thread Simon Glass
This is useful information and is not always the same as the 'count' arg
to ut_run_list() so add it as a separate stat.

Signed-off-by: Simon Glass 
---

 include/test/test.h | 3 +++
 test/test-main.c| 2 ++
 2 files changed, 5 insertions(+)

diff --git a/include/test/test.h b/include/test/test.h
index bc8f0bbe501..f7087ab4eea 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -14,10 +14,13 @@
  *
  * @fail_count: Number of tests that failed
  * @skip_count: Number of tests that were skipped
+ * @test_count: Number of tests run. If a test is run muiltiple times, only one
+ * is counted
  */
 struct ut_stats {
int fail_count;
int skip_count;
+   int test_count;
 };
 
 /*
diff --git a/test/test-main.c b/test/test-main.c
index e8aecd267c7..e36bc37d29e 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -643,6 +643,7 @@ static int ut_run_tests(struct unit_test_state *uts, const 
char *prefix,
}
old_fail_count = uts->cur.fail_count;
 
+   uts->cur.test_count++;
if (one && upto == pos) {
ret = ut_run_test_live_flat(uts, one);
if (uts->cur.fail_count != old_fail_count) {
@@ -717,6 +718,7 @@ int ut_run_list(struct unit_test_state *uts, const char 
*category,
if (has_dm_tests)
dm_test_restore(uts->of_root);
 
+   printf("Tests run: %d, ", uts->cur.test_count);
if (uts->cur.skip_count)
printf("Skipped: %d, ", uts->cur.skip_count);
if (ret == -ENOENT)
-- 
2.34.1



[PATCH 34/43] test: Drop the info test from the list

2025-01-15 Thread Simon Glass
The 'info' test is not a real test. With the new suite array we can drop
this and the associated special-case code.

Signed-off-by: Simon Glass 
---

 test/cmd_ut.c   |  4 +---
 test/py/tests/test_suite.py | 13 +
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 0d055119ce3..798710972e5 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -93,7 +93,6 @@ int cmd_ut_category(const char *name, const char *prefix,
NULL, \
}
 
-SUITE_DECL(info);
 SUITE_DECL(bdinfo);
 SUITE_DECL(bootstd);
 SUITE_DECL(cmd);
@@ -121,7 +120,6 @@ SUITE_DECL(seama);
 SUITE_DECL(upl);
 
 static struct suite suites[] = {
-   SUITE_CMD(info, do_ut_info),
 #ifdef CONFIG_CMD_BDI
SUITE(bdinfo),
 #endif
@@ -247,7 +245,7 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, int 
argc,
 
puts("\nTests  Suite\n");
puts("-  -\n");
-   for (i = 1; i < ARRAY_SIZE(suites); i++) {
+   for (i = 0; i < ARRAY_SIZE(suites); i++) {
struct suite *ste = &suites[i];
long n_ent = ste->end - ste->start;
 
diff --git a/test/py/tests/test_suite.py b/test/py/tests/test_suite.py
index ed636bbde74..938dfb468f6 100644
--- a/test/py/tests/test_suite.py
+++ b/test/py/tests/test_suite.py
@@ -8,7 +8,7 @@ import re
 EXPECTED_SUITES = [
 'addrmap', 'bdinfo', 'bloblist', 'bootm', 'bootstd',
 'cmd', 'common', 'dm', 'env', 'exit',
-'fdt', 'font', 'hush', 'info', 'lib',
+'fdt', 'font', 'hush', 'lib',
 'loadm', 'log', 'mbr', 'measurement', 'mem',
 'overlay', 'pci_mps', 'setexpr', 'upl',
 ]
@@ -145,9 +145,8 @@ def test_suite(u_boot_console):
 suites, all_tests, exp_test_count, missing, extra = collect_info(cons,
  
output)
 
-# Make sure we got a test count for each suite (ignore 'info' since it 
isn't
-# a real suite
-assert suites - exp_test_count.keys() == {'info'}
+# Make sure we got a test count for each suite
+assert suites - exp_test_count.keys() == set()
 
 # Run 'ut info' and compare with the log results
 with cons.log.section('Check suite test-counts'):
@@ -166,10 +165,8 @@ def test_suite(u_boot_console):
 
 cons.log.info(str(exp_test_count))
 for suite in EXPECTED_SUITES:
-# 'info' is not really a suite, just a subcommand of 'ut'
-if suite != 'info':
-assert test_count[suite] in ['?', str(exp_test_count[suite])],\
-f'suite {suite} expected {exp_test_count[suite]}'
+assert test_count[suite] in ['?', str(exp_test_count[suite])], \
+f'suite {suite} expected {exp_test_count[suite]}'
 
 assert suite_count == len(EXPECTED_SUITES)
 assert total_test_count == len(all_tests)
-- 
2.34.1



[PATCH 39/43] test: Move stat-printing into its own function

2025-01-15 Thread Simon Glass
Add a function to show the stats, so we can decide when to print it.

This slightly adjusts the output, so that any 'test not found' message
appears on its own line after all other output.

The 'failures' message now appears in lower case so update pytest
accordingly.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/spl.c|  1 +
 include/test/ut.h |  8 
 test/py/tests/test_spl.py |  2 +-
 test/py/tests/test_upl.py |  2 +-
 test/py/tests/test_ut.py  |  2 +-
 test/py/tests/test_vbe.py |  2 +-
 test/py/tests/test_vpl.py |  2 +-
 test/test-main.c  | 14 +-
 8 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 0ad23e4ba95..544ea8717eb 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -153,6 +153,7 @@ void spl_board_init(void)
ut_init_state(&uts);
ret = ut_run_list(&uts, "spl", NULL, tests, count,
  state->select_unittests, 1, false, NULL);
+   ut_report(&uts.cur, "Tests");
ut_uninit_state(&uts);
/* continue execution into U-Boot */
}
diff --git a/include/test/ut.h b/include/test/ut.h
index a51defc3b90..55bb5aa2092 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -530,4 +530,12 @@ int ut_run_list(struct unit_test_state *uts, const char 
*category,
const char *select_name, int runs_per_test, bool force_run,
const char *test_insert);
 
+/**
+ * ut_report() - Report stats on a test run
+ *
+ * @stats: Stats to show
+ * @prefix: Name of this run type, e.g. "Tests" or "Total tests"
+ */
+void ut_report(struct ut_stats *stats, const char *prefix);
+
 #endif
diff --git a/test/py/tests/test_spl.py b/test/py/tests/test_spl.py
index 42e4c4342b2..474f430a344 100644
--- a/test/py/tests/test_spl.py
+++ b/test/py/tests/test_spl.py
@@ -36,7 +36,7 @@ def test_spl(u_boot_console, ut_spl_subtest):
 cons = u_boot_console
 cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]])
 output = cons.get_spawn_output().replace('\r', '')
-assert 'Failures: 0' in output
+assert 'failures: 0' in output
 finally:
 # Restart afterward in case a non-SPL test is run next. This should not
 # happen since SPL tests are run in their own invocation of test.py, 
but
diff --git a/test/py/tests/test_upl.py b/test/py/tests/test_upl.py
index 3164bda6b71..d94359d8b9b 100644
--- a/test/py/tests/test_upl.py
+++ b/test/py/tests/test_upl.py
@@ -35,4 +35,4 @@ def test_upl_handoff(u_boot_console):
 
 # Check the FIT offsets look correct
 output = cons.run_command('ut upl -f upl_test_info_norun')
-assert 'Failures: 0' in output
+assert 'failures: 0' in output
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index cacf11f7c0a..d2d8ce10755 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -607,4 +607,4 @@ def test_ut(u_boot_console, ut_subtest):
 assert 'Unknown command \'quux\' - try \'help\'' in output
 else:
 output = u_boot_console.run_command('ut ' + ut_subtest)
-assert output.endswith('Failures: 0')
+assert output.endswith('failures: 0')
diff --git a/test/py/tests/test_vbe.py b/test/py/tests/test_vbe.py
index 50b6c1cd911..861df3f8266 100644
--- a/test/py/tests/test_vbe.py
+++ b/test/py/tests/test_vbe.py
@@ -117,4 +117,4 @@ def test_vbe(u_boot_console):
 with cons.log.section('Kernel load'):
 output = cons.run_command_list(cmd.splitlines())
 
-assert 'Failures: 0' in output[-1]
+assert 'failures: 0' in output[-1]
diff --git a/test/py/tests/test_vpl.py b/test/py/tests/test_vpl.py
index 4af578b9173..8c472ca7a92 100644
--- a/test/py/tests/test_vpl.py
+++ b/test/py/tests/test_vpl.py
@@ -26,7 +26,7 @@ def test_vpl(u_boot_console, ut_vpl_subtest):
 cons = u_boot_console
 cons.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]])
 output = cons.get_spawn_output().replace('\r', '')
-assert 'Failures: 0' in output
+assert 'failures: 0' in output
 finally:
 # Restart afterward in case a non-VPL test is run next. This should not
 # happen since VPL tests are run in their own invocation of test.py, 
but
diff --git a/test/test-main.c b/test/test-main.c
index e36bc37d29e..a0a3f6086ef 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -673,6 +673,14 @@ static int ut_run_tests(struct unit_test_state *uts, const 
char *prefix,
return uts->cur.fail_count ? -EBADF : 0;
 }
 
+void ut_report(struct ut_stats *stats, const char *prefix)
+{
+   printf("%s run: %d, ", prefix, stats->test_count);
+   if (stats->skip_count)
+   printf("skipped: %d, ", stats->skip_count);
+   printf("failures: %d\n", stats->fail_count);
+}
+
 int ut_run_list(struct unit_test_state *uts, const char *category,
const char *prefix, str

[PATCH 42/43] test: Disable test_suite

2025-01-15 Thread Simon Glass
This fails at present, so disable it until it can pass.

Signed-off-by: Simon Glass 
---

 test/py/tests/test_suite.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/py/tests/test_suite.py b/test/py/tests/test_suite.py
index 1c248602199..d5d68502167 100644
--- a/test/py/tests/test_suite.py
+++ b/test/py/tests/test_suite.py
@@ -122,7 +122,8 @@ def process_ut_info(cons, output):
 @pytest.mark.buildconfigspec('sandbox')
 @pytest.mark.notbuildconfigspec('sandbox_spl')
 @pytest.mark.notbuildconfigspec('sandbox64')
-def test_suite(u_boot_console, u_boot_config):
+# This test is disabled since it fails; remove the leading 'x' to try it
+def xtest_suite(u_boot_console, u_boot_config):
 """Perform various checks on the unit tests, including:
 
- The number of suites matches that reported by the 'ut info'
-- 
2.34.1



[PATCH 41/43] test: Sort the test suites

2025-01-15 Thread Simon Glass
Put the suites in order by name, for easier code-maintenance. This also
helps find test results for a particular swuit in the 'ut all' output.

Signed-off-by: Simon Glass 
---

 test/cmd_ut.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f33918ddd00..3afab422e4a 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -90,7 +90,10 @@ int cmd_ut_category(struct unit_test_state *uts, const char 
*name,
NULL, \
}
 
+SUITE_DECL(addrmap);
 SUITE_DECL(bdinfo);
+SUITE_DECL(bloblist);
+SUITE_DECL(bootm);
 SUITE_DECL(bootstd);
 SUITE_DECL(cmd);
 SUITE_DECL(common);
@@ -99,25 +102,25 @@ SUITE_DECL(env);
 SUITE_DECL(exit);
 SUITE_DECL(fdt);
 SUITE_DECL(font);
-SUITE_DECL(optee);
-SUITE_DECL(overlay);
+SUITE_DECL(hush);
 SUITE_DECL(lib);
+SUITE_DECL(loadm);
 SUITE_DECL(log);
 SUITE_DECL(mbr);
-SUITE_DECL(mem);
-SUITE_DECL(setexpr);
 SUITE_DECL(measurement);
-SUITE_DECL(bloblist);
-SUITE_DECL(bootm);
-SUITE_DECL(addrmap);
-SUITE_DECL(hush);
-SUITE_DECL(loadm);
+SUITE_DECL(mem);
+SUITE_DECL(optee);
+SUITE_DECL(overlay);
 SUITE_DECL(pci_mps);
 SUITE_DECL(seama);
+SUITE_DECL(setexpr);
 SUITE_DECL(upl);
 
 static struct suite suites[] = {
+   SUITE(addrmap),
SUITE(bdinfo),
+   SUITE(bloblist),
+   SUITE(bootm),
 #ifdef CONFIG_UT_BOOTSTD
SUITE_CMD(bootstd, do_ut_bootstd),
 #endif
@@ -128,25 +131,22 @@ static struct suite suites[] = {
SUITE(exit),
SUITE(fdt),
SUITE(font),
+   SUITE(hush),
+   SUITE(lib),
+   SUITE(loadm),
+   SUITE(log),
+   SUITE(mbr),
+   SUITE(measurement),
+   SUITE(mem),
 #ifdef CONFIG_UT_OPTEE
SUITE_CMD(optee, do_ut_optee),
 #endif
 #ifdef CONFIG_UT_OVERLAY
SUITE_CMD(overlay, do_ut_overlay),
 #endif
-   SUITE(lib),
-   SUITE(log),
-   SUITE(mbr),
-   SUITE(mem),
-   SUITE(setexpr),
-   SUITE(measurement),
-   SUITE(bloblist),
-   SUITE(bootm),
-   SUITE(addrmap),
-   SUITE(hush),
-   SUITE(loadm),
SUITE(pci_mps),
SUITE(seama),
+   SUITE(setexpr),
SUITE(upl),
 };
 
-- 
2.34.1



[PATCH 40/43] test: Record and show the totals for all test runs

2025-01-15 Thread Simon Glass
With 'ut all' multiple test suites are run. Add a way to collect totals
and show them at the end.

Signed-off-by: Simon Glass 
---

 include/test/test.h | 3 +++
 test/cmd_ut.c   | 2 ++
 test/test-main.c| 9 +++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/test/test.h b/include/test/test.h
index f7087ab4eea..58023f6eafb 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -27,6 +27,7 @@ struct ut_stats {
  * struct unit_test_state - Entire state of test system
  *
  * @cur: Statistics for the current run
+ * @run_count: Number of times ut_run_list() has been called
  * @start: Store the starting mallinfo when doing leak test
  * @of_live: true to use livetree if available, false to use flattree
  * @of_root: Record of the livetree root node (used for setting up tests)
@@ -48,6 +49,8 @@ struct ut_stats {
  */
 struct unit_test_state {
struct ut_stats cur;
+   struct ut_stats total;
+   int run_count;
struct mallinfo start;
struct device_node *of_root;
bool of_live;
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index f315c442abf..f33918ddd00 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -206,6 +206,8 @@ static int do_ut_all(struct unit_test_state *uts, struct 
cmd_tbl *cmdtp,
any_fail = retval;
}
}
+   if (uts->run_count > 1)
+   ut_report(&uts->total, "Total tests");
 
return any_fail;
 }
diff --git a/test/test-main.c b/test/test-main.c
index a0a3f6086ef..6010c24207c 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -690,6 +690,8 @@ int ut_run_list(struct unit_test_state *uts, const char 
*category,
bool has_dm_tests = false;
int ret;
 
+   memset(&uts->cur, '\0', sizeof(struct ut_stats));
+
if (!CONFIG_IS_ENABLED(OF_PLATDATA) &&
ut_list_has_dm_tests(tests, count, prefix, select_name)) {
has_dm_tests = true;
@@ -727,8 +729,11 @@ int ut_run_list(struct unit_test_state *uts, const char 
*category,
dm_test_restore(uts->of_root);
 
ut_report(&uts->cur, "Tests");
-   if (ret == -ENOENT)
-   printf("Test '%s' not found\n", select_name);
+
+   uts->total.skip_count += uts->cur.skip_count;
+   uts->total.fail_count += uts->cur.fail_count;
+   uts->total.test_count += uts->cur.test_count;
+   uts->run_count++;
 
return ret;
 }
-- 
2.34.1



[PATCH 43/43] test: Move help into the suite declaration

2025-01-15 Thread Simon Glass
Rather than having the help in the longhelp, put it in the suite info
so 'ut info -s' can show it. This is tidier, particular due to the
removal of #ifdefs

This means that the help text is present in the image (although not
displayed with 'ut info -s') so the image-size increases. But with
UNIT_TEST enabled, we expect large images so this doesn't seem
important.

Signed-off-by: Simon Glass 
---

 test/cmd_ut.c | 127 --
 1 file changed, 40 insertions(+), 87 deletions(-)

diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 3afab422e4a..76f481f509b 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -19,14 +19,16 @@
  *
  * @name: Name of suite
  * @start: First test in suite
- * end: End test in suite (points to the first test in the next suite
- * cmd: Command to use to run the suite
+ * @end: End test in suite (points to the first test in the next suite
+ * @cmd: Command to use to run the suite
+ * @help: Help-string to show for this suite
  */
 struct suite {
const char *name;
struct unit_test *start;
struct unit_test *end;
ut_cmd_func cmd;
+   const char *help;
 };
 
 static int do_ut_all(struct unit_test_state *uts, struct cmd_tbl *cmdtp,
@@ -75,19 +77,21 @@ int cmd_ut_category(struct unit_test_state *uts, const char 
*name,
ll_end_decl(suite_end_ ## _name, struct unit_test, ut_ ## _name)
 
 /* declare a test suite which uses a subcommand to run */
-#define SUITE_CMD(_name, _cmd_func) { \
+#define SUITE_CMD(_name, _cmd_func, _help) { \
#_name, \
suite_start_ ## _name, \
suite_end_ ## _name, \
_cmd_func, \
+   _help, \
}
 
 /* declare a test suite which can be run directly without a subcommand */
-#define SUITE(_name) { \
+#define SUITE(_name, _help) { \
#_name, \
suite_start_ ## _name, \
suite_end_ ## _name, \
NULL, \
+   _help, \
}
 
 SUITE_DECL(addrmap);
@@ -117,37 +121,37 @@ SUITE_DECL(setexpr);
 SUITE_DECL(upl);
 
 static struct suite suites[] = {
-   SUITE(addrmap),
-   SUITE(bdinfo),
-   SUITE(bloblist),
-   SUITE(bootm),
+   SUITE(addrmap, "very basic test of addrmap command"),
+   SUITE(bdinfo, "bdinfo (board info) command"),
+   SUITE(bloblist, "bloblist implementation"),
+   SUITE(bootm, "bootm command"),
 #ifdef CONFIG_UT_BOOTSTD
-   SUITE_CMD(bootstd, do_ut_bootstd),
+   SUITE_CMD(bootstd, do_ut_bootstd, "standard boot implementation"),
 #endif
-   SUITE(cmd),
-   SUITE(common),
-   SUITE(dm),
-   SUITE(env),
-   SUITE(exit),
-   SUITE(fdt),
-   SUITE(font),
-   SUITE(hush),
-   SUITE(lib),
-   SUITE(loadm),
-   SUITE(log),
-   SUITE(mbr),
-   SUITE(measurement),
-   SUITE(mem),
+   SUITE(cmd, "various commands"),
+   SUITE(common, "tests for common/ directory"),
+   SUITE(dm, "driver model"),
+   SUITE(env, "environment"),
+   SUITE(exit, "shell exit and variables"),
+   SUITE(fdt, "fdt command"),
+   SUITE(font, "font command"),
+   SUITE(hush, "hush behaviour"),
+   SUITE(lib, "library functions"),
+   SUITE(loadm, "loadm command parameters and loading memory blob"),
+   SUITE(log, "logging functions"),
+   SUITE(mbr, "mbr command"),
+   SUITE(measurement, "TPM-based measured boot"),
+   SUITE(mem, "memory-related commands"),
 #ifdef CONFIG_UT_OPTEE
-   SUITE_CMD(optee, do_ut_optee),
+   SUITE_CMD(optee, do_ut_optee, "OP-TEE"),
 #endif
 #ifdef CONFIG_UT_OVERLAY
-   SUITE_CMD(overlay, do_ut_overlay),
+   SUITE_CMD(overlay, do_ut_overlay, "device tree overlays"),
 #endif
-   SUITE(pci_mps),
-   SUITE(seama),
-   SUITE(setexpr),
-   SUITE(upl),
+   SUITE(pci_mps, "PCI Express Maximum Payload Size"),
+   SUITE(seama, "seama command parameters loading and decoding"),
+   SUITE(setexpr, "setexpr command"),
+   SUITE(upl, "Universal payload support"),
 };
 
 /**
@@ -232,16 +236,19 @@ static int do_ut_info(struct cmd_tbl *cmdtp, int flag, 
int argc,
if (flags && !strcmp("-s", flags)) {
int i;
 
-   puts("\nTests  Suite\n");
-   puts("-  -\n");
+   puts("\nTests  Suite Purpose");
+   puts("\n-    -\n");
for (i = 0; i < ARRAY_SIZE(suites); i++) {
struct suite *ste = &suites[i];
long n_ent = ste->end - ste->start;
 
if (n_ent)
-   printf("%5ld  %s\n", n_ent, ste->name);
+   printf("%5ld", n_ent);
else if (ste->cmd)
-   printf("%5s  %s\n", "?", ste->name);
+   printf("%5s", "?");
+   else  /* suite is not present */
+   continue;
+

[PATCH 2/2] board: rockpi4-rk3399: update email address for Christopher Obbard

2025-01-15 Thread Christopher Obbard
Update my email address.

Signed-off-by: Christopher Obbard 
---
 board/radxa/rockpi4-rk3399/MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/radxa/rockpi4-rk3399/MAINTAINERS 
b/board/radxa/rockpi4-rk3399/MAINTAINERS
index 
da5273fb9a39c38473272c388182b9c4f32caa12..f50d9289ed67bde6b32f075ec137a38605b88d14
 100644
--- a/board/radxa/rockpi4-rk3399/MAINTAINERS
+++ b/board/radxa/rockpi4-rk3399/MAINTAINERS
@@ -15,7 +15,7 @@ F:configs/rock-4c-plus-rk3399_defconfig
 F: arch/arm/dts/rk3399-rock-4c-plus*
 
 ROCK-4SE
-M: Christopher Obbard 
+M: Christopher Obbard 
 R: Jonas Karlman 
 S: Maintained
 F: configs/rock-4se-rk3399_defconfig

-- 
2.47.1



[PATCH 0/2] Update my email address

2025-01-15 Thread Christopher Obbard
Update my email address for various locations in the U-Boot project.
This will (hopefully) stop any mails from going to /dev/null.

---
Christopher Obbard (2):
  .mailmap: update email address for Christopher Obbard
  board: rockpi4-rk3399: update email address for Christopher Obbard

 .mailmap   | 1 +
 board/radxa/rockpi4-rk3399/MAINTAINERS | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
---
base-commit: 4eb937058ffd9d413929f566246eb684efe8eab5
change-id: 20250115-wip-obbardc-update-email-b78477a2d396

Best regards,
-- 
Christopher Obbard 



RE: Lab failure on JH7110 (StarFive VisionFive 2)

2025-01-15 Thread Hal Feng
> On 09.01.25 20:37, Simon Glass wrote:
> Hi,
> 
> I am seeing a lab failure on this board with the test_dm_compat test[1]:
> 
> === FAILURES
> ===
> 559 test_dm_compat
> 
> 560test/py/tests/test_dm.py:20: in test_dm_compat
> 561 assert not bad_drivers
> 562E AssertionError: assert not {'starfive_gpio'}
> 
> Would you have time to take a look, please? A patch to fix a similar problem
> on another board is [2].
> 
> Regards,
> Simon
> 
> [1] https://ci.u-boot.org/u-boot/u-boot/-/jobs/14394
> [2]
> https://patchwork.ozlabs.org/project/uboot/patch/20240611200156.224552
> 5-19-...@chromium.org/

I will take a look. Thanks.

Best regards,
Hal


Re: [PATCH] linker_lists: Update the alignment using CONFIG_LINKER_LIST_ALIGN

2025-01-15 Thread Quentin Schulz

Hi Liya,

On 1/14/25 8:09 AM, 1425075...@qq.com wrote:

[You don't often get email from 1425075...@qq.com. Learn why this is important 
at https://aka.ms/LearnAboutSenderIdentification ]

From: Liya Huang <1425075...@qq.com>

This patch updates the alignment of linker lists to use the
CONFIG_LINKER_LIST_ALIGN macro instead of a hardcoded value.
This ensures that the alignment is consistent with the configuration.
Replace __attribute__((unused)) with __maybe_unused and
__always_unused to eliminate the warning of checkpatch.pl.

Reviewed-by: Simon Glass 


This... is odd. I don't see an earlier version of that patch and your 
name/mail only returns two patches on the U-Boot mailing list. I believe 
Reviewed-by needs to be publicly given on the ML as they are a proof of 
review by the mentioned person and is usually a trust mark for 
maintainers to merge code. Here it may have been added without Simon's 
consent. Now imagine Simon is not answering for a few days/weeks, the 
maintainer could still believe Simon went through a proper review and 
merge that patch taking that into account while no review may actually 
have been conducted. This is making me uncomfortable.


Same issue for 
https://lore.kernel.org/u-boot/tencent_cce8303926957c427aae06f9d91282458...@qq.com/.


I'm not saying review wasn't done properly, but its acknowledgment 
should be made public by the mentioned person instead of being put into 
the v1.


Have I missed an earlier version or discussion maybe?

Cheers,
Quentin


Re: [PATCH 0/7] board: rockchip: add FriendlyElec NanoPi R3S

2025-01-15 Thread Quentin Schulz

Hi Tianling,

On 1/14/25 5:14 PM, Tianling Shen wrote:

Hi Quentin,

On 2025/1/14 23:21, Quentin Schulz wrote:

Hi Tianling,

On 1/14/25 3:49 PM, Tianling Shen wrote:

Hi Quentin,

On 2025/1/14 22:39, Quentin Schulz wrote:

Hi Tianling,

On 12/26/24 10:20 AM, Tianling Shen wrote:

The NanoPi R3S(as "R3S") is an open source platform with dual-Gbps
Ethernet ports designed and developed by FriendlyElec for IoT
applications.

Tianling Shen (7):
   arm64: dts: rockchip: Add FriendlyARM NanoPi R3S board
   arm64: dts: rockchip: fix model name for FriendlyElec NanoPi R3S
   arm64: dts: rockchip: replace deprecated snps,reset props for 
NanoPi

 R3S
   arm64: dts: rockchip: sort props in pmu_io_domains node for 
NanoPi R3S

   arm64: dts: rockchip: enable eMMC HS200 mode for NanoPi R3S
   arm64: dts: rockchip: reorder mmc aliases for NanoPi R3S


How did you backport the above patches?

./tools/update-subtree.sh pick dts 

is the tool to be used, it should have added a



Thank you for the tip! I did not know there's such a script and
I just copy&paste the commit message from linux tree manually.



Mmmm, how did you apply the patch in your tree then? Trying to figure 
out how we can avoid this in the future.


I fetched the patches[1] as-is from kernel and applied them by `git am 
-3` with path correction, then maually added the line "[ upstream 
commit: xx ]" to commit message.


1. https://eur02.safelinks.protection.outlook.com/? 
url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fpatch%2F%3Fid%3D50decd493c8394c52d04561fe4ede34df27a46ba&data=05%7C02%7Cquentin.schulz%40cherry.de%7C72d5c95645ef4197c18908dd34b69565%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638724680973346196%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=urDrXWTzIt2NF%2BUrBSO1FnSTxjBO5Q4nYHFU9i%2BRII0%3D&reserved=0


https://eur02.safelinks.protection.outlook.com/? 
url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fpatch%2F%3Fid%3Db5bf84206a5c77528f9dd4cbca4e72caa063c102&data=05%7C02%7Cquentin.schulz%40cherry.de%7C72d5c95645ef4197c18908dd34b69565%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638724680973368900%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=x4CksM87w51QxzlrqNqjKvpQOJ6KKmSFQ01hoWmiCyg%3D&reserved=0


https://eur02.safelinks.protection.outlook.com/? 
url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fpatch%2F%3Fid%3D82b2868937883b65732da498b26366d34db61510&data=05%7C02%7Cquentin.schulz%40cherry.de%7C72d5c95645ef4197c18908dd34b69565%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638724680973382545%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=qyjod1yP7k%2F7bhjfHdZqn3LqettTPI41duikY0NRveg%3D&reserved=0


https://eur02.safelinks.protection.outlook.com/? 
url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fpatch%2F%3Fid%3D17e150fdd983c7e59b9240e34a166285f3c3fb39&data=05%7C02%7Cquentin.schulz%40cherry.de%7C72d5c95645ef4197c18908dd34b69565%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638724680973396320%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Zv7tjHe0VKKp%2FuIBFu5zrO%2BusEVjm%2F3lJ73jdaTmVuA%3D&reserved=0


https://eur02.safelinks.protection.outlook.com/? 
url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fpatch%2F%3Fid%3D1b5365034410f1ca21adadadd492b99bdf4f2c55&data=05%7C02%7Cquentin.schulz%40cherry.de%7C72d5c95645ef4197c18908dd34b69565%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638724680973413639%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=%2F3uw74TSfuoUpOFkfJPLWzKjoh331Y5RaPvEa4DrDs4%3D&reserved=0


https://eur02.safelinks.protection.outlook.com/? 
url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fpatch%2F%3Fid%3Db7cd1115456d312f8c5e60c80fdc35fd35ea6eab&data=05%7C02%7Cquentin.schulz%40cherry.de%7C72d5c95645ef4197c18908dd34b69565%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638724680973431321%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=pFych4CEp7BfolVm1KMGk828MIkCaMRNw8hCf7p2ldI%3D&reserved=0




Thanks for explaining!



I'm wondering if we shouldn't have tooling in place to detect when 
things aren't done the proper way (for maintainers I mean). We 
**really** want to have dts/upstream be upstream + some patches that 
were already merged in devicetree-rebasing tree. I don't know enough 
about subtree merges that Tom does when updating to a 

Re: [PATCH] doc: coolpi: Fix the defconfig name

2025-01-15 Thread Quentin Schulz

Hi Andy,

On 1/13/25 11:56 AM, Andy Yan wrote:

The defconfig name should be: coolpi-cm5-genbook-rk3588_defconfig

Signed-off-by: Andy Yan 


Reviewed-by: Quentin Schulz 


---

  doc/board/coolpi/genbook_cm5_rk3588.rst | 2 +-


What about renaming every file that are inconsistent in naming?

board/coolpi/genbook_cm5_rk3588/ to board/coolpi/cm5_genbook_rk3588/
doc/board/coolpi/genbook_cm5_rk3588.rst to 
doc/board/coolpi/cm5_genbook_rk3588.rst

include/configs/genbook-cm5-rk3588.h to include/configs/cm5-genbook-rk3588.h

If we do this change, we also need to change a few variables in 
Kconfig/defconfig. If we do this change, it needs to be done in a 
separate patch though!


What do you think?

Cheers,
Quentin


Re: [PATCH 01/15] vbe: Split out some VBE code into a common file

2025-01-15 Thread Simon Glass
Hi Tom,

On Tue, 14 Jan 2025 at 19:48, Simon Glass  wrote:
>
> Hi Tom,
>
> On Tue, 14 Jan 2025 at 18:41, Tom Rini  wrote:
> >
> > On Tue, Jan 14, 2025 at 06:18:26PM -0700, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Tue, 14 Jan 2025 at 10:33, Tom Rini  wrote:
> > > >
> > > > On Tue, Jan 14, 2025 at 10:58:01AM -0600, Tom Rini wrote:
> > > > > On Tue, Jan 14, 2025 at 05:58:04AM -0700, Simon Glass wrote:
> > > > > > Hi Tom,
> > > > > >
> > > > > > On Mon, 13 Jan 2025 at 18:22, Tom Rini  wrote:
> > > > > > >
> > > > > > > On Thu, Jan 09, 2025 at 05:29:56AM -0700, Simon Glass wrote:
> > > > > > >
> > > > > > > > Loading a FIT is useful for other VBE methods, such as ABrec, 
> > > > > > > > so start
> > > > > > > > a new common file. Add functions for reading the version and 
> > > > > > > > nvdata.
> > > > > > > > Also add a function to get the block device.
> > > > > > >
> > > > > > > This is not a good commit message when you're also introducing
> > > > > > > functional changes (blk_dread -> blk_read).
> > > > > >
> > > > > > Yes, I did not actually notice this size change at all, as 
> > > > > > mentioned,
> > > > > > as I only built for a few boards (firefly rk3399/rk3288 and a few
> > > > > > sandbox ones). The blk_dread() function is the old API for reading
> > > > >
> > > > > You have much faster build machines available than I do, it would be
> > > > > good to run a world build before/after (it might take an hour on
> > > > > alexandra) before posting these big series.
> > >
> > > OK. I used to do this, but with CI sometimes grabbing the machines it
> > > ends up with a huge load and sometimes runs out of memory. I suppose I
> > > can stop the runner before doing it and remember to restart it
> > > afterwards. Or perhaps Alex has enough memory per thread? (96GB).
> >
> > Personally, I would make the script that does the world build for size
> > test turn off the runner before starting and turn it back on when done
> > otherwise build time will suffer greatly and you would have been better
> > served doing it all on a slower class of machine.
> >
> > >
> > > > >
> > > > > > from a block. It didn't occur to me that blk_dread() would bypass 
> > > > > > the
> > > > > > cache.
> > > > >
> > > > > Yes, how is that happening? That's what doesn't make sense.
> > >
> > > OK, I see. It is actually one level deeper than I thought.
> > >
> > > PARTITIONS is not enabled, for example on phycore_am62x_r5_usbdfu
> > > which means that blk_get_dev() returns NULL
> > >
> > > So long as all the code is in one module, blk_get_dev() returning NULL
> > > causes the calls to vbe_simple_read_state() and simple_read_nvdata()
> > > to be dropped, so their code is dropped too, so there is no
> > > blk_read()/blk_dread() call. It is optimised away. It just happens to
> > > be the only call in U-Boot
> >
> > Ah, that is all also true, thanks.
> >
> > > > > > > Further, this functional
> > > > > > > change seems to introduce some other code being pulled in very
> > > > > > > unexpectedly, and that needs to be explained. For example,
> > > > > > > phycore_am62x_r5_usbdfu is another case and that has
> > > > > > > CONFIG_BLOCK_CACHE=y but CONFIG_SPL_BLOCK_CACHE=n, and yet the 
> > > > > > > size
> > > > > > > growth is in full U-Boot.
> > > > > >
> > > > > > This board currently uses blk_dread(), but not blk_read(), so the
> > > > > > addition of a blk_read() call in non-SPL causes the BLK cache to be
> > > > > > pulled in.
> > > > >
> > > > > But, how? I mean, this sounds like some underlying bug that needs to 
> > > > > be
> > > > > fixed. The platform sets CONFIG_BLK=y and CONFIG_BLOCK_CACHE=y and
> > > > > drivers/block/blk-uclass.c has:
> > > > > ulong blk_dread(struct blk_desc *desc, lbaint_t start, lbaint_t 
> > > > > blkcnt,
> > > > > void *buffer)
> > > > > {
> > > > > return blk_read(desc->bdev, start, blkcnt, buffer);
> > > > > }
> > > > >
> > > > > Or perhaps the answer / problem here is that I need to track down 
> > > > > what's
> > > > > going wrong here instead of asking you to track this down.
> > > >
> > > > So, digging in to this, what's going on is that the platforms I've noted
> > > > here (and a few others) don't actually enable any block devices. That's
> > > > why, today, with VBE on still, they discard all of the code still. Your
> > > > rework means that while there's still no block devices, we're now
> > > > including the code. What to do? Both of:
> > > > - These platforms *should* disable the assorted block device related
> > > >   library options they have enabled if / when possible (it might not be
> > > >   a neat and easy un-tangle).
> > >
> > > As above, the issue seems to be PARTITIONS
> >
> > Yes, I think we both agree there's a number of useless functionality
> > enabled on these handful of platforms. PARTITIONS explains how it gets
> > optimized away and all of the useless block-related things like MMC
> > core should also be dropped.
> >
> > > > - VBE needs to handle 

Re: [PATCH v4 0/5] rpi: Tidy up booting

2025-01-15 Thread Simon Glass
Hi,

On Thu, 19 Dec 2024 at 17:34, Simon Glass  wrote:
>
> This series allows rpi to boot a compressed Ubuntu kernel with ~100MB
> ramdisk, by expanding the available space.
>
> It also tidies up some strange behaviour with the provided FDT, where a
> separate pointer is maintained to it, even though U-Boot has copied it
> and placed it in its own space. This avoids strange bugs where it
> accidentally gets overwritten when loading a file into memory.
>
> The patch to expand the devicetree was dropped, meaning that people
> should be careful to unset fdt_addr in the environment.
>
> In version 2, it incorporates some changes to fdt_addr, etc. suggested
> by Tom, as well as adding myself as a maintainer.
>
> Changes in v4:
> - Expand the comment on set_fdt_addr()
> - Update the commit message to talk in terms of my testing
>
> Changes in v3:
> - Add to the existing comment block
> - Update the comment block with the new values, including compression
>
> Changes in v2:
> - Add new patch to make myself an rpi maintainer
> - Add new patch to set bootm_size
> - Add new patch to drop fdt_high and initrd_high
> - Drop patch to allow expanding the devicetree during relocation
>
> Simon Glass (5):
>   rpi: Add myself to the list of maintainers
>   rpi: Set bootm_size to 512MB
>   rpi: Drop fdt_high and initrd_high
>   rpi: Update environment to support booti and large initrd
>   rpi: Use the U-Boot control FDT for fdt_addr
>
>  MAINTAINERS   |  1 +
>  board/raspberrypi/rpi/rpi.c   | 20 +--
>  board/raspberrypi/rpi/rpi.env | 37 +++
>  3 files changed, 31 insertions(+), 27 deletions(-)
>
> --
> 2.34.1
>

Are there any comments on this series, or can it be applied?

Regards,
Simon


[PATCH v2 21/22] vbe: Support loading SPL images

2025-01-15 Thread Simon Glass
VBE needs to load different images from a FIT depending on the xPL phase
in use. The IH_PHASE value is used to select the image to load.

Add the required logic to handle this. For compatibility with the
SPL-loader driver, fill out a struct spl_image_info with the details
needed to boot the next phase.

This is good enough for VBE-simple but ABrec will need the full set of
bootstd features. So add a USE_BOOTMETH define to control this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/vbe_common.c| 85 ++--
 boot/vbe_common.h| 14 +++-
 boot/vbe_simple_fw.c |  3 +-
 3 files changed, 97 insertions(+), 5 deletions(-)

diff --git a/boot/vbe_common.c b/boot/vbe_common.c
index 1926e851398..2bc6c4d73ab 100644
--- a/boot/vbe_common.c
+++ b/boot/vbe_common.c
@@ -16,6 +16,11 @@
 #include 
 #include "vbe_common.h"
 
+binman_sym_declare(ulong, u_boot_vpl_nodtb, size);
+binman_sym_declare(ulong, u_boot_vpl_bss_pad, size);
+binman_sym_declare(ulong, u_boot_spl_nodtb, size);
+binman_sym_declare(ulong, u_boot_spl_bss_pad, size);
+
 int vbe_get_blk(const char *storage, struct udevice **blkp)
 {
struct blk_desc *desc;
@@ -105,17 +110,43 @@ int vbe_read_nvdata(struct udevice *blk, ulong offset, 
ulong size, u8 *buf)
return 0;
 }
 
+/**
+ * h_vbe_load_read() - Handler for reading an SPL image from a FIT
+ *
+ * See spl_load_reader for the definition
+ */
+ulong h_vbe_load_read(struct spl_load_info *load, ulong off, ulong size,
+ void *buf)
+{
+   struct blk_desc *desc = load->priv;
+   lbaint_t sector = off >> desc->log2blksz;
+   lbaint_t count = size >> desc->log2blksz;
+   int ret;
+
+   log_debug("vbe read log2blksz %x offset %lx sector %lx count %lx\n",
+ desc->log2blksz, (ulong)off, (long)sector, (ulong)count);
+
+   ret = blk_dread(desc, sector, count, buf);
+   log_debug("ret=%x\n", ret);
+   if (ret < 0)
+   return ret;
+
+   return ret << desc->log2blksz;
+}
+
 int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,
-ulong *load_addrp, ulong *lenp, char **namep)
+struct spl_image_info *image, ulong *load_addrp, ulong *lenp,
+char **namep)
 {
ALLOC_CACHE_ALIGN_BUFFER(u8, sbuf, MMC_MAX_BLOCK_LEN);
-   ulong size, blknum, addr, len, load_addr, num_blks;
+   ulong size, blknum, addr, len, load_addr, num_blks, spl_load_addr;
ulong aligned_size, fdt_load_addr, fdt_size;
const char *fit_uname, *fit_uname_config;
struct bootm_headers images = {};
enum image_phase_t phase;
struct blk_desc *desc;
int node, ret;
+   bool for_xpl;
void *buf;
 
desc = dev_get_uclass_plat(blk);
@@ -168,7 +199,8 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, 
ulong area_size,
  gd->malloc_base + gd->malloc_limit);
 #endif
/* figure out the phase to load */
-   phase = IS_ENABLED(CONFIG_VPL_BUILD) ? IH_PHASE_SPL : IH_PHASE_U_BOOT;
+   phase = IS_ENABLED(CONFIG_TPL_BUILD) ? IH_PHASE_NONE :
+   IS_ENABLED(CONFIG_VPL_BUILD) ? IH_PHASE_SPL : IH_PHASE_U_BOOT;
 
/*
 * Load the image from the FIT. We ignore any load-address information
@@ -179,6 +211,20 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, 
ulong area_size,
fit_uname = NULL;
fit_uname_config = NULL;
log_debug("loading FIT\n");
+
+   if (xpl_phase() == PHASE_SPL && !IS_ENABLED(CONFIG_SANDBOX)) {
+   struct spl_load_info info;
+
+   spl_load_init(&info, h_vbe_load_read, desc, desc->blksz);
+   xpl_set_phase(&info, IH_PHASE_U_BOOT);
+   log_debug("doing SPL from %s blksz %lx log2blksz %x area_offset 
%lx + fdt_size %lx\n",
+ blk->name, desc->blksz, desc->log2blksz, area_offset, 
ALIGN(size, 4));
+   ret = spl_load_simple_fit(image, &info, area_offset, buf);
+   log_debug("spl_load_abrec_fit() ret=%d\n", ret);
+
+   return ret;
+   }
+
ret = fit_image_load(&images, addr, &fit_uname, &fit_uname_config,
 IH_ARCH_DEFAULT, image_ph(phase, IH_TYPE_FIRMWARE),
 BOOTSTAGE_ID_FIT_SPL_START, FIT_LOAD_IGNORED,
@@ -197,6 +243,31 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, 
ulong area_size,
 
fdt_load_addr = 0;
fdt_size = 0;
+   if ((xpl_phase() == PHASE_TPL || xpl_phase() == PHASE_VPL) &&
+   !IS_ENABLED(CONFIG_SANDBOX)) {
+   /* allow use of a different image from the configuration node */
+   fit_uname = NULL;
+   ret = fit_image_load(&images, addr, &fit_uname,
+&fit_uname_config, IH_ARCH_DEFAULT,
+image_ph(phase, IH_TYPE_FLATDT),
+

[PATCH v2 22/22] vbe: Update simple-fw to support using the SPL loader

2025-01-15 Thread Simon Glass
For a sandbox implementation, where code size is no object, it makes sense
to use the full bootstd drivers to load images.

For real boards, running from SRAM, this adds quite a bit of overhead.

Add a way to load the next phase using just the underlying storage
driver, to reduce code size. For now, only MMC is supported.

Change the log_debug() to show the load address and size in a more
neutral way, rather than suggesting that the load has already happened.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Split up the first patch into 5 separate patches, to highlight code size

 boot/vbe_common.c|   2 +-
 boot/vbe_simple_fw.c | 112 +--
 2 files changed, 77 insertions(+), 37 deletions(-)

diff --git a/boot/vbe_common.c b/boot/vbe_common.c
index 2bc6c4d73ab..0d51fe762c3 100644
--- a/boot/vbe_common.c
+++ b/boot/vbe_common.c
@@ -239,7 +239,7 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, 
ulong area_size,
if (ret < 0)
return log_msg_ret("ld", ret);
node = ret;
-   log_debug("loaded to %lx\n", load_addr);
+   log_debug("load %lx size %lx\n", load_addr, len);
 
fdt_load_addr = 0;
fdt_size = 0;
diff --git a/boot/vbe_simple_fw.c b/boot/vbe_simple_fw.c
index 9da3e49a66e..cb5534fc731 100644
--- a/boot/vbe_simple_fw.c
+++ b/boot/vbe_simple_fw.c
@@ -8,6 +8,7 @@
 
 #define LOG_CATEGORY LOGC_BOOT
 
+#include 
 #include 
 #include 
 #include 
@@ -17,13 +18,24 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
+#include "vbe_common.h"
 #include "vbe_simple.h"
 
+#ifdef CONFIG_BOOTMETH_VBE_SIMPLE
+binman_sym_extern(ulong, vbe_a, image_pos);
+binman_sym_extern(ulong, vbe_a, size);
+#else
+binman_sym_declare(ulong, vbe_a, image_pos);
+binman_sym_declare(ulong, vbe_a, size);
+#endif
+
+binman_sym_declare(ulong, vpl, image_pos);
+binman_sym_declare(ulong, vpl, size);
+
 /**
  * vbe_simple_read_bootflow_fw() - Create a bootflow for firmware
  *
@@ -54,6 +66,8 @@ int vbe_simple_read_bootflow_fw(struct udevice *dev, struct 
bootflow *bflow)
ret = vbe_read_fit(blk, priv->area_start + priv->skip_offset,
   priv->area_size, NULL, &load_addr, &len,
   &bflow->name);
+   if (ret)
+   return log_msg_ret("vbe", ret);
 
/* set up the bootflow with the info we obtained */
bflow->blk = blk;
@@ -63,16 +77,14 @@ int vbe_simple_read_bootflow_fw(struct udevice *dev, struct 
bootflow *bflow)
return 0;
 }
 
-static int simple_load_from_image(struct spl_image_info *spl_image,
+static int simple_load_from_image(struct spl_image_info *image,
  struct spl_boot_device *bootdev)
 {
-   struct udevice *meth, *bdev;
-   struct simple_priv *priv;
-   struct bootflow bflow;
struct vbe_handoff *handoff;
int ret;
 
-   if (xpl_phase() != PHASE_VPL && xpl_phase() != PHASE_SPL)
+   if (xpl_phase() != PHASE_VPL && xpl_phase() != PHASE_SPL &&
+   xpl_phase() != PHASE_TPL)
return -ENOENT;
 
ret = bloblist_ensure_size(BLOBLISTT_VBE, sizeof(struct vbe_handoff),
@@ -80,36 +92,64 @@ static int simple_load_from_image(struct spl_image_info 
*spl_image,
if (ret)
return log_msg_ret("ro", ret);
 
-   vbe_find_first_device(&meth);
-   if (!meth)
-   return log_msg_ret("vd", -ENODEV);
-   log_debug("vbe dev %s\n", meth->name);
-   ret = device_probe(meth);
-   if (ret)
-   return log_msg_ret("probe", ret);
-
-   priv = dev_get_priv(meth);
-   log_debug("simple %s\n", priv->storage);
-   ret = bootdev_find_by_label(priv->storage, &bdev, NULL);
-   if (ret)
-   return log_msg_ret("bd", ret);
-   log_debug("bootdev %s\n", bdev->name);
-
-   bootflow_init(&bflow, bdev, meth);
-   ret = bootmeth_read_bootflow(meth, &bflow);
-   log_debug("\nfw ret=%d\n", ret);
-   if (ret)
-   return log_msg_ret("rd", ret);
-
-   /* jump to the image */
-   spl_image->flags = SPL_SANDBOXF_ARG_IS_BUF;
-   spl_image->arg = bflow.buf;
-   spl_image->size = bflow.size;
-   log_debug("Image: %s at %p size %x\n", bflow.name, bflow.buf,
- bflow.size);
-
-   /* this is not used from now on, so free it */
-   bootflow_free(&bflow);
+   if (USE_BOOTMETH) {
+   struct udevice *meth, *bdev;
+   struct simple_priv *priv;
+   struct bootflow bflow;
+
+   vbe_find_first_device(&meth);
+   if (!meth)
+   return log_msg_ret("vd", -ENODEV);
+   log_debug("vbe dev %s\n", meth->name);
+   ret = device_probe(meth);
+   if (ret)
+   return log_msg_ret("probe", ret);
+
+   priv = dev_get_priv(meth);
+   log_debug("simple %s\n", priv->storag

[PATCH v2 20/22] vbe: Support loading an FDT with the relocating loader

2025-01-15 Thread Simon Glass
Add FDT support so that this can be copied down in memory after loading
and made available to the new image.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/vbe_common.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/boot/vbe_common.c b/boot/vbe_common.c
index 30dd18d3c38..1926e851398 100644
--- a/boot/vbe_common.c
+++ b/boot/vbe_common.c
@@ -260,6 +260,26 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, 
ulong area_size,
memmove(fdt_base_buf, fdt_base_buf + extra,
fdt_size);
}
+#if CONFIG_IS_ENABLED(RELOC_LOADER)
+   image->fdt_buf = fdt_base_buf;
+
+   ulong xpl_size;
+   ulong xpl_pad;
+   ulong fdt_start;
+
+   if (xpl_phase() == PHASE_TPL) {
+   xpl_size = binman_sym(ulong, u_boot_vpl_nodtb, 
size);
+   xpl_pad = binman_sym(ulong, u_boot_vpl_bss_pad, 
size);
+   } else {
+   xpl_size = binman_sym(ulong, u_boot_spl_nodtb, 
size);
+   xpl_pad = binman_sym(ulong, u_boot_spl_bss_pad, 
size);
+   }
+   fdt_start = image->load_addr + xpl_size + xpl_pad;
+   log_debug("load_addr %lx xpl_size %lx copy-to %lx\n",
+ image->load_addr, xpl_size + xpl_pad,
+ fdt_start);
+   image->fdt_start = map_sysmem(fdt_start, fdt_size);
+#endif
}
}
if (load_addrp)
-- 
2.34.1



[PATCH 11/13] net: fsl_enetc: Add initial netc-blk-ctrl driver support

2025-01-15 Thread Marek Vasut
The netc-blk-ctrl driver is used to configure Integrated Endpoint
Register Block (IERB) and Privileged Register Block (PRB) of NETC.
For i.MX platforms, it is also used to configure the NETCMIX block.

The IERB contains registers that are used for pre-boot initialization,
debug, and non-customer configuration. The PRB controls global reset
and global error handling for NETC. The NETCMIX block is mainly used
to set MII protocol and PCS protocol of the links, it also contains
settings for some other functions.

Note the IERB configuration registers can only be written after being
unlocked by PRB, otherwise, all write operations are inhibited. A warm
reset is performed when the IERB is unlocked, and it results in an FLR
to all NETC devices. Therefore, all NETC device drivers must be probed
or initialized after the warm reset is finished.

Ported from Linux 6.13-rc as of commit
fe5ba6bf91b3 ("net: enetc: add initial netc-blk-ctrl driver support")

Signed-off-by: Marek Vasut 
---
Cc: Alice Guo 
Cc: Ilias Apalodimas 
Cc: Jerome Forissier 
Cc: Joe Hershberger 
Cc: Markus Gothe 
Cc: Peng Fan 
Cc: Ramon Fried 
Cc: Robert Marko 
Cc: Romain Naour 
Cc: Simon Glass 
Cc: Tim Harvey 
Cc: Tom Rini 
Cc: Ye Li 
Cc: u-boot@lists.denx.de
---
 drivers/net/Kconfig   |  14 ++
 drivers/net/Makefile  |   1 +
 drivers/net/fsl_enetc_netc_blk_ctrl.c | 346 ++
 3 files changed, 361 insertions(+)
 create mode 100644 drivers/net/fsl_enetc_netc_blk_ctrl.c

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 88ff025a37b..dcf6b4c81fc 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1019,6 +1019,20 @@ config FSL_ENETC
  This driver supports the NXP ENETC Ethernet controller found on some
  of the NXP SoCs.
 
+config FSL_ENETC_NETC_BLK_CTRL
+   bool "NXP ENETC NETC blocks control driver"
+   depends on FSL_ENETC && IMX95
+   default y if IMX95
+   help
+ This driver configures Integrated Endpoint Register Block (IERB) and
+ Privileged Register Block (PRB) of NETC. For i.MX platforms, it also
+ includes the configuration of NETCMIX block.
+ The IERB contains registers that are used for pre-boot initialization,
+ debug, and non-customer configuration. The PRB controls global reset
+ and global error handling for NETC. The NETCMIX block is mainly used
+ to set MII protocol and PCS protocol of the links, it also contains
+ settings for some other functions.
+
 config MDIO_GPIO_BITBANG
bool "GPIO bitbanging MDIO driver"
depends on DM_MDIO && DM_GPIO
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index e51a917933e..c6217f08f14 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_FEC_MXC) += fec_mxc.o
 obj-$(CONFIG_FMAN_ENET) += fm/
 obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o
 obj-$(CONFIG_FSL_ENETC) += fsl_enetc.o fsl_enetc_mdio.o
+obj-$(CONFIG_FSL_ENETC_NETC_BLK_CTRL) += fsl_enetc_netc_blk_ctrl.o
 obj-$(CONFIG_FSL_LS_MDIO) += fsl_ls_mdio.o
 obj-$(CONFIG_FSL_MC_ENET) += fsl-mc/
 obj-$(CONFIG_FSL_MC_ENET) += ldpaa_eth/
diff --git a/drivers/net/fsl_enetc_netc_blk_ctrl.c 
b/drivers/net/fsl_enetc_netc_blk_ctrl.c
new file mode 100644
index 000..46b68d3d8a4
--- /dev/null
+++ b/drivers/net/fsl_enetc_netc_blk_ctrl.c
@@ -0,0 +1,346 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+/*
+ * NXP NETC Blocks Control Driver
+ *
+ * Copyright 2024 NXP
+ *
+ * This driver is used for pre-initialization of NETC, such as PCS and MII
+ * protocols, LDID, warm reset, etc. Therefore, all NETC device drivers can
+ * only be probed after the netc-blk-crtl driver has completed initialization.
+ * In addition, when the system enters suspend mode, IERB, PRB, and NETCMIX
+ * will be powered off, except for WOL. Therefore, when the system resumes,
+ * these blocks need to be reinitialized.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* NETCMIX registers */
+#define IMX95_CFG_LINK_IO_VAR  0x0
+#define  IO_VAR_16FF_16G_SERDES0x1
+#define  IO_VAR(port, var) (((var) & 0xf) << ((port) << 2))
+
+#define IMX95_CFG_LINK_MII_PROT0x4
+#define CFG_LINK_MII_PORT_0GENMASK(3, 0)
+#define CFG_LINK_MII_PORT_1GENMASK(7, 4)
+#define  MII_PROT_MII  0x0
+#define  MII_PROT_RMII 0x1
+#define  MII_PROT_RGMII0x2
+#define  MII_PROT_SERIAL   0x3
+#define  MII_PROT(port, prot)  (((prot) & 0xf) << ((port) << 2))
+
+#define IMX95_CFG_LINK_PCS_PROT(a) (0x8 + (a) * 4)
+#define PCS_PROT_1G_SGMII  BIT(0)
+#define PCS_PROT_2500M_SGMII   BIT(1)
+#define PCS_PROT_XFI   BIT(3)
+#define PCS_PROT_SFI   BIT(4)
+#define PCS_PROT_10G_SXGMIIBIT(6)
+
+/* NETC privileged register block registe

  1   2   3   >