platform/kernel/u-boot.git
2 years agoMerge tag 'efi-2022-04-rc3-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sun, 13 Mar 2022 12:18:17 +0000 (08:18 -0400)]
Merge tag 'efi-2022-04-rc3-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-04-rc3-2

Documentation:
* Fix description for SiFive Unmatched
* Add libgnutls28-dev to build dependencies

UEFI
* Avoid possibly invalid GUID pointers for protocol interfaces

Other
* Serial console support for cls command

2 years agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi
Tom Rini [Sat, 12 Mar 2022 12:20:29 +0000 (07:20 -0500)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-spi

- sunXi SPI fixups (Andre)
- bcm iproc qspi (Rayagonda)

2 years agoefi_loader: copy GUID in InstallProtocolInterface()
Heinrich Schuchardt [Wed, 9 Mar 2022 18:56:23 +0000 (19:56 +0100)]
efi_loader: copy GUID in InstallProtocolInterface()

InstallProtocolInterface() is called with a pointer to the protocol GUID.
There is not guarantee that the memory used by the caller for the protocol
GUID stays allocated. To play it safe the GUID should be copied to U-Boot's
internal structures.

Reported-by: Joerie de Gram <j.de.gram@gmail.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: add libgnutls28-dev to build dependencies
Heinrich Schuchardt [Sat, 12 Mar 2022 10:56:23 +0000 (11:56 +0100)]
doc: add libgnutls28-dev to build dependencies

mkeficapsule requires package libgnutls28-dev for building

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: path to u-boot-spl.bin on SiFive Unmatched board
Heinrich Schuchardt [Thu, 10 Mar 2022 10:32:49 +0000 (11:32 +0100)]
doc: path to u-boot-spl.bin on SiFive Unmatched board

u-boot-spl.bin is built in spl/.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agocmd: add serial console support for the cls command
Heinrich Schuchardt [Fri, 11 Feb 2022 17:11:05 +0000 (18:11 +0100)]
cmd: add serial console support for the cls command

Currently the cls command does not support the serial console

The screen can be cleared in the video uclass, the colored frame buffer
console, and the serial console by sending the same escape sequence.
This reduces the cls command to a single printf() statement on most
boards.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agomtd: spi-nor-ids: Enable quad read for Gigadevice gd25lq128
Niklas Cassel [Thu, 3 Mar 2022 18:26:39 +0000 (18:26 +0000)]
mtd: spi-nor-ids: Enable quad read for Gigadevice gd25lq128

The Gigadevice gd25lq128 serial flash exists in different versions,
all which identify themselves using the same JEDEC id.

gd25lq128c:
https://www.gigadevice.com/datasheet/gd25lq128

gd25lq128d:
https://www.gigadevice.com/datasheet/gd25lq128d

However, all versions support quad read, so enable it.
Tested and verified on the Sipeed MAix BiT board.

Fixes: 30b9a28a3f2d ("mtd: spi-nor-ids: Add Gigadevice gd25lq128 ID")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2 years agosunxi: boards: Enable SPI flash support in U-Boot proper
Andre Przywara [Tue, 11 Jan 2022 12:46:06 +0000 (12:46 +0000)]
sunxi: boards: Enable SPI flash support in U-Boot proper

Some sunxi boards ship with SPI flash, which allows booting through the
BootROM. We cover this functionality by a separate SPL "mini" driver.
Separately we have a proper DM_SPI driver for U-Boot proper, which
provides access to the SPI flash through the "sf" command. That allows
to update the firmware on the SPI flash, also to store the environment
there.

However only very few boards actually enable support for U-Boot proper,
even though that would work and the SPL part is configured.

Use the cleaned up configuration scheme to enable SPI flash on those
boards which mention a SPI flash in their .dts, or which use the SPL SPI
support.

Out of the box this would enable storing the environment on the SPI
flash, and allows people to read or write the flash from U-Boot, for
instance to update the SPI flash when booted via an SD card.

For this to actually work there must be a "spi0" alias in the DT, which
most boards are missing. But this should be addressed separately.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2 years agoenv: sunxi: enable ENV_IS_IN_SPI_FLASH
Andre Przywara [Tue, 11 Jan 2022 12:46:05 +0000 (12:46 +0000)]
env: sunxi: enable ENV_IS_IN_SPI_FLASH

Now that sunxi uses CONFIG_SPI more sanely, and can also now properly
load the environment from SPI flash, let's enable the symbol that
actually considers the SPI flash when accessing the environment.

As this symbol depends on CONFIG_SPI, which we now only enable if the
board has a SPI flash, we can make if "default y" for all Allwinner
boards.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2 years agosunxi: use boot source for determining environment location
Andre Przywara [Tue, 11 Jan 2022 12:46:04 +0000 (12:46 +0000)]
sunxi: use boot source for determining environment location

Currently we only support to load the environment from raw MMC or FAT
locations on Allwinner boards. With the advent of SPI flash we probably
also want to support using the environment there, so we need to become
a bit more flexible.

Change the environment priority function to take the boot source into
account. When booted from eMMC or SD card, we use FAT or MMC, if
configured, as before.
If we are booted from SPI flash, we try to use the environment from
there, if possible. The same is true for NAND flash booting, although
this is somewhat theoretical right now (as untested).

This way we can use the same image for SD and SPI flash booting, which
allows us to simply copy a booted image from SD card to the SPI flash,
for instance.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2 years agoenv: sunxi: Define location in SPI flash
Andre Przywara [Tue, 11 Jan 2022 12:46:03 +0000 (12:46 +0000)]
env: sunxi: Define location in SPI flash

To allow loading and storing the environment from SPI flash, adjust the
raw offset variables for Allwinner boards to make sense there.

U-Boot (including SPL and other blobs) is loaded from the beginning of
SPI flash, so move the environment location as far back as possible, to
not create unnecessary limits. As those offsets are shared with (now
mostly unused) raw MMC environment, we should respect the common one
megabyte limit, which also makes sense on SPI flash.

So limit the environment for those raw locations to 64KB, and place it
just below 1MB (@960KB).

Those values are currently unused, unless someone forcibly enables the
raw MMC environment. In this case it would break as of now, as the
current offset of 544KB is far too low for the current (arm64) U-Boot
proper.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2 years agosunxi: Kconfig: Fix up SPI configuration
Andre Przywara [Tue, 11 Jan 2022 12:46:02 +0000 (12:46 +0000)]
sunxi: Kconfig: Fix up SPI configuration

Commit 7945caf22c44 ("arm: sunxi: Enable SPI/SPI-FLASH support for A64")
selected CONFIG_SPI by default on all Allwinner A64 boards, even though
only 4 out of the 14 A64 boards have a SPI flash chip. All other SoCs
had to manually select DM_SPI and friends, even though they are a
platform property (the sunxi SPI driver is DM_SPI only).

Clean this up to allow easy selection of SPI flash support in U-Boot
proper, by selecting DM_SPI and DM_SPI_FLASH *if* CONFIG_SPI is
selected, for *all* Allwinner SoCs. This simplifies the defconfig for
two Libretech boards already.

Also remove the forced CONFIG_SPI from the A64 Kconfig, instead let the
four boards which allow SPI booting select this explicitly.

Any board wishing to support SPI flash in U-Boot proper now just defines
CONFIG_SPI and CONFIG_SPI_FLASH_<vendor> in its defconfig, Kconfig takes
care of the rest.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2 years agoMerge branch '2022-03-08-assorted-fixes'
Tom Rini [Tue, 8 Mar 2022 13:42:51 +0000 (08:42 -0500)]
Merge branch '2022-03-08-assorted-fixes'

- serial uclass fix, mailmap/gitignore updates

2 years agoboard: .gitignore: replace dsdt.c by dsdt_generated.c
Philippe Reynes [Tue, 8 Mar 2022 09:37:19 +0000 (10:37 +0100)]
board: .gitignore: replace dsdt.c by dsdt_generated.c

Since commit 5d94cbd1dca7 ("scripts: Makefile.lib: generate
dsdt_generated.c instead of dsdt.c"), the file generated
is named dsdt_generated.c instead of dsdt.c.
So all files .gitignore referencing dsdt.c should be
upated with dsdt_generated.c.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agodrivers: serial: Make sure we really return a serial device
Mark Kettenis [Mon, 21 Feb 2022 21:17:37 +0000 (22:17 +0100)]
drivers: serial: Make sure we really return a serial device

The stdout-path property in the device tree does not necessarily
point at a serial device. On machines such as the Apple M1 laptops
where the serial port isn't easy to access and users expect to see
console output on the integrated display stdout-path may point at
the device tree node for the framebuffer for example.

If stdout-path does not point at a node for a serial device, the
serial_check_stdout() will not find a bound device and will drop
down into code that attempts to use lists_bind_fdt() to bind a
device anyway. However, that fallback code does not check that
the uclass of the device is UCLASS_SERIAL. So if stdout-path points
at the framebuffer instead of the serial device it will return a
UCLASS_VIDEO device. Since the code that calls this function
expects the returned device to be a UCLASS_SERIAL device, U-Boot
will crash as soon as it attempts to send output to the console.

Add a check here to verify that the uclass of the bound device
really is UCLASS_SERIAL. If it isn't, serial_check_stdout() will
return an error and serial_find_console_or_panic() will use the
serial device with sequence number 0 as the console and all is fine.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years ago.mailmap: Fix Heinrich's xypron.glpk@gmx.de record
Michal Simek [Mon, 7 Mar 2022 07:41:21 +0000 (08:41 +0100)]
.mailmap: Fix Heinrich's xypron.glpk@gmx.de record

There is one issue with Heinrich xypron.glpk@gmx.de <xypron.glpk@gmx.de>
record which should be specifically grouped with his name.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-watchdog
Tom Rini [Tue, 8 Mar 2022 13:42:20 +0000 (08:42 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-watchdog

- Update MAINTAINERS file (Stefan)
- wdt-uclass.c: add a property u-boot, noautostart (Philippe)
- armada_37xx: Probe driver also when watchdog is already running (Pali)
- rti_wdt: Add 10% safety margin to clock frequency (Jan)

2 years agowatchdog: rti_wdt: Add 10% safety margin to clock frequency
Jan Kiszka [Tue, 8 Mar 2022 06:25:50 +0000 (07:25 +0100)]
watchdog: rti_wdt: Add 10% safety margin to clock frequency

When running against RC_OSC_32k, the watchdog may suffer from running
faster than expected, expiring earlier. The Linux kernel adds a 10%
margin to the timeout calculation by slowing down the read clock rate
accordingly. Do the same here, also to have comparable preset values
for both drivers.

Along this, fix the name of the local var holding to frequency - in Hz,
not kHz.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2 years agowatchdog: armada_37xx: Probe driver also when watchdog is already running
Pali Rohár [Wed, 23 Feb 2022 13:21:40 +0000 (14:21 +0100)]
watchdog: armada_37xx: Probe driver also when watchdog is already running

If Armada 37xx watchdog is started before U-Boot then CNTR_CTRL_ACTIVE bit
is set, U-Boot armada-37xx-wdt.c driver fails to initialize and so U-Boot
is unable to use or kick this watchdog.

Do not check for CNTR_CTRL_ACTIVE bit and always initialize watchdog. Same
behavior is implemented in Linux kernel driver.

This change allows to activate watchdog in firmware which loads U-Boot.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agodrivers: watchdog: wdt-uclass.c: add a property u-boot, noautostart
Philippe Reynes [Thu, 10 Feb 2022 17:17:54 +0000 (18:17 +0100)]
drivers: watchdog: wdt-uclass.c: add a property u-boot, noautostart

Since commit 492ee6b8d0e7 ("watchdog: wdt-uclass.c: handle all DM
watchdogs in watchdog_reset()"), all the watchdog are started when
the config WATCHDOG_AUTOSTART.

To avoid a binary choice none/all, a property u-boot,noautostart
may be added in the watchdog node of the u-boot device tree to not
autostart this watchdog.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoMAINTAINERS: Add watchdog maintainers entry
Stefan Roese [Thu, 13 Jan 2022 15:57:31 +0000 (16:57 +0100)]
MAINTAINERS: Add watchdog maintainers entry

I've been handling "inofficially" the watchdog related patches for a few
years now. Let's make this official and add a tree for it and also add
myself here in the MAINTAINERS file.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Harald Seiler <hws@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Sun, 6 Mar 2022 01:46:55 +0000 (20:46 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi

- Fix ARMv5/F1C100 FEL booting
- Fix F1C100 reset
- Introduce proper F1C100 boot method detection
- Enable SPI booting for F1C100

Boot tested from FEL, SPI, SD card and eMMC (where applicable) on
Pine64-LTS, Pine-H64, BananaPi M1, OrangePi Zero, LicheePi Nano(F1C100).

2 years agoMerge branch '2022-03-04-assorted-minor-fixes'
Tom Rini [Sat, 5 Mar 2022 16:34:31 +0000 (11:34 -0500)]
Merge branch '2022-03-04-assorted-minor-fixes'

- mailmap file updates, OpenSSL code cleanup, assorted TI platform
  fixes, typo fix.

2 years agolib: rsa: use actual OpenSSL 1.1.0 EVP MD API
Yann Droneaud [Tue, 1 Mar 2022 15:12:34 +0000 (16:12 +0100)]
lib: rsa: use actual OpenSSL 1.1.0 EVP MD API

Since OpenSSL 1.1.0, EVP_MD_CTX_create() is EVP_MD_CTX_new()
                     EVP_MD_CTX_destroy() is EVP_MD_CTX_free()
                     EVP_MD_CTX_init() is EVP_MD_CTX_reset()

As there's no need to reset a newly created EVP_MD_CTX, moreover
EVP_DigestSignInit() does the reset, thus call to EVP_MD_CTX_init()
can be dropped.
As there's no need to reset an EVP_MD_CTX before it's destroyed,
as it will be reset by EVP_MD_CTX_free(), call to EVP_MD_CTX_reset()
is not needed and can be dropped.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
2 years ago.mailmap: Record all address for main U-Boot contributor
Michal Simek [Tue, 1 Mar 2022 11:43:32 +0000 (12:43 +0100)]
.mailmap: Record all address for main U-Boot contributor

Based on looking at top contributors it was seen that top statistics from
top contributors don't include all contributions from different email
addresses. That's why I checked all top contributors are checked it.

git shortlog -n $START..$END -e -s

The patch is adding mapping for Bin Meng, Marek Vasut, Masahiro Yamada,
Michal Simek, Tom Rini, Wolfgang Denk.
And also use mapping for Stefan Roese and Wolfgang Denk to be properly
counted.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Acked-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agomkimage: error handling for FIT image
Heinrich Schuchardt [Tue, 1 Mar 2022 07:53:56 +0000 (08:53 +0100)]
mkimage: error handling for FIT image

If parameter -F is given but FIT support is missing, a NULL pointer might
dereferenced (Coverity CID 350249).

If incorrect parameters are given, provide a message and show usage.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agocmd: pwm: fix typo 'eisable' -> 'disable'
Sébastien Szymanski [Fri, 25 Feb 2022 13:48:54 +0000 (14:48 +0100)]
cmd: pwm: fix typo 'eisable' -> 'disable'

Fixed misspelled 'disable' in help text.

Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
2 years agoarm: dts: iot2050: Add cfg register space for ringacc and udmap
Jan Kiszka [Wed, 16 Feb 2022 08:06:49 +0000 (09:06 +0100)]
arm: dts: iot2050: Add cfg register space for ringacc and udmap

Recent unrelated fixes (9876ae7db6da) revealed that we were missing bits
from 2af181b53e28 in the IOT2050 dt. Add them, but only for main U-Boot.
SPL loads from QSPI only, thus cannot use DMA.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2 years agoconfigs: j721e_*_evm_a72_defconfig: Enable config for setting mmc speed mode
Aswath Govindraju [Wed, 16 Feb 2022 05:57:24 +0000 (11:27 +0530)]
configs: j721e_*_evm_a72_defconfig: Enable config for setting mmc speed mode

Enable config for setting mmc speed mode from U-Boot command line.

Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
2 years agoarm: mach-k3: am6_init: Use CONFIG_TI_I2C_BOARD_DETECT
Christian Gmeiner [Tue, 15 Feb 2022 06:47:55 +0000 (07:47 +0100)]
arm: mach-k3: am6_init: Use CONFIG_TI_I2C_BOARD_DETECT

We only want to call do_board_detect() if CONFIG_TI_I2C_BOARD_DETECT
is set. Same as done for am64.

This makes it possible to add a custom am65 based board design to
U-Boot that does not use this board detection mechanism.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2 years agoconfigs: ti: use standard configuration nodes naming
Romain Naour [Thu, 10 Feb 2022 22:13:36 +0000 (23:13 +0100)]
configs: ti: use standard configuration nodes naming

Currently, any u-boot bootloader for ti armv7 platforms using
DEFAULT_FIT_TI_ARGS to boot with a fitimage (boot_fit = 1)
doesn't boot when built with Yocto Poky (openembedded-core).

  ## Loading kernel from FIT Image at 90000000 ...
  Could not find configuration node
  ERROR: can't get kernel image!

Arago forked the kernel-fitimage class [1] and altered the
configuration nodes naming while adding the OPTEE support by
using FITIMAGE_CONF_BY_NAME by default [2].

The "upstream" kernel-fitimage class from openembedded-core still
add the "conf-" prefix for each configuration nodes [3].

The ITS file format (from doc/uImage.FIT/source_file_format.txt)
is not really accurate with the expected naming of these nodes.
But in practice the "conf-" prefix is widely used.

When the FIT image support has been added for ti armv7 platforms
the naming from Arago has been used [3]. Fix this issue by adding
the prefix expected by the ITS file generated by kernel-fitimage
class from openembedded-core.

[1] http://arago-project.org/git/meta-arago.git?p=meta-arago.git;a=commitdiff;h=719ab1b2098bcdc59c249e3529fa82cb1b9130e6
[2] http://arago-project.org/git/meta-arago.git?p=meta-arago.git;a=commitdiff;h=f23f2876a0cda89241d031bb7ba0b4256ed90035
[3] https://git.openembedded.org/openembedded-core/tree/meta/classes/kernel-fitimage.bbclass?h=yocto-3.1.13#n290
[3] 1e93cc8473e4fe018aececc8ed3bf8fc2b3ff561

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Denys Dmytriyenko <denys@konsulko.com>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Fri, 4 Mar 2022 13:27:32 +0000 (08:27 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- pci_mvebu: Minor cleanup (Pali)
- mvebu: turris_omnia: Enable ext4 write support (Marek)
- a37xx: Misc fixes in PCI and pinctrl (Pali & Marek)
- a38x/rtc: Fix null pointer access (Francios)
- mvebu: x530: clearfog: Fix ODT configuration (Chris)
- kwboot: Fix boot and terminal mode (Pali)

2 years agotools: kwboot: Update references with public links
Pali Rohár [Wed, 2 Mar 2022 10:49:27 +0000 (11:49 +0100)]
tools: kwboot: Update references with public links

Public documents about BootROM of some Marvell SoCs are available in the
public Web Archive. Put this information into source code.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Update doc about Avanta
Pali Rohár [Wed, 2 Mar 2022 10:49:26 +0000 (11:49 +0100)]
tools: kwboot: Update doc about Avanta

Testes proved that current kwboot version supports also Avanta SoCs.
It looks like that Avanta SoCs are using same kwbimage format as Armada.

Signed-off-by: Pali Rohár <pali@kernel.org>
Tested-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Update manpage
Pali Rohár [Wed, 2 Mar 2022 10:49:25 +0000 (11:49 +0100)]
tools: kwboot: Update manpage

Document -D, -b, -d, -q and -s options.

Add common examples how to use kwboot.

Add information about Armada 38x BootROM bug for debug console mode and how
to workaround it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Update usage
Pali Rohár [Wed, 2 Mar 2022 10:49:24 +0000 (11:49 +0100)]
tools: kwboot: Update usage

Add all supported Armada SoCs and document -b and -d options in usage.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Add support for backspace key in mini terminal
Pali Rohár [Wed, 2 Mar 2022 10:49:23 +0000 (11:49 +0100)]
tools: kwboot: Add support for backspace key in mini terminal

Marvell BootROM recognize only '\b' byte as backspace. Use terminfo
for retrieving current backspace sequence and replace any occurrence of
backspace sequence by the '\b' byte.

Reading terminfo database is possible via tigetstr() function from system
library libtinfo.so.*. So link kwboot with -ltinfo.

Normally terminfo functions are in <term.h> system header file. But this
header file conflicts with U-Boot "termios_linux.h" header file. So declare
terminfo functions manually.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Fix sending and processing debug message pattern (-d option)
Pali Rohár [Wed, 2 Mar 2022 10:49:22 +0000 (11:49 +0100)]
tools: kwboot: Fix sending and processing debug message pattern (-d option)

-d option is currently broken. In most cases BootROM does not detect this
message pattern. For sending debug message pattern it is needed to do same
steps as for boot message pattern.

Implement sending debug message pattern via same separate thread like it is
for boot message pattern.

Checking if BootROM entered into UART debug mode is different than
detecting UART boot mode. When in boot mode, BootROM sends xmodem NAK
bytes. When in debug mode, BootROM activates console echo and reply back
every written byte (extept \r\n which is interpreted as executing command
and \b which is interpreting as removing the last sent byte).

So in kwboot, check that BootROM send back at least 4 debug message
patterns as a echo reply for debug message patterns which kwboot is sending
in the loop.

Then there is another observation, if host writes too many bytes (as
command) then BootROM command line buffer may overflow after trying to
execute such long command. To workaround this overflow, it is enough to
remove bytes from the input line buffer by sending 3 \b bytes for every
sent character. So do it.

With this change, it is possbile to enter into the UART debug mode with
kwboot -d option.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Use separate thread for sending boot message pattern
Pali Rohár [Wed, 2 Mar 2022 10:49:21 +0000 (11:49 +0100)]
tools: kwboot: Use separate thread for sending boot message pattern

After BootROM successfully detects boot message pattern on UART it waits
until host stop sending data on UART. For example Armada 385 BootROM
requires that host does not send anything on UART at least 24 ms. If host
is still sending something then BootROM waits (possibly infinitely).

BootROM successfully detects boot message pattern if it receives it in
small period of time after power on.

So to ensure that host put BootROM into UART boot mode, host must send
continuous stream of boot message pattern with a small gap (for A385 at
least 24 ms) after series of pattern. But this gap cannot be too often or
too long to ensure that it does not cover whole BootROM time window when it
is detecting for boot message pattern.

Therefore it is needed to do following steps in cycle without any delay:
1. send series of boot message pattern over UART
2. wait until kernel transmit all data
3. sleep small period of time

At the same time, host needs to monitor input queue, data received on the
UART and checking if it contains NAK byte by which BootROM informs that
xmodem transfer is ready.

But it is not possible to wait until kernel transmit all data on UART and
at the same time in the one process to also wait for input data. This is
limitation of POSIX tty API and also by linux kernel that it does not
provide asynchronous function for waiting until all data are transmitted.
There is only synchronous variant tcdrain().

So to correctly implement this handshake on systems with linux kernel, it
is needed to use tcdrain() in separate thread.

Implement sending of boot message pattern in one thread and reading of
reply in the main thread. Use pthread library for threads.

This change makes UART booting on Armada 385 more reliable. It is possible
to start kwboot and power on board after minute and kwboot correctly put
board into UART boot mode.

Old implementation without separate thread has an issue that it read just
one byte from UART input queue and then it send 128 message pattern to the
output queue. If some noise was on UART then kwboot was not able to read
BootROM response as its input queue was just overflowed and kwboot was
sending more data than receiving.

This change basically fixed above issue too.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Cleanup bootmsg and debugmsg variables
Pali Rohár [Wed, 2 Mar 2022 10:49:20 +0000 (11:49 +0100)]
tools: kwboot: Cleanup bootmsg and debugmsg variables

Function kwboot_debugmsg() is always called with kwboot_msg_debug as msg
and function kwboot_bootmsg() with kwboot_msg_debug as msg. Function
kwboot_bootmsg() is never called with NULL msg.

Simplify, cleanup and remove dead code.

No functional change.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Remove msg_req_delay
Pali Rohár [Wed, 2 Mar 2022 10:49:19 +0000 (11:49 +0100)]
tools: kwboot: Remove msg_req_delay

Variable msg_req_delay is set but never used. So completely remove it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Check for return value of kwboot_tty_send() and tcflush()
Pali Rohár [Wed, 2 Mar 2022 10:49:18 +0000 (11:49 +0100)]
tools: kwboot: Check for return value of kwboot_tty_send() and tcflush()

Failure of kwboot_tty_send() and tcflush() functions is fatal, it does not
make sense to continue. So return error back to the caller like in other
places where are called these functions.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
2 years agoARM: mvebu: x530: clearfog: Add ODT configuration
Chris Packham [Tue, 1 Mar 2022 00:53:23 +0000 (13:53 +1300)]
ARM: mvebu: x530: clearfog: Add ODT configuration

Commit 369e532691e0 ("ddr: marvell: a38x: allow board specific ODT
configuration") added the odt_config member to struct
mv_ddr_topology_map ahead of the clk_enable and ck_delay members. This
means that any boards that configured either of clk_enable or ck_delay
needed to have their board topology updated. This affects the x530 and
clearfog boards. Other A38x boards don't touch any of the trailing
members of mv_ddr_topology_map so don't need updating.

Fixes: 369e532691e0 ("ddr: marvell: a38x: allow board specific ODT configuration")
Signed-off-by: Chris Packham <judge.packham@gmail.com>
Acked-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm64: a37xx: pinctrl: Fix PWM pins indexes
Marek Behún [Mon, 28 Feb 2022 14:59:37 +0000 (15:59 +0100)]
arm64: a37xx: pinctrl: Fix PWM pins indexes

Commit 5534fb4f4833 ("arm64: a37xx: pinctrl: Correct PWM pins
definitions") introduced bogus definitions os PWM pins: all 4 pins have
index 11, instead of having indexes 11, 12, 13, 14.

Fix this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agodrivers: rtc: fix null pointer access in armada38x_rtc_reset
Francois Berder [Mon, 28 Feb 2022 09:31:45 +0000 (10:31 +0100)]
drivers: rtc: fix null pointer access in armada38x_rtc_reset

Replace null pointer by pointer to device registers when calling
armada38x_rtc_write.

Signed-off-by: Francois Berder <fberder@outlook.fr>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function again
Pali Rohár [Wed, 23 Feb 2022 12:52:32 +0000 (13:52 +0100)]
arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function again

The a3700_fdt_fix_pcie_regions() function still computes nonsense.

It computes the fixup offset from the PCI address taken from the first
row of the "ranges" array, which means that:
- PCI address must equal CPU address (otherwise the computed fix offset
  will be wrong),
- the first row must contain the lowest address.

This is the case for the default device-tree, which is why we didn't
notice it.

It also adds the fixup offset to all PCI and CPU addresses, which is
wrong.

Instead:
1) The fixup offset must be computed from the CPU address, not PCI
   address.

2) The fixup offset must be computed from the row containing the lowest
   CPU address, which is not necessarily contained in the first row.

3) The PCI address - the address to which the PCIe controller remaps the
   address space as seen from the point of view of the PCIe device -
   must be fixed by the fix offset in the same way as the CPU address
   only in the special case when the CPU adn PCI addresses are the same.
   Same addresses means that remapping is disabled, and thus if we
   change the CPU address, we need also to change the PCI address so
   that the remapping is still disabled afterwards.

Consider an example:
  The ranges entries contain:
    PCI address   CPU address
    70000000      EA000000
    E9000000      E9000000
    EB000000      EB000000

  By default CPU PCIe window is at:        E8000000 - F0000000
  Consider the case when TF-A moves it to: F2000000 - FA000000

  Until now the function would take the PCI address of the first entry:
  70000000, and the new base, F2000000, to compute the fix offset:
  F2000000 - 70000000 = 82000000, and then add 8200000 to all addresses,
  resulting in
    PCI address   CPU address
    F2000000      6C000000
    6B000000      6B000000
    6D000000      6D000000
  which is complete nonsense - none of the CPU addresses is in the
  requested window.

  Now it will take the lowest CPU address, which is in second row,
  E9000000, and compute the fix offset F2000000 - E9000000 = 09000000,
  and then add it to all CPU addresses and those PCI addresses which
  equal to their corresponding CPU addresses, resulting in
    PCI address   CPU address
    70000000      F3000000
    F2000000      F2000000
    F4000000      F4000000
  where all of the CPU addresses are in the needed window.

Fixes: 4a82fca8e330 ("arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function")
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: turris_omnia: Enable ext4 write support in defconfig
Marek Behún [Fri, 18 Feb 2022 16:46:25 +0000 (17:46 +0100)]
arm: mvebu: turris_omnia: Enable ext4 write support in defconfig

Enable ext4 write support in Turris Omnia's defconfig. Some users find
it useful.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agopci: pci_mvebu: Cleanup macro names
Pali Rohár [Fri, 18 Feb 2022 11:25:23 +0000 (12:25 +0100)]
pci: pci_mvebu: Cleanup macro names

Use "MVPCIE_" prefix instead of generic "PCIE_" prefix for pci_mvebu.c
specific macros. Define offset macros for Root Port registers and use
standard register macros from pci.h when accessing Root Port registers.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agopci: pci_mvebu: Remove unused SELECT and lane_mask
Pali Rohár [Fri, 18 Feb 2022 11:25:22 +0000 (12:25 +0100)]
pci: pci_mvebu: Remove unused SELECT and lane_mask

Macro SELECT() is unused and struct mvebu_pcie field lane_mask is unused
too. Remove them.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agotools: kwboot: Fix quitting terminal
Pali Rohár [Fri, 18 Feb 2022 11:24:13 +0000 (12:24 +0100)]
tools: kwboot: Fix quitting terminal

Sometimes kwboot after quitting terminal prints error message:

  terminal: Bad address

This is caused by trying to call write() syscall with count of (size_t)-1
bytes.

When quit sequence is split into more read() calls then number of input
bytes (nin) at the end of cycle can underflow and be negative. Fix it.

Fixes: de7514046ea5 ("tools: kwboot: Fix detection of quit esc sequence")
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoMerge tag 'u-boot-at91-fixes-2022.04-a' of https://source.denx.de/u-boot/custodians...
Tom Rini [Thu, 3 Mar 2022 13:24:37 +0000 (08:24 -0500)]
Merge tag 'u-boot-at91-fixes-2022.04-a' of https://source.denx.de/u-boot/custodians/u-boot-at91

First set of u-boot-atmel fixes for the 2022.04 cycle:

This fixes set includes only a single fix for the Ethernet on sama7g5ek
board which is broken at the moment.

2 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
Tom Rini [Thu, 3 Mar 2022 13:24:13 +0000 (08:24 -0500)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq

Update and fixes for sl28, lx2, pblimage generation for some powerpc
products

2 years agosunxi: f1c100s: Drop SYSRESET to enable reset functionality
Andre Przywara [Wed, 2 Mar 2022 01:30:55 +0000 (01:30 +0000)]
sunxi: f1c100s: Drop SYSRESET to enable reset functionality

The F1C100s DT contains the wrong compatible string for the watchdog,
which breaks reset functionality.
Updating the DT goes via the Linux tree, but to allow reset
functionality meanwhile (useful for development!), disable SYSRESET for
now, to let the old-fashioned watchdog driver kick in and provide the
reset_cpu() implementation.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: f1c100s: Fix FEL registers restore
Andre Przywara [Tue, 1 Mar 2022 12:21:58 +0000 (12:21 +0000)]
sunxi: f1c100s: Fix FEL registers restore

Commit 88998f777531 ("arm: arm926ej-s: Add sunxi code") introduced
the ARM926 version of the code to save and restore some FEL state, to
be able to return to the BROM FEL code after the SPL has run.

However during review a change was made, that happened to mess up the
register restore part, so SCTLR and CPSR ended up with the wrong values,
breaking return to FEL.

Use the same offset that we actually save those registers to, to make
FEL booting actually work on the Lichee Pi Nano.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agomach-sunxi: Enable SPI boot for SUNIV and licheepi nano
Jesse Taube [Sat, 12 Feb 2022 00:32:35 +0000 (19:32 -0500)]
mach-sunxi: Enable SPI boot for SUNIV and licheepi nano

Enable SPI boot in SPL on SUNIV architecture and use
it in the licheepi nano that uses the F1C100s.

Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agomach-sunxi: Add SPL SPI boot for SUNIV
Jesse Taube [Sat, 12 Feb 2022 00:32:34 +0000 (19:32 -0500)]
mach-sunxi: Add SPL SPI boot for SUNIV

The SUNIV SoCs come with a sun6i-style SPI controller at the base address
of sun4i SPI controller. The module clock of the SPI controller is
missing which leaves us running directly from the AHB clock, which is
set to 200MHz.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
[Icenowy: Original implementation]
Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
[Jesse: adaptation to Upstream U-Boot]
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agomach-sunxi: Add boot device detection for SUNIV/F1C100s
Jesse Taube [Sat, 12 Feb 2022 00:32:33 +0000 (19:32 -0500)]
mach-sunxi: Add boot device detection for SUNIV/F1C100s

In contrast to other Allwinner SoCs the F1C100s BROM does not store a
boot source indicator in the eGON header in SRAM. This leaves the SPL
guessing where we were exactly booted from, and for instance trying
the SD card first, even though we booted from SPI flash.

By inspecting the BROM code and by experimentation, Samuel found that the
top of the BROM stack contains unique pointers for each of the boot
sources, which we can use as a boot source indicator.

This patch removes the existing board_boot_order bodge and replace it
with a proper boot source indication function.

The only caveat is that this only works in the SPL, as the SPL header
gets overwritten with the exception vectors, once U-Boot proper takes
over. Always return MMC0 as the boot source, when called from U-Boot
proper, as a placeholder for now, until we find another way.

Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
Suggested-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Tue, 1 Mar 2022 12:48:39 +0000 (07:48 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

2 years agophy: nop-phy: Fix phy reset if no reset-gpio defined
Tim Harvey [Mon, 28 Feb 2022 22:53:21 +0000 (14:53 -0800)]
phy: nop-phy: Fix phy reset if no reset-gpio defined

Ensure there is a valid reset-gpio defined before using it.

Fixes: f9852acdce02 ("phy: nop-phy: Fix enabling reset")
Cc: Adam Ford <aford173@gmail.com>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
2 years agoPrepare v2022.04-rc3
Tom Rini [Mon, 28 Feb 2022 23:02:33 +0000 (18:02 -0500)]
Prepare v2022.04-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMerge branch '2022-02-28-bugfixes'
Tom Rini [Mon, 28 Feb 2022 20:45:52 +0000 (15:45 -0500)]
Merge branch '2022-02-28-bugfixes'

- Assorted bugfixes

2 years agoboard: stemmy: Detect board variants and patch DTB
Linus Walleij [Sun, 20 Feb 2022 22:47:01 +0000 (23:47 +0100)]
board: stemmy: Detect board variants and patch DTB

This patch scans the cmdline from the Samsung SBL (second stage
bootloader) and stores the parameters board_id=N and lcdtype=N
in order to augment the DTB for different board and LCD types.

We then add a custom ft_board_setup() callback that will inspect
the DTB and patch it using the stored LCD type. At this point
we know which product we are dealing with, so using the passed
board_id we can also print the board variant for diagnostics.

We patch the Codina, Skomer and Kyle DTBs to use the right
LCD type as passed in lcdtype from the SBL.

This also creates an infrastructure for handling any other
Samsung U8500 board variants that may need a slightly augmented
DTB.

Cc: Markuss Broks <markuss.broks@gmail.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2 years agoarm: apple: Switch to fully dynamic mem layout
Janne Grunau [Sat, 19 Feb 2022 13:05:19 +0000 (14:05 +0100)]
arm: apple: Switch to fully dynamic mem layout

Support for Apple M1 Pro and Max will allow using a single binary for
all M1 SoCs. The M1 Pro/Max have a different memory layout. The RAM
start address is 0x100_0000_0000 instead of 0x8_0000_0000.
Replace the hardcoded memory layout with dynamic initialized
environment variables in board_late_init().

Tested on Mac Mini (2020) and Macbook Pro 14-inch (2021).

Signed-off-by: Janne Grunau <j@jannau.net>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
2 years agoarm: pdu001: Setup pinmux for console UART as early as possible
Felix Brack [Mon, 21 Feb 2022 13:26:05 +0000 (14:26 +0100)]
arm: pdu001: Setup pinmux for console UART as early as possible

To make sure we get a working console as soon as possible in the SPL the
UART pins require to be configured earlier. This is especially
true for the pins of UART3, since the PDU001 board uses this UART for
the console by default.

Signed-off-by: Felix Brack <fb@ltec.ch>
2 years agoarm: pdu001: Fix early debugging UART
Felix Brack [Tue, 15 Feb 2022 14:27:23 +0000 (15:27 +0100)]
arm: pdu001: Fix early debugging UART

The changes from commit 0dba45864b2a ("arm: Init the debug UART")
prevent the early debug UART from being initialized correctly.
To fix this we not just configure the pin multiplexer but add setting up
early clocks.

Signed-off-by: Felix Brack <fb@ltec.ch>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agotools: mkimage/dumpimage: Allow to use -l with -T
Pali Rohár [Sun, 13 Feb 2022 00:09:46 +0000 (01:09 +0100)]
tools: mkimage/dumpimage: Allow to use -l with -T

Currently -l option for mkimage and dumpimage ignores option -T and always
tries to autodetect image type.

With this change it is possible to tell mkimage and dumpimage to parse
image file as specific type (and not random autodetected type). This allows
to use mkimage -l or dumpimage -l as tool for validating image.

params.type for -l option is now by default initialized to zero
(IH_TYPE_INVALID) instead of IH_TYPE_KERNEL. imagetool_get_type() for
IH_TYPE_INVALID returns NULL, which is assigned to tparams. mkimage and
dumpimage code is extended to handle tparams with NULL for -l option. And
imagetool_verify_print_header() is extended to do validation via tparams if
is not NULL.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agotools: pblimage: fix image header verification function
Hou Zhiqiang [Thu, 17 Feb 2022 03:51:36 +0000 (11:51 +0800)]
tools: pblimage: fix image header verification function

The Layerscape platforms have different RCW header value from FSL
PowerPC platforms, the current image header verification callback
is only working on PowerPC, it will fail on Layerscape, this patch
is to fix this issue.

This is a historical problem and exposed by the following patch:
http://patchwork.ozlabs.org/project/uboot/patch/20220114173443.9877-1-pali@kernel.org

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agolx2160a: Fix distroboot device list for configs without USB/SCSI/etc
Daniel Klauer [Wed, 9 Feb 2022 14:53:41 +0000 (15:53 +0100)]
lx2160a: Fix distroboot device list for configs without USB/SCSI/etc

The BOOT_TARGET_DEVICES list for distro_bootcmd was hard-coded to assume
that all boot devices are available/enabled in the configuration,
thus ignoring the actual config settings. The config_distro_bootcmd.h
header file specifically has compile-time checks to detect such problems.

To allow disabling USB, SCSI, etc. in custom lx2160a board configs,
make it depend on the config settings and use only the enabled features.

Signed-off-by: Daniel Klauer <daniel.klauer@gin.de>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: use fit image generator
Michael Walle [Fri, 25 Feb 2022 12:51:56 +0000 (18:21 +0530)]
board: sl28: use fit image generator

Simplify the binman config and fdt nodes by using the "@..-SEQ"
substitutions and CONFIG_OF_LIST.

Signed-off-by: Michael Walle <michael@walle.cc>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: disable random MAC address generation
Michael Walle [Fri, 25 Feb 2022 12:48:40 +0000 (18:18 +0530)]
board: sl28: disable random MAC address generation

Nowadays, u-boot (when CONFIG_NET_RANDOM_ETHADDR is set) will set
enetaddr to a random value if not set and then pass the randomly
generated MAC address to linux.

This is bad for the following reasons:
 (1) it makes it impossible for linux to detect this error
 (2) linux won't trigger any fallback mechanism for the case where
     it didn't find any valid MAC address
 (3) a saveenv will store this randomly generated MAC address in the
     environment

Probably, the user will also be unaware that something is wrong. He will
just get different MAC addresses on each reboot, asking himself why this
is the case.

As this board usually have a serial port, the user can just fix this by
setting the MAC address manually in the environment. Also disable the
netconsole just in case, because it cannot be guaranteed that it will
work in any case. After all, this was just a convenience option, because
the bootloader - right now - doesn't have the ability to read the MAC
address, which is stored in the OTP. But it is far more important to
have a clear view of whats wrong with a board and that means we can no
longer use this Kconfig option.

Signed-off-by: Michael Walle <michael@walle.cc>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: remove "Useful I2C tricks" section from docs
Michael Walle [Mon, 15 Nov 2021 22:45:50 +0000 (23:45 +0100)]
board: sl28: remove "Useful I2C tricks" section from docs

They are no longer needed, because we now have proper driver support for
the sl28cpld management controller.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: disable recovery watchdog
Michael Walle [Mon, 15 Nov 2021 22:45:49 +0000 (23:45 +0100)]
board: sl28: disable recovery watchdog

This board has an internal watchdog which supervises the board startup.
Although, the initial state of the watchdog is configurable, it is
enabled by default. In board_late_init(), which means almost everything
worked as expected, disable the watchdog.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: enable SoC watchdog support
Michael Walle [Mon, 15 Nov 2021 22:45:48 +0000 (23:45 +0100)]
board: sl28: enable SoC watchdog support

The SoC provides two additional watchdogs integrated in the SoC. Enable
support for these.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: enable sl28cpld support
Michael Walle [Mon, 15 Nov 2021 22:45:47 +0000 (23:45 +0100)]
board: sl28: enable sl28cpld support

Enable the GPIO and watchdog driver. Don't start the watchdog
automatically, though.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: print CPLD version on bootup
Michael Walle [Mon, 15 Nov 2021 22:45:46 +0000 (23:45 +0100)]
board: sl28: print CPLD version on bootup

Most of the time it is very useful to have the version of the board
management controller. Now that we have a driver, print it during
startup.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: sl28: fix DRAM pretty print
Michael Walle [Mon, 15 Nov 2021 22:45:45 +0000 (23:45 +0100)]
board: sl28: fix DRAM pretty print

The current console output is:

DRAM:  4 GiB
DDR    4 GiB (DDR3, 32-bit, CL=11, ECC on)

The size is printed twice and we can save one line of console output if
we join both lines. The new output is as follows:

DRAM:  4 GiB (DDR3, 32-bit, CL=11, ECC on)

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agogpio: add sl28cpld driver
Michael Walle [Fri, 25 Feb 2022 12:40:24 +0000 (18:10 +0530)]
gpio: add sl28cpld driver

The gpio block is part of the sl28cpld sl28cpld management controller.
There are three different flavors: the usual input and output where the
direction is configurable, but also input only and output only variants.

Signed-off-by: Michael Walle <michael@walle.cc>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agowatchdog: add sl28cpld watchdog driver
Michael Walle [Mon, 15 Nov 2021 22:45:43 +0000 (23:45 +0100)]
watchdog: add sl28cpld watchdog driver

The watchdog timer is part of the sl28cpld management controller. The
watchdog timer usually supervises the bootloader boot-up and if it bites
the failsafe bootloader will be activated. Apart from that it supports
the usual board level reset and one SMARC speciality: driving the
WDT_TIMEOUT# signal.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agomisc: add sl28cpld base driver
Michael Walle [Fri, 25 Feb 2022 12:36:24 +0000 (18:06 +0530)]
misc: add sl28cpld base driver

Add a multi-function device driver which will probe its children and
provides methods to access the device.

Signed-off-by: Michael Walle <michael@walle.cc>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoMerge tag 'efi-2022-04-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sat, 26 Feb 2022 15:21:39 +0000 (10:21 -0500)]
Merge tag 'efi-2022-04-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-04-rc3

Documentation:

* add man-page for fatload
* add SMBIOS table page

UEFI:

* partial fix for UEFI secure boot with intermediate certs
* disable watchdog when returning to command line
* reset system after capsule update

2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-sh
Tom Rini [Sat, 26 Feb 2022 15:21:13 +0000 (10:21 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-sh

- rzg2_beacon updates

2 years agoefi_loader: update the timing of enabling and disabling EFI watchdog
Masahisa Kojima [Tue, 22 Feb 2022 00:58:30 +0000 (09:58 +0900)]
efi_loader: update the timing of enabling and disabling EFI watchdog

UEFI specification requires that 5 minutes watchdog timer is
armed before the firmware's boot manager invokes an EFI boot option.
This watchdog timer is updated as follows, according to the
UEFI specification.

 1) The EFI Image may reset or disable the watchdog timer as needed.
 2) If control is returned to the firmware's boot manager,
    the watchdog timer must be disabled.
 3) On successful completion of EFI_BOOT_SERVICES.ExitBootServices()
    the watchdog timer is disabled.

1) is up to the EFI image, and 3) is already implemented in U-Boot.
This patch implements 2), the watchdog is disabled when control is
returned to U-Boot.

In addition, current implementation arms the EFI watchdog at only
the first "bootefi" invocation. The EFI watchdog must be armed
in every EFI boot option invocation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi_loader: test/py: Reset system after capsule update on disk
Masami Hiramatsu [Wed, 16 Feb 2022 06:16:12 +0000 (15:16 +0900)]
efi_loader: test/py: Reset system after capsule update on disk

Add a cold reset soon after processing capsule update on disk.
This is required in UEFI specification 2.9 Section 8.5.5
"Delivery of Capsules via file on Mass Storage device" as;

    In all cases that a capsule is identified for processing the system is
    restarted after capsule processing is completed.

This also reports the result of each capsule update so that the user can
notice that the capsule update has been succeeded or not from console log.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agotest/py: Handle expected reboot while booting sandbox
Masami Hiramatsu [Wed, 16 Feb 2022 06:16:02 +0000 (15:16 +0900)]
test/py: Handle expected reboot while booting sandbox

Add expected_reset optional argument to ConsoleBase::ensure_spawned(),
ConsoleBase::restart_uboot() and ConsoleSandbox::restart_uboot_with_flags()
so that it can handle a reset while the 1st boot process after main
boot logo before prompt correctly.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agotest/py: Handle expected reset by command
Masami Hiramatsu [Wed, 16 Feb 2022 06:15:52 +0000 (15:15 +0900)]
test/py: Handle expected reset by command

Add wait_for_reboot optional argument to ConsoleBase::run_command()
so that it can handle an expected reset by command execution.

This is useful if a command will reset the sandbox while testing
such commands, e.g. run_command("reset", wait_for_reboot = True)

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi_loader: use efi_update_capsule_firmware() for capsule on disk
Masami Hiramatsu [Wed, 16 Feb 2022 06:15:42 +0000 (15:15 +0900)]
efi_loader: use efi_update_capsule_firmware() for capsule on disk

Since the efi_update_capsule() represents the UpdateCapsule() runtime
service, it has to handle the capsule flags and update ESRT. However
the capsule-on-disk doesn't need to care about such things.

Thus, the capsule-on-disk should use the efi_capsule_update_firmware()
directly instead of calling efi_update_capsule().

This means the roles of the efi_update_capsule() and capsule-on-disk
are different. We have to keep the efi_update_capsule() for providing
runtime service API at boot time.

Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agoefi_loader: fix uefi secure boot with intermediate certs
Ilias Apalodimas [Mon, 14 Feb 2022 09:14:22 +0000 (11:14 +0200)]
efi_loader: fix uefi secure boot with intermediate certs

The general rule of accepting or rejecting an image is
 1. Is the sha256 of the image in dbx
 2. Is the image signed with a certificate that's found in db and
    not in dbx
 3. The image carries a cert which is signed by a cert in db (and
    not in dbx) and the image can be verified against the former
 4. Is the sha256 of the image in db

For example SHIM is signed by "CN=Microsoft Windows UEFI Driver Publisher",
which is issued by "CN=Microsoft Corporation UEFI CA 2011", which in it's
turn is issued by "CN=Microsoft Corporation Third Party Marketplace Root".
The latter is a self-signed CA certificate and with our current implementation
allows shim to execute if we insert it in db.

However it's the CA cert in the middle of the chain which usually ends up
in the system's db.  pkcs7_verify_one() might or might not return the root
certificate for a given chain.  But when verifying executables in UEFI,  the
trust anchor can be in the middle of the chain, as long as that certificate
is present in db.  Currently we only allow this check on self-signed
certificates,  so let's remove that check and allow all certs to try a
match an entry in db.

Open questions:
- Does this break any aspect of variable authentication since
  efi_signature_verify() is used on those as well?

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2 years agotools: mkeficapsule: remove duplicated code
AKASHI Takahiro [Wed, 16 Feb 2022 01:49:51 +0000 (10:49 +0900)]
tools: mkeficapsule: remove duplicated code

That code is mistakenly duplicated due to copy-and-paste error.
Just remove it.

Fixes: CID 348360
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: describe fatload command
Heinrich Schuchardt [Fri, 18 Feb 2022 18:33:09 +0000 (19:33 +0100)]
doc: describe fatload command

Man-page for fatload command.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: describe generation of SMBIOS table
Heinrich Schuchardt [Wed, 16 Feb 2022 06:59:31 +0000 (07:59 +0100)]
doc: describe generation of SMBIOS table

SMBIOS is not x86 specific. So we should have an architecture independent
page describing it.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoarm: rmobile: rzg2_beacon: Enable proper Ethernet PHY
Adam Ford [Fri, 25 Feb 2022 20:32:53 +0000 (14:32 -0600)]
arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY

The wrong phy was being enabled, because it worked and the proper
PHY did not.  After the Renesas maintainer made some adjustments
to the device tree, Linux was able to use the proper driver, and
when that device tree was ported to Linux, the ethernet stopped
working due to the lack of rgmii-rxid support.  Now that
rgmii-rxid is supported, enable the proper driver to restore
ethernet function.

Fixes: 1eaf61c84db6 ("arm: dts: beacon-rzg2: Resync device trees with Linux 5.16-rc3")
Signed-off-by: Adam Ford <aford173@gmail.com>
2 years agonet: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
Adam Ford [Fri, 25 Feb 2022 20:32:52 +0000 (14:32 -0600)]
net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid

Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford <aford173@gmail.com>
2 years agoMerge tag 'clk-2022.04-rc2' of https://source.denx.de/u-boot/custodians/u-boot-clk
Tom Rini [Fri, 25 Feb 2022 16:21:32 +0000 (11:21 -0500)]
Merge tag 'clk-2022.04-rc2' of https://source.denx.de/u-boot/custodians/u-boot-clk

Clock patches for v2022.04-rc2

This has an assortment of cleanups and the occasional bugfix. Also present
is the addition of the clock subsystem documentation to HTML docs.

CI: https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/11075

2 years agoscripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c
Philippe Reynes [Tue, 22 Feb 2022 13:54:39 +0000 (14:54 +0100)]
scripts: Makefile.lib: generate dsdt_generated.c instead of dsdt.c

There is a conflict between the static file
lib/acpi/dsdt.c and the file dsdt.c generated
dynamicaly by scripts/Makefile.lib. When a
mrproper is done, the static file dsdt.c is
removed. If a build with acpi enabled is
launched after, the following error is raised:

  CC      lib/acpi/acpi_table.o
make[2]: *** No rule to make target 'lib/acpi/dsdt.asl', needed by 'lib/acpi/dsdt.c'.  Stop.
scripts/Makefile.build:394: recipe for target 'lib/acpi' failed

To avoid such error, the generated file is named
dsdt_generated.c instead of dstdt.c.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Tested-by: Heiko Thiery <heiko.thiery@gmail.com>
2 years agocmd: clk: fix long help message
Patrick Delaunay [Mon, 31 Jan 2022 16:21:40 +0000 (17:21 +0100)]
cmd: clk: fix long help message

Fix the long help message for "clk setfreq" command

Fixes: 7ab418fbe612 ("clk: add support for setting clk rate from cmdline")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Link: https://lore.kernel.org/r/20220131172131.4.Ic863c28ffdcc15b3f4616434c2efd88b4e45495c@changeid
2 years agocmd: clk: update result of do_clk_setfreq
Patrick Delaunay [Mon, 31 Jan 2022 16:21:39 +0000 (17:21 +0100)]
cmd: clk: update result of do_clk_setfreq

Update the result of do_clk_setfreq and always returns a CMD_RET_ value
(-EINVAL was a possible result).

This patch avoid the CLI output "exit not allowed from main input shell."

Fixes: 7ab418fbe612 ("clk: add support for setting clk rate from cmdline")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Link: https://lore.kernel.org/r/20220131172131.3.Iec2029edb7fc0b29e13bcb86058ad2f614f62779@changeid
2 years agocmd: clk: replace clk_lookup by uclass_get_device_by_name
Patrick Delaunay [Mon, 31 Jan 2022 16:21:38 +0000 (17:21 +0100)]
cmd: clk: replace clk_lookup by uclass_get_device_by_name

The function clk_lookup can be replaced by a direct call
to uclass_get_device_by_name for UCLASS_CLK.

This patch removes duplicated codes by the generic DM API and avoids
issue in clk_lookup because result of uclass_get_device wasn't tested;
when ret < 0, dev = NULL and dev->name is invalid, the next function
call strcmp(name, dev->name) causes a crash.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20220131172131.2.I7bc7762eff1e31ab7ff5b34c416ee03b8fe52200@changeid
2 years agocmd: clk: test the number of argument in setfreq command
Patrick Delaunay [Mon, 31 Jan 2022 16:21:37 +0000 (17:21 +0100)]
cmd: clk: test the number of argument in setfreq command

Test the number of argument in setfreq command to avoid a crash when
the command setfreq is called without argument:

  STM32MP> clk setfreq
  data abort
  pc : [<ddba3f18>]    lr : [<ddba3f89>]
  reloc pc : [<c018ff18>]    lr : [<c018ff89>]
  sp : dbaf45b8  ip : ddb1d859  fp : 00000002
  r10: dbb3fd80  r9 : dbb11e90  r8 : ddbf38cc
  r7 : ddb39725  r6 : 00000000  r5 : 00000000  r4 : dbb3fd84
  r3 : dbb3fd84  r2 : 0000000a  r1 : dbaf45bc  r0 : 00000011
  Flags: nzCv  IRQs off  FIQs off  Mode SVC_32 (T)
  Code: 4dd3 1062 85a3 ddbd (7803) 2b30
  Resetting CPU ...

Fixes: 7ab418fbe612 ("clk: add support for setting clk rate from cmdline")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Link: https://lore.kernel.org/r/20220131172131.1.I32a8f213d330dccd922f7aafc60d3d63fcbe8615@changeid
2 years agoclk: ccf: correct the test on the parent uclass in clk_enable/clk_disable
Patrick Delaunay [Mon, 24 Jan 2022 13:17:14 +0000 (14:17 +0100)]
clk: ccf: correct the test on the parent uclass in clk_enable/clk_disable

It is safe to check if the uclass id on the device is UCLASS_CLK
before to call the clk_ functions, but today this comparison is
not done on the device used in API: clkp->dev->parent
but on the device himself: clkp->dev.

This patch corrects this behavior and tests if the parent device
is a clock device before to call the clock API, clk_enable or
clk_disable, on this device.

Fixes: 0520be0f67e3 ("clk: prograte clk enable/disable to parent")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
2 years agoclk: Add clk_get_by_name_optional
Sean Anderson [Sat, 15 Jan 2022 20:52:47 +0000 (15:52 -0500)]
clk: Add clk_get_by_name_optional

This adds a helper function for clk_get_by_name in cases where the clock is
optional. Hopefully this helps point driver writers in the right direction.
Also convert some existing users.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/r/20220115205247.566210-2-seanga2@gmail.com