Re: [PATCH 3/4] rockchip: rk3399-rockpro64: Disable bootstage instrumentation config

2024-10-01 Thread Simon Glass
Hi Paul,

On Mon, 30 Sept 2024 at 13:07, Paul Kocialkowski  wrote:
>
> Hi,
>
> Le Mon 30 Sep 24, 12:52, Simon Glass a écrit :
> > On Mon, 30 Sept 2024 at 03:03, Peter Robinson  wrote:
> > > On Thu, 26 Sept 2024 at 19:32, Paul Kocialkowski  
> > > wrote:
> > > > The boot timing and reporting (bootstage) infrastructure is useful for
> > > > performance analysis and debug but adds overhead and console noise when
> > > > using the device normally. Remove it from the device config.
> > > >
> > > > Signed-off-by: Paul Kocialkowski 
> > > Reviewed-by: Peter Robinson 
> > >
> > > This makes sense, for those that want this information will know how
> > > to build it for testing.
> >
> > Can you just disable the report? There should be no need to disable
> > bootstage itself.
>
> I see bootstage as a debug/development feature, so I don't really see why it
> should be enabled on default builds.
>
> Besides the console noise aspect, my intent here is also to tidy up this 
> config.

Well OK.

BTW one day I'd like to see bootstage be on by default, since it
provides a way to monitor boot times for devices. But that would need
some improvements: the current shared-memory approach between SPL and
U-Boot is not great and we could use bloblist instead. Also I'm not
sure how the information could be sent to the OS.

Reviewed-by: Simon Glass 

Regards,
Simon


>
> Cheers,
>
> Paul
>
> > Regards,
> > Simon
> >
> >
> > > > ---
> > > >  configs/rockpro64-rk3399_defconfig | 3 ---
> > > >  1 file changed, 3 deletions(-)
> > > >
> > > > diff --git a/configs/rockpro64-rk3399_defconfig 
> > > > b/configs/rockpro64-rk3399_defconfig
> > > > index fc0804a0b80d..095d27ffaa04 100644
> > > > --- a/configs/rockpro64-rk3399_defconfig
> > > > +++ b/configs/rockpro64-rk3399_defconfig
> > > > @@ -19,8 +19,6 @@ CONFIG_SPL_SPI=y
> > > >  CONFIG_SYS_LOAD_ADDR=0x800800
> > > >  CONFIG_PCI=y
> > > >  CONFIG_DEBUG_UART=y
> > > > -CONFIG_BOOTSTAGE=y
> > > > -CONFIG_BOOTSTAGE_REPORT=y
> > > >  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
> > > >  CONFIG_DISPLAY_BOARDINFO_LATE=y
> > > >  CONFIG_SPL_MAX_SIZE=0x4
> > > > @@ -38,7 +36,6 @@ CONFIG_CMD_POWEROFF=y
> > > >  CONFIG_CMD_USB=y
> > > >  # CONFIG_CMD_SETEXPR is not set
> > > >  CONFIG_CMD_TIME=y
> > > > -CONFIG_CMD_BOOTSTAGE=y
> > > >  CONFIG_SPL_OF_CONTROL=y
> > > >  CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent 
> > > > assigned-clocks assigned-clock-rates assigned-clock-parents"
> > > >  CONFIG_ENV_IS_IN_SPI_FLASH=y
> > > > --
> > > > 2.46.2
> > > >
>
> --
> Paul Kocialkowski,
>
> Independent contractor - sys-base - https://www.sys-base.io/
> Free software developer - https://www.paulk.fr/
>
> Specialist in multimedia, graphics and embedded hardware support with Linux.


Re: [PATCH v2 0/8] bootstd: sunxi: Migrate to standard boot

2024-10-01 Thread Simon Glass
Hi,

On Tue, 1 Oct 2024 at 06:23, Quentin Schulz  wrote:
>
> Hi Mattijs, Simon,
>
> On 10/1/24 2:07 PM, Mattijs Korpershoek wrote:
> > Hi Simon,
> >
> > On mar., oct. 01, 2024 at 05:18, Simon Glass  wrote:
> >
> >> Hi,
> >>
> >> On Fri, 23 Aug 2024 at 14:48, Simon Glass  wrote:
> >>>
> >>> This series attempts to migrate all sunxi boards to use standard boot,
> >>> along with a text environment.
> >>>
> >>> Changes in v2:
> >>> - Add new patch to resolve BOOTSTD->BLK recursion with Kconfig
> >>> - Put the FEL bootmeth before all other global bootmeths
> >>> - Convert the other DISTRO_DEFAULTS in the Kconfig too
> >>> - Keep BOOTCMD_SUNXI_COMPAT
> >>> - Keep bootcmd_sunxi_compat if OLD_SUNXI_KERNEL_COMPAT is enabled
> >>>
> >>> Simon Glass (8):
> >>>blk: Make functions available unconditionally
> >>>bootstd: Avoid calling unavailable block functions
> >>>bootstd: Avoid depending on BLK
> >>>sunxi: Add a bootmeth for FEL
> >>>sunxi: Move to bootstd
> >>>sunxi: Drop old distro boot variables
> >>>env: Provide a work-around for unquoting fdtfile
> >>>sunxi: Move to text environment
> >>>
> >>>   Makefile  |   1 +
> >>>   arch/arm/Kconfig  |  10 +-
> >>>   board/sunxi/sunxi.env | 152 +++
> >>>   boot/Kconfig  |  16 +-
> >>>   boot/Makefile |   1 +
> >>>   boot/bootdev-uclass.c |   3 +
> >>>   boot/bootmeth_fel.c   |  81 ++
> >>>   .../gardena-smart-gateway-mt7688_defconfig|   1 +
> >>>   doc/usage/environment.rst |  12 +
> >>>   include/blk.h |   9 +-
> >>>   include/configs/sunxi-common.h| 238 --
> >>>   11 files changed, 278 insertions(+), 246 deletions(-)
> >>>   create mode 100644 board/sunxi/sunxi.env
> >>>   create mode 100644 boot/bootmeth_fel.c
> >>>
> >>> --
> >>> 2.34.1
> >>>
> >>
> >> I'm just checking on this series. Are there any comments, or can it be 
> >> applied?
> >
> > Quentin mentioned a typo in patch 3/8, see:
> > https://lore.kernel.org/all/1f963aa8-948a-4657-9f1b-a3bc38df4...@cherry.de/
> >
>
> Well, is it really a typo or was this still a WIP patch that made it to
> the ML somehow? That was basically the "question" or concern about "wip"
> appearing in the commit log :)

It was an ex-wip patch which I modified and failed to remove the
'wip'. It was fixed in v3[1] (which I now see that I should have
replied to here)

Regards,
SImon

[1] 
https://patchwork.ozlabs.org/project/uboot/patch/20240901222734.462334-4-...@chromium.org/


Re: [PATCH v2 0/8] bootstd: sunxi: Migrate to standard boot

2024-10-01 Thread Simon Glass
Hi,

On Fri, 23 Aug 2024 at 14:48, Simon Glass  wrote:
>
> This series attempts to migrate all sunxi boards to use standard boot,
> along with a text environment.
>
> Changes in v2:
> - Add new patch to resolve BOOTSTD->BLK recursion with Kconfig
> - Put the FEL bootmeth before all other global bootmeths
> - Convert the other DISTRO_DEFAULTS in the Kconfig too
> - Keep BOOTCMD_SUNXI_COMPAT
> - Keep bootcmd_sunxi_compat if OLD_SUNXI_KERNEL_COMPAT is enabled
>
> Simon Glass (8):
>   blk: Make functions available unconditionally
>   bootstd: Avoid calling unavailable block functions
>   bootstd: Avoid depending on BLK
>   sunxi: Add a bootmeth for FEL
>   sunxi: Move to bootstd
>   sunxi: Drop old distro boot variables
>   env: Provide a work-around for unquoting fdtfile
>   sunxi: Move to text environment
>
>  Makefile  |   1 +
>  arch/arm/Kconfig  |  10 +-
>  board/sunxi/sunxi.env | 152 +++
>  boot/Kconfig  |  16 +-
>  boot/Makefile |   1 +
>  boot/bootdev-uclass.c |   3 +
>  boot/bootmeth_fel.c   |  81 ++
>  .../gardena-smart-gateway-mt7688_defconfig|   1 +
>  doc/usage/environment.rst |  12 +
>  include/blk.h |   9 +-
>  include/configs/sunxi-common.h| 238 --
>  11 files changed, 278 insertions(+), 246 deletions(-)
>  create mode 100644 board/sunxi/sunxi.env
>  create mode 100644 boot/bootmeth_fel.c
>
> --
> 2.34.1
>

I'm just checking on this series. Are there any comments, or can it be applied?

Regards,
Simon


Re: [PATCH] cmd: Make bootvx independent of bootelf

2024-09-30 Thread Simon Glass
Hi Daniel,

On Sun, 29 Sept 2024 at 03:27, Daniel Palmer  wrote:
>
> There are lots of usecases for running baremetal ELF
> binaries via bootelf but if you enable bootelf you
> get bootvx as well and you probably don't want or need
> it.
>
> Hide bootvx behind it's own configuration option.
>
> Signed-off-by: Daniel Palmer 
> ---
>  cmd/Kconfig | 11 +--
>  cmd/elf.c   |  6 ++
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 978f44eda426..262c4118f7f6 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -491,11 +491,18 @@ config CMD_CEDIT
>   loading and saving of configuration as well as showing an editor.
>
>  config CMD_ELF
> -   bool "bootelf, bootvx"
> +   bool "bootelf"
> default y
> select LIB_ELF
> help
> - Boot an ELF/vxWorks image from the memory.
> + Boot an ELF image from memory.
> +
> +config CMD_ELF_BOOTVX
> +   bool "bootvx"
> +   default y
> +   depends on CMD_ELF
> +   help
> + Boot a vxWorks image from memory
>
>  config CMD_ELF_FDT_SETUP
> bool "Flattened Device Tree setup in bootelf cmd"
> diff --git a/cmd/elf.c b/cmd/elf.c
> index 673c6c30511c..fe7f06ef74eb 100644
> --- a/cmd/elf.c
> +++ b/cmd/elf.c
> @@ -10,8 +10,10 @@
>  #include 
>  #include 
>  #include 
> +#ifdef CONFIG_CMD_ELF_BOOTVX
>  #include 
>  #include 
> +#endif

No need to #idef headers files. Just include them always.

>  #ifdef CONFIG_X86
>  #include 
>  #include 
> @@ -100,6 +102,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
> return rcode;
>  }
>
> +#ifdef CONFIG_CMD_ELF_BOOTVX
>  /*
>   * Interpreter command to boot VxWorks from a memory image.  The image can
>   * be either an ELF image or a raw binary.  Will attempt to setup the
> @@ -307,6 +310,7 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>
> return 1;
>  }
> +#endif
>
>  U_BOOT_CMD(
> bootelf, CONFIG_SYS_MAXARGS, 0, do_bootelf,
> @@ -323,8 +327,10 @@ U_BOOT_CMD(
>  #endif
>  );
>
> +#ifdef CONFIG_CMD_ELF_BOOTVX
>  U_BOOT_CMD(
> bootvx, 2, 0, do_bootvx,
> "Boot vxWorks from an ELF image",
> " [address] - load address of vxWorks ELF image."
>  );

This needs a doc/usage/cmd update

I'm not sure if it is possible to test it in CI?

> +#endif
> --
> 2.43.0
>

Regards,
Simon


Re: [PATCH v3 2/2] binman: add fast authentication method for i.MX8M signing

2024-09-30 Thread Simon Glass
Hi Brian,

On Mon, 30 Sept 2024 at 10:10, Brian Ruley  wrote:
>
> Using the PKI tree with SRKs as intermediate CA isn't necessary or even
> desirable in some situations (boot time, for example). Add the possibility

spelling

> to use the "fast authentication" method where the image and CSF are both
> signed using the SRK [1, p.63].
>
> [1] 
> https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
>
> Signed-off-by: Brian Ruley 
> Cc: Marek Vasut 
>
>  tools/binman/etype/nxp_imx8mcst.py | 23 +++
>  1 file changed, 19 insertions(+), 4 deletions(-)

That should be below the --- (you can use patman to get this right
automatically)
> ---
>  tools/binman/etype/nxp_imx8mcst.py | 44 ++
>  1 file changed, 32 insertions(+), 12 deletions(-)
>
> diff --git a/tools/binman/etype/nxp_imx8mcst.py 
> b/tools/binman/etype/nxp_imx8mcst.py
> index 0c744a00d7..a80cb94499 100644
> --- a/tools/binman/etype/nxp_imx8mcst.py
> +++ b/tools/binman/etype/nxp_imx8mcst.py
> @@ -36,6 +36,9 @@ csf_config_template = '''
>File = "SRK_1_2_3_4_table.bin"
>Source index = 0
>
> +[Install NOCAK]
> +  File = "SRK1_sha256_4096_65537_v3_usr_crt.pem"
> +
>  [Install CSFK]
>File = "CSF1_1_sha256_4096_65537_v3_usr_crt.pem"

Since 'sha256_4096_65537_v3_usr_crt.' is common to everything, could
you have a variable, say keyname, and use that everywhere?

>
> @@ -74,16 +77,25 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  self._node, 'nxp,srk-table',
>  'SRK_1_2_3_4_table.bin'
>   ))
> -self.csf_crt = os.getenv(
> -'CSF_KEY', fdt_util.GetString(
> -   self._node, 'nxp,csf-crt',
> -   'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'
> -   ))
> -self.img_crt = os.getenv(
> -'IMG_KEY', fdt_util.GetString(
> -   self._node, 'nxp,img-crt',
> -   'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'
> -   ))
> +self.fast_auth = fdt_util.GetBool(self._node, 'nxp,fast-auth')
> +if not self.fast_auth:
> +self.csf_crt = os.getenv(
> +'CSF_KEY', fdt_util.GetString(
> +   self._node, 'nxp,csf-crt',
> +   'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'

e.g. f'CSF1_1_{keyname}'

> +   ))
> +self.img_crt = os.getenv(
> +'IMG_KEY', fdt_util.GetString(
> +   self._node, 'nxp,img-crt',
> +   'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'
> +   ))
> +else:
> +self.srk_crt = os.getenv(
> +'SRK_KEY', fdt_util.GetString(
> +   self._node, 'nxp,srk-crt',
> +   'SRK1_sha256_4096_65537_v3_usr_crt.pem'
> +   ))

All three options seem to read the 'nxp,srk-crt' property, so you can
do that once the if() to reduce the amount of duplicated code.

> +
>  self.unlock = fdt_util.GetBool(self._node, 'nxp,unlock')
>  self.ReadEntries()
>
> @@ -137,8 +149,16 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  # Load configuration template and modify keys of interest
>  config.read_string(csf_config_template)
>  config['Install SRK']['File'] = '"' + self.srk_table + '"'

This is what I mean by the f-string:

f'"{self.srk_table}"'

> -config['Install CSFK']['File'] = '"' + self.csf_crt + '"'
> -config['Install Key']['File'] = '"' + self.img_crt + '"'
> +if not self.fast_auth:
> +config.remove_section('Install NOCAK')
> +config['Install CSFK']['File'] = '"' + self.csf_crt + '"'
> +config['Install Key']['File'] = '"' + self.img_crt + '"'
> +else:
> +config.remove_section('Install CSFK')
> +config.remove_section('Install Key')
> +config['Install NOCAK']['File'] = '"' + self.srk_crt + '"'
> +config['Authenticate Data']['Verification index'] = '0'
> +
>  config['Authenticate Data']['Blocks'] = (hex(signbase) + ' 0 '
>   + hex(len(data)) + ' "'
>   + str(output_dname) + '"')

Can use f-strings here too, e.g.

f'{signbase:#x} 0 {len(data):#x} ...

> --
> 2.39.5
>

Regards,
Simon


[PATCH 2/3] binman: Support getting test-coverage on just one test

2024-09-30 Thread Simon Glass
Pass the arguments through to test_util so that a single test can be
used.

Update the docs and add some missing backquotes in the same section.

Signed-off-by: Simon Glass 
---

 tools/binman/binman.rst | 5 -
 tools/binman/main.py| 6 +++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index f9a3a42183b..c25914312a8 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -2099,12 +2099,15 @@ Code coverage
 -
 
 Binman is a critical tool and is designed to be very testable. Entry
-implementations target 100% test coverage. Run 'binman test -T' to check this.
+implementations target 100% test coverage. Run ``binman test -T`` to check 
this.
 
 To enable Python test coverage on Debian-type distributions (e.g. Ubuntu)::
 
$ sudo apt-get install python-coverage python3-coverage python-pytest
 
+You can also check the coverage provided by a single test, e.g.::
+
+   binman test -T testSimple
 
 Exit status
 ---
diff --git a/tools/binman/main.py b/tools/binman/main.py
index dc817ddcd42..619840e7d55 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -85,7 +85,7 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, 
args, toolpath):
 
 return (0 if result.wasSuccessful() else 1)
 
-def RunTestCoverage(toolpath, build_dir):
+def RunTestCoverage(toolpath, build_dir, args):
 """Run the tests and check that we get 100% coverage"""
 glob_list = control.GetEntryModules(False)
 all_set = set([os.path.splitext(os.path.basename(item))[0]
@@ -97,7 +97,7 @@ def RunTestCoverage(toolpath, build_dir):
 test_util.run_test_coverage('tools/binman/binman', None,
 ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*',
  'tools/u_boot_pylib/*'],
-build_dir, all_set, extra_args or None)
+build_dir, all_set, extra_args or None, args=args)
 
 def RunBinman(args):
 """Main entry point to binman once arguments are parsed
@@ -117,7 +117,7 @@ def RunBinman(args):
 
 if args.cmd == 'test':
 if args.test_coverage:
-RunTestCoverage(args.toolpath, args.build_dir)
+RunTestCoverage(args.toolpath, args.build_dir, args.tests)
 else:
 ret_code = RunTests(args.debug, args.verbosity, args.processes,
 args.test_preserve_dirs, args.tests,
-- 
2.34.1



[PATCH 1/3] u_boot_pylib: Support running coverage on selected functions

2024-09-30 Thread Simon Glass
At present run_test_coverage() assumes you want code coverage for the
entire code base. This is the normal situation, but sometimes it is
useful to see the coverage provided by just a single test. Add support
for this.

Signed-off-by: Simon Glass 
---

 tools/u_boot_pylib/test_util.py | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/u_boot_pylib/test_util.py b/tools/u_boot_pylib/test_util.py
index 857ce58c98c..dd671965263 100644
--- a/tools/u_boot_pylib/test_util.py
+++ b/tools/u_boot_pylib/test_util.py
@@ -23,8 +23,9 @@ except:
 use_concurrent = False
 
 
-def run_test_coverage(prog, filter_fname, exclude_list, build_dir, 
required=None,
-extra_args=None, single_thread='-P1'):
+def run_test_coverage(prog, filter_fname, exclude_list, build_dir,
+  required=None, extra_args=None, single_thread='-P1',
+  args=None):
 """Run tests and check that we get 100% coverage
 
 Args:
@@ -42,6 +43,7 @@ def run_test_coverage(prog, filter_fname, exclude_list, 
build_dir, required=None
 single_thread (str): Argument string to make the tests run
 single-threaded. This is necessary to get proper coverage results.
 The default is '-P0'
+args (list of str): List of tests to run, or None to run all
 
 Raises:
 ValueError if the code coverage is not 100%
@@ -66,9 +68,10 @@ def run_test_coverage(prog, filter_fname, exclude_list, 
build_dir, required=None
'coverage')
 
 cmd = ('%s%s run '
-   '--omit "%s" %s %s %s %s' % (prefix, covtool, ','.join(glob_list),
-prog, extra_args or '', test_cmd,
-single_thread or '-P1'))
+   '--omit "%s" %s %s %s %s %s' % (prefix, covtool, 
','.join(glob_list),
+   prog, extra_args or '', test_cmd,
+   single_thread or '-P1',
+   ' '.join(args) if args else ''))
 os.system(cmd)
 stdout = command.output(covtool, 'report')
 lines = stdout.splitlines()
-- 
2.34.1



Re: [PATCH v3 1/2] binman: cosmetic: code formatting fixes

2024-09-30 Thread Simon Glass
Hi Brian,

On Mon, 30 Sept 2024 at 10:10, Brian Ruley  wrote:
>
> Conform to the style guide used in the project by making the following
> changes:
> * Use single quotes for multiline strings (except docstrings)
> * Fix line width to 79 cols
> * Use f-string instead of formatting a regular string
>
> Signed-off-by: Brian Ruley 
> ---
>  tools/binman/etype/nxp_imx8mcst.py | 28 +---
>  1 file changed, 21 insertions(+), 7 deletions(-)

Reviewed-by: Simon Glass 

Thanks for doing this.

Some of my comments on the other patch could be applied here, if you prefer.

>
> diff --git a/tools/binman/etype/nxp_imx8mcst.py 
> b/tools/binman/etype/nxp_imx8mcst.py
> index 8221517b0c..0c744a00d7 100644
> --- a/tools/binman/etype/nxp_imx8mcst.py
> +++ b/tools/binman/etype/nxp_imx8mcst.py
> @@ -23,7 +23,7 @@ from u_boot_pylib import tools
>  MAGIC_NXP_IMX_IVT = 0x412000d1
>  MAGIC_FITIMAGE= 0xedfe0dd0
>
> -csf_config_template = """
> +csf_config_template = '''
>  [Header]
>Version = 4.3
>Hash Algorithm = sha256
> @@ -53,7 +53,7 @@ csf_config_template = """
>  [Authenticate Data]
>Verification index = 2
>Blocks = 0x1234 0x78 0xabcd "data.bin"
> -"""
> +'''
>
>  class Entry_nxp_imx8mcst(Entry_mkimage):
>  """NXP i.MX8M CST .cfg file generator and cst invoker
> @@ -69,9 +69,21 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  def ReadNode(self):
>  super().ReadNode()
>  self.loader_address = fdt_util.GetInt(self._node, 
> 'nxp,loader-address')
> -self.srk_table = os.getenv('SRK_TABLE', 
> fdt_util.GetString(self._node, 'nxp,srk-table', 'SRK_1_2_3_4_table.bin'))
> -self.csf_crt = os.getenv('CSF_KEY', fdt_util.GetString(self._node, 
> 'nxp,csf-crt', 'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'))
> -self.img_crt = os.getenv('IMG_KEY', fdt_util.GetString(self._node, 
> 'nxp,img-crt', 'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'))
> +self.srk_table = os.getenv(
> +'SRK_TABLE', fdt_util.GetString(
> +self._node, 'nxp,srk-table',
> +'SRK_1_2_3_4_table.bin'
> + ))
> +self.csf_crt = os.getenv(
> +'CSF_KEY', fdt_util.GetString(
> +   self._node, 'nxp,csf-crt',
> +   'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'
> +   ))
> +self.img_crt = os.getenv(
> +'IMG_KEY', fdt_util.GetString(
> +   self._node, 'nxp,img-crt',
> +   'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'
> +   ))
>  self.unlock = fdt_util.GetBool(self._node, 'nxp,unlock')
>  self.ReadEntries()
>
> @@ -118,7 +130,7 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  tools.write_file(output_dname, data)
>
>  # Generate CST configuration file used to sign payload
> -cfg_fname = tools.get_output_filename('nxp.csf-config-txt.%s' % uniq)
> +cfg_fname = tools.get_output_filename(f'nxp.csf-config-txt.{uniq}')
>  config = configparser.ConfigParser()
>  # Do not make key names lowercase
>  config.optionxform = str
> @@ -127,7 +139,9 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  config['Install SRK']['File'] = '"' + self.srk_table + '"'
>  config['Install CSFK']['File'] = '"' + self.csf_crt + '"'
>  config['Install Key']['File'] = '"' + self.img_crt + '"'
> -config['Authenticate Data']['Blocks'] = hex(signbase) + ' 0 ' + 
> hex(len(data)) + ' "' + str(output_dname) + '"'
> +config['Authenticate Data']['Blocks'] = (hex(signbase) + ' 0 '
> + + hex(len(data)) + ' "'
> + + str(output_dname) + '"')
>  if not self.unlock:
>  config.remove_section('Unlock')
>  with open(cfg_fname, 'w') as cfgf:
> --
> 2.39.5
>

Regards,
Simon


Re: [PATCH] Extend usage for OF_OVERLAY_LIST beyond SPL

2024-09-30 Thread Simon Glass
On Mon, 30 Sept 2024 at 06:05, Sumit Garg  wrote:
>
> On Mon, 30 Sept 2024 at 15:50, Jan Kiszka  wrote:
> >
> > From: Jan Kiszka 
> >
> > Allow to use OF_OVERLAY_LIST also for the case that the overlays just
> > need be built, e.g. when they will be picked up by binman as artifacts
> > of the final U-Boot image. The IOT2050 boards have such a need when
> > switching to OF_UPSTREAM.
> >
> > Signed-off-by: Jan Kiszka 
> > ---
> >
> > While waiting for the merge of v6.12-rc1-dts and while seeing related
> > but different attempts to address the overlay topic. See the patch
> > in use here:
> >
> > https://github.com/siemens/u-boot/commits/jan/iot2050
> >
> >  dts/Kconfig  | 4 ++--
> >  scripts/Makefile.dts | 1 +
> >  2 files changed, 3 insertions(+), 2 deletions(-)
> >
>
> Reviewed-by: Sumit Garg 
>

Reviewed-by: Simon Glass 


Re: [PATCH 3/4] rockchip: rk3399-rockpro64: Disable bootstage instrumentation config

2024-09-30 Thread Simon Glass
Hi,

On Mon, 30 Sept 2024 at 03:03, Peter Robinson  wrote:
>
> On Thu, 26 Sept 2024 at 19:32, Paul Kocialkowski  wrote:
> >
> > From: Paul Kocialkowski 
> >
> > The boot timing and reporting (bootstage) infrastructure is useful for
> > performance analysis and debug but adds overhead and console noise when
> > using the device normally. Remove it from the device config.
> >
> > Signed-off-by: Paul Kocialkowski 
> Reviewed-by: Peter Robinson 
>
> This makes sense, for those that want this information will know how
> to build it for testing.

Can you just disable the report? There should be no need to disable
bootstage itself.

Regards,
Simon


> > ---
> >  configs/rockpro64-rk3399_defconfig | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/configs/rockpro64-rk3399_defconfig 
> > b/configs/rockpro64-rk3399_defconfig
> > index fc0804a0b80d..095d27ffaa04 100644
> > --- a/configs/rockpro64-rk3399_defconfig
> > +++ b/configs/rockpro64-rk3399_defconfig
> > @@ -19,8 +19,6 @@ CONFIG_SPL_SPI=y
> >  CONFIG_SYS_LOAD_ADDR=0x800800
> >  CONFIG_PCI=y
> >  CONFIG_DEBUG_UART=y
> > -CONFIG_BOOTSTAGE=y
> > -CONFIG_BOOTSTAGE_REPORT=y
> >  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
> >  CONFIG_DISPLAY_BOARDINFO_LATE=y
> >  CONFIG_SPL_MAX_SIZE=0x4
> > @@ -38,7 +36,6 @@ CONFIG_CMD_POWEROFF=y
> >  CONFIG_CMD_USB=y
> >  # CONFIG_CMD_SETEXPR is not set
> >  CONFIG_CMD_TIME=y
> > -CONFIG_CMD_BOOTSTAGE=y
> >  CONFIG_SPL_OF_CONTROL=y
> >  CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks 
> > assigned-clock-rates assigned-clock-parents"
> >  CONFIG_ENV_IS_IN_SPI_FLASH=y
> > --
> > 2.46.2
> >


Re: [PATCH v1] mailbox: support timeout when sending

2024-09-30 Thread Simon Glass
Hi,

On Sun, 29 Sept 2024 at 06:54,  wrote:
>
> From: Peng Fan 
>
> Add timeout support for mbox_send.
>
> Signed-off-by: Peng Fan 
> Signed-off-by: Alice Guo 
> Reviewed-by: Ye Li 
> ---
>  drivers/mailbox/mailbox-uclass.c | 19 ++-
>  include/mailbox.h|  2 ++
>  2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/mailbox-uclass.c 
> b/drivers/mailbox/mailbox-uclass.c
> index 4bf4987ce0..0ca8b3770f 100644
> --- a/drivers/mailbox/mailbox-uclass.c
> +++ b/drivers/mailbox/mailbox-uclass.c
> @@ -117,10 +117,27 @@ int mbox_free(struct mbox_chan *chan)
>  int mbox_send(struct mbox_chan *chan, const void *data)
>  {
> struct mbox_ops *ops = mbox_dev_ops(chan->dev);
> +   ulong start_time, timeout_us;
> +   int ret;
>
> debug("%s(chan=%p, data=%p)\n", __func__, chan, data);
>
> -   return ops->send(chan, data);
> +   start_time = timer_get_us();
> +   timeout_us = chan->tx_timeout_us;
> +   /*
> +* Account for partial us ticks, but if timeout_us is 0, ensure we
> +* still don't wait at all.
> +*/
> +   if (timeout_us)
> +   timeout_us++;
> +
> +   for (;;) {
> +   ret = ops->send(chan, data);
> +   if (ret != -EBUSY)
> +   return ret;
> +   if ((timer_get_us() - start_time) >= timeout_us)

get_timer_us_long(start_time) >= timeout_us

would be better here as it is designed to do the maths for you!

> +   return -ETIMEDOUT;
> +   }
>  }
>
>  int mbox_recv(struct mbox_chan *chan, void *data, ulong timeout_us)
> diff --git a/include/mailbox.h b/include/mailbox.h
> index e70266fb61..3cc64f20b7 100644
> --- a/include/mailbox.h
> +++ b/include/mailbox.h
> @@ -46,6 +46,7 @@ struct udevice;
>   *
>   * @dev: The device which implements the mailbox.
>   * @id: The mailbox channel ID within the provider.
> + * @tx_timeout_us: The tx timeout in us.
>   * @con_priv: Hook for controller driver to attach private data
>   *
>   * Currently, the mailbox API assumes that a single integer ID is enough to
> @@ -61,6 +62,7 @@ struct mbox_chan {
> struct udevice *dev;
> /* Written by of_xlate.*/
> unsigned long id;
> +   unsigned long tx_timeout_us;

ulong

> void *con_priv;
>  };
>
> --
> 2.34.1
>

Please also update test/dm/mailbox.c so this new feature is tested in
CI. You can use timer_test_add_offset() in a test to add to the
current (faked) time.

Regards,
Simon


[PATCH 3/3] binman: Add a tutorial on resolving test-coverage bugs

2024-09-30 Thread Simon Glass
Provide a short description of how tests work, why they are so critical
and how to resolve gaps in Binman's test coverage.

Signed-off-by: Simon Glass 
---

 MAINTAINERS  |   1 +
 doc/develop/binman_tests.rst | 734 +++
 doc/develop/index.rst|   1 +
 tools/binman/binman.rst  |   5 +
 4 files changed, 741 insertions(+)
 create mode 100644 doc/develop/binman_tests.rst

diff --git a/MAINTAINERS b/MAINTAINERS
index 7ab39d91a55..65a9ea1face 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -909,6 +909,7 @@ BINMAN
 M: Simon Glass 
 M: Alper Nebi Yasak 
 S: Maintained
+F: doc/develop/binman_tests.rst
 F: tools/binman/
 
 BLKMAP
