platform/kernel/u-boot.git
16 months agotools: kwbimage: Fix endianity when dumping NAND_PAGE_SIZE
Pali Rohár [Sat, 14 Jan 2023 13:31:00 +0000 (14:31 +0100)]
tools: kwbimage: Fix endianity when dumping NAND_PAGE_SIZE

Fixes: 1a8e6b63e24f ("tools: kwbimage: Dump kwbimage config file on '-p -1' option")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwbimage: Fix dumping register set / DATA commands
Pali Rohár [Sun, 8 Jan 2023 12:53:48 +0000 (13:53 +0100)]
tools: kwbimage: Fix dumping register set / DATA commands

Upper-bound for iterating for-loop over register set entries is incorrect.
Fix it byt calculating correct number of entries.

And fix also dumping the last entry DATA_DELAY, which is the last and not
first (zero).

Fixes: 1a8e6b63e24f ("tools: kwbimage: Dump kwbimage config file on '-p -1' option")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Enable command by default
Pali Rohár [Sat, 21 Jan 2023 22:51:15 +0000 (23:51 +0100)]
cmd: mvebu/bubt: Enable command by default

This makes updating of u-boot/firmware on Marvell boards easier.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Fix warnings: unused variable 'secure_mode' and 'fuse_read_u64'...
Pali Rohár [Mon, 20 Feb 2023 21:42:54 +0000 (22:42 +0100)]
cmd: mvebu/bubt: Fix warnings: unused variable 'secure_mode' and 'fuse_read_u64' defined but not used

'secure_mode' and 'fuse_read_u64' are used only on A38x and A37xx.

Fixes: f7b0bbca2b62 ("cmd: mvebu/bubt: Check for A38x/A37xx OTP secure bits and secure boot")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Better guess default MVEBU_*_BOOT option
Pali Rohár [Sat, 21 Jan 2023 22:38:31 +0000 (23:38 +0100)]
cmd: mvebu/bubt: Better guess default MVEBU_*_BOOT option

For 32-bit Armada boards which use SPL we can determinate boot device from
existing MVEBU_SPL_BOOT_DEVICE_* option. For all other boards (e.g. 64-bit
Armada) default option still needs to be set manually.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Set correct default image name for 32-bit Armada SoCs
Pali Rohár [Sun, 8 Jan 2023 13:01:03 +0000 (14:01 +0100)]
cmd: mvebu/bubt: Set correct default image name for 32-bit Armada SoCs

32-bit Armada SoCs uses u-boot binary packed in kwbimage format. Name of
the image is in CONFIG_BUILD_TARGET option. So use it as a default option
in Kconfig.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Check also A8K boot image checksum
Pali Rohár [Sun, 29 Jan 2023 17:49:04 +0000 (18:49 +0100)]
cmd: mvebu/bubt: Check also A8K boot image checksum

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Do not modify image in A8K check_image_header()
Pali Rohár [Sun, 29 Jan 2023 17:38:11 +0000 (18:38 +0100)]
cmd: mvebu/bubt: Do not modify image in A8K check_image_header()

Change checksum verification code so it does require to modify image.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Mark all local symbols as static
Pali Rohár [Tue, 10 Jan 2023 21:47:17 +0000 (22:47 +0100)]
cmd: mvebu/bubt: Mark all local symbols as static

There is no need to export these local functions and structures.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Rename variable image_size to hdr_size
Pali Rohár [Sun, 8 Jan 2023 13:31:28 +0000 (14:31 +0100)]
cmd: mvebu/bubt: Rename variable image_size to hdr_size

Variable image_size contains size of the header, not size of the whole
image. Rename this variable to reflect content.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Add support for reading image from the SATA disk partition
Pali Rohár [Sat, 21 Jan 2023 22:29:36 +0000 (23:29 +0100)]
cmd: mvebu/bubt: Add support for reading image from the SATA disk partition

This change allows to load boot image from the first SATA/SCSI device
partition and burn it to board boot location (e.g. SPI-NOR). This is
particularly when storage device is not handled by U-Boot as USB mass
storage (which is already supported by bubt) but as SATA/SCSI device.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Add support for writing image to SATA disk
Pali Rohár [Sun, 22 Jan 2023 00:25:12 +0000 (01:25 +0100)]
cmd: mvebu/bubt: Add support for writing image to SATA disk

All 32-bit Armada SoCs and also 64-bit Armada 3720 SoC can load and boot
firmware from SATA disk. This adds support for updating firmware binary for
these SoCs. On 32-bit Armada SoC is firmware stored at sector 1 and on
Armada 3720 is stored at MBR partition 0x4d or GPT partition with type GUID
6828311A-BA55-42A4-BCDE-A89BB5EDECAE (Marvell Armada 3700 Boot partition).

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Add support for selecting eMMC HW partition
Pali Rohár [Sat, 21 Jan 2023 21:58:28 +0000 (22:58 +0100)]
cmd: mvebu/bubt: Add support for selecting eMMC HW partition

Support for burning into the correct eMMC HW boot partition was broken and
removed in commit 96be2f072768 ("mvebu: bubt: Drop dead code"). Reimplement
this functionality and bring it back again.

Fixes: 96be2f072768 ("mvebu: bubt: Drop dead code")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Show image type and error parsing reasons
Pali Rohár [Tue, 10 Jan 2023 21:33:56 +0000 (22:33 +0100)]
tools: kwboot: Show image type and error parsing reasons

Show image type and version during parsing of kwbimage.
And show reasons in error messages when parsing failed.
This can help to debug issues with invalid images.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Fix patching of SPI/NOR XIP images
Pali Rohár [Sat, 21 Jan 2023 11:59:20 +0000 (12:59 +0100)]
tools: kwboot: Fix patching of SPI/NOR XIP images

