platform/kernel/u-boot.git
20 months agoMakefile: apply dynamic relocations for LLD
Nick Desaulniers [Mon, 26 Sep 2022 20:47:40 +0000 (20:47 +0000)]
Makefile: apply dynamic relocations for LLD

It seems that for aarch64, unless we apply dynamic relocations to the
location being relocated, we fail to boot.

As Fangrui notes:
  For dynamic relocations using the RELA format (readelf -Wr), GNU ld
  sets the initial content to r_addend; ld.lld doesn't do that by
  default (needs --apply-dynamic-relocs).

Otherwise .rodata appears to be full of NUL-bytes before relocation,
causing crashes when trying to invoke the function pointers in
init_sequence_f from initcall_run_list().

Link: https://reviews.llvm.org/D42797
Suggested-by: Fangrui Song <maskray@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Alistair Delva <adelva@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
20 months agoexamples: standalone: Fix build with LLVM toolchain
Alistair Delva [Mon, 26 Sep 2022 20:47:10 +0000 (20:47 +0000)]
examples: standalone: Fix build with LLVM toolchain

When building the standalone example with llvm, the link step fails:

examples/standalone/libstubs.o: In function `dummy':
include/_exports.h:10: undefined reference to `jt'
include/_exports.h:11: undefined reference to `jt'
include/_exports.h:12: undefined reference to `jt'
include/_exports.h:13: undefined reference to `jt'
include/_exports.h:14: undefined reference to `jt'
examples/standalone/libstubs.o:include/_exports.h:15:
  more undefined references to `jt' follow

Indeed, the standalone libstubs.o does use the jt symbol, but it was
marked 'static' in stubs.c. It's strange how gcc builds are working.

Signed-off-by: Alistair Delva <adelva@google.com>
Cc: Rick Chen <rick@andestech.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
20 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Mon, 10 Oct 2022 19:38:14 +0000 (15:38 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

20 months agoMerge tag 'efi-2023-01-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Mon, 10 Oct 2022 16:14:51 +0000 (12:14 -0400)]
Merge tag 'efi-2023-01-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2023-01-rc1-2

Documentation:

* man-page for cls command
* update build requirements

UEFI

* Fix bugs in the Stop() function of the EFi Driver Binding protocol
  for block devices
* Avoid EFI_CALL() when invoking CloseProtocol()

20 months agousb: gadget: fastboot: detach usb on reboot commands
Mattijs Korpershoek [Fri, 7 Oct 2022 09:38:22 +0000 (11:38 +0200)]
usb: gadget: fastboot: detach usb on reboot commands

When host issues "fastboot reboot fastboot", it's expected that the
board drops the USB connection before resetting.

On some boards, such as Khadas VIM3L and SEI610, this is not the case.

We observe the following error:
$ fastboot reboot fastboot
Rebooting into fastboot                            OKAY [  0.004s]
fastboot: error: Failed to boot into userspace fastboot; one or more components might be unbootable.

This does not happen when we use the RST button on the board.
It can be reproduced in linux with:
  # echo b > /proc/sysrq-trigger

In this case, we hit a undefined hardware behavior, where D+ and D-
are in an unknown state. Therefore the host can't detect usb
disconnection.

Make sure we always call usb_gadget_release() when a "fastboot reboot"
command is issued.

Note: usb_gadget_release() should be called before g_dnl_unregister()
because g_dnl_unregister() triggers a complete() call on each
endpoint (thus calling do_reset()).

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
20 months agousb: ehci: Remove unused ehci_{setup,shutdown}_phy() helpers
Patrice Chotard [Tue, 6 Sep 2022 06:15:29 +0000 (08:15 +0200)]
usb: ehci: Remove unused ehci_{setup,shutdown}_phy() helpers

Remove unused ehci_{setup,shutdown}_phy() helpers now replaced by
generic_{setup,shutdown}_phy().

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
20 months agousb: ehci: Make usage of generic_{setup,shutdown}_phy() helpers
Patrice Chotard [Tue, 6 Sep 2022 06:15:28 +0000 (08:15 +0200)]
usb: ehci: Make usage of generic_{setup,shutdown}_phy() helpers

Replace ehci_setup_phy() and ehci_shutdown_phy () by respectively
generic_setup_phy() and generic_shutdown_phy().

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
20 months agousb: ohci: Make usage of generic_{setup,shutdown}_phy() helpers
Patrice Chotard [Tue, 6 Sep 2022 06:15:27 +0000 (08:15 +0200)]
usb: ohci: Make usage of generic_{setup,shutdown}_phy() helpers

Replace ohci_setup_phy() and ohci_shutdown_phy () by respectively
generic_setup_phy() and generic_shutdown_phy().

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
20 months agophy: Add generic_{setup,shutdown}_phy() helpers
Patrice Chotard [Tue, 6 Sep 2022 06:15:26 +0000 (08:15 +0200)]
phy: Add generic_{setup,shutdown}_phy() helpers

In drivers usb/host/{ehci,ohci}-generic.c, {ehci,ohci}_setup_phy() and
{ehci,ohci}_shutdown_phy() shares 95% of common code.
Factorize this code in new generic_{setup,shudown}_phy() functions.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
20 months agousb: gadget: Clean up Makefile ifdeffery
Marek Vasut [Tue, 23 Aug 2022 17:06:51 +0000 (19:06 +0200)]
usb: gadget: Clean up Makefile ifdeffery

Take the USB_ETHER ifdef block apart and make use of obj-$(VAR) instead
to include the source files in build. The duplicate CI_UDC entry is now
removed, the USB_DEVICE ifdef is now reduced to core.o ep.o addition,
the ether.o can be conditionally compiled in using USB_ETHER.

No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
20 months agousb: Add missing guard around env_get() in usb_hub
Marek Vasut [Mon, 19 Sep 2022 19:19:23 +0000 (21:19 +0200)]
usb: Add missing guard around env_get() in usb_hub

The env_get() might be undefined in case ENV_SUPPORT is disabled,
which may happen e.g. in SPL. Add missing ifdef guard around the
env_get() to prevent build failure.

Signed-off-by: Marek Vasut <marex@denx.de>
Tested-by: Fabio Estevam <festevam@denx.de>
20 months agoefi_loader: reformat efi_disk_add_dev()
Heinrich Schuchardt [Fri, 7 Oct 2022 09:03:01 +0000 (11:03 +0200)]
efi_loader: reformat efi_disk_add_dev()

Make it clearer why InstallMultipleProtocolInterfaces is invoked with two
NULLs:

* rename guid to esp_guid
* put protocol GUIDs and the related interfaces on same lines
* add comment

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_loader: simplify efi_set_load_options()
Heinrich Schuchardt [Fri, 7 Oct 2022 14:21:28 +0000 (16:21 +0200)]
efi_loader: simplify efi_set_load_options()

* Replace the OpenProtocol() call by efi_search_protocol().
* Remove the CloseProtocol() call.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_driver: use efi_close_protocol
Heinrich Schuchardt [Fri, 7 Oct 2022 14:12:54 +0000 (16:12 +0200)]
efi_driver: use efi_close_protocol

Avoid EFI_CALL() by using efi_close_protocol().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_loader: internal CloseProtocol
Heinrich Schuchardt [Fri, 7 Oct 2022 13:18:15 +0000 (15:18 +0200)]
efi_loader: internal CloseProtocol

Allow avoiding using EFI_CALL() when closing a protocol by providing an
internal function.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_loader: CloseProtocol in efi_fmp_find
Heinrich Schuchardt [Fri, 7 Oct 2022 13:29:52 +0000 (15:29 +0200)]
efi_loader: CloseProtocol in efi_fmp_find

The CloseProtocol() boot service requires a handle as first argument.
Passing the protocol interface is incorrect.

CloseProtocol() only has an effect if called with a non-zero value for
agent_handle. HandleProtocol() uses an opaque agent_handle when invoking
OpenProtocol() (currently NULL). Therefore HandleProtocol() should be
avoided.

* Replace the LocateHandle() call by efi_search_protocol().
* Remove the CloseProtocol() call.

Fixes: 8d99026f0697 ("efi_loader: capsule: support firmware update")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_loader: CloseProtocol in tcg2_measure_gpt_data
Heinrich Schuchardt [Fri, 7 Oct 2022 12:28:18 +0000 (14:28 +0200)]
efi_loader: CloseProtocol in tcg2_measure_gpt_data

The CloseProtocol() boot service requires a handle as first argument.
Passing the protocol interface is incorrect.

CloseProtocol() only has an effect if called with a non-zero value for
agent_handle. HandleProtocol() uses an opaque agent_handle when invoking
OpenProtocol() (currently NULL). Therefore HandleProtocol() should be
avoided.

* Replace the LocateHandle() call by efi_search_protocol().
* Remove the CloseProtocol() call.
* Remove a superfluous goto.

Fixes: ce3dbc5d080d ("efi_loader: add UEFI GPT measurement")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_driver: fix efi_uc_stop()
Heinrich Schuchardt [Fri, 7 Oct 2022 21:53:38 +0000 (23:53 +0200)]
efi_driver: fix efi_uc_stop()

We must always call EFI_EXIT() when returning from an EFIAPI function.

Fixes: 05ef48a2484b ("efi_driver: EFI block driver")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_loader: don't export efi_remove_all_protocols
Heinrich Schuchardt [Fri, 7 Oct 2022 14:55:29 +0000 (16:55 +0200)]
efi_loader: don't export efi_remove_all_protocols

This function is only used inside efi_boottime.c and is not safe to use
outside of this context.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_loader: printf code in efi_disk_get_device_name()
Heinrich Schuchardt [Fri, 7 Oct 2022 10:55:16 +0000 (12:55 +0200)]
efi_loader: printf code in efi_disk_get_device_name()

part is unsigned. So it must be printed with %u.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agodoc: describe usage of virt-make-fs for testing
Heinrich Schuchardt [Fri, 7 Oct 2022 23:19:22 +0000 (01:19 +0200)]
doc: describe usage of virt-make-fs for testing

We want tests to avoid the usage of sudo. Describe that virt-make-fs can
generate disk images without being root.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agodoc: add python3-filelock python3-pytest-xdist
Heinrich Schuchardt [Fri, 7 Oct 2022 22:46:35 +0000 (00:46 +0200)]
doc: add python3-filelock python3-pytest-xdist

Packages python3-filelock python3-pytest-xdist as required to run
'make tests'. Add them to the required packages list in the documentation.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agodoc: man-page for cls
Heinrich Schuchardt [Fri, 7 Oct 2022 18:51:35 +0000 (20:51 +0200)]
doc: man-page for cls

Provide a man-page for the cls command.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agocmd: CMD_CLS should not depend on video
Heinrich Schuchardt [Fri, 7 Oct 2022 18:36:12 +0000 (20:36 +0200)]
cmd: CMD_CLS should not depend on video

The cls command works fine on the serial console. There is no reason to
let it depend on the availability of video.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoMerge tag 'u-boot-nand-20221009' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Mon, 10 Oct 2022 12:17:08 +0000 (08:17 -0400)]
Merge tag 'u-boot-nand-20221009' of https://source.denx.de/u-boot/custodians/u-boot-nand-flash

- mtd: Update the function name to 'rfree'
- Support NAND ONFI EDO mode for imx8mn architecture
- dm: clk: add missing stub when CONFIG_CLK is deactivated

20 months agomtd: Update the function name to 'rfree'
Fabio Estevam [Fri, 7 Oct 2022 14:35:53 +0000 (11:35 -0300)]
mtd: Update the function name to 'rfree'

Since commit 8d38a8459b0d ("mtd: Rename free() to rfree()")
the function has been renamed to rfree(), so update the description
inside the mtd_oob_region structure as well.

Fixes: 8d38a8459b0d ("mtd: Rename free() to rfree()")
Reported-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Signed-off-by: Fabio Estevam <festevam@denx.de>
Acked-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agomtd: mxs_nand: Support EDO mode for imx8mn architecture
Michael Trimarchi [Tue, 30 Aug 2022 14:48:47 +0000 (16:48 +0200)]
mtd: mxs_nand: Support EDO mode for imx8mn architecture

Add support for imx8mn architecture in order to run the NAND
in fast edo mode.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agomtd: mxs_nand: get the clock with the right name
Dario Binacchi [Tue, 27 Sep 2022 09:56:33 +0000 (11:56 +0200)]
mtd: mxs_nand: get the clock with the right name

Rename the gpmi_apb_bch clock name to gpmi_bch_apb, as you can find in
the device tree.

Fixes: commit a59691280daca ("MXS_NAND: Add clock support for iMX8")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
20 months agomtd: mxs_nand: don't get the gpmi_apbh_dma clock
Dario Binacchi [Tue, 27 Sep 2022 09:47:29 +0000 (11:47 +0200)]
mtd: mxs_nand: don't get the gpmi_apbh_dma clock

This clock name is not present in any U-boot and Linux kernel device
tree.

Fixes: commit a59691280daca ("MXS_NAND: Add clock support for iMX8")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
20 months agoimx: gpmi: Add register needed to control nand bus timing
Michael Trimarchi [Tue, 30 Aug 2022 14:47:51 +0000 (16:47 +0200)]
imx: gpmi: Add register needed to control nand bus timing

It is used as delay for gpmi write strobe.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agoclk: imx: clk-imx8mn add gpmi nand clocks
Michael Trimarchi [Tue, 30 Aug 2022 14:45:20 +0000 (16:45 +0200)]
clk: imx: clk-imx8mn add gpmi nand clocks

Add gpmi nand clock. Those clock can be used in mxs nand driver
to run nand to EDO mode 5, 4, ...

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agoclk: imx: gate2 support shared counter and relative clock functions
Michael Trimarchi [Tue, 30 Aug 2022 14:41:38 +0000 (16:41 +0200)]
clk: imx: gate2 support shared counter and relative clock functions

Add shared counter in order to avoid to swich off clock that
are already used.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agodm: clk: add missing stub when CONFIG_CLK is deactivated
Dario Binacchi [Tue, 27 Sep 2022 17:18:19 +0000 (19:18 +0200)]
dm: clk: add missing stub when CONFIG_CLK is deactivated

Add missing stub for functions [devm_]clk_...() when CONFIG_CLK is
deactivated.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
20 months agomtd: nand: Fix SPL build after migration of CONFIG_SYS_NAND_SELF_INIT to Kconfig
Roger Quadros [Wed, 28 Sep 2022 11:42:35 +0000 (14:42 +0300)]
mtd: nand: Fix SPL build after migration of CONFIG_SYS_NAND_SELF_INIT to Kconfig

This fixes the below build error if nand.c is included in
an SPL build.

/work/u-boot/drivers/mtd/nand/raw/nand.c: In function ‘nand_init_chip’:
/work/u-boot/drivers/mtd/nand/raw/nand.c:82:28: error: ‘nand_chip’ undeclared (first use in this function)
   82 |  struct nand_chip *nand = &nand_chip[i];
      |                            ^~~~~~~~~
/work/u-boot/drivers/mtd/nand/raw/nand.c:82:28: note: each undeclared identifier is reported only once for each function it appears in
/work/u-boot/drivers/mtd/nand/raw/nand.c:84:20: error: ‘base_address’ undeclared (first use in this function); did you mean ‘base_addr’?
   84 |  ulong base_addr = base_address[i];
      |                    ^~~~~~~~~~~~
      |                    base_addr

Fixes: 068c41f1cc77 ("Finish conversion CONFIG_SYS_NAND_SELF_INIT to Kconfig")
Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
20 months agoMerge tag 'efi-2023-01-rc1' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Fri, 7 Oct 2022 15:51:05 +0000 (11:51 -0400)]
Merge tag 'efi-2023-01-rc1' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2023-01-rc1

UEFI:

* Provide driver binding protocol to registered events for block devices
* Code simplification and refactoring
* Fix pylint errors in test_efi_secboot

Other:

* Improve checks for register ranges

20 months agoMerge branch '2022-10-07-riscv-toolchain-update'
Tom Rini [Fri, 7 Oct 2022 15:25:05 +0000 (11:25 -0400)]
Merge branch '2022-10-07-riscv-toolchain-update'

- Update RISC-V to use 32bit or 64bit toolchains, depending on if we're
  building for 32bit or 64bit CPUs. This requires updating the Docker
  container as well to have the 32bit toolchain.

20 months agoMerge branch '2022-10-06-assorted-platform-and-board-updates'
Tom Rini [Fri, 7 Oct 2022 15:23:19 +0000 (11:23 -0400)]
Merge branch '2022-10-06-assorted-platform-and-board-updates'

- Assorted platform updates for developerbox, armv8 platforms in
  general, TI K3 and AM65 platforms, nuvoton NPCM845 SoC and then clock
  driver, ftgpio010 support, and common/board_f cleanups.

20 months agoriscv: Fix build against binutils 2.38
Alexandre Ghiti [Mon, 3 Oct 2022 16:07:54 +0000 (18:07 +0200)]
riscv: Fix build against binutils 2.38

The following description is copied from the equivalent patch for the
Linux Kernel proposed by Aurelien Jarno:

>From version 2.38, binutils default to ISA spec version 20191213. This
means that the csr read/write (csrr*/csrw*) instructions and fence.i
instruction has separated from the `I` extension, become two standalone
extensions: Zicsr and Zifencei. As the kernel uses those instruction,
this causes the following build failure:

arch/riscv/cpu/mtrap.S: Assembler messages:
arch/riscv/cpu/mtrap.S:65: Error: unrecognized opcode `csrr a0,scause'
arch/riscv/cpu/mtrap.S:66: Error: unrecognized opcode `csrr a1,sepc'
arch/riscv/cpu/mtrap.S:67: Error: unrecognized opcode `csrr a2,stval'
arch/riscv/cpu/mtrap.S:70: Error: unrecognized opcode `csrw sepc,a0'

Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Christian Stewart <christian@paral.in>
Reviewed-by: Rick Chen <rick@andestech.com>
20 months agobuildman: differentiate between riscv32, riscv64
Heinrich Schuchardt [Mon, 3 Oct 2022 16:07:53 +0000 (18:07 +0200)]
buildman: differentiate between riscv32, riscv64

riscv32 needs a different toolchain than riscv64

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Rick Chen <rick@andestech.com>
20 months agodocker: install riscv32 toolchain
Heinrich Schuchardt [Mon, 3 Oct 2022 16:07:52 +0000 (18:07 +0200)]
docker: install riscv32 toolchain

For building riscv32 targets we should use the riscv32 toolchain.
Add it to the Docker image.

Drop the riscv toolchain-alias as we do not need it in future.

While in here, update to the latest "jammy" tag.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Rick Chen <rick@andestech.com>
[trini: Update to latest jammy tag]
Signed-off-by: Tom Rini <trini@konsulko.com>
20 months agoclk: nuvoton: Add support for NPCM845
Jim Liu [Tue, 27 Sep 2022 08:45:16 +0000 (16:45 +0800)]
clk: nuvoton: Add support for NPCM845

Add clock controller driver for NPCM845

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Acked-by: Sean Anderson <seanga2@gmail.com>
20 months agoarm: nuvoton: Add support for Nuvoton NPCM845 BMC
Jim Liu [Tue, 27 Sep 2022 08:45:15 +0000 (16:45 +0800)]
arm: nuvoton: Add support for Nuvoton NPCM845 BMC

Add basic support for the Nuvoton NPCM845 EVB (Arbel).

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
20 months agonet: ti: am65-cpsw-nuss: Enable MDIO manual mode
Ravi Gunasekaran [Thu, 22 Sep 2022 09:51:24 +0000 (15:21 +0530)]
net: ti: am65-cpsw-nuss: Enable MDIO manual mode

For the TI SoCs affected by errata i2329, enable MDIO manual
mode by default

Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
20 months agonet: ti: cpsw-mdio: Add workaround for errata i2329
Ravi Gunasekaran [Thu, 22 Sep 2022 09:51:23 +0000 (15:21 +0530)]
net: ti: cpsw-mdio: Add workaround for errata i2329

In certain TI SoCs, on the CPSW and ICSS peripherals, there is
a possibility that the MDIO interface returns corrupt data on
MDIO reads or writes incorrect data on MDIO writes. There is also
a possibility for the MDIO interface to become unavailable until
the next peripheral reset.

The workaround is to configure the MDIO in manual mode and disable the
MDIO state machine and emulate the MDIO protocol by reading and writing
appropriate fields in MDIO_MANUAL_IF_REG register of the MDIO controller
to manipulate the MDIO clock and data pins.

More details about the errata i2329 and the workaround is available in:
https://www.ti.com/lit/er/sprz487a/sprz487a.pdf

Add implementation to disable MDIO state machine, configure MDIO in manual
mode and provide software MDIO read and writes via MDIO bitbanging. Allow
the MDIO to be initialized based on the need for manual mode.

Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
20 months agodma: ti: k3-udma: Fix 'SZ_64K’ undeclared error
Dhruva Gole [Tue, 20 Sep 2022 05:26:02 +0000 (10:56 +0530)]
dma: ti: k3-udma: Fix 'SZ_64K’ undeclared error

Include linux/sizes.h because it defines SZ_64K which is used in many
places inside k3-udma.c
This fixes the error: ‘SZ_64K’ undeclared which appears during build
time

Signed-off-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
20 months agoarmv8: cache_v8: Fix pgtables setup when MMU is already enabled
Pali Rohár [Wed, 14 Sep 2022 11:37:46 +0000 (13:37 +0200)]
armv8: cache_v8: Fix pgtables setup when MMU is already enabled

When MMU is already enabled then dcache_enable() does not call mmu_setup()
and so setup_all_pgtables() is also never called.

In this situation when some driver calls mmu_set_region_dcache_behaviour()
function then U-Boot crashes with error message:

    Emergency page table not setup.

Fix this issue by explicitly calling setup_all_pgtables() in dcache_enable()
function near condition for mmu_setup().

This change fixes chainloading U-Boot from U-Boot on Turris Mox board which
uses mvneta ethernet driver which calls mmu_set_region_dcache_behaviour().

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
20 months agocommon/board_f: drop ifdefs around header includes
Ovidiu Panait [Tue, 13 Sep 2022 18:31:29 +0000 (21:31 +0300)]
common/board_f: drop ifdefs around header includes

Drop the remaining ifdef around spl.h include.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
20 months agocommon/board_f: introduce arch_setup_dest_addr()
Ovidiu Panait [Tue, 13 Sep 2022 18:31:28 +0000 (21:31 +0300)]
common/board_f: introduce arch_setup_dest_addr()

In order to move ppc-specific code out of setup_dest_addr(), provide an
arch-specific variant arch_setup_dest_addr(), that can be used by
architecture code to fix up the initial reloc address.

It is called at the end of setup_dest_addr() initcall and the default
implementation is a nop stub.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
20 months agocommon/board_f: move CONFIG_MACH_TYPE logic to arch/arm/lib/bdinfo.c
Ovidiu Panait [Tue, 13 Sep 2022 18:31:27 +0000 (21:31 +0300)]
common/board_f: move CONFIG_MACH_TYPE logic to arch/arm/lib/bdinfo.c

asm/mach_type.h header and CONFIG_MACH_TYPE macro are arm-specific, so move
related bdinfo logic to arch_setup_bdinfo() in arch/arm/lib/bdinfo.c.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
20 months agocommon/board_f: remove XTRN_DECLARE_GLOBAL_DATA_PTR dead code
Ovidiu Panait [Tue, 13 Sep 2022 18:31:26 +0000 (21:31 +0300)]
common/board_f: remove XTRN_DECLARE_GLOBAL_DATA_PTR dead code

The XTRN_DECLARE_GLOBAL_DATA_PTR declarations in ppc code are permanently
commented out, so there are no users for this macro:
 #if 1
   #define DECLARE_GLOBAL_DATA_PTR   register volatile gd_t *gd asm ("r2")
 #else /* We could use plain global data, but the resulting code is bigger */
   #define XTRN_DECLARE_GLOBAL_DATA_PTR   extern
   #define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR \
                                       gd_t *gd
 #endif

Remove all references to this macro, but add a documentation note regarding
the possibility of using plain global data for the GD pointer.

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
20 months agoboard: developerbox: move mem_map setup later
Jassi Brar [Mon, 12 Sep 2022 17:05:29 +0000 (12:05 -0500)]
board: developerbox: move mem_map setup later

dram_init() can't modify global/static variables, so
move the mem_map setup later when bss is available.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
20 months agoboard: developerbox: use identity mapping for >4GB
Jassi Brar [Mon, 12 Sep 2022 17:05:15 +0000 (12:05 -0500)]
board: developerbox: use identity mapping for >4GB

Identity-map the second and later memory banks which are located >4GB.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
20 months agogpio: ftgpio010: Add support for Faraday Technology FTGPIO010
Sergei Antonov [Mon, 12 Sep 2022 10:09:15 +0000 (13:09 +0300)]
gpio: ftgpio010: Add support for Faraday Technology FTGPIO010

Add Faraday Technology's FTGPIO010 controller driver.

Signed-off-by: Sergei Antonov <saproj@gmail.com>
20 months agocmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol
Ilias Apalodimas [Thu, 6 Oct 2022 13:08:44 +0000 (16:08 +0300)]
cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol

In general handles should only be deleted if the last remaining protocol
is removed.  Instead of explicitly calling
efi_create_handle -> efi_add_protocol -> efi_delete_handle which blindly
removes all protocols from a handle before removing it,  use
InstallMultiple/UninstallMultiple which adheres to the EFI spec and only
deletes a handle if there are no additional protocols present

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
20 months agoefi_loader: define internal implementations of install/uninstallmultiple
Ilias Apalodimas [Thu, 6 Oct 2022 13:08:46 +0000 (16:08 +0300)]
efi_loader: define internal implementations of install/uninstallmultiple

A following patch is cleaning up the core EFI code trying to remove
sequences of efi_create_handle, efi_add_protocol.

Although this works fine there's a problem with the latter since it is
usually combined with efi_delete_handle() which blindly removes all
protocols on a handle and deletes the handle.  We should try to adhere to
the EFI spec which only deletes a handle if the last instance of a protocol
has been removed.  Another problem is that efi_delete_handle() never checks
for opened protocols,  but the EFI spec defines that the caller is
responsible for ensuring that there are no references to a protocol
interface that is going to be removed.

So let's fix this by replacing all callsites of
efi_create_handle(), efi_add_protocol() , efi_delete_handle() with
Install/UninstallMultipleProtocol.

In order to do that redefine functions that can be used by the U-Boot
proper internally and add '_ext' variants that will be used from the
EFI API

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
20 months agoMAINTAINERS: get rid of the optee variables entry
Ilias Apalodimas [Thu, 6 Oct 2022 08:41:24 +0000 (11:41 +0300)]
MAINTAINERS: get rid of the optee variables entry

Since I am co-maintaining EFI with Heinrich remove the special
entry for EFI variable storage via OP-TEE

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_driver: move event registration to driver
Heinrich Schuchardt [Thu, 6 Oct 2022 05:29:41 +0000 (07:29 +0200)]
efi_driver: move event registration to driver

Move the registration of events for the addition and removal of block
devices to the block device driver. Here we can add a reference to the
EFI Driver Binding protocol as context.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_selftest: rename event_notify
Heinrich Schuchardt [Thu, 6 Oct 2022 05:28:19 +0000 (07:28 +0200)]
efi_selftest: rename event_notify

A function event_notify() exists. We should not use the same name for and
EFI event. Rename events in unit tests.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_driver: add init function to EFI block driver
Heinrich Schuchardt [Wed, 5 Oct 2022 09:28:47 +0000 (11:28 +0200)]
efi_driver: add init function to EFI block driver

For handling added and removed block devices we need to register events
which has to be done when the driver is installed.

This patch only creates an empty init function that will be filled with
code later on. The function needs to be called before any EFI block devices
are used. Move the efi_driver_init() call to early init.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_driver: provide driver binding protocol to bind function
Heinrich Schuchardt [Tue, 4 Oct 2022 17:12:59 +0000 (19:12 +0200)]
efi_driver: provide driver binding protocol to bind function

DisconnectController() is based on the open protocol information created
when the driver opens a protocol with BY_CHILD_CONTROLLER or BY_DRIVER.

To create an open protocol information it is required to supply the handle
of the driver as agent handle. This information is available as field
DriverBindingHandle in the driver binding protocol.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_driver: reformat efi_block_device.c
Heinrich Schuchardt [Tue, 4 Oct 2022 16:53:34 +0000 (18:53 +0200)]
efi_driver: reformat efi_block_device.c

* use Sphinx documentation style
* correct indentation

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agodoc: documentation of EFI driver binding protocol
Heinrich Schuchardt [Tue, 4 Oct 2022 16:28:24 +0000 (18:28 +0200)]
doc: documentation of EFI driver binding protocol

* Convert code comments in include/efi_driver.h to Sphinx style.
* Add include/efi_driver.h to the HTML documentation.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_driver: carve out function to create block device
Heinrich Schuchardt [Tue, 4 Oct 2022 14:19:30 +0000 (16:19 +0200)]
efi_driver: carve out function to create block device

* Carve out function efi_bl_create_block_device() from efi_bl_bind().
* Add a check for U-Boot devices to efi_bl_bind().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agocmd: simplify command efidebug
Heinrich Schuchardt [Tue, 4 Oct 2022 13:31:17 +0000 (15:31 +0200)]
cmd: simplify command efidebug

Currently we have subcommands 'efidebug dh' which shows protocols per
handle and 'efidebug devices' which shows the device path. None shows which
U-Boot device matches the handle.

Change 'efidebug dh' to show the device path and the U-Boot device if any
is associated with the handle.

Remove 'efidebug devices'.

Old output of 'efidebug dh':

    Handle           Protocols
    ================ ====================
    000000001b22e690 Device Path, Block IO
    000000001b22e800 Device Path, Block IO, system, Simple File System

New output of 'efidebug dh':

    000000001b22e690 (host0)
      /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00)
      Block IO

    000000001b22e800 (host0:1)
      /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/VenHw(bbe4e671-5773-4ea1-9aab-3a7dbf40c482,00)/HD(1,GPT,7e5c17c5-3f5f-49d0-ae96-511b21d7f273,0x800,0x3f7df)
      Block IO
      system
      Simple File System

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_driver: simplify efi_uc_stop(), call efi_free_pool()
Heinrich Schuchardt [Tue, 4 Oct 2022 10:50:51 +0000 (12:50 +0200)]
efi_driver: simplify efi_uc_stop(), call efi_free_pool()

We have exported efi_free_pool(). There is no need to use EFI_CALL().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_driver: fix error handling
Heinrich Schuchardt [Mon, 3 Oct 2022 08:35:35 +0000 (10:35 +0200)]
efi_driver: fix error handling

If creating the block device fails,

* delete all created objects and references
* close the protocol interface on the controller

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi_loader: function to unlink udevice and handle
Heinrich Schuchardt [Mon, 3 Oct 2022 07:47:51 +0000 (09:47 +0200)]
efi_loader: function to unlink udevice and handle

When deleting a device or a handle we must remove the link between the two
to avoid dangling references.

Provide function efi_unlink_dev() for this purpose.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agotest: fix some pylint errors in test_efi_secboot
Heinrich Schuchardt [Sat, 1 Oct 2022 18:55:14 +0000 (20:55 +0200)]
test: fix some pylint errors in test_efi_secboot

* Remove unused import
* Provide module docstring

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
20 months agoefi_loader: efi_dp_part_node check dp_alloc return value
Heinrich Schuchardt [Thu, 6 Oct 2022 11:36:02 +0000 (13:36 +0200)]
efi_loader: efi_dp_part_node check dp_alloc return value

dp_alloc() may return NULL. This needs to be caught.

Fixes: 98d48bdf415e ("efi_loader: provide a function to create a partition node")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agocmd: simplify do_efi_boot_add()
Heinrich Schuchardt [Thu, 6 Oct 2022 04:48:02 +0000 (06:48 +0200)]
cmd: simplify do_efi_boot_add()

Use efi_convert_string() to convert a UTF-8 to a UTF-16 string.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agocmd: simplify do_env_set_efi()
Heinrich Schuchardt [Thu, 6 Oct 2022 04:52:51 +0000 (06:52 +0200)]
cmd: simplify do_env_set_efi()

Use efi_convert_string() to convert a UTF-8 to a UTF-16 string.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
20 months agoefi: Add string conversion helper
Paul Barker [Wed, 5 Oct 2022 12:18:35 +0000 (13:18 +0100)]
efi: Add string conversion helper

Signed-off-by: Paul Barker <paul.barker@sancloud.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
20 months agodoc: typo 'it it' in doc/develop/package/index.rst
Heinrich Schuchardt [Tue, 4 Oct 2022 20:02:46 +0000 (22:02 +0200)]
doc: typo 'it it' in doc/develop/package/index.rst

%s/it it/it/

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoregmap: fix range checks
Heinrich Schuchardt [Thu, 29 Sep 2022 22:27:06 +0000 (22:27 +0000)]
regmap: fix range checks

On the 32bit ARM sandbox 'dm ut dm_test_devm_regmap' fails with an abort.
This is due to incorrect range checks.

On 32-bit systems the size of size_t and int is both 32 bit. The expression
(offset + val_len) is bound to overflow if offset == -1. Add an overflow
check.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
20 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Thu, 6 Oct 2022 12:44:23 +0000 (08:44 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- Kirkwood: remove km/keymile kirkwood boards (Holger)
- mtd: nand: pxa3xx: simplify ECC hardware parameters (Chris)
- tools: kwbimage: Verify maximal kwbimage header size (Pali)
- mvebu: Add support for programming LD eFuse on Armada 385 (Pali)
- mvebu: Misc timer improvements / cleanup (Stefan)

20 months agoarm: mvebu: turris_omnia: Specify VHV gpio for eFUSE programming
Pali Rohár [Thu, 22 Sep 2022 11:43:46 +0000 (13:43 +0200)]
arm: mvebu: turris_omnia: Specify VHV gpio for eFUSE programming

VHV gpio is connected to MCU and only on updated board design. Without it
eFUSE programming does not work. Omnia MCU driver exports this GPIO to
U-Boot under name mcu_56 and only when it is supported by MCU. So U-Boot
fuse command refuse eFUSE programming on older board design when VHV gpio
is not available.

We tested that Armada 385 without connected VHV gpio can do eFUSE
programming but only for some bits and only sometimes - it is unstable.
And better to be disabled on older board design without VHV gpio support.

Signed-off-by: Pali Rohár <pali@kernel.org>
20 months agoarm: mvebu: Add support for specifying VHV_Enable GPIO
Pali Rohár [Thu, 22 Sep 2022 11:43:45 +0000 (13:43 +0200)]
arm: mvebu: Add support for specifying VHV_Enable GPIO

VHV_Enable GPIO is required to enable during eFuse programming on Armada
SoCs not from 3700 family. Add support for enabling and disabling VHV pin
via GPIO during eFuse programming, when specified.

All details are in Marvell AN-389: ARMADA VHV Power document
(Doc. No. MV-S302545-00 Rev. C, August 2, 2016).

Note that due to HW Errata 3.6 eFuse erroneous burning (Ref #: HWE-3718342)
VHV power must be disabled while core voltage is off to prevent erroneous
eFuse programming.

This is specified in Marvell ARMADA 380/385/388 Functional Errata,
Guidelines, and Restrictions document
(Doc. No. MV-S501377-00 Rev. D, December 1, 2016).

Signed-off-by: Pali Rohár <pali@kernel.org>
20 months agoarm: mvebu: Add support for programming LD0 and LD1 eFuse
Pali Rohár [Thu, 22 Sep 2022 11:43:44 +0000 (13:43 +0200)]
arm: mvebu: Add support for programming LD0 and LD1 eFuse

This patch implements LD eFuse programming support. Armada 385 contains two
LD eFuse lines, each is 256 bit long with one additional lock bit. LD 0
line is mapped to U-Boot fuse bank 64 and LD 1 line to fuse bank 65. U-Boot
32-bit fuse words 0-8 are mapped to LD eFuse line bits 0-255. U-Boot fuse
word 9 is mapped to LD eFuse line lock bit.

So to program LD 1 General Purpose Data line, use U-Boot fuse command:

    => fuse prog -y 65 0 0x76543210
    => fuse prog -y 65 1 0xfedcba98
    => fuse prog -y 65 2 0x76543210
    => fuse prog -y 65 3 0xfedcba98
    => fuse prog -y 65 4 0x76543210
    => fuse prog -y 65 5 0xfedcba98
    => fuse prog -y 65 6 0x76543210
    => fuse prog -y 65 7 0xfedcba98
    => fuse prog -y 65 8 0x1

Signed-off-by: Pali Rohár <pali@kernel.org>
20 months agotimer: orion-timer: Only init timer once
Stefan Roese [Wed, 21 Sep 2022 06:26:42 +0000 (08:26 +0200)]
timer: orion-timer: Only init timer once

Move the code making sure that the timer is initialized only once into
orion_timer_init(), which is called from timer_early_init() and from
orion_timer_probe(). This way the timer is not re-initialized.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Michael Walle <michael@walle.cc>
Cc: Pali Rohár <pali@kernel.org>
20 months agoarm: mvebu: Remove timer.c
Stefan Roese [Wed, 21 Sep 2022 06:26:41 +0000 (08:26 +0200)]
arm: mvebu: Remove timer.c

Since the move to CONFIG_TIMER with support for CONFIG_TIMER_EARLY, this
platform specific init_timer() function is not needed any more. Let's
remove it completely.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Michael Walle <michael@walle.cc>
Cc: Pali Rohár <pali@kernel.org>
20 months agotools: kwbimage: Verify maximal kwbimage header size
Pali Rohár [Sun, 18 Sep 2022 16:39:18 +0000 (18:39 +0200)]
tools: kwbimage: Verify maximal kwbimage header size

BootROM loads kwbimage header to L2-SRAM and BootROM reserve only 192 kB for it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
20 months agomtd: nand: pxa3xx: simplify ECC hardware parameters
Chris Packham [Thu, 25 Aug 2022 04:59:49 +0000 (16:59 +1200)]
mtd: nand: pxa3xx: simplify ECC hardware parameters

Replace the if/else chain in pxa_ecc_init() with a lookup table. This
makes the code more concise and hopefully easier to follow. Remove the
unused ecc_layout tables and replace it with a single dummy one (the
pxa3xx driver has never used this but the mtd subsystem expects it to be
provided).

Tested on an Allied Telesis x530 switch with Micron MT29F2G08ABAEAWP
NAND Flash.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
20 months agoboard/km: remove kirkwood boards
Holger Brunck [Mon, 15 Aug 2022 06:35:11 +0000 (08:35 +0200)]
board/km: remove kirkwood boards

These boards are out of maintenance and can be removed.

Signed-off-by: Holger Brunck <holger.brunck@hitachienergy.com>
Reviewed-by: Stefan Roese <sr@denx.de>
20 months agoMerge branch 'next'
Tom Rini [Mon, 3 Oct 2022 19:39:46 +0000 (15:39 -0400)]
Merge branch 'next'

20 months agoPrepare v2022.10 v2022.10
Tom Rini [Mon, 3 Oct 2022 19:25:32 +0000 (15:25 -0400)]
Prepare v2022.10

Signed-off-by: Tom Rini <trini@konsulko.com>
20 months agoimx8mn-ddr4-evk-u-boot: Fix broken boot
Fabio Estevam [Mon, 3 Oct 2022 14:02:03 +0000 (11:02 -0300)]
imx8mn-ddr4-evk-u-boot: Fix broken boot

When the imx8mn.dtsi file was pulled in from Linux, the UARTs
were moved into an spba sub-node which wasn't being included
in the SPL device tree.  This meant the references to the UART
weren't being handled properly and when booting the system would
constantly reboot.  Fix this by adding the spba node to the spl
device tree to restore normal booting.

Based on the patch from Adam Ford for the imx8mn-beacon-kit-u-boot
board.

Fixes: 4e5114daf9eb ("imx8mn: synchronise device tree with linux")
Signed-off-by: Fabio Estevam <festevam@denx.de>
20 months agoimx8mn-venice-u-boot: Fix broken boot
Fabio Estevam [Mon, 3 Oct 2022 14:01:15 +0000 (11:01 -0300)]
imx8mn-venice-u-boot: Fix broken boot

When the imx8mn.dtsi file was pulled in from Linux, the UARTs
were moved into an spba sub-node which wasn't being included
in the SPL device tree.  This meant the references to the UART
weren't being handled properly and when booting the system would
constantly reboot.  Fix this by adding the spba node to the spl
device tree to restore normal booting.

Based on the patch from Adam Ford for the imx8mn-beacon-kit-u-boot
board.

Fixes: 4e5114daf9eb ("imx8mn: synchronise device tree with linux")
Signed-off-by: Fabio Estevam <festevam@denx.de>
21 months agoMerge branch '2022-09-29-dm-core-support-multiple-device-trees-in-ofnode' into next
Tom Rini [Fri, 30 Sep 2022 19:52:10 +0000 (15:52 -0400)]
Merge branch '2022-09-29-dm-core-support-multiple-device-trees-in-ofnode' into next

To quote the author:
At present the ofnode interface is somewhat limited, in that it cannot
access the device tree provided by the OS, only the one used by U-Boot
itself (assuming these are separate). This prevents using ofnode functions
to handle device tree fixups, i.e. ft_board_setup() and the like.

The ofnode interface was introduced to allow a consistent API to access
the device tree, whether a flat tree or a live tree (OF_LIVE) is in use.

With the flat tree, adding nodes and properties at the start of the tree
(as often happens when writing to the /chosen node) requires copying a
lot of data for each operation. With live tree, such operations are
quite a bit faster, since there is no memory copying required. This has to
be weighed against the required memory allocation with OF_LIVE, as well
as the cost of unflattening and flattening the device tree which U-Boot
is running.

This series enables support for access to multiple device trees with the
ofnode interface. This is already available to some extent with OF_LIVE,
but some of the ofnode functions need changes to allow the tree to be
specified.

The mechanism works by using the top 1-4 bits of the device tree offset.
The sign bit is not affected, since negative values must be supported.

With this implemented, it becomes possible to use the ofnode interface
to do device tree fixups. The only current user is the EVT_FT_FIXUP
event.

This has two main benefits:

- ofnode can now be used everywhere, in preference to the libfdt calls
- live tree can eventually be used everywhere, with potential speed
  improvements when larger number of fixups are used

This series is only a step along the way. Firstly, while it is possible
to access the 'fix-up' tree using OF_LIVE, most of the fixup functions use
flat tree directly, rather than the ofnode interface. These need to be
updated. Also the tree must be flattened again before it is passed to the
OS. This is not currently implemented.

With OFNODE_MULTI_TREE disabled this has almost no effect on code size:
around 4 bytes if EVENT is enabled, 0 if not. With the feature enabled,
the increase is around 700 bytes, e.g. on venice2:

$ buildman -b ofn2a venice2 -sS --step 0
Summary of 2 commits for 1 boards (1 thread, 64 jobs per thread)
01: image: Drop some other #ifdefs in image-board.c
       arm:  w+   venice2
48: wip
       arm: (for 1/1 boards) all +668.0 text +668.0

This size increase is not too bad, considering the extra functionality,
but is too large to enable everywhere. So for now this features needs to
be opt-in only, based on EVENT.

21 months agoMerge tag 'efi-2022-10-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Fri, 30 Sep 2022 12:30:38 +0000 (08:30 -0400)]
Merge tag 'efi-2022-10-rc6' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-10-rc6

Documentation:

* doc: improve description of autostart

UEFI:

* prefix test functions with efi_st_ in the LoadImage unit test
* avoid a warning message in efi_initrd_deregister()

21 months agodm: core: Support copying properties with ofnode
Simon Glass [Wed, 7 Sep 2022 02:27:33 +0000 (20:27 -0600)]
dm: core: Support copying properties with ofnode

Add a function to copy properties from one node to another.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Allow copying ofnode property data when writing
Simon Glass [Wed, 7 Sep 2022 02:27:32 +0000 (20:27 -0600)]
dm: core: Allow copying ofnode property data when writing

At present ofnode_write_prop() is inconsistent between livetree and
flattree, in that livetree requires the caller to ensure the property
value is stable (e.g. in rodata or allocated) but flattree does not, since
it makes a copy.

This makes the API call a bit painful to use, since the caller must do
different things depending on OF_LIVE.

Add a new 'copy' argument which tells the function to make a copy if
needed. Add some tests to cover this behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agovbe: Allow test to run with live/flat tree
Simon Glass [Wed, 7 Sep 2022 02:27:31 +0000 (20:27 -0600)]
vbe: Allow test to run with live/flat tree

This test can operate in all conditions now. Update the test and comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Expand ofnode tests
Simon Glass [Wed, 7 Sep 2022 02:27:30 +0000 (20:27 -0600)]
dm: core: Expand ofnode tests

The current tests do not cover all functions, nor do they cover the new
multi-tree functionality. Add and update the tests accordingly and update
the 'future work' notes in the documentation.

There is a still more testing needed for the failure cases, since at
present some ofnode functions return a libfdt error code instead of
converting it to an errno.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Create a function to get a live tree in a test
Simon Glass [Wed, 7 Sep 2022 02:27:29 +0000 (20:27 -0600)]
dm: core: Create a function to get a live tree in a test

Move this logic out of the test into separate functions, so we can use it
in other tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Update comments for default-FDT ofnode functions
Simon Glass [Wed, 7 Sep 2022 02:27:28 +0000 (20:27 -0600)]
dm: core: Update comments for default-FDT ofnode functions

Some ofnode functions can only operate on the default device tree, i.e.
U-Boot's control FDT. Add comments to that effect. Fix up the reference to
device tree bindings while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Complete phandle implementation using the other FDT
Simon Glass [Wed, 7 Sep 2022 02:27:27 +0000 (20:27 -0600)]
dm: core: Complete phandle implementation using the other FDT

We need to be able to look up phandles in any FDT, not just the control
FDT. Use the 'other' FDT to test this, with a helper function which gets
this as an oftree that can then we used as needed.

Add a few more tests and some comments at the top of the file, to explain
what is going on.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Add the ofnode multi-tree implementation
Simon Glass [Wed, 7 Sep 2022 02:27:26 +0000 (20:27 -0600)]
dm: core: Add the ofnode multi-tree implementation

Add the logic to redirect requests for the device tree through a function
which can look up the tree ID. This works by using the top bits of
ofnode.of_offset to encode a tree.

It is assumed that there will only be a few device trees used at runtime,
typically the control FDT (always tree ID 0) and possibly a separate FDT
to be passed the OS.

The maximum number of device trees supported at runtime is 8, with this
implementation. That would use bits 30:28 of the node-offset value,
meaning that the positive offset range is limited to bits 27:0, versus
30:1 with this feature disabled. That still allows a device tree of up
to 256MB, which should be enough for most FITs. Larger ones can be
supported by using external data with the FIT, or by enabling OF_LIVE.

Update the documentation a little and fix up the comment for
ofnode_valid().

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Add definitions for multiple ofnode trees
Simon Glass [Wed, 7 Sep 2022 02:27:25 +0000 (20:27 -0600)]
dm: core: Add definitions for multiple ofnode trees

At present, unless OF_LIVE is enabled, ofnode only supports access to one
device tree, the control FDT. This is because only the node offset is
encoded in ofnode, with the tree being implicit.

This makes ofnode (without OF_LIVE) unsuitable for device tree fixups, as
implemented by ft_board_setup() and other such functions.

To solve this, we can use the top bits of the node offset to hold a tree
ID.

Add the definitions for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Split ofnode_path_root() into two functions
Simon Glass [Wed, 7 Sep 2022 02:27:24 +0000 (20:27 -0600)]
dm: core: Split ofnode_path_root() into two functions

This function turns out to be a little confusing since it looks up a path
and also registers the tree. Split it into two, one that gets the root
node and one that looks up a path, so the purpose is clear.

Registering the tree will happen in a function to be added in a later
patch, called oftree_from_fdt().

Signed-off-by: Simon Glass <sjg@chromium.org>
21 months agodm: core: Allow obtaining a node offset in the same tree
Simon Glass [Wed, 7 Sep 2022 02:27:23 +0000 (20:27 -0600)]
dm: core: Allow obtaining a node offset in the same tree

In some cases we want to obtain an ofnode in the same tree as a different
ofnode, such as when looking up a subnode. At present this is trivial,
since there is only one tree. When there are multiple trees, this
implementation will change.

Also move the ofnode_to_offset() function up higher in the header file,
since we will need to provide a different implementation with multiple
trees.

Signed-off-by: Simon Glass <sjg@chromium.org>