diff --git a/doc/develop/binman_tests.rst b/doc/develop/binman_tests.rst
new file mode 100644
index 000..a632694a6fe
--- /dev/null
+++ b/doc/develop/binman_tests.rst
@@ -0,0 +1,734 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+.. toctree::
+   :maxdepth: 1
+
+Binman Tests
+
+
+.. contents::
+   :depth: 2
+   :local:
+
+There is some material on writing tests in the main Binman documentation
+(see :doc:`package/index`). This short guide is separate so people don't
+feel they have to read as much.
+
+Code and output is mostly included verbatim, which makes the doc longer, but
+avoids its becoming confusing when the output or referenced code changes in the
+future.
+
+Purpose
+---
+
+The main purpose of tests in Binman is to make sure that Binman actually does
+what it is supposed to. Various people contribute code, refactoring is done
+over time, but U-Boot users (developers, SoC vendors, board vendors) rely on
+Binman producing images which function correctly. Without tests, a one-line
+change could unintentionally break a corner-case and the problem might not be
+noticed for months. Debugging an image-generation problem with a board you
+don't have can be very hard.
+
+A secondary purpose is productivity. U-Boot contributors are busy and often
+have too much on their plate. Trying to figure out why their patch broke
+some other vendor's workflow can be very time-consuming and frustrating. By
+building in tests from the start, this is largely avoided. If your change has
+full test coverage and doesn't break any test, all is well and no one can
+complain.
+
+A lessor purpose is to document what Binman actually does. If a test covers a
+feature, it works. If there is no test coverage, no one can say for sure
+whether it works in all expected situations, certainly not wihout manual
+effort.
+
+In fact, strictly speaking it isn't completely clear what 'works' even means in
+the case where these is no test to cover the code. We are often left guessing
+as to what the documentation means, what was actually intended, etc.
+
+Finally, code-coverage helps to remove 'zombie code', copied from elsewhere
+because it looks reasonable, but not actually needed. The same situation arises
+in silicon-chip design, where a part of the chip is not validated. If it isn't
+validated, it can be assumed not to work, either now or later, so it is best to
+remove that logic to avoid it causing problems.
+
+Setting up
+--
+
+Binman tests use various utility programs. Most of these are documented in
+:doc:`../build/gcc`. But some are SoC-specific. To fetch these, tell Binman to
+fetch or build any missing tools:
+
+.. code-block:: bash
+
+$ binman tool -f missing
+
+When this completes successfully, you can list the tools. You should see
+something like this:
+
+.. code-block:: bash
+
+$ binman tool -l
+Name Version  DescriptionPath
+---  ---  -  
--
+bootgen  ** Bootg Xilinx Bootgen 
/home/sglass/.binman-tools/bootgen
+bzip21.0.8bzip2 compression  /usr/bin/bzip2
+cbfstool unknown  Manipulate CBFS files  
/home/sglass/bin/cbfstool
+fdt_add_pubkey   unknown  Generate image for U-Boot  
/home/sglass/bin/fdt_add_pubkey
+fdtgrep  unknown  Grep devicetree files  
/home/sglass/bin/fdtgrep
+fiptool  v2.11.0(rele Manipulate ATF FIP files   
/home/sglass/.binman-tools/fiptool
+futility v0.0.1-9f2e9 Chromium OS firmware utili 
/home/sglass/.binman-tools/futility
+gzip 1.12 gzip compression   /usr/bin/gzip
+ifwitool unknown  Manipulate Intel IFWI file 
/home/sglass/.binman-tools/ifwitool
+lz4  v1.9.4   lz4 compression/usr/bin/lz4
+lzma_alone   9.22 betalzma_alone compression 
/usr/bin/lzma_alone
+lzop v1.04lzo compression/usr/bin/lzop
+mkeficapsule 2024.10-rc5- mkeficapsule tool for gene 
/home/sglass/bin/mkeficapsule
+mkimage  2024.10-rc5- Generate image for U-Boot  
/hom

Re: [PATCH] binman: add fast authentication method for i.MX8M signing

2024-09-30 Thread Simon Glass
Hi Brian,

On Mon, 30 Sept 2024 at 08:47, Brian Ruley  wrote:
>
> On Mon, Sep 30, 2024 at 08:10:49AM -0600, Simon Glass wrote:
> >
> > WARNING: This email originated from outside of GE HealthCare. Please 
> > validate the sender's email address before clicking on links or attachments 
> > as they may not be safe.
> >
> > Hi Brian,
> >
> > On Mon, 30 Sept 2024 at 07:01, Brian Ruley  
> > wrote:
> > >
> > > On Sun, Sep 29, 2024 at 06:46:23PM -0600, Tom Rini wrote:
> > > > On Sun, Sep 29, 2024 at 04:49:17PM -0600, Simon Glass wrote:
> > > > > Hi Fabio,
> > > > >
> > > > > On Sun, 29 Sept 2024 at 14:53, Fabio Estevam  
> > > > > wrote:
> > > > > >
> > > > > > Hi Simon, Marek, and Tom,
> > > > > >
> > > > > > On Fri, Sep 27, 2024 at 5:47???PM Tom Rini  
> > > > > > wrote:
> > > > > >
> > > > > > > > Please can you coordinate with Marek as we need to sort out the 
> > > > > > > > test
> > > > > > > > coverage for this etype, before adding more functionality. I 
> > > > > > > > did a
> > > > > > > > starting point, now in -next, which should help.
> > > > > > >
> > > > > > > Well, when someone has both time and understanding of the tools 
> > > > > > > and the
> > > > > > > frameworks, we can expand the automatic tests while still having
> > > > > > > functional testing as people use the feature.
> > > > > >
> > > > > > Do you think this patch should be applied as is? Could the tests be
> > > > > > handled later?
> > > > > >
> > > > > > Please let me know.
> > > > >
> > > > > Who is going to handle the tests later and when?
> > > >
> > > > Someone, once how to write and run the tests is documented. That's a
> > > > big hurdle this private thread has shown, to me at least.
> > > >
> > > > --
> > > > Tom
> > >
> > > Hi,
> > >
> > > I fixed a minor issue in the patch, and sent a revised version.
> > >
> > > Seems that you don't have the testing quite defined yet, so I don't know
> > > what I can contribute there. Maybe something can be done with the CSF
> > > parser to check that the signing works correctly?
> >
> > Just to be clear, the testing is fully defined...this is actually the
> > only entry type which doesn't have a proper test. Every other user was
> > able to add a test. The goal here isn't really to check that external
> > tools are working (they should have their own tests), more to check
> > that Binman is doing the right thing.
> >
> > I will get some sort of patch out by tomorrow morning to help this process.
> >
> > >
> > > However, I think this feature is quite benign, and it would be great to
> > > get some functional testing in for this feature, as Tom said. For us,
> > > this is an important feature, so we have done extensive testing
> > > internally to verify that it works.
> >
> > I fully understand that...but of course without an automated test in
> > Binman it may break at any moment, as Binman continues to be expanded.
> >
> > BTW, minor code-style things: U-Boot's Python code uses single quotes
> > and the line limit is 80cols.
> >
> > Regards,
> > Simon
>
> Hi Simon,
>
> > Just to be clear, the testing is fully defined...this is actually the
> > only entry type which doesn't have a proper test. Every other user was
> > able to add a test. The goal here isn't really to check that external
> > tools are working (they should have their own tests), more to check
> > that Binman is doing the right thing.
> >
> > I will get some sort of patch out by tomorrow morning to help this process.
>
> Alrighty. I'll include a test once we get this sorted out.
>
> > BTW, minor code-style things: U-Boot's Python code uses single quotes
> > and the line limit is 80cols.
>
> I don't understand what you mean because I did use single quotes :)
> Perhaps you were looking at the CSF template, which is not Python code?

Ah OK, I see. It would be less confusing if you used f-strings.
Unfortunately Binman does not use them always and there are tons of
pylint warnings about it.

>
> As for the column width, sorry, I was only trying to follow the pattern
> in the file. I thought it was 120 cols. I will include a predecessor
> patch to fix the column width to 80.

Oh, OK, yes I wasn't around when the original patch was sent so didn't
review it.

Regards,
SImon


Re: [PATCH v6 09/12] efi_loader: Add a test app

2024-09-30 Thread Simon Glass
Hi Heinrich,

On Mon, 30 Sept 2024 at 06:05, Heinrich Schuchardt  wrote:
>
> On 27.09.24 18:50, Simon Glass wrote:
> > Hi Ilias,
> >
> > On Fri, 27 Sept 2024 at 07:51, Ilias Apalodimas
> >  wrote:
> >>
> >> Hi Simon,
> >>
> >> On Fri, 27 Sept 2024 at 01:04, Simon Glass  wrote:
> >>>
> >>> Add a simple app to use for testing. This is intended to do whatever it
> >>> needs to for testing purposes. For now it just prints a message and
> >>> exits boot services.
> >>>
> >>> Signed-off-by: Simon Glass 
> >>> ---
> >>>
> >>> (no changes since v1)
> >>>
> >>>   lib/efi_loader/Kconfig   | 10 ++
> >>>   lib/efi_loader/Makefile  |  1 +
> >>>   lib/efi_loader/testapp.c | 68 
> >>>   3 files changed, 79 insertions(+)
> >>>   create mode 100644 lib/efi_loader/testapp.c
> >>>
> >>> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> >>> index 6f6fa8d629d..41083e7c137 100644
> >>> --- a/lib/efi_loader/Kconfig
> >>> +++ b/lib/efi_loader/Kconfig
> >>> @@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE
> >>>No additional space will be required in the resulting U-Boot 
> >>> binary
> >>>when this option is enabled.
> >>>
> >>> +config BOOTEFI_TESTAPP_COMPILE
> >>> +   bool "Compile an EFI test app for testing"
> >>> +   default y
> >>> +   help
> >>> + This compiles an app designed for testing. It is packed into an 
> >>> image
> >>> + by the test.py testing frame in the setup_efi_image() function.
> >>> +
> >>> + No additional space will be required in the resulting U-Boot 
> >>> binary
> >>> + when this option is enabled.
> >>> +
> >>>   endif
> >>>
> >>>   source "lib/efi/Kconfig"
> >>> diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> >>> index 00d18966f9e..87131ab911d 100644
> >>> --- a/lib/efi_loader/Makefile
> >>> +++ b/lib/efi_loader/Makefile
> >>> @@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump
> >>>   ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
> >>>   apps-y += dtbdump
> >>>   endif
> >>> +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp
> >>>
> >>>   obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
> >>>   obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.o
> >>> diff --git a/lib/efi_loader/testapp.c b/lib/efi_loader/testapp.c
> >>> new file mode 100644
> >>> index 000..feb444c92e9
> >>> --- /dev/null
> >>> +++ b/lib/efi_loader/testapp.c
> >>> @@ -0,0 +1,68 @@
> >>> +// SPDX-License-Identifier: GPL-2.0+
> >>> +/*
> >>> + * Hello world EFI application
> >>> + *
> >>> + * Copyright 2024 Google LLC
> >>> + * Written by Simon Glass 
> >>> + *
> >>> + * This test program is used to test the invocation of an EFI 
> >>> application.
> >>> + * It writes a few messages to the console and then exits boot services
> >>> + */
> >>> +
> >>> +#include 
> >>> +
> >>> +static const efi_guid_t loaded_image_guid = 
> >>> EFI_LOADED_IMAGE_PROTOCOL_GUID;
> >>> +
> >>> +static struct efi_system_table *systable;
> >>> +static struct efi_boot_services *boottime;
> >>> +static struct efi_simple_text_output_protocol *con_out;
> >>> +
> >>> +/**
> >>> + * efi_main() - entry point of the EFI application.
> >>> + *
> >>> + * @handle:handle of the loaded image
> >>> + * @systab:system table
> >>> + * Return: status code
> >>> + */
> >>> +efi_status_t EFIAPI efi_main(efi_handle_t handle,
> >>> +struct efi_system_table *systab)
> >>> +{
> >>> +   struct efi_loaded_image *loaded_image;
> >>> +   efi_status_t ret;
> >>> +   efi_uintn_t map_size;
> >>> +   efi_uintn_t map_key;
> >>> +   efi_uintn_t desc_size;
> >>> +   u32 desc_version;
> >>> +
> >>> +   systable = systab;
> >>> + 

Re: [PATCH] binman: add fast authentication method for i.MX8M signing

2024-09-30 Thread Simon Glass
Hi Brian,

On Mon, 30 Sept 2024 at 07:01, Brian Ruley  wrote:
>
> On Sun, Sep 29, 2024 at 06:46:23PM -0600, Tom Rini wrote:
> > On Sun, Sep 29, 2024 at 04:49:17PM -0600, Simon Glass wrote:
> > > Hi Fabio,
> > >
> > > On Sun, 29 Sept 2024 at 14:53, Fabio Estevam  wrote:
> > > >
> > > > Hi Simon, Marek, and Tom,
> > > >
> > > > On Fri, Sep 27, 2024 at 5:47???PM Tom Rini  wrote:
> > > >
> > > > > > Please can you coordinate with Marek as we need to sort out the test
> > > > > > coverage for this etype, before adding more functionality. I did a
> > > > > > starting point, now in -next, which should help.
> > > > >
> > > > > Well, when someone has both time and understanding of the tools and 
> > > > > the
> > > > > frameworks, we can expand the automatic tests while still having
> > > > > functional testing as people use the feature.
> > > >
> > > > Do you think this patch should be applied as is? Could the tests be
> > > > handled later?
> > > >
> > > > Please let me know.
> > >
> > > Who is going to handle the tests later and when?
> >
> > Someone, once how to write and run the tests is documented. That's a
> > big hurdle this private thread has shown, to me at least.
> >
> > --
> > Tom
>
> Hi,
>
> I fixed a minor issue in the patch, and sent a revised version.
>
> Seems that you don't have the testing quite defined yet, so I don't know
> what I can contribute there. Maybe something can be done with the CSF
> parser to check that the signing works correctly?

Just to be clear, the testing is fully defined...this is actually the
only entry type which doesn't have a proper test. Every other user was
able to add a test. The goal here isn't really to check that external
tools are working (they should have their own tests), more to check
that Binman is doing the right thing.

I will get some sort of patch out by tomorrow morning to help this process.

>
> However, I think this feature is quite benign, and it would be great to
> get some functional testing in for this feature, as Tom said. For us,
> this is an important feature, so we have done extensive testing
> internally to verify that it works.

I fully understand that...but of course without an automated test in
Binman it may break at any moment, as Binman continues to be expanded.

BTW, minor code-style things: U-Boot's Python code uses single quotes
and the line limit is 80cols.

Regards,
Simon


[PATCH v3 25/33] drivers: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD

2024-09-29 Thread Simon Glass
Use the new symbol to refer to any 'SPL' build, including TPL and VPL

Signed-off-by: Simon Glass 
---

Changes in v3:
- Split into several patches

 drivers/Makefile  |  4 +-
 drivers/block/Makefile|  2 +-
 drivers/bus/Makefile  |  2 +-
 drivers/clk/altera/clk-agilex.c   |  2 +-
 drivers/clk/altera/clk-agilex5.c  |  2 +-
 drivers/clk/altera/clk-n5x.c  |  2 +-
 drivers/clk/clk-uclass.c  |  2 +-
 drivers/clk/clk_vexpress_osc.c|  4 +-
 drivers/clk/clk_zynq.c| 22 +-
 drivers/clk/imx/clk-imx8mm.c  |  6 +--
 drivers/clk/imx/clk-imx8mn.c  |  6 +--
 drivers/clk/imx/clk-imxrt1020.c   |  2 +-
 drivers/clk/imx/clk-imxrt1050.c   |  2 +-
 drivers/clk/rockchip/clk_px30.c   |  6 +--
 drivers/clk/rockchip/clk_rk3188.c |  6 +--
 drivers/clk/rockchip/clk_rk3288.c |  8 ++--
 drivers/clk/rockchip/clk_rk3328.c |  4 +-
 drivers/clk/rockchip/clk_rk3368.c | 14 +++---
 drivers/clk/rockchip/clk_rk3399.c | 10 ++---
 drivers/clk/rockchip/clk_rk3568.c | 10 ++---
 drivers/clk/rockchip/clk_rk3588.c | 14 +++---
 drivers/clk/sifive/sifive-prci.c  |  2 +-
 drivers/clk/starfive/clk-jh7110-pll.c |  4 +-
 drivers/clk/stm32/clk-stm32mp1.c  |  6 +--
 drivers/core/ofnode.c |  4 +-
 drivers/crypto/fsl/jobdesc.c  |  2 +-
 drivers/crypto/fsl/jr.c   |  6 +--
 drivers/ddr/altera/sdram_gen5.c   |  4 +-
 drivers/ddr/fsl/lc_common_dimm_params.c   |  6 +--
 drivers/ddr/fsl/main.c|  6 +--
 drivers/ddr/imx/imx8m/Makefile|  2 +-
 drivers/ddr/imx/imx8ulp/Makefile  |  2 +-
 drivers/ddr/imx/imx9/Makefile |  2 +-
 drivers/ddr/imx/phy/Makefile  |  2 +-
 drivers/ddr/marvell/a38x/Makefile | 44 +--
 drivers/ddr/marvell/a38x/old/Makefile | 28 ++--
 drivers/ddr/marvell/axp/Makefile  | 20 -
 drivers/firmware/firmware-zynqmp.c| 10 ++---
 drivers/fpga/intel_sdm_mb.c   |  2 +-
 drivers/fpga/zynqpl.c |  6 +--
 drivers/gpio/Makefile |  2 +-
 drivers/gpio/gpio-uclass.c|  4 +-
 drivers/gpio/pca953x.c|  2 +-
 drivers/gpio/rk_gpio.c|  4 +-
 drivers/gpio/s5p_gpio.c   | 10 ++---
 drivers/gpio/sunxi_gpio.c |  2 +-
 drivers/gpio/tca642x.c|  2 +-
 drivers/gpio/tegra_gpio.c |  2 +-
 drivers/input/Makefile|  2 +-
 drivers/mailbox/zynqmp-ipi.c  |  6 +--
 drivers/misc/Makefile |  6 +--
 drivers/misc/gsc.c|  2 +-
 drivers/misc/imx8/scu.c   |  2 +-
 drivers/mmc/Makefile  |  2 +-
 drivers/mmc/mmc-uclass.c  |  4 +-
 drivers/mmc/mmc.c | 20 -
 drivers/mmc/mmc_legacy.c  |  4 +-
 drivers/mmc/mmc_private.h |  2 +-
 drivers/mmc/omap_hsmmc.c  |  4 +-
 drivers/mmc/rockchip_dw_mmc.c |  2 +-
 drivers/mmc/rockchip_sdhci.c  |  2 +-
 drivers/mmc/socfpga_dw_mmc.c  |  2 +-
 drivers/mmc/tmio-common.c |  2 +-
 drivers/mmc/uniphier-sd.c |  4 +-
 drivers/mmc/zynq_sdhci.c  |  6 +--
 drivers/mtd/Makefile  |  2 +-
 drivers/mtd/nand/Makefile |  2 +-
 drivers/mtd/nand/raw/Makefile |  2 +-
 drivers/mtd/nand/raw/atmel_nand.c |  4 +-
 drivers/mtd/nand/raw/lpc32xx_nand_mlc.c   |  6 +--
 drivers/mtd/nand/raw/lpc32xx_nand_slc.c   |  8 ++--
 drivers/mtd/nand/raw/nand_base.c  | 10 ++---
 drivers/mtd/nand/raw/omap_gpmc.c  |  4 +-
 drivers/mtd/nand/raw/sand_nand.c  |  2 +-
 drivers/mtd/onenand/Makefile  |  2 +-
 drivers/mtd/spi/Makefile  |  2 +-
 drivers/mtd/spi/sf-uclass.c   |  2 +-
 drivers/mtd/spi/sf_dataflash.c|  2 +-
 drivers/mtd/spi/spi-nor-core.c|  4 +-
 drivers/net/dwc_eth_xgmac_socfpga.c   |  2 +-
 drivers/net/dwmac_socfpga.c   |  2 +-
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c |  4 +-
 drivers/pinctrl/pinctrl_stm32.c   |  4 +-
 drivers/pinctrl/tegra/Makefile|  2 +-
 drivers/pinctrl/uniphier/pinctrl-uniphier.h   |  2 +-
 drivers/power/Makefile|  2 +-
 drivers/power/pm

[PATCH v3 27/33] global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD

2024-09-29 Thread Simon Glass
Complete this rename for all directories outside arch/ board/ drivers/
and include/

Use the new symbol to refer to any 'SPL' build, including TPL and VPL

Signed-off-by: Simon Glass 
---

Changes in v3:
- Drop the change in Makefile.xpl since XPL is already defined

 README |  4 ++--
 boot/Makefile  |  2 +-
 boot/image-android-dt.c|  2 +-
 boot/image-android.c   |  2 +-
 boot/image-fit-sig.c   |  2 +-
 cmd/Makefile   |  4 ++--
 cmd/nvedit.c   | 12 ++--
 common/Makefile|  8 
 common/cli_readline.c  |  2 +-
 common/console.c   |  2 +-
 common/hash.c  |  2 +-
 common/spl/Makefile|  2 +-
 common/splash_source.c |  2 +-
 config.mk  |  2 +-
 disk/part.c|  2 +-
 disk/part_dos.c|  2 +-
 doc/develop/distro.rst |  4 ++--
 doc/develop/qconfig.rst|  2 +-
 doc/develop/tests_sandbox.rst  |  2 +-
 dts/Makefile   |  2 +-
 env/Makefile   |  2 +-
 env/common.c   |  4 ++--
 env/fat.c  |  4 ++--
 env/flash.c|  6 +++---
 env/mmc.c  |  6 +++---
 env/nand.c |  8 
 env/nowhere.c  |  2 +-
 env/sf.c   |  2 +-
 fs/Makefile|  2 +-
 fs/fs.c|  6 +++---
 lib/Makefile   |  6 +++---
 lib/crypto/Makefile|  4 ++--
 lib/display_options.c  |  2 +-
 lib/fdtdec.c   |  4 ++--
 lib/hang.c |  2 +-
 lib/hashtable.c|  4 ++--
 lib/hexdump.c  |  2 +-
 lib/uuid.c |  2 +-
 net/bootp.c|  2 +-
 net/net.c  |  8 
 scripts/Kbuild.include |  2 +-
 scripts/Makefile.xpl   |  2 +-
 test/Makefile  |  2 +-
 test/cmd_ut.c  |  2 +-
 test/dm/Makefile   |  2 +-
 test/lib/Makefile  |  2 +-
 test/test-main.c   |  2 +-
 tools/binman/test/generated/autoconf.h |  2 +-
 48 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/README b/README
index 54e723162fd..c27c386e968 100644
--- a/README
+++ b/README
@@ -1418,13 +1418,13 @@ Low Level (hardware related) configuration options:
This only takes effect if the memory commands are activated
globally (CONFIG_CMD_MEMORY).
 
-- CONFIG_SPL_BUILD
+- CONFIG_XPL_BUILD
Set when the currently running compilation is for an artifact
that will end up in one of the 'xPL' builds, i.e. SPL, TPL or
VPL. Code that needs phase-specific behaviour can check this,
or (where possible) use xpl_phase() instead.
 
-   Note that CONFIG_SPL_BUILD *is* always defined when either
+   Note that CONFIG_XPL_BUILD *is* always defined when either
of CONFIG_TPL_BUILD / CONFIG_VPL_BUILD is defined. This can be
counter-intuitive and should perhaps be changed.
 
diff --git a/boot/Makefile b/boot/Makefile
index 40e2337de0f..5bf07e83388 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -3,7 +3,7 @@
 # (C) Copyright 2004-2006
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
-ifndef CONFIG_SPL_BUILD
+ifndef CONFIG_XPL_BUILD
 
 obj-$(CONFIG_BOOT_RETRY) += bootretry.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
diff --git a/boot/image-android-dt.c b/boot/image-android-dt.c
index 3b25018c2e7..653835cea76 100644
--- a/boot/image-android-dt.c
+++ b/boot/image-android-dt.c
@@ -72,7 +72,7 @@ bool android_dt_get_fdt_by_index(ulong hdr_addr, u32 index, 
ulong *addr,
return true;
 }
 
-#if !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_XPL_BUILD)
 static void android_dt_print_fdt_info(const struct fdt_header *fdt)
 {
u32 fdt_size;
diff --git a/boot/image-android.c b/boot/image-android.c
index 774565fd1fe..fdfff58a2a7 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -652,7 +652,7 @@ bool android_image_get_dtb_by_index(ulong hdr_addr, ulong 
vendor_boot_img,
return false;
 }
 
-#if !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_XPL_BUILD)
 /**
  * android_print_contents - prints out the contents of the Android format image
  * @hdr: pointer to the Android format image header
diff --git a/boot/image-fit-sig.c b/boot/image-fit-sig.c
index fe328df4a85..35873b1fb

[PATCH v3 00/33] Tidy up use of 'SPL' and CONFIG_SPL_BUILD

2024-09-29 Thread Simon Glass
When the SPL build-phase was first created it was designed to solve a
particular problem (the need to init SDRAM so that U-Boot proper could
be loaded). It has since expanded to become an important part of U-Boot,
with three phases now present: TPL, VPL and SPL

Due to this history, the term 'SPL' is used to mean both a particular
phase (the one before U-Boot proper) and all the non-proper phases.
This has become confusing.

For a similar reason CONFIG_SPL_BUILD is set to 'y' for all 'SPL'
phases, not just SPL. So code which can only be compiled for actual SPL,
for example, must use something like this:

   #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)

In Makefiles we have similar issues. SPL_ has been used as a variable
which expands to either SPL_ or nothing, to chose between options like
CONFIG_BLK and CONFIG_SPL_BLK. When TPL appeared, a new SPL_TPL variable
was created which expanded to 'SPL_', 'TPL_' or nothing. Later it was
updated to support 'VPL_' as well.

This series starts a change in terminology and usage to resolve the
above issues:

- The word 'xPL' is used instead of 'SPL' to mean a non-proper build
- A new CONFIG_XPL_BUILD define indicates that the current build is an
  'xPL' build
- The existing CONFIG_SPL_BUILD is changed to mean SPL; it is not now
  defined for TPL and VPL phases
- The existing SPL_ Makefile variable is renamed to SPL_
- The existing SPL_TPL Makefile variable is renamed to PHASE_

It should be noted that xpl_phase() can generally be used instead of
the above CONFIGs without a code-space or run-time penalty.

This series does not attempt to convert all of U-Boot to use this new
terminology but it makes a start. In particular, renaming spl.h and
common/spl seems like a bridge too far at this point.

The series is fully bisectable. It has also been checked to ensure there
are no code-size changes on any commit.

Changes in v3:
- Correct the subject to match what the patch changed to do
- Don't update to use SPL_BUILD in the SPL check
- Drop the change in Makefile.xpl since XPL is already defined
- Move earlier in the series
- Move to earlier in the series
- Split into several patches
- Squash in 'x86: Update a comment to mention XPL'

Changes in v2:
- Drop patches not stricly necessary for the conversion
- Move to earlier in the series
- Rebase to -next
- Update cover letter re code size

Simon Glass (33):
  Makefile: Add a u-boot.cfg file for VPL
  boot: Drop unnecessary ifdef for LOAD_FIT
  tegra: Drop dependency on SPL_BUILD
  net: freescale: Drop use of SPL_BUILD dependency
  serial: Make use of the SERIAL define
  stdio: Make use of the SERIAL define
  scripts: Rename Makefile.spl to Makefile.xpl
  scripts: Add some comments about autoconf.mk
  scripts: Define CONFIG_XPL_BUILD for all xPL builds
  qconfig: Add XPL_BUILD to ignored symbols
  xpl: Rename u_boot_first_phase to xpl_is_first_phase()
  xpl: Rename spl_phase to xpl_phase_t
  xpl: Rename spl_phase() to xpl_phase()
  xpl: Rename spl_in_proper() to not_xpl()
  xpl: Add a function to indicate when in xPL
  xpl: Rename spl_next_phase() and spl_prev_phase()
  xpl: Rename spl_phase_prefix() and spl_phase_name()
  log: global: Rename warn_non_spl()
  doc: Update SPL docs for the xPL changes
  README: Drop SoC-specific comment about SPL
  doc: Move init-related things out of README
  doc: Update init docs for the xPL changes
  arch: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  board: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  drivers: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  include: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  xpl: Define CONFIG_SPL_BUILD only for the SPL build
  kconfig: binman: Check for SPL instead of XPL
  global: Rename SPL_ to XPL_
  global: Rename SPL_TPL_ to PHASE_
  spl: Rename SPL_TPL_NAME and SPL_TPL_PROMPT
  qconfig: Update tool for new Makefile variables

 Makefile  |  14 +--
 README| 100 +-
 arch/arm/Makefile |   6 +-
 arch/arm/config.mk|  12 +--
 arch/arm/cpu/arm11/Makefile   |   2 +-
 arch/arm/cpu/arm1176/start.S  |   2 +-
 arch/arm/cpu/arm920t/Makefile |   2 +-
 arch/arm/cpu/arm926ejs/Makefile   |   4 +-
 arch/arm/cpu/arm926ejs/mxs/Makefile   |   4 +-
 arch/arm/cpu/arm926ejs/sunxi/config.mk|   2 +-
 arch/arm/cpu/armv7/Makefile   |   4 +-
 arch/arm/cpu/armv7/cpu.c  |   2 +-
 arch/arm/cpu/armv7/lowlevel_init.S|   4 +-
 arch/arm/cpu/armv7/s5p-common/Makefile|   2 +-
 arch/arm/cpu/armv7/start.S|   2 +-
 arch/arm/cpu/armv7/sunxi/Makefile |   4 +-
 arch/arm/cpu/armv8

[PATCH v3 32/33] spl: Rename SPL_TPL_NAME and SPL_TPL_PROMPT

2024-09-29 Thread Simon Glass
Rename these to use the word PHASE instead.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/spl/spl.c| 36 ++--
 common/spl/spl_fit.c|  2 +-
 common/spl/spl_legacy.c |  2 +-
 include/spl.h   | 14 +++---
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 9748a3fb3e9..94657d00591 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -97,9 +97,9 @@ __weak int dram_init_banksize(void)
 #if CONFIG_IS_ENABLED(OS_BOOT)
 __weak int spl_start_uboot(void)
 {
-   puts(SPL_TPL_PROMPT
+   puts(PHASE_PROMPT
 "Please implement spl_start_uboot() for your board\n");
-   puts(SPL_TPL_PROMPT "Direct Linux boot not active!\n");
+   puts(PHASE_PROMPT "Direct Linux boot not active!\n");
return 1;
 }
 
@@ -140,13 +140,13 @@ void spl_fixup_fdt(void *fdt_blob)
/* fixup the memory dt node */
err = fdt_shrink_to_minimum(fdt_blob, 0);
if (err == 0) {
-   printf(SPL_TPL_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
+   printf(PHASE_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
return;
}
 
err = arch_fixup_fdt(fdt_blob);
if (err) {
-   printf(SPL_TPL_PROMPT "arch_fixup_fdt err - %d\n", err);
+   printf(PHASE_PROMPT "arch_fixup_fdt err - %d\n", err);
return;
}
 #endif
@@ -330,7 +330,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->load_addr = start;
spl_image->entry_point = start;
spl_image->size = size;
-   debug(SPL_TPL_PROMPT
+   debug(PHASE_PROMPT
  "payload Image, load addr: 0x%lx size: %d\n",
  spl_image->load_addr, spl_image->size);
return 0;
@@ -344,7 +344,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
spl_image->size = end - start;
-   debug(SPL_TPL_PROMPT
+   debug(PHASE_PROMPT
  "payload zImage, load addr: 0x%lx size: %d\n",
  spl_image->load_addr, spl_image->size);
return 0;
@@ -423,7 +423,7 @@ static int write_spl_handoff(void)
ret = handoff_arch_save(ho);
if (ret)
return ret;
-   debug(SPL_TPL_PROMPT "Wrote SPL handoff\n");
+   debug(PHASE_PROMPT "Wrote SPL handoff\n");
 
return 0;
 }
@@ -623,11 +623,11 @@ static int boot_from_devices(struct spl_image_info 
*spl_image,
printf("Trying to boot from %s\n",
   spl_loader_name(loader));
else if (CONFIG_IS_ENABLED(SHOW_ERRORS)) {
-   printf(SPL_TPL_PROMPT
+   printf(PHASE_PROMPT
   "Unsupported Boot Device %d\n",
   bootdev);
} else {
-   puts(SPL_TPL_PROMPT
+   puts(PHASE_PROMPT
 "Unsupported Boot Device!\n");
}
}
@@ -673,7 +673,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
struct spl_image_info spl_image;
int ret, os;
 
-   debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
+   debug(">>" PHASE_PROMPT "board_init_r()\n");
 
spl_set_bd();
 
@@ -693,7 +693,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
if (ret) {
debug("%s: Failed to set up bloblist: ret=%d\n",
  __func__, ret);
-   puts(SPL_TPL_PROMPT "Cannot set up bloblist\n");
+   puts(PHASE_PROMPT "Cannot set up bloblist\n");
hang();
}
}
@@ -702,7 +702,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
ret = setup_spl_handoff();
if (ret) {
-   puts(SPL_TPL_PROMPT "Cannot set up SPL handoff\n");
+   puts(PHASE_PROMPT "Cannot set up SPL handoff\n");
hang();
}
}
@@ -723,7 +723,7 @@ void board_init_r(gd_t *d

[PATCH v3 31/33] global: Rename SPL_TPL_ to PHASE_

2024-09-29 Thread Simon Glass
Use PHASE_ as the symbol to select a particular XPL build. This means
that SPL_TPL_ is no-longer set.

Update the comment in bootstage to refer to this symbol, instead of
SPL_

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile  |  2 +-
 arch/arm/cpu/armv8/Makefile   |  2 +-
 arch/arm/lib/Makefile | 16 +++---
 arch/arm/mach-at91/arm926ejs/Makefile |  2 +-
 arch/arm/mach-omap2/Makefile  |  2 +-
 arch/arm/mach-rockchip/Makefile   |  2 +-
 arch/powerpc/lib/Makefile |  2 +-
 arch/riscv/lib/Makefile   | 14 ++---
 arch/x86/Makefile |  6 +-
 arch/x86/cpu/Makefile |  8 +--
 arch/x86/cpu/broadwell/Makefile   | 10 ++--
 arch/x86/cpu/intel_common/Makefile| 10 ++--
 arch/x86/lib/Makefile |  6 +-
 board/coreboot/coreboot/Makefile  |  2 +-
 boot/Makefile | 80 +--
 common/Makefile   | 26 -
 common/bootstage.c|  4 +-
 common/init/Makefile  |  2 +-
 common/spl/Makefile   | 56 +--
 disk/Makefile | 18 +++---
 drivers/Makefile  | 70 +++
 drivers/adc/Makefile  |  2 +-
 drivers/block/Makefile|  8 +--
 drivers/cache/Makefile|  2 +-
 drivers/clk/Makefile  | 18 +++---
 drivers/clk/exynos/Makefile   |  2 +-
 drivers/clk/imx/Makefile  | 20 +++
 drivers/clk/ti/Makefile   |  4 +-
 drivers/core/Makefile | 10 ++--
 drivers/crypto/fsl/Makefile   |  2 +-
 drivers/gpio/Makefile |  6 +-
 drivers/input/Makefile|  6 +-
 drivers/misc/Makefile | 16 +++---
 drivers/mmc/Makefile  |  6 +-
 drivers/mtd/Makefile  |  4 +-
 drivers/mtd/nand/Makefile |  2 +-
 drivers/mtd/nand/raw/Makefile |  2 +-
 drivers/mtd/spi/Makefile  |  8 +--
 drivers/pinctrl/starfive/Makefile |  4 +-
 drivers/power/Makefile|  8 +--
 drivers/power/acpi_pmc/Makefile   |  2 +-
 drivers/power/pmic/Makefile   |  4 +-
 drivers/power/regulator/Makefile  |  2 +-
 drivers/ram/Makefile  |  2 +-
 drivers/reset/Makefile|  2 +-
 drivers/rng/Makefile  |  2 +-
 drivers/rtc/Makefile  |  6 +-
 drivers/scsi/Makefile |  2 +-
 drivers/serial/Makefile   |  2 +-
 drivers/spi/Makefile  |  2 +-
 drivers/sysreset/Makefile | 14 ++---
 drivers/tpm/Makefile  |  4 +-
 drivers/usb/gadget/Makefile   |  6 +-
 drivers/usb/host/Makefile |  4 +-
 drivers/video/Makefile| 16 +++---
 drivers/watchdog/Makefile |  2 +-
 env/Makefile  | 22 
 fs/sandbox/Makefile   |  2 +-
 lib/Makefile  | 34 ++--
 lib/acpi/Makefile |  2 +-
 lib/libfdt/Makefile   |  2 +-
 lib/rsa/Makefile  |  4 +-
 net/Makefile  |  6 +-
 scripts/Kbuild.include|  8 +--
 scripts/Makefile.xpl  | 44 +++
 test/dm/Makefile  |  4 +-
 tools/qconfig.py  |  6 +-
 67 files changed, 338 insertions(+), 338 deletions(-)

diff --git a/Makefile b/Makefile
index d38adcbd1e6..ca74406f21c 100644
--- a/Makefile
+++ b/Makefile
@@ -883,7 +883,7 @@ libs-y += drivers/usb/ulpi/
 ifdef CONFIG_POST
 libs-y += post/
 endif
-libs-$(CONFIG_$(SPL_TPL_)UNIT_TEST) += test/
+libs-$(CONFIG_$(PHASE_)UNIT_TEST) += test/
 libs-$(CONFIG_UT_ENV) += test/env/
 libs-$(CONFIG_UT_OPTEE) += test/optee/
 libs-$(CONFIG_UT_OVERLAY) += test/overlay/
diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
index c5f568e2cb7..8747d2eb186 100644
--- a/arch/arm/cpu/armv8/Makefile
+++ b/arch/arm/cpu/armv8/Makefile
@@ -6,7 +6,7 @@
 extra-y:= start.o
 
 obj-y  += cpu.o
-ifndef CONFIG_$(SPL_TPL_)TIMER
+ifndef CONFIG_$(PHASE_)TIMER
 obj-$(CONFIG_SYS_ARCH_TIMER) += generic_timer.o
 endif
 ifndef CONFIG_$(XPL_)SYS_DCACHE_OFF
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index b73a0397541..211ff4960e1 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -34,7 +34,7 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 else
-obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
+obj-$(CONFIG_$(PHASE_)FRAMEWORK) += spl.o
 ifdef CONFIG_SPL_FRAMEWORK
 obj-$(CONFIG_CMD_BOOTI) += image.o
 obj-$(CONFIG_CMD_BOOTZ) += zimage.o
@@ -42,14 +42,14 @@ endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
-obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET

[PATCH v3 30/33] global: Rename SPL_ to XPL_

2024-09-29 Thread Simon Glass
Use XPL_ as the symbol to indicate an SPL build. This means that SPL_ is
no-longer set.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile|  4 +--
 arch/arm/config.mk  |  6 ++--
 arch/arm/cpu/arm920t/Makefile   |  2 +-
 arch/arm/cpu/arm926ejs/Makefile |  2 +-
 arch/arm/cpu/armv7/Makefile |  2 +-
 arch/arm/cpu/armv8/Makefile |  4 +--
 arch/arm/lib/Makefile   |  2 +-
 arch/arm/mach-at91/arm926ejs/Makefile   |  2 +-
 arch/arm/mach-imx/Makefile  |  2 +-
 arch/arm/mach-omap2/am33xx/Makefile |  2 +-
 arch/arm/mach-orion5x/Makefile  |  4 +--
 arch/arm/mach-stm32mp/stm32mp1/Makefile |  2 +-
 arch/arm/mach-tegra/Makefile|  2 +-
 arch/arm/mach-tegra/tegra20/Makefile|  2 +-
 arch/arm/mach-tegra/tegra30/Makefile|  2 +-
 arch/arm/mach-zynqmp/Makefile   |  2 +-
 arch/riscv/Makefile |  2 +-
 arch/riscv/lib/Makefile |  8 ++---
 arch/x86/Makefile   |  2 +-
 arch/x86/cpu/Makefile   | 12 +++
 arch/x86/cpu/intel_common/Makefile  |  4 +--
 arch/x86/cpu/ivybridge/Makefile |  6 ++--
 arch/x86/cpu/qemu/Makefile  |  2 +-
 arch/x86/lib/Makefile   |  4 +--
 board/bosch/guardian/Makefile   |  2 +-
 board/freescale/common/Makefile |  4 +--
 board/st/common/Makefile|  2 +-
 board/tcl/sl50/Makefile |  2 +-
 board/ti/am335x/Makefile|  2 +-
 board/ti/am43xx/Makefile|  2 +-
 board/vscom/baltos/Makefile |  2 +-
 board/xilinx/zynqmp/Makefile|  2 +-
 boot/Makefile   |  2 +-
 cmd/Makefile|  2 +-
 doc/develop/tests_writing.rst   |  6 ++--
 drivers/Makefile| 14 
 drivers/ata/Makefile|  2 +-
 drivers/block/Makefile  |  2 +-
 drivers/bus/Makefile|  2 +-
 drivers/core/Makefile   |  6 ++--
 drivers/ddr/altera/Makefile |  2 +-
 drivers/dfu/Makefile| 16 -
 drivers/firmware/Makefile   |  2 +-
 drivers/gpio/Makefile   |  8 ++---
 drivers/i2c/Makefile| 16 -
 drivers/led/Makefile|  2 +-
 drivers/mailbox/Makefile|  2 +-
 drivers/misc/Makefile   | 10 +++---
 drivers/mmc/Makefile|  6 ++--
 drivers/mux/Makefile|  2 +-
 drivers/nvme/Makefile   |  2 +-
 drivers/phy/Makefile|  6 ++--
 drivers/phy/cadence/Makefile|  4 +--
 drivers/phy/ti/Makefile |  2 +-
 drivers/pinctrl/Makefile|  8 ++---
 drivers/power/domain/Makefile   |  2 +-
 drivers/power/pmic/Makefile | 30 
 drivers/power/regulator/Makefile| 46 -
 drivers/remoteproc/Makefile |  2 +-
 drivers/serial/Makefile |  2 +-
 drivers/timer/Makefile  |  8 ++---
 drivers/usb/cdns3/Makefile  |  4 +--
 drivers/usb/common/Makefile |  2 +-
 drivers/usb/dwc3/Makefile   |  4 +--
 drivers/usb/gadget/udc/Makefile |  4 +--
 drivers/usb/host/Makefile   |  2 +-
 drivers/video/Makefile  |  2 +-
 drivers/video/tidss/Makefile|  2 +-
 fs/fat/Makefile |  4 +--
 fs/squashfs/Makefile|  2 +-
 lib/Makefile| 28 +++
 lib/acpi/Makefile   |  8 ++---
 lib/aes/Makefile|  2 +-
 lib/crypto/Makefile | 14 
 lib/ecdsa/Makefile  |  2 +-
 net/Makefile|  6 ++--
 scripts/Kbuild.include  |  4 +--
 scripts/Makefile.xpl|  4 +--
 test/Makefile   | 22 ++--
 test/fuzz/Makefile  |  2 +-
 tools/qconfig.py|  6 ++--
 81 files changed, 219 insertions(+), 219 deletions(-)

diff --git a/Makefile b/Makefile
index 4378993ccfd..d38adcbd1e6 100644
--- a/Makefile
+++ b/Makefile
@@ -829,7 +829,7 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 UBOOTINCLUDE:= \
-Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-   $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+   $(if $(CONFIG_$(XPL_)SYS_THUMB_BUILD), \
$(if $(CONFIG_HAS_THUMB2), \
$(if $(CONFIG_CPU_V7M), \
-I$(srctree)/arch/arm/thumb1/include), \
@@ -864,7 +864,7 @@ libs-y += disk/
 libs-y += drivers/
 libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
 libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl

[PATCH v3 29/33] kconfig: binman: Check for SPL instead of XPL

2024-09-29 Thread Simon Glass
Now that SPL means SPL (only) and is not defined for other phases,
update kconfig rules.

This is done in one patch since otherwise many Binman tests fail.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h| 10 +-
 tools/binman/test/generated/autoconf.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index a59f2a61e6a..ec9584b2426 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -40,7 +40,7 @@
 #define _CONFIG_PREFIX TPL_
 #elif defined(CONFIG_VPL_BUILD)
 #define _CONFIG_PREFIX VPL_
-#elif defined(CONFIG_XPL_BUILD)
+#elif defined(CONFIG_SPL_BUILD)
 #define _CONFIG_PREFIX SPL_
 #else
 #define _CONFIG_PREFIX
@@ -54,7 +54,7 @@
  * CONFIG_VAL(FOO) evaluates to the value of
  *  CONFIG_TOOLS_FOO if USE_HOSTCC is defined,
  *  CONFIG_FOO if CONFIG_XPL_BUILD is undefined,
- *  CONFIG_SPL_FOO if CONFIG_XPL_BUILD is defined.
+ *  CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined.
  *  CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined.
  *  CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined.
  */
@@ -107,21 +107,21 @@ long invalid_use_of_IF_ENABLED_INT(void);
  * CONFIG_IS_ENABLED(FOO) expands to
  *  1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
  *  1 if CONFIG_XPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  1 if CONFIG_XPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  0 otherwise.
  *
  * CONFIG_IS_ENABLED(FOO, (abc)) expands to
  *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
  *  abc if CONFIG_XPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_XPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  nothing otherwise.
  *
  * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
  *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
  *  abc if CONFIG_XPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_XPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  def otherwise.
  *
diff --git a/tools/binman/test/generated/autoconf.h 
b/tools/binman/test/generated/autoconf.h
index 75af48f9116..6a23039f469 100644
--- a/tools/binman/test/generated/autoconf.h
+++ b/tools/binman/test/generated/autoconf.h
@@ -1,3 +1,3 @@
 #define CONFIG_BINMAN 1
-#define CONFIG_XPL_BUILD 1
+#define CONFIG_SPL_BUILD 1
 #define CONFIG_SPL_BINMAN_SYMBOLS 1
-- 
2.34.1



[PATCH v3 33/33] qconfig: Update tool for new Makefile variables

2024-09-29 Thread Simon Glass
Take account of the new XPL_ and PHASE_ instead of the old SPL_ and
SPL_TPL_

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Drop patches not stricly necessary for the conversion
- Rebase to -next
- Update cover letter re code size

 tools/qconfig.py | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/qconfig.py b/tools/qconfig.py
index 7b4934b726d..058d72cf4bc 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -1175,7 +1175,7 @@ def prefix_config(cfg):
 return oper + cfg
 
 
-RE_MK_CONFIGS = re.compile(r'CONFIG_(\$\(SPL_(?:TPL_)?\))?([A-Za-z0-9_]*)')
+RE_MK_CONFIGS = re.compile(r'CONFIG_(\$\(XPL_\)|\$\(PHASE_\))?([A-Za-z0-9_]*)')
 RE_IFDEF = re.compile(r'(ifdef|ifndef)')
 RE_C_CONFIGS = re.compile(r'CONFIG_([A-Za-z0-9_]*)')
 RE_CONFIG_IS = re.compile(r'CONFIG_IS_ENABLED\(([A-Za-z0-9_]*)\)')
@@ -1186,7 +1186,7 @@ class ConfigUse:
 """Set up a new ConfigUse
 
 Args:
-cfg (str): CONFIG option, without any CONFIG_ or SPL_ prefix
+cfg (str): CONFIG option, without any CONFIG_ or xPL_ prefix
 is_spl (bool): True if this option relates to SPL
 fname (str): Makefile filename where the CONFIG option was found
 rest (str): Line of the Makefile
@@ -1319,7 +1319,7 @@ def do_scan_source(path, do_update):
 key (ConfigUse): object
 value (list of str): matching lines
 spl_mode (int): If MODE_SPL, look at source code which implies
-an SPL_ option, but for which there is none;
+an xPL_ option, but for which there is none;
 for MOD_PROPER, look at source code which implies a Proper
 option (i.e. use of CONFIG_IS_ENABLED() or $(XPL_) or
 $(PHASE_) but for which there none;
@@ -1341,7 +1341,7 @@ def do_scan_source(path, do_update):
 if spl_mode == MODE_SPL:
 check = use.is_spl
 
-# If it is an SPL symbol, try prepending all SPL_ prefixes to
+# If it is an SPL symbol, try prepending all xPL_ prefixes to
 # find at least one SPL symbol
 if use.is_spl:
 for prefix in SPL_PREFIXES:
@@ -1354,7 +1354,7 @@ def do_scan_source(path, do_update):
 continue
 elif spl_mode == MODE_PROPER:
 # Try to find the Proper version of this symbol, i.e. without
-# the SPL_ prefix
+# the xPL_ prefix
 proper_name = is_not_proper(name)
 if proper_name:
 name = proper_name
@@ -1450,7 +1450,7 @@ def do_scan_source(path, do_update):
 show_uses(not_found)
 spl_not_found |= {is_not_proper(key) or key for key in not_found.keys()}
 
-print('\nCONFIG options used as Proper in Makefiles but without a non-SPL_ 
variant:')
+print('\nCONFIG options used as Proper in Makefiles but without a non-xPL_ 
variant:')
 not_found = check_not_found(all_uses, MODE_PROPER)
 show_uses(not_found)
 proper_not_found |= {not_found.keys()}
@@ -1468,16 +1468,16 @@ def do_scan_source(path, do_update):
 show_uses(not_found)
 spl_not_found |= {is_not_proper(key) or key for key in not_found.keys()}
 
-print('\nCONFIG options used as Proper in source but without a non-SPL_ 
variant:')
+print('\nCONFIG options used as Proper in source but without a non-xPL_ 
variant:')
 not_found = check_not_found(all_uses, MODE_PROPER)
 show_uses(not_found)
 proper_not_found |= {not_found.keys()}
 
-print('\nCONFIG options used as SPL but without an SPL_ variant:')
+print('\nCONFIG options used as SPL but without an xPL_ variant:')
 for item in sorted(spl_not_found):
 print(f'   {item}')
 
-print('\nCONFIG options used as Proper but without a non-SPL_ variant:')
+print('\nCONFIG options used as Proper but without a non-xPL_ variant:')
 for item in sorted(proper_not_found):
 print(f'   {item}')
 
-- 
2.34.1



[PATCH v3 11/33] xpl: Rename u_boot_first_phase to xpl_is_first_phase()

2024-09-29 Thread Simon Glass
This is a better name for this function, so update it.

Tidy up the function comment to mention VPL.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Don't update to use SPL_BUILD in the SPL check

 arch/arm/mach-omap2/am33xx/board.c |  2 +-
 common/bloblist.c  |  4 ++--
 common/spl/spl.c   |  4 ++--
 include/spl.h  | 14 --
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-omap2/am33xx/board.c 
b/arch/arm/mach-omap2/am33xx/board.c
index abdc1e40335..548d6b7cfe4 100644
--- a/arch/arm/mach-omap2/am33xx/board.c
+++ b/arch/arm/mach-omap2/am33xx/board.c
@@ -526,7 +526,7 @@ EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, am33xx_dm_post_init);
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void)
 {
-   if (u_boot_first_phase()) {
+   if (xpl_is_first_phase()) {
hw_data_init();
set_uart_mux_conf();
setup_early_clocks();
diff --git a/common/bloblist.c b/common/bloblist.c
index 2008ab4d25c..fb86789df42 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -504,13 +504,13 @@ int bloblist_init(void)
 * If U-Boot is not in the first phase, an existing bloblist must be
 * at a fixed address.
 */
-   bool from_addr = fixed && !u_boot_first_phase();
+   bool from_addr = fixed && !xpl_is_first_phase();
/*
 * If U-Boot is in the first phase that an arch custom routine should
 * install the bloblist passed from previous loader to this fixed
 * address.
 */
-   bool from_boot_arg = fixed && u_boot_first_phase();
+   bool from_boot_arg = fixed && xpl_is_first_phase();
 
if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
from_addr = false;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index c13b2b8f714..9c3bba48251 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -464,13 +464,13 @@ static int spl_common_init(bool setup_malloc)
gd->malloc_ptr = 0;
}
 #endif
-   ret = bootstage_init(u_boot_first_phase());
+   ret = bootstage_init(xpl_is_first_phase());
if (ret) {
debug("%s: Failed to set up bootstage: ret=%d\n", __func__,
  ret);
return ret;
}
-   if (!u_boot_first_phase()) {
+   if (!xpl_is_first_phase()) {
ret = bootstage_unstash_default();
if (ret)
log_debug("Failed to unstash bootstage: ret=%d\n", ret);
diff --git a/include/spl.h b/include/spl.h
index de808ccd413..fa87d865f5f 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -34,18 +34,20 @@ struct spl_boot_device;
 enum boot_device;
 
 /*
- * u_boot_first_phase() - check if this is the first U-Boot phase
+ * xpl_is_first_phase() - check if this is the first U-Boot phase
  *
- * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on the
- * build flags we can determine whether the current build is for the first
+ * U-Boot has up to four phases: TPL, VPL, SPL and U-Boot proper. Depending on
+ * the build flags we can determine whether the current build is for the first
  * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. If
  * there is SPL but no TPL, the the first phase is SPL. If there is TPL, then
- * it is the first phase.
+ * it is the first phase, etc.
  *
- * @returns true if this is the first phase of U-Boot
+ * Note that VPL can never be the first phase. If it exists, it is loaded from
+ * TPL
  *
+ * Return: true if this is the first phase of U-Boot
  */
-static inline bool u_boot_first_phase(void)
+static inline bool xpl_is_first_phase(void)
 {
if (IS_ENABLED(CONFIG_TPL)) {
if (IS_ENABLED(CONFIG_TPL_BUILD))
-- 
2.34.1



[PATCH v3 10/33] qconfig: Add XPL_BUILD to ignored symbols

2024-09-29 Thread Simon Glass
This now appears in the code base, so add it to the list of ignored
symbols in qconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/qconfig.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/qconfig.py b/tools/qconfig.py
index 8c2fc9efc5f..71e911eeb3b 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -77,7 +77,7 @@ IGNORE_SYMS = ['DEBUG_SECTION_MISMATCH', 
'FTRACE_MCOUNT_RECORD', 'GCOV_KERNEL',
'IS_ENABLED_', 'IS_ENABLED_1', 'IS_ENABLED_2', 'IS_ENABLED_3',
'SPL_', 'TPL_', 'SPL_FOO', 'TPL_FOO', 'TOOLS_FOO',
'ACME', 'SPL_ACME', 'TPL_ACME', 'TRACE_BRANCH_PROFILING',
-   'VAL', '_UNDEFINED', 'SPL_BUILD', ]
+   'VAL', '_UNDEFINED', 'SPL_BUILD', 'XPL_BUILD', ]
 
 SPL_PREFIXES = ['SPL_', 'TPL_', 'VPL_', 'TOOLS_']
 
-- 
2.34.1



[PATCH v3 28/33] xpl: Define CONFIG_SPL_BUILD only for the SPL build

2024-09-29 Thread Simon Glass
Make this define mean SPL only, not TPL, VPL, etc.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.autoconf | 4 ++--
 scripts/Makefile.xpl  | 7 +--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index d7544022a31..c1eab2f3a1d 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -87,11 +87,11 @@ spl/u-boot.cfg: include/config.h FORCE
 
 tpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_TPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_TPL_BUILD)
 
 vpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_VPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_VPL_BUILD)
 
 include/autoconf.mk: u-boot.cfg
$(call cmd,autoconf)
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index 08453f0b415..b43ff998679 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -21,9 +21,10 @@ include $(srctree)/scripts/Kbuild.include
 
 -include include/config/auto.conf
 
-# This file contains 0, 2 or 3 lines
+# This file contains 0, or 2 lines
 # It is empty for U-Boot proper (where $(obj) is empty)
-# For any xPL build it contains CONFIG_SPL_BUILD=y and CONFIG_XPL_BUILD=y
+# For any xPL build it contains CONFIG_XPL_BUILD=y
+#- for SPL builds it also contains CONFIG_SPL_BUILD=y
 #- for TPL builds it also contains CONFIG_TPL_BUILD=y
 #- for VPL builds it also contains CONFIG_VPL_BUILD=y
 -include $(obj)/include/autoconf.mk
@@ -31,7 +32,9 @@ include $(srctree)/scripts/Kbuild.include
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 
 KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
+ifeq ($(CONFIG_SPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
+endif
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
 else
-- 
2.34.1



[PATCH v3 26/33] include: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD

2024-09-29 Thread Simon Glass
Use the new symbol to refer to any 'SPL' build, including TPL and VPL

Signed-off-by: Simon Glass 
---

Changes in v3:
- Split into several patches

 include/asm-generic/global_data.h  |  2 +-
 include/bootcount.h|  4 ++--
 include/config_distro_bootcmd.h| 10 +-
 include/configs/P1010RDB.h |  4 ++--
 include/configs/am335x_evm.h   |  4 ++--
 include/configs/am335x_guardian.h  |  4 ++--
 include/configs/am335x_shc.h   |  4 ++--
 include/configs/am43xx_evm.h   |  4 ++--
 include/configs/am57xx_evm.h   |  2 +-
 include/configs/capricorn-common.h |  4 ++--
 include/configs/cgtqmx8.h  |  2 +-
 include/configs/da850evm.h |  2 +-
 include/configs/dra7xx_evm.h   |  4 ++--
 include/configs/ds116.h|  4 ++--
 include/configs/ds414.h|  4 ++--
 include/configs/gardena-smart-gateway-mt7688.h |  2 +-
 include/configs/imx6q-bosch-acc.h  |  2 +-
 include/configs/imx6ulz_smm_m2.h   |  4 ++--
 include/configs/imx8mm-cl-iot-gate.h   |  2 +-
 include/configs/imx8mm_beacon.h|  2 +-
 include/configs/imx8mm_data_modul_edm_sbc.h|  2 +-
 include/configs/imx8mm_evk.h   |  2 +-
 include/configs/imx8mm_icore_mx8mm.h   |  4 ++--
 include/configs/imx8mm_phg.h   |  2 +-
 include/configs/imx8mm_venice.h|  2 +-
 include/configs/imx8mp_rsb3720.h   |  2 +-
 include/configs/imx8mq_cm.h|  2 +-
 include/configs/imx8mq_evk.h   |  2 +-
 include/configs/imx8mq_phanbell.h  |  2 +-
 include/configs/imx8mq_reform2.h   |  2 +-
 include/configs/imx8qm_mek.h   |  2 +-
 include/configs/imx8qxp_mek.h  |  2 +-
 include/configs/imx8ulp_evk.h  |  2 +-
 include/configs/imx93_evk.h|  2 +-
 include/configs/kontron-sl-mx8mm.h |  4 ++--
 include/configs/kontron_pitx_imx8m.h   |  2 +-
 include/configs/librem5.h  |  2 +-
 include/configs/linkit-smart-7688.h|  2 +-
 include/configs/ls1043a_common.h   |  6 +++---
 include/configs/ls1046a_common.h   |  6 +++---
 include/configs/ls1088a_common.h   |  2 +-
 include/configs/msc_sm2s_imx8mp.h  |  2 +-
 include/configs/mt7621.h   |  2 +-
 include/configs/mt7628.h   |  2 +-
 include/configs/n2350.h|  4 ++--
 include/configs/p1_p2_rdb_pc.h |  4 ++--
 include/configs/phycore_imx8mm.h   |  2 +-
 include/configs/pico-imx8mq.h  |  2 +-
 include/configs/rk3399_common.h|  4 ++--
 include/configs/rockchip-common.h  |  2 +-
 include/configs/socfpga_common.h   |  2 +-
 include/configs/stm32mp15_common.h |  4 ++--
 include/configs/stm32mp15_dh_dhsom.h   |  2 +-
 include/configs/ti_omap3_common.h  |  2 +-
 include/configs/ti_omap4_common.h  |  2 +-
 include/configs/turris_1x.h|  4 ++--
 include/configs/turris_omnia.h |  4 ++--
 include/configs/verdin-imx8mm.h|  2 +-
 include/configs/verdin-imx8mp.h|  4 ++--
 include/configs/vining_2000.h  |  2 +-
 include/configs/xilinx_zynqmp.h|  2 +-
 include/configs/zynq-common.h  |  4 ++--
 include/env.h  |  2 +-
 include/env_callback.h |  2 +-
 include/fdtdec.h   |  2 +-
 include/image-android-dt.h |  2 +-
 include/iotrace.h  |  2 +-
 include/linux/kconfig.h| 18 +-
 include/mmc.h  |  2 +-
 include/mtd/cfi_flash.h|  2 +-
 include/net.h  |  6 +++---
 include/part.h |  2 +-
 include/sdp.h  |  2 +-
 include/search.h   |  2 +-
 include/spl.h  | 14 +++---
 include/stdio.h|  2 +-
 include/sunxi_gpio.h   |  2 +-
 include/upl.h  |  4 ++--
 include/vbe.h  |  2 +-
 79 files changed, 125 insertions(+), 125 deletions(-)

diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index d6c15e2c406..644a0d77873 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -55,7 +55,7 @@ struct global_data {
 * @cur_serial_de

[PATCH v3 22/33] doc: Update init docs for the xPL changes

2024-09-29 Thread Simon Glass
Update the documentation here to cover the meaning of xPL

Signed-off-by: Simon Glass 
---

(no changes since v1)

 doc/develop/init.rst | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/doc/develop/init.rst b/doc/develop/init.rst
index 2955d9bdbc3..ce985781bb4 100644
--- a/doc/develop/init.rst
+++ b/doc/develop/init.rst
@@ -4,15 +4,16 @@ Board Initialisation Flow
 -
 
 This is the intended start-up flow for boards. This should apply for both
-SPL and U-Boot proper (i.e. they both follow the same rules).
+xPL and U-Boot proper (i.e. they both follow the same rules).
 
-Note: "SPL" stands for "Secondary Program Loader," which is explained in
-more detail later in this file.
+Note: "xPL" stands for "any Program Loader", including SPL (Secondary
+Program Loader), TPL (Tertiary Program Loader) and VPL (Verifying Program
+Loader). The boot sequence is TPL->VPL->SPL->U-Boot proper
 
-At present, SPL mostly uses a separate code path, but the function names
+At present, xPL mostly uses a separate code path, but the function names
 and roles of each function are the same. Some boards or architectures
 may not conform to this.  At least most ARM boards which use
-CONFIG_SPL_FRAMEWORK conform to this.
+CONFIG_xPL_FRAMEWORK conform to this.
 
 Execution typically starts with an architecture-specific (and possibly
 CPU-specific) start.S file, such as:
@@ -48,7 +49,7 @@ board_init_f()
 
 Non-xPL-specific notes:
 
-- dram_init() is called to set up DRAM. If already done in SPL this
+- dram_init() is called to set up DRAM. If already done in xPL this
   can do nothing
 
 xPL-specific notes:
@@ -68,9 +69,9 @@ xPL-specific notes:
 - must return normally from this function (don't call board_init_r()
   directly)
 
-Here the BSS is cleared. For SPL, if CONFIG_SPL_STACK_R is defined, then at
+Here the BSS is cleared. For xPL, if CONFIG_xPL_STACK_R is defined, then at
 this point the stack and global_data are relocated to below
-CONFIG_SPL_STACK_R_ADDR. For non-SPL, U-Boot is relocated to run at the top of
+CONFIG_xPL_STACK_R_ADDR. For non-xPL, U-Boot is relocated to run at the top of
 memory.
 
 board_init_r()
@@ -82,11 +83,11 @@ board_init_r()
 - BSS is available, all static/global variables can be used
 - execution eventually continues to main_loop()
 
-Non-SPL-specific notes:
+Non-xPL-specific notes:
 
 - U-Boot is relocated to the top of memory and is now running from
   there.
 
-SPL-specific notes:
+xPL-specific notes:
 
-- stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined
+- stack is optionally in SDRAM, if CONFIG_xPL_STACK_R is defined
-- 
2.34.1



[PATCH v3 21/33] doc: Move init-related things out of README

2024-09-29 Thread Simon Glass
Move this section to rst, changing it just enough so that it builds.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move to earlier in the series

 README| 82 --
 doc/develop/index.rst |  1 +
 doc/develop/init.rst  | 92 +++
 3 files changed, 93 insertions(+), 82 deletions(-)
 create mode 100644 doc/develop/init.rst

diff --git a/README b/README
index 78d91a2f62d..54e723162fd 100644
--- a/README
+++ b/README
@@ -133,88 +133,6 @@ run some of U-Boot's tests.
 
 See doc/arch/sandbox/sandbox.rst for more details.
 
-
-Board Initialisation Flow:
---
-
-This is the intended start-up flow for boards. This should apply for both
-SPL and U-Boot proper (i.e. they both follow the same rules).
-
-Note: "SPL" stands for "Secondary Program Loader," which is explained in
-more detail later in this file.
-
-At present, SPL mostly uses a separate code path, but the function names
-and roles of each function are the same. Some boards or architectures
-may not conform to this.  At least most ARM boards which use
-CONFIG_SPL_FRAMEWORK conform to this.
-
-Execution typically starts with an architecture-specific (and possibly
-CPU-specific) start.S file, such as:
-
-   - arch/arm/cpu/armv7/start.S
-   - arch/powerpc/cpu/mpc83xx/start.S
-   - arch/mips/cpu/start.S
-
-and so on. From there, three functions are called; the purpose and
-limitations of each of these functions are described below.
-
-lowlevel_init():
-   - purpose: essential init to permit execution to reach board_init_f()
-   - no global_data or BSS
-   - there is no stack (ARMv7 may have one but it will soon be removed)
-   - must not set up SDRAM or use console
-   - must only do the bare minimum to allow execution to continue to
-   board_init_f()
-   - this is almost never needed
-   - return normally from this function
-
-board_init_f():
-   - purpose: set up the machine ready for running board_init_r():
-   i.e. SDRAM and serial UART
-   - global_data is available
-   - stack is in SRAM
-   - BSS is not available, so you cannot use global/static variables,
-   only stack variables and global_data
-
-   Non-SPL-specific notes:
-   - dram_init() is called to set up DRAM. If already done in SPL this
-   can do nothing
-
-   SPL-specific notes:
-   - you can override the entire board_init_f() function with your own
-   version as needed.
-   - preloader_console_init() can be called here in extremis
-   - should set up SDRAM, and anything needed to make the UART work
-   - there is no need to clear BSS, it will be done by crt0.S
-   - for specific scenarios on certain architectures an early BSS *can*
- be made available (via CONFIG_SPL_EARLY_BSS by moving the clearing
- of BSS prior to entering board_init_f()) but doing so is discouraged.
- Instead it is strongly recommended to architect any code changes
- or additions such to not depend on the availability of BSS during
- board_init_f() as indicated in other sections of this README to
- maintain compatibility and consistency across the entire code base.
-   - must return normally from this function (don't call board_init_r()
-   directly)
-
-Here the BSS is cleared. For SPL, if CONFIG_SPL_STACK_R is defined, then at
-this point the stack and global_data are relocated to below
-CONFIG_SPL_STACK_R_ADDR. For non-SPL, U-Boot is relocated to run at the top of
-memory.
-
-board_init_r():
-   - purpose: main execution, common code
-   - global_data is available
-   - SDRAM is available
-   - BSS is available, all static/global variables can be used
-   - execution eventually continues to main_loop()
-
-   Non-SPL-specific notes:
-   - U-Boot is relocated to the top of memory and is now running from
-   there.
-
-   SPL-specific notes:
-   - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined
-
 The following options need to be configured:
 
 - CPU Type:Define exactly one, e.g. CONFIG_MPC85XX.
diff --git a/doc/develop/index.rst b/doc/develop/index.rst
index 0d0e60ab56c..da9643dca14 100644
--- a/doc/develop/index.rst
+++ b/doc/develop/index.rst
@@ -38,6 +38,7 @@ Implementation
distro
driver-model/index
environment
+   init
expo
cedit
event
diff --git a/doc/develop/init.rst b/doc/develop/init.rst
new file mode 100644
index 000..2955d9bdbc3
--- /dev/null
+++ b/doc/develop/init.rst
@@ -0,0 +1,92 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Board Initialisation Flow
+-
+
+This is the intended start-up flow for boards. This should apply for both
+SPL and U-Boot proper (i.e. they both follow the same rules).
+
+Note: "SPL" stands for "Sec

[PATCH v3 20/33] README: Drop SoC-specific comment about SPL

2024-09-29 Thread Simon Glass
This should not be in the generic README file, so drop it.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move to earlier in the series

 README | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/README b/README
index c7ee06a21dd..78d91a2f62d 100644
--- a/README
+++ b/README
@@ -213,15 +213,7 @@ board_init_r():
there.
 
SPL-specific notes:
-   - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined and
-   CONFIG_SYS_FSL_HAS_CCI400
-
-   Defined For SoC that has cache coherent interconnect
-   CCN-400
-
-   CONFIG_SYS_FSL_HAS_CCN504
-
-   Defined for SoC that has cache coherent interconnect CCN-504
+   - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined
 
 The following options need to be configured:
 
-- 
2.34.1



[PATCH v3 17/33] xpl: Rename spl_phase_prefix() and spl_phase_name()

2024-09-29 Thread Simon Glass
Use simpler names for these functions.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/spl.c | 4 ++--
 arch/x86/lib/tpl.c | 2 +-
 cmd/vbe.c  | 2 +-
 common/spl/spl.c   | 5 ++---
 include/spl.h  | 8 
 5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 71d785f4c3e..c50df5f9179 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -27,8 +27,8 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool 
use_img)
const char *cur_prefix, *next_prefix;
int ret;
 
-   cur_prefix = spl_phase_prefix(xpl_phase());
-   next_prefix = spl_phase_prefix(xpl_next_phase());
+   cur_prefix = xpl_prefix(xpl_phase());
+   next_prefix = xpl_prefix(xpl_next_phase());
ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
if (ret)
return log_msg_ret("find", ret);
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 0606b4a1c67..f7df7e03621 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -103,7 +103,7 @@ int spl_spi_load_image(void)
 
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
-   debug("Jumping to %s at %lx\n", spl_phase_name(xpl_next_phase()),
+   debug("Jumping to %s at %lx\n", xpl_name(xpl_next_phase()),
  (ulong)spl_image->entry_point);
 #ifdef DEBUG
print_buffer(spl_image->entry_point, (void *)spl_image->entry_point, 1,
diff --git a/cmd/vbe.c b/cmd/vbe.c
index 423d9e5f8f0..186f6e6860d 100644
--- a/cmd/vbe.c
+++ b/cmd/vbe.c
@@ -93,7 +93,7 @@ static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int 
argc,
printf("Phases:");
for (i = PHASE_NONE; i < PHASE_COUNT; i++) {
if (handoff->phases & (1 << i))
-   printf(" %s", spl_phase_name(i));
+   printf(" %s", xpl_name(i));
 
}
if (!handoff->phases)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index ad5c309348b..9748a3fb3e9 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -475,8 +475,7 @@ static int spl_common_init(bool setup_malloc)
if (ret)
log_debug("Failed to unstash bootstage: ret=%d\n", ret);
}
-   bootstage_mark_name(get_bootstage_id(true),
-   spl_phase_name(xpl_phase()));
+   bootstage_mark_name(get_bootstage_id(true), xpl_name(xpl_phase()));
 #if CONFIG_IS_ENABLED(LOG)
ret = log_init();
if (ret) {
@@ -762,7 +761,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
os = spl_image.os;
if (os == IH_OS_U_BOOT) {
-   debug("Jumping to %s...\n", spl_phase_name(xpl_next_phase()));
+   debug("Jumping to %s...\n", xpl_name(xpl_next_phase()));
} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
debug("Jumping to U-Boot via ARM Trusted Firmware\n");
spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
diff --git a/include/spl.h b/include/spl.h
index 50ffe4f79f9..b2978d8bbaf 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -194,11 +194,11 @@ static inline enum xpl_phase_t xpl_next_phase(void)
 }
 
 /**
- * spl_phase_name() - Get the name of the current phase
+ * xpl_name() - Get the name of a phase
  *
  * Return: phase name
  */
-static inline const char *spl_phase_name(enum xpl_phase_t phase)
+static inline const char *xpl_name(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
@@ -216,12 +216,12 @@ static inline const char *spl_phase_name(enum xpl_phase_t 
phase)
 }
 
 /**
- * spl_phase_prefix() - Get the prefix  of the current phase
+ * xpl_prefix() - Get the prefix  of the current phase
  *
  * @phase: Phase to look up
  * Return: phase prefix ("spl", "tpl", etc.)
  */
-static inline const char *spl_phase_prefix(enum xpl_phase_t phase)
+static inline const char *xpl_prefix(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
-- 
2.34.1



[PATCH v3 19/33] doc: Update SPL docs for the xPL changes

2024-09-29 Thread Simon Glass
Update the various references to SPL in this document. Make sure to
refer to 'phases' instead of 'stages', which is not a U-Boot term.

Fix a few U-boot typos and try to improve grammar a little while we are
here.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Move to earlier in the series

 doc/develop/spl.rst | 79 +++--
 1 file changed, 41 insertions(+), 38 deletions(-)

diff --git a/doc/develop/spl.rst b/doc/develop/spl.rst
index a92110e4fa9..aa6d28fa333 100644
--- a/doc/develop/spl.rst
+++ b/doc/develop/spl.rst
@@ -1,11 +1,12 @@
-Generic SPL framework
+Generic xPL framework
 =
 
 Overview
 
 
-To unify all existing implementations for a secondary program loader (SPL)
-and to allow simply adding of new implementations this generic SPL framework
+To unify all existing implementations for secondary/tertiary program loaders
+(generically called xPL)
+and to allow simply adding of new implementations this generic xPL framework
 has been created. With this framework almost all source files for a board
 can be reused. No code duplication or symlinking is necessary anymore.
 
@@ -13,38 +14,39 @@ can be reused. No code duplication or symlinking is 
necessary anymore.
 How it works
 
 
-The object files for SPL are built separately and placed in the "spl" 
directory.
-The final binaries which are generated are u-boot-spl, u-boot-spl.bin and
-u-boot-spl.map.
+The object files for xPL are built separately and placed in a subdirectory
+("spl", "tpl" or "vpl").
+The final binaries which are generated for SPL are u-boot-spl, u-boot-spl.bin
+and u-boot-spl.map
 
-A config option named CONFIG_SPL_BUILD is enabled by Kconfig for SPL.
-Source files can therefore be compiled for SPL with different settings.
+A config option named CONFIG_XPL_BUILD is enabled by Kconfig for xPL builds.
+Source files can therefore be compiled for xPL with different settings.
 
 For example::
 
-   ifeq ($(CONFIG_SPL_BUILD),y)
+   ifeq ($(CONFIG_XPL_BUILD),y)
obj-y += board_spl.o
else
obj-y += board.o
endif
 
-   obj-$(CONFIG_SPL_BUILD) += foo.o
+   obj-$(CONFIG_XPL_BUILD) += foo.o
 
-   #ifdef CONFIG_SPL_BUILD
+   if (IS_ENABLED(CONFIG_XPL_BUILD))
foo();
-   #endif
 
if (xpl_phase() == PHASE_TPL)
bar();
 
-The building of SPL images can be enabled by CONFIG_SPL option in Kconfig.
+The building of xPL images can be enabled by CONFIG_SPL (etc.) options in
+Kconfig.
 
-Because SPL images normally have a different text base, one has to be
-configured by defining CONFIG_SPL_TEXT_BASE. The linker script has to be
-defined with CONFIG_SPL_LDSCRIPT.
+Because xPL images normally have a different text base, one has to be
+configured by defining CONFIG_xPL_TEXT_BASE. The linker script has to be
+defined with CONFIG_xPL_LDSCRIPT.
 
-To support generic U-Boot libraries and drivers in the SPL binary one can
-optionally define CONFIG_SPL_XXX_SUPPORT. Currently following options
+To support generic U-Boot libraries and drivers in the xPL binary one can
+optionally define CONFIG_xPL_XXX_SUPPORT. Currently following options
 are supported:
 
 CONFIG_SPL_LIBCOMMON_SUPPORT (common/libcommon.o)
@@ -77,7 +79,7 @@ CONFIG_SPL_DM_GPIO (drivers/gpio/gpio-uclass.o)
 CONFIG_SPL_BMP (drivers/video/bmp.o)
 CONFIG_SPL_BLOBLIST (common/bloblist.o)
 
-Adding SPL-specific code
+Adding xPL-specific code
 
 
 To check whether a feature is enabled, use CONFIG_IS_ENABLED()::
@@ -92,7 +94,7 @@ U-Boot Boot Phases
 --
 
 U-Boot goes through the following boot phases where TPL, VPL, SPL are optional.
-While many boards use SPL, less use TPL.
+While many boards use SPL, fewer use TPL.
 
 TPL
Very early init, as tiny as possible. This loads SPL (or VPL if enabled).
@@ -179,29 +181,30 @@ files instead introduces another set of headaches.  These 
warnings are
 not usually important to understanding the flow, however.
 
 
-Reserving memory in SPL
+Reserving memory in xPL
 ---
 
-If memory needs to be reserved in RAM during SPL stage with the requirement 
that
-the SPL reserved memory remains preserved across further boot stages too
+If memory needs to be reserved in RAM during an xPL phase with the requirement
+that the xPL reserved memory remains preserved across further boot phases too
 then it needs to be reserved mandatorily starting from end of RAM. This is to
-ensure that further stages can simply skip this region before carrying out
+ensure that further phases can simply skip this region before carrying out
 further reservations or updating the relocation address.
 
-Also out of these regions which are to be preserved across further stages of
+Also out of these regions which are to be preserved across further phases of
 boot, video framebuffer memory region must be reserved first starting from
-end of RAM

[PATCH v3 18/33] log: global: Rename warn_non_spl()

2024-09-29 Thread Simon Glass
This should now refer to xPL rather than SPL, so update it throughout
the tree.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move to earlier in the series

 arch/arm/lib/cache.c |  2 +-
 doc/develop/logging.rst  |  2 +-
 drivers/spi/spi-uclass.c |  4 ++--
 include/log.h| 12 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index b2ae74a59f1..cac2159fe1a 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -62,7 +62,7 @@ int check_cache_range(unsigned long start, unsigned long stop)
ok = 0;
 
if (!ok) {
-   warn_non_spl("CACHE: Misaligned operation at range [%08lx, 
%08lx]\n",
+   warn_non_xpl("CACHE: Misaligned operation at range [%08lx, 
%08lx]\n",
 start, stop);
}
 
diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 704a6bf1d84..d7a40c94bf0 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -292,7 +292,7 @@ Convert debug() statements in the code to log() statements
 
 Convert error() statements in the code to log() statements
 
-Figure out what to do with BUG(), BUG_ON() and warn_non_spl()
+Figure out what to do with BUG(), BUG_ON() and warn_non_xpl()
 
 Add a way to browse log records
 
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 6e281725239..f6efebd2e90 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -538,7 +538,7 @@ int spi_slave_of_to_plat(struct udevice *dev, struct 
dm_spi_slave_plat *plat)
mode |= SPI_TX_OCTAL;
break;
default:
-   warn_non_spl("spi-tx-bus-width %d not supported\n", value);
+   warn_non_xpl("spi-tx-bus-width %d not supported\n", value);
break;
}
 
@@ -556,7 +556,7 @@ int spi_slave_of_to_plat(struct udevice *dev, struct 
dm_spi_slave_plat *plat)
mode |= SPI_RX_OCTAL;
break;
default:
-   warn_non_spl("spi-rx-bus-width %d not supported\n", value);
+   warn_non_xpl("spi-rx-bus-width %d not supported\n", value);
break;
}
 
diff --git a/include/log.h b/include/log.h
index 7c25bf0b081..bf81a27011f 100644
--- a/include/log.h
+++ b/include/log.h
@@ -246,10 +246,10 @@ int _log_buffer(enum log_category_t cat, enum log_level_t 
level,
 #define _DEBUG 0
 #endif
 
-#ifdef CONFIG_SPL_BUILD
-#define _SPL_BUILD 1
+#ifdef CONFIG_XPL_BUILD
+#define _XPL_BUILD 1
 #else
-#define _SPL_BUILD 0
+#define _XPL_BUILD 0
 #endif
 
 #if CONFIG_IS_ENABLED(LOG)
@@ -281,9 +281,9 @@ int _log_buffer(enum log_category_t cat, enum log_level_t 
level,
 #define debug(fmt, args...)\
debug_cond(_DEBUG, fmt, ##args)
 
-/* Show a message if not in SPL */
-#define warn_non_spl(fmt, args...) \
-   debug_cond(!_SPL_BUILD, fmt, ##args)
+/* Show a message if not in xPL */
+#define warn_non_xpl(fmt, args...) \
+   debug_cond(!_XPL_BUILD, fmt, ##args)
 
 /*
  * An assertion is run-time check done in debug mode only. If DEBUG is not
-- 
2.34.1



[PATCH v3 16/33] xpl: Rename spl_next_phase() and spl_prev_phase()

2024-09-29 Thread Simon Glass
Rename this to use the xpl prefix.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/spl.c |  4 ++--
 arch/x86/lib/tpl.c |  2 +-
 common/bloblist.c  |  2 +-
 common/spl/spl.c   | 14 +++---
 include/spl.h  |  8 
 lib/fdtdec.c   |  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 7497d90fb89..71d785f4c3e 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -28,7 +28,7 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool 
use_img)
int ret;
 
cur_prefix = spl_phase_prefix(xpl_phase());
-   next_prefix = spl_phase_prefix(spl_next_phase());
+   next_prefix = spl_phase_prefix(xpl_next_phase());
ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
if (ret)
return log_msg_ret("find", ret);
@@ -101,7 +101,7 @@ static int load_from_image(struct spl_image_info *spl_image,
if (!IS_ENABLED(CONFIG_SANDBOX_VPL))
return -ENOENT;
 
-   next_phase = spl_next_phase();
+   next_phase = xpl_next_phase();
pos = spl_get_image_pos();
size = spl_get_image_size();
if (pos == BINMAN_SYM_MISSING || size == BINMAN_SYM_MISSING) {
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 7c03dea0711..0606b4a1c67 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -103,7 +103,7 @@ int spl_spi_load_image(void)
 
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
-   debug("Jumping to %s at %lx\n", spl_phase_name(spl_next_phase()),
+   debug("Jumping to %s at %lx\n", spl_phase_name(xpl_next_phase()),
  (ulong)spl_image->entry_point);
 #ifdef DEBUG
print_buffer(spl_image->entry_point, (void *)spl_image->entry_point, 1,
diff --git a/common/bloblist.c b/common/bloblist.c
index fb86789df42..6640ad1fd69 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -512,7 +512,7 @@ int bloblist_init(void)
 */
bool from_boot_arg = fixed && xpl_is_first_phase();
 
-   if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
+   if (xpl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
from_addr = false;
if (fixed)
addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 6c297ebf37a..ad5c309348b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -176,10 +176,10 @@ ulong spl_get_image_pos(void)
return BINMAN_SYM_MISSING;
 
 #ifdef CONFIG_VPL
-   if (spl_next_phase() == PHASE_VPL)
+   if (xpl_next_phase() == PHASE_VPL)
return binman_sym(ulong, u_boot_vpl_any, image_pos);
 #endif
-   return spl_next_phase() == PHASE_SPL ?
+   return xpl_next_phase() == PHASE_SPL ?
binman_sym(ulong, u_boot_spl_any, image_pos) :
binman_sym(ulong, u_boot_any, image_pos);
 }
@@ -190,10 +190,10 @@ ulong spl_get_image_size(void)
return BINMAN_SYM_MISSING;
 
 #ifdef CONFIG_VPL
-   if (spl_next_phase() == PHASE_VPL)
+   if (xpl_next_phase() == PHASE_VPL)
return binman_sym(ulong, u_boot_vpl_any, size);
 #endif
-   return spl_next_phase() == PHASE_SPL ?
+   return xpl_next_phase() == PHASE_SPL ?
binman_sym(ulong, u_boot_spl_any, size) :
binman_sym(ulong, u_boot_any, size);
 }
@@ -201,10 +201,10 @@ ulong spl_get_image_size(void)
 ulong spl_get_image_text_base(void)
 {
 #ifdef CONFIG_VPL
-   if (spl_next_phase() == PHASE_VPL)
+   if (xpl_next_phase() == PHASE_VPL)
return CONFIG_VPL_TEXT_BASE;
 #endif
-   return spl_next_phase() == PHASE_SPL ? CONFIG_SPL_TEXT_BASE :
+   return xpl_next_phase() == PHASE_SPL ? CONFIG_SPL_TEXT_BASE :
CONFIG_TEXT_BASE;
 }
 
@@ -762,7 +762,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
os = spl_image.os;
if (os == IH_OS_U_BOOT) {
-   debug("Jumping to %s...\n", spl_phase_name(spl_next_phase()));
+   debug("Jumping to %s...\n", spl_phase_name(xpl_next_phase()));
} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
debug("Jumping to U-Boot via ARM Trusted Firmware\n");
spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
diff --git a/include/spl.h b/include/spl.h
index fe2df78b0a6..50ffe4f79f9 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -155,12 +155,12 @@ static inline bool is_xpl(void)
 }
 
 /**
- * spl_prev_phase() - Figure out the previous U-Boot phase
+ * xpl_prev_phase() - Figure out the previous U-Boot phase
  *
  * Return: the previous phase from this one, e.g. if called in SPL this returns
  * PHASE_TPL, if TPL is enabled
  */
-static inl

[PATCH v3 13/33] xpl: Rename spl_phase() to xpl_phase()

2024-09-29 Thread Simon Glass
Rename this function to indicate that it refers to any xPL phase.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Move to earlier in the series

 README   |  6 +++---
 arch/sandbox/cpu/spl.c   |  2 +-
 arch/sandbox/cpu/start.c |  2 +-
 arch/x86/cpu/apollolake/cpu_spl.c|  4 ++--
 arch/x86/cpu/apollolake/hostbridge.c |  2 +-
 arch/x86/cpu/apollolake/lpc.c|  2 +-
 arch/x86/cpu/apollolake/pch.c|  2 +-
 arch/x86/cpu/apollolake/pmc.c|  4 ++--
 arch/x86/cpu/apollolake/punit.c  |  2 +-
 arch/x86/cpu/apollolake/spl.c|  2 +-
 arch/x86/cpu/broadwell/cpu.c |  2 +-
 arch/x86/cpu/i386/cpu.c  |  2 +-
 arch/x86/cpu/intel_common/mrc.c  |  2 +-
 arch/x86/cpu/intel_common/p2sb.c |  6 +++---
 arch/x86/lib/fsp2/fsp_dram.c |  2 +-
 arch/x86/lib/fsp2/fsp_init.c |  4 ++--
 boot/fdt_simplefb.c  |  2 +-
 boot/vbe_simple_fw.c |  4 ++--
 common/board_f.c |  2 +-
 common/bootstage.c   |  2 +-
 common/spl/spl.c |  6 +++---
 doc/develop/spl.rst  |  4 +++-
 drivers/i2c/designware_i2c_pci.c |  4 ++--
 drivers/misc/p2sb-uclass.c   |  2 +-
 drivers/pci/pci-uclass.c |  4 ++--
 drivers/pci/pci_rom.c|  4 ++--
 drivers/pinctrl/intel/pinctrl.c  |  6 +++---
 drivers/power/acpi_pmc/acpi-pmc-uclass.c |  2 +-
 drivers/ram/rockchip/sdram_rk3399.c  |  2 +-
 drivers/spi/ich.c|  4 ++--
 drivers/sysreset/sysreset-uclass.c   |  2 +-
 drivers/video/console_truetype.c |  6 +++---
 drivers/video/video-uclass.c |  6 +++---
 include/spl.h| 10 +-
 lib/fdtdec.c |  2 +-
 lib/lmb.c|  4 ++--
 lib/time.c   |  2 +-
 37 files changed, 64 insertions(+), 62 deletions(-)

diff --git a/README b/README
index 4be1e8c22a0..c7ee06a21dd 100644
--- a/README
+++ b/README
@@ -1512,7 +1512,7 @@ Low Level (hardware related) configuration options:
Set when the currently running compilation is for an artifact
that will end up in one of the 'xPL' builds, i.e. SPL, TPL or
VPL. Code that needs phase-specific behaviour can check this,
-   or (where possible) use spl_phase() instead.
+   or (where possible) use xpl_phase() instead.
 
Note that CONFIG_SPL_BUILD *is* always defined when either
of CONFIG_TPL_BUILD / CONFIG_VPL_BUILD is defined. This can be
@@ -1522,13 +1522,13 @@ Low Level (hardware related) configuration options:
Set when the currently running compilation is for an artifact
that will end up in the TPL build (as opposed to SPL, VPL or
U-Boot proper). Code that needs phase-specific behaviour can
-   check this, or (where possible) use spl_phase() instead.
+   check this, or (where possible) use xpl_phase() instead.
 
 - CONFIG_VPL_BUILD
Set when the currently running compilation is for an artifact
that will end up in the VPL build (as opposed to the SPL, TPL
or U-Boot proper). Code that needs phase-specific behaviour can
-   check this, or (where possible) use spl_phase() instead.
+   check this, or (where possible) use xpl_phase() instead.
 
 - CONFIG_ARCH_MAP_SYSMEM
Generally U-Boot (and in particular the md command) uses
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 6c6f4fd8c3e..7497d90fb89 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -27,7 +27,7 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool 
use_img)
const char *cur_prefix, *next_prefix;
int ret;
 
-   cur_prefix = spl_phase_prefix(spl_phase());
+   cur_prefix = spl_phase_prefix(xpl_phase());
next_prefix = spl_phase_prefix(spl_next_phase());
ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
if (ret)
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 9ad5d46271a..4d3c806840b 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -206,7 +206,7 @@ static int sandbox_cmdline_cb_test_fdt(struct sandbox_state 
*state,
char *relname;
int len;
 
-   if (spl_phase() <= PHASE_SPL)
+   if (xpl_phase() <= PHASE_SPL)
relname = "../arch/sandbox/dts/test.dtb";
else
relname = "arch/sandbox/dts/test.dtb";
diff --git a/arch/x86/cpu/apollolake/cpu_spl.c 
b/arch/x86/cpu/apollolake/cpu_spl.c
index 8798fa79d4c..8198667fa50 100644
--- a/arc

[PATCH v3 15/33] xpl: Add a function to indicate when in xPL

2024-09-29 Thread Simon Glass
Add the opposite function to not_xpl() for completeness.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/spl.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/spl.h b/include/spl.h
index 948486164d9..fe2df78b0a6 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -144,6 +144,16 @@ static inline bool not_xpl(void)
return true;
 }
 
+/* returns true if in xPL, false if in U-Boot proper */
+static inline bool is_xpl(void)
+{
+#ifdef CONFIG_XPL_BUILD
+   return true;
+#endif
+
+   return false;
+}
+
 /**
  * spl_prev_phase() - Figure out the previous U-Boot phase
  *
-- 
2.34.1



[PATCH v3 07/33] scripts: Rename Makefile.spl to Makefile.xpl

2024-09-29 Thread Simon Glass
Rename this file to indicate that it refers to any non-U-Boot-proper
phase, not just SPL, which is the phase immediately before U-Boot
proper.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile   | 6 +++---
 scripts/{Makefile.spl => Makefile.xpl} | 0
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename scripts/{Makefile.spl => Makefile.xpl} (100%)

diff --git a/Makefile b/Makefile
index 300cee2e7f6..4378993ccfd 100644
--- a/Makefile
+++ b/Makefile
@@ -2094,7 +2094,7 @@ spl/u-boot-spl-dtb.hex: spl/u-boot-spl
@:
 
 spl/u-boot-spl: tools prepare $(if $(CONFIG_SPL_OF_CONTROL),dts/dt.dtb)
-   $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
+   $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.xpl all
 
 spl/sunxi-spl.bin: spl/u-boot-spl
@:
@@ -2113,14 +2113,14 @@ tpl/u-boot-tpl.bin: tpl/u-boot-tpl
$(TPL_SIZE_CHECK)
 
 tpl/u-boot-tpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
-   $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
+   $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.xpl all
 
 vpl/u-boot-vpl.bin: vpl/u-boot-vpl
@:
$(VPL_SIZE_CHECK)
 
 vpl/u-boot-vpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
-   $(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.spl all
+   $(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.xpl all
 
 TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
 
diff --git a/scripts/Makefile.spl b/scripts/Makefile.xpl
similarity index 100%
rename from scripts/Makefile.spl
rename to scripts/Makefile.xpl
-- 
2.34.1



[PATCH v3 14/33] xpl: Rename spl_in_proper() to not_xpl()

2024-09-29 Thread Simon Glass
Give this function a slightly easier name.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/mtd/nand/raw/sand_nand.c| 2 +-
 drivers/ram/rockchip/sdram_rk3399.c | 2 +-
 drivers/serial/ns16550.c| 4 ++--
 include/spl.h   | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/raw/sand_nand.c b/drivers/mtd/nand/raw/sand_nand.c
index 229d7b5b65a..456e841b1c4 100644
--- a/drivers/mtd/nand/raw/sand_nand.c
+++ b/drivers/mtd/nand/raw/sand_nand.c
@@ -601,7 +601,7 @@ static int sand_nand_probe(struct udevice *dev)
}
 
nand = &chip->nand;
-   nand->options = spl_in_proper() ? 0 : NAND_SKIP_BBTSCAN;
+   nand->options = not_xpl() ? 0 : NAND_SKIP_BBTSCAN;
nand->flash_node = np;
nand->dev_ready = sand_nand_dev_ready;
nand->cmdfunc = sand_nand_command;
diff --git a/drivers/ram/rockchip/sdram_rk3399.c 
b/drivers/ram/rockchip/sdram_rk3399.c
index 7f8a6ba8410..5676c099a43 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -196,7 +196,7 @@ static bool phase_sdram_init(void)
return xpl_phase() == PHASE_TPL ||
(!IS_ENABLED(CONFIG_TPL) &&
 !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) &&
-!spl_in_proper());
+!not_xpl());
 }
 
 static struct io_setting *
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 6fcb5b523ac..55bc39648d7 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -473,7 +473,7 @@ static int ns16550_serial_getinfo(struct udevice *dev,
struct ns16550_plat *plat = com_port->plat;
 
/* save code size */
-   if (!spl_in_proper())
+   if (!not_xpl())
return -ENOSYS;
 
info->type = SERIAL_CHIP_16550_COMPATIBLE;
@@ -555,7 +555,7 @@ int ns16550_serial_of_to_plat(struct udevice *dev)
struct clk clk;
int err;
 
-   addr = spl_in_proper() ? dev_read_addr_size(dev, &size) :
+   addr = not_xpl() ? dev_read_addr_size(dev, &size) :
dev_read_addr(dev);
err = ns16550_serial_assign_base(plat, addr, size);
if (err && !device_is_on_pci_bus(dev))
diff --git a/include/spl.h b/include/spl.h
index bf011139548..948486164d9 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -134,8 +134,8 @@ static inline enum xpl_phase_t xpl_phase(void)
 #endif
 }
 
-/* returns true if in U-Boot proper, false if in SPL */
-static inline bool spl_in_proper(void)
+/* returns true if in U-Boot proper, false if in xPL */
+static inline bool not_xpl(void)
 {
 #ifdef CONFIG_SPL_BUILD
return false;
-- 
2.34.1



[PATCH v3 06/33] stdio: Make use of the SERIAL define

2024-09-29 Thread Simon Glass
This is always enabled for U-Boot proper, so simplify the condition
in the common Makefile.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move earlier in the series

 include/stdio.h | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h
index 7b999a519ba..e7325795533 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -9,10 +9,7 @@ int getchar(void);
 int tstc(void);
 
 /* stdout */
-#if !defined(CONFIG_SPL_BUILD) || \
-   (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL)) || \
-   (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \
-   defined(CONFIG_SPL_SERIAL))
+#if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(SERIAL)
 void putc(const char c);
 void puts(const char *s);
 #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
-- 
2.34.1



[PATCH v3 12/33] xpl: Rename spl_phase to xpl_phase_t

2024-09-29 Thread Simon Glass
This name fits better with the new naming scheme, so update it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/spl.c   |  2 +-
 common/spl/spl.c |  2 +-
 doc/device-tree-bindings/bootph.yaml |  2 +-
 include/spl.h| 12 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 1c33a520c64..6c6f4fd8c3e 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -91,7 +91,7 @@ static int load_from_image(struct spl_image_info *spl_image,
   struct spl_boot_device *bootdev)
 {
struct sandbox_state *state = state_get_current();
-   enum u_boot_phase next_phase;
+   enum xpl_phase_t next_phase;
const char *fname;
ulong pos, size;
int full_size;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 9c3bba48251..9ed91929ee1 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -441,7 +441,7 @@ static inline int write_spl_handoff(void) { return 0; }
  */
 static enum bootstage_id get_bootstage_id(bool start)
 {
-   enum u_boot_phase phase = spl_phase();
+   enum xpl_phase_t phase = spl_phase();
 
if (IS_ENABLED(CONFIG_TPL_BUILD) && phase == PHASE_TPL)
return start ? BOOTSTAGE_ID_START_TPL : BOOTSTAGE_ID_END_TPL;
diff --git a/doc/device-tree-bindings/bootph.yaml 
b/doc/device-tree-bindings/bootph.yaml
index a3ccf06efa7..a364b3fe37f 100644
--- a/doc/device-tree-bindings/bootph.yaml
+++ b/doc/device-tree-bindings/bootph.yaml
@@ -83,6 +83,6 @@ properties:
   bootph-all:
 type: boolean
 description:
-  Include this node in all phases (for U-Boot see enum u_boot_phase).
+  Include this node in all phases (for U-Boot see enum xpl_phase_t).
 
 additionalProperties: true
diff --git a/include/spl.h b/include/spl.h
index fa87d865f5f..6d44b627259 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -62,7 +62,7 @@ static inline bool xpl_is_first_phase(void)
return false;
 }
 
-enum u_boot_phase {
+enum xpl_phase_t {
PHASE_NONE, /* Invalid phase, signifying before U-Boot */
PHASE_TPL,  /* Running in TPL */
PHASE_VPL,  /* Running in VPL */
@@ -116,7 +116,7 @@ enum u_boot_phase {
  *
  * Return: U-Boot phase
  */
-static inline enum u_boot_phase spl_phase(void)
+static inline enum xpl_phase_t spl_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
return PHASE_TPL;
@@ -150,7 +150,7 @@ static inline bool spl_in_proper(void)
  * Return: the previous phase from this one, e.g. if called in SPL this returns
  * PHASE_TPL, if TPL is enabled
  */
-static inline enum u_boot_phase spl_prev_phase(void)
+static inline enum xpl_phase_t spl_prev_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
return PHASE_NONE;
@@ -172,7 +172,7 @@ static inline enum u_boot_phase spl_prev_phase(void)
  * Return: the next phase from this one, e.g. if called in TPL this returns
  * PHASE_SPL
  */
-static inline enum u_boot_phase spl_next_phase(void)
+static inline enum xpl_phase_t spl_next_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
return IS_ENABLED(CONFIG_VPL) ? PHASE_VPL : PHASE_SPL;
@@ -188,7 +188,7 @@ static inline enum u_boot_phase spl_next_phase(void)
  *
  * Return: phase name
  */
-static inline const char *spl_phase_name(enum u_boot_phase phase)
+static inline const char *spl_phase_name(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
@@ -211,7 +211,7 @@ static inline const char *spl_phase_name(enum u_boot_phase 
phase)
  * @phase: Phase to look up
  * Return: phase prefix ("spl", "tpl", etc.)
  */
-static inline const char *spl_phase_prefix(enum u_boot_phase phase)
+static inline const char *spl_phase_prefix(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
-- 
2.34.1



[PATCH v3 09/33] scripts: Define CONFIG_XPL_BUILD for all xPL builds

2024-09-29 Thread Simon Glass
The new name 'xPL' is intended to indicate a build of any phase which is
not U-Boot proper. Define it for all such phases.

Note that we also define CONFIG_SPL_BUILD for all xPL builds. This
preserves existing behaviour, but future patches will adjust that.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.autoconf | 6 +++---
 scripts/Makefile.xpl  | 9 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index b42f9b525fe..d7544022a31 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -83,15 +83,15 @@ u-boot.cfg: include/config.h FORCE
 
 spl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD)
 
 tpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_TPL_BUILD)
 
 vpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_VPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_VPL_BUILD)
 
 include/autoconf.mk: u-boot.cfg
$(call cmd,autoconf)
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index 3091311a3d2..ad21d451a30 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -21,15 +21,16 @@ include $(srctree)/scripts/Kbuild.include
 
 -include include/config/auto.conf
 
-# This file contains 0, 1 or 2 lines
+# This file contains 0, 2 or 3 lines
 # It is empty for U-Boot proper (where $(obj) is empty)
-# For any xPL build it contains CONFIG_SPL_BUILD=y
-# For TPL builds it has CONFIG_SPL_BUILD=y and CONFIG_TPL_BUILD=y
-# For VPL builds it has CONFIG_SPL_BUILD=y and CONFIG_VPL_BUILD=y
+# For any xPL build it contains CONFIG_SPL_BUILD=y and CONFIG_XPL_BUILD=y
+#- for TPL builds it also contains CONFIG_TPL_BUILD=y
+#- for VPL builds it also contains CONFIG_VPL_BUILD=y
 -include $(obj)/include/autoconf.mk
 
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 
+KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
-- 
2.34.1



[PATCH v3 08/33] scripts: Add some comments about autoconf.mk

2024-09-29 Thread Simon Glass
Now that the conversion of all CONFIG options to Kconfig is complete,
these files only contain the xPL_BUILD defines. Add a comment to make
this clear.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.xpl | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index 1868f1beef6..3091311a3d2 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -20,6 +20,12 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 include $(srctree)/scripts/Kbuild.include
 
 -include include/config/auto.conf
+
+# This file contains 0, 1 or 2 lines
+# It is empty for U-Boot proper (where $(obj) is empty)
+# For any xPL build it contains CONFIG_SPL_BUILD=y
+# For TPL builds it has CONFIG_SPL_BUILD=y and CONFIG_TPL_BUILD=y
+# For VPL builds it has CONFIG_SPL_BUILD=y and CONFIG_VPL_BUILD=y
 -include $(obj)/include/autoconf.mk
 
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
-- 
2.34.1



[PATCH v3 01/33] Makefile: Add a u-boot.cfg file for VPL

2024-09-29 Thread Simon Glass
Create this file for VPL as well, for consistency.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 525576f987d..300cee2e7f6 100644
--- a/Makefile
+++ b/Makefile
@@ -624,7 +624,7 @@ include/config/%.conf: $(KCONFIG_CONFIG) 
include/config/auto.conf.cmd
@# Otherwise, 'make silentoldconfig' would be invoked twice.
$(Q)touch include/config/auto.conf
 
-u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg:
+u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg vpl/u-boot.cfg:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(@)
 
 -include include/autoconf.mk
-- 
2.34.1



[PATCH v3 05/33] serial: Make use of the SERIAL define

2024-09-29 Thread Simon Glass
This is always enabled for U-Boot proper, so simplify the condition
in the common Makefile.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Move earlier in the series

 common/Makefile | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index d871113cbb9..c52d4c39f6b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -65,15 +65,7 @@ obj-$(CONFIG_DDR_SPD) += ddr_spd.o
 obj-$(CONFIG_SPD_EEPROM) += ddr_spd.o
 obj-$(CONFIG_HWCONFIG) += hwconfig.o
 obj-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o
-ifdef CONFIG_SPL_BUILD
-ifdef CONFIG_TPL_BUILD
-obj-$(CONFIG_TPL_SERIAL) += console.o
-else
-obj-$(CONFIG_SPL_SERIAL) += console.o
-endif
-else
-obj-y += console.o
-endif # CONFIG_SPL_BUILD
+obj-$(CONFIG_$(SPL_TPL_)SERIAL) += console.o
 
 obj-$(CONFIG_CROS_EC) += cros_ec.o
 obj-y += dlmalloc.o
-- 
2.34.1



[PATCH v3 04/33] net: freescale: Drop use of SPL_BUILD dependency

2024-09-29 Thread Simon Glass
SPL_BUILD is not a Kconfig symbol. Perhaps the intent here is to use
SPL instead. However, this causes build errors, e.g. with T1024RDB_NAND

So drop the dependency on !SPL_BUILD since it does nothing.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/net/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e7d0ddfe25a..403d7e1c679 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -891,7 +891,7 @@ config FEC2_PHY_NORXERR
 
 config SYS_DPAA_QBMAN
bool "Device tree fixup for QBMan on freescale SOCs"
-   depends on (ARM || PPC) && !SPL_BUILD
+   depends on ARM || PPC
default y if ARCH_B4860 || \
 ARCH_B4420 || \
 ARCH_P1023 || \
-- 
2.34.1



[PATCH v3 03/33] tegra: Drop dependency on SPL_BUILD

2024-09-29 Thread Simon Glass
SPL_BUILD is not a Kconfig symbol so perhaps the intent here is to
use SPL instead. But that changes the output size.

So drop the dependency on !SPL_BUILD since it does nothing.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Correct the subject to match what the patch changed to do

 arch/arm/mach-tegra/tegra124/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra124/Kconfig 
b/arch/arm/mach-tegra/tegra124/Kconfig
index fb016aa46c9..84c8f86bad0 100644
--- a/arch/arm/mach-tegra/tegra124/Kconfig
+++ b/arch/arm/mach-tegra/tegra124/Kconfig
@@ -21,8 +21,8 @@ config TARGET_CEI_TK1_SOM
bool "Colorado Engineering Inc Tegra124 TK1-som board"
select ARCH_SUPPORT_PSCI
select BOARD_LATE_INIT
-   select CPU_V7_HAS_NONSEC if !SPL_BUILD
-   select CPU_V7_HAS_VIRT if !SPL_BUILD
+   select CPU_V7_HAS_NONSEC
+   select CPU_V7_HAS_VIRT
help
  The Colorado Engineering Tegra TK1-SOM is a very compact
  (51mmx58mm) board that is functionally almost the same as
-- 
2.34.1



[PATCH v3 02/33] boot: Drop unnecessary ifdef for LOAD_FIT

2024-09-29 Thread Simon Glass
Use the normal SPL_TPL_ approach for this option.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/boot/Makefile b/boot/Makefile
index f4675d6ffd5..40e2337de0f 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -58,9 +58,7 @@ obj-$(CONFIG_$(SPL_TPL_)FIT_CIPHER) += image-cipher.o
 
 obj-$(CONFIG_CMD_ADTIMG) += image-android-dt.o
 
-ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
-endif
+obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += common_fit.o
 
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += expo.o scene.o expo_build.o
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += scene_menu.o scene_textline.o
-- 
2.34.1



Re: [PATCH] binman: add fast authentication method for i.MX8M signing

2024-09-29 Thread Simon Glass
Hi Fabio,

On Sun, 29 Sept 2024 at 14:53, Fabio Estevam  wrote:
>
> Hi Simon, Marek, and Tom,
>
> On Fri, Sep 27, 2024 at 5:47 PM Tom Rini  wrote:
>
> > > Please can you coordinate with Marek as we need to sort out the test
> > > coverage for this etype, before adding more functionality. I did a
> > > starting point, now in -next, which should help.
> >
> > Well, when someone has both time and understanding of the tools and the
> > frameworks, we can expand the automatic tests while still having
> > functional testing as people use the feature.
>
> Do you think this patch should be applied as is? Could the tests be
> handled later?
>
> Please let me know.

Who is going to handle the tests later and when?

Regards,
Simon


Re: [PATCH v2 16/30] kconfig: binman: Check for SPL instead of XPL

2024-09-29 Thread Simon Glass
Hi Jonas,

On Sun, 29 Sept 2024 at 00:08, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2024-09-28 22:00, Simon Glass wrote:
> > Now that SPL means SPL (only) and is not defined for other phases,
> > update kconfig rules.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  include/linux/kconfig.h| 10 +-
> >  tools/binman/test/generated/autoconf.h |  2 +-
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
> > index a59f2a61e6a..ec9584b2426 100644
> > --- a/include/linux/kconfig.h
> > +++ b/include/linux/kconfig.h
> > @@ -40,7 +40,7 @@
> >  #define _CONFIG_PREFIX TPL_
> >  #elif defined(CONFIG_VPL_BUILD)
> >  #define _CONFIG_PREFIX VPL_
> > -#elif defined(CONFIG_XPL_BUILD)
> > +#elif defined(CONFIG_SPL_BUILD)
>
> This change back from XPL to SPL is probably not needed it you did not
> change it to XPL in the first place.
>
> Just doing a mass search and replace is making this series hard to
> review.
>
> Personally I did not fully realize that SPL_ or SPL_BUILD meant any xPL
> build before this series, so I would look at each SPL_BUILD to XPL_BUILD
> and SPL_ to XPL_ change and try to understand the original intent.
>
> I know multiple places where I have used SPL_ and not SPL_TPL_ because
> of this, and similar have used SPL_BUILD for parts I only want in SPL
> and not in TPL.

Yes and this will be the case all over the tree. I have added
countless similar things myself. The good news is that everything
works as before and there is now a clean 'SPL_BUILD' which can be used
without any dependency on !TPL_BUILD etc.

>
> How should I best handle sending fixes where I e.g. have used SPL_ in
> Makefile that instead should be changed to SPL_TPL_/PHASE_ and similar
> avoid a change to XPL_BUILD because the original intent was just for SPL?

Ideally use xpl_phase() if possible. Otherwise you can send a patch to
clean up and simplify the #ifdefs.

>
> I will also suggest you rearrange some of you patches to make this more
> reviewable and possible also make git bisect easier, maybe:
>
> - any fixes not involving XPL first, e.g. _SPL to _SPL_TPL in Makefile,

Where are you seeing those?

>   SPL_BUILD in Kconfig etc

Here I think you mean the fixes for tegram etc, Yes I can put those first.

> - add XPL_BUILD symbol

OK

> - all fixes and cleanup involving XPL_BUILD symbol

OK

> - rename and use spl_ to xpl_ functions

OK. That will generate churn, since they will have to be using
SPL_BUILD at this point, then changed later to use XPL_BUILD.

> - doc updates

OK

> - replace SPL_BUILD with XPL_BUILD in code, preferably in multiple
>   smaller logical patches instead of a single big patch

OK I can split it by subdir, perhaps. It is about 15k lines of changes

> - remove SPL_BUILD for TPL and VPL

OK

> - rename SPL_ to XPL_ in Makefile

OK

> - rename SPL_TPL_ to PHASE_ in Makefile, NAME and PROMPT

OK

>
> or something similar instead of doing the big search and replace early.

I will give this a try in v3.

Regards,
Simon


Re: [PATCH v2 04/30] scripts: Define CONFIG_XPL_BUILD for all xPL builds

2024-09-29 Thread Simon Glass
Hi Jonas,

On Sat, 28 Sept 2024 at 22:56, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2024-09-28 22:00, Simon Glass wrote:
> > The new name 'xPL' is intended to indicate a build of any phase which is
> > not U-Boot proper. Define it for all such phases.
> >
> > Note that we also define CONFIG_SPL_BUILD for all xPL builds. This
> > preserves existing behaviour, but future patches will adjust that.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  scripts/Makefile.autoconf | 6 +++---
> >  scripts/Makefile.xpl  | 9 +
> >  2 files changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
> > index b42f9b525fe..d7544022a31 100644
> > --- a/scripts/Makefile.autoconf
> > +++ b/scripts/Makefile.autoconf
> > @@ -83,15 +83,15 @@ u-boot.cfg: include/config.h FORCE
> >
> >  spl/u-boot.cfg: include/config.h FORCE
> >   $(Q)mkdir -p $(dir $@)
> > - $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD)
> > + $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD)
> >
> >  tpl/u-boot.cfg: include/config.h FORCE
> >   $(Q)mkdir -p $(dir $@)
> > - $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
> > + $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
> > -DCONFIG_TPL_BUILD)
> >
> >  vpl/u-boot.cfg: include/config.h FORCE
> >   $(Q)mkdir -p $(dir $@)
> > - $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_VPL_BUILD)
> > + $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
> > -DCONFIG_VPL_BUILD)
> >
> >  include/autoconf.mk: u-boot.cfg
> >   $(call cmd,autoconf)
> > diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
> > index 3091311a3d2..ad21d451a30 100644
> > --- a/scripts/Makefile.xpl
> > +++ b/scripts/Makefile.xpl
> > @@ -21,15 +21,16 @@ include $(srctree)/scripts/Kbuild.include
> >
> >  -include include/config/auto.conf
> >
> > -# This file contains 0, 1 or 2 lines
> > +# This file contains 0, 2 or 3 lines
> >  # It is empty for U-Boot proper (where $(obj) is empty)
> > -# For any xPL build it contains CONFIG_SPL_BUILD=y
> > -# For TPL builds it has CONFIG_SPL_BUILD=y and CONFIG_TPL_BUILD=y
> > -# For VPL builds it has CONFIG_SPL_BUILD=y and CONFIG_VPL_BUILD=y
> > +# For any xPL build it contains CONFIG_SPL_BUILD=y and CONFIG_XPL_BUILD=y
> > +#- for TPL builds it also contains CONFIG_TPL_BUILD=y
> > +#- for VPL builds it also contains CONFIG_VPL_BUILD=y
>
> This comment block was just added in the prior patch, and now changed
> and re-formatted, why not just add the comments in this patch or at
> least this patch should only contain the addition of XPL_BUILD.

It is changing because this patch changes how things work. I
documented it properly in the previous patch so that it is clear what
is changing in this patch.

I suppose I could just drop the changes in the previous patch, but I
like the idea of clearly documenting what is going on, in case we have
to come back to this later.

[..]

Regards,
Simon


Re: [PATCH v2 13/30] xpl: Define CONFIG_SPL_BUILD only for the SPL build

2024-09-29 Thread Simon Glass
Hi Jonas,

On Sun, 29 Sept 2024 at 00:19, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2024-09-28 22:00, Simon Glass wrote:
> > Make this define mean SPL only, not TPL, VPL, etc.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  scripts/Makefile.autoconf | 4 ++--
> >  scripts/Makefile.xpl  | 9 ++---
> >  2 files changed, 8 insertions(+), 5 deletions(-)
> >
>
> [snip]
>
> > --- a/scripts/Makefile.xpl
> > +++ b/scripts/Makefile.xpl
> > @@ -21,9 +21,10 @@ include $(srctree)/scripts/Kbuild.include
> >
> >  -include include/config/auto.conf
> >
> > -# This file contains 0, 2 or 3 lines
> > +# This file contains 0, or 2 lines
> >  # It is empty for U-Boot proper (where $(obj) is empty)
> > -# For any xPL build it contains CONFIG_SPL_BUILD=y and CONFIG_XPL_BUILD=y
> > +# For any xPL build it contains CONFIG_XPL_BUILD=y
> > +#- for SPL builds it also contains CONFIG_SPL_BUILD=y
> >  #- for TPL builds it also contains CONFIG_TPL_BUILD=y
> >  #- for VPL builds it also contains CONFIG_VPL_BUILD=y
> >  -include $(obj)/include/autoconf.mk
> > @@ -31,7 +32,9 @@ include $(srctree)/scripts/Kbuild.include
> >  UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
> >
> >  KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
> > -KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
>
> This change look strange and this line should have defined
> CONFIG_SPL_BUILD prior to this patch.

Yes, I will fix up the earlier patch:

global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD

so that it doesn't define XPL_BUILD twice. This affects the behaviour
of 'make defconfig' but I suspect buildman did not do a reconfig so it
had no effect.

Regards,
Simon


Re: [PATCH v2 05/30] global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD

2024-09-29 Thread Simon Glass
Hi Jonas,

On Sun, 29 Sept 2024 at 13:00, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2024-09-28 22:00, Simon Glass wrote:
> > Use the new symbol to refer to any 'SPL' build, including TPL and VPL
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
>
> [snip]
>
> > diff --git a/arch/arm/include/asm/arch-rockchip/boot0.h 
> > b/arch/arm/include/asm/arch-rockchip/boot0.h
> > index 0c375e543a5..edb2a31c348 100644
> > --- a/arch/arm/include/asm/arch-rockchip/boot0.h
> > +++ b/arch/arm/include/asm/arch-rockchip/boot0.h
> > @@ -12,7 +12,7 @@
> >   * To make life easier for everyone, we build the SPL binary with
> >   * space for this 4-byte header already included in the binary.
> >   */
> > -#ifdef CONFIG_SPL_BUILD
> > +#ifdef CONFIG_XPL_BUILD
> >   /*
> >* We need to add 4 bytes of space for the 'RK33' at the
> >* beginning of the executable.  However, as we want to keep
> > @@ -39,7 +39,7 @@ entry_counter:
> >   .word   0
> >  #endif
> >
> > -#if (defined(CONFIG_SPL_BUILD) || defined(CONFIG_ARM64))
> > +#if (defined(CONFIG_XPL_BUILD) || defined(CONFIG_ARM64))
> >   /* U-Boot proper of armv7 do not need this */
> >   b reset
> >  #endif
> > @@ -54,7 +54,7 @@ _start:
> >   ARM_VECTORS
> >  #endif
> >
> > -#if !defined(CONFIG_TPL_BUILD) && defined(CONFIG_SPL_BUILD) && \
> > +#if !defined(CONFIG_TPL_BUILD) && defined(CONFIG_XPL_BUILD) && \
>
> This is meant to be for SPL where TF-A is loaded into part of SRAM,
> and is only needed/used when CONFIG_TPL=n, so no need to replace it with
> XPL_BUILD.

I'm not sure if there is a misunderstanding here.

XPL_BUILD is the new SPL_BUILD, i.e. it means the same as SPL_BUILD
used to. So all occurrences of SPL_BUILD need to change to XPL_BUILD.

Before it was a bit unclear and murky as to what was intended,
particularly as apparently many people were not too sure of the real
meaning of SPL_BUILD. Resolving that is the intent of this rename.

Of course I think follow-up patches could tidy things up, now that we
have a 'real' SPL_BUILD (which means SPL and not also TPL, VPL). I
included some of those in the v1 series, but of course then people
wonder why they can't be squashed into the rename, so it just confuses
the whole process.

So my goal with this patch is to completely rename everything.


>
> >   (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0)
> >   .space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for the ATF data */
> >  #endif
> > diff --git a/arch/arm/include/asm/arch-rockchip/cru_rv1126.h 
> > b/arch/arm/include/asm/arch-rockchip/cru_rv1126.h
> > index 49a1f763795..ae273de3144 100644
> > --- a/arch/arm/include/asm/arch-rockchip/cru_rv1126.h
> > +++ b/arch/arm/include/asm/arch-rockchip/cru_rv1126.h
> > @@ -11,7 +11,7 @@
> >  #define KHz  1000
> >  #define OSC_HZ   (24 * MHz)
> >
> > -#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> > +#if defined(CONFIG_XPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> >  #define APLL_HZ  (1008 * MHz)
> >  #else
> >  #define APLL_HZ  (816 * MHz)
> > @@ -20,7 +20,7 @@
> >  #define CPLL_HZ  (500 * MHz)
> >  #define HPLL_HZ  (1400 * MHz)
> >  #define PCLK_PDPMU_HZ(100 * MHz)
> > -#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> > +#if defined(CONFIG_XPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> >  #define ACLK_PDBUS_HZ(396 * MHz)
> >  #else
> >  #define ACLK_PDBUS_HZ(500 * MHz)
> > @@ -32,7 +32,7 @@
> >  #define HCLK_PDCORE_HZ   (200 * MHz)
> >  #define HCLK_PDAUDIO_HZ  (150 * MHz)
> >  #define CLK_OSC0_DIV_HZ  (32768)
> > -#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> > +#if defined(CONFIG_XPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> >  #define ACLK_PDVI_HZ (297 * MHz)
> >  #define CLK_ISP_HZ   (297 * MHz)
> >  #define ACLK_PDISPP_HZ   (297 * MHz)
> > @@ -324,7 +324,7 @@ enum {
> >   DCLK_VOP_DIV_SHIFT  = 0,
> >   DCLK_VOP_DIV_MASK   = 0xff,
> >
> > -#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> > +#if defined(CONFIG_XPL_BUILD) && defined(CONFIG_SPL_KERNEL_BOOT)
> >   /* CRU_CLK_SEL49_CON */
> >   ACLK_PDVI_SEL_SHIFT = 6,
> >   ACLK_PDVI_SEL_MASK  = 0x3 << ACLK_PDVI_SEL_SHIFT,
> > @@ -397,7 

Re: [PATCH v2 21/30] xpl: Rename u_boot_first_phase to xpl_is_first_phase()

2024-09-29 Thread Simon Glass
Hi Jonas,

On Sat, 28 Sept 2024 at 16:23, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2024-09-28 22:00, Simon Glass wrote:
> > This is a better name for this function, so update it.
> >
> > Tidy up the function comment to mention VPL. Use SPL_BUILD in the SPL
> > check, for clarity.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  arch/arm/mach-omap2/am33xx/board.c |  2 +-
> >  common/bloblist.c  |  4 ++--
> >  common/spl/spl.c   |  4 ++--
> >  include/spl.h  | 16 +---
> >  4 files changed, 14 insertions(+), 12 deletions(-)
> >
>
> [snip]
>
> > --- a/include/spl.h
> > +++ b/include/spl.h
> > @@ -34,24 +34,26 @@ struct spl_boot_device;
> >  enum boot_device;
> >
> >  /*
> > - * u_boot_first_phase() - check if this is the first U-Boot phase
> > + * xpl_is_first_phase() - check if this is the first U-Boot phase
> >   *
> > - * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on 
> > the
> > - * build flags we can determine whether the current build is for the first
> > + * U-Boot has up to four phases: TPL, VPL, SPL and U-Boot proper. 
> > Depending on
> > + * the build flags we can determine whether the current build is for the 
> > first
> >   * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. 
> > If
> >   * there is SPL but no TPL, the the first phase is SPL. If there is TPL, 
> > then
> > - * it is the first phase.
> > + * it is the first phase, etc.
> >   *
> > - * @returns true if this is the first phase of U-Boot
> > + * Note that VPL can never be the first phase. If it exists, it is loaded 
> > from
> > + * TPL
> >   *
> > + * Return: true if this is the first phase of U-Boot
> >   */
> > -static inline bool u_boot_first_phase(void)
> > +static inline bool xpl_is_first_phase(void)
> >  {
> >   if (IS_ENABLED(CONFIG_TPL)) {
> >   if (IS_ENABLED(CONFIG_TPL_BUILD))
> >   return true;
> >   } else if (IS_ENABLED(CONFIG_SPL)) {
> > - if (IS_ENABLED(CONFIG_XPL_BUILD))
> > + if (IS_ENABLED(CONFIG_SPL_BUILD))
>
> Here is another instance where it made no sense to replace SPL with XPL
> to just later restore it back to SPL.

Thanks for taking the time to look through this!

The rename to XPL happens in 'global: Rename SPL_ to XPL_' which is an
earlier patch. That patch renames absolutely everything. If I leave
this particular one as SPL_BUILD, then there will still be occurrences
of SPL_BUILD in U-Boot. So when I later rebase this series I won't
know whether I missed something or not.

I can certainly drop the s/XPL/SPL/ change in this patch though, if
that is suitable?

Regards,
Simon


[PATCH v2 18/30] global: Rename SPL_TPL_ to PHASE_

2024-09-28 Thread Simon Glass
Use PHASE_ as the symbol to select a particular XPL build. This means
that SPL_TPL_ is no-longer set.

Update the comment in bootstage to refer to this symbol, instead of
SPL_

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile  |  2 +-
 arch/arm/cpu/armv8/Makefile   |  2 +-
 arch/arm/lib/Makefile | 16 +++---
 arch/arm/mach-at91/arm926ejs/Makefile |  2 +-
 arch/arm/mach-omap2/Makefile  |  2 +-
 arch/arm/mach-rockchip/Makefile   |  2 +-
 arch/powerpc/lib/Makefile |  2 +-
 arch/riscv/lib/Makefile   | 14 ++---
 arch/x86/Makefile |  6 +-
 arch/x86/cpu/Makefile |  8 +--
 arch/x86/cpu/broadwell/Makefile   | 10 ++--
 arch/x86/cpu/intel_common/Makefile| 10 ++--
 arch/x86/lib/Makefile |  6 +-
 board/coreboot/coreboot/Makefile  |  2 +-
 boot/Makefile | 80 +--
 common/Makefile   | 26 -
 common/bootstage.c|  4 +-
 common/init/Makefile  |  2 +-
 common/spl/Makefile   | 56 +--
 disk/Makefile | 18 +++---
 drivers/Makefile  | 70 +++
 drivers/adc/Makefile  |  2 +-
 drivers/block/Makefile|  8 +--
 drivers/cache/Makefile|  2 +-
 drivers/clk/Makefile  | 18 +++---
 drivers/clk/exynos/Makefile   |  2 +-
 drivers/clk/imx/Makefile  | 20 +++
 drivers/clk/ti/Makefile   |  4 +-
 drivers/core/Makefile | 10 ++--
 drivers/crypto/fsl/Makefile   |  2 +-
 drivers/gpio/Makefile |  6 +-
 drivers/input/Makefile|  6 +-
 drivers/misc/Makefile | 16 +++---
 drivers/mmc/Makefile  |  6 +-
 drivers/mtd/Makefile  |  4 +-
 drivers/mtd/nand/Makefile |  2 +-
 drivers/mtd/nand/raw/Makefile |  2 +-
 drivers/mtd/spi/Makefile  |  8 +--
 drivers/pinctrl/starfive/Makefile |  4 +-
 drivers/power/Makefile|  8 +--
 drivers/power/acpi_pmc/Makefile   |  2 +-
 drivers/power/pmic/Makefile   |  4 +-
 drivers/power/regulator/Makefile  |  2 +-
 drivers/ram/Makefile  |  2 +-
 drivers/reset/Makefile|  2 +-
 drivers/rng/Makefile  |  2 +-
 drivers/rtc/Makefile  |  6 +-
 drivers/scsi/Makefile |  2 +-
 drivers/serial/Makefile   |  2 +-
 drivers/spi/Makefile  |  2 +-
 drivers/sysreset/Makefile | 14 ++---
 drivers/tpm/Makefile  |  4 +-
 drivers/usb/gadget/Makefile   |  6 +-
 drivers/usb/host/Makefile |  4 +-
 drivers/video/Makefile| 16 +++---
 drivers/watchdog/Makefile |  2 +-
 env/Makefile  | 22 
 fs/sandbox/Makefile   |  2 +-
 lib/Makefile  | 34 ++--
 lib/acpi/Makefile |  2 +-
 lib/libfdt/Makefile   |  2 +-
 lib/rsa/Makefile  |  4 +-
 net/Makefile  |  6 +-
 scripts/Kbuild.include|  8 +--
 scripts/Makefile.xpl  | 44 +++
 test/dm/Makefile  |  4 +-
 tools/qconfig.py  |  6 +-
 67 files changed, 338 insertions(+), 338 deletions(-)

diff --git a/Makefile b/Makefile
index d38adcbd1e6..ca74406f21c 100644
--- a/Makefile
+++ b/Makefile
@@ -883,7 +883,7 @@ libs-y += drivers/usb/ulpi/
 ifdef CONFIG_POST
 libs-y += post/
 endif
-libs-$(CONFIG_$(SPL_TPL_)UNIT_TEST) += test/
+libs-$(CONFIG_$(PHASE_)UNIT_TEST) += test/
 libs-$(CONFIG_UT_ENV) += test/env/
 libs-$(CONFIG_UT_OPTEE) += test/optee/
 libs-$(CONFIG_UT_OVERLAY) += test/overlay/
diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
index c5f568e2cb7..8747d2eb186 100644
--- a/arch/arm/cpu/armv8/Makefile
+++ b/arch/arm/cpu/armv8/Makefile
@@ -6,7 +6,7 @@
 extra-y:= start.o
 
 obj-y  += cpu.o
-ifndef CONFIG_$(SPL_TPL_)TIMER
+ifndef CONFIG_$(PHASE_)TIMER
 obj-$(CONFIG_SYS_ARCH_TIMER) += generic_timer.o
 endif
 ifndef CONFIG_$(XPL_)SYS_DCACHE_OFF
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index b73a0397541..211ff4960e1 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -34,7 +34,7 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 else
-obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
+obj-$(CONFIG_$(PHASE_)FRAMEWORK) += spl.o
 ifdef CONFIG_SPL_FRAMEWORK
 obj-$(CONFIG_CMD_BOOTI) += image.o
 obj-$(CONFIG_CMD_BOOTZ) += zimage.o
@@ -42,14 +42,14 @@ endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
-obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET

[PATCH v2 17/30] global: Rename SPL_ to XPL_

2024-09-28 Thread Simon Glass
Use XPL_ as the symbol to indicate an SPL build. This means that SPL_ is
no-longer set.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile|  4 +--
 arch/arm/config.mk  |  6 ++--
 arch/arm/cpu/arm920t/Makefile   |  2 +-
 arch/arm/cpu/arm926ejs/Makefile |  2 +-
 arch/arm/cpu/armv7/Makefile |  2 +-
 arch/arm/cpu/armv8/Makefile |  4 +--
 arch/arm/lib/Makefile   |  2 +-
 arch/arm/mach-at91/arm926ejs/Makefile   |  2 +-
 arch/arm/mach-imx/Makefile  |  2 +-
 arch/arm/mach-omap2/am33xx/Makefile |  2 +-
 arch/arm/mach-orion5x/Makefile  |  4 +--
 arch/arm/mach-stm32mp/stm32mp1/Makefile |  2 +-
 arch/arm/mach-tegra/Makefile|  2 +-
 arch/arm/mach-tegra/tegra20/Makefile|  2 +-
 arch/arm/mach-tegra/tegra30/Makefile|  2 +-
 arch/arm/mach-zynqmp/Makefile   |  2 +-
 arch/riscv/Makefile |  2 +-
 arch/riscv/lib/Makefile |  8 ++---
 arch/x86/Makefile   |  2 +-
 arch/x86/cpu/Makefile   | 12 +++
 arch/x86/cpu/intel_common/Makefile  |  4 +--
 arch/x86/cpu/ivybridge/Makefile |  6 ++--
 arch/x86/cpu/qemu/Makefile  |  2 +-
 arch/x86/lib/Makefile   |  4 +--
 board/bosch/guardian/Makefile   |  2 +-
 board/freescale/common/Makefile |  4 +--
 board/st/common/Makefile|  2 +-
 board/tcl/sl50/Makefile |  2 +-
 board/ti/am335x/Makefile|  2 +-
 board/ti/am43xx/Makefile|  2 +-
 board/vscom/baltos/Makefile |  2 +-
 board/xilinx/zynqmp/Makefile|  2 +-
 boot/Makefile   |  2 +-
 cmd/Makefile|  2 +-
 doc/develop/tests_writing.rst   |  6 ++--
 drivers/Makefile| 14 
 drivers/ata/Makefile|  2 +-
 drivers/block/Makefile  |  2 +-
 drivers/bus/Makefile|  2 +-
 drivers/core/Makefile   |  6 ++--
 drivers/ddr/altera/Makefile |  2 +-
 drivers/dfu/Makefile| 16 -
 drivers/firmware/Makefile   |  2 +-
 drivers/gpio/Makefile   |  8 ++---
 drivers/i2c/Makefile| 16 -
 drivers/led/Makefile|  2 +-
 drivers/mailbox/Makefile|  2 +-
 drivers/misc/Makefile   | 10 +++---
 drivers/mmc/Makefile|  6 ++--
 drivers/mux/Makefile|  2 +-
 drivers/nvme/Makefile   |  2 +-
 drivers/phy/Makefile|  6 ++--
 drivers/phy/cadence/Makefile|  4 +--
 drivers/phy/ti/Makefile |  2 +-
 drivers/pinctrl/Makefile|  8 ++---
 drivers/power/domain/Makefile   |  2 +-
 drivers/power/pmic/Makefile | 30 
 drivers/power/regulator/Makefile| 46 -
 drivers/remoteproc/Makefile |  2 +-
 drivers/serial/Makefile |  2 +-
 drivers/timer/Makefile  |  8 ++---
 drivers/usb/cdns3/Makefile  |  4 +--
 drivers/usb/common/Makefile |  2 +-
 drivers/usb/dwc3/Makefile   |  4 +--
 drivers/usb/gadget/udc/Makefile |  4 +--
 drivers/usb/host/Makefile   |  2 +-
 drivers/video/Makefile  |  2 +-
 drivers/video/tidss/Makefile|  2 +-
 fs/fat/Makefile |  4 +--
 fs/squashfs/Makefile|  2 +-
 lib/Makefile| 28 +++
 lib/acpi/Makefile   |  8 ++---
 lib/aes/Makefile|  2 +-
 lib/crypto/Makefile | 14 
 lib/ecdsa/Makefile  |  2 +-
 net/Makefile|  6 ++--
 scripts/Kbuild.include  |  4 +--
 scripts/Makefile.xpl|  4 +--
 test/Makefile   | 22 ++--
 test/fuzz/Makefile  |  2 +-
 tools/qconfig.py|  6 ++--
 81 files changed, 219 insertions(+), 219 deletions(-)

diff --git a/Makefile b/Makefile
index 4378993ccfd..d38adcbd1e6 100644
--- a/Makefile
+++ b/Makefile
@@ -829,7 +829,7 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 UBOOTINCLUDE:= \
-Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
-   $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+   $(if $(CONFIG_$(XPL_)SYS_THUMB_BUILD), \
$(if $(CONFIG_HAS_THUMB2), \
$(if $(CONFIG_CPU_V7M), \
-I$(srctree)/arch/arm/thumb1/include), \
@@ -864,7 +864,7 @@ libs-y += disk/
 libs-y += drivers/
 libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
 libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl

[PATCH v2 00/30] Tidy up use of 'SPL' and CONFIG_SPL_BUILD

2024-09-28 Thread Simon Glass
When the SPL build-phase was first created it was designed to solve a
particular problem (the need to init SDRAM so that U-Boot proper could
be loaded). It has since expanded to become an important part of U-Boot,
with three phases now present: TPL, VPL and SPL

Due to this history, the term 'SPL' is used to mean both a particular
phase (the one before U-Boot proper) and all the non-proper phases.
This has become confusing.

For a similar reason CONFIG_SPL_BUILD is set to 'y' for all 'SPL'
phases, not just SPL. So code which can only be compiled for actual SPL,
for example, must use something like this:

   #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)

In Makefiles we have similar issues. SPL_ has been used as a variable
which expands to either SPL_ or nothing, to chose between options like
CONFIG_BLK and CONFIG_SPL_BLK. When TPL appeared, a new SPL_TPL variable
was created which expanded to 'SPL_', 'TPL_' or nothing. Later it was
updated to support 'VPL_' as well.

This series starts a change in terminology and usage to resolve the
above issues:

- The word 'xPL' is used instead of 'SPL' to mean a non-proper build
- A new CONFIG_XPL_BUILD define indicates that the current build is an
  'xPL' build
- The existing CONFIG_SPL_BUILD is changed to mean SPL; it is not now
  defined for TPL and VPL phases
- The existing SPL_ Makefile variable is renamed to SPL_
- The existing SPL_TPL Makefile variable is renamed to PHASE_

It should be noted that xpl_phase() can generally be used instead of
the above CONFIGs without a code-space or run-time penalty.

This series does not attempt to convert all of U-Boot to use this new
terminology but it makes a start. In particular, renaming spl.h and
common/spl seems like a bridge too far at this point.

An attempt has been made to make this series bisectable, but this is a
little tricky, so some logic errors may be present.

The series has been checked to make sure that there are no code-size
changes on any commit.

Changes in v2:
- Drop patches not stricly necessary for the conversion
- Update cover letter re code size
- Rebase to -next

Simon Glass (30):
  Makefile: Add a u-boot.cfg file for VPL
  scripts: Rename Makefile.spl to Makefile.xpl
  scripts: Add some comments about autoconf.mk
  scripts: Define CONFIG_XPL_BUILD for all xPL builds
  global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  doc: Update SPL docs for the xPL changes
  net: freescale: Drop use of SPL_BUILD dependency
  x86: Update a comment to mention XPL
  tegra: Use SPL instead of SPL_BUILD
  log: global: Rename warn_non_spl() and update the condition
  qconfig: Add XPL_BUILD to ignored symbols
  boot: Drop unnecessary ifdef for LOAD_FIT
  xpl: Define CONFIG_SPL_BUILD only for the SPL build
  serial: Make use of the SERIAL define
  stdio: Make use of the SERIAL define
  kconfig: binman: Check for SPL instead of XPL
  global: Rename SPL_ to XPL_
  global: Rename SPL_TPL_ to PHASE_
  spl: Rename SPL_TPL_NAME and SPL_TPL_PROMPT
  qconfig: Update tool for new Makefile variables
  xpl: Rename u_boot_first_phase to xpl_is_first_phase()
  xpl: Rename spl_phase to xpl_phase_t
  xpl: Rename spl_phase() to xpl_phase()
  xpl: Rename spl_in_proper() to not_xpl()
  xpl: Add a function to indicate when in xPL
  xpl: Rename spl_next_phase() and spl_prev_phase()
  xpl: Rename spl_phase_prefix() and spl_phase_name()
  README: Drop SoC-specific comment about SPL
  doc: Move init-related things out of README
  doc: Update init docs for the xPL changes

 Makefile  | 14 +--
 README| 99 +--
 arch/arm/Makefile |  6 +-
 arch/arm/config.mk| 12 +--
 arch/arm/cpu/arm11/Makefile   |  2 +-
 arch/arm/cpu/arm1176/start.S  |  2 +-
 arch/arm/cpu/arm920t/Makefile |  2 +-
 arch/arm/cpu/arm926ejs/Makefile   |  4 +-
 arch/arm/cpu/arm926ejs/mxs/Makefile   |  4 +-
 arch/arm/cpu/arm926ejs/sunxi/config.mk|  2 +-
 arch/arm/cpu/armv7/Makefile   |  4 +-
 arch/arm/cpu/armv7/cpu.c  |  2 +-
 arch/arm/cpu/armv7/lowlevel_init.S|  4 +-
 arch/arm/cpu/armv7/s5p-common/Makefile|  2 +-
 arch/arm/cpu/armv7/start.S|  2 +-
 arch/arm/cpu/armv7/sunxi/Makefile |  4 +-
 arch/arm/cpu/armv8/Makefile   | 12 +--
 arch/arm/cpu/armv8/cache_v8.c |  2 +-
 arch/arm/cpu/armv8/fsl-layerscape/Makefile|  2 +-
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   | 14 +--
 .../armv8/fsl-layerscape/fsl_lsch2_speed.c|  2 +-
 .../armv8/fsl-layerscape/fsl_lsch3_serdes.c   |  6 +-
 arch/arm/cpu/armv8/fsl-layerscape/icid.c  |  6 +-
 arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S  |  6 +-
 .../arm/cpu/armv8/fsl-layerscape/l

[PATCH v2 30/30] doc: Update init docs for the xPL changes

2024-09-28 Thread Simon Glass
Update the documentation here to cover the meaning of xPL

Signed-off-by: Simon Glass 
---

Changes in v2:
- Drop patches not stricly necessary for the conversion
- Update cover letter re code size
- Rebase to -next

 doc/develop/init.rst | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/doc/develop/init.rst b/doc/develop/init.rst
index 2955d9bdbc3..ce985781bb4 100644
--- a/doc/develop/init.rst
+++ b/doc/develop/init.rst
@@ -4,15 +4,16 @@ Board Initialisation Flow
 -
 
 This is the intended start-up flow for boards. This should apply for both
-SPL and U-Boot proper (i.e. they both follow the same rules).
+xPL and U-Boot proper (i.e. they both follow the same rules).
 
-Note: "SPL" stands for "Secondary Program Loader," which is explained in
-more detail later in this file.
+Note: "xPL" stands for "any Program Loader", including SPL (Secondary
+Program Loader), TPL (Tertiary Program Loader) and VPL (Verifying Program
+Loader). The boot sequence is TPL->VPL->SPL->U-Boot proper
 
-At present, SPL mostly uses a separate code path, but the function names
+At present, xPL mostly uses a separate code path, but the function names
 and roles of each function are the same. Some boards or architectures
 may not conform to this.  At least most ARM boards which use
-CONFIG_SPL_FRAMEWORK conform to this.
+CONFIG_xPL_FRAMEWORK conform to this.
 
 Execution typically starts with an architecture-specific (and possibly
 CPU-specific) start.S file, such as:
@@ -48,7 +49,7 @@ board_init_f()
 
 Non-xPL-specific notes:
 
-- dram_init() is called to set up DRAM. If already done in SPL this
+- dram_init() is called to set up DRAM. If already done in xPL this
   can do nothing
 
 xPL-specific notes:
@@ -68,9 +69,9 @@ xPL-specific notes:
 - must return normally from this function (don't call board_init_r()
   directly)
 
-Here the BSS is cleared. For SPL, if CONFIG_SPL_STACK_R is defined, then at
+Here the BSS is cleared. For xPL, if CONFIG_xPL_STACK_R is defined, then at
 this point the stack and global_data are relocated to below
-CONFIG_SPL_STACK_R_ADDR. For non-SPL, U-Boot is relocated to run at the top of
+CONFIG_xPL_STACK_R_ADDR. For non-xPL, U-Boot is relocated to run at the top of
 memory.
 
 board_init_r()
@@ -82,11 +83,11 @@ board_init_r()
 - BSS is available, all static/global variables can be used
 - execution eventually continues to main_loop()
 
-Non-SPL-specific notes:
+Non-xPL-specific notes:
 
 - U-Boot is relocated to the top of memory and is now running from
   there.
 
-SPL-specific notes:
+xPL-specific notes:
 
-- stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined
+- stack is optionally in SDRAM, if CONFIG_xPL_STACK_R is defined
-- 
2.34.1



[PATCH v2 29/30] doc: Move init-related things out of README

2024-09-28 Thread Simon Glass
Move this section to rst, changing it just enough so that it builds.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 README| 81 -
 doc/develop/index.rst |  1 +
 doc/develop/init.rst  | 92 +++
 3 files changed, 93 insertions(+), 81 deletions(-)
 create mode 100644 doc/develop/init.rst

diff --git a/README b/README
index 5115d28fac1..5a5b93fecb8 100644
--- a/README
+++ b/README
@@ -134,87 +134,6 @@ run some of U-Boot's tests.
 See doc/arch/sandbox/sandbox.rst for more details.
 
 
-Board Initialisation Flow:
---
-
-This is the intended start-up flow for boards. This should apply for both
-SPL and U-Boot proper (i.e. they both follow the same rules).
-
-Note: "SPL" stands for "Secondary Program Loader," which is explained in
-more detail later in this file.
-
-At present, SPL mostly uses a separate code path, but the function names
-and roles of each function are the same. Some boards or architectures
-may not conform to this.  At least most ARM boards which use
-CONFIG_SPL_FRAMEWORK conform to this.
-
-Execution typically starts with an architecture-specific (and possibly
-CPU-specific) start.S file, such as:
-
-   - arch/arm/cpu/armv7/start.S
-   - arch/powerpc/cpu/mpc83xx/start.S
-   - arch/mips/cpu/start.S
-
-and so on. From there, three functions are called; the purpose and
-limitations of each of these functions are described below.
-
-lowlevel_init():
-   - purpose: essential init to permit execution to reach board_init_f()
-   - no global_data or BSS
-   - there is no stack (ARMv7 may have one but it will soon be removed)
-   - must not set up SDRAM or use console
-   - must only do the bare minimum to allow execution to continue to
-   board_init_f()
-   - this is almost never needed
-   - return normally from this function
-
-board_init_f():
-   - purpose: set up the machine ready for running board_init_r():
-   i.e. SDRAM and serial UART
-   - global_data is available
-   - stack is in SRAM
-   - BSS is not available, so you cannot use global/static variables,
-   only stack variables and global_data
-
-   Non-SPL-specific notes:
-   - dram_init() is called to set up DRAM. If already done in SPL this
-   can do nothing
-
-   SPL-specific notes:
-   - you can override the entire board_init_f() function with your own
-   version as needed.
-   - preloader_console_init() can be called here in extremis
-   - should set up SDRAM, and anything needed to make the UART work
-   - there is no need to clear BSS, it will be done by crt0.S
-   - for specific scenarios on certain architectures an early BSS *can*
- be made available (via CONFIG_SPL_EARLY_BSS by moving the clearing
- of BSS prior to entering board_init_f()) but doing so is discouraged.
- Instead it is strongly recommended to architect any code changes
- or additions such to not depend on the availability of BSS during
- board_init_f() as indicated in other sections of this README to
- maintain compatibility and consistency across the entire code base.
-   - must return normally from this function (don't call board_init_r()
-   directly)
-
-Here the BSS is cleared. For SPL, if CONFIG_SPL_STACK_R is defined, then at
-this point the stack and global_data are relocated to below
-CONFIG_SPL_STACK_R_ADDR. For non-SPL, U-Boot is relocated to run at the top of
-memory.
-
-board_init_r():
-   - purpose: main execution, common code
-   - global_data is available
-   - SDRAM is available
-   - BSS is available, all static/global variables can be used
-   - execution eventually continues to main_loop()
-
-   Non-SPL-specific notes:
-   - U-Boot is relocated to the top of memory and is now running from
-   there.
-
-   SPL-specific notes:
-   - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined
-
 The following options need to be configured:
 
 - CPU Type:Define exactly one, e.g. CONFIG_MPC85XX.
diff --git a/doc/develop/index.rst b/doc/develop/index.rst
index 0d0e60ab56c..da9643dca14 100644
--- a/doc/develop/index.rst
+++ b/doc/develop/index.rst
@@ -38,6 +38,7 @@ Implementation
distro
driver-model/index
environment
+   init
expo
cedit
event
diff --git a/doc/develop/init.rst b/doc/develop/init.rst
new file mode 100644
index 000..2955d9bdbc3
--- /dev/null
+++ b/doc/develop/init.rst
@@ -0,0 +1,92 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Board Initialisation Flow
+-
+
+This is the intended start-up flow for boards. This should apply for both
+SPL and U-Boot proper (i.e. they both follow the same rules).
+
+Note: "SPL" stands for "Secondary Program Loader," whi

[PATCH v2 28/30] README: Drop SoC-specific comment about SPL

2024-09-28 Thread Simon Glass
This should not be in the generic README file, so drop it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 README | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/README b/README
index 54ffbd0975b..5115d28fac1 100644
--- a/README
+++ b/README
@@ -213,15 +213,7 @@ board_init_r():
there.
 
SPL-specific notes:
-   - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined and
-   CONFIG_SYS_FSL_HAS_CCI400
-
-   Defined For SoC that has cache coherent interconnect
-   CCN-400
-
-   CONFIG_SYS_FSL_HAS_CCN504
-
-   Defined for SoC that has cache coherent interconnect CCN-504
+   - stack is optionally in SDRAM, if CONFIG_SPL_STACK_R is defined
 
 The following options need to be configured:
 
-- 
2.34.1



[PATCH v2 27/30] xpl: Rename spl_phase_prefix() and spl_phase_name()

2024-09-28 Thread Simon Glass
Use simpler names for these functions.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/spl.c | 4 ++--
 arch/x86/lib/tpl.c | 2 +-
 cmd/vbe.c  | 2 +-
 common/spl/spl.c   | 5 ++---
 include/spl.h  | 8 
 5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 71d785f4c3e..c50df5f9179 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -27,8 +27,8 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool 
use_img)
const char *cur_prefix, *next_prefix;
int ret;
 
-   cur_prefix = spl_phase_prefix(xpl_phase());
-   next_prefix = spl_phase_prefix(xpl_next_phase());
+   cur_prefix = xpl_prefix(xpl_phase());
+   next_prefix = xpl_prefix(xpl_next_phase());
ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
if (ret)
return log_msg_ret("find", ret);
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 0606b4a1c67..f7df7e03621 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -103,7 +103,7 @@ int spl_spi_load_image(void)
 
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
-   debug("Jumping to %s at %lx\n", spl_phase_name(xpl_next_phase()),
+   debug("Jumping to %s at %lx\n", xpl_name(xpl_next_phase()),
  (ulong)spl_image->entry_point);
 #ifdef DEBUG
print_buffer(spl_image->entry_point, (void *)spl_image->entry_point, 1,
diff --git a/cmd/vbe.c b/cmd/vbe.c
index 423d9e5f8f0..186f6e6860d 100644
--- a/cmd/vbe.c
+++ b/cmd/vbe.c
@@ -93,7 +93,7 @@ static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int 
argc,
printf("Phases:");
for (i = PHASE_NONE; i < PHASE_COUNT; i++) {
if (handoff->phases & (1 << i))
-   printf(" %s", spl_phase_name(i));
+   printf(" %s", xpl_name(i));
 
}
if (!handoff->phases)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index a221b64f81d..94657d00591 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -475,8 +475,7 @@ static int spl_common_init(bool setup_malloc)
if (ret)
log_debug("Failed to unstash bootstage: ret=%d\n", ret);
}
-   bootstage_mark_name(get_bootstage_id(true),
-   spl_phase_name(xpl_phase()));
+   bootstage_mark_name(get_bootstage_id(true), xpl_name(xpl_phase()));
 #if CONFIG_IS_ENABLED(LOG)
ret = log_init();
if (ret) {
@@ -762,7 +761,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
os = spl_image.os;
if (os == IH_OS_U_BOOT) {
-   debug("Jumping to %s...\n", spl_phase_name(xpl_next_phase()));
+   debug("Jumping to %s...\n", xpl_name(xpl_next_phase()));
} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
debug("Jumping to U-Boot via ARM Trusted Firmware\n");
spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
diff --git a/include/spl.h b/include/spl.h
index d66c6cdd24a..fcf1313b8ae 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -194,11 +194,11 @@ static inline enum xpl_phase_t xpl_next_phase(void)
 }
 
 /**
- * spl_phase_name() - Get the name of the current phase
+ * xpl_name() - Get the name of a phase
  *
  * Return: phase name
  */
-static inline const char *spl_phase_name(enum xpl_phase_t phase)
+static inline const char *xpl_name(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
@@ -216,12 +216,12 @@ static inline const char *spl_phase_name(enum xpl_phase_t 
phase)
 }
 
 /**
- * spl_phase_prefix() - Get the prefix  of the current phase
+ * xpl_prefix() - Get the prefix  of the current phase
  *
  * @phase: Phase to look up
  * Return: phase prefix ("spl", "tpl", etc.)
  */
-static inline const char *spl_phase_prefix(enum xpl_phase_t phase)
+static inline const char *xpl_prefix(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
-- 
2.34.1



[PATCH v2 26/30] xpl: Rename spl_next_phase() and spl_prev_phase()

2024-09-28 Thread Simon Glass
Rename this to use the xpl prefix.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/spl.c |  4 ++--
 arch/x86/lib/tpl.c |  2 +-
 common/bloblist.c  |  2 +-
 common/spl/spl.c   | 14 +++---
 include/spl.h  |  8 
 lib/fdtdec.c   |  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 7497d90fb89..71d785f4c3e 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -28,7 +28,7 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool 
use_img)
int ret;
 
cur_prefix = spl_phase_prefix(xpl_phase());
-   next_prefix = spl_phase_prefix(spl_next_phase());
+   next_prefix = spl_phase_prefix(xpl_next_phase());
ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
if (ret)
return log_msg_ret("find", ret);
@@ -101,7 +101,7 @@ static int load_from_image(struct spl_image_info *spl_image,
if (!IS_ENABLED(CONFIG_SANDBOX_VPL))
return -ENOENT;
 
-   next_phase = spl_next_phase();
+   next_phase = xpl_next_phase();
pos = spl_get_image_pos();
size = spl_get_image_size();
if (pos == BINMAN_SYM_MISSING || size == BINMAN_SYM_MISSING) {
diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index 7c03dea0711..0606b4a1c67 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -103,7 +103,7 @@ int spl_spi_load_image(void)
 
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
-   debug("Jumping to %s at %lx\n", spl_phase_name(spl_next_phase()),
+   debug("Jumping to %s at %lx\n", spl_phase_name(xpl_next_phase()),
  (ulong)spl_image->entry_point);
 #ifdef DEBUG
print_buffer(spl_image->entry_point, (void *)spl_image->entry_point, 1,
diff --git a/common/bloblist.c b/common/bloblist.c
index fb86789df42..6640ad1fd69 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -512,7 +512,7 @@ int bloblist_init(void)
 */
bool from_boot_arg = fixed && xpl_is_first_phase();
 
-   if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
+   if (xpl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
from_addr = false;
if (fixed)
addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
diff --git a/common/spl/spl.c b/common/spl/spl.c
index a0de495e529..a221b64f81d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -176,10 +176,10 @@ ulong spl_get_image_pos(void)
return BINMAN_SYM_MISSING;
 
 #ifdef CONFIG_VPL
-   if (spl_next_phase() == PHASE_VPL)
+   if (xpl_next_phase() == PHASE_VPL)
return binman_sym(ulong, u_boot_vpl_any, image_pos);
 #endif
-   return spl_next_phase() == PHASE_SPL ?
+   return xpl_next_phase() == PHASE_SPL ?
binman_sym(ulong, u_boot_spl_any, image_pos) :
binman_sym(ulong, u_boot_any, image_pos);
 }
@@ -190,10 +190,10 @@ ulong spl_get_image_size(void)
return BINMAN_SYM_MISSING;
 
 #ifdef CONFIG_VPL
-   if (spl_next_phase() == PHASE_VPL)
+   if (xpl_next_phase() == PHASE_VPL)
return binman_sym(ulong, u_boot_vpl_any, size);
 #endif
-   return spl_next_phase() == PHASE_SPL ?
+   return xpl_next_phase() == PHASE_SPL ?
binman_sym(ulong, u_boot_spl_any, size) :
binman_sym(ulong, u_boot_any, size);
 }
@@ -201,10 +201,10 @@ ulong spl_get_image_size(void)
 ulong spl_get_image_text_base(void)
 {
 #ifdef CONFIG_VPL
-   if (spl_next_phase() == PHASE_VPL)
+   if (xpl_next_phase() == PHASE_VPL)
return CONFIG_VPL_TEXT_BASE;
 #endif
-   return spl_next_phase() == PHASE_SPL ? CONFIG_SPL_TEXT_BASE :
+   return xpl_next_phase() == PHASE_SPL ? CONFIG_SPL_TEXT_BASE :
CONFIG_TEXT_BASE;
 }
 
@@ -762,7 +762,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
os = spl_image.os;
if (os == IH_OS_U_BOOT) {
-   debug("Jumping to %s...\n", spl_phase_name(spl_next_phase()));
+   debug("Jumping to %s...\n", spl_phase_name(xpl_next_phase()));
} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
debug("Jumping to U-Boot via ARM Trusted Firmware\n");
spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
diff --git a/include/spl.h b/include/spl.h
index f90c3f56329..d66c6cdd24a 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -155,12 +155,12 @@ static inline bool is_xpl(void)
 }
 
 /**
- * spl_prev_phase() - Figure out the previous U-Boot phase
+ * xpl_prev_phase() - Figure out the previous U-Boot phase
  *
  * Return: the previous phase from this one, e.g. if called in SPL this returns
  * PHASE_TPL, if TPL is enabled
  */
-static inl

[PATCH v2 25/30] xpl: Add a function to indicate when in xPL

2024-09-28 Thread Simon Glass
Add the opposite function to not_xpl() for completeness.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/spl.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/spl.h b/include/spl.h
index c9ab0f3e977..f90c3f56329 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -144,6 +144,16 @@ static inline bool not_xpl(void)
return true;
 }
 
+/* returns true if in xPL, false if in U-Boot proper */
+static inline bool is_xpl(void)
+{
+#ifdef CONFIG_XPL_BUILD
+   return true;
+#endif
+
+   return false;
+}
+
 /**
  * spl_prev_phase() - Figure out the previous U-Boot phase
  *
-- 
2.34.1



[PATCH v2 24/30] xpl: Rename spl_in_proper() to not_xpl()

2024-09-28 Thread Simon Glass
Give this function a slightly easier name.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/mtd/nand/raw/sand_nand.c| 2 +-
 drivers/ram/rockchip/sdram_rk3399.c | 2 +-
 drivers/serial/ns16550.c| 4 ++--
 include/spl.h   | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/raw/sand_nand.c b/drivers/mtd/nand/raw/sand_nand.c
index 53489223030..3678bb8a41b 100644
--- a/drivers/mtd/nand/raw/sand_nand.c
+++ b/drivers/mtd/nand/raw/sand_nand.c
@@ -601,7 +601,7 @@ static int sand_nand_probe(struct udevice *dev)
}
 
nand = &chip->nand;
-   nand->options = spl_in_proper() ? 0 : NAND_SKIP_BBTSCAN;
+   nand->options = not_xpl() ? 0 : NAND_SKIP_BBTSCAN;
nand->flash_node = np;
nand->dev_ready = sand_nand_dev_ready;
nand->cmdfunc = sand_nand_command;
diff --git a/drivers/ram/rockchip/sdram_rk3399.c 
b/drivers/ram/rockchip/sdram_rk3399.c
index 7b48af49af8..6fa8f268770 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -196,7 +196,7 @@ static bool phase_sdram_init(void)
return xpl_phase() == PHASE_TPL ||
(!IS_ENABLED(CONFIG_TPL) &&
 !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) &&
-!spl_in_proper());
+!not_xpl());
 }
 
 static struct io_setting *
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 248fe3f778f..3489228127e 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -473,7 +473,7 @@ static int ns16550_serial_getinfo(struct udevice *dev,
struct ns16550_plat *plat = com_port->plat;
 
/* save code size */
-   if (!spl_in_proper())
+   if (!not_xpl())
return -ENOSYS;
 
info->type = SERIAL_CHIP_16550_COMPATIBLE;
@@ -555,7 +555,7 @@ int ns16550_serial_of_to_plat(struct udevice *dev)
struct clk clk;
int err;
 
-   addr = spl_in_proper() ? dev_read_addr_size(dev, &size) :
+   addr = not_xpl() ? dev_read_addr_size(dev, &size) :
dev_read_addr(dev);
err = ns16550_serial_assign_base(plat, addr, size);
if (err && !device_is_on_pci_bus(dev))
diff --git a/include/spl.h b/include/spl.h
index 079a38433a2..c9ab0f3e977 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -134,8 +134,8 @@ static inline enum xpl_phase_t xpl_phase(void)
 #endif
 }
 
-/* returns true if in U-Boot proper, false if in SPL */
-static inline bool spl_in_proper(void)
+/* returns true if in U-Boot proper, false if in xPL */
+static inline bool not_xpl(void)
 {
 #ifdef CONFIG_XPL_BUILD
return false;
-- 
2.34.1



[PATCH v2 23/30] xpl: Rename spl_phase() to xpl_phase()

2024-09-28 Thread Simon Glass
Rename this function to indicate that it refers to any xPL phase.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 README   |  6 +++---
 arch/sandbox/cpu/spl.c   |  2 +-
 arch/sandbox/cpu/start.c |  2 +-
 arch/x86/cpu/apollolake/cpu_spl.c|  4 ++--
 arch/x86/cpu/apollolake/hostbridge.c |  2 +-
 arch/x86/cpu/apollolake/lpc.c|  2 +-
 arch/x86/cpu/apollolake/pch.c|  2 +-
 arch/x86/cpu/apollolake/pmc.c|  4 ++--
 arch/x86/cpu/apollolake/punit.c  |  2 +-
 arch/x86/cpu/apollolake/spl.c|  2 +-
 arch/x86/cpu/broadwell/cpu.c |  2 +-
 arch/x86/cpu/i386/cpu.c  |  2 +-
 arch/x86/cpu/intel_common/mrc.c  |  2 +-
 arch/x86/cpu/intel_common/p2sb.c |  6 +++---
 arch/x86/lib/fsp2/fsp_dram.c |  2 +-
 arch/x86/lib/fsp2/fsp_init.c |  4 ++--
 boot/fdt_simplefb.c  |  2 +-
 boot/vbe_simple_fw.c |  4 ++--
 common/board_f.c |  2 +-
 common/bootstage.c   |  2 +-
 common/spl/spl.c |  6 +++---
 doc/develop/spl.rst  |  4 ++--
 drivers/i2c/designware_i2c_pci.c |  4 ++--
 drivers/misc/p2sb-uclass.c   |  2 +-
 drivers/pci/pci-uclass.c |  4 ++--
 drivers/pci/pci_rom.c|  4 ++--
 drivers/pinctrl/intel/pinctrl.c  |  6 +++---
 drivers/power/acpi_pmc/acpi-pmc-uclass.c |  2 +-
 drivers/ram/rockchip/sdram_rk3399.c  |  2 +-
 drivers/spi/ich.c|  4 ++--
 drivers/sysreset/sysreset-uclass.c   |  2 +-
 drivers/video/console_truetype.c |  6 +++---
 drivers/video/video-uclass.c |  6 +++---
 include/spl.h| 10 +-
 lib/fdtdec.c |  2 +-
 lib/lmb.c|  4 ++--
 lib/time.c   |  2 +-
 37 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/README b/README
index a88e14a0449..54ffbd0975b 100644
--- a/README
+++ b/README
@@ -1512,7 +1512,7 @@ Low Level (hardware related) configuration options:
Set when the currently running compilation is for an artifact
that will end up in one of the 'xPL' builds, i.e. SPL, TPL or
VPL. Code that needs phase-specific behaviour can check this,
-   or (where possible) use spl_phase() instead.
+   or (where possible) use xpl_phase() instead.
 
Note that CONFIG_XPL_BUILD *is* always defined when either
of CONFIG_TPL_BUILD / CONFIG_VPL_BUILD is defined. This can be
@@ -1522,13 +1522,13 @@ Low Level (hardware related) configuration options:
Set when the currently running compilation is for an artifact
that will end up in the TPL build (as opposed to SPL, VPL or
U-Boot proper). Code that needs phase-specific behaviour can
-   check this, or (where possible) use spl_phase() instead.
+   check this, or (where possible) use xpl_phase() instead.
 
 - CONFIG_VPL_BUILD
Set when the currently running compilation is for an artifact
that will end up in the VPL build (as opposed to the SPL, TPL
or U-Boot proper). Code that needs phase-specific behaviour can
-   check this, or (where possible) use spl_phase() instead.
+   check this, or (where possible) use xpl_phase() instead.
 
 - CONFIG_ARCH_MAP_SYSMEM
Generally U-Boot (and in particular the md command) uses
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 6c6f4fd8c3e..7497d90fb89 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -27,7 +27,7 @@ int sandbox_find_next_phase(char *fname, int maxlen, bool 
use_img)
const char *cur_prefix, *next_prefix;
int ret;
 
-   cur_prefix = spl_phase_prefix(spl_phase());
+   cur_prefix = spl_phase_prefix(xpl_phase());
next_prefix = spl_phase_prefix(spl_next_phase());
ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
if (ret)
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index ef587ef48b0..81752edc9f8 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -206,7 +206,7 @@ static int sandbox_cmdline_cb_test_fdt(struct sandbox_state 
*state,
char *relname;
int len;
 
-   if (spl_phase() <= PHASE_SPL)
+   if (xpl_phase() <= PHASE_SPL)
relname = "../arch/sandbox/dts/test.dtb";
else
relname = "arch/sandbox/dts/test.dtb";
diff --git a/arch/x86/cpu/apollolake/cpu_spl.c 
b/arch/x86/cpu/apollolake/cpu_spl.c
index 8798fa79d4c..8198667fa50 100644
--- a/arch/x86/cpu/apollolake/cpu_spl.c
+++ b/arch/x8

[PATCH v2 22/30] xpl: Rename spl_phase to xpl_phase_t

2024-09-28 Thread Simon Glass
This name fits better with the new naming scheme, so update it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/sandbox/cpu/spl.c   |  2 +-
 common/spl/spl.c |  2 +-
 doc/device-tree-bindings/bootph.yaml |  2 +-
 include/spl.h| 12 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 1c33a520c64..6c6f4fd8c3e 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -91,7 +91,7 @@ static int load_from_image(struct spl_image_info *spl_image,
   struct spl_boot_device *bootdev)
 {
struct sandbox_state *state = state_get_current();
-   enum u_boot_phase next_phase;
+   enum xpl_phase_t next_phase;
const char *fname;
ulong pos, size;
int full_size;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 674ab35ede0..81b3501ebaf 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -441,7 +441,7 @@ static inline int write_spl_handoff(void) { return 0; }
  */
 static enum bootstage_id get_bootstage_id(bool start)
 {
-   enum u_boot_phase phase = spl_phase();
+   enum xpl_phase_t phase = spl_phase();
 
if (IS_ENABLED(CONFIG_TPL_BUILD) && phase == PHASE_TPL)
return start ? BOOTSTAGE_ID_START_TPL : BOOTSTAGE_ID_END_TPL;
diff --git a/doc/device-tree-bindings/bootph.yaml 
b/doc/device-tree-bindings/bootph.yaml
index a3ccf06efa7..a364b3fe37f 100644
--- a/doc/device-tree-bindings/bootph.yaml
+++ b/doc/device-tree-bindings/bootph.yaml
@@ -83,6 +83,6 @@ properties:
   bootph-all:
 type: boolean
 description:
-  Include this node in all phases (for U-Boot see enum u_boot_phase).
+  Include this node in all phases (for U-Boot see enum xpl_phase_t).
 
 additionalProperties: true
diff --git a/include/spl.h b/include/spl.h
index 01057ee103e..3447a429e87 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -62,7 +62,7 @@ static inline bool xpl_is_first_phase(void)
return false;
 }
 
-enum u_boot_phase {
+enum xpl_phase_t {
PHASE_NONE, /* Invalid phase, signifying before U-Boot */
PHASE_TPL,  /* Running in TPL */
PHASE_VPL,  /* Running in VPL */
@@ -116,7 +116,7 @@ enum u_boot_phase {
  *
  * Return: U-Boot phase
  */
-static inline enum u_boot_phase spl_phase(void)
+static inline enum xpl_phase_t spl_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
return PHASE_TPL;
@@ -150,7 +150,7 @@ static inline bool spl_in_proper(void)
  * Return: the previous phase from this one, e.g. if called in SPL this returns
  * PHASE_TPL, if TPL is enabled
  */
-static inline enum u_boot_phase spl_prev_phase(void)
+static inline enum xpl_phase_t spl_prev_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
return PHASE_NONE;
@@ -172,7 +172,7 @@ static inline enum u_boot_phase spl_prev_phase(void)
  * Return: the next phase from this one, e.g. if called in TPL this returns
  * PHASE_SPL
  */
-static inline enum u_boot_phase spl_next_phase(void)
+static inline enum xpl_phase_t spl_next_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
return IS_ENABLED(CONFIG_VPL) ? PHASE_VPL : PHASE_SPL;
@@ -188,7 +188,7 @@ static inline enum u_boot_phase spl_next_phase(void)
  *
  * Return: phase name
  */
-static inline const char *spl_phase_name(enum u_boot_phase phase)
+static inline const char *spl_phase_name(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
@@ -211,7 +211,7 @@ static inline const char *spl_phase_name(enum u_boot_phase 
phase)
  * @phase: Phase to look up
  * Return: phase prefix ("spl", "tpl", etc.)
  */
-static inline const char *spl_phase_prefix(enum u_boot_phase phase)
+static inline const char *spl_phase_prefix(enum xpl_phase_t phase)
 {
switch (phase) {
case PHASE_TPL:
-- 
2.34.1



[PATCH v2 21/30] xpl: Rename u_boot_first_phase to xpl_is_first_phase()

2024-09-28 Thread Simon Glass
This is a better name for this function, so update it.

Tidy up the function comment to mention VPL. Use SPL_BUILD in the SPL
check, for clarity.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/mach-omap2/am33xx/board.c |  2 +-
 common/bloblist.c  |  4 ++--
 common/spl/spl.c   |  4 ++--
 include/spl.h  | 16 +---
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-omap2/am33xx/board.c 
b/arch/arm/mach-omap2/am33xx/board.c
index e720fb6b21f..4e9ad8935e3 100644
--- a/arch/arm/mach-omap2/am33xx/board.c
+++ b/arch/arm/mach-omap2/am33xx/board.c
@@ -526,7 +526,7 @@ EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, am33xx_dm_post_init);
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 void board_debug_uart_init(void)
 {
-   if (u_boot_first_phase()) {
+   if (xpl_is_first_phase()) {
hw_data_init();
set_uart_mux_conf();
setup_early_clocks();
diff --git a/common/bloblist.c b/common/bloblist.c
index 2008ab4d25c..fb86789df42 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -504,13 +504,13 @@ int bloblist_init(void)
 * If U-Boot is not in the first phase, an existing bloblist must be
 * at a fixed address.
 */
-   bool from_addr = fixed && !u_boot_first_phase();
+   bool from_addr = fixed && !xpl_is_first_phase();
/*
 * If U-Boot is in the first phase that an arch custom routine should
 * install the bloblist passed from previous loader to this fixed
 * address.
 */
-   bool from_boot_arg = fixed && u_boot_first_phase();
+   bool from_boot_arg = fixed && xpl_is_first_phase();
 
if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
from_addr = false;
diff --git a/common/spl/spl.c b/common/spl/spl.c
index dc73d3aff00..674ab35ede0 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -464,13 +464,13 @@ static int spl_common_init(bool setup_malloc)
gd->malloc_ptr = 0;
}
 #endif
-   ret = bootstage_init(u_boot_first_phase());
+   ret = bootstage_init(xpl_is_first_phase());
if (ret) {
debug("%s: Failed to set up bootstage: ret=%d\n", __func__,
  ret);
return ret;
}
-   if (!u_boot_first_phase()) {
+   if (!xpl_is_first_phase()) {
ret = bootstage_unstash_default();
if (ret)
log_debug("Failed to unstash bootstage: ret=%d\n", ret);
diff --git a/include/spl.h b/include/spl.h
index fec5677c7a9..01057ee103e 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -34,24 +34,26 @@ struct spl_boot_device;
 enum boot_device;
 
 /*
- * u_boot_first_phase() - check if this is the first U-Boot phase
+ * xpl_is_first_phase() - check if this is the first U-Boot phase
  *
- * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on the
- * build flags we can determine whether the current build is for the first
+ * U-Boot has up to four phases: TPL, VPL, SPL and U-Boot proper. Depending on
+ * the build flags we can determine whether the current build is for the first
  * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. If
  * there is SPL but no TPL, the the first phase is SPL. If there is TPL, then
- * it is the first phase.
+ * it is the first phase, etc.
  *
- * @returns true if this is the first phase of U-Boot
+ * Note that VPL can never be the first phase. If it exists, it is loaded from
+ * TPL
  *
+ * Return: true if this is the first phase of U-Boot
  */
-static inline bool u_boot_first_phase(void)
+static inline bool xpl_is_first_phase(void)
 {
if (IS_ENABLED(CONFIG_TPL)) {
if (IS_ENABLED(CONFIG_TPL_BUILD))
return true;
} else if (IS_ENABLED(CONFIG_SPL)) {
-   if (IS_ENABLED(CONFIG_XPL_BUILD))
+   if (IS_ENABLED(CONFIG_SPL_BUILD))
return true;
} else {
return true;
-- 
2.34.1



[PATCH v2 20/30] qconfig: Update tool for new Makefile variables

2024-09-28 Thread Simon Glass
Take account of the new XPL_ and PHASE_ instead of the old SPL_ and
SPL_TPL_

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/qconfig.py | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/qconfig.py b/tools/qconfig.py
index 7b4934b726d..058d72cf4bc 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -1175,7 +1175,7 @@ def prefix_config(cfg):
 return oper + cfg
 
 
-RE_MK_CONFIGS = re.compile(r'CONFIG_(\$\(SPL_(?:TPL_)?\))?([A-Za-z0-9_]*)')
+RE_MK_CONFIGS = re.compile(r'CONFIG_(\$\(XPL_\)|\$\(PHASE_\))?([A-Za-z0-9_]*)')
 RE_IFDEF = re.compile(r'(ifdef|ifndef)')
 RE_C_CONFIGS = re.compile(r'CONFIG_([A-Za-z0-9_]*)')
 RE_CONFIG_IS = re.compile(r'CONFIG_IS_ENABLED\(([A-Za-z0-9_]*)\)')
@@ -1186,7 +1186,7 @@ class ConfigUse:
 """Set up a new ConfigUse
 
 Args:
-cfg (str): CONFIG option, without any CONFIG_ or SPL_ prefix
+cfg (str): CONFIG option, without any CONFIG_ or xPL_ prefix
 is_spl (bool): True if this option relates to SPL
 fname (str): Makefile filename where the CONFIG option was found
 rest (str): Line of the Makefile
@@ -1319,7 +1319,7 @@ def do_scan_source(path, do_update):
 key (ConfigUse): object
 value (list of str): matching lines
 spl_mode (int): If MODE_SPL, look at source code which implies
-an SPL_ option, but for which there is none;
+an xPL_ option, but for which there is none;
 for MOD_PROPER, look at source code which implies a Proper
 option (i.e. use of CONFIG_IS_ENABLED() or $(XPL_) or
 $(PHASE_) but for which there none;
@@ -1341,7 +1341,7 @@ def do_scan_source(path, do_update):
 if spl_mode == MODE_SPL:
 check = use.is_spl
 
-# If it is an SPL symbol, try prepending all SPL_ prefixes to
+# If it is an SPL symbol, try prepending all xPL_ prefixes to
 # find at least one SPL symbol
 if use.is_spl:
 for prefix in SPL_PREFIXES:
@@ -1354,7 +1354,7 @@ def do_scan_source(path, do_update):
 continue
 elif spl_mode == MODE_PROPER:
 # Try to find the Proper version of this symbol, i.e. without
-# the SPL_ prefix
+# the xPL_ prefix
 proper_name = is_not_proper(name)
 if proper_name:
 name = proper_name
@@ -1450,7 +1450,7 @@ def do_scan_source(path, do_update):
 show_uses(not_found)
 spl_not_found |= {is_not_proper(key) or key for key in not_found.keys()}
 
-print('\nCONFIG options used as Proper in Makefiles but without a non-SPL_ 
variant:')
+print('\nCONFIG options used as Proper in Makefiles but without a non-xPL_ 
variant:')
 not_found = check_not_found(all_uses, MODE_PROPER)
 show_uses(not_found)
 proper_not_found |= {not_found.keys()}
@@ -1468,16 +1468,16 @@ def do_scan_source(path, do_update):
 show_uses(not_found)
 spl_not_found |= {is_not_proper(key) or key for key in not_found.keys()}
 
-print('\nCONFIG options used as Proper in source but without a non-SPL_ 
variant:')
+print('\nCONFIG options used as Proper in source but without a non-xPL_ 
variant:')
 not_found = check_not_found(all_uses, MODE_PROPER)
 show_uses(not_found)
 proper_not_found |= {not_found.keys()}
 
-print('\nCONFIG options used as SPL but without an SPL_ variant:')
+print('\nCONFIG options used as SPL but without an xPL_ variant:')
 for item in sorted(spl_not_found):
 print(f'   {item}')
 
-print('\nCONFIG options used as Proper but without a non-SPL_ variant:')
+print('\nCONFIG options used as Proper but without a non-xPL_ variant:')
 for item in sorted(proper_not_found):
 print(f'   {item}')
 
-- 
2.34.1



[PATCH v2 19/30] spl: Rename SPL_TPL_NAME and SPL_TPL_PROMPT

2024-09-28 Thread Simon Glass
Rename these to use the word PHASE instead.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/spl/spl.c| 36 ++--
 common/spl/spl_fit.c|  2 +-
 common/spl/spl_legacy.c |  2 +-
 include/spl.h   | 14 +++---
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index c13b2b8f714..dc73d3aff00 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -97,9 +97,9 @@ __weak int dram_init_banksize(void)
 #if CONFIG_IS_ENABLED(OS_BOOT)
 __weak int spl_start_uboot(void)
 {
-   puts(SPL_TPL_PROMPT
+   puts(PHASE_PROMPT
 "Please implement spl_start_uboot() for your board\n");
-   puts(SPL_TPL_PROMPT "Direct Linux boot not active!\n");
+   puts(PHASE_PROMPT "Direct Linux boot not active!\n");
return 1;
 }
 
@@ -140,13 +140,13 @@ void spl_fixup_fdt(void *fdt_blob)
/* fixup the memory dt node */
err = fdt_shrink_to_minimum(fdt_blob, 0);
if (err == 0) {
-   printf(SPL_TPL_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
+   printf(PHASE_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
return;
}
 
err = arch_fixup_fdt(fdt_blob);
if (err) {
-   printf(SPL_TPL_PROMPT "arch_fixup_fdt err - %d\n", err);
+   printf(PHASE_PROMPT "arch_fixup_fdt err - %d\n", err);
return;
}
 #endif
@@ -330,7 +330,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->load_addr = start;
spl_image->entry_point = start;
spl_image->size = size;
-   debug(SPL_TPL_PROMPT
+   debug(PHASE_PROMPT
  "payload Image, load addr: 0x%lx size: %d\n",
  spl_image->load_addr, spl_image->size);
return 0;
@@ -344,7 +344,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
spl_image->size = end - start;
-   debug(SPL_TPL_PROMPT
+   debug(PHASE_PROMPT
  "payload zImage, load addr: 0x%lx size: %d\n",
  spl_image->load_addr, spl_image->size);
return 0;
@@ -423,7 +423,7 @@ static int write_spl_handoff(void)
ret = handoff_arch_save(ho);
if (ret)
return ret;
-   debug(SPL_TPL_PROMPT "Wrote SPL handoff\n");
+   debug(PHASE_PROMPT "Wrote SPL handoff\n");
 
return 0;
 }
@@ -624,11 +624,11 @@ static int boot_from_devices(struct spl_image_info 
*spl_image,
printf("Trying to boot from %s\n",
   spl_loader_name(loader));
else if (CONFIG_IS_ENABLED(SHOW_ERRORS)) {
-   printf(SPL_TPL_PROMPT
+   printf(PHASE_PROMPT
   "Unsupported Boot Device %d\n",
   bootdev);
} else {
-   puts(SPL_TPL_PROMPT
+   puts(PHASE_PROMPT
 "Unsupported Boot Device!\n");
}
}
@@ -674,7 +674,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
struct spl_image_info spl_image;
int ret, os;
 
-   debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
+   debug(">>" PHASE_PROMPT "board_init_r()\n");
 
spl_set_bd();
 
@@ -694,7 +694,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
if (ret) {
debug("%s: Failed to set up bloblist: ret=%d\n",
  __func__, ret);
-   puts(SPL_TPL_PROMPT "Cannot set up bloblist\n");
+   puts(PHASE_PROMPT "Cannot set up bloblist\n");
hang();
}
}
@@ -703,7 +703,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
ret = setup_spl_handoff();
if (ret) {
-   puts(SPL_TPL_PROMPT "Cannot set up SPL handoff\n");
+   puts(PHASE_PROMPT "Cannot set up SPL handoff\n");
hang();
}
}
@@ -724,7 +724,7 @@ void board_init_r(gd_t *d

[PATCH v2 16/30] kconfig: binman: Check for SPL instead of XPL

2024-09-28 Thread Simon Glass
Now that SPL means SPL (only) and is not defined for other phases,
update kconfig rules.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/linux/kconfig.h| 10 +-
 tools/binman/test/generated/autoconf.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index a59f2a61e6a..ec9584b2426 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -40,7 +40,7 @@
 #define _CONFIG_PREFIX TPL_
 #elif defined(CONFIG_VPL_BUILD)
 #define _CONFIG_PREFIX VPL_
-#elif defined(CONFIG_XPL_BUILD)
+#elif defined(CONFIG_SPL_BUILD)
 #define _CONFIG_PREFIX SPL_
 #else
 #define _CONFIG_PREFIX
@@ -54,7 +54,7 @@
  * CONFIG_VAL(FOO) evaluates to the value of
  *  CONFIG_TOOLS_FOO if USE_HOSTCC is defined,
  *  CONFIG_FOO if CONFIG_XPL_BUILD is undefined,
- *  CONFIG_SPL_FOO if CONFIG_XPL_BUILD is defined.
+ *  CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined.
  *  CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined.
  *  CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined.
  */
@@ -107,21 +107,21 @@ long invalid_use_of_IF_ENABLED_INT(void);
  * CONFIG_IS_ENABLED(FOO) expands to
  *  1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
  *  1 if CONFIG_XPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  1 if CONFIG_XPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  0 otherwise.
  *
  * CONFIG_IS_ENABLED(FOO, (abc)) expands to
  *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
  *  abc if CONFIG_XPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_XPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  nothing otherwise.
  *
  * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
  *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
  *  abc if CONFIG_XPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_XPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
  *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
  *  def otherwise.
  *
diff --git a/tools/binman/test/generated/autoconf.h 
b/tools/binman/test/generated/autoconf.h
index 75af48f9116..6a23039f469 100644
--- a/tools/binman/test/generated/autoconf.h
+++ b/tools/binman/test/generated/autoconf.h
@@ -1,3 +1,3 @@
 #define CONFIG_BINMAN 1
-#define CONFIG_XPL_BUILD 1
+#define CONFIG_SPL_BUILD 1
 #define CONFIG_SPL_BINMAN_SYMBOLS 1
-- 
2.34.1



[PATCH v2 15/30] stdio: Make use of the SERIAL define

2024-09-28 Thread Simon Glass
This is always enabled for U-Boot proper, so simplify the condition
in the common Makefile.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/stdio.h | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h
index 56609b846ff..d42fdd2728c 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -9,10 +9,7 @@ int getchar(void);
 int tstc(void);
 
 /* stdout */
-#if !defined(CONFIG_XPL_BUILD) || \
-   (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL)) || \
-   (defined(CONFIG_XPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \
-   defined(CONFIG_SPL_SERIAL))
+#if !defined(CONFIG_XPL_BUILD) || CONFIG_IS_ENABLED(SERIAL)
 void putc(const char c);
 void puts(const char *s);
 #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
-- 
2.34.1



[PATCH v2 14/30] serial: Make use of the SERIAL define

2024-09-28 Thread Simon Glass
This is always enabled for U-Boot proper, so simplify the condition
in the common Makefile.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 common/Makefile | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 9fdad4bc38d..ae8984659c0 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -65,15 +65,7 @@ obj-$(CONFIG_DDR_SPD) += ddr_spd.o
 obj-$(CONFIG_SPD_EEPROM) += ddr_spd.o
 obj-$(CONFIG_HWCONFIG) += hwconfig.o
 obj-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o
-ifdef CONFIG_XPL_BUILD
-ifdef CONFIG_TPL_BUILD
-obj-$(CONFIG_TPL_SERIAL) += console.o
-else
-obj-$(CONFIG_SPL_SERIAL) += console.o
-endif
-else
-obj-y += console.o
-endif # CONFIG_XPL_BUILD
+obj-$(CONFIG_$(SPL_TPL_)SERIAL) += console.o
 
 obj-$(CONFIG_CROS_EC) += cros_ec.o
 obj-y += dlmalloc.o
-- 
2.34.1



[PATCH v2 13/30] xpl: Define CONFIG_SPL_BUILD only for the SPL build

2024-09-28 Thread Simon Glass
Make this define mean SPL only, not TPL, VPL, etc.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.autoconf | 4 ++--
 scripts/Makefile.xpl  | 9 ++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index d7544022a31..c1eab2f3a1d 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -87,11 +87,11 @@ spl/u-boot.cfg: include/config.h FORCE
 
 tpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_TPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_TPL_BUILD)
 
 vpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_VPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_VPL_BUILD)
 
 include/autoconf.mk: u-boot.cfg
$(call cmd,autoconf)
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index 63d4ec334bc..b43ff998679 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -21,9 +21,10 @@ include $(srctree)/scripts/Kbuild.include
 
 -include include/config/auto.conf
 
-# This file contains 0, 2 or 3 lines
+# This file contains 0, or 2 lines
 # It is empty for U-Boot proper (where $(obj) is empty)
-# For any xPL build it contains CONFIG_SPL_BUILD=y and CONFIG_XPL_BUILD=y
+# For any xPL build it contains CONFIG_XPL_BUILD=y
+#- for SPL builds it also contains CONFIG_SPL_BUILD=y
 #- for TPL builds it also contains CONFIG_TPL_BUILD=y
 #- for VPL builds it also contains CONFIG_VPL_BUILD=y
 -include $(obj)/include/autoconf.mk
@@ -31,7 +32,9 @@ include $(srctree)/scripts/Kbuild.include
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 
 KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
-KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
+ifeq ($(CONFIG_SPL_BUILD),y)
+KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
+endif
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
 else
-- 
2.34.1



[PATCH v2 12/30] boot: Drop unnecessary ifdef for LOAD_FIT

2024-09-28 Thread Simon Glass
Use the normal SPL_TPL_ approach for this option.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 boot/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/boot/Makefile b/boot/Makefile
index 299a22ed689..5bf07e83388 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -58,9 +58,7 @@ obj-$(CONFIG_$(SPL_TPL_)FIT_CIPHER) += image-cipher.o
 
 obj-$(CONFIG_CMD_ADTIMG) += image-android-dt.o
 
-ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
-endif
+obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += common_fit.o
 
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += expo.o scene.o expo_build.o
 obj-$(CONFIG_$(SPL_TPL_)EXPO) += scene_menu.o scene_textline.o
-- 
2.34.1



[PATCH v2 11/30] qconfig: Add XPL_BUILD to ignored symbols

2024-09-28 Thread Simon Glass
This now appears in the code base, so add it to the list of ignored
symbols in qconfig

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/qconfig.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/qconfig.py b/tools/qconfig.py
index 8c2fc9efc5f..71e911eeb3b 100755
--- a/tools/qconfig.py
+++ b/tools/qconfig.py
@@ -77,7 +77,7 @@ IGNORE_SYMS = ['DEBUG_SECTION_MISMATCH', 
'FTRACE_MCOUNT_RECORD', 'GCOV_KERNEL',
'IS_ENABLED_', 'IS_ENABLED_1', 'IS_ENABLED_2', 'IS_ENABLED_3',
'SPL_', 'TPL_', 'SPL_FOO', 'TPL_FOO', 'TOOLS_FOO',
'ACME', 'SPL_ACME', 'TPL_ACME', 'TRACE_BRANCH_PROFILING',
-   'VAL', '_UNDEFINED', 'SPL_BUILD', ]
+   'VAL', '_UNDEFINED', 'SPL_BUILD', 'XPL_BUILD', ]
 
 SPL_PREFIXES = ['SPL_', 'TPL_', 'VPL_', 'TOOLS_']
 
-- 
2.34.1



[PATCH v2 10/30] log: global: Rename warn_non_spl() and update the condition

2024-09-28 Thread Simon Glass
This should now refer to xPL rather than SPL, so update it throughout
the tree.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/lib/cache.c |  2 +-
 doc/develop/logging.rst  |  2 +-
 drivers/spi/spi-uclass.c |  4 ++--
 include/log.h| 10 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index b2ae74a59f1..cac2159fe1a 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -62,7 +62,7 @@ int check_cache_range(unsigned long start, unsigned long stop)
ok = 0;
 
if (!ok) {
-   warn_non_spl("CACHE: Misaligned operation at range [%08lx, 
%08lx]\n",
+   warn_non_xpl("CACHE: Misaligned operation at range [%08lx, 
%08lx]\n",
 start, stop);
}
 
diff --git a/doc/develop/logging.rst b/doc/develop/logging.rst
index 704a6bf1d84..d7a40c94bf0 100644
--- a/doc/develop/logging.rst
+++ b/doc/develop/logging.rst
@@ -292,7 +292,7 @@ Convert debug() statements in the code to log() statements
 
 Convert error() statements in the code to log() statements
 
-Figure out what to do with BUG(), BUG_ON() and warn_non_spl()
+Figure out what to do with BUG(), BUG_ON() and warn_non_xpl()
 
 Add a way to browse log records
 
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 6e281725239..f6efebd2e90 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -538,7 +538,7 @@ int spi_slave_of_to_plat(struct udevice *dev, struct 
dm_spi_slave_plat *plat)
mode |= SPI_TX_OCTAL;
break;
default:
-   warn_non_spl("spi-tx-bus-width %d not supported\n", value);
+   warn_non_xpl("spi-tx-bus-width %d not supported\n", value);
break;
}
 
@@ -556,7 +556,7 @@ int spi_slave_of_to_plat(struct udevice *dev, struct 
dm_spi_slave_plat *plat)
mode |= SPI_RX_OCTAL;
break;
default:
-   warn_non_spl("spi-rx-bus-width %d not supported\n", value);
+   warn_non_xpl("spi-rx-bus-width %d not supported\n", value);
break;
}
 
diff --git a/include/log.h b/include/log.h
index 371f99d82e7..bf81a27011f 100644
--- a/include/log.h
+++ b/include/log.h
@@ -247,9 +247,9 @@ int _log_buffer(enum log_category_t cat, enum log_level_t 
level,
 #endif
 
 #ifdef CONFIG_XPL_BUILD
-#define _SPL_BUILD 1
+#define _XPL_BUILD 1
 #else
-#define _SPL_BUILD 0
+#define _XPL_BUILD 0
 #endif
 
 #if CONFIG_IS_ENABLED(LOG)
@@ -281,9 +281,9 @@ int _log_buffer(enum log_category_t cat, enum log_level_t 
level,
 #define debug(fmt, args...)\
debug_cond(_DEBUG, fmt, ##args)
 
-/* Show a message if not in SPL */
-#define warn_non_spl(fmt, args...) \
-   debug_cond(!_SPL_BUILD, fmt, ##args)
+/* Show a message if not in xPL */
+#define warn_non_xpl(fmt, args...) \
+   debug_cond(!_XPL_BUILD, fmt, ##args)
 
 /*
  * An assertion is run-time check done in debug mode only. If DEBUG is not
-- 
2.34.1



[PATCH v2 09/30] tegra: Use SPL instead of SPL_BUILD

2024-09-28 Thread Simon Glass
SPL_BUILD is not a Kconfig symbol so perhaps the intent here is to
use SPL instead. But that changes the output size.

So drop the dependency on !SPL_BUILD since it does nothing.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/arm/mach-tegra/tegra124/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra124/Kconfig 
b/arch/arm/mach-tegra/tegra124/Kconfig
index fb016aa46c9..84c8f86bad0 100644
--- a/arch/arm/mach-tegra/tegra124/Kconfig
+++ b/arch/arm/mach-tegra/tegra124/Kconfig
@@ -21,8 +21,8 @@ config TARGET_CEI_TK1_SOM
bool "Colorado Engineering Inc Tegra124 TK1-som board"
select ARCH_SUPPORT_PSCI
select BOARD_LATE_INIT
-   select CPU_V7_HAS_NONSEC if !SPL_BUILD
-   select CPU_V7_HAS_VIRT if !SPL_BUILD
+   select CPU_V7_HAS_NONSEC
+   select CPU_V7_HAS_VIRT
help
  The Colorado Engineering Tegra TK1-SOM is a very compact
  (51mmx58mm) board that is functionally almost the same as
-- 
2.34.1



[PATCH v2 08/30] x86: Update a comment to mention XPL

2024-09-28 Thread Simon Glass
This uses XPL now, so update the comment.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/cpu/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index fbd23af6ce9..ea11b09eacc 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -247,7 +247,7 @@ static int last_stage_init(void)
 }
 EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
 
-#endif  /* !SYS_COREBOOT && !EFI_STUB && !SPL_BUILD */
+#endif  /* !SYS_COREBOOT && !EFI_STUB && !XPL_BUILD */
 
 static int x86_init_cpus(void)
 {
-- 
2.34.1



[PATCH v2 07/30] net: freescale: Drop use of SPL_BUILD dependency

2024-09-28 Thread Simon Glass
SPL_BUILD is not a Kconfig symbol. Perhaps the intent here is to use
SPL instead. However, this causes build errors, e.g. with T1024RDB_NAND

So drop the dependency on !SPL_BUILD since it does nothing.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/net/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e7d0ddfe25a..403d7e1c679 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -891,7 +891,7 @@ config FEC2_PHY_NORXERR
 
 config SYS_DPAA_QBMAN
bool "Device tree fixup for QBMan on freescale SOCs"
-   depends on (ARM || PPC) && !SPL_BUILD
+   depends on ARM || PPC
default y if ARCH_B4860 || \
 ARCH_B4420 || \
 ARCH_P1023 || \
-- 
2.34.1



[PATCH v2 06/30] doc: Update SPL docs for the xPL changes

2024-09-28 Thread Simon Glass
Update the various references to SPL in this document. Make sure to
refer to 'phases' instead of 'stages', which is not a U-Boot term.

Fix a few U-boot typos and try to improve grammar a little while we are
here.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 doc/develop/spl.rst | 81 -
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/doc/develop/spl.rst b/doc/develop/spl.rst
index 4bb48e6b7b3..fba4a439d3a 100644
--- a/doc/develop/spl.rst
+++ b/doc/develop/spl.rst
@@ -1,11 +1,12 @@
-Generic SPL framework
+Generic xPL framework
 =
 
 Overview
 
 
-To unify all existing implementations for a secondary program loader (SPL)
-and to allow simply adding of new implementations this generic SPL framework
+To unify all existing implementations for secondary/tertiary program loaders
+(generically called xPL)
+and to allow simply adding of new implementations this generic xPL framework
 has been created. With this framework almost all source files for a board
 can be reused. No code duplication or symlinking is necessary anymore.
 
@@ -13,36 +14,39 @@ can be reused. No code duplication or symlinking is 
necessary anymore.
 How it works
 
 
-The object files for SPL are built separately and placed in the "spl" 
directory.
-The final binaries which are generated are u-boot-spl, u-boot-spl.bin and
-u-boot-spl.map.
+The object files for xPL are built separately and placed in a subdirectory
+("spl", "tpl" or "vpl").
+The final binaries which are generated for SPL are u-boot-spl, u-boot-spl.bin
+and u-boot-spl.map
 
-A config option named CONFIG_SPL_BUILD is enabled by Kconfig for SPL.
-Source files can therefore be compiled for SPL with different settings.
+A config option named CONFIG_XPL_BUILD is enabled by Kconfig for xPL builds.
+Source files can therefore be compiled for xPL with different settings.
 
 For example::
 
-   ifeq ($(CONFIG_SPL_BUILD),y)
+   ifeq ($(CONFIG_XPL_BUILD),y)
obj-y += board_spl.o
else
obj-y += board.o
endif
 
-   obj-$(CONFIG_SPL_BUILD) += foo.o
+   obj-$(CONFIG_XPL_BUILD) += foo.o
 
-   #ifdef CONFIG_SPL_BUILD
+   if (IS_ENABLED(CONFIG_XPL_BUILD))
foo();
-   #endif
 
+   if (spl_phase() == PHASE_TPL)
+   bar();
 
-The building of SPL images can be enabled by CONFIG_SPL option in Kconfig.
+The building of xPL images can be enabled by CONFIG_SPL (etc.) options in
+Kconfig.
 
-Because SPL images normally have a different text base, one has to be
-configured by defining CONFIG_SPL_TEXT_BASE. The linker script has to be
-defined with CONFIG_SPL_LDSCRIPT.
+Because xPL images normally have a different text base, one has to be
+configured by defining CONFIG_xPL_TEXT_BASE. The linker script has to be
+defined with CONFIG_xPL_LDSCRIPT.
 
-To support generic U-Boot libraries and drivers in the SPL binary one can
-optionally define CONFIG_SPL_XXX_SUPPORT. Currently following options
+To support generic U-Boot libraries and drivers in the xPL binary one can
+optionally define CONFIG_xPL_XXX_SUPPORT. Currently following options
 are supported:
 
 CONFIG_SPL_LIBCOMMON_SUPPORT (common/libcommon.o)
@@ -75,7 +79,7 @@ CONFIG_SPL_DM_GPIO (drivers/gpio/gpio-uclass.o)
 CONFIG_SPL_BMP (drivers/video/bmp.o)
 CONFIG_SPL_BLOBLIST (common/bloblist.o)
 
-Adding SPL-specific code
+Adding xPL-specific code
 
 
 To check whether a feature is enabled, use CONFIG_IS_ENABLED()::
@@ -90,7 +94,7 @@ U-Boot Boot Phases
 --
 
 U-Boot goes through the following boot phases where TPL, VPL, SPL are optional.
-While many boards use SPL, less use TPL.
+While many boards use SPL, fewer use TPL.
 
 TPL
Very early init, as tiny as possible. This loads SPL (or VPL if enabled).
@@ -177,29 +181,30 @@ files instead introduces another set of headaches.  These 
warnings are
 not usually important to understanding the flow, however.
 
 
-Reserving memory in SPL
+Reserving memory in xPL
 ---
 
-If memory needs to be reserved in RAM during SPL stage with the requirement 
that
-the SPL reserved memory remains preserved across further boot stages too
+If memory needs to be reserved in RAM during an xPL phase with the requirement
+that the xPL reserved memory remains preserved across further boot phases too
 then it needs to be reserved mandatorily starting from end of RAM. This is to
-ensure that further stages can simply skip this region before carrying out
+ensure that further phases can simply skip this region before carrying out
 further reservations or updating the relocation address.
 
-Also out of these regions which are to be preserved across further stages of
+Also out of these regions which are to be preserved across further phases of
 boot, video framebuffer memory region must be reserved first starting from
-end of RAM for which helper function spl_reserve_video_fro

[PATCH v2 04/30] scripts: Define CONFIG_XPL_BUILD for all xPL builds

2024-09-28 Thread Simon Glass
The new name 'xPL' is intended to indicate a build of any phase which is
not U-Boot proper. Define it for all such phases.

Note that we also define CONFIG_SPL_BUILD for all xPL builds. This
preserves existing behaviour, but future patches will adjust that.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.autoconf | 6 +++---
 scripts/Makefile.xpl  | 9 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index b42f9b525fe..d7544022a31 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -83,15 +83,15 @@ u-boot.cfg: include/config.h FORCE
 
 spl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD)
 
 tpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_TPL_BUILD)
 
 vpl/u-boot.cfg: include/config.h FORCE
$(Q)mkdir -p $(dir $@)
-   $(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_VPL_BUILD)
+   $(call cmd,u_boot_cfg,-DCONFIG_XPL_BUILD -DCONFIG_SPL_BUILD 
-DCONFIG_VPL_BUILD)
 
 include/autoconf.mk: u-boot.cfg
$(call cmd,autoconf)
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index 3091311a3d2..ad21d451a30 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -21,15 +21,16 @@ include $(srctree)/scripts/Kbuild.include
 
 -include include/config/auto.conf
 
-# This file contains 0, 1 or 2 lines
+# This file contains 0, 2 or 3 lines
 # It is empty for U-Boot proper (where $(obj) is empty)
-# For any xPL build it contains CONFIG_SPL_BUILD=y
-# For TPL builds it has CONFIG_SPL_BUILD=y and CONFIG_TPL_BUILD=y
-# For VPL builds it has CONFIG_SPL_BUILD=y and CONFIG_VPL_BUILD=y
+# For any xPL build it contains CONFIG_SPL_BUILD=y and CONFIG_XPL_BUILD=y
+#- for TPL builds it also contains CONFIG_TPL_BUILD=y
+#- for VPL builds it also contains CONFIG_VPL_BUILD=y
 -include $(obj)/include/autoconf.mk
 
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 
+KBUILD_CPPFLAGS += -DCONFIG_XPL_BUILD
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
-- 
2.34.1



[PATCH v2 03/30] scripts: Add some comments about autoconf.mk

2024-09-28 Thread Simon Glass
Now that the conversion of all CONFIG options to Kconfig is complete,
these files only contain the xPL_BUILD defines. Add a comment to make
this clear.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/Makefile.xpl | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index 1868f1beef6..3091311a3d2 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -20,6 +20,12 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 include $(srctree)/scripts/Kbuild.include
 
 -include include/config/auto.conf
+
+# This file contains 0, 1 or 2 lines
+# It is empty for U-Boot proper (where $(obj) is empty)
+# For any xPL build it contains CONFIG_SPL_BUILD=y
+# For TPL builds it has CONFIG_SPL_BUILD=y and CONFIG_TPL_BUILD=y
+# For VPL builds it has CONFIG_SPL_BUILD=y and CONFIG_VPL_BUILD=y
 -include $(obj)/include/autoconf.mk
 
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
-- 
2.34.1



[PATCH v2 02/30] scripts: Rename Makefile.spl to Makefile.xpl

2024-09-28 Thread Simon Glass
Rename this file to indicate that it refers to any non-U-Boot-proper
phase, not just SPL, which is the phase immediately before U-Boot
proper.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile   | 6 +++---
 scripts/{Makefile.spl => Makefile.xpl} | 0
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename scripts/{Makefile.spl => Makefile.xpl} (100%)

diff --git a/Makefile b/Makefile
index 300cee2e7f6..4378993ccfd 100644
--- a/Makefile
+++ b/Makefile
@@ -2094,7 +2094,7 @@ spl/u-boot-spl-dtb.hex: spl/u-boot-spl
@:
 
 spl/u-boot-spl: tools prepare $(if $(CONFIG_SPL_OF_CONTROL),dts/dt.dtb)
-   $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
+   $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.xpl all
 
 spl/sunxi-spl.bin: spl/u-boot-spl
@:
@@ -2113,14 +2113,14 @@ tpl/u-boot-tpl.bin: tpl/u-boot-tpl
$(TPL_SIZE_CHECK)
 
 tpl/u-boot-tpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
-   $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
+   $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.xpl all
 
 vpl/u-boot-vpl.bin: vpl/u-boot-vpl
@:
$(VPL_SIZE_CHECK)
 
 vpl/u-boot-vpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
-   $(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.spl all
+   $(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.xpl all
 
 TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
 
diff --git a/scripts/Makefile.spl b/scripts/Makefile.xpl
similarity index 100%
rename from scripts/Makefile.spl
rename to scripts/Makefile.xpl
-- 
2.34.1



[PATCH v2 01/30] Makefile: Add a u-boot.cfg file for VPL

2024-09-28 Thread Simon Glass
Create this file for VPL as well, for consistency.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 525576f987d..300cee2e7f6 100644
--- a/Makefile
+++ b/Makefile
@@ -624,7 +624,7 @@ include/config/%.conf: $(KCONFIG_CONFIG) 
include/config/auto.conf.cmd
@# Otherwise, 'make silentoldconfig' would be invoked twice.
$(Q)touch include/config/auto.conf
 
-u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg:
+u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg vpl/u-boot.cfg:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(@)
 
 -include include/autoconf.mk
-- 
2.34.1



Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

2024-09-27 Thread Simon Glass
Hi Ilias,

On Fri, 27 Sept 2024 at 07:15, Ilias Apalodimas
 wrote:
>
> [...]
>
> > > > > > > > in one place with 'bloblist list'
> > > > > > > >
> > > > > > >
> > > > > > > So what's the consent and the next step here?
> > > > > > > Is the current code OK as is, as it works with both BLOBLIST and 
> > > > > > > without?
> > > > > > > Should I drop support for one or the other?
> > > > > >
> > > > > > Just BLOBLIST. The EFI allocation is done using efi_acpi.c which you
> > > > > > can check to make sure it is working.
> > > > > >
> > > > > > Using efi_allocate_pages() before the app starts is not good.
> > > > >
> > > > > Simon, please stop trying to enforce decisions on subsystems you don't
> > > > > maintain. I am pretty sure both Heinrich and I said no to this.
> > > >
> > > > I am the ACPI maintainer, and x86 maintainer long before ACPI came in
> > > > for ARM (which I originally hacked together, as you know). I also
> > > > wrote bloblist, including the header file which says:
> > >
> > > That's not the EFI subsystem though. And last time I checked where the
> > > ACPI tables are allocated makes no difference as long as they are
> > > installed on a config table.
> >
> > With my maintainer hat on, ACPI tables go in a bloblist.
> >
> > The difference it makes is that the tables end up in the U-Boot memory-area.
> >
> > >
> > > >
> > > >  * 6. Bloblist is designed to be passed to Linux as reserved memory.
> > > > While linux
> > > >  * doesn't understand the bloblist header, it can be passed the 
> > > > indivdual blobs.
> > >
> > > And as I already said, *when* bloblist is consumed by any OS and you
> > > have a valid use case other than "I can do bloblist list and I like
> > > it", you can change 3 lines of code and allocate the ACPI table there.
> >
> > Bloblist is not intended to be consumed by an OS. It is a firmware
> > construct, a way for U-Boot to arrange things in such a way that they
> > can be located and updated at runtime. What objection do you actually
> > have to using bloblist for tables?
>
> That bloblist, is currently used for the firmware handoff protocol.
> And that protocol *ends* when U-Boot launches, so I don't see why
> adding anything there that's not defined makes any sense.
>
> >
> > >
> > > >  * For example, ACPI tables can reside in a blob and the address of 
> > > > those is
> > > >  * passed to Linux, without Linux ever being away of the existence of a
> > > >  * bloblist. Having all the blobs contiguous in memory simplifies the
> > > >  * reserved-memory space.
> > >
> > > No, it doesn't because all of the other tables are currently allocated
> > > by the EFI subsystem. So it actually fragments it. Apart from that You
> > > dont really know what the OS is going to do with that memory. It
> > > depends on the EFI memory type and OS decisions.
> >
> > The ACPI table is not allocated by the EFI subsystem. Neither is
> > SMBIOS, which currently uses malloc() but should move into a bloblist
> > too.
>
> SMBIOS is different. it's not tightly linked to EFI. But we mark that
> region properly in memory as well.
>
> > The system table is in U-Boot's data region. Much of EFI's data
> > and all the driver model stuff is in the malloc() region.
>
> You keep saying "much of EFI data" and I keep repeating that whatever
> is *not* needed by the EFI spec, internal allocations, lists, etc we
> use malloc. Whatever is described in the EFI spec, we use
> efi_allocate_XX()
>
> >
> > >
> > > >
> > > > This decision has serious impacts on memory management in U-Boot. It
> > > > also bears on the complexity of memory, how bootstd works, board
> > > > scripts and the like. We should discuss this and figure out a path
> > > > forward.
> > >
> > > It has close to zero impact because *all* of the EFI memory lives in
> > > top memory. So apart from the EFI_BOUNCE_BUFFER perhaps,  I don't see
> > > why the impact is """serious""".
> > > EFI allocates memory which does not affect U-Boot of file loading
> > > apart from the max size allowed. Now with LMB it is marked as
> > > reserved. So why is this any different from any other LMB reservation?
> > > It's memory used by someone that you aren't allowed to use, just like
> > > we reserve U-Boot memory. If there's a bug in reservations, by all
> > > means, let's fix it.
> >
> > I think you are saying that because only a small amount of memory is
> > affected it doesn't matter much.
>
> No, I am saying this because you need to allocate the memory
> regardless if you want to support EFI. So as long as it's not in the
> middle of the memory space, not allowing you to load stuff, it makes
> little difference.
>
> > Well, I suppose so. But if it doesn't
> > matter, why is Sughosh spending all this time solving the problem?
>
> First of all, we got multiple asks from Tom saying LMB wasn't doing
> all that it should for a long time and needed fixing regardless.
> LMB prior to the patches was calling efi_get_memory_map_alloc() on the
> reserve function and b

Re: [PATCH] binman: add fast authentication method for i.MX8M signing

2024-09-27 Thread Simon Glass
Hi,

On Fri, 27 Sept 2024 at 06:42, Brian Ruley  wrote:
>
> Using the PKI tree with SRKs as intermediate CA isn't necessary or even
> desirable in some situations (boot time, for example). Add the possbility
> to use the "fast authentication" method where the image and CSF are both
> signed using the SRK [1, p.63].
>
> [1] 
> https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
>
> Signed-off-by: Brian Ruley 
> Cc: Marek Vasut 
>
>  tools/binman/etype/nxp_imx8mcst.py | 23 +++
>  1 file changed, 19 insertions(+), 4 deletions(-)
>

Please can you coordinate with Marek as we need to sort out the test
coverage for this etype, before adding more functionality. I did a
starting point, now in -next, which should help.

> diff --git a/tools/binman/etype/nxp_imx8mcst.py 
> b/tools/binman/etype/nxp_imx8mcst.py
> index 8221517b0c..d39b6a79de 100644
> --- a/tools/binman/etype/nxp_imx8mcst.py
> +++ b/tools/binman/etype/nxp_imx8mcst.py
> @@ -36,6 +36,9 @@ csf_config_template = """
>File = "SRK_1_2_3_4_table.bin"
>Source index = 0
>
> +[Install NOCAK]
> +  File = "SRK1_sha256_4096_65537_v3_usr_crt.pem"
> +
>  [Install CSFK]
>File = "CSF1_1_sha256_4096_65537_v3_usr_crt.pem"
>
> @@ -70,8 +73,13 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  super().ReadNode()
>  self.loader_address = fdt_util.GetInt(self._node, 
> 'nxp,loader-address')
>  self.srk_table = os.getenv('SRK_TABLE', 
> fdt_util.GetString(self._node, 'nxp,srk-table', 'SRK_1_2_3_4_table.bin'))
> -self.csf_crt = os.getenv('CSF_KEY', fdt_util.GetString(self._node, 
> 'nxp,csf-crt', 'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'))
> -self.img_crt = os.getenv('IMG_KEY', fdt_util.GetString(self._node, 
> 'nxp,img-crt', 'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'))
> +self.fast_auth = fdt_util.GetBool(self._node, 'nxp,fast-auth')
> +if not self.fast_auth:
> +self.csf_crt = os.getenv('CSF_KEY', 
> fdt_util.GetString(self._node, 'nxp,csf-crt', 
> 'CSF1_1_sha256_4096_65537_v3_usr_crt.pem'))
> +self.img_crt = os.getenv('IMG_KEY', 
> fdt_util.GetString(self._node, 'nxp,img-crt', 
> 'IMG1_1_sha256_4096_65537_v3_usr_crt.pem'))
> +else:
> +self.srk_crt = os.getenv('SRK_KEY', 
> fdt_util.GetString(self._node, 'nxp,srk-crt', 
> 'SRK1_sha256_2048_65537_v3_usr_crt.pem'))
> +
>  self.unlock = fdt_util.GetBool(self._node, 'nxp,unlock')
>  self.ReadEntries()
>
> @@ -125,8 +133,16 @@ class Entry_nxp_imx8mcst(Entry_mkimage):
>  # Load configuration template and modify keys of interest
>  config.read_string(csf_config_template)
>  config['Install SRK']['File'] = '"' + self.srk_table + '"'
> -config['Install CSFK']['File'] = '"' + self.csf_crt + '"'
> -config['Install Key']['File'] = '"' + self.img_crt + '"'
> +if not self.fast_auth:
> +config.remove_section('Install NOCAK')
> +config['Install CSFK']['File'] = '"' + self.csf_crt + '"'
> +config['Install Key']['File'] = '"' + self.img_crt + '"'
> +else:
> +config.remove_section('Install CSFK')
> +config.remove_section('Install Key')
> +config['Install NOCAK']['File'] = '"' + self.srk_crt + '"'
> +config['Authenticate Data']['Verification index'] = '0'
> +
>  config['Authenticate Data']['Blocks'] = hex(signbase) + ' 0 ' + 
> hex(len(data)) + ' "' + str(output_dname) + '"'
>  if not self.unlock:
>  config.remove_section('Unlock')
> --
> 2.39.2
>

Regards,
Simon


Re: [PATCH 00/27] led: Remove old status-LED code

2024-09-27 Thread Simon Glass
Hi Peter,

On Fri, 27 Sept 2024 at 09:52, Peter Robinson  wrote:
>
> Hi Simon,
>
> > There has been an LED framework in U-Boot which uses driver model for
> > about 9 years now. Recent work is underway to improve it and provide
> > more features. It is probably a good time to drop the old code, which
> > is only used by 5 boards:
> >
> >./tools/qconfig.py -f LED_STATUS
> >5 matches
> >eb_cpu5282 eb_cpu5282_internal mx23_olinuxino pinephone
> >socfpga_vining_fpga
>
> Why aren't these boards being migrated to what ever the new frame work
> is rather than dropping quite useful functionality on these devices?

I don't have any of those boards, but perhaps their maintainers might
like to weigh in?

Regards,
Simon


Re: [PATCH v6 09/12] efi_loader: Add a test app

2024-09-27 Thread Simon Glass
Hi Ilias,

On Fri, 27 Sept 2024 at 07:51, Ilias Apalodimas
 wrote:
>
> Hi Simon,
>
> On Fri, 27 Sept 2024 at 01:04, Simon Glass  wrote:
> >
> > Add a simple app to use for testing. This is intended to do whatever it
> > needs to for testing purposes. For now it just prints a message and
> > exits boot services.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >  lib/efi_loader/Kconfig   | 10 ++
> >  lib/efi_loader/Makefile  |  1 +
> >  lib/efi_loader/testapp.c | 68 
> >  3 files changed, 79 insertions(+)
> >  create mode 100644 lib/efi_loader/testapp.c
> >
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index 6f6fa8d629d..41083e7c137 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -564,6 +564,16 @@ config BOOTEFI_HELLO_COMPILE
> >   No additional space will be required in the resulting U-Boot 
> > binary
> >   when this option is enabled.
> >
> > +config BOOTEFI_TESTAPP_COMPILE
> > +   bool "Compile an EFI test app for testing"
> > +   default y
> > +   help
> > + This compiles an app designed for testing. It is packed into an 
> > image
> > + by the test.py testing frame in the setup_efi_image() function.
> > +
> > + No additional space will be required in the resulting U-Boot 
> > binary
> > + when this option is enabled.
> > +
> >  endif
> >
> >  source "lib/efi/Kconfig"
> > diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> > index 00d18966f9e..87131ab911d 100644
> > --- a/lib/efi_loader/Makefile
> > +++ b/lib/efi_loader/Makefile
> > @@ -20,6 +20,7 @@ apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump
> >  ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
> >  apps-y += dtbdump
> >  endif
> > +apps-$(CONFIG_BOOTEFI_TESTAPP_COMPILE) += testapp
> >
> >  obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
> >  obj-$(CONFIG_EFI_BOOTMGR) += efi_bootmgr.o
> > diff --git a/lib/efi_loader/testapp.c b/lib/efi_loader/testapp.c
> > new file mode 100644
> > index 000..feb444c92e9
> > --- /dev/null
> > +++ b/lib/efi_loader/testapp.c
> > @@ -0,0 +1,68 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Hello world EFI application
> > + *
> > + * Copyright 2024 Google LLC
> > + * Written by Simon Glass 
> > + *
> > + * This test program is used to test the invocation of an EFI application.
> > + * It writes a few messages to the console and then exits boot services
> > + */
> > +
> > +#include 
> > +
> > +static const efi_guid_t loaded_image_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
> > +
> > +static struct efi_system_table *systable;
> > +static struct efi_boot_services *boottime;
> > +static struct efi_simple_text_output_protocol *con_out;
> > +
> > +/**
> > + * efi_main() - entry point of the EFI application.
> > + *
> > + * @handle:handle of the loaded image
> > + * @systab:system table
> > + * Return: status code
> > + */
> > +efi_status_t EFIAPI efi_main(efi_handle_t handle,
> > +struct efi_system_table *systab)
> > +{
> > +   struct efi_loaded_image *loaded_image;
> > +   efi_status_t ret;
> > +   efi_uintn_t map_size;
> > +   efi_uintn_t map_key;
> > +   efi_uintn_t desc_size;
> > +   u32 desc_version;
> > +
> > +   systable = systab;
> > +   boottime = systable->boottime;
> > +   con_out = systable->con_out;
> > +
> > +   /* Get the loaded image protocol */
> > +   ret = boottime->open_protocol(handle, &loaded_image_guid,
> > + (void **)&loaded_image, NULL, NULL,
> > + EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> > +   if (ret != EFI_SUCCESS) {
> > +   con_out->output_string
> > +   (con_out, u"Cannot open loaded image protocol\r\n");
> > +   goto out;
> > +   }
> > +
> > +   /* UEFI requires CR LF */
> > +   con_out->output_string(con_out, u"U-Boot test app for 
> > EFI_LOADER\r\n");
> > +
> > +out:
> > +   map_size = 0;
> > +   ret = boottime->get_memory_map(&map_size, NULL, &map_key, 
> > &desc_size,
> > +

Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

2024-09-27 Thread Simon Glass
Hi Ilias,

On Fri, 27 Sept 2024 at 05:30, Ilias Apalodimas
 wrote:
>
> On Fri, 27 Sept 2024 at 13:53, Simon Glass  wrote:
> >
> > Hi Ilias,
> >
> > On Thu, 26 Sept 2024 at 13:18, Ilias Apalodimas
> >  wrote:
> > >
> > > On Thu, 26 Sept 2024 at 14:04, Simon Glass  wrote:
> > > >
> > > > Hi Patrick,
> > > >
> > > > On Thu, 26 Sept 2024 at 10:01, Patrick Rudolph
> > > >  wrote:
> > > > >
> > > > > Hi Simon,
> > > > > On Fri, Sep 20, 2024 at 6:01 PM Simon Glass  wrote:
> > > > > >
> > > > > > Hi Ilias,
> > > > > >
> > > > > > On Fri, 20 Sept 2024 at 08:36, Ilias Apalodimas
> > > > > >  wrote:
> > > > > > >
> > > > > > > Hi Simon,
> > > > > > >
> > > > > > > On Thu, 19 Sept 2024 at 18:36, Simon Glass  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hi Ilias,
> > > > > > > >
> > > > > > > > On Thu, 19 Sept 2024 at 17:20, Ilias Apalodimas
> > > > > > > >  wrote:
> > > > > > > > >
> > > > > > > > > Hi Simon,
> > > > > > > > >
> > > > > > > > > On Thu, 19 Sept 2024 at 18:00, Simon Glass 
> > > > > > > > >  wrote:
> > > > > > > > > >
> > > > > > > > > > Hi Ilias,
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > [...]
> > > > > > > > >
> > > > > > > > > > > > > +
> > > > > > > > > > > > > +   if (!addr)
> > > > > > > > > > > > > +   return log_msg_ret("mem", 
> > > > > > > > > > > > > -ENOMEM);
> > > > > > > > > > > > > +   } else {
> > > > > > > > > > > > > +   pages = efi_size_in_pages(TABLE_SIZE);
> > > > > > > > > > > > > +
> > > > > > > > > > > > > +   ret = 
> > > > > > > > > > > > > efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
> > > > > > > > > > > > > +
> > > > > > > > > > > > > EFI_ACPI_RECLAIM_MEMORY,
> > > > > > > > > > > > > +pages, 
> > > > > > > > > > > > > &new_acpi_addr);
> > > > > > > > > > > > > +   if (ret != EFI_SUCCESS)
> > > > > > > > > > > > > +   return log_msg_ret("mem", 
> > > > > > > > > > > > > -ENOMEM);
> > > > > > > > > > > > > +
> > > > > > > > > > > > > +   addr = (void 
> > > > > > > > > > > > > *)(uintptr_t)new_acpi_addr;
> > > > > > > > > > > > > +   }
> > > > > > > > > > > > > +
> > > > > > > > > > > >
> > > > > > > > > > > > The tables should be written regardless of whether 
> > > > > > > > > > > > EFI_LOADER is enabled.
> > > > > > > > > > >
> > > > > > > > > > > *Why*? How do you expect to hand them over to the OS?
> > > > > > > > > >
> > > > > > > > > > Why - because boards which need ACPI tables to boot should 
> > > > > > > > > > generate
> > > > > > > > > > them;
> > > > > > > > >
> > > > > > > > > Noone argued that.
> > > > > > > > >
> > > > > > > > > > also this happens when U-Boot starts up, in 
> > > > > > > > > > last_stage_init()
> > > > > > > > > > How - it isn't possible, but eventually I suppose it will 
> > &g

Re: [PATCH 04/16] event: add event to notify lmb memory map changes

2024-09-27 Thread Simon Glass
Hi Sughosh,

On Thu, 26 Sept 2024 at 14:29, Sughosh Ganu  wrote:
>
> On Thu, 26 Sept 2024 at 16:38, Simon Glass  wrote:
> >
> > Hi Sughosh,
> >
> > On Thu, 26 Sept 2024 at 09:12, Sughosh Ganu  wrote:
> > >
> > > On Wed, 25 Sept 2024 at 18:23, Simon Glass  wrote:
> > > >
> > > > Hi Sughosh,
> > > >
> > > > On Fri, 20 Sept 2024 at 13:38, Sughosh Ganu  
> > > > wrote:
> > > > >
> > > > > On Fri, 20 Sept 2024 at 14:51, Ilias Apalodimas
> > > > >  wrote:
> > > > > >
> > > > > > Hi Sughosh,
> > > > > >
> > > > > > On Tue, 17 Sept 2024 at 15:33, Sughosh Ganu 
> > > > > >  wrote:
> > > > > > >
> > > > > > > On Sat, 14 Sept 2024 at 20:38, Heinrich Schuchardt 
> > > > > > >  wrote:
> > > > > > > >
> > > > > > > > On 9/5/24 10:27, Sughosh Ganu wrote:
> > > > > > > > > Add an event which would be used for notifying changes in the
> > > > > > > > > LMB modules' memory map. This is to be used for having a
> > > > > > > > > synchronous view of the memory that is currently in use, and 
> > > > > > > > > that is
> > > > > > > > > available for allocations.
> > > > > > > >
> > > > > > > > The synchronous view problem only exists because we are 
> > > > > > > > duplicating
> > > > > > > > data. Store the EFI memory type in LMB and the problem vanishes.
> > > > > > >
> > > > > > > The LMB module only concerns itself with RAM memory. If I 
> > > > > > > understand
> > > > > > > correctly, you are proposing maintaining the EFI memory map 
> > > > > > > within the
> > > > > > > LMB module ? That would mean handling memory types other than
> > > > > > > conventional memory in LMB.
> > > > > >
> > > > > > I am pretty sure I've asked this before, but do these *always* need 
> > > > > > to
> > > > > > be in sync?
> > > > > >
> > > > > > The efi allocators will call LMB now. So when we allocate something
> > > > > > gtom EFI, even if any potential changes from LMB haven't been
> > > > > > published to EFI, we won't have any memory corruptions. Can't we 
> > > > > > just
> > > > > > opportunistically update the memory map once someone requests it?
> > > > >
> > > > > I have given this a thought. Because what you mention, Simon has a
> > > > > similar comment. But to achieve this, it would require generating a
> > > > > new efi memory map afresh every time such a requirement comes up. This
> > > > > would mean, create a new memory map, put in the conventional memory,
> > > > > and add other memory types that were part of the existing memory map.
> > > > > And then remove the older memory map. This would need to be done every
> > > > > time a memory map is needed to be generated. And that would also
> > > > > include instances when a user enters a command to get the current
> > > > > memory map. I think notifying any changes to the lmb memory map to the
> > > > > efi memory module is easier, and less error prone.
> > > >
> > > > We need to get some agreement on my memory-allocation patches first. I
> > > > don't believe we are on the same page on those, despite some weeks of
> > > > discussion. We need to resolve that issue first. I did try right from
> > > > the start to first agree on the problem to be solved. We skipped that,
> > > > so now we are having to do it now...
> > >
> > > These patches are currently under review. But fwiw, I think you are
> > > aware that these patches are not related to what your patch series is
> > > attempting. Your patches are related to the efi_allocate_pool()
> > > function, whereas this series is trying to use LMB as the backend for
> > > allocating pages, as requested from efi_allocate_pages(). So these are
> > > not related. But like I said, you are aware of these details :)
> >
> > The thing is, if we actually tidy up the EFI allocations then there
> > will 

Re: [PATCH 04/16] event: add event to notify lmb memory map changes

2024-09-27 Thread Simon Glass
Hi Sughosh,

On Fri, 27 Sept 2024 at 05:01, Sughosh Ganu  wrote:
>
> On Fri, 27 Sept 2024 at 16:12, Simon Glass  wrote:
> >
> > Hi Sughosh,
> >
> > On Thu, 26 Sept 2024 at 14:29, Sughosh Ganu  wrote:
> > >
> > > On Thu, 26 Sept 2024 at 16:38, Simon Glass  wrote:
> > > >
> > > > Hi Sughosh,
> > > >
> > > > On Thu, 26 Sept 2024 at 09:12, Sughosh Ganu  
> > > > wrote:
> > > > >
> > > > > On Wed, 25 Sept 2024 at 18:23, Simon Glass  wrote:
> > > > > >
> > > > > > Hi Sughosh,
> > > > > >
> > > > > > On Fri, 20 Sept 2024 at 13:38, Sughosh Ganu 
> > > > > >  wrote:
> > > > > > >
> > > > > > > On Fri, 20 Sept 2024 at 14:51, Ilias Apalodimas
> > > > > > >  wrote:
> > > > > > > >
> > > > > > > > Hi Sughosh,
> > > > > > > >
> > > > > > > > On Tue, 17 Sept 2024 at 15:33, Sughosh Ganu 
> > > > > > > >  wrote:
> > > > > > > > >
> > > > > > > > > On Sat, 14 Sept 2024 at 20:38, Heinrich Schuchardt 
> > > > > > > > >  wrote:
> > > > > > > > > >
> > > > > > > > > > On 9/5/24 10:27, Sughosh Ganu wrote:
> > > > > > > > > > > Add an event which would be used for notifying changes in 
> > > > > > > > > > > the
> > > > > > > > > > > LMB modules' memory map. This is to be used for having a
> > > > > > > > > > > synchronous view of the memory that is currently in use, 
> > > > > > > > > > > and that is
> > > > > > > > > > > available for allocations.
> > > > > > > > > >
> > > > > > > > > > The synchronous view problem only exists because we are 
> > > > > > > > > > duplicating
> > > > > > > > > > data. Store the EFI memory type in LMB and the problem 
> > > > > > > > > > vanishes.
> > > > > > > > >
> > > > > > > > > The LMB module only concerns itself with RAM memory. If I 
> > > > > > > > > understand
> > > > > > > > > correctly, you are proposing maintaining the EFI memory map 
> > > > > > > > > within the
> > > > > > > > > LMB module ? That would mean handling memory types other than
> > > > > > > > > conventional memory in LMB.
> > > > > > > >
> > > > > > > > I am pretty sure I've asked this before, but do these *always* 
> > > > > > > > need to
> > > > > > > > be in sync?
> > > > > > > >
> > > > > > > > The efi allocators will call LMB now. So when we allocate 
> > > > > > > > something
> > > > > > > > gtom EFI, even if any potential changes from LMB haven't been
> > > > > > > > published to EFI, we won't have any memory corruptions. Can't 
> > > > > > > > we just
> > > > > > > > opportunistically update the memory map once someone requests 
> > > > > > > > it?
> > > > > > >
> > > > > > > I have given this a thought. Because what you mention, Simon has a
> > > > > > > similar comment. But to achieve this, it would require generating 
> > > > > > > a
> > > > > > > new efi memory map afresh every time such a requirement comes up. 
> > > > > > > This
> > > > > > > would mean, create a new memory map, put in the conventional 
> > > > > > > memory,
> > > > > > > and add other memory types that were part of the existing memory 
> > > > > > > map.
> > > > > > > And then remove the older memory map. This would need to be done 
> > > > > > > every
> > > > > > > time a memory map is needed to be generated. And that would also
> > > > > > > include instances when a user enters a command to get the current
> > > > > > > memory map. I think notifying an

Re: [PATCH v6 05/12] efi_loader: Show the vendor in helloworld

2024-09-27 Thread Simon Glass
Hi Ilias,

On Fri, 27 Sept 2024 at 06:00, Ilias Apalodimas
 wrote:
>
> Hi Simon
>
>
> On Fri, 27 Sept 2024 at 01:01, Simon Glass  wrote:
> >
> > Show the vendor name so it is clear which firmware is being used, e.g.
> > whether U-Boot is providing the boot services.
> >
> > Signed-off-by: Simon Glass 
>
> I already sent my r-b for this. [0]. I am not sure Heinrich remarks were 
> covered

Heinrich basically didn't see the point of this patch, but then
suggested printing out FirmwareRevision too. I did reply but didn't
hear back.

So I suggest we just go with this and we can expand it later. Or just
drop the patch.

>
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Reword commit message
> > - Use 'Firmware vendor' instead of just 'Vendor'
> >
> >  lib/efi_loader/helloworld.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
> > index 586177de0c8..c4d2afcb40a 100644
> > --- a/lib/efi_loader/helloworld.c
> > +++ b/lib/efi_loader/helloworld.c
> > @@ -237,6 +237,9 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
> > (con_out, u"Missing device path for device 
> > handle\r\n");
> > goto out;
> > }
> > +   con_out->output_string(con_out, u"Firmware vendor: ");
> > +   con_out->output_string(con_out, systab->fw_vendor);
> > +   con_out->output_string(con_out, u"\n");
> > con_out->output_string(con_out, u"Boot device: ");
> > ret = print_device_path(device_path, device_path_to_text);
> > if (ret != EFI_SUCCESS)
> > --
> > 2.43.0
> >
>
> [0] 
> https://lore.kernel.org/u-boot/cac_iwj+dthbghaqjwiwm8zvcxf3mcoom13yplsqggbpcpgn...@mail.gmail.com/

Regards,
Simon


Re: [PATCH 02/16] lmb: add a flag to allow suppressing memory map change notification

2024-09-27 Thread Simon Glass
Hi Ilias,

On Fri, 27 Sept 2024 at 05:08, Ilias Apalodimas
 wrote:
>
> Hi Simon,
>
> On Thu, 19 Sept 2024 at 17:12, Simon Glass  wrote:
> >
> > Hi,
> >
> > On Tue, 17 Sept 2024 at 13:55, Sughosh Ganu  wrote:
> > >
> > > On Sat, 14 Sept 2024 at 20:14, Heinrich Schuchardt  
> > > wrote:
> > > >
> > > > On 9/5/24 10:27, Sughosh Ganu wrote:
> > > > > Add a flag LMB_NONOTIFY that can be passed to the LMB API's for
> > > > > reserving memory. This will then result in no notification being sent
> > > > > from the LMB module for the changes to the LMB's memory map.
> > > >
> > > > You seem to be using this in patch 3 and 7.
> > > >
> > > > Please, describe in this patch why you want to be able to suppress
> > > > notification.
> > >
> > > Will add the reasoning behind this flag in the commit message.
> > >
> > > >
> > > > In the EFI context we should use LMB notification to notify the
> > > > EFI_EVENT_GROUP_MEMORY_MAP_CHANGE event.
> > > >
> > > > See chapter 7.1.2 EFI_BOOT_SERVICES.CreateEventEx() in the UEFI
> > > > specification.
> > >
> > > So, do you want me to use the EFI event signaling mechanism for this
> > > purpose ? Is my understanding correct ? If so, this will mean that we
> > > have an event notification specifically for EFI, and there might be
> > > one needed for any other consumers of this event. Currently there
> > > aren't any other consumers of the LMB memory map change event other
> > > than EFI, but using the U-Boot's event notification mechanism means
> > > that the same notification mechanism can be used if there were any
> > > additional consumers of this event in the future. In that case, we
> > > would have two separate event notifications, one for EFI, and one for
> > > non-EFI consumers.
> >
> > As I have previously said, none of this is necessary.
> >
> > Essentially all of the EFI setup that is done in U-Boot can be delayed
> > until we are actually starting an EFI app.
>
> Can you explain how you plan to deal with EFI variables, the TPM
> eventlog, measuring events when tables are added, capsules updates etc
> etc, which expect certain EFI services to be up and running?

Yes, sure. Accessing EFI variables is going to require EFI to be
inited, I assume. For capsule updates, I believe that is triggered on
boot, so again it would need EFI services. It's fine to use EFI when
it is needed. But this memory-map thing has really got out of hand.
BTW we need TPM eventlog and measuring for any type of boot so it
needs to work without EFI.

>
> > The current approach of
> > keeping parallel EFI tables everywhere is causing much confusion.
>
> Apart from all of the above the EFI app can return. Which makes all of
> the above just a burden

It's fine if it returns, isn't it? What is the burden?

>
> >
> > For EFI, it should be enough to read the lmb tables at the end and add
> > whatever parallel tables are needed to boot the app.
>
> Yes apart from the fact that LMB has no idea about memory types or 
> permissions.

Neither should it. It is for laying out images in memory. We need to
maintain some separation of concerns here, or we'll end up with a
complex mess. Memory types are really an EFI construct which should be
easy enough to add statically - e.g. U-Boot code is
EFI_BOOT_SERVICES_CODE. Memory permissions are known based on the
memory areas, so I don't think lmb needs to know about that.


>
> > We should not
> > need to keep things in sync through the life of U-Boot, since:
> >
> > 1. EFI pool-allocations should use malloc() until the app starts
> > 2. EFI page allocations should not be allowed until the app starts
> >
> > This whole area needs a healthy dose of 'keep it simple'.

Regards,
Simon


Re: [PATCH 19/27] mx23_olinuxino: Drop status-LED code

2024-09-27 Thread Simon Glass
Hi Marek,

On Fri, 27 Sept 2024 at 00:20, Marek Vasut  wrote:
>
> On 9/27/24 12:10 AM, Simon Glass wrote:
> > Hi Marek,
>
> Hello Simon,
>
> > On Thu, 26 Sept 2024 at 23:40, Marek Vasut  wrote:
> >>
> >> On 9/26/24 10:44 PM, Simon Glass wrote:
> >>> This is not used anymore, so drop it.
> >>>
> >>> Signed-off-by: Simon Glass 
> >>> ---
> >>>
> >>>board/olimex/mx23_olinuxino/mx23_olinuxino.c | 7 ---
> >>>1 file changed, 7 deletions(-)
> >>>
> >>> diff --git a/board/olimex/mx23_olinuxino/mx23_olinuxino.c 
> >>> b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
> >>> index b2bb6678c23..78136c1620a 100644
> >>> --- a/board/olimex/mx23_olinuxino/mx23_olinuxino.c
> >>> +++ b/board/olimex/mx23_olinuxino/mx23_olinuxino.c
> >>> @@ -13,9 +13,6 @@
> >>>#include 
> >>>#include 
> >>>#include 
> >>> -#ifdef CONFIG_LED_STATUS
> >>> -#include 
> >>> -#endif
> >>>#include 
> >>>
> >>>DECLARE_GLOBAL_DATA_PTR;
> >>> @@ -61,9 +58,5 @@ int board_init(void)
> >>>/* Adress of boot parameters */
> >>>gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
> >>>
> >>> -#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
> >>> - status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_STATE);
> >>> -#endif
> >> Why not define the GPIO LED in DT, it might even already be defined there.
> >
> > Yes I see it in the DT for quite a few boards, so that's what we should use.
> Since LED uclass already uses well established DM_FLAG_PROBE_AFTER_BIND
> flag, the update here should be only a matter of enabling DM LED and
> GPIO LED driver.

Yes, fair enough, but I hope you are not suggesting I try and do it?

I'm OK with that flag with LEDs. It is regulators where I get nervous.

Regards,
Simon


Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

2024-09-27 Thread Simon Glass
Hi Ilias,

On Thu, 26 Sept 2024 at 13:26, Ilias Apalodimas
 wrote:
>
> Hi Simon,
>
> On Fri, 20 Sept 2024 at 19:01, Simon Glass  wrote:
> >
> > Hi Ilias,
> >
> > On Fri, 20 Sept 2024 at 08:36, Ilias Apalodimas
> >  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Thu, 19 Sept 2024 at 18:36, Simon Glass  wrote:
> > > >
> > > > Hi Ilias,
> > > >
> > > > On Thu, 19 Sept 2024 at 17:20, Ilias Apalodimas
> > > >  wrote:
> > > > >
> > > > > Hi Simon,
> > > > >
> > > > > On Thu, 19 Sept 2024 at 18:00, Simon Glass  wrote:
> > > > > >
> > > > > > Hi Ilias,
> > > > > >
> > > > >
> > > > > [...]
> > > > >
> > > > > > > > > +
> > > > > > > > > +   if (!addr)
> > > > > > > > > +   return log_msg_ret("mem", -ENOMEM);
> > > > > > > > > +   } else {
> > > > > > > > > +   pages = efi_size_in_pages(TABLE_SIZE);
> > > > > > > > > +
> > > > > > > > > +   ret = 
> > > > > > > > > efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
> > > > > > > > > +
> > > > > > > > > EFI_ACPI_RECLAIM_MEMORY,
> > > > > > > > > +pages, 
> > > > > > > > > &new_acpi_addr);
> > > > > > > > > +   if (ret != EFI_SUCCESS)
> > > > > > > > > +   return log_msg_ret("mem", -ENOMEM);
> > > > > > > > > +
> > > > > > > > > +   addr = (void *)(uintptr_t)new_acpi_addr;
> > > > > > > > > +   }
> > > > > > > > > +
> > > > > > > >
> > > > > > > > The tables should be written regardless of whether EFI_LOADER 
> > > > > > > > is enabled.
> > > > > > >
> > > > > > > *Why*? How do you expect to hand them over to the OS?
> > > > > >
> > > > > > Why - because boards which need ACPI tables to boot should generate
> > > > > > them;
> > > > >
> > > > > Noone argued that.
> > > > >
> > > > > > also this happens when U-Boot starts up, in last_stage_init()
> > > > > > How - it isn't possible, but eventually I suppose it will be, once 
> > > > > > we
> > > > > > have a use case for booting with ACPI but without EFI
> > > > >
> > > > > Are you aware of such an OS? If not, we can accept the patches when we
> > > > > have a reason.
> > > >
> > > > Which patches? This is how it works today. We set up the tables in
> > > > last_stage_init(), so they can be examined while in U-Boot.
> > >
> > > What I mean, is that until we have a valid use case to store the ACPI
> > > in a bloblist, I prefer them being allocated with proper EFI memory
> > > backing
> >
> > I'm going to assert prior art here. If ARM is to have ACPI in U-Boot,
> > it should follow the most recent x86 approach and store it in the
> > bloblist. That is what the blloblist is for. It also avoids using
> > memory below the U-Boot area, which is not allowed.
>
> By prior art you mean [0], which was none of the EFI maintainers got involved?

Yes. I should point out that I wrote the original EFI app support and
am maintainer for that. I also reviewed the original EFI_LOADER
support over quite a few revisions. I have a pretty-good understanding
of the implementation and issues.

>
> >
> > >
> > > >
> > > > It is the patches to change this which I object to.
> > > >
> > > > > I remember patches being hard NAK'ed on using DTs to pass the ACPI
> > > > > table address in the past.
> > > >
> > > > Yes, I believe Bytedance carries a patch locally for that :-)
> > >
> > > Exactly
> > >
> > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > Can we drop this

Re: [PATCH 14/42] rockchip: Simplify check for SPL

2024-09-27 Thread Simon Glass
Hi Jonas,

On Thu, 26 Sept 2024 at 18:13, Jonas Karlman  wrote:
>
> Hi Simon,
>
> On 2024-09-27 00:35, Simon Glass wrote:
> > Now that SPL means SPL (only) and is not defined for TPL, simplify some
> > checks for SPL.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >  arch/arm/include/asm/arch-rockchip/boot0.h |  3 +--
> >  arch/arm/mach-rockchip/rk3399/rk3399.c |  2 +-
> >  drivers/clk/rockchip/clk_rk3368.c  |  8 
> >  drivers/ram/rockchip/sdram_rk3288.c| 10 +-
> >  drivers/ram/rockchip/sdram_rk3399.c|  2 +-
> >  drivers/ram/rockchip/sdram_rv1126.c|  9 +++--
> >  6 files changed, 15 insertions(+), 19 deletions(-)
> >
> > diff --git a/arch/arm/include/asm/arch-rockchip/boot0.h 
> > b/arch/arm/include/asm/arch-rockchip/boot0.h
> > index edb2a31c348..918f0495fa0 100644
> > --- a/arch/arm/include/asm/arch-rockchip/boot0.h
> > +++ b/arch/arm/include/asm/arch-rockchip/boot0.h
> > @@ -54,7 +54,6 @@ _start:
> >   ARM_VECTORS
> >  #endif
> >
> > -#if !defined(CONFIG_TPL_BUILD) && defined(CONFIG_XPL_BUILD) && \
> > - (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0)
> > +#if defined(CONFIG_SPL_BUILD) && (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0)
>
> This was changed from SPL to XPL just to be changed back to SPL in this
> patch?, such change probably just clutter git blame, was the change to
> use XPL really necessary in the first place?
>
> Because SPL_BUILD was used together with !TPL_BUILD it is pretty obvious
> that SPL_BUILD did not need to change to XPL_BUILD in the first place.

Yes this is a bit of a corner case.

For the first patch, CONFIG_SPL_BUILD is defined for any 'SPL' build.
For the second it is defined only for SPL. So in this case, yes, it
doesn't matter. But across the whole of U-Boot, it does.

I got pretty deep down the rabbit hole on this one, and perhaps should
not have gone ahead with the 'clean-up'. So I think we can just drop
this patch. I'll look at what others might be dropped too.

Regards,
Simon


Re: [PATCH v4 14/35] efi_loader: Allocate and write ACPI tables

2024-09-27 Thread Simon Glass
Hi Ilias,

On Thu, 26 Sept 2024 at 13:18, Ilias Apalodimas
 wrote:
>
> On Thu, 26 Sept 2024 at 14:04, Simon Glass  wrote:
> >
> > Hi Patrick,
> >
> > On Thu, 26 Sept 2024 at 10:01, Patrick Rudolph
> >  wrote:
> > >
> > > Hi Simon,
> > > On Fri, Sep 20, 2024 at 6:01 PM Simon Glass  wrote:
> > > >
> > > > Hi Ilias,
> > > >
> > > > On Fri, 20 Sept 2024 at 08:36, Ilias Apalodimas
> > > >  wrote:
> > > > >
> > > > > Hi Simon,
> > > > >
> > > > > On Thu, 19 Sept 2024 at 18:36, Simon Glass  wrote:
> > > > > >
> > > > > > Hi Ilias,
> > > > > >
> > > > > > On Thu, 19 Sept 2024 at 17:20, Ilias Apalodimas
> > > > > >  wrote:
> > > > > > >
> > > > > > > Hi Simon,
> > > > > > >
> > > > > > > On Thu, 19 Sept 2024 at 18:00, Simon Glass  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hi Ilias,
> > > > > > > >
> > > > > > >
> > > > > > > [...]
> > > > > > >
> > > > > > > > > > > +
> > > > > > > > > > > +   if (!addr)
> > > > > > > > > > > +   return log_msg_ret("mem", 
> > > > > > > > > > > -ENOMEM);
> > > > > > > > > > > +   } else {
> > > > > > > > > > > +   pages = efi_size_in_pages(TABLE_SIZE);
> > > > > > > > > > > +
> > > > > > > > > > > +   ret = 
> > > > > > > > > > > efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
> > > > > > > > > > > +
> > > > > > > > > > > EFI_ACPI_RECLAIM_MEMORY,
> > > > > > > > > > > +pages, 
> > > > > > > > > > > &new_acpi_addr);
> > > > > > > > > > > +   if (ret != EFI_SUCCESS)
> > > > > > > > > > > +   return log_msg_ret("mem", 
> > > > > > > > > > > -ENOMEM);
> > > > > > > > > > > +
> > > > > > > > > > > +   addr = (void *)(uintptr_t)new_acpi_addr;
> > > > > > > > > > > +   }
> > > > > > > > > > > +
> > > > > > > > > >
> > > > > > > > > > The tables should be written regardless of whether 
> > > > > > > > > > EFI_LOADER is enabled.
> > > > > > > > >
> > > > > > > > > *Why*? How do you expect to hand them over to the OS?
> > > > > > > >
> > > > > > > > Why - because boards which need ACPI tables to boot should 
> > > > > > > > generate
> > > > > > > > them;
> > > > > > >
> > > > > > > Noone argued that.
> > > > > > >
> > > > > > > > also this happens when U-Boot starts up, in last_stage_init()
> > > > > > > > How - it isn't possible, but eventually I suppose it will be, 
> > > > > > > > once we
> > > > > > > > have a use case for booting with ACPI but without EFI
> > > > > > >
> > > > > > > Are you aware of such an OS? If not, we can accept the patches 
> > > > > > > when we
> > > > > > > have a reason.
> > > > > >
> > > > > > Which patches? This is how it works today. We set up the tables in
> > > > > > last_stage_init(), so they can be examined while in U-Boot.
> > > > >
> > > > > What I mean, is that until we have a valid use case to store the ACPI
> > > > > in a bloblist, I prefer them being allocated with proper EFI memory
> > > > > backing
> > > >
> > > > I'm going to assert prior art here. If ARM is to have ACPI in U-Boot,
> > > > it should follow the most recent x86 approach and store it 

Re: [PATCH 15/15] binman: Make a start on an iMX8 test

2024-09-27 Thread Simon Glass
Hi Marek,

On Fri, 27 Sept 2024 at 00:20, Marek Vasut  wrote:
>
> On 9/27/24 12:07 AM, Simon Glass wrote:
> > This patch is for Marek, to provide a starting point.
> >
> > To try it, use 'binman test -T' and see the missing coverage.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> >   tools/binman/etype/nxp_imx8mimage.py |  3 ++-
> >   tools/binman/ftest.py|  4 
> >   tools/binman/test/339_nxp_imx8.dts   | 17 +
> >   3 files changed, 23 insertions(+), 1 deletion(-)
> >   create mode 100644 tools/binman/test/339_nxp_imx8.dts
> >
> > Applied to u-boot-dm/next, thanks!
>
> Is this patch really supposed to be applied as-is ?
> The commit message makes it seem like some RFC/Example code.

Well it is better than what we have, so I applied it. It should give
you something to build on.

Regards,
Simon


Re: [PATCH 02/16] lmb: add a flag to allow suppressing memory map change notification

2024-09-27 Thread Simon Glass
Hi Sughosh,

On Fri, 20 Sept 2024 at 06:33, Sughosh Ganu  wrote:
>
> On Thu, 19 Sept 2024 at 19:42, Simon Glass  wrote:
> >
> > Hi,
> >
> > On Tue, 17 Sept 2024 at 13:55, Sughosh Ganu  wrote:
> > >
> > > On Sat, 14 Sept 2024 at 20:14, Heinrich Schuchardt  
> > > wrote:
> > > >
> > > > On 9/5/24 10:27, Sughosh Ganu wrote:
> > > > > Add a flag LMB_NONOTIFY that can be passed to the LMB API's for
> > > > > reserving memory. This will then result in no notification being sent
> > > > > from the LMB module for the changes to the LMB's memory map.
> > > >
> > > > You seem to be using this in patch 3 and 7.
> > > >
> > > > Please, describe in this patch why you want to be able to suppress
> > > > notification.
> > >
> > > Will add the reasoning behind this flag in the commit message.
> > >
> > > >
> > > > In the EFI context we should use LMB notification to notify the
> > > > EFI_EVENT_GROUP_MEMORY_MAP_CHANGE event.
> > > >
> > > > See chapter 7.1.2 EFI_BOOT_SERVICES.CreateEventEx() in the UEFI
> > > > specification.
> > >
> > > So, do you want me to use the EFI event signaling mechanism for this
> > > purpose ? Is my understanding correct ? If so, this will mean that we
> > > have an event notification specifically for EFI, and there might be
> > > one needed for any other consumers of this event. Currently there
> > > aren't any other consumers of the LMB memory map change event other
> > > than EFI, but using the U-Boot's event notification mechanism means
> > > that the same notification mechanism can be used if there were any
> > > additional consumers of this event in the future. In that case, we
> > > would have two separate event notifications, one for EFI, and one for
> > > non-EFI consumers.
> >
> > As I have previously said, none of this is necessary.
> >
> > Essentially all of the EFI setup that is done in U-Boot can be delayed
> > until we are actually starting an EFI app. The current approach of
> > keeping parallel EFI tables everywhere is causing much confusion.
> >
> > For EFI, it should be enough to read the lmb tables at the end and add
> > whatever parallel tables are needed to boot the app. We should not
> > need to keep things in sync through the life of U-Boot, since:
> >
> > 1. EFI pool-allocations should use malloc() until the app starts
> > 2. EFI page allocations should not be allowed until the app starts
> >
> > This whole area needs a healthy dose of 'keep it simple'.
>
> Except, the current implementation proposed by the patch *is* actually
> much more simpler than syncing the maps when the app starts. Because
> there is another scenario when the map needs to be synced, when the
> user issues a 'efidebug memmap' command, which dumps the efi memory
> map.
>
> Syncing the map from lmb means that the efi memory map first has to be
> generated afresh. And that is much more complicated than the method
> incorporated in the patch series. Apart from the ram/conventional
> memory type, we also need to include other memory types that might
> have been added to the memory map. So, this would mean, create a new
> memory map, add entries for conventional memory as have been obtained
> from lmb followed by other entries, and then discard the old memory
> map. And this has to be carried out every time a need for a memory map
> update is needed.

We are just not on the same page here. But I've replied to this point
on your other email. Also please understand that my objective is
actually to not do EFI allocations until just before the EFI app
actually starts (when we set up the EFI memory map). Until then, I
believe malloc() suffices.

Regards,
Simon


[PATCH 30/42] global: Rename SPL_TPL_ to PHASE_

2024-09-26 Thread Simon Glass
Use PHASE_ as the symbol to select a particular XPL build. This means
that SPL_TPL_ is no-longer set.

Update the comment in bootstage to refer to this symbol, instead of
SPL_

Signed-off-by: Simon Glass 
---

 Makefile  |  2 +-
 arch/arm/cpu/armv8/Makefile   |  2 +-
 arch/arm/lib/Makefile | 16 +++---
 arch/arm/mach-at91/arm926ejs/Makefile |  2 +-
 arch/arm/mach-omap2/Makefile  |  2 +-
 arch/arm/mach-rockchip/Makefile   |  2 +-
 arch/powerpc/lib/Makefile |  2 +-
 arch/riscv/lib/Makefile   | 14 ++---
 arch/x86/Makefile |  6 +-
 arch/x86/cpu/Makefile |  8 +--
 arch/x86/cpu/broadwell/Makefile   | 10 ++--
 arch/x86/cpu/intel_common/Makefile| 10 ++--
 arch/x86/lib/Makefile |  6 +-
 board/coreboot/coreboot/Makefile  |  2 +-
 boot/Makefile | 80 +--
 common/Makefile   | 26 -
 common/bootstage.c|  4 +-
 common/init/Makefile  |  2 +-
 common/spl/Makefile   | 56 +--
 disk/Makefile | 18 +++---
 drivers/Makefile  | 70 +++
 drivers/adc/Makefile  |  2 +-
 drivers/block/Makefile|  8 +--
 drivers/cache/Makefile|  2 +-
 drivers/clk/Makefile  | 18 +++---
 drivers/clk/exynos/Makefile   |  2 +-
 drivers/clk/imx/Makefile  | 20 +++
 drivers/clk/ti/Makefile   |  4 +-
 drivers/core/Makefile | 10 ++--
 drivers/crypto/fsl/Makefile   |  2 +-
 drivers/gpio/Makefile |  6 +-
 drivers/input/Makefile|  6 +-
 drivers/misc/Makefile | 16 +++---
 drivers/mmc/Makefile  |  6 +-
 drivers/mtd/Makefile  |  4 +-
 drivers/mtd/nand/Makefile |  2 +-
 drivers/mtd/nand/raw/Makefile |  2 +-
 drivers/mtd/spi/Makefile  |  8 +--
 drivers/pinctrl/starfive/Makefile |  4 +-
 drivers/power/Makefile|  8 +--
 drivers/power/acpi_pmc/Makefile   |  2 +-
 drivers/power/pmic/Makefile   |  4 +-
 drivers/power/regulator/Makefile  |  2 +-
 drivers/ram/Makefile  |  2 +-
 drivers/reset/Makefile|  2 +-
 drivers/rng/Makefile  |  2 +-
 drivers/rtc/Makefile  |  6 +-
 drivers/scsi/Makefile |  2 +-
 drivers/serial/Makefile   |  2 +-
 drivers/spi/Makefile  |  2 +-
 drivers/sysreset/Makefile | 14 ++---
 drivers/tpm/Makefile  |  4 +-
 drivers/usb/gadget/Makefile   |  6 +-
 drivers/usb/host/Makefile |  4 +-
 drivers/video/Makefile| 16 +++---
 drivers/watchdog/Makefile |  2 +-
 env/Makefile  | 22 
 fs/sandbox/Makefile   |  2 +-
 lib/Makefile  | 34 ++--
 lib/acpi/Makefile |  2 +-
 lib/libfdt/Makefile   |  2 +-
 lib/rsa/Makefile  |  4 +-
 net/Makefile  |  6 +-
 scripts/Kbuild.include|  8 +--
 scripts/Makefile.xpl  | 44 +++
 test/dm/Makefile  |  4 +-
 tools/qconfig.py  |  6 +-
 67 files changed, 338 insertions(+), 338 deletions(-)

diff --git a/Makefile b/Makefile
index d38adcbd1e6..ca74406f21c 100644
--- a/Makefile
+++ b/Makefile
@@ -883,7 +883,7 @@ libs-y += drivers/usb/ulpi/
 ifdef CONFIG_POST
 libs-y += post/
 endif
-libs-$(CONFIG_$(SPL_TPL_)UNIT_TEST) += test/
+libs-$(CONFIG_$(PHASE_)UNIT_TEST) += test/
 libs-$(CONFIG_UT_ENV) += test/env/
 libs-$(CONFIG_UT_OPTEE) += test/optee/
 libs-$(CONFIG_UT_OVERLAY) += test/overlay/
diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
index c5f568e2cb7..8747d2eb186 100644
--- a/arch/arm/cpu/armv8/Makefile
+++ b/arch/arm/cpu/armv8/Makefile
@@ -6,7 +6,7 @@
 extra-y:= start.o
 
 obj-y  += cpu.o
-ifndef CONFIG_$(SPL_TPL_)TIMER
+ifndef CONFIG_$(PHASE_)TIMER
 obj-$(CONFIG_SYS_ARCH_TIMER) += generic_timer.o
 endif
 ifndef CONFIG_$(XPL_)SYS_DCACHE_OFF
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index b73a0397541..211ff4960e1 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -34,7 +34,7 @@ obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 else
-obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o
+obj-$(CONFIG_$(PHASE_)FRAMEWORK) += spl.o
 ifdef CONFIG_SPL_FRAMEWORK
 obj-$(CONFIG_CMD_BOOTI) += image.o
 obj-$(CONFIG_CMD_BOOTZ) += zimage.o
@@ -42,14 +42,14 @@ endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
-obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset-arm64.o

[PATCH 00/42] Tidy up use of 'SPL' and CONFIG_SPL_BUILD

2024-09-26 Thread Simon Glass
When the SPL build-phase was first created it was designed to solve a
particular problem (the need to init SDRAM so that U-Boot proper could
be loaded). It has since expanded to become an important part of U-Boot,
with three phases now present: TPL, VPL and SPL

Due to this history, the term 'SPL' is used to mean both a particular
phase (the one before U-Boot proper) and all the non-proper phases.
This has become confusing.

For a similar reason CONFIG_SPL_BUILD is set to 'y' for all 'SPL'
phases, not just SPL. So code which can only be compiled for actual SPL,
for example, must use something like this:

   #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)

In Makefiles we have similar issues. SPL_ has been used as a variable
which expands to either SPL_ or nothing, to chose between options like
CONFIG_BLK and CONFIG_SPL_BLK. When TPL appeared, a new SPL_TPL variable
was created which expanded to 'SPL_', 'TPL_' or nothing. Later it was
updated to support 'VPL_' as well.

This series starts a change in terminology and usage to resolve the
above issues:

- The word 'xPL' is used instead of 'SPL' to mean a non-proper build
- A new CONFIG_XPL_BUILD define indicates that the current build is an
  'xPL' build
- The existing CONFIG_SPL_BUILD is changed to mean SPL; it is not now
  defined for TPL and VPL phases
- The existing SPL_ Makefile variable is renamed to SPL_
- The existing SPL_TPL Makefile variable is renamed to PHASE_

It should be noted that xpl_phase() can generally be used instead of
the above CONFIGs without a code-space or run-time penalty.

This series does not attempt to convert all of U-Boot to use this new
terminology but it makes a start. In particular, renaming spl.h and
common/spl seems like a bridge too far at this point.

An attempt has been made to make this series bisectable, but this is a
little tricky, so some logic errors may be present.

Some more analysis is probably needed, e.g. to make sure that the code
size doesn't change for any board.


Simon Glass (42):
  Makefile: Add a u-boot.cfg file for VPL
  scripts: Rename Makefile.spl to Makefile.xpl
  scripts: Add some comments about autoconf.mk
  scripts: Define CONFIG_XPL_BUILD for all xPL builds
  global: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILD
  doc: Update SPL docs for the xPL changes
  net: freescale: Drop use of SPL_BUILD dependency
  x86: Update a comment to mention XPL
  tegra: Use SPL instead of SPL_BUILD
  log: global: Rename warn_non_spl() and update the condition
  qconfig: Add XPL_BUILD to ignored symbols
  boot: Drop unnecessary ifdef for LOAD_FIT
  xpl: Define CONFIG_SPL_BUILD only for the SPL build
  rockchip: Simplify check for SPL
  mips: Simplify check for SPL
  powerpc: Simplify check for SPL
  x86: Simplify check for SPL
  freescale: Simplify check for SPL
  mtd: Simplify check for SPL
  dm: Simplify check for SPL
  spl: Simplify check for SPL
  powerpc: Correct check for SPL
  serial: Make use of the SERIAL define
  stdio: Make use of the SERIAL define
  drivers: Simplify Makefile checks
  kconfig: binman: Check for SPL instead of XPL
  rockchip: Simplify Makefile condition
  drivers: Simplify Makefile condition
  global: Rename SPL_ to XPL_
  global: Rename SPL_TPL_ to PHASE_
  spl: Rename SPL_TPL_NAME and SPL_TPL_PROMPT
  qconfig: Update tool for new Makefile variables
  xpl: Rename u_boot_first_phase to xpl_is_first_phase()
  xpl: Rename spl_phase to xpl_phase_t
  xpl: Rename spl_phase() to xpl_phase()
  xpl: Rename spl_in_proper() to not_xpl()
  xpl: Add a function to indicate when in xPL
  xpl: Rename spl_next_phase() and spl_prev_phase()
  xpl: Rename spl_phase_prefix() and spl_phase_name()
  README: Drop SoC-specific comment about SPL
  doc: Move init-related things out of README
  doc: Update init docs for the xPL changes

 Makefile  | 14 +--
 README| 99 +--
 arch/arm/Makefile |  6 +-
 arch/arm/config.mk| 12 +--
 arch/arm/cpu/arm11/Makefile   |  2 +-
 arch/arm/cpu/arm1176/start.S  |  2 +-
 arch/arm/cpu/arm920t/Makefile |  2 +-
 arch/arm/cpu/arm926ejs/Makefile   |  4 +-
 arch/arm/cpu/arm926ejs/mxs/Makefile   |  4 +-
 arch/arm/cpu/arm926ejs/sunxi/config.mk|  2 +-
 arch/arm/cpu/armv7/Makefile   |  4 +-
 arch/arm/cpu/armv7/cpu.c  |  2 +-
 arch/arm/cpu/armv7/lowlevel_init.S|  4 +-
 arch/arm/cpu/armv7/s5p-common/Makefile|  2 +-
 arch/arm/cpu/armv7/start.S|  2 +-
 arch/arm/cpu/armv7/sunxi/Makefile |  4 +-
 arch/arm/cpu/armv8/Makefile   | 12 +--
 arch/arm/cpu/armv8/cache_v8.c |  2 +-
 arch/arm/cpu/armv8/fsl-layerscape/Makefile|  2 +-
 arc

  1   2   3   4   5   6   7   8   9   10   >