Marvell BootROM interprets execaddr of SPI/NOR XIP images as relative byte
offset from the from the beginning of the flash device. So if data image
offset and execute offset are not same then it is needed to adjust them
also in DDR RAM.

Fixes: f2c644e0b8bc ("tools: kwboot: Patch destination address to DDR area for SPI image")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Add check that kwbimage contains DDR init code
Pali Rohár [Sun, 8 Jan 2023 12:46:14 +0000 (13:46 +0100)]
tools: kwboot: Add check that kwbimage contains DDR init code

Some NOR images may be execute-in-place and do not contain DDR init code in
its kwbimage header. Such images cannot be booted over UART as BootROM
loads them to RAM. Add check that kwbimage contains DDR init code in its
header (either as binary code header or as the simple register-value set).

In some cases it is possible to load very small image into L2SRAM and when
DDR init code is not required. So check for L2SRAM load address and skip
DDR init code check in this case.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Validate optional kwbimage v1 headers
Pali Rohár [Sun, 8 Jan 2023 12:42:07 +0000 (13:42 +0100)]
tools: kwboot: Validate optional kwbimage v1 headers

Before starting parsing of kwbimage, first validate that all optional v1
headers and correct. This prevents kwboot crashes on invalid input.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Fix parsing UART image without data checksum
Pali Rohár [Sun, 8 Jan 2023 12:38:27 +0000 (13:38 +0100)]
tools: kwboot: Fix parsing UART image without data checksum

The 32-bit data checksum in UART image is not checked by the BootROM and
also Marvell tools do not generate it.

So if data checksum stored in UART image does not match calculated checksum
from the image then treat those checksum bytes as part of the executable
image code (and not as the checksum) and for compatibility with the rest of
the code manually insert data checksum into the in-memory image after the
executable code, without overwriting it.

This should allow to boot UART images generated by Marvell tools.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Add image type documentation
Pali Rohár [Sat, 21 Jan 2023 18:57:28 +0000 (19:57 +0100)]
tools: kwboot: Add image type documentation

Add information of all available image types and where they should be
stored. Storage location offsets where documented from the disassembly of
the A385 BootROM image dump.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Add more documentation references
Pali Rohár [Sun, 8 Jan 2023 12:34:24 +0000 (13:34 +0100)]
tools: kwboot: Add more documentation references

Add reference to Avanta Boot Flow documentation, BobCat2, AlleyCat3 and
PONCat3 BootROM Firmware documentation and links to public Marvell tools:
hdrparser.c and doimage.c

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agoarm: mvebu: spl: Fix support for loading U-Boot proper from SD card
Pali Rohár [Sun, 8 Jan 2023 23:52:09 +0000 (00:52 +0100)]
arm: mvebu: spl: Fix support for loading U-Boot proper from SD card

Marvell BootROM loads MMC image from sector 0 (HW boot or data partition)
and SD image from sector 1.

So for SD card booting it is needed to not use constant CONFIG MMC options
and instead of them it is needed to define functions spl_mmc_boot_mode()
spl_mmc_get_uboot_raw_sector() which determinate offsets at SPL runtime
based on MMC or SD card.

Calculation of SD card sector expects following values:
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0

Fixes: 2226ca173486 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agospl: mmc: Allow to disable SYS_MMCSD_FS_BOOT_PARTITION
Pali Rohár [Sat, 21 Jan 2023 14:13:08 +0000 (15:13 +0100)]
spl: mmc: Allow to disable SYS_MMCSD_FS_BOOT_PARTITION

On some platforms is SYS_MMCSD_FS_BOOT_PARTITION unsupported. So allow to
completely disable MMC FS Boot support via new option SYS_MMCSD_FS_BOOT.

By default MMC FS Boot support is enabled (like it was before) except for
ARCH_MVEBU where MMC FS Boot supported is unsupported due to Marvell
BootROM limitations.

Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agoarm: mvebu: spl: Load proper U-Boot from selected eMMC boot partition
Pali Rohár [Sun, 8 Jan 2023 12:31:41 +0000 (13:31 +0100)]
arm: mvebu: spl: Load proper U-Boot from selected eMMC boot partition

When eMMC boot is selected then BootROM loads kwbimage header (U-Boot SPL)
from the selected eMMC boot partition. So for eMMC boot ensure that U-Boot
SPL loads U-Boot proper (from kwbimage) also from the same selected eMMC
boot partition.

Fixes: 2226ca173486 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agoarm: mvebu: spl: Remove checks for BOOT_DEVICE_MMC2 and BOOT_DEVICE_MMC2_2
Pali Rohár [Sun, 8 Jan 2023 12:27:07 +0000 (13:27 +0100)]
arm: mvebu: spl: Remove checks for BOOT_DEVICE_MMC2 and BOOT_DEVICE_MMC2_2

BOOT_DEVICE_MMC2 and BOOT_DEVICE_MMC2_2 are representing mmc dev 1 but all
Armada SoCs have only one mmc controller. So remove references to
non-existent second mmc controller.

Fixes: f830703f4284 ("arm: mvebu: Check that kwbimage blockid matches boot mode")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Fix parsing SATA kwbimage
Pali Rohár [Sat, 21 Jan 2023 12:59:20 +0000 (13:59 +0100)]
cmd: mvebu/bubt: Fix parsing SATA kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SATA image as number of sectors the beginning of the hard
drive, but as number of sectors relative to the main header.

Reject invalid and accept valid SATA images.

