]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
2 years agovirtio: pci: Check virtio common config size
Andrew Scull [Thu, 21 Apr 2022 16:11:03 +0000 (16:11 +0000)]
virtio: pci: Check virtio common config size

Check that the common config is at least as large as the struct it is
expected to contain. Only then is it safe to cast the pointer and be
safe from out-of-bounds accesses.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agovirtio: pci: Bounds check notification writes
Andrew Scull [Thu, 21 Apr 2022 16:11:02 +0000 (16:11 +0000)]
virtio: pci: Bounds check notification writes

Make sure virtio notifications are written within their allocated
buffer.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agovirtio: pci: Bounds check device config access
Andrew Scull [Thu, 21 Apr 2022 16:11:01 +0000 (16:11 +0000)]
virtio: pci: Bounds check device config access

The device config is optional, so check it was present and mapped before
trying to use the pointer. Bounds violations are an error, not just a
warning, so bail if the checks fail.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agovirtio: pci: Fix discovery of device config length
Andrew Scull [Thu, 21 Apr 2022 16:11:00 +0000 (16:11 +0000)]
virtio: pci: Fix discovery of device config length

The length of the device config was erroneously being taken from the
notify capability. Correct this by finding the length in the device
capability.

Fixes: 550435edf810 ("virtio: pci: Support non-legacy PCI transport device")
Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agovirtio: pci: Allow exclusion of legacy driver
Andrew Scull [Thu, 21 Apr 2022 16:10:59 +0000 (16:10 +0000)]
virtio: pci: Allow exclusion of legacy driver

Add a new config to control whether the driver for legacy virtio PCI
devices is included in the build. VIRTIO_PCI_LEGACY is included by
default when VIRTIO_PCI is selected, but it can also be independently
toggled.

Signed-off-by: Andrew Scull <ascull@google.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agoCI: Azure: Rework how we update MSYS2
Tom Rini [Tue, 3 May 2022 12:30:14 +0000 (08:30 -0400)]
CI: Azure: Rework how we update MSYS2

Based on reading https://www.msys2.org/docs/ci/ and "Other Systems"
rework how we update MSYS2 to the current version.  We run it once, to
perform nothing other than being the first run, then we run pacman
twice.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMerge branch '2022-05-02-add-verifying-program-loader'
Tom Rini [Mon, 2 May 2022 23:02:44 +0000 (19:02 -0400)]
Merge branch '2022-05-02-add-verifying-program-loader'

To quote the author:

U-Boot provides a verified-boot feature based around FIT, but there is
no standard way of implementing it for a board. At present the various
required pieces must be built up separately, to produce a working
implementation. In particular, there is no built-in support for selecting
A/B boot or recovery mode.

This series introduces VPL, a verified program loader phase for U-Boot.
Its purpose is to run the verified-boot process and decide which SPL
binary should be run. It is critical that this decision happens before
SPL runs, since SPL sets up SDRAM and we need to be able to update the
SDRAM-init code in the field.

Adding VPL into the boot flow provides a standard place to implement
verified boot. This series includes the phase itself, some useful Kconfig
options and a sandbox_vpl build for sandbox. No verfied-boot support is
provided in this series.

Most of the patches in this series are fixes and improvements to docs and
various Kconfig conditions for SPL.

