Commit graph

89905 commits

Author SHA1 Message Date
Simon Glass
1047b5340c bootstd: Introduce programmatic boot
At present bootstd requires CONFIG_CMDLINE to operate. Add a new
'programmatic' boot which can be used when no command line is available.
For now it does almost nothing, since most bootmeths require the
command line.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13 11:51:24 -05:00
Simon Glass
984e6fedb5 bootm: Reduce arguments to bootm_find_other()
Rather than passing the full list of command arguments, pass only those
which are needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
65f0bfe28a bootm: Add a function to check overlap
Move this code into a function to reduce code size and make it easier
to understand. Drop the unnecessary 0x to help a little with code size.

Use this in bootm_find_images()

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
3ac85bdc6a bootm: Adjust the parameters of bootm_find_images()
Rather than passing it all the command-line args, pass in the pieces
that it needs. These are the image address, the ramdisk address/name
and the FDT address/name.

Ultimately this will allow usage of this function without being called
from the command line.

Move the function comment to the header file and tidy it a little.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13 11:51:24 -05:00
Simon Glass
b020254d71 bootm: optee: Drop special call to bootm_find_other()
The normal bootm flow calls bootm_find_other() can call the
BOOTM_STATE_FINDOTHER state as part of its processing. Fix the
condition there so that this hack can be removed.

Also drop the confusing check for the OS type, since do_bootm_tee() is
only called if the condition is met - see bootm_os_get_boot_func()

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13 11:51:24 -05:00
Simon Glass
e2fc90e5ad bootm: efi: Drop special call to bootm_find_other()
The normal bootm flow calls bootm_find_other() can call the
BOOTM_STATE_FINDOTHER state as part of its processing. Fix the
condition there so that this hack can be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13 11:51:24 -05:00
Simon Glass
46aee252af bootm: Simplify Android ramdisk addr in bootm_find_images()
The Android mechanism uses the loadaddr envrionment-variable to get the
load address, if none is provided. This is equivalent to
image_load_addr so use that instead, converting it to a string as
needed.

This change will permit passing img_addr to this function, in a future
change.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
96456285c2 bootm: Reduce arguments to boot_get_loadables()
This function only uses two arguments. The 'arch' always has a constant
value, so drop it. This simplifies the function call.

Tidy up the function comment while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
745367b218 bootm: Reduce arguments to boot_get_fpga()
This function only uses two arguments. The 'arch' always has a constant
value, so drop it. This simplifies the function call.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
0aa923aba5 bootm: Reduce arguments to boot_get_fdt()
This function only uses one argument from bootm (argv[2]) so pass it in
directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
ba5e3f7f78 bootm: Pass image buffer to boot_get_fdt()
Rather than having boot_get_fdt() calculate this, move the calculation
into the caller. This removes the access to argv[0] in this function,
so we can later refactor it to just accept argv[2] instead of the whole
argv[].

Move the function comment to the header file and fix the u8 argument,
while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
972d524893 bootm: Drop #ifdef in bootm_find_images()
The OF_LIBFDT #ifdef makes it harder to use a local variable for that
code block. Convert it to if() instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-12-13 11:51:24 -05:00
Simon Glass
813f75d858 fdt: Allow use of fdt_support inside if() statements
Most of the fdt_support.h header file is included only if OF_LIBFDT or
OF_CONTROL are enabled. This means that calling functions defined in
that file must happen inside an #ifdef

This is unnecessary, so reduce the condition to just !USE_HOSTCC

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
8eda15bc6a bootm: Reduce arguments to boot_get_ramdisk()
This function normally only uses one argument so pass it in directly.
Move comments to the header file so could one day include these
functions in API docs. Fix up the u8 argument while here, since it
avoids the compiler having to mask the value on some machines.