Fixes: 5a0653493307 ("cmd: mvebu/bubt: Check for A38x image data checksum")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agoarm: mvebu: spl: Fix parsing SATA kwbimage
Pali Rohár [Sat, 21 Jan 2023 12:47:45 +0000 (13:47 +0100)]
arm: mvebu: spl: Fix parsing SATA kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SATA image as number of sectors the beginning of the hard
drive, but as number of sectors relative to the main header.

To process SATA kwbimage and load U-Boot proper from it in the same way as
Marvell BootROM, it is needed to interpret srcaddr as relative offset to
the main header. This change fixes booting of U-Boot proper from SPL code
in SATA image.

Fixes: 2226ca173486 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Fix parsing SATA kwbimage
Pali Rohár [Sat, 21 Jan 2023 12:45:36 +0000 (13:45 +0100)]
tools: kwboot: Fix parsing SATA kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SATA image as number of sectors the beginning of the hard
drive, but as number of sectors relative to the main header.

To parse SATA kwbimage in the same way as Marvell BootROM, it is needed to
interpret srcaddr as relative offset to the main header. This change fixes
loading of SATA images via kwboot over UART.

Fixes: 792e42355083 ("tools: kwboot: Patch source address in image header")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwbimage: Fix generating, verifying and extracting SATA kwbimage
Pali Rohár [Sat, 21 Jan 2023 12:34:55 +0000 (13:34 +0100)]
tools: kwbimage: Fix generating, verifying and extracting SATA kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SATA image as number of sectors the beginning of the hard
drive, but as number of sectors relative to the main header.

The main header is stored at absolute sector number 1. So do not add or
subtract it when calculating with relative offsets to the main header.

Fixes: 501a54a29cc2 ("tools: kwbimage: Fix generation of SATA, SDIO and PCIe images")
Fixes: 5c61710c9880 ("tools: kwbimage: Properly set srcaddr in kwbimage v0")
Fixes: e0c243c398a7 ("tools: kwbimage: Validate data checksum of v1 images")
Fixes: aa6943ca3122 ("kwbimage: Add support for extracting images via dumpimage tool")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agocmd: mvebu/bubt: Fix parsing SDIO kwbimage
Pali Rohár [Sun, 8 Jan 2023 12:18:39 +0000 (13:18 +0100)]
cmd: mvebu/bubt: Fix parsing SDIO kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SDIO image as offset in number of sectors (like for SATA
image), but as offset in bytes (like for all other images except SATA).

To ensure that we do not store invalid SDIO image to the boot location
(read by the Marvell BootROM), we need to check that image is valid
and srcaddr is intepreted in bytes, in the same way as it is done by
Marvell BootROM.

This fixes rejecting valid and accepting invalid SDIO images by bubt command.

Fixes: 5a0653493307 ("cmd: mvebu/bubt: Check for A38x image data checksum")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agoarm: mvebu: spl: Fix parsing SDIO kwbimage
Pali Rohár [Sun, 8 Jan 2023 12:16:38 +0000 (13:16 +0100)]
arm: mvebu: spl: Fix parsing SDIO kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SDIO image as offset in number of sectors (like for SATA
image), but as offset in bytes (like for all other images except SATA).

To process SDIO kwbimage and load U-Boot proper from it in the same way as
Marvell BootROM, it is needed to interpret srcaddr in bytes. This change
fixes booting of U-Boot proper from SPL code stored in SDIO image.

Fixes: 2226ca173486 ("arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwboot: Fix parsing SDIO kwbimage
Pali Rohár [Sun, 8 Jan 2023 12:20:20 +0000 (13:20 +0100)]
tools: kwboot: Fix parsing SDIO kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SDIO image as offset in number of sectors (like for SATA
image), but as offset in bytes (like for all other images except SATA).

To parse SDIO kwbimage in the same way as Marvell BootROM, it is needed to
interpret srcaddr in bytes. This change fixes loading of SDIO images via
kwboot over UART.

Fixes: 792e42355083 ("tools: kwboot: Patch source address in image header")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agotools: kwbimage: Fix generating, verifying and extracting SDIO kwbimage
Pali Rohár [Sun, 8 Jan 2023 12:22:03 +0000 (13:22 +0100)]
tools: kwbimage: Fix generating, verifying and extracting SDIO kwbimage

Despite the official specification, Marvell BootROM does not interpret
srcaddr from SDIO image as offset in number of sectors (like for SATA
image), but as offset in bytes (like for all other images except SATA).

To generate SDIO kwbimage compatible with Marvell BootROM, it is needed to
have srcaddr in bytes. This change fixes SDIO images for Armada 38x SoCs.

Fixes: 501a54a29cc2 ("tools: kwbimage: Fix generation of SATA, SDIO and PCIe images")
Fixes: 5c61710c9880 ("tools: kwbimage: Properly set srcaddr in kwbimage v0")
Fixes: e0c243c398a7 ("tools: kwbimage: Validate data checksum of v1 images")
Fixes: aa6943ca3122 ("kwbimage: Add support for extracting images via dumpimage tool")
Signed-off-by: Pali Rohár <pali@kernel.org>
16 months agoMerge tag 'tpm-next-28022023' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 28 Feb 2023 14:50:16 +0000 (09:50 -0500)]
Merge tag 'tpm-next-28022023' of https://source.denx.de/u-boot/custodians/u-boot-tpm into next

TPM auto startup and testing:

Due to U-Boot's lazy binding we always relied on command line tools to
initialize the TPM subsystem and devices.  One exception is the EFI
subsystem.  When compiled with TCG2 measured boot support the TPM was
automatically initialized.