2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Mon, 2 May 2022 23:00:42 +0000 (19:00 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- Misc turris_omnia/mox related Fixes and impovements (Pali)
- Turris Omnia: Add support for configuring mSATA and WWAN slots
  via env variables (Pali)
- net: mvgbe: Set PHY page 0 before phy_connect (Tony)
- kirkwood: nsa310s: Use Marvell uclass mvgbe and PHY driver (Tony)
- mvebu: turris_omnia: Fix SYS_RSTOUT_* macro names (Pali)
- mvebu: clearfog_defconfig: enable setexpr command (Josef)
- mvebu: x530: set MPP55 to gpio (Chris)

2 years agoCI: Run VPL tests
Simon Glass [Sat, 30 Apr 2022 06:56:57 +0000 (00:56 -0600)]
CI: Run VPL tests

Add tests for VPL into the mix. For now this just runs the help test and
a few SPL ones.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agovpl: Test that VPL runs correctly through to U-Boot proper
Simon Glass [Sat, 30 Apr 2022 06:56:56 +0000 (00:56 -0600)]
vpl: Test that VPL runs correctly through to U-Boot proper

Check the TPL -> VPL -> SPL -> U-Boot path by running the 'help' command
in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agovpl: Support running vpl tests
Simon Glass [Sat, 30 Apr 2022 06:56:55 +0000 (00:56 -0600)]
vpl: Support running vpl tests

Add support for these to the pytest system.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: Add a build for VPL
Simon Glass [Sat, 30 Apr 2022 06:56:54 +0000 (00:56 -0600)]
sandbox: Add a build for VPL

Add an initial VPL build for sandbox. This includes the flow:

   TPL (with of-platdata) -> VPL -> SPL -> U-Boot

To run it:

   ./tpl/u-boot-tpl -D

The -D is needed to get the default device tree, which includes the serial
console info.

Add a Makefile check for OF_HOSTFILE which is the option that enables
devicetree control on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agovpl: Add Kconfig options for VPL
Simon Glass [Sat, 30 Apr 2022 06:56:53 +0000 (00:56 -0600)]
vpl: Add Kconfig options for VPL

Add VPL versions of commonly used Kconfig options.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoIntroduce Verifying Program Loader (VPL)
Simon Glass [Sat, 30 Apr 2022 06:56:52 +0000 (00:56 -0600)]
Introduce Verifying Program Loader (VPL)

Add support for VPL, a new phase of U-Boot. This runs after TPL. It is
responsible for selecting which SPL binary to run, based on a
verified-boot process.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoMakefile: Tidy up the TPL build rules
Simon Glass [Sat, 30 Apr 2022 06:56:51 +0000 (00:56 -0600)]
Makefile: Tidy up the TPL build rules

These should follow the same pattern as SPL, for consistency. Fix them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoMakefile: Simplify devicetree rules for SPL/TPL
Simon Glass [Sat, 30 Apr 2022 06:56:50 +0000 (00:56 -0600)]
Makefile: Simplify devicetree rules for SPL/TPL

The current logic checks several options to decide whether SPL/TPL need
the U-Boot devicetree to be built. In fact we can check OF_CONTROL, which
is enabled in all cases that matter.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoavb: Don't build in SPL
Simon Glass [Sat, 30 Apr 2022 06:56:49 +0000 (00:56 -0600)]
avb: Don't build in SPL

This feature is not used in SPL at present. Update the Makefile to avoid
it being built.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agobloblist: Correct Kconfig dependencies
Simon Glass [Sat, 30 Apr 2022 06:56:48 +0000 (00:56 -0600)]
bloblist: Correct Kconfig dependencies

This feature is not available in SPL unless common/ and lib/ are built.
Update the Kconfig to avoid build errors.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agotest: Tidy up test building with SPL
Simon Glass [Sat, 30 Apr 2022 06:56:47 +0000 (00:56 -0600)]
test: Tidy up test building with SPL

We can in principle add tests to any SPL build, e.g. TPL or VPL. Update
the build rules to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Expand SPL docs to explain the phase and config
Simon Glass [Sat, 30 Apr 2022 06:56:46 +0000 (00:56 -0600)]
doc: Expand SPL docs to explain the phase and config

Add a bit more information about how to use SPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Convert SPL documentation to ReST
Simon Glass [Sat, 30 Apr 2022 06:56:45 +0000 (00:56 -0600)]
doc: Convert SPL documentation to ReST

Move this documentation over to .rst format.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoARM: mvebu: x530: set MPP55 to gpio
Chris Packham [Mon, 2 May 2022 03:16:25 +0000 (15:16 +1200)]
ARM: mvebu: x530: set MPP55 to gpio

MPP55 is used as a reset connected to the L3 switch chip. This doesn't
matter for u-boot as it doesn't use the L3 switch but it is useful to
be able to toggle the switch in/out of reset for the OS.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: clearfog_defconfig: enable setexpr command
Josef Schlehofer [Fri, 29 Apr 2022 15:49:14 +0000 (17:49 +0200)]
arm: mvebu: clearfog_defconfig: enable setexpr command

This command is useful in U-boot scripts and it is being used by
OpenWrt bootscript for this board [1]. Otherwise shell scripting
commands are enabled by default in cmd/Kconfig.

[1] https://github.com/openwrt/openwrt/blob/852126680e21edc71c0c66561ae5a6d7479dcc67/target/linux/mvebu/image/clearfog.bootscript#L7

[2] https://source.denx.de/u-boot/u-boot/-/blob/e95afa56753cebcd20a5114b6d121f281b789006/cmd/Kconfig#L1504

Fixes: 0299c90f396c5b2971a4bac596339f4b03661c27 ("arm: mvebu: Add
SolidRun ClearFog Armada 38x initial support")

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: turris_omnia: Fix SYS_RSTOUT_* macro names
Pali Rohár [Fri, 29 Apr 2022 11:53:25 +0000 (13:53 +0200)]
arm: mvebu: turris_omnia: Fix SYS_RSTOUT_* macro names

This is A385 register.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: kirkwood: nsa310s: Use Marvell uclass mvgbe and PHY driver for DM Ethernet
Tony Dinh [Sun, 17 Apr 2022 20:42:42 +0000 (13:42 -0700)]
arm: kirkwood: nsa310s: Use Marvell uclass mvgbe and PHY driver for DM Ethernet

The Zyxel NSA310s board has the network chip Marvell Alaska 88E1318S.
Use uclass mvgbe and the compatible driver M88E1310 driver to bring
up Ethernet.

- Use uclass mvgbe to bring up the network. And remove ad-hoc code.
- Remove CONFIG_RESET_PHY_R.
- Enable CONFIG_PHY_MARVELL to properly configure the network.
- Add phy mode RGMII to kirkwood-nsa310s.dts
- Miscellaneous changes: Move constants to .c file and remove header file
board/zyxel/nsa310s/nsa310s.h, add support for large USB and SATA HDDs,
use BIT macro, add/cleanup comments, and cosmetic changes.

Note that this patch is depended on the following patch:
https://patchwork.ozlabs.org/project/uboot/patch/20220412201820.10291-1-mibodhi@gmail.com/

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
2 years agonet: marvell: mvgbe: Set PHY page 0 before phy_connect
Tony Dinh [Tue, 12 Apr 2022 20:18:19 +0000 (13:18 -0700)]
net: marvell: mvgbe: Set PHY page 0 before phy_connect

For most Kirkwood boards, the PHY page is already set to page 0
(in register 22) before phy_connect is invoked. But some board like
the Zyxel NSA310S (which uses the network chip MV88E1318S), the PHY page
is not set to page 0. There seems to be some bad data remained in
register 22 when the uclass MVGBE about to invoke phy_connect().

This patch enables the uclass MVGBE to always set the PHY page to 0
before phy_connect.

For reference, please see this discussion:
[RFC PATCH v2] arm: kirkwood: nsa310s: Use Marvell uclass mvgbe
and PHY driver for DM Ethernet.
https://lists.denx.de/pipermail/u-boot/2022-April/480946.html

This patch has been tested with the following Kirkwood boards:

NSA310S (88F6702, network chip MV88E1318S)
Sheevaplug (88F6281, network chip MV88E1318)
Pogo V4 (88F6192, network chip 88E1116R)
GF Home(88F6281, network chip 88E1116R)
Dreamplug (88F6281, network chip MV88E1318)
Dell Kace M300 (88F6282, network chip MV88E1318) - out of tree u-boot

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
2 years agoarm: mvebu: turris_mox: Add NVMe and SCSI to boot targets
Pali Rohár [Wed, 6 Apr 2022 09:39:36 +0000 (11:39 +0200)]
arm: mvebu: turris_mox: Add NVMe and SCSI to boot targets

U-Boot for Turris Mox has already enabled NVMe and SCSI support. So add
NVMe and SCSI to boot targets.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Add NVMe to boot targets
Pali Rohár [Wed, 6 Apr 2022 09:39:35 +0000 (11:39 +0200)]
arm: mvebu: turris_omnia: Add NVMe to boot targets

U-Boot for Turris Omnia has already enabled NVMe support. So add NVMe to
boot targets.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Always enable MMC, SCSI and USB boot targets
Pali Rohár [Wed, 6 Apr 2022 09:39:34 +0000 (11:39 +0200)]
arm: mvebu: turris_omnia: Always enable MMC, SCSI and USB boot targets

U-Boot for Turris Omnia is always compiled with MMC, SCSI and USB support,
so always enable macros for booting from these devices.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Define CONFIG_ETHPRIME instead of ethact= ENV
Pali Rohár [Wed, 6 Apr 2022 09:39:33 +0000 (11:39 +0200)]
arm: mvebu: turris_omnia: Define CONFIG_ETHPRIME instead of ethact= ENV

CONFIG_ETHPRIME defines primary ethernet device and env variable $ethact
stores currently active ethernet device.

So there is no point to set ethact= in default environment. Instead set
CONFIG_ETHPRIME properly.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
2 years agoarm: mvebu: turris_omnia: Fix RESET button message
Pali Rohár [Wed, 6 Apr 2022 09:39:32 +0000 (11:39 +0200)]
arm: mvebu: turris_omnia: Fix RESET button message

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
2 years agoarm: mvebu: turris_omnia: Add support for USB3.0 mode in WWAN MiniPCIe slot
Pali Rohár [Wed, 2 Mar 2022 11:47:58 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Add support for USB3.0 mode in WWAN MiniPCIe slot

PCIe Mini CEM 2.1 spec added support for USB3.0 mode on MiniPCIe cards.
USB3.0 and PCIe share same pins and only one function can be active at the
same time. PCIe Mini CEM 2.1 spec says that determining function is
platform specific and spec does not define any dedicated pin which could
say if card is USB3.0-based or PCIe-based.

Implement this platform specific decision (USB3.0 vs PCIe) for WWAN
MiniPCIe slot on Turris Omnia via U-Boot env variable "omnia_wwan_slot",
similarly like is implemented forced mode for MiniPCIe/mSATA slot via
"omnia_msata_slot" env variable. Value "usb3" for "omnia_wwan_slot" would
mean to set USB3.0 mode and value "pcie" original PCIe mode.

A385 SoC on Turris Omnia has configurable fifth SerDes line (exported to
MiniPCIe WWAN slot with SIM card) either to USB3.0 or PCIe functionality,
so implementation of this new PCIe Mini CEM 2.1 feature is simple, by just
configuring SerDes to USB 3.0 mode.

Other twos MiniPCIe slots on Turris Omnia do not have this new
functionality as their SerDes lines cannot be switched to USB3.0
functionality.

Note that A385 SoC does not have too many USB3.0 blocks, so activating
USB3.0 in MiniPCIe cause that one external USB3.0 USB-A port would loose
USB3.0 functionality and would be downgraded just to USB2.0.

By default this MiniPCIe WWAN slot is in PCIe mode, like before.

To set this MiniPCIe WWAN slot to USB3.0 mode, call U-Boot commands:

  => setenv omnia_wwan_slot usb3
  => saveenv
  => reset

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Signal error when sata/pcie DT mode
Pali Rohár [Wed, 2 Mar 2022 11:47:57 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Signal error when sata/pcie DT mode

Show error message when DT file does not contain sata or pcie node which
should be explicitly disabled. This can happen when U-Boot code for finding
those nodes is incomplete or when those DT nodes are in different
unexpected location. In any case it is needed to know if DT not was not
explicitly disabled as it could mean that combo slots where setup
incorrectly.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Extract code for disabling sata/pcie
Pali Rohár [Wed, 2 Mar 2022 11:47:56 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Extract code for disabling sata/pcie

Move code for disabling sata and pcie DT nodes to own functions, so this
code can be called from other places in follow up patches.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Allow to configure mSATA slot via env variable
Pali Rohár [Wed, 2 Mar 2022 11:47:55 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Allow to configure mSATA slot via env variable

Some PCIe-based MiniPCIe cards are broken and they do not ground PIN 43
which is required by PCIe mini CEM specs. Such broken cards are incorrectly
detected as mSATA cards because SATA specs requires that PIN 43 on mSATA
cards has to be disconnected.

PIN 43 on Turris Omnia is used only for MiniPCIe/mSATA card detection by
software in U-Boot SPL. Allow to override that U-Boot SPL detection by a
new "omnia_msata_slot" env variable (to value "pcie" or "sata") so broken
MiniPCIe cards can be used in combo mSATA/MiniPCIe slot too.

As configuration of PCIe vs SATA functionality is done in U-Boot SPL,
it is required to change env variable in permanent storage and reset the
board to take effect.

To force PCIe mode for broken MiniPCIe cards, call U-Boot commands:

  => setenv omnia_msata_slot pcie
  => saveenv
  => reset

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Define only one serdes map variable
Pali Rohár [Wed, 2 Mar 2022 11:47:54 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Define only one serdes map variable

By default use primary serdes map with PCIe function in combined
miniPCIe/mSATA slot. When SATA is detected change serdes map variable at
runtime.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Enable ENV support in SPL
Pali Rohár [Wed, 2 Mar 2022 11:47:53 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Enable ENV support in SPL

Allow to read ENV variables also in SPL on Turris Omnia.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoarm: mvebu: turris_omnia: Provide env_sf_get_env_addr() function
Pali Rohár [Wed, 2 Mar 2022 11:47:52 +0000 (12:47 +0100)]
arm: mvebu: turris_omnia: Provide env_sf_get_env_addr() function

BootROM maps SPI Flash to fixed address 0xD4000000 and this mapping is
active also when BootROM is executing binary kwbimage headers, which
includes also U-Boot SPL.

Therefore no initialization code is required to access SPI Flags from
U-Boot SPL. In proper U-Boot it is remapped to other location.

So in mvebu implementation of env_sf_get_env_addr() function returns
0xD4000000 when running in SPL and NULL when in proper U-Boot.

This change would allow to use U-Boot ENV in U-Boot SPL. Normally it is not
possible to read ENV because it is too big and U-Boot SPL does not have
such big malloc() pool to real all ENV variables.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
2 years agoenv: sf: Allow to use env_sf_init_addr() at any stage
Pali Rohár [Wed, 2 Mar 2022 11:47:51 +0000 (12:47 +0100)]
env: sf: Allow to use env_sf_init_addr() at any stage

In some cases it makes sense to use env_sf_init_addr() also in SPL mode.
Allow it for boards by providing custom implementation of weak function
env_sf_get_env_addr(). When this function returns NULL it signals that
address is invalid, like config option CONFIG_ENV_ADDR.

There is no change in default behavior or in config options.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agoMerge tag 'efi-2022-07-rc2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Fri, 29 Apr 2022 18:04:08 +0000 (14:04 -0400)]
Merge tag 'efi-2022-07-rc2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-07-rc2

UEFI:

* fix UEFI booting after integration of UEFI sub-system with driver model
* avoid random return values from devpath_is_partition()
* minor code clean ups

2 years agoMerge branch '2022-04-29-fuzzing-and-asan-fixes'
Tom Rini [Fri, 29 Apr 2022 15:25:06 +0000 (11:25 -0400)]
Merge branch '2022-04-29-fuzzing-and-asan-fixes'

To quote the author:

I've been experimenting with ASAN on sandbox and turned up a few issues
that are fixed in this series.

Basic ASAN was easy to turn on, but integrating with dlmalloc was
messier and fairly intrusive. Even when I had it working, there was only
a small redzone between allocations which limits the usefulness.

I saw another series on the list by Sean Anderson to enable valgrind
which was finding a different set of issues, though there was one
overlap that Sean is fixing with
"[PATCH] IOMUX: Fix access past end of console_devices".

With these issues fixed, I was able to run the dm tests without any ASAN
issues. There are a couple of leaks reported at the end, but that's for
another day.

2 years agotest: dm: devres: Remove use-after-free
Andrew Scull [Sun, 3 Apr 2022 10:39:15 +0000 (10:39 +0000)]
test: dm: devres: Remove use-after-free

Use-after-free shouldn't be used, even in tests. It's bad practice and
makes the test brittle.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agotest: Fix pointer overrun in dm_test_devm_regmap()
Andrew Scull [Sun, 3 Apr 2022 10:39:14 +0000 (10:39 +0000)]
test: Fix pointer overrun in dm_test_devm_regmap()

This tests calls regmap_read() which takes a uint pointer as an output
parameter. The test was passing a pointer to a u16 which resulted in an
overflow when the output was written. Fix this by following the
regmap_read() API and passing a uint pointer instead.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Jean-Jacques Hiblot <jjhiblot@ti.com>
Cc: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agosound: Fix buffer overflow in square wave generation
Andrew Scull [Sun, 3 Apr 2022 10:39:13 +0000 (10:39 +0000)]
sound: Fix buffer overflow in square wave generation

Data is written for each channel but is only tracked as having one
channel written. This resulted in a buffer overflow and corruption of
the allocator's metadata which caused further problems when the buffer
was later freed. This could be observed with sandbox unit tests.

Resolve the overflow by tracking the writes for each channel.

Fixes: f987177db9 ("dm: sound: Use the correct number of channels for sound")
Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agousb: sandbox: Bounds check read from buffer
Andrew Scull [Sun, 3 Apr 2022 10:39:12 +0000 (10:39 +0000)]
usb: sandbox: Bounds check read from buffer

The buffer is 512 bytes but read requests can be 800 bytes. Limit the
request to the size of the buffer.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agousb: sandbox: Check for string end in copy_to_unicode()
Andrew Scull [Sun, 3 Apr 2022 10:39:11 +0000 (10:39 +0000)]
usb: sandbox: Check for string end in copy_to_unicode()

When copying the string in copy_to_unicode(), check for the null
terminator in each position, not just at the start, to avoid reading
beyond the end of the string.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: sandbox: Add missing PCI bar to barinfo
Andrew Scull [Sun, 3 Apr 2022 10:39:10 +0000 (10:39 +0000)]
x86: sandbox: Add missing PCI bar to barinfo

There are expecte to be bars 0 through 5, but the last of these was
missing leading to an read beyond the buffer. Add the missing element
with zero values.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agoacpi: Fix buffer overflow in do_acpi_dump()
Andrew Scull [Sun, 3 Apr 2022 10:39:09 +0000 (10:39 +0000)]
acpi: Fix buffer overflow in do_acpi_dump()

When do_acpi_dump() converts the table name to upper case, pass the
actual size of the output buffer so that the null terminator doesn't get
written beyond the end of the buffer.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Correct position of gdb '--args' parameter
Andrew Scull [Sun, 3 Apr 2022 10:39:08 +0000 (10:39 +0000)]
doc: Correct position of gdb '--args' parameter

The '--args' parameter to gdb comes before the binary that the debugger
will be attached to rather than after the binary and before the
arguments. Fix that in the docs.

Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agoefi_loader: call efi_init_early() earlier
Heinrich Schuchardt [Thu, 28 Apr 2022 06:30:30 +0000 (06:30 +0000)]
efi_loader: call efi_init_early() earlier

efi_init_early() creates an event hook for block device probing.
It has to be called before any block device is probed.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi_loader: disk: allow blk devices even without UCLASS_PARTITION
AKASHI Takahiro [Thu, 28 Apr 2022 04:49:16 +0000 (13:49 +0900)]
efi_loader: disk: allow blk devices even without UCLASS_PARTITION

While GPT partition is mandated in UEFI specification, CONFIG_PARTITION is
seen optional under the current implementation.
So modify efi_disk_rw_blocks() to allow accepting UCLASS_BLK devices.

Fixes: commit d97e98c887ed ("efi_loader: disk: use udevice instead of blk_desc")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Mark Kettenis <kettenis@openbsd.org>
2 years agoefi_loader: simplify efi_add_conventional_memory_map()
Heinrich Schuchardt [Mon, 25 Apr 2022 21:54:48 +0000 (23:54 +0200)]
efi_loader: simplify efi_add_conventional_memory_map()

Remove redundant constraint.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi_loader: simplify try_load_entry()
Heinrich Schuchardt [Mon, 25 Apr 2022 21:35:01 +0000 (23:35 +0200)]
efi_loader: simplify try_load_entry()

Use function efi_create_indexed_name() to create the BootXXXX variable
name.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi: fix devpath_is_partition()
Heinrich Schuchardt [Mon, 25 Apr 2022 21:21:20 +0000 (23:21 +0200)]
efi: fix devpath_is_partition()

If the path consists only of an end node, it does not refer to a partition.
Avoid returning a random value from the stack in this case.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi_loader: don't call log with __func__ as parameter
Heinrich Schuchardt [Fri, 29 Apr 2022 05:15:04 +0000 (07:15 +0200)]
efi_loader: don't call log with __func__ as parameter

The log functions print file name, line number, and function name if
selected via the log command or customizing. Don't print the function
name twice.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoMerge branch '2022-04-28-led-updates'
Tom Rini [Thu, 28 Apr 2022 17:46:31 +0000 (13:46 -0400)]
Merge branch '2022-04-28-led-updates'

- DM GPIO bugfix
- LED related code clean-ups
- Fix some of the DM/LED tests
- Update the LED dt binding doc

2 years agodt-bindings: leds: import common led bindings from linux 5.17
Pali Rohár [Thu, 28 Apr 2022 11:26:53 +0000 (13:26 +0200)]
dt-bindings: leds: import common led bindings from linux 5.17

This allows usage of LED_COLOR_ID_RGB macro in DTS files.

Signed-off-by: Pali Rohár <pali@kernel.org>
2 years agotest: dm: pinmux: Get LED2 udevice in the pinmux test
Marek Vasut [Mon, 25 Apr 2022 16:33:51 +0000 (18:33 +0200)]
test: dm: pinmux: Get LED2 udevice in the pinmux test

The UT reinitializes the pin controller state, get LED2 udevice
to trigger its probe and configure the pin controller pin state
as it is expected by the test.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
2 years agotest: dm: led: Fix LED enumeration
Marek Vasut [Mon, 25 Apr 2022 16:33:50 +0000 (18:33 +0200)]
test: dm: led: Fix LED enumeration

The GPIO LED driver no longer considers the top level node an LED,
because it is not an LED. With this bug fixed, the LED enumeration
has changed. Update the test accordingly.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
2 years agoled: Drop led_default_state()
Marek Vasut [Fri, 22 Apr 2022 13:41:42 +0000 (15:41 +0200)]
led: Drop led_default_state()

This function is empty, drop it.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2 years agoled: gpio: Use NOP uclass driver for top-level node
Marek Vasut [Fri, 22 Apr 2022 13:34:00 +0000 (15:34 +0200)]
led: gpio: Use NOP uclass driver for top-level node

The top level DT node of gpio-leds is not a LED itself, bind NOP uclass
driver to it, and bind different LED uclass driver to its subnodes which
represent the actual LEDs. This simplifies the probe() implementation
and fixes the bogus top-level not-an-LED in 'led list' command output:

```
=> led list
led             Error -121 <--- This is removed/fixed by this patch
green:user0     off
```

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
2 years agoled: gpio: Check device compatible string to determine the top level node
Marek Vasut [Fri, 22 Apr 2022 13:15:55 +0000 (15:15 +0200)]
led: gpio: Check device compatible string to determine the top level node

Since 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing"),
all LED nodes have some sort of label. Use device_is_compatible(..."leds-gpio")
to determine whether this is a top-level node, since it is only the top
level node which is compatible with "leds-gpio", the GPIO LEDs subnodes
are not.

Fixes: 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
2 years agoled: Mark device instance with DM_FLAG_PROBE_AFTER_BIND
Marek Vasut [Fri, 22 Apr 2022 13:15:54 +0000 (15:15 +0200)]
led: Mark device instance with DM_FLAG_PROBE_AFTER_BIND

Calling device_probe() from uclass .post_bind() callback has all kinds
of odd side-effects, e.g. device instances not being available just yet.
Make use of the DM_FLAG_PROBE_AFTER_BIND instead, mark device instances
which need to be probe()d in order to configure the LED default state
with this flag and let the DM core do the device_probe() at the right
time instead.

Fixes: 72675b063b6 ("led: Configure LED default-state on boot")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
2 years agodm: core: Add DM_FLAG_PROBE_AFTER_BIND flag
Marek Vasut [Fri, 22 Apr 2022 13:15:53 +0000 (15:15 +0200)]
dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag

Introduce DM_FLAG_PROBE_AFTER_BIND flag, which can be set by driver or
uclass in .bind(), to indicate such driver instance should be probe()d
once binding of all devices is complete.

This is useful in case the driver determines that hardware initialization
is mandatory on boot, and such initialization happens only in probe().
This also solves the inability to call device_probe() from .bind().

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
2 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-mpc85xx
Tom Rini [Wed, 27 Apr 2022 13:19:41 +0000 (09:19 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-mpc85xx

fsl-qoriq: Fixes and updates on fsl-layerscape
mpc85xx: fixes and code cleanup

2 years agoMerge tag 'u-boot-amlogic-20220427' of https://source.denx.de/u-boot/custodians/u...
Tom Rini [Wed, 27 Apr 2022 13:19:17 +0000 (09:19 -0400)]
Merge tag 'u-boot-amlogic-20220427' of https://source.denx.de/u-boot/custodians/u-boot-amlogic

- Add AXG support for SARADC, including minimal ao-clk driver
- Update Amlogic documentation for Matrix & Jethub D1

2 years agodoc: boards: amlogic: update jethub d1 specifications
Vyacheslav Bocharov [Tue, 26 Apr 2022 05:26:33 +0000 (08:26 +0300)]
doc: boards: amlogic: update jethub d1 specifications

Signed-off-by: Vyacheslav Bocharov <adeep@lexina.in>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
[narmstrong: removed trailing whitespaces and fixed sphinx build error]
Link: https://lore.kernel.org/r/20220426052633.3027932-2-adeep@lexina.in
2 years agoMerge tag 'u-boot-at91-2022.07-b' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 26 Apr 2022 11:54:12 +0000 (07:54 -0400)]
Merge tag 'u-boot-at91-2022.07-b' of https://source.denx.de/u-boot/custodians/u-boot-at91

Second set of u-boot-at91 features for the 2022.07 cycle:

This feature set includes the new driver for the AT91 reset controller,
a new board called sam9x60 curiosity, and several other fixes and
clean-ups (sama7g5ek qspi clock, impedance; remove unused code,
introduce Kconfig symbols for SPL timers)

2 years agocpu: 83xx: Add missing dependency on CPU_MPC83XX
Michal Simek [Fri, 22 Apr 2022 13:32:21 +0000 (15:32 +0200)]
cpu: 83xx: Add missing dependency on CPU_MPC83XX

It looks quite weird that for non PPC platforms cpu driver for MPC83xx can
be selected. That's why define proper dependency.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: ls1046afrwy: Remove Manish Tomar's email
Sean Anderson [Tue, 19 Apr 2022 21:06:31 +0000 (17:06 -0400)]
board: ls1046afrwy: Remove Manish Tomar's email

Manish Tomar's email bounces. Remove it, and reassign the config he was
maintaining to the primary maintainer for the board.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopci: fsl: Change compatible string for mpc8548 to "fsl, mpc8548-pcie"
Pali Rohár [Thu, 14 Apr 2022 20:52:03 +0000 (22:52 +0200)]
pci: fsl: Change compatible string for mpc8548 to "fsl, mpc8548-pcie"

Upstream Linux kernel uses for mpc8548-based PCIe controllers compatible
string "fsl,mpc8548-pcie". So change U-Boot fsl PCIe driver and all DTS
files to use "fsl,mpc8548-pcie" instead of "fsl,pcie-mpc8548" to be
compatible with Linux kernel.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Set dfsrr property for i2c nodes
Pali Rohár [Fri, 8 Apr 2022 12:39:58 +0000 (14:39 +0200)]
powerpc: dts: p2020: Set dfsrr property for i2c nodes

Linux kernel dts files pq3-i2c-*.dtsi also sets this dfsrr property for i2c
nodes.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Define L2 cache node
Pali Rohár [Fri, 8 Apr 2022 12:39:57 +0000 (14:39 +0200)]
powerpc: dts: p2020: Define L2 cache node

Copy definition of L2 cache node from upstream Linux kernel P2020 dts files.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Make usb@22000 node compatible for Linux kernel driver
Pali Rohár [Fri, 8 Apr 2022 12:39:56 +0000 (14:39 +0200)]
powerpc: dts: p2020: Make usb@22000 node compatible for Linux kernel driver

Linux P2020 USB kernel driver uses compatible string fsl-usb2-dr-v1.6 and
needs more DT properties. Copy P2020 usb@22000 properties from upstream
Linux kernel.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Add missing interrupts property to spi@7000 node
Pali Rohár [Fri, 8 Apr 2022 12:39:55 +0000 (14:39 +0200)]
powerpc: dts: p2020: Add missing interrupts property to spi@7000 node

interrupts property for spi@7000 node is needed for compatibility with
Linux kernel.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Do not automatically disable spi@7000 node in p2020-post.dtsi
Pali Rohár [Fri, 8 Apr 2022 12:39:54 +0000 (14:39 +0200)]
powerpc: dts: p2020: Do not automatically disable spi@7000 node in p2020-post.dtsi

Device tree include file p2020-post.dtsi should be included after the board
device tree file and overrides settings of the board. So it should not
disable some node as board cannot enable it via normal way (it has to
enable it after inclusion of p2020-post.dtsi file).

Fix it by removal of explicit disable in p2020-post.dtsi file and then
remove explicit post-post enable in all P2020 board device tree files.
Currently no P2020 board has spi@7000 node disabled.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Add Linux compatible string and property for eSDHC
Pali Rohár [Fri, 8 Apr 2022 12:39:53 +0000 (14:39 +0200)]
powerpc: dts: p2020: Add Linux compatible string and property for eSDHC

Linux kernel eSDHC driver for P2020 requires additional compatible string
fsl,p2020-esdhc and interrupts property. Add them to p2020-post.dtsi file
to make U-Boot board DTS files compatible for Linux kernel.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Add ptp_clock@24e00 node via pq3-etsec1-timer-0.dtsi
Pali Rohár [Fri, 8 Apr 2022 12:39:52 +0000 (14:39 +0200)]
powerpc: dts: p2020: Add ptp_clock@24e00 node via pq3-etsec1-timer-0.dtsi

Import pq3-etsec1-timer-0.dtsi device tree include file from upstream Linux
kernel for P2020. This allows U-Boot to use P2020 device tree files from
upstream Linux kernel which reference ptp_clock@24e00 device.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Make PCIe nodes compatible for Linux kernel driver
Pali Rohár [Fri, 8 Apr 2022 12:39:51 +0000 (14:39 +0200)]
powerpc: dts: p2020: Make PCIe nodes compatible for Linux kernel driver

Linux P2020 PCIe kernel driver uses compatible string fsl,mpc8548-pcie and
needs more DT properties. Copy P2020 PCIe nodes and definitions from
upstream Linux kernel.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Add gpio-controller@fc00 node via pq3-gpio-0.dtsi
Pali Rohár [Fri, 8 Apr 2022 12:39:50 +0000 (14:39 +0200)]
powerpc: dts: p2020: Add gpio-controller@fc00 node via pq3-gpio-0.dtsi

Import pq3-gpio-0.dtsi device tree include file from upstream Linux kernel
for P2020. This allows U-Boot to use P2020 device tree files from upstream
Linux kernel which reference gpio-controller@fc00 device.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Define SW macros for lower and upper NOR banks
Pali Rohár [Thu, 7 Apr 2022 10:16:22 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Define SW macros for lower and upper NOR banks

Replace hardcoded i2c hex values for NOR banks by named SW macros in
map_lowernorbank/map_uppernorbank env commands.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Use named macros for i2c bus num and address
Pali Rohár [Thu, 7 Apr 2022 10:16:21 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Use named macros for i2c bus num and address

Replace hardcoded boot i2c bus num and address by existing macros when
generating env for CONFIG_EXTRA_ENV_SETTINGS.

Same macros are used in U-Boot board code when reading information from
boot i2c data.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Fix env $vscfw_addr
Pali Rohár [Thu, 7 Apr 2022 10:16:20 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Fix env $vscfw_addr

Do not stringify env $vscfw_addr two times (once implicitly via string
operator "" and second time explicitly via __stringify() macro) and allow
to compile U-Boot without CONFIG_VSC7385_ENET (when __VSCFW_ADDR was not
defined and so macro name was stringified into CONFIG_EXTRA_ENV_SETTINGS).

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Move ifdef for USB/eLBC check to correct place
Pali Rohár [Thu, 7 Apr 2022 10:16:19 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Move ifdef for USB/eLBC check to correct place

Whole section about USB/eLBC configuration seems to be P1020 specific. So
add ifdefs to not compile it on other platforms (e.g. P2020).

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Fix page attributes for second 1G SDRAM map
Pali Rohár [Thu, 7 Apr 2022 10:16:18 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Fix page attributes for second 1G SDRAM map

Like for first 1G SDRAM map, do not enable Caching-inhibited nor Guarded
attribute for second 1G SDRAM mapping. Whole 2G SDRAM should use caches and
also allow speculative loading (by not setting Guarded attribute).

Also enable Memory Coherency attribute for second 1G SDRAM map. In commit
316f0d0f8f3c ("powerpc: mpc85xx: Fix static TLB table for SDRAM") it was
enabled for all SDRAM maps on all other boards, just missed this one case.

As a last thing, first 1G SDRAM map has wrong comment, so adjust it.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Do not set MPC85xx_PMUXCR_SDHC_WP bit when SDHC_WP...
Pali Rohár [Thu, 7 Apr 2022 10:16:17 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Do not set MPC85xx_PMUXCR_SDHC_WP bit when SDHC_WP is used as GPIO

When MPC85xx_PMUXCR_SDHC_WP is set then SDHC controller automatically makes
inserted SD card readonly if GPIO[9] is active.

In some design GPIO[9] pin does not have to be connected to SD card
write-protect pin and can be used as GPIO.

So do not set MPC85xx_PMUXCR_SDHC_WP bit when GPIO[9] is not used for
SDHC_WP functionality.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Detect both P2020 SD switch configurations
Pali Rohár [Thu, 7 Apr 2022 10:16:15 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Detect both P2020 SD switch configurations

As written in comment, P2020 has two possible SD switch configurations.
Extend code to detect both of them.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agoboard: freescale: p1_p2_rdb_pc: Do not hang in checkboard()
Pali Rohár [Thu, 7 Apr 2022 10:16:14 +0000 (12:16 +0200)]
board: freescale: p1_p2_rdb_pc: Do not hang in checkboard()

Like in all other checks in checkboard() function, do not hang on error.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: mpc85xx: Define linker sections in ascending order
Pali Rohár [Tue, 5 Apr 2022 13:12:35 +0000 (15:12 +0200)]
powerpc: mpc85xx: Define linker sections in ascending order

It is too confusing if sections are defined in non-ascending order.

Also linker has to go backward and then again forward when generating final
binary.

To make future changes easier, define all linker sections in ascending
order.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: mpc85xx: Put bss after image when not including reset vector
Pali Rohár [Tue, 5 Apr 2022 13:12:34 +0000 (15:12 +0200)]
powerpc: mpc85xx: Put bss after image when not including reset vector

Linker knows exact size of the image, so there is no need to use
CONFIG_SYS_MONITOR_LEN macro (which should be upper limit).

Remove usage of CONFIG_SYS_MONITOR_LEN macro to simplify setup.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: mpc85xx: Remove useless SIZEOF_HEADERS and .interp from ld script
Pali Rohár [Tue, 5 Apr 2022 13:12:33 +0000 (15:12 +0200)]
powerpc: mpc85xx: Remove useless SIZEOF_HEADERS and .interp from ld script

.interp section is not available in output ELF binary and SIZEOF_HEADERS is
needed at all.

There is no change in generated u-boot.bin binary.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: mpc85xx: Remove duplicate u-boot-nand.lds
Pali Rohár [Mon, 25 Apr 2022 08:51:20 +0000 (14:21 +0530)]
powerpc: mpc85xx: Remove duplicate u-boot-nand.lds

Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: mpc85xx: Remove u-boot-nand_spl.lds
Pali Rohár [Mon, 25 Apr 2022 04:02:03 +0000 (09:32 +0530)]
powerpc: mpc85xx: Remove u-boot-nand_spl.lds

mpc85xx SPL NAND linker script u-boot-nand_spl.lds is not used since
Jun 2014 commit 0234446fd171 ("nand_spl: remove MPC8536DS support").

Remove it.

Signed-off-by: Pali Rohár <pali@kernel.org>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: mpc85xx: Fix CONFIG_OF_SEPARATE support
Pali Rohár [Tue, 5 Apr 2022 13:12:30 +0000 (15:12 +0200)]
powerpc: mpc85xx: Fix CONFIG_OF_SEPARATE support

Currently CONFIG_OF_SEPARATE is completely broken and U-Boot for some
mpc85xx board (e.g. P2020) has to be compiled with CONFIG_OF_EMBED.
Otherwise it crashes during early init.

When debug console is enabled and all debug logging options are turned on
then U-Boot on P2020 with CONFIG_OF_SEPARATE prints following error:

  No valid device tree binary found at 110dc300
  initcall sequence 110d3560 failed at call 1109535c (err=-1)
  ### ERROR ### Please RESET the board ###

Problem is with appended DTB. When CONFIG_SYS_MPC85XX_NO_RESETVEC is set
U-Boot binary image without DTB ends immediately after the .u_boot_list
section. At this position is defined _end symbol at which U-Boot expects
start of the appended DTB.

Problem is that after .u_boot_list section are in linker script defined
another sections with 256 byte long padding which are completely empty.
During conversion of U-Boot ELF binary to RAW binary u-boot-nodtb.bin,
objcopy removes trailing zero padding and therefore DTB is appended at
wrong position.

Changing alignment from 256 bytes to 4 bytes fixes this issue. And appended
DTB is finally at he correct position. With this fix U-Boot on P2020 with
CONFIG_OF_SEPARATE option starts working again.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p1020/p2020: Fix esdhc node name
Pali Rohár [Tue, 5 Apr 2022 09:23:25 +0000 (11:23 +0200)]
powerpc: dts: p1020/p2020: Fix esdhc node name

For compatibility with Linux kernel DTS files and also with other U-Boot
powerpc DTS files, rename esdhc@2e000 node to sdhc@2e000 in p1020-post.dtsi
and p2020-post.dtsi include files.

Linux kernel DTS files which include these dtsi files, expect that esdhc
node has name sdhc@2e000 and do not work with other node names.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agopowerpc: dts: p2020: Add localbus node
Pali Rohár [Tue, 5 Apr 2022 09:15:21 +0000 (11:15 +0200)]
powerpc: dts: p2020: Add localbus node

This node is required for NAND and NOR support. Node is taken from the
upstream Linux kernel DTS file.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agommc: fsl_esdhc_spl: pre-PBL: implement redundancy support
Pali Rohár [Mon, 4 Apr 2022 16:33:11 +0000 (18:33 +0200)]
mmc: fsl_esdhc_spl: pre-PBL: implement redundancy support

QorIQ pre-PBL BootROM scans first 24 SD card sectors (each with fixed 512
bytes length) for boot signature. Implement same redundancy behavior in
fsl_esdhc_spl driver to allow loading proper U-Boot when boot sector is not
the first one.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agommc: fsl_esdhc: Define macro ESDHCCTL_SNOOP for Snoop attribute
Pali Rohár [Mon, 4 Apr 2022 16:32:13 +0000 (18:32 +0200)]
mmc: fsl_esdhc: Define macro ESDHCCTL_SNOOP for Snoop attribute

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agomtd: nand: raw: Add support for DT property nand-ecc-algo=bch
Pali Rohár [Mon, 4 Apr 2022 16:17:21 +0000 (18:17 +0200)]
mtd: nand: raw: Add support for DT property nand-ecc-algo=bch

According to Linux kernel DT schema nand-controller.yaml, using DT property
nand-ecc-algo=bch is the correct way for specifying BCH as ECC algorithm.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2 years agomtd: rawnand: fsl_elbc: Use ECC configuration from device tree
Pali Rohár [Mon, 4 Apr 2022 16:17:20 +0000 (18:17 +0200)]
mtd: rawnand: fsl_elbc: Use ECC configuration from device tree

Initialize ECC configuration after nand_scan_ident() call and only in case
nand_scan_ident() have not done it. nand_scan_ident() fills ECC
configuration from device tree.

Fixes usage of NAND_ECC_SOFT_BCH when it is specified in device tree.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>