The Android case here is bit strange, since it can use argv[0], so deal
with that in the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
3e3bd5bda7 bootm: Reduce arguments to bootm_find_os()
This function only uses one argument so pass it in directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
b13e94886c bootm: Move error printing out of boot_get_kernel()
The same error message is printed in two places. Move it out to the
caller so we can avoid passing in the command name. Leave the bootstage
handling where it is.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
bdfa1b6785 bootstage: Drop BOOTSTAGE_ID_FIT_KERNEL_INFO
This is a misnomer since we don't necessarily know that the image is a
FIT. Use the existing BOOTSTAGE_ID_CHECK_IMAGETYPE instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
4c76f5e49a bootm: Use the error return from boot_get_kernel()
Rather than looking for a zero-sized image, use the error code returned
to determine if things are OK.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
4f77169c94 bootm: Adjust position of unmap_sysmem() in boot_get_kernel()
These unmaps should happen regardless of the return value. Move them
before the 'return' statement.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
7721e71f03 bootm: Adjust boot_get_kernel() to return an error
This function obtains lots of error codes and then throws them away.
Update it to return the error, moving the image pointer to an
argument.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
429acb38db image: Document error codes from fit_image_load()
Put a list of these in the function documentation so it is easier to
decode what went wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
820110c453 bootm: Reduce arguments to boot_get_kernel()
This function only uses one argument and just needs to know the name of
the command which called it. Adjust the function to use only what it
needs. This will make it easier to call from a non-command context.

Tidy up the function comment while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
530cc4797f image: Tidy up genimg_get_kernel_addr_fit()
This function does not modify its first argument, so mark it const. Also
move the comments to the header file and expand them to provide more
useful information.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
7f3b1ee3b2 bootm: Move boot_get_kernel() higher in the file
Move this code and image_get_kernel() higher in the file to avoid the
need for a forward declaration.

No attempt is made to remove #ifdefs or adjust the code in any other
way.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
921070bcdc bootm: Simplify arguments for bootm_pre_load()
Move the argument decoding to the caller, to avoid needing to pass the
command-line arguments.

Add a function comment while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2023-12-13 11:51:24 -05:00
Simon Glass
a50e886a7f bootm: Drop arguments from bootm_start()
This function does not use its arguments. Drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-13 11:51:24 -05:00
Simon Glass
e62714ca5f bootstd: Add missing header file from bootdev.h
Add a dm/uclass-id.h to the bootdev header file, since it uses
enum uclass_id

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-13 11:51:24 -05:00
Simon Glass
10c398d6e4 treewide: Tidy up semicolon after command macros
The U_BOOT_CMD_COMPLETE() macro has a semicolon at the end, perhaps
inadvertently. Some code has taken advantage of this.

Tidy this up by dropping the semicolon from the macro and adding it to
macro invocations as required.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-13 11:51:24 -05:00
Simon Glass
f7fac5e7f5 mmc: env: Unify the U_BOOT_ENV_LOCATION conditions
The declaration of U_BOOT_ENV_LOCATION() uses a different #ifdef
condition from the code it calls. Use the same condition to avoid a
build warning if CONFIG_CMD_SAVEENV is disabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-13 11:51:24 -05:00
Simon Glass
1d38722e01 README: Correct docs for CONFIG_SPL_BUILD
This option is defined in both SPL and TPL builds, so correct the docs
related to this. Also point to spl_phase() which is normally a better
option. Mention VPL as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-12-13 11:51:24 -05:00
Simon Glass
b1f8b56f45 arm: x86: Drop discarding of command linker-lists
Since we can now cleanly disable CMDLINE when needed, drop the rules
which discard the command code.  It will not be built in the first
place.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-12-13 11:51:24 -05:00
Sean Anderson
1125e291fb bootm: Enable legacy VxWorks booting from FITs
This works without issue, so don't fail.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2023-11-16 16:21:38 -05:00
Tom Rini
be0724601a Introduce STM32MP2 SoCs family support
Add STM32MP257F-EV1 board
 -----BEGIN PGP SIGNATURE-----
 
 iQJQBAABCgA6FiEEXyrViUccKBz9c35Jysd4L3sz/6YFAmVR87YcHHBhdHJpY2Uu
 Y2hvdGFyZEBmb3NzLnN0LmNvbQAKCRDKx3gvezP/ph+cD/0YFWkURt5TASxw49MB
 EE8PHjuWFPRVhR/lBX0vUxJRfltbmbJOKeGSZZeRW7LGApDVKVxKdrk2gGeLekJk
 L4i5KHBCDts35v3xfFhfxBYMYgXN7KiCo5Cv49b6ibxNeAUt/zKM1+CmLQWW+O8J
 60LhATQduTHE9/QYiZYJusO4ma+HOSlCgbE+4jwj19Y3DaridBZ0/P+yVarjB6Mo
 j/cpGkQ9YQekx0gD6OJjd13kU8LJ5/qaKpMhLhU5HwnxvSuosy1JX8r9gNA2x5yt
 EqscRJBnQE2pKCIekzETX347Es/vhcYM6YFIGyY40bDT83on2cgxFm4xKAZ4RdNb
 uT4G24AueIiyT3Rpd4vGv9cWuSksSiSxcAa4ouMGAxnNyDwJaJ7HYGqnQ4yA8doR
 VbtwK1bT6LutgMn7ymFAiDEYaeplhF4ybxvXZJT9/qjeMXfwhBGF9UYqQNDUCDah
 8ljbA0jIIV1SIVgYL4jPCwby9D53GGVtQ06SVXiJRhHgVJnkQaojByYU7xS8xrqS
 1j1Ccy9rmpixS4pt589Q1dKoPGiUVgh9Z58PpR9yrCWzIokIL0WTMttG0PkSUJYJ
 VpNuQbsKK3LZ01xbhVpZWauOoKTfK2Fe6XsF04WCP+cK8rM+uV6DeE+bqhnadj/M
 CHJscGOKvhIR3jkF10F5mMJ1RA==
 =E2zX
 -----END PGP SIGNATURE-----