However that init was not complete.  The TCG specs [0] (and specifically
§12.3 Self-test modes) describe how self-tests on the device should be
performed.  This PR is adding an extra API function, that can be used to
initialize the TPM2.0 properly.

Simon added the equivalent for TPM1.2 and refactored the DM tests to
include the new funtion.

[0] https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.07-2014-03-13.pdf

16 months agoMerge tag 'u-boot-nand-20230227' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 28 Feb 2023 14:46:07 +0000 (09:46 -0500)]
Merge tag 'u-boot-nand-20230227' of https://source.denx.de/u-boot/custodians/u-boot-nand-flash into next

Pull request for u-boot-nand-20230227

- mark reserved blocks from Ashok Reddy Soma
- backport BRCMNAND changes from Linux from Linus Walleij
- fix display of unknown raw ID from Patrice Chotard
- show reserved block in chip.erase from Michael Trimarchi

16 months agotpm: Implement tpm_auto_start() for TPMv1.2
Simon Glass [Tue, 21 Feb 2023 13:24:52 +0000 (06:24 -0700)]
tpm: Implement tpm_auto_start() for TPMv1.2

Add an implementation of this, moving the common call to tpm_init() up
into the common API implementation.

Add a test.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agotpm: Separate out the TPM tests for v1 and v2
Simon Glass [Tue, 21 Feb 2023 13:24:51 +0000 (06:24 -0700)]
tpm: Separate out the TPM tests for v1 and v2

Currently there is only one test and it only works on TPM v2. Update it
to work on v1.2 as well, using a new function to pick up the required
TPM.

Update sandbox to include both a v1.2 and v2 TPM so that this works.
Split out the existing test into two pieces, one for init and one for
the v2-only report_state feature.

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agotest: add a test for the new tpm_auto_start() function
Ilias Apalodimas [Sat, 18 Feb 2023 15:21:22 +0000 (17:21 +0200)]
test: add a test for the new tpm_auto_start() function

A prior patch adds a new API function for TPM2.0, which performs
the full startup sequence of the TPM.  Add a selftest for that.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agotpm: sandbox: Change the return code when device is already open
Ilias Apalodimas [Sat, 18 Feb 2023 15:18:49 +0000 (17:18 +0200)]
tpm: sandbox: Change the return code when device is already open

All the TPM drivers as well as out TCG TIS API for a TPM2.0 device
return -EBUSY if the device has already been opened.  Adjust
the sandbox TPM do return the same error code.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: use tpm_auto_start for the tpm device
Ilias Apalodimas [Wed, 25 Jan 2023 11:06:03 +0000 (13:06 +0200)]
efi_loader: use tpm_auto_start for the tpm device

A previous commit is adding a new tpm startup functions which
initializes the TPMv2 and performs all the needed selftests.
Since the TPM selftests might be needed depending on the requested
algorithm or functional module use that instead.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agotpm: add a function that performs selftest + startup
Ilias Apalodimas [Wed, 25 Jan 2023 10:18:36 +0000 (12:18 +0200)]
tpm: add a function that performs selftest + startup

As described in [0] if a command requires use of an untested algorithm
or functional module, the TPM performs the test and then completes the
command actions.

Since we don't check for TPM_RC_NEEDS_TEST (which is the return code of
the TPM in that case) and even if we would, it would complicate our TPM
code for no apparent reason,  add a wrapper function that performs both
the selftest and the startup sequence of the TPM.

It's worth noting that this is implemented on TPMv2.0.  The code for
1.2 would look similar,  but I don't have a device available to test.

[0]
https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.07-2014-03-13.pdf
§12.3 Self-test modes

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoMerge tag 'v2023.04-rc3' into next
Tom Rini [Mon, 27 Feb 2023 22:28:21 +0000 (17:28 -0500)]
Merge tag 'v2023.04-rc3' into next

Prepare v2023.04-rc3

16 months agoDockerfile: Add missing "chmod" of u-boot-gen-combined
Tom Rini [Mon, 27 Feb 2023 15:49:54 +0000 (10:49 -0500)]
Dockerfile: Add missing "chmod" of u-boot-gen-combined

I had added this line locally, rebuild the image, but didn't ensure that
I had committed the correct version of the patch as well.

Fixes: 75b031ee4a96 ("Dockerfile: download binaries for Nokia RX-51")
Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoPrepare v2023.04-rc3
Tom Rini [Mon, 27 Feb 2023 22:18:36 +0000 (17:18 -0500)]
Prepare v2023.04-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agomtd: nand: Show reserved block in chip.erase
Michael Trimarchi [Mon, 27 Feb 2023 15:01:43 +0000 (16:01 +0100)]
mtd: nand: Show reserved block in chip.erase

The "nand chip.erase" command always printed as bad blocks even in the
case of reserved blocks. Reserved blocks are used for storing bad block
tables. The patch displays "bbt reserved" when printing reserved blocks in
"nand chip.erase" command.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: spinand: Fix display of unknown raw ID
Patrice Chotard [Mon, 13 Feb 2023 17:30:04 +0000 (18:30 +0100)]
mtd: spinand: Fix display of unknown raw ID

In case ID is not found in manufacturer table, the raw ID is
printed using %*phN format which is not supported by lib/vsprintf.c.
The information displayed doesn't reflect the raw ID return by the
unknown spi-nand.

Use %02x format instead, as done in spi-nor-core.c.

For example, before this patch:
  ERROR: spi-nand: spi_nand flash@0: unknown raw ID f74ec040
after
  ERROR: spi-nand: spi_nand flash@0: unknown raw ID 00 c2 26 03

