platform/kernel/u-boot.git
3 years agofs: fat: generate unique short names
Heinrich Schuchardt [Wed, 25 Nov 2020 15:33:55 +0000 (16:33 +0100)]
fs: fat: generate unique short names

File names must be unique within their directory. So before assigning a
short name we must check that it is unique.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: call set_name() only once
Heinrich Schuchardt [Sun, 22 Nov 2020 18:19:39 +0000 (19:19 +0100)]
fs: fat: call set_name() only once

In set_name() we select the short name. Once this is correctly implemented
this will be a performance intensive operation because we need to check
that the name does not exist yet. So set_name should only be called once.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: pass shortname to fill_dir_slot
Heinrich Schuchardt [Sat, 21 Nov 2020 07:32:50 +0000 (08:32 +0100)]
fs: fat: pass shortname to fill_dir_slot

Currently we pass the short name via the directory iterator.
Pass it explicitly as a parameter.

This removes the requirement to set the short name in the iterator before
writing the long name.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: create correct short names
Heinrich Schuchardt [Fri, 20 Nov 2020 11:55:22 +0000 (12:55 +0100)]
fs: fat: create correct short names

The current function set_name() used to create short names has the
following deficiencies resolved by this patch:

* Long names (e.g. FOO.TXT) are stored even if a short name is enough.
* Short names with spaces are created, e.g. "A     ~1.TXT".
* Short names with illegal characters are created, e.g. "FOO++BAR".
* Debug output does not not consider that the short file name has no
  concluding '\0'.

The solution for the following bug is split of into a separate patch:

* Short file names must be unique.

This patch only provides the loop over possible short file names.

Fixes: c30a15e590c ("FAT: Add FAT write feature")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: export fat_next_cluster()
Heinrich Schuchardt [Sun, 22 Nov 2020 08:19:52 +0000 (09:19 +0100)]
fs: fat: export fat_next_cluster()

Rename function next_cluster() to fat_next_cluster() and export it.

When creating a new directory entries we should reuse deleted entries.
This requires re-scanning the directory.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: correct first cluster for '..'
Heinrich Schuchardt [Tue, 24 Nov 2020 20:04:07 +0000 (21:04 +0100)]
fs: fat: correct first cluster for '..'

The FAT specification [1] requires that for a '..' directory entry pointing
to the root directory the fields DIR_FstClusHi and DIR_FstClusLo are 0.

[1] Microsoft FAT Specification, Microsoft Corporation, August 30 2005

Fixes: 31a18d570d96 ("fs: fat: support mkdir")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
3 years agospl: fit: Prefer a malloc()'d buffer for loading images
Alexandru Gagniuc [Wed, 21 Oct 2020 23:32:58 +0000 (18:32 -0500)]
spl: fit: Prefer a malloc()'d buffer for loading images

Fit images were loaded to a buffer provided by spl_get_load_buffer().
This may work when the FIT image is small and fits between the start
of DRAM and SYS_TEXT_BASE.

One problem with this approach is that the location of the buffer may
be manipulated by changing the 'size' field of the FIT. A maliciously
crafted FIT image could place the buffer over executable code and be
able to take control of SPL. This is unacceptable for secure boot of
signed FIT images.

Another problem is with larger FIT images, usually containing one or
more linux kernels. In such cases the buffer be be large enough so as
to start before DRAM (Figure I). Trying to load an image in this case
has undefined behavior.
For example, on stm32mp1, the MMC controller hits a RX overrun error,
and aborts loading.
    _________________
   |    FIT Image    |
   |                 |
  /===================\                        /=====================\
  ||      DRAM       ||                        |        DRAM         |
  ||                 ||                        |                     |
  ||_________________||  SYS_TEXT_BASE         | ___________________ |
  |                   |                        ||     FIT Image     ||
  |                   |                        ||                   ||
  | _________________ |  SYS_SPL_MALLOC_START  || _________________ ||
  ||  malloc() data  ||                        |||  malloc() data  |||
  ||_________________||                        |||_________________|||
  |                   |                        ||___________________||
  |                   |                        |                     |

        Figure I                                       Figure II

One possibility that was analyzed was to remove the negative offset,
such that the buffer starts at SYS_TEXT_BASE. This is not a proper
solution because on a number of platforms, the malloc buffer() is
placed at a fixed address, usually after SYS_TEXT_BASE. A large
enough FIT image could cause the malloc()'d data to be overwritten
(Figure II) when loading.

          /======================\
          |        DRAM          |
          |                      |
          |                      |   CONFIG_SYS_TEXT_BASE
          |                      |
          |                      |
          | ____________________ |   CONFIG_SYS_SPL_MALLOC_START
          ||   malloc() data    ||
          ||                    ||
          || __________________ ||
          |||    FIT Image     |||
          |||                  |||
          |||                  |||

                 Figure III

The solution proposed here is to replace the ad-hoc heuristics of
spl_get_load_buffer() with malloc(). This provides two advantages:
    * Bounds checking of the buffer region
    * Guarantees the buffer does not conflict with other memory

The first problem is solved by constraining the buffer such that it
will not overlap currently executing code. This eliminates the chance
of a malicious FIT being able to replace the executing SPL code prior
to signature checking.

The second problem is solved in conjunction with increasing
CONFIG_SYS_SPL_MALLOC_SIZE. Since the SPL malloc() region is
carefully crafted on a per-platform basis, the chances of memory
conflicts are virtually eliminated.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoMerge branch '2020-12-07-bootm-and-spl-atf-improvements' into next
Tom Rini [Mon, 7 Dec 2020 22:16:23 +0000 (17:16 -0500)]
Merge branch '2020-12-07-bootm-and-spl-atf-improvements' into next

- Series to improve "bootm" by allowing variable evaluation within the
  cmdline we would be passing.  This will help with Chrome OS but can be
  useful elsewhere.
- Improve ATF (TF-A) support within SPL.

3 years agobootm: Support string substitution in bootargs
Simon Glass [Thu, 5 Nov 2020 17:33:48 +0000 (10:33 -0700)]
bootm: Support string substitution in bootargs

In some cases it is necessary to pass parameters to Linux so that it will
boot correctly. For example, the rootdev parameter is often used to
specify the root device. However the root device may change depending on
whence U-Boot loads the kernel. At present it is necessary to build up
the command line by adding device strings to it one by one.

It is often more convenient to provide a template for bootargs, with
U-Boot doing the substitution from other environment variables.