Merge tag 'u-boot-stm32-20231113' of https://source.denx.de/u-boot/custodians/u-boot-stm into next

Introduce STM32MP2 SoCs family support
Add STM32MP257F-EV1 board

[trini: Adjust some includes]
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-11-13 13:35:57 -05:00
Patrice Chotard
01a701994b stm32mp2: initial support
Add initial support for STM32MP2 SoCs family.

SoCs information are available here :
https://www.st.com/content/st_com/en/campaigns/microprocessor-stm32mp2.html

Migrate all MP1 related code into stm32mp1/ directory
Create stm32mp2 directory dedicated for STM32MP2 SoCs.

Common code to MP1, MP13 and MP25 is kept into
arch/arm/mach-stm32/mach-stm32mp directory :
  - boot_params.c
  - bsec
  - cmd_stm32key
  - cmd_stm32prog
  - dram_init.c
  - syscon.c
  - ecdsa_romapi.c

For STM32MP2, it also :
  - adds memory region description needed for ARMv8 MMU.
  - enables early data cache before relocation.
    During the transition before/after relocation, the MMU, initially setup
    at the beginning of DDR, must be setup again at a correct address after
    relocation. This is done in enables_caches() by disabling cache, force
    arch.tlb_fillptr to NULL which will force the MMU to be setup again but
    with a new value for gd->arch.tlb_addr. gd->arch.tlb_addr has been
    updated after relocation in arm_reserve_mmu().

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
970d1673b0 ARM: dts: stm32: Add STM32MP257F Evaluation board support
Add STM32MP257F Evaluation board support. It embeds a STM32MP257FAI SoC,
with 4GB of DDR4, TSN switch (2+1 ports), 2*USB typeA, 1*USB2 typeC,
SNOR OctoSPI, mini PCIe, STPMIC2 for power distribution ...

Sync device tree with kernel v6.6-rc1.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
778f4eaa80 pinctrl: pinctrl_stm32: Add stm32mp2 support
Add stm32mp2 compatible.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
6261cf6abd serial: stm32: Fix AARCH64 compilation warnings
When building with AARCH64 defconfig, we got warnings, fix them
by using registers base address defined as void __iomem * instead of
fdt_addr_t.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
3e0b12af8a stm32mp: bsec: Fix AARCH64 compilation warnings
When building with AARCH64 defconfig, we got warnings, fix them.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
75ba0fd570 stm32mp: dram_init: Limit DDR usage under 4GB boundary for STM32MP
Limit DDR usage under 4GB boundary on STM32MP regardless of
memory size declared in device tree.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrick Delaunay
ee15c72da2 stm32mp: dram_init: Fix AARCH64 compilation warnings
When building with AARCH64 defconfig, we got warnings for debug
message
- format '%x' expects argument of type 'unsigned int',
   but argument 3 has type 'size_t' {aka 'long unsigned int'}).