Fixes: 0a6d6bae0386 ("mtd: nand: Add core infrastructure to support SPI NANDs")

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Acked-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC
Álvaro Fernández Rojas [Sat, 11 Feb 2023 15:29:09 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC

Hamming ECC doesn't cover the OOB data, so reading or writing OOB shall
always be done without ECC enabled.
This is a problem when adding JFFS2 cleanmarkers to erased blocks. If JFFS2
clenmarkers are added to the OOB with ECC enabled, OOB bytes will be changed
from ff ff ff to 00 00 00, reporting incorrect ECC errors.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210224080210.23686-1-noltari@gmail.com
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: support v2.1-v2.2 controllers
Álvaro Fernández Rojas [Sat, 11 Feb 2023 15:29:08 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: support v2.1-v2.2 controllers

v2.1: tested on Netgear DGND3700v1 (BCM6368)
v2.2: tested on Netgear DGND3700v2 (BCM6362)

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-6-noltari@gmail.com
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: rename page sizes
Álvaro Fernández Rojas [Sat, 11 Feb 2023 15:29:07 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: rename page sizes

Current pages sizes apply to controllers after v3.4

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-4-noltari@gmail.com
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: fix CS0 layout
Álvaro Fernández Rojas [Sat, 11 Feb 2023 15:29:06 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: fix CS0 layout

Only v3.3-v5.0 have a different CS0 layout.
Controllers before v3.3 use the same layout for every CS.

Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-3-noltari@gmail.com
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: rename v4 registers
Álvaro Fernández Rojas [Sat, 11 Feb 2023 15:29:05 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: rename v4 registers

These registers are also used on v3.3.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200522121524.4161539-2-noltari@gmail.com
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: correctly verify erased pages
Álvaro Fernández Rojas [Sat, 11 Feb 2023 15:29:04 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: correctly verify erased pages

The current code checks that the whole OOB area is erased.
This is a problem when JFFS2 cleanmarkers are added to the OOB, since it will
fail due to the usable OOB bytes not being 0xff.
Correct this by only checking that data and ECC bytes aren't 0xff.

Fixes: 02b88eea9f9c ("mtd: brcmnand: Add check for erased page bitflips")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200512082451.771212-1-noltari@gmail.com
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: nand: brcmnand: Add support for flash-dma v0
Kamal Dasu [Sat, 11 Feb 2023 15:29:03 +0000 (16:29 +0100)]
mtd: nand: brcmnand: Add support for flash-dma v0

This change adds support for flash dma v0.0.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: Fix ecc chunk calculation for erased page bitfips
Claire Lin [Sat, 11 Feb 2023 15:29:02 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: Fix ecc chunk calculation for erased page bitfips

In brcmstb_nand_verify_erased_page(), the ECC chunk pointer calculation
while correcting erased page bitflips is wrong, fix it.

Fixes: 02b88eea9f9c ("mtd: brcmnand: Add check for erased page bitflips")
Signed-off-by: Claire Lin <claire.lin@broadcom.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: Add support for v7.3 controller
Kamal Dasu [Sat, 11 Feb 2023 15:29:01 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: Add support for v7.3 controller

This change adds support for brcm NAND v7.3 controller. This controller
uses a newer version of flash_dma engine and change mostly implements
these differences.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: rawnand: brcmnand: Refactored code to introduce helper functions
Kamal Dasu [Sat, 11 Feb 2023 15:29:00 +0000 (16:29 +0100)]
mtd: rawnand: brcmnand: Refactored code to introduce helper functions

Refactored NAND ECC and CMD address configuration code to use helper
functions.

Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
[Ported to U-Boot from the Linux kernel]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-by: William Zhang <william.zhang@broadcom.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agomtd: nand: Mark reserved blocks
Ashok Reddy Soma [Thu, 5 Jan 2023 09:46:20 +0000 (02:46 -0700)]
mtd: nand: Mark reserved blocks

Reserved blocks are used for storing bad block tables. With "nand bad"
command, these reserved blocks are shown as bad blocks. This is leading
to confusion when compared with Linux bad blocks. Hence, display
"bbt reserved" when printing reserved blocks with "nand bad" command.

To acheive this, return 2 which represents reserved from nand_isbad_bbt()
instead of 1 in case of reserved blocks and catch it in cmd/nand.c.

"nand bad" command display's hexadecimal numbers, so add "0x" prefix.

Example log will show up as below.

ZynqMP> nand bad

Device 0 bad blocks:
  0x00400000
  0x16800000
  0x16c00000
  0x17000000
  0x3d800000
  0x3e400000
  0xe8400000
  0xff000000  (bbt reserved)
  0xff400000  (bbt reserved)
  0xff800000  (bbt reserved)
  0xffc00000  (bbt reserved)
  0x116800000
  0x116c00000
  0x1ff000000  (bbt reserved)
  0x1ff400000  (bbt reserved)
  0x1ff800000  (bbt reserved)
  0x1ffc00000  (bbt reserved)

Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-By: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
16 months agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 27 Feb 2023 14:11:57 +0000 (09:11 -0500)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoMerge branch '2023-02-24-include-nx51-components-in-docker-for-testing' into next
Tom Rini [Sat, 25 Feb 2023 17:44:30 +0000 (12:44 -0500)]
Merge branch '2023-02-24-include-nx51-components-in-docker-for-testing' into next

- Merge in changes to our Dockerfile so that we build and download ahead
  of time all of the components required to run the nx51 test scripts.
  This will both speed up the specific job and address failures in Azure
  where the ipk files fail to download.

16 months agoCI: Update test/nokia_rx51_test.sh to use prebuilt images
Pali Rohár [Tue, 21 Feb 2023 16:22:29 +0000 (11:22 -0500)]
CI: Update test/nokia_rx51_test.sh to use prebuilt images

Now that the Dockerfile creates images which have the binaries we
require included, have CI make symlinks for them and update the existing
script to support this.

Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agoDockerfile: build qemu for Nokia n900
Heinrich Schuchardt [Fri, 13 Jan 2023 19:31:33 +0000 (20:31 +0100)]
Dockerfile: build qemu for Nokia n900

Using a pre-built QEMU saves a lot of time when testing.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
16 months agoDockerfile: download binaries for Nokia RX-51
Heinrich Schuchardt [Fri, 13 Jan 2023 18:25:01 +0000 (19:25 +0100)]
Dockerfile: download binaries for Nokia RX-51

Downloading files for a test may fail if the server is offline.
It is preferable to provide the files in our Docker image.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-tegra
Tom Rini [Thu, 23 Feb 2023 22:32:22 +0000 (17:32 -0500)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-tegra

16 months agoMerge branch '2023-02-23-assorted-fixes'
Tom Rini [Thu, 23 Feb 2023 22:30:49 +0000 (17:30 -0500)]
Merge branch '2023-02-23-assorted-fixes'

- btrfs bugfix, silence a bunch of gcc-12.2 linker warnings finally,
  relax one of the trace test time requirements (so CI doesn't fail due
  to test being slightly slow, but still correct), and correct env on
  MMC and checking for where GPT can be

16 months agoARM: tegra20: implement BCT patching
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:38 +0000 (19:35 +0200)]
ARM: tegra20: implement BCT patching

This function allows updating bootloader from u-boot
on production devices without need in host PC.

Be aware! It works only with re-crypt BCT.

Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Signed-off-by: Ramin Khonsari <raminterex@yahoo.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra30: implement BCT patching
Ramin Khonsari [Tue, 14 Feb 2023 17:35:37 +0000 (19:35 +0200)]
ARM: tegra30: implement BCT patching

This function allows updating bootloader from u-boot
on production devices without need in host PC.

Be aware! It works only with re-crypted BCT.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Ramin Khonsari <raminterex@yahoo.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: crypto: extend crypto functional
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:36 +0000 (19:35 +0200)]
ARM: tegra: crypto: extend crypto functional

Add support for encryption, decryption and signinig with
non-zero key saving backward compatibility.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: expose crypto module for all Tegra SoCs
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:35 +0000 (19:35 +0200)]
ARM: tegra: expose crypto module for all Tegra SoCs

Move crypto module from T20 only into common Tegra dir.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoboard: tegra30: switch to updated pre-dm i2c write
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:34 +0000 (19:35 +0200)]
board: tegra30: switch to updated pre-dm i2c write

Configure PMIC voltages for early stages using updated
early i2c write.

Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoboard: tegra124: switch to updated pre-dm i2c write
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:33 +0000 (19:35 +0200)]
board: tegra124: switch to updated pre-dm i2c write

Configure PMIC for early stages using updated i2c write.

Tested-by: Thierry Reding <treding@nvidia.com> # Jetson TK1 T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: create common pre-dm i2c write
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:32 +0000 (19:35 +0200)]
ARM: tegra: create common pre-dm i2c write

This implementation allows pwr i2c writing on early SPL
stages when DM is not yet setup.

Such writing is needed to configure main voltages of PMIC
on early SPL for bootloader to boot properly.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: add late init support
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:31 +0000 (19:35 +0200)]
ARM: tegra: add late init support

Late init function allows passing values like identifiers and
perform device specific configurations of pre-boot stage.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: provide default USB gadget setup
Maxim Schwalm [Tue, 14 Feb 2023 17:35:30 +0000 (19:35 +0200)]
ARM: tegra: provide default USB gadget setup

All Nvidia boards use the same manufacturer, vendor ID and product ID
for the gadgets. Make them the defaults to remove some boilerplate from
the defconfigs.

Inspired by commit e02687bda96c ("sunxi: provide default USB gadget
setup") which did the same for Allwinner boards.

Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Maxim Schwalm <maxim.schwalm@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agospi: tegra20_slink: accept any word length
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:29 +0000 (19:35 +0200)]
spi: tegra20_slink: accept any word length

Original t20 slink could work with commands only
fully divisible by 8. This patch removes such
restriction, so commands of any bitlength now
can be passed and processed.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF600T T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: Fix Tegra PWM parent clock
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:28 +0000 (19:35 +0200)]
ARM: tegra: Fix Tegra PWM parent clock

Default parent clock for the PWM on Tegra is a 32kHz clock and
is unable to support the requested PWM period.

Fix PWM support on Tegra20, Tegra30, Tegra114, Tegra124 and Tegra210 by
updating the parent clock for the PWM to be the PLL_P.

This commit is equivalent to Linux kernel commit:
https://lore.kernel.org/all/20221010100046.6477-1-jonathanh@nvidia.com/

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # ASUS TF201 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra30: add PLLD to pll setup
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:27 +0000 (19:35 +0200)]
ARM: tegra30: add PLLD to pll setup

On T30 unlike T20 dsi panels are wider used on devices
and PLLD is used as DISP1 parent more often, so lets
enable it as well for this cases.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF700T T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X T30
Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: clock: add clock_decode_pair helper
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:26 +0000 (19:35 +0200)]
ARM: tegra: clock: add clock_decode_pair helper

Get periph clock id and its parent from device tree.
This works by looking up the peripheral's 'clocks' node and
reading out the second and fourth cells, which are the
peripheral and PLL clock numbers.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: tegra: clock: add clk_id_to_pll_id helper
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:25 +0000 (19:35 +0200)]
ARM: tegra: clock: add clk_id_to_pll_id helper

This function allows to convert a device tree clock ID to PLL ID.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoARM: t20/t30: swap host1x and disp1 clock parents
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:24 +0000 (19:35 +0200)]
ARM: t20/t30: swap host1x and disp1 clock parents

According to mainline clock tables and TRM HOST1X
parent is PLLC, while DISP1 usually uses PLLP as
parent clock.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agotegra30: clock: add EXTPERIPH
Svyatoslav Ryhel [Tue, 14 Feb 2023 17:35:23 +0000 (19:35 +0200)]
tegra30: clock: add EXTPERIPH

This mappings were missing for some reason.

Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom <twarren@nvidia.com>
16 months agoenv: mmc: Apply GPT only on eMMC user HW partition
Marek Vasut [Thu, 9 Feb 2023 12:30:10 +0000 (13:30 +0100)]
env: mmc: Apply GPT only on eMMC user HW partition