Add a way to substitute strings in the bootargs variable. This allows
things like "rootdev=${rootdev}" to be used in bootargs, with the
${rootdev} substitution providing the UUID of the root device.

For example, to substitute the GUID of the kernel partition:

  setenv bootargs "console=/dev/ttyS0 rootdev=${uuid}/PARTNROFF=1
kern_guid=${uuid}"
  part uuid mmc 2:2 uuid
  bootm

This is particularly useful when the command line from another place. For
example, Chrome OS stores the command line next to the kernel itself. It
depends on the kernel version being used as well as the hardware features,
so it is extremely difficult to devise a U-Boot script that works on all
boards and kernel versions. With this feature, the command line can be
read from disk and used directly, with a few substitutions set up.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocli: Support macro processing with a fixed-size buffer
Simon Glass [Thu, 5 Nov 2020 17:33:47 +0000 (10:33 -0700)]
cli: Support macro processing with a fixed-size buffer

At present cli_simple_process_macros() requires that the caller provide
an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This
makes sense since it is designed to be used from the command line. But we
also want to use it for bootargs substitution.

Update the function to allow the caller to specify the buffer size. Also
return an error if the buffer is exhausted. The caller can ignore that if
preferred.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: zimage: Add silent-console processing
Simon Glass [Thu, 5 Nov 2020 17:33:46 +0000 (10:33 -0700)]
x86: zimage: Add silent-console processing

At present zimage does its own command-line processing and does not
support the 'silent console' feature. There doesn't seem to be any good
reason for this.

Add support for silent console to zimage.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Allow updating the bootargs in a buffer
Simon Glass [Thu, 5 Nov 2020 17:33:45 +0000 (10:33 -0700)]
bootm: Allow updating the bootargs in a buffer

At present we only support updating the 'bootargs' environment
variable. Add another function to update a buffer instead. This will
allow zimage to use this feature.

Also add a lot more tests to cover various cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Update bootm_process_cmdline_env() to use flags
Simon Glass [Thu, 5 Nov 2020 17:33:44 +0000 (10:33 -0700)]
bootm: Update bootm_process_cmdline_env() to use flags

At present only one transformation is supported: making the Linux console
silent. To prepare for adding more, convert the boolean parameter into a
flag value.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Split out bootargs environment reading / writing
Simon Glass [Thu, 5 Nov 2020 17:33:43 +0000 (10:33 -0700)]
bootm: Split out bootargs environment reading / writing

At present bootm_process_cmdline_env() reads the 'bootargs' variable and
then writes it back afterwards. This is painful for tests, which would
rather use a simple buffer.

It is also useful for zimage to use a buffer, since it does not actually
put the Linux command line in the bootargs variable.

Refactor the existing code into two pieces. One handles reading and
writing the environment variable, as well as allocating a buffer for use
by the rest of the code, which now operates on a buffer.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Use size rather than length for CONSOLE_ARG
Simon Glass [Thu, 5 Nov 2020 17:33:42 +0000 (10:33 -0700)]
bootm: Use size rather than length for CONSOLE_ARG

Use the size (including terminator) for in this function, rather than
the length. This is arguably easier to follow, with the coming
refactor.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Add a bool parameter to bootm_process_cmdline_env()
Simon Glass [Thu, 5 Nov 2020 17:33:41 +0000 (10:33 -0700)]
bootm: Add a bool parameter to bootm_process_cmdline_env()

This function will soon do more than just handle the 'silent linux'
feature. As a first step, update it to take a boolean parameter,
indicating whether or not the processing is required.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Rename fixup_silent_linux()
Simon Glass [Thu, 5 Nov 2020 17:33:40 +0000 (10:33 -0700)]
bootm: Rename fixup_silent_linux()

We want to add more processing to this function. Before doing so, rename
it to bootm_process_cmdline_env(), which is more generic.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Update fixup_silent_linux() to return an error
Simon Glass [Thu, 5 Nov 2020 17:33:39 +0000 (10:33 -0700)]
bootm: Update fixup_silent_linux() to return an error

At present this function fails silently on error. Update it to produce
an error code. Report this error to the user and abort the boot, since it
likely will prevent a successful start.

No tests are added at this stage, since additional refactoring is taking
place in subsequent patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobootm: Add tests for fixup_silent_linux()
Simon Glass [Thu, 5 Nov 2020 17:33:38 +0000 (10:33 -0700)]
bootm: Add tests for fixup_silent_linux()

This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoenv: Allow returning errors from hdelete_r()
Simon Glass [Thu, 5 Nov 2020 17:33:37 +0000 (10:33 -0700)]
env: Allow returning errors from hdelete_r()

At present this function returns 1 on success and 0 on failure. But in
the latter case it provides no indication of what went wrong.

If an attempt is made to delete a non-existent variable, the caller may
want to ignore this error. This happens when setting a non-existent
variable to "", for example.

Update the function to return 0 on success and a useful error code on
failure. Add a function comment too.

Make sure that env_set() does not return an error if it is deleting a
variable that doesn't exist. We could update env_set() to return useful
error numbers also, but that is beyond the scope of this change.

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

3 years agoboard: sl28: add OP-TEE Trusted OS support (bl32)
Michael Walle [Wed, 18 Nov 2020 16:46:02 +0000 (17:46 +0100)]
board: sl28: add OP-TEE Trusted OS support (bl32)

Add support to load the OP-TEE Trusted OS by the SPL.

Signed-off-by: Michael Walle <michael@walle.cc>
3 years agoboard: sl28: add ATF support (bl31)
Michael Walle [Wed, 18 Nov 2020 16:46:01 +0000 (17:46 +0100)]
board: sl28: add ATF support (bl31)

Add support to load the bl31 part of the ARM Trusted Firmware by the
SPL.

Signed-off-by: Michael Walle <michael@walle.cc>
3 years agoboard: sl28: remove u-boot from loadable DT node
Michael Walle [Wed, 18 Nov 2020 16:46:00 +0000 (17:46 +0100)]
board: sl28: remove u-boot from loadable DT node

It is not needed. Remove it.

Signed-off-by: Michael Walle <michael@walle.cc>
3 years agoarmv8: layerscape: don't initialize GIC in SPL
Michael Walle [Wed, 18 Nov 2020 16:45:59 +0000 (17:45 +0100)]
armv8: layerscape: don't initialize GIC in SPL

The BL31 expects the GIC to be uninitialized. Thus, if we are loading
the BL31 by the SPL we must not initialize it. If u-boot is loaded by
the SPL directly, it will initialize the GIC again (in the same
lowlevel_init()).

This was tested on a custom board with SPL loading the BL31 and jumping
to u-boot as BL33 as well as loading u-boot directly by the SPL. In case
the ATF BL1/BL2 is used, this patch won't change anything, because no
SPL is used at all.

Signed-off-by: Michael Walle <michael@walle.cc>
3 years agospl: atf: add support for LOAD_IMAGE_V2
Michael Walle [Wed, 18 Nov 2020 16:45:58 +0000 (17:45 +0100)]
spl: atf: add support for LOAD_IMAGE_V2

Newer platforms use the LOAD_IMAGE_V2 parameter passing method. Add
support for it.

Signed-off-by: Michael Walle <michael@walle.cc>
3 years agospl: atf: remove helper structure from common header
Michael Walle [Wed, 18 Nov 2020 16:45:57 +0000 (17:45 +0100)]
spl: atf: remove helper structure from common header

bl2_to_bl31_params_mem is just an implementation detail of the SPL ATF
support and is not needed anywhere else. Move it from the header to the
actual module.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Michal Simek <michal.simek@xilinx.com>
3 years agospl: atf: provide a bl2_plat_get_bl31_params_default()
Michael Walle [Wed, 18 Nov 2020 16:45:56 +0000 (17:45 +0100)]
spl: atf: provide a bl2_plat_get_bl31_params_default()

Move the actual implementation of the bl2_plat_get_bl31_params() to its
own function. The weak function will just call the default
implementation. This has the advantage that board code can still call
the original implementation if it just want to modify minor things.

Signed-off-by: Michael Walle <michael@walle.cc>
3 years agospl: atf: move storage for bl31_params into function
Michael Walle [Wed, 18 Nov 2020 16:45:55 +0000 (17:45 +0100)]
spl: atf: move storage for bl31_params into function

There is no need to have the storage available globally. This is also a
preparation for LOAD_IMAGE_V2 support. That will introduce a similar
generator function which also has its own storage.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Michal Simek <michal.simek@xilinx.com>
3 years agotreewide: use CONFIG_IS_ENABLED() for ARMV8_SEC_FIRMWARE_SUPPORT
Michael Walle [Wed, 18 Nov 2020 16:45:54 +0000 (17:45 +0100)]
treewide: use CONFIG_IS_ENABLED() for ARMV8_SEC_FIRMWARE_SUPPORT

There is SPL_ARMV8_SEC_FIRMWARE_SUPPORT and ARMV8_SEC_FIRMWARE_SUPPORT.
Thus use CONFIG_IS_ENABLED() instead of the simple #ifdef.

Signed-off-by: Michael Walle <michael@walle.cc>
Acked-by: Michal Simek <michal.simek@xilinx.com>
3 years agoMerge tag 'efi-next' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi into...
Tom Rini [Thu, 3 Dec 2020 21:21:51 +0000 (16:21 -0500)]
Merge tag 'efi-next' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi into next

Pull request for UEFI sub-system for next

This pull request adds:

* eventlog support for TCG2_PROTOCOL
* UEFI capusule updates

It replace printf by log in efi_uclass.c

3 years agosandbox: enable capsule update for testing
AKASHI Takahiro [Tue, 17 Nov 2020 00:28:05 +0000 (09:28 +0900)]
sandbox: enable capsule update for testing

Add more configuration options to allow for efi capsule update
on sandbox.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agotest/py: efi_capsule: test for raw image capsule
AKASHI Takahiro [Mon, 30 Nov 2020 09:12:17 +0000 (18:12 +0900)]
test/py: efi_capsule: test for raw image capsule

The test can run on sandbox build and it attempts to execute a firmware
update via a capsule-on-disk, using a raw image capsule,
CONFIG_EFI_CAPSULE_RAW.

To run this test successfully, you need configure U-Boot specifically;
See test_capsule_firmware.py for requirements, and hence it won't run
on Travis CI, at least, for now.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agotest/py: efi_capsule: test for FIT image capsule
AKASHI Takahiro [Mon, 30 Nov 2020 09:12:16 +0000 (18:12 +0900)]
test/py: efi_capsule: test for FIT image capsule

The test can run on sandbox build and it attempts to execute a firmware
update via a capsule-on-disk, using a FIT image capsule,
CONFIG_EFI_CAPSULE_FIT.

To run this test successfully, you need configure U-Boot specifically;
See test_capsule_firmware.py for requirements, and hence it won't run
on Travis CI, at least, for now.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agotools: add mkeficapsule command for UEFI capsule update
AKASHI Takahiro [Mon, 30 Nov 2020 09:12:15 +0000 (18:12 +0900)]
tools: add mkeficapsule command for UEFI capsule update

This is a utility mainly for test purpose.
  mkeficapsule -f: create a test capsule file for FIT image firmware

Having said that, you will be able to customize the code to fit
your specific requirements for your platform.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agocmd: add "efidebug capsule" command
AKASHI Takahiro [Tue, 17 Nov 2020 00:28:01 +0000 (09:28 +0900)]
cmd: add "efidebug capsule" command

"efidebug capsule" is more or less a debugging utility.
  efidebug capsule update: invoke UpdateCapsule against data on memory
  efidebug capsule show: show a capsule header
  efidebug capsule result: dump a capsule result variable

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agoefi_loader: add firmware management protocol for raw image
AKASHI Takahiro [Tue, 17 Nov 2020 00:28:00 +0000 (09:28 +0900)]
efi_loader: add firmware management protocol for raw image

In this commit, a very simple firmware management protocol driver
is implemented. It will take a binary image in a capsule file and
apply the data using dfu backend storage drivers via dfu_write_by_alt()
interface.

So "dfu_alt_info" variable should be properly set to specify a device
and location to be updated. Please read README.dfu.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agoefi_loader: add firmware management protocol for FIT image
AKASHI Takahiro [Mon, 30 Nov 2020 09:12:12 +0000 (18:12 +0900)]
efi_loader: add firmware management protocol for FIT image

In this commit, a very simple firmware management protocol driver
is implemented. It will take a common FIT image firmware in a capsule
file and apply the data using dfu backend storage drivers via
update_fit() interface.

So "dfu_alt_info" variable should be properly set to specify a device
and location to be updated. Please read README.dfu.

Fit image is a common file format for firmware update on U-Boot, and
this protocol works neatly just as a wrapper for one.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agoefi_loader: capsule: support firmware update
AKASHI Takahiro [Mon, 30 Nov 2020 09:12:11 +0000 (18:12 +0900)]
efi_loader: capsule: support firmware update

A capsule tagged with the guid, EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID,
is handled as a firmware update object.
What efi_update_capsule() basically does is to load any firmware management
protocol (or fmp) drivers contained in a capsule, find out an appropriate
fmp driver and then invoke its set_image() interface against each binary
in a capsule.
In this commit, however, loading drivers is not supported.

The result of applying a capsule is set to be stored in "CapsuleXXXX"
variable, but its implementation is deferred to a fmp driver.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agoefi_loader: capsule: add memory range capsule definitions
AKASHI Takahiro [Tue, 17 Nov 2020 00:27:57 +0000 (09:27 +0900)]
efi_loader: capsule: add memory range capsule definitions

Memory range capsule gives us a way to notify that some memory regions
should be left untouched across the next reset.
See UEFI specification, section 8.5.3.

Since how we should handle this kind of capsule is totally up to
the system, no implementation will be added in this commit.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agoefi_loader: capsule: add capsule_on_disk support
AKASHI Takahiro [Tue, 17 Nov 2020 00:27:56 +0000 (09:27 +0900)]
efi_loader: capsule: add capsule_on_disk support

Capsule data can be loaded into the system either via UpdateCapsule
runtime service or files on a file system (of boot device).
The latter case is called "capsules on disk", and actual updates will
take place at the next boot time.

In this commit, we will support capsule on disk mechanism.

Please note that U-Boot itself has no notion of "boot device" and
all the capsule files to be executed will be detected only if they
are located in a specific directory, \EFI\UpdateCapsule, on a device
that is identified as a boot device by "BootXXXX" variables.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agoefi_loader: define UpdateCapsule api
AKASHI Takahiro [Tue, 17 Nov 2020 00:27:55 +0000 (09:27 +0900)]
efi_loader: define UpdateCapsule api

In this commit, skeleton functions for capsule-related API's are
added under CONFIG_EFI_UPDATE_CAPSULE configuration.
Detailed implementation for a specific capsule type will be added
in the succeeding patches.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agocommon: update: fix an "unused" warning against update_flash()
AKASHI Takahiro [Thu, 19 Nov 2020 00:37:19 +0000 (09:37 +0900)]
common: update: fix an "unused" warning against update_flash()

Since update_flash() is used only in update_tftp(), it should be
guarded with appropriate config options.

After the commit 3149e524fc1e, common/update.c will be built under
either CONFIG_UDATE_TFTP, CONFIG_DFU_TFTP or CONFIG_UPDATE_FIT.
Since CONFIG_UPDATE_FIT, hence fit_update(), doesn't rely on
update_flash(), the compiler may cause an "unused" warning if
CONFIG_UPDATE_FIT=y and CONFIG_UPDATE_TFTP=n and CONFIG_DFU_TFTP=n.

This is, for example, the case for sandbox defconfig where
EFI_CAPSULE_FIRMWARE_FIT is enabled for test purpose.

Fixes: 3149e524fc1e ("common: update: add a generic interface for FIT
       image")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
3 years agocmd: efidebug: Add support for TCG2 final events table
Ilias Apalodimas [Mon, 30 Nov 2020 09:47:41 +0000 (11:47 +0200)]
cmd: efidebug: Add support for TCG2 final events table

A previous commit is adding EFI_TCG2_PROTOCOL, which in it's eventlog
support registers an EFI configuration table.
Let's add the necessary GUID so 'efidebug table' command can display
table names properly.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: Introduce eventlog support for TCG2_PROTOCOL
Ilias Apalodimas [Mon, 30 Nov 2020 09:47:40 +0000 (11:47 +0200)]
efi_loader: Introduce eventlog support for TCG2_PROTOCOL

In the previous patches we only introduced a minimal subset of the
EFI_TCG2_PROTOCOL protocol implementing GetCapability().
So let's continue adding features to it, introducing the
GetEventLog() and HashLogExtendEvent() functions.

In order to do that we first need to construct the eventlog in memory,
specifically in EFI_BOOT_SERVICES_DATA memory and a configuration table
from EFI_ACPI_MEMORY_NVS.
U-Boot won't currently add any events to the log or measure any
components, but will expose the necessary EFI APIs for applications
to do so.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agotpm: Add tpm2 headers for TCG2 eventlog support
Ilias Apalodimas [Mon, 30 Nov 2020 09:47:39 +0000 (11:47 +0200)]
tpm: Add tpm2 headers for TCG2 eventlog support

A following patch introduces support for the EFI_TCG2_PROTOCOL
eventlog management.
Introduce the necessary tpm related headers

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agotpm: use more than sha256 on pcr_extend
Ilias Apalodimas [Thu, 26 Nov 2020 21:07:22 +0000 (23:07 +0200)]
tpm: use more than sha256 on pcr_extend

The current tpm2_pcr_extend is hardcoded using SHA256.
Let's make the actual command to the TPM2 configurable so we can support
a wider range of algorithms and keep the current command line as-is i.e
limited to SHA256 only

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoefi_loader: replace printf by log in efi_uclass.c
Heinrich Schuchardt [Tue, 1 Dec 2020 08:06:29 +0000 (09:06 +0100)]
efi_loader: replace printf by log in efi_uclass.c

Use logging functions instead of printf() and debug().

Change logging messages for uclass creation and destruction to log_debug().

Reported-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoMerge branch '2020-12-01-next-imports' into next
Tom Rini [Wed, 2 Dec 2020 16:35:02 +0000 (11:35 -0500)]
Merge branch '2020-12-01-next-imports' into next

- More IPQ40xx improvements
- Add string support to setexpr (and tests)
- ProxyDHCP support
- Assorted cleanups

3 years agokm/arm: coding style clean up
Holger Brunck [Fri, 30 Oct 2020 11:45:49 +0000 (12:45 +0100)]
km/arm: coding style clean up

Address most of the checkpatch issues we found in km_arm and common km
code.

CC: Stefan Roese <sr@denx.de>
CC: Valentin Longchamp <valentin.longchamp@hitachi-powergrids.com>
Signed-off-by: Holger Brunck <holger.brunck@hitachi-powergrids.com>
Reviewed-by: Stefan Roese <sr@denx.de>
3 years agospl: spl_fit.c: enable check of signature for config node in spl/tpl
Philippe Reynes [Thu, 29 Oct 2020 17:50:29 +0000 (18:50 +0100)]
spl: spl_fit.c: enable check of signature for config node in spl/tpl

This commit add the support of signature check for config node
in spl/tpl when the function spl_load_simple_fit is used.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoIPQ40xx: clk: add USB clock handling
Robert Marko [Wed, 28 Oct 2020 12:56:26 +0000 (13:56 +0100)]
IPQ40xx: clk: add USB clock handling

USB clocks were completely forgotten as driver would always return 0 even if clock ID was unknown.

This behaviour changed with "IPQ40xx: clk: dont always return 0" and this will now causes the USB-s to fail probing as clock enable will return -EINVAL.

So to fix that lets add all of the USB clocks to the driver.

Fixes: 430e1dcf ("IPQ40xx: Add USB nodes")

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
3 years agoIPQ40xx: clk: dont always return 0
Robert Marko [Wed, 28 Oct 2020 12:56:25 +0000 (13:56 +0100)]
IPQ40xx: clk: dont always return 0

Currently the driver will go through the clock ID-s and set/enable them as needed.
But if the ID is unknown it will fall through the switch case to the default case which will always return 0.

This is not correct and default cases should return a error code since clock ID is unknown.
So lets return -EINVAL instead.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
3 years agoIPQ40xx: clk: drop breaks in switch case
Robert Marko [Wed, 28 Oct 2020 12:56:24 +0000 (13:56 +0100)]
IPQ40xx: clk: drop breaks in switch case

There is no point in having break statements in the switch case as there is already a return before break.

So lets drop them from the driver.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
3 years agoIPQ40xx: clk: use dev_read_addr()
Robert Marko [Wed, 28 Oct 2020 12:56:23 +0000 (13:56 +0100)]
IPQ40xx: clk: use dev_read_addr()

Lets convert the driver to use dev_read_addr() instead of the devfdt_get_addr().

While we are here, lets also alphabetise the includes.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Cc: Luka Perkov <luka.perkov@sartura.hr>
3 years agocmd: Kconfig: migrate CONFIG_SYS_PROMPT_HUSH_PS2
Patrick Delaunay [Mon, 26 Oct 2020 08:31:42 +0000 (09:31 +0100)]
cmd: Kconfig: migrate CONFIG_SYS_PROMPT_HUSH_PS2

Move CONFIG_SYS_PROMPT_HUSH_PS2 in Kconfig, depending
on CONFIG_HUSH_PARSER, and remove the default value defined
in cli_hush.c under __U_BOOT__.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agohush: Remove default CONFIG_SYS_PROMPT_HUSH_PS2 setting from board files
Patrick Delaunay [Mon, 26 Oct 2020 08:31:41 +0000 (09:31 +0100)]
hush: Remove default CONFIG_SYS_PROMPT_HUSH_PS2 setting from board files

There is no reason to define default option for this macro which is
already done in common/cli_hush.c.

  87 #ifndef CONFIG_SYS_PROMPT_HUSH_PS2
  88 #define CONFIG_SYS_PROMPT_HUSH_PS2      "> "
  89 #endif

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Acked-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
3 years agonet: sntp: remove CONFIG_TIMESTAMP constraint
Heinrich Schuchardt [Fri, 23 Oct 2020 10:58:27 +0000 (12:58 +0200)]
net: sntp: remove CONFIG_TIMESTAMP constraint

CONFIG_TIMESTAMP is not related to the RTC drivers. It does not make any
sense to let the updating of the RTC by the sntp command depend on it.

Drop the CONFIG_TIMESTAMP checks.

Furthermore function dm_rtc_set() is enabled by CONFIG_DM_RTC. There is no
reason to require CONFIG_CMD_DATE when using a driver model RTC. The UEFI
sub-system can consume the RTC functions even if there is not date command.

Only check CONFIG_CMD_DATE when using a non-driver model RTC.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agosetexpr: Add support for strings
Simon Glass [Sun, 1 Nov 2020 21:15:44 +0000 (14:15 -0700)]
setexpr: Add support for strings

Add support for dealing with string operands, including reading a string
from memory into an environment variable and concatenating two strings.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Marek Behún <marek.behun@nic.cz>
3 years agosetexpr: Convert to use a struct for values
Simon Glass [Sun, 1 Nov 2020 21:15:43 +0000 (14:15 -0700)]
setexpr: Convert to use a struct for values

At present a ulong is used to hold operand values. This means that
strings cannot be used. While most operations are not useful for strings,
concatenation is. As a starting point to supporting strings, convert the
code to use a struct instead of a ulong for operands.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosetexpr: Correct buffer overflow bug and enable tests
Simon Glass [Sun, 1 Nov 2020 21:15:42 +0000 (14:15 -0700)]
setexpr: Correct buffer overflow bug and enable tests

At present when more than one substitution is made this function
overwrites its buffers. Fix this bug and update the tests now that they
can pass.

Also update the debug code to show all substrings, since at present it
omits the final one.

Fixes: 855f18ea0e6 ("setexpr: add regex substring matching and substitution")
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosetexpr: Correct dropping of final unmatched string
Simon Glass [Sun, 1 Nov 2020 21:15:41 +0000 (14:15 -0700)]
setexpr: Correct dropping of final unmatched string

At present the 'nlen' variable increases with each loop. If the previous
loop had back references, then subsequent loops without back references
use the wrong value of nlen. The value is larger, meaning that the string
terminator from nbuf is copied along to the main buffer, thus terminating
the string prematurely.

This leads to the final result being truncated, e.g. missing the last
(unmatched) part of the string. So "match match tail" become
"replaced replaced" instead of "replaced replaced tail".

Fix this by resetting nlen to the correct value each time around the lop.

Fixes: 855f18ea0e6 ("setexpr: add regex substring matching and substitution")
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosetexpr: Add some tests for buffer overflow and backref
Simon Glass [Sun, 1 Nov 2020 21:15:40 +0000 (14:15 -0700)]
setexpr: Add some tests for buffer overflow and backref

Add tests to check for buffer overflow using simple replacement as well
as back references. At present these don't fully pass.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosetexpr: Split the core logic into its own function
Simon Glass [Sun, 1 Nov 2020 21:15:39 +0000 (14:15 -0700)]
setexpr: Split the core logic into its own function

At present this function always allocates a large amount of stack, and
selects its own size for buffers. This makes it hard to test the code
for buffer overflow.

Separate out the inner logic of the substitution so that tests can call
this directly. This will allow checking that the algorithm does not
overflow the buffer.

Fix up one of the error lines at the same time, since it should be
printing nbuf_size, not data_size.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agotest: Add some setexpr regex tests
Simon Glass [Sun, 1 Nov 2020 21:15:38 +0000 (14:15 -0700)]
test: Add some setexpr regex tests

Add tests for the setexpr regex commands.

Note that these tests currently crash on sandbox due to an existing bug in
the setexpr implementation, so two of the tests are commented out.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosetexpr: Add explicit support for 32- and 64-bit ints
Simon Glass [Sun, 1 Nov 2020 21:15:37 +0000 (14:15 -0700)]
setexpr: Add explicit support for 32- and 64-bit ints

At present this function assumes that a size of 4 refers to a ulong. This
is true on 32-bit machines but not commonly on 64-bit machines.

This means that the 'l' specify does not work correctly with setexpr.

Add an explicit case for 32-bit values so that 64-bit machines can still
use the 'l' specifier. On 32-bit machines, 64-bit is still not supported.

This corrects the operation of the default size (which is 4 for setexpr),
so update the tests accordingly.

The original code for reading from memory was included in 47ab5ad1457
("cmd_setexpr: allow memory addresses in expressions") but I am not adding
a Fixes: tag since that code was not written with 64-bit machines in mind.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocommand: Add constants for cmd_get_data_size string / error
Simon Glass [Sun, 1 Nov 2020 21:15:36 +0000 (14:15 -0700)]
command: Add constants for cmd_get_data_size string / error

At present these values are open-coded in a few places. Add constants so
the meaning is clear.

Also add a comment to cmd_get_data_size()

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agotest: Add some tests for setexpr
Simon Glass [Sun, 1 Nov 2020 21:15:35 +0000 (14:15 -0700)]
test: Add some tests for setexpr

This command currently has no tests. Add some for basic assignment and the
integer operations.

Note that the default size for setexpr is ulong, which varies depending on
the build machine. So for sandbox on a 64-bit host, this means that the
default size is 64 bits.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Correctly propagate failure when removing target
Pali Rohár [Mon, 26 Oct 2020 13:10:49 +0000 (14:10 +0100)]
Makefile: Correctly propagate failure when removing target

On more places is used pattern 'command > $@ || rm -f $@'. But it does not
propagate failure from 'command' as 'rm -f' returns success.

Fix it by calling 'false' to correctly propagate failure after 'rm -f'.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agogpio: Convert to use APIs which support live DT
Patrick Delaunay [Wed, 9 Sep 2020 16:26:16 +0000 (18:26 +0200)]
gpio: Convert to use APIs which support live DT

Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the
driver can support live DT.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
3 years agoAdds basic support for ProxyDHCP
Lyle Franklin [Mon, 5 Aug 2019 10:23:42 +0000 (06:23 -0400)]
Adds basic support for ProxyDHCP

- ProxyDHCP allows a second DHCP server to exist alongside your main
  DHCP server and supply additional BOOTP related options
- When u-boot sends out a DHCP request, the real DHCP server will
  respond with a normal response containing the new client IP address
  while simultaneously the ProxyDHCP server will respond with a blank
  client IP address and a `bootfile` option
- This patch adds CONFIG_SERVERIP_FROM_PROXYDHCP (default false) to
  enable this behavior and CONFIG_SERVERIP_FROM_PROXYDHCP_DELAY_MS
  (default 100) which tells u-boot to wait additional time after
  receiving the main DHCP response to give the ProxyDHCP response time
  to arrive
- The PXE spec for ProxyDHCP is more complicated than the solution
  added here as diagramed on page 16:
  http://www.pix.net/software/pxeboot/archive/pxespec.pdf:

```
DHCP Discover will be retried four times. The four timeouts are 4, 8, 16
and 32 seconds respectively. If a DHCPOFFER is received without an Option
timeouts in an attempt to receive a PXE response.
```

- Adding a simple delay worked for my purposes but let me know if a
  more robust solution is required

Signed-off-by: Lyle Franklin <lylejfranklin@gmail.com>
3 years agocmd: pxe: Use internal FDT if retrieving from FDTDIR fails
Anton Leontiev [Tue, 3 Sep 2019 07:52:24 +0000 (10:52 +0300)]
cmd: pxe: Use internal FDT if retrieving from FDTDIR fails

As FDTDIR label doesn't specify exact file to be loaded, it should
not fail if no file exists in the directory. In this case try to boot
with internal FDT if it exists.

Signed-off-by: Anton Leontiev <aleontiev@elvees.com>
3 years agoPrepare v2021.01-rc3
Tom Rini [Mon, 30 Nov 2020 18:09:42 +0000 (13:09 -0500)]
Prepare v2021.01-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 30 Nov 2020 17:50:32 +0000 (12:50 -0500)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge tag 'mmc-2020-11-29' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc
Tom Rini [Sun, 29 Nov 2020 16:12:59 +0000 (11:12 -0500)]
Merge tag 'mmc-2020-11-29' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc

- mmc minor update for better debug and error check
- fsl_esdhc sysctl set and make sure delay check for HS400

3 years agoMerge tag 'efi-2021-01-rc3-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sun, 29 Nov 2020 16:12:49 +0000 (11:12 -0500)]
Merge tag 'efi-2021-01-rc3-3' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for efi-2021-01-rc3 (3)

The following errors are corrected:

* Linux crash when accessing UEFI variables at runtime.
* UEFI variable using standalone MM on 32 bit systems
  not working due to missing packing of communication
  structure
* NULL dereference when FAT16 root directory is full
* FAT files with a short file name starting with 0xE5 (0x05 in directory
  entry) where treated as deleted.

The UEFI SetTime() service is enabled on ARM QEMU.

3 years agocharset: make u16_strnlen accessible at runtime
Ilias Apalodimas [Sun, 22 Nov 2020 13:10:26 +0000 (15:10 +0200)]
charset: make u16_strnlen accessible at runtime

commit 1fabfeef506c ("efi_loader: parameter check in GetNextVariableName()")
introduces a check using u16_strnlen(). This code is used on EFI
runtime variables as well, so unless we mark it as runtime, the kernel
will crash trying to access it.

Fixes: 1fabfeef506c ("efi_loader: parameter check in GetNextVariableName()")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agolib/efi_loader: fix ABI in efi_mm_communicate_header
Etienne Carriere [Sat, 21 Nov 2020 10:59:33 +0000 (11:59 +0100)]
lib/efi_loader: fix ABI in efi_mm_communicate_header

Pack struct efi_mm_communicate_header as done in EDK2 as seen in
release 201808 [1]. If not packed sizeof() for the structure adds
4 additional bytes on 32bit targets which breaks the ABI.

Link: [1] https://github.com/tianocore/edk2/blob/edk2-stable201808/MdePkg/Include/Protocol/MmCommunication.h#L21
Fixes: 23a397d2e2fb ("efi_loader: Add headers for EDK2 StandAloneMM communication")
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: enable EFI_SET_TIME on sandbox and QEMU ARM
Heinrich Schuchardt [Sat, 21 Nov 2020 19:52:18 +0000 (20:52 +0100)]
efi_loader: enable EFI_SET_TIME on sandbox and QEMU ARM

Enable EFI_SET_TIME on the sandbox and QEMU ARM to ensure that we compile
and test the relevant code.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: use ATTR_ARCH instead of anonymous 0x20
Heinrich Schuchardt [Sun, 22 Nov 2020 10:13:33 +0000 (11:13 +0100)]
fs: fat: use ATTR_ARCH instead of anonymous 0x20

Using constants instead of anonymous numbers increases code readability.

Fixes: 704df6aa0a28 ("fs: fat: refactor write interface for a file offset")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agofs: fat: directory entries starting with 0x05
Heinrich Schuchardt [Sat, 21 Nov 2020 11:34:20 +0000 (12:34 +0100)]
fs: fat: directory entries starting with 0x05

0x05 is used as replacement letter for 0xe5 at the first position of short
file names. We must not skip over directory entries starting with 0x05.

Cf. Microsoft FAT Specification, August 30 2005

Fixes: 39606d462c97 ("fs: fat: handle deleted directory entries correctly")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agofs: fat: avoid NULL dereference when root dir is full
Heinrich Schuchardt [Thu, 19 Nov 2020 11:24:44 +0000 (12:24 +0100)]
fs: fat: avoid NULL dereference when root dir is full

When trying to create a file in the full root directory of a FAT32
filesystem a NULL dereference can be observed.

When the root directory of a FAT16 filesystem is full fill_dir_slot() must
return -1 to signal that a new directory entry could not be allocated.

Fixes: cd2d727fff7e ("fs: fat: allocate a new cluster for root directory of fat32")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-i2c
Tom Rini [Sat, 28 Nov 2020 15:55:46 +0000 (10:55 -0500)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-i2c

3 years agoriscv: sifive/fu540: kconfig: Enable support for Opencores I2C controller
Pragnesh Patel [Sat, 14 Nov 2020 09:12:35 +0000 (14:42 +0530)]
riscv: sifive/fu540: kconfig: Enable support for Opencores I2C controller

Enable support for SiFive FU540 Opencores I2C master controller.

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoi2c: ocores: add i2c driver for OpenCores I2C controller
Pragnesh Patel [Sat, 14 Nov 2020 09:12:34 +0000 (14:42 +0530)]
i2c: ocores: add i2c driver for OpenCores I2C controller

Add support for the OpenCores I2C controller IP core
(See http://www.opencores.org/projects.cgi/web/i2c/overview).

This driver implementation is inspired from the Linux OpenCores
I2C driver available.

Thanks to Peter Korsgaard <peter@korsgaard.com> for writing Linux
OpenCores I2C driver.

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
Reviewed-by: Rick Chen <rick@andestech.com>
3 years agoi2c: designware_i2c: Don't warn if no reset controller
Simon Glass [Mon, 9 Nov 2020 14:12:49 +0000 (07:12 -0700)]
i2c: designware_i2c: Don't warn if no reset controller

At present if CONFIG_RESET is not enabled, this code shows a warning:

  designware_i2c_ofdata_to_platdata() i2c_designware_pci i2c2@16,0:
Can't get reset: -524

Avoid this by checking if reset is supported, first.

Fixes: 622597dee4f ("i2c: designware: add reset ctrl to driver")
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoi2c: mvtwsi: disable i2c slave also on Armada 8k
Baruch Siach [Thu, 1 Oct 2020 11:49:02 +0000 (14:49 +0300)]
i2c: mvtwsi: disable i2c slave also on Armada 8k

The hidden I2C slave is also present on the Armada 8k AP806. Testing
shows that this I2C slave causes the same issues as Armada 38x.
Disabling that I2C slave fixes all these issues.

I2C blocks on the Armada 8k CP110 are not affected.

Extend the I2C slave disable to Armada 8k as well.

Cc: Stefan Roese <sr@denx.de>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
3 years agommc: check a return value about regulator's always-on
Jaehoon Chung [Fri, 6 Nov 2020 11:30:41 +0000 (20:30 +0900)]
mmc: check a return value about regulator's always-on

Regulator can be set to "always-on".
It's not error about enable/disable. It needs to check about
its condition.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
3 years agommc: display an error number to debug
Jaehoon Chung [Mon, 16 Nov 2020 22:04:59 +0000 (07:04 +0900)]
mmc: display an error number to debug

It's useful to know an error number when it's debugging.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
3 years agommc: fsl_esdhc: make sure delay chain locked for HS400
Yangbo Lu [Tue, 20 Oct 2020 03:04:52 +0000 (11:04 +0800)]
mmc: fsl_esdhc: make sure delay chain locked for HS400

For eMMC HS400 mode, the DLL reset is a required step for mmc rescan.
This step has not been documented in reference manual, but the RM will
be fixed sooner or later.

In previous commit to support eMMC HS400,
  db8f936 mmc: fsl_esdhc: support eMMC HS400 mode

the steps to configure DLL could be found in commit message,
  13. Set DLLCFG0[DLL_ENABLE] and DLLCFG0[DLL_FREQ_SEL].
  14. Wait for delay chain to lock.

these would be fixed as,
  13.   Set DLLCFG0[DLL_ENABLE] and DLLCFG0[DLL_FREQ_SEL].
  13.1  Write DLLCFG0[DLL_RESET] to 1 and wait for 1us,
        then write DLLCFG0[DLL_RESET]
  14.   Wait for delay chain to lock.

This patch is to add the step of DLL reset, and make sure delay chain
locked for HS400.

Fixes: db8f93672b42 ("mmc: fsl_esdhc: support eMMC HS400 mode")
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: fsl_esdhc: set sysctl register for clock initialization
Yangbo Lu [Tue, 20 Oct 2020 03:04:51 +0000 (11:04 +0800)]
mmc: fsl_esdhc: set sysctl register for clock initialization

The initial clock setting should be through sysctl register only,
while the mmc_set_clock() will call mmc_set_ios() introduce other
configurations like bus width, mode, and so on.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agommc: Add some helper functions for retrying on error
Sean Anderson [Sat, 17 Oct 2020 12:36:27 +0000 (08:36 -0400)]
mmc: Add some helper functions for retrying on error

All of the existing quirks add retries to various calls of mmc_send_cmd.
mmc_send_cmd_quirks is a helper function to do this retrying behavior. It
checks if quirks mode is enabled, and if a specific quirk is activated it
retries on error.

This also adds mmc_send_cmd_retry, which retries on error every time
(instead of if a quirk is activated).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agoMerge tag 'u-boot-stm32-20201125' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
Tom Rini [Wed, 25 Nov 2020 16:00:52 +0000 (11:00 -0500)]
Merge tag 'u-boot-stm32-20201125' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm

- STM32 MCU's DT update
- Add DHCOM based STM32MP15x PicoITX board
- Correct ALIGN macro usage for on syram for SPL dcache support
- Fixes on DHCOM: uSD card-detect GPIO and Drop QSPI CS2
- Fix compilation issue for spl_mmc_boot_partition
- Fix MTD partitions for serial boot
- Add support of MCU HOLD BOOT with reset for stm32 remoteproc
  (prepare alligneent with  kernel DT)
- Correct bias information and support in STM32 soc and STMFX
- Support optional vbus in usbphyc
- Update FIT examples to avoid kernel zImage relocation before decompression

3 years agoboard: st: stm32mp1: update load address for FIT examples
Patrick Delaunay [Wed, 25 Nov 2020 11:28:10 +0000 (12:28 +0100)]
board: st: stm32mp1: update load address for FIT examples

Update kernel load address for FIT examples to avoid relocation:
- Kernel example uses Image.gz with U-Boot gzip decompression
  at final kernel location 0x0xC0008000.
- Copro example loads zImage at a correct location (0xC4000000),
  to avoid zImage relocation before decompression by kernel code.

An other solution to avoid zImage relocation is to align
the kernel load and entry address with the real location in FIT
(the relocation of zImage is skipped in U-Boot bootm command for
identical address) but it is less flexible because this offset
depends on FIT content:

For example:

## Loading kernel from FIT Image at c2000000 ...
   Using 'ev1' configuration
   Trying 'kernel' kernel subimage
     Description:  Linux kernel
     Created:      2020-10-22   9:08:32 UTC
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0xc20000cc

The kernel offset in FIT is 0xCC in FIT and zImage is decompressed at
0xC0008000 by kernel code:

kernel {
description = "Linux kernel";
data = /incbin/("zImage");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0xC20000cc>;
entry = <0xC20000cc>;
hash-1 {
algo = "sha1";
};
};

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agophy: stm32: usbphyc: manage optional vbus regulator on phy_power_on/off
Patrick Delaunay [Thu, 15 Oct 2020 12:50:57 +0000 (14:50 +0200)]
phy: stm32: usbphyc: manage optional vbus regulator on phy_power_on/off

This patch adds support for optional vbus regulator.
It is managed on phy_power_on/off calls and may be needed for host mode.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agopinctrl: stmfx: update pin name
Patrick Delaunay [Wed, 28 Oct 2020 09:51:57 +0000 (10:51 +0100)]
pinctrl: stmfx: update pin name

Update pin name to avoid duplicated name with SOC GPIO
gpio0...gpio15 / agpio0....agpio7: add a stmfx prefix.

This pin name can be used in pinmux command.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agopinctrl: stmfx: update pincontrol and gpio device name
Patrick Delaunay [Wed, 28 Oct 2020 09:51:56 +0000 (10:51 +0100)]
pinctrl: stmfx: update pincontrol and gpio device name

The device name is used in pinmux command and in log trace
so it is better to use the parent parent name ("stmfx@42" for
example) than a generic name ("pinctrl" or "stmfx-gpio")
to identify the device instance.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agogpio: stm32: correct the bias management
Patrick Delaunay [Wed, 28 Oct 2020 09:49:08 +0000 (10:49 +0100)]
gpio: stm32: correct the bias management

Use the bias configuration for all the GPIO configurations and not
only for input GPIO, as indicated in Reference manual
(Table 81. Port bit configuration table).

Fixes: 43efbb6a3ebf0223f9eab8d45916f602d876319f ("gpio: stm32: add ops get_dir_flags")
Fixes: f13ff88b61c32ac8f0e9068c41328b265ef619eb ("gpio: stm32: add ops set_dir_flags")
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agopinctrl: stm32: display bias information for all pins
Patrick Delaunay [Wed, 28 Oct 2020 09:49:07 +0000 (10:49 +0100)]
pinctrl: stm32: display bias information for all pins

Display the bias information for input gpios or AF configuration,
and not only for output pin, as described in Reference manual
(Table 81. Port bit configuration table).

Fixes: da7a0bb1f279 ("pinctrl: stm32: add information on pin configuration")
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agoremoteproc: stm32: update error management in stm32_copro_start
Patrick Delaunay [Thu, 15 Oct 2020 13:01:13 +0000 (15:01 +0200)]
remoteproc: stm32: update error management in stm32_copro_start

The coprocessor is running as soon as the hold boot is de-asserted.

So indicate this running state and save the resource table even
if the protective assert, to avoid autonomous reboot, is failed.

This error case should never occurs.

Cc: Fabien DESSENNE <fabien.dessenne@st.com>
Cc: Arnaud POULIQUEN <arnaud.pouliquen@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agoremoteproc: stm32: use reset for hold boot
Patrick Delaunay [Thu, 15 Oct 2020 13:01:12 +0000 (15:01 +0200)]
remoteproc: stm32: use reset for hold boot

Use the reset function to handle the hold boot bit in RCC
with device tree handle with MCU_HOLD_BOOT identifier.

This generic reset allows to remove the two specific properties:
- st,syscfg-holdboot
- st,syscfg-tz

This patch prepares alignment with kernel device tree.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Fabien DESSENNE <fabien.dessenne@st.com>
Cc: Arnaud POULIQUEN <arnaud.pouliquen@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>