- format '%lx' expects argument of type 'long unsigned int',
  but argument 2 has type 'phys_addr_t' {aka 'long long unsigned
  int'}

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
dba8d92a3d stm32mp: dram_init: Get RAM size from DT if no RAM driver found
In case there is no RAM driver retrieve RAM size from DT as fallback.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Patrice Chotard
2f9886c668 arm: caches: Make DCACHE_DEFAULT_OPTION accessible for ARM64 arch
This fixes the following compilation error in ARM64:
arch/arm/mach-stm32mp/dram_init.c: In function ‘board_get_usable_ram_top’:
arch/arm/mach-stm32mp/dram_init.c:59:45: error: ‘DCACHE_DEFAULT_OPTION’ undeclared (first use in this function)
   59 |  mmu_set_region_dcache_behaviour(reg, size, DCACHE_DEFAULT_OPTION);
      |                                             ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-11-13 10:55:38 +01:00
Tom Rini
3b6db6901f Merge branch '2023-11-10-improve-semihosting-armv6' into next
To quote the author:
This series has a few fixes for semihosting on ARMv6 and older CPUs. The
first two patches address problems regarding the stack pointer and link
register. U-Boot runs in supervisor mode, so taking a software interrupt
will clobber sp/lr. I think we really should run in system mode, since
it has separate sp/lr registers. To quote ARM DDI 0100I:

> The remaining mode is System mode, which is not entered by any
> exception and has exactly the same registers available as User mode.
> However, it is a privileged mode and is therefore not subject to the
> User mode restrictions. It is intended for use by operating system
> tasks that need access to system resources, but wish to avoid using
> the additional registers associated with the exception modes. Avoiding
> such use ensures that the task state is not corrupted by the
> occurrence of any exception.

However, the processor mode has been supervisor for such a long time
(since relocation got introduced) that I would rather not touch it.
2023-11-10 12:52:33 -05:00
Sean Anderson
47cfdb2192 arm: semihosting: Support semihosting fallback on 32-bit ARM
Add support for a semihosting fallback on 32-bit ARM. The assembly is
lightly adapted from the irq return code, except there is no offset
since lr already points to the correct instruction. The C side is mostly
like ARM64, except we have fewer cases to deal with.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2023-11-10 12:52:33 -05:00
Sean Anderson
6ef83ab6be arm: semihosting: Fix returning from traps on ARMv6 and lower
U-Boot runs in supervisor mode. On ARMv6 and lower, software interrupts
are taken in supervisor mode. When entering an interrupt, the link
register is set to the address of the next instruction. However, if we
are already in supervisor mode, this clobbers the link register. The
debugger can't help us, since by the time it notices we've taken a
software interrupt, the link register is already gone. Work around this
by moving the return address to another register.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2023-11-10 12:52:28 -05:00
Sean Anderson
298c26c5c7 arm: Fix software interrupt handler
When we take a software interrupt, we are already in supervisor mode.
get_bad_stack assumes we are not in supervisor mode so it can clobber
the stack pointer. This causes us to have an invalid stack once that
macro finishes. Revert back to the get_bad_stack_swi macro which was
previously removed.

Fixes: 41623c91b0 ("arm: move exception handling out of start.S files")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2023-11-10 11:55:17 -05:00
Tom Rini
b630f8b3ae scsi: Forceably finish migration to DM_SCSI
The migration deadline for moving to DM_SCSI was v2023.04. A further
reminder was sent out in August 2023 to the remaining platforms that had
not migrated already, and that a few more over the line (or configs
deleted).

With this commit we:
- Rename CONFIG_DM_SCSI to CONFIG_SCSI.
- Remove all of the non-DM SCSI code. This includes removing other
  legacy symbols and code and removes some legacy non-DM AHCI code.
- Some platforms that had previously been DM_SCSI=y && SCSI=n are now
  fully migrated to DM_SCSI as a few corner cases in the code assumed
  DM_SCSI=y meant SCSI=y.

Signed-off-by: Tom Rini <trini@konsulko.com>
2023-11-07 18:36:06 -05:00
Tom Rini
1e4d9dd871 Merge branch '2023-11-07-assorted-big-cleanups' into next
- Merge in changes such that CONFIG_CMDLINE can be disabled and merge
  in a series that starts to remove <common.h> usage.
2023-11-07 18:33:09 -05:00
Tom Rini
d7f592da6e x86: Drop <common.h> from remaining header files
None of these header files need to include <common.h> so we can just
drop that entirely.

Signed-off-by: Tom Rini <trini@konsulko.com>
2023-11-07 14:50:52 -05:00
Tom Rini
e8acfd2bb2 arm: Drop <common.h> from remaining header files
None of these header files need to include <common.h> so we can just
drop that entirely.

Signed-off-by: Tom Rini <trini@konsulko.com>
2023-11-07 14:50:52 -05:00