Apply the GPT U-Boot environment GUID type look up only on eMMC user
HW partition, do not apply the look up on eMMC boot HW partitions as
mmc_offset_try_partition() assumes either SD partitions or eMMC user
HW partition.

This fixes environment operation on systems where CONFIG_SYS_MMC_ENV_PART
is non-zero and CONFIG_SYS_REDUNDAND_ENVIRONMENT is set.

Fixes: 80105d8fd52 ("env: mmc: select GPT env partition by type guid")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
16 months agotrace: Relax test requirements
Simon Glass [Fri, 17 Feb 2023 22:45:16 +0000 (15:45 -0700)]
trace: Relax test requirements

We expect the profile and bootstage to agree on timing, but when
running on slow machines there can be a larger descrepency. Increase the
tolerance to fix this.

Fixes: 9cea4797aeb ("trace: Add a test")
Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agox86: Pass -z execstack for EFI payload flags
Tom Rini [Tue, 14 Feb 2023 20:09:32 +0000 (15:09 -0500)]
x86: Pass -z execstack for EFI payload flags

To match how we link EFI executables elsewhere, and to silence a linker
warning, pass -z execstack here as well.

Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoMakefile: Link with -z noexectack
Tom Rini [Tue, 14 Feb 2023 20:09:31 +0000 (15:09 -0500)]
Makefile: Link with -z noexectack

When moving to gcc-12.2 we started trying to quiet some of the new
linker warnings, that are not relevant to us. However, a
misunderstanding of the mechanics at play meant that I intentionally
omitted passing -z noexecstack to the linker, when we do need to. Add
this flag and in turn remove warnings from the linker.

Fixes: 1e1c51f8ace8 ("Makefile: link with --no-warn-rwx-segments")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agofs: btrfs: limit the mapped length to the original length
Qu Wenruo [Mon, 13 Feb 2023 00:37:59 +0000 (08:37 +0800)]
fs: btrfs: limit the mapped length to the original length

[BUG]
There is a bug report that btrfs driver caused hang during file read:

  This breaks btrfs on the HiFive Unmatched.

  => pci enum
  PCIE-0: Link up (Gen1-x8, Bus0)
  => nvme scan
  => load nvme 0:2 0x8c000000 /boot/dtb/sifive/hifive-unmatched-a00.dtb
  [hangs]

[CAUSE]
The reporter provided some debug output:

  read_extent_data: cur=615817216, orig_len=16384, cur_len=16384
  read_extent_data: btrfs_map_block: cur_len=479944704; ret=0
  read_extent_data: ret=0
  read_extent_data: cur=615833600, orig_len=4096, cur_len=4096
  read_extent_data: btrfs_map_block: cur_len=479928320; ret=0

Note the second and the last line, the @cur_len is 450+MiB, which is
almost a chunk size.

And inside __btrfs_map_block(), we limits the returned value to stripe
length, but that's depending on the chunk type:

if (map->type & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
 BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4 |
 BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 |
 BTRFS_BLOCK_GROUP_RAID10 |
 BTRFS_BLOCK_GROUP_DUP)) {
/* we limit the length of each bio to what fits in a stripe */
*length = min_t(u64, ce->size - offset,
      map->stripe_len - stripe_offset);
} else {
*length = ce->size - offset;
}

This means, if the chunk is SINGLE profile, then we don't limit the
returned length at all, and even for other profiles, we can still return
a length much larger than the requested one.

[FIX]
Properly clamp the returned length, preventing it from returning a much
larger range than expected.

Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Qu Wenruo <wqu@suse.com>
16 months agousb: dwc3-uniphier: Select PHY
Marek Vasut [Thu, 23 Feb 2023 16:29:24 +0000 (17:29 +0100)]
usb: dwc3-uniphier: Select PHY

Make sure the PHY subsystem is activated for the uniphier DWC3 glue
logic, as it depends on PHY implementation there.

Signed-off-by: Marek Vasut <marex@denx.de>
16 months agoMerge branch 'next' of git://source.denx.de/u-boot-usb into next
Tom Rini [Wed, 22 Feb 2023 23:21:40 +0000 (18:21 -0500)]
Merge branch 'next' of git://source.denx.de/u-boot-usb into next

- dwc3-generic rework and then switch uniphier to it

16 months agouniphier_defconfig: Disable USB_XHCI_DWC3
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:34 +0000 (14:50 +0900)]
uniphier_defconfig: Disable USB_XHCI_DWC3

Replacing with dwc3-generic, no need USB_XHCI_DWC3 anymore.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agousb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:33 +0000 (14:50 +0900)]
usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3

dwc3-uniphier depends on xhci-dwc3 framework, however, it is preferable
to use dwc3-generic.

This driver calls the exported dwc3-generic functions and redefine
the SoC-dependent operations to fit dwc3-generic.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agophy: socionext: Add UniPhier USB3 PHY driver
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:32 +0000 (14:50 +0900)]
phy: socionext: Add UniPhier USB3 PHY driver

Add USB3 PHY driver support to control clocks and resets needed to enable
PHY. The phy_ops->init() and exit() control PHY clocks and resets only,
and clocks and resets for the controller and the parent logic are enabled
in advance.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agoclk: uniphier: Add missing USB SS-PHY clocks
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:31 +0000 (14:50 +0900)]
clk: uniphier: Add missing USB SS-PHY clocks

The USB SS-PHY needs its own clock, however, some clocks don't have
clock gates. Define missing clock entries for the PHY as reference
clock.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agoreset: uniphier: Add USB glue reset support
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:30 +0000 (14:50 +0900)]
reset: uniphier: Add USB glue reset support

Add reset control support in USB glue logic. This needs to control
the external clocks and resets for the logic before accessing the
glue logic.

The USB dm tree when using dwc3-generic is the following:

   USB glue
     +-- controller       (need controller-reset)
     +-- controller-reset (need syscon-reset)
     +-- phy

The controller needs to deassert "controller-reset" in USB glue before
the controller registers are accessed. The glue needs to deassert
"syscon-reset" before the glue registers are accessed.

The glue itself doesn't have "syscon-reset", so the controller-reset
controls "syscon-reset" instead.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agousb: dwc3-generic: Add the size of regs property to glue structure
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:29 +0000 (14:50 +0900)]
usb: dwc3-generic: Add the size of regs property to glue structure

Add the size of regs property to the glue structure to correctly
specify the register region to map.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agousb: dwc3-generic: Export glue structures and functions
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:28 +0000 (14:50 +0900)]
usb: dwc3-generic: Export glue structures and functions

In order to allow external SoC-dependent glue drivers to use dwc3-generic
functions, push the glue structures and export the functions to a header
file.

The exported structures and functions are:

- struct dwc3_glue_data
- struct dwc3_glue_ops
- dwc3_glue_bind()
- dwc3_glue_probe()
- dwc3_glue_remove()

The SoC-dependent glue drivers can only define their own wrapper driver
and specify these functions. The drivers can also add their own compatible
strings and configure functions.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agousb: dwc3-generic: Add clock initialization in child DT node
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:27 +0000 (14:50 +0900)]
usb: dwc3-generic: Add clock initialization in child DT node

Same as the reset cotnrol, should add a clock initialization in child DT
node, if the glue node doesn't have any clocks.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agousb: dwc3-generic: Allow different controller DT node pattern
Kunihiko Hayashi [Mon, 20 Feb 2023 05:50:26 +0000 (14:50 +0900)]
usb: dwc3-generic: Allow different controller DT node pattern

The most of devicetree has the following USB node structure.
The controller node is placed as a child node of the glue node.
Current dwc3-generic driver works on this premise.

    glue {
        /* glue node */
usb {
            /* controller node */
};
    };

However, UniPhier original devicetree has the following USB node structure.
The controller node is separately placed from the glue node.

    usb {
        /* controller node */
    };
    glue {
        /* glue node */
    };

In dwc_glue_bind(), this patch provides .glue_get_ctrl_dev() callback to
get such a controller node and binds the driver related to the node.

If this callback isn't defined, dwc_glue_bind() looks for the controller
nodes from the child nodes, as before.

Suggested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Marek Vasut <marex@denx.de>
16 months agousb: dwc3: Look up reference clock DT phandle in both controller DT nodes
Marek Vasut [Mon, 20 Feb 2023 05:50:25 +0000 (14:50 +0900)]
usb: dwc3: Look up reference clock DT phandle in both controller DT nodes

There are currently four disparate placement possibilities of DWC3
reference clock phandle in SoC DTs:
- in top level glue node, with generic subnode without clock (ZynqMP)
- in top level generic node, with no subnode (i.MX8MQ)
- in generic subnode, with other clock in top level node (i.MX8MP)
- in both top level node and generic subnode (Rockchip)

Cover all the possibilities here by looking into both nodes, start
with the top level node as that seems to be used in majority of DTs
to reference the clock.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
16 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Wed, 22 Feb 2023 18:36:29 +0000 (13:36 -0500)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-usb

- DWC3 bugfix

16 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-socfpga
Tom Rini [Wed, 22 Feb 2023 14:28:03 +0000 (09:28 -0500)]
Merge https://source.denx.de/u-boot/custodians/u-boot-socfpga

- chameleonv3 updates

16 months agochameleonv3: Convert CONFIG_SPL_MAX_SIZE to Kconfig
Paweł Anikiel [Tue, 21 Feb 2023 15:17:06 +0000 (16:17 +0100)]
chameleonv3: Convert CONFIG_SPL_MAX_SIZE to Kconfig

This file was missed during the conversion process. Add the symbol to
defconfig.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agoarm: dts: chameleonv3: Add 270-2 variant
Paweł Anikiel [Tue, 21 Feb 2023 15:17:05 +0000 (16:17 +0100)]
arm: dts: chameleonv3: Add 270-2 variant

Add devicetree for chameleonv3 with the 270-2I2-D11E variant of the
Mercury+ AA1 module

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
Reviewed-by: Simon Glass <sjg@chromium.org>