platform/kernel/u-boot.git
3 years agoconfigs: rpi4: Enable DM_DMA across all RPi4 configurations
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:30 +0000 (13:55 +0100)]
configs: rpi4: Enable DM_DMA across all RPi4 configurations

The DM_DMA option is needed in order to translate physical address into
bus addresses on a per-device basis.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agommc: Introduce mmc_phys_to_bus()/mmc_bus_to_phys()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:29 +0000 (13:55 +0100)]
mmc: Introduce mmc_phys_to_bus()/mmc_bus_to_phys()

This will allow us to use DM variants of phys_to_bus()/bus_to_phys()
when relevant.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoxhci: translate virtual addresses into the bus's address space
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:28 +0000 (13:55 +0100)]
xhci: translate virtual addresses into the bus's address space

So far we've been content with passing physical addresses when
configuring memory addresses into XHCI controllers, but not all
platforms have buses with transparent mappings. Specifically the
Raspberry Pi 4 might introduce an offset to memory accesses incoming
from its PCIe port.

Introduce xhci_virt_to_bus() and xhci_bus_to_virt() to cater with these
limitations, and make sure we don't break non DM users.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
[mb: fix compilation for 32 bit]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
fix from nicolas

3 years agodm: test: Add test case for dev_phys_to_bus()/dev_bus_to_phys()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:27 +0000 (13:55 +0100)]
dm: test: Add test case for dev_phys_to_bus()/dev_bus_to_phys()

By reusing DT nodes already available in sandbox's test DT introduce a
test to validate dev_phys_to_bus()/dev_bus_to_phys().

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: Introduce dev_phys_to_bus()/dev_bus_to_phys()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:26 +0000 (13:55 +0100)]
dm: Introduce dev_phys_to_bus()/dev_bus_to_phys()

These functions, instead of relying on hard-coded platform-specific
address translations, make use of the DMA constraints provided by the DM
core. This allows for per-device translations.

We can't yet get rid of the legacy phys_to_bus()/bus_to_phys()
implementations as some of its users are not integrated into the
device model.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: test: Add test case for dev->dma_offset
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:25 +0000 (13:55 +0100)]
dm: test: Add test case for dev->dma_offset

Add test to validate dev->dma_offset is properly set on devices.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: Introduce DMA constraints into the core device model
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:24 +0000 (13:55 +0100)]
dm: Introduce DMA constraints into the core device model

Calculating the DMA offset between a bus address space and CPU's every
time we call phys_to_bus() and bus_to_phys() isn't ideal performance
wise, as it implies traversing the device tree from the device's node up
to the root. Since this information is static and available before the
device's initialization, parse it before the probe call an provide the
DMA offset in 'struct udevice' for the address translation code to use
it.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: test: Add test case for dev_get_dma_ranges()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:23 +0000 (13:55 +0100)]
dm: test: Add test case for dev_get_dma_ranges()

Introduce some new nodes in sandbox's test device-tree and dm tests in
order to validate dev_get_dma_range().

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agodm: Introduce xxx_get_dma_range()
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:22 +0000 (13:55 +0100)]
dm: Introduce xxx_get_dma_range()

Add the following functions to get a specific device's DMA ranges:
 - dev_get_dma_range()
 - ofnode_get_dma_range()
 - of_get_dma_range()
 - fdt_get_dma_range()
They are specially useful in oder to be able validate a physical address
space range into a bus's and to convert addresses from and to address
spaces.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agopci: pcie-brcmstb: Fix inbound window configurations
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:21 +0000 (13:55 +0100)]
pci: pcie-brcmstb: Fix inbound window configurations

So far we've assumed a fixed configuration for inbound windows as we had
a single user for this controller. But the controller's DMA constraints
were improved starting with BCM2711's B1 revision of the SoC, notably
available in CM4 and Pi400. They allow for wider inbound windows. We can
now cover the whole address space, whereas before we where limited to
the lower 3GB.

This information is passed to us through DT's 'dma-ranges' property and
it's specially important for us to honor it since some interactions with
the board's co-processor assume we're doing so (specifically the XHCI
firmware load operation, which is handled by the co-processor after
u-boot has correctly configured the PCIe controller).

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorpi: Add identifier for the new CM4
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:20 +0000 (13:55 +0100)]
rpi: Add identifier for the new CM4

The Raspberry Pi Foundation released the new Compute Module 4 which we
want to detect, so we can enable Ethernet on it and know the correct
device tree file name.

Note that this sets the Ethernet option to true since the official CM4
IO board has an Ethernet port. But that might not be the case when using
custom ones.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorpi: Add identifier for the new RPi400
Nicolas Saenz Julienne [Tue, 12 Jan 2021 12:55:19 +0000 (13:55 +0100)]
rpi: Add identifier for the new RPi400

The Raspberry Pi Foundation released the new RPi400 which we want to
detect, so we can enable Ethernet on it and know the correct device tree
file name.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE
Marek Szyprowski [Mon, 1 Feb 2021 11:16:33 +0000 (12:16 +0100)]
rpi: limit size of the RAM to the multiple of the MMU_SECTION_SIZE

When RPi4 is booted from USB Mass Storage, the firmware reports 947MiB of
the ARM memory (948 in case of the standard SD-card boot). This value is
not MMU_SECTION_SIZE aligned, so the dram_bank_mmu_setup() skips mapping
of the last 1MiB. This later causes u-boot in ARM 32bit mode to freeze,
because it relocated itself into that unmapped memory and fails to
execute.

Fix this by limiting the size of the first bank to the multiple of
MMU_SECTION_SIZE.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agopci: brcmstb: Cleanup controller state before handover
Nicolas Saenz Julienne [Thu, 14 Jan 2021 15:49:01 +0000 (16:49 +0100)]
pci: brcmstb: Cleanup controller state before handover

Make sure we handover the PCIe controller in a clean state. Some of the
devices hanging from the PCIe bus might need to be properly reset
through #PERST in order for Linux to be able to initialize them.

This is specially important in order to properly initialize Raspberry Pi
4 B and 400's USB chip.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agousb: xhci-pci: Add DM_FLAG_OS_PREPARE flag
Nicolas Saenz Julienne [Thu, 14 Jan 2021 15:49:00 +0000 (16:49 +0100)]
usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag

The PCIe bus the controller is connected to might need to be removed
prior the handover. Make sure xhci-pci is also removed so as to avoid
unexpected timeouts or hangs.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoconfig: Enable iProc RNG200 driver in RPi4 configs
Matthias Brugger [Tue, 15 Dec 2020 09:49:24 +0000 (10:49 +0100)]
config: Enable iProc RNG200 driver in RPi4 configs

We find the iProc RNG200 in the Raspberry Pi 4. Add it to all it's
config so that it can be used.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
[mb: drop rpi_4_32b_defconfig]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agorng: Add iProc RNG200 driver
Matthias Brugger [Tue, 15 Dec 2020 09:49:23 +0000 (10:49 +0100)]
rng: Add iProc RNG200 driver

Add support for random number generator RNG200.
This is for example found on RPi4.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
[mb: adapt to new struct driver memebers]
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
3 years agoMerge branch '2021-02-16-assorted-improvements'
Tom Rini [Tue, 16 Feb 2021 20:14:34 +0000 (15:14 -0500)]
Merge branch '2021-02-16-assorted-improvements'

- DSA switch support (Layerscape platforms)
- IOMUX cleanup / fixes
- i2c OP-TEE trampoline driver

3 years agoconfigs: ls1028a: Enable the Ethernet switch driver in defconfig
Alex Marginean [Mon, 25 Jan 2021 12:23:57 +0000 (14:23 +0200)]
configs: ls1028a: Enable the Ethernet switch driver in defconfig

The switch driver for LS1028A Ethernet switch is now compiled in for
the NXP LS1028A reference design boards and for the Kontron SMARC-sAL28.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Michael Walle <michael@walle.cc>
3 years agoarm: dts: ls1028a: Add Ethernet switch node and dependencies
Alex Marginean [Mon, 25 Jan 2021 12:23:56 +0000 (14:23 +0200)]
arm: dts: ls1028a: Add Ethernet switch node and dependencies

The definition follows the DSA binding in kernel and describes the switch,
its ports and PHYs.  The switch node has the same structure as in Linux
and this patch enables it (and relevant ports) for the LS1028A RDB board.

ENETC PF6 is the 2nd Eth controller linked to the switch on LS1028A, it is
not used in U-Boot and was disabled.  Ethernet port aliases were also
added to better manage the multitude of ports available now.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Michael Walle <michael@walle.cc>
3 years agodrivers: net: Add Felix DSA switch driver
Alex Marginean [Mon, 25 Jan 2021 12:23:55 +0000 (14:23 +0200)]
drivers: net: Add Felix DSA switch driver

This driver is used for the Ethernet switch integrated into LS1028A NXP.
Felix on LS1028A has 4 front panel ports and two internal ports, I/O
to/from the switch is done through an ENETC Ethernet interface.
The 4 front panel ports are available as Ethernet interfaces and can be
used with the typical network commands like tftp.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
3 years agonet: Introduce DSA class for Ethernet switches
Claudiu Manoil [Mon, 25 Jan 2021 12:23:53 +0000 (14:23 +0200)]
net: Introduce DSA class for Ethernet switches

DSA stands for Distributed Switch Architecture and it covers switches that
are connected to the CPU through an Ethernet link and generally use frame
tags to pass information about the source/destination ports to/from CPU.
Front panel ports are presented as regular ethernet devices in U-Boot and
they are expected to support the typical networking commands.
DSA switches may be cascaded, DSA class code does not currently support
this.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
3 years agonet: phy: introduce fixed_phy_create for DSA CPU ports
Vladimir Oltean [Mon, 25 Jan 2021 12:23:52 +0000 (14:23 +0200)]
net: phy: introduce fixed_phy_create for DSA CPU ports

The DSA (Distributed Switch Architecture) implementation has made a
design decision when it got introduced to the Linux kernel in 2008.
That was to hide away from the user the CPU-facing Ethernet MAC, since
it does not make sense to register it as a struct net_device (UCLASS_ETH
udevice for U-Boot), because that would never be beneficial for a user:
they would not be able to use it for traffic, since conceptually, a
packet delivered to the CPU port should loop back into the system.

Nonetheless, DSA has had numerous growing pains due to the lack of a
struct net_device for the CPU port, but so far it has overcome them.
It is unlikely at this stage of maturity that this aspect of it will
change.

We would like U-Boot to present the same information as Linux, to be at
parity in terms of number of interfaces, so that ethNaddr environment
variables could directly be associated between U-Boot and Linux.
Therefore, we would implicitly like U-Boot to hide the CPU port from the
user as well.

But the paradox is that DSA still needs a struct phy_device to inform
the driver of the parameters of the link that it should configure the
CPU port to. The problem is that the phy_device is typically returned
via a call to phy_connect, which needs an udevice to attach the PHY to,
and to search its ofnode for the 'fixed-link' property. But we don't
have an udevice to present for the CPU port.

Since 99% of DSA setups are MAC-to-MAC connections between the switch
and the host Ethernet controller, the struct phy_device is going to be a
fixed PHY. This simplifies things quite a bit. In U-Boot, a fixed PHY
does not need an MDIO bus, and does not need an attached dev either.
Basically, the phy_connect call doesn't do any connection, it just
creates the fixed PHY.

The proposal of this patch is to introduce a new fixed_phy_create
function which will take a single argument: the ofnode that holds this:

port@4 {
reg = <4>;
phy-mode = "internal";

fixed-link {
speed = <2500>;
full-duplex;
};
};

and probe a fixed PHY driver using the information from this ofnode.
DSA will probably be the only user of this function.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
3 years agonet: phy: fixed: support speeds of 2500 and 10000
Vladimir Oltean [Mon, 25 Jan 2021 12:23:51 +0000 (14:23 +0200)]
net: phy: fixed: support speeds of 2500 and 10000

Unlike the Linux fixed PHY driver, the one in U-Boot does not attempt to
emulate the clause 22 register set of a gigabit copper PHY driver
through the swphy framework. Therefore, the limitation of being unable
to support speeds higher than gigabit in fixed-link does not apply to
the U-Boot fixed PHY driver. This makes the fixed-link U-Boot
implementation more similar to the one from phylink, which can work with
any valid link speed.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
3 years agotest: dm: tee: extend with RPC test
Igor Opaniuk [Mon, 25 Jan 2021 12:28:43 +0000 (14:28 +0200)]
test: dm: tee: extend with RPC test

Extend existing DM tee tests adding test coverage for reverse RPC calls.
Currently this commit only adds tests for I2C requests from TEE driver
to TEE supplicant, for instance reading/writing data to emulated i2c
eeprom defines in standard sandbox test device tree
(arch/sandbox/dts/test.dtb):

=> i2c bus
Bus 0: i2c@0  (active 0)
   2c: eeprom@2c, offset len 1, flags 0
   ...

Running TEE tests:
=> ut dm tee
Test: dm_test_tee: tee.c
Test: dm_test_tee: tee.c (flat tree)
Failures: 0

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agodrivers: tee: sandbox: add rpc test ta emulation
Igor Opaniuk [Mon, 25 Jan 2021 12:28:42 +0000 (14:28 +0200)]
drivers: tee: sandbox: add rpc test ta emulation

This adds support for RPC test trusted application emulation, which
permits to test reverse RPC calls to TEE supplicant. Currently it covers
requests to the I2C bus from TEE.

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agotest: py: add pygit2 and pyelftools to requirements.txt
Igor Opaniuk [Mon, 25 Jan 2021 12:28:41 +0000 (14:28 +0200)]
test: py: add pygit2 and pyelftools to requirements.txt

Add pygit2 and pyelftools to the list of packages for virtualenv
needed to run all sets of pytests.This fixes warnings like:

binman.elf_test.TestElf.testDecodeElf (subunit.RemotedTestCase):
Python elftools not available

Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agodrivers: tee: i2c trampoline driver
Jorge Ramirez-Ortiz [Mon, 25 Jan 2021 12:28:40 +0000 (14:28 +0200)]
drivers: tee: i2c trampoline driver

This commit gives the secure world access to the I2C bus so it can
communicate with I2C slaves (typically those would be secure elements
like the NXP SE050).

A similar service implementation has been merged in linux:
c05210ab ("drivers: optee: allow op-tee to access devices on the i2c
bus")

Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
3 years agousb: kbd: destroy device after console is stopped
Andy Shevchenko [Thu, 11 Feb 2021 15:09:44 +0000 (17:09 +0200)]
usb: kbd: destroy device after console is stopped

In case of IOMUX enabled it assumes that console devices in the list
are available to get them stopped properly via ->stop() callback.
However, the USB keyboard driver violates this assumption and tries
to play tricks so the device get destroyed while being listed as
an active console.

Swap the order of device deregistration and IOMUX update along with
converting to use iomux_replace_device() jelper to avoid the use-after-free.

Fixes: 3cbcb2892809 ("usb: Fix usb_kbd_deregister when console-muxing is used")
Fixes: 8a8348703081 ("dm: usb: Add a remove() method for USB keyboards")
Reported-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Introduce iomux_replace_device()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:43 +0000 (17:09 +0200)]
IOMUX: Introduce iomux_replace_device()

Some console devices may appear or disappear at run time. In order to
support such a hotplug mechanism introduce a new iomux_replace_device()
helper to update the list of devices without altering environment.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Split out for_each_console_dev() helper macro
Andy Shevchenko [Thu, 11 Feb 2021 15:09:42 +0000 (17:09 +0200)]
IOMUX: Split out for_each_console_dev() helper macro

It is not only less lines of code, but also better readability
when new macro is being in use. Introduce for_each_console_dev()
helper macro and convert current users to it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Split out iomux_match_device() helper
Andy Shevchenko [Thu, 11 Feb 2021 15:09:41 +0000 (17:09 +0200)]
IOMUX: Split out iomux_match_device() helper

Deduplicate the code used in a few places by splitting out a common helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoIOMUX: Switch to use stdio_file_to_flags()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:40 +0000 (17:09 +0200)]
IOMUX: Switch to use stdio_file_to_flags()

Deduplicate code by replacing with stdio_file_to_flags() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoconsole: Set file and devices at one go
Andy Shevchenko [Thu, 11 Feb 2021 15:09:39 +0000 (17:09 +0200)]
console: Set file and devices at one go

Logical continuation of the change that brought console_devices_set() is
to unify console_setfile() with it and replace in the callers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoconsole: Set console device counter in console_devices_set()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:38 +0000 (17:09 +0200)]
console: Set console device counter in console_devices_set()

console_devices_set() missed the console device counter to be set correctly.

Fixes: 45375adc9799 ("console: add function console_devices_set")
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoconsole: Switch to use stdio_file_to_flags()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:37 +0000 (17:09 +0200)]
console: Switch to use stdio_file_to_flags()

Deduplicate code by replacing with stdio_file_to_flags() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agostdio: Introduce a new helper stdio_file_to_flags()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:36 +0000 (17:09 +0200)]
stdio: Introduce a new helper stdio_file_to_flags()

Let's deduplicate existing copies by splitting off to a new helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agostdio: Split out nulldev_register() and move it under #if
Andy Shevchenko [Thu, 11 Feb 2021 15:09:35 +0000 (17:09 +0200)]
stdio: Split out nulldev_register() and move it under #if

It's possible that NULLDEV can be disabled while it makes leftovers,
move entire device under #if.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agostdio: Get rid of dead code, i.e. stdio_deregister()
Andy Shevchenko [Thu, 11 Feb 2021 15:09:34 +0000 (17:09 +0200)]
stdio: Get rid of dead code, i.e. stdio_deregister()

Nobody is using stdio_deregister(), remove for good.

Note, even its parameters are not consistent with stdio_register().
So, if anyone want to introduce this again, better with some consistency.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 years agoPrepare v2021.04-rc2
Tom Rini [Tue, 16 Feb 2021 03:34:56 +0000 (22:34 -0500)]
Prepare v2021.04-rc2

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge branch '2021-02-15-fix-CVE-2021-27097-CVE-2021-27138'
Tom Rini [Tue, 16 Feb 2021 00:19:56 +0000 (19:19 -0500)]
Merge branch '2021-02-15-fix-CVE-2021-27097-CVE-2021-27138'

Fix CVE-2021-27097 and CVE-2021-27138.  For more details see
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-27097 and
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-27138

3 years agoimage: Check for unit addresses in FITs
Simon Glass [Tue, 16 Feb 2021 00:08:12 +0000 (17:08 -0700)]
image: Check for unit addresses in FITs

Using unit addresses in a FIT is a security risk. Add a check for this
and disallow it.

CVE-2021-27138

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agolibfdt: Check for multiple/invalid root nodes
Simon Glass [Tue, 16 Feb 2021 00:08:11 +0000 (17:08 -0700)]
libfdt: Check for multiple/invalid root nodes

It is possible to construct a devicetree blob with multiple root nodes.
Update fdt_check_full() to check for this, along with a root node with an
invalid name.

CVE-2021-27097

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agoimage: Add an option to do a full check of the FIT
Simon Glass [Tue, 16 Feb 2021 00:08:10 +0000 (17:08 -0700)]
image: Add an option to do a full check of the FIT

Some strange modifications of the FIT can introduce security risks. Add an
option to check it thoroughly, using libfdt's fdt_check_full() function.

Enable this by default if signature verification is enabled.

CVE-2021-27097

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agoimage: Adjust the workings of fit_check_format()
Simon Glass [Tue, 16 Feb 2021 00:08:09 +0000 (17:08 -0700)]
image: Adjust the workings of fit_check_format()

At present this function does not accept a size for the FIT. This means
that it must be read from the FIT itself, introducing potential security
risk. Update the function to include a size parameter, which can be
invalid, in which case fit_check_format() calculates it.

For now no callers pass the size, but this can be updated later.

Also adjust the return value to an error code so that all the different
types of problems can be distinguished by the user.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agotest: Add tests for the 'evil' vboot attacks
Simon Glass [Tue, 16 Feb 2021 00:08:08 +0000 (17:08 -0700)]
test: Add tests for the 'evil' vboot attacks

Add tests to check that these two attacks are mitigated by recent patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agotest: Add vboot_evil implementation
Simon Glass [Tue, 16 Feb 2021 00:08:07 +0000 (17:08 -0700)]
test: Add vboot_evil implementation

Add a library which performs two different attacks on a FIT.

Signed-off-by: Julien Lenoir <julien.lenoir@intel.com>
Signed-off-by: Bruce Monroe <bruce.monroe@intel.com>
Signed-off-by: Arie Haenel <arie.haenel@intel.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agofit: Don't allow verification of images with @ nodes
Simon Glass [Tue, 16 Feb 2021 00:08:06 +0000 (17:08 -0700)]
fit: Don't allow verification of images with @ nodes

When searching for a node called 'fred', any unit address appended to the
name is ignored by libfdt, meaning that 'fred' can match 'fred@1'. This
means that we cannot be sure that the node originally intended is the one
that is used.

Disallow use of nodes with unit addresses.

Update the forge test also, since it uses @ addresses.

CVE-2021-27138

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agofdt_region: Check for a single root node of the correct name
Simon Glass [Tue, 16 Feb 2021 00:08:05 +0000 (17:08 -0700)]
fdt_region: Check for a single root node of the correct name

At present fdt_find_regions() assumes that the FIT is a valid devicetree.
If the FIT has two root nodes this is currently not detected in this
function, nor does libfdt's fdt_check_full() notice. Also it is possible
for the root node to have a name even though it should not.

Add checks for these and return -FDT_ERR_BADSTRUCTURE if a problem is
detected.

CVE-2021-27097

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Bruce Monroe <bruce.monroe@intel.com>
Reported-by: Arie Haenel <arie.haenel@intel.com>
Reported-by: Julien Lenoir <julien.lenoir@intel.com>
3 years agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 15 Feb 2021 18:34:30 +0000 (13:34 -0500)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge branch '2021-02-02-drop-asm_global_data-when-unused'
Tom Rini [Mon, 15 Feb 2021 13:19:40 +0000 (08:19 -0500)]
Merge branch '2021-02-02-drop-asm_global_data-when-unused'

- Merge the patch to take <asm/global_data.h> out of <common.h>

3 years agoMerge branch '2021-02-14-remove-some-boards'
Tom Rini [Mon, 15 Feb 2021 13:15:42 +0000 (08:15 -0500)]
Merge branch '2021-02-14-remove-some-boards'

- Remove some boards that are behind on conversions and have had their
  removal acked or suggested by the relevant maintainers.

3 years agosh: Remove sh7763rdp board
Tom Rini [Wed, 10 Feb 2021 17:51:26 +0000 (12:51 -0500)]
sh: Remove sh7763rdp board

This board has not been converted to CONFIG_DM by the deadline of v2020.01
and is missing other conversions which depend on this as well.  Remove it.

Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agosh: Remove sh7757lcr board
Tom Rini [Wed, 10 Feb 2021 17:51:25 +0000 (12:51 -0500)]
sh: Remove sh7757lcr board

This board has not been converted to CONFIG_DM by the deadline of v2020.01
and is missing other conversions which depend on this as well.  Remove it.

As this is the last SH4A board, remove that support as well.

Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agosh: Remove sh7753evb board
Tom Rini [Wed, 10 Feb 2021 17:51:24 +0000 (12:51 -0500)]
sh: Remove sh7753evb board

This board has not been converted to CONFIG_DM by the deadline of v2020.01
and is missing other conversions which depend on this as well.  Remove it.

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agosh: Remove sh7752evb board
Tom Rini [Wed, 10 Feb 2021 17:51:23 +0000 (12:51 -0500)]
sh: Remove sh7752evb board

This board has not been converted to CONFIG_DM by the deadline of v2020.01
and is missing other conversions which depend on this as well.  Remove it.

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agosh: Remove r7780mp board
Tom Rini [Wed, 10 Feb 2021 17:51:22 +0000 (12:51 -0500)]
sh: Remove r7780mp board

This board has not been converted to CONFIG_DM by the deadline of v2020.01
and is missing other conversions which depend on this as well.  Remove it.

Patch-cc: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
Patch-cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agosh: Remove MigoR board
Tom Rini [Wed, 10 Feb 2021 17:51:21 +0000 (12:51 -0500)]
sh: Remove MigoR board

This board has not been converted to CONFIG_DM by the deadline of v2020.01
and is missing other conversions which depend on this as well.  Remove it.

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoppc: Remove MPC8641HPCN board
Tom Rini [Wed, 10 Feb 2021 02:42:54 +0000 (21:42 -0500)]
ppc: Remove MPC8641HPCN board

This board relies on using CONFIG_LIBATA but does not enable CONFIG_AHCI.  The
deadline for this conversion was the v2019.07 release.  The use of CONFIG_AHCI
requires CONFIG_DM.  The deadline for this conversion was v2020.01.  Remove
this board.

Cc: Priyanka Jain <priyanka.jain@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: Remove MPC8610HPCD board
Tom Rini [Wed, 10 Feb 2021 02:42:53 +0000 (21:42 -0500)]
ppc: Remove MPC8610HPCD board

This board relies on using CONFIG_LIBATA but does not enable CONFIG_AHCI.  The
deadline for this conversion was the v2019.07 release.  The use of CONFIG_AHCI
requires CONFIG_DM.  The deadline for this conversion was v2020.01.  Remove
this board.

Cc: Priyanka Jain <priyanka.jain@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: Remove MPC8572DS board
Tom Rini [Wed, 10 Feb 2021 02:42:52 +0000 (21:42 -0500)]
ppc: Remove MPC8572DS board

This board relies on using CONFIG_LIBATA but does not enable CONFIG_AHCI.  The
deadline for this conversion was the v2019.07 release.  The use of CONFIG_AHCI
requires CONFIG_DM.  The deadline for this conversion was v2020.01.  Remove
this board.

Cc: Priyanka Jain <priyanka.jain@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoppc: Remove MPC8544DS board
Tom Rini [Wed, 10 Feb 2021 02:42:51 +0000 (21:42 -0500)]
ppc: Remove MPC8544DS board

This board relies on using CONFIG_LIBATA but does not enable CONFIG_AHCI.  The
deadline for this conversion was the v2019.07 release.  The use of CONFIG_AHCI
requires CONFIG_DM.  The deadline for this conversion was v2020.01.  Remove
this board.

Cc: Priyanka Jain <priyanka.jain@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoarm: Remove db-88f6281-bp board
Tom Rini [Tue, 9 Feb 2021 13:03:16 +0000 (08:03 -0500)]
arm: Remove db-88f6281-bp board

This board has not been converted to CONFIG_DM_MMC by the deadline of
v2019.04, which is almost two years ago.  In addition there are other DM
migrations it is also missing.  Remove it.

Cc: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Chris Packham <judge.packham@gmail.com>
3 years agoarm: Remove ls2080a_simu board
Tom Rini [Tue, 9 Feb 2021 13:03:10 +0000 (08:03 -0500)]
arm: Remove ls2080a_simu board

This board has not been converted to CONFIG_DM_MMC by the deadline of
v2019.04, which is almost two years ago.  In addition there are other DM
migrations it is also missing.  Remove it.

Cc: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Cc: Priyanka Jain <priyanka.jain@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
3 years agoarm: Remove mx35pdk board
Tom Rini [Tue, 9 Feb 2021 13:03:02 +0000 (08:03 -0500)]
arm: Remove mx35pdk board

This board has not been converted to CONFIG_DM_MMC by the deadline of
v2019.04, which is almost two years ago.  In addition there are other DM
migrations it is also missing.  Remove it.

Cc: Stefano Babic <sbabic@denx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Stefano Babic <sbabic@denx.de>
3 years agoarm: Remove apx4devkit board
Tom Rini [Tue, 9 Feb 2021 13:02:59 +0000 (08:02 -0500)]
arm: Remove apx4devkit board

This board has not been converted to CONFIG_DM_MMC by the deadline of
v2019.04, which is almost two years ago.  In addition there are other DM
migrations it is also missing.  Remove it.

Cc: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Lauri Hintsala <lauri.hintsala@silabs.com<mailto:lauri.hintsala@silabs.com>>
Signed-off-by: Tom Rini <trini@konsulko.com<mailto:trini@konsulko.com>>
3 years agoRevert "fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup()"
Tom Rini [Sun, 14 Feb 2021 19:08:17 +0000 (14:08 -0500)]
Revert "fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup()"

On Rockchip platforms we need this area of code in TPL, but there is no
TPL_SEPARATE_BSS symbol.

This reverts commit 0a2aaab0b678fd1778ff2fc59d0770fc82995532.

Reported-by: Markus Reichl <m.reichl@fivetechno.de>
Reported-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer>
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge tag 'efi-2021-04-rc2-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sun, 14 Feb 2021 14:27:46 +0000 (09:27 -0500)]
Merge tag 'efi-2021-04-rc2-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for efi-2021-04-rc2-2

Bug fixes:
* fix stack smashing in UEFI capsule updates
* correct loading of UEFI binaries where Virtual size is not a
  multiple of FileAlignment
* simplify detection of capsule files.
* buildman: use threading.is_alive() instead of removed method IsAlive()

3 years agobuildman: 'Thread' object has no attribute 'isAlive'
Heinrich Schuchardt [Thu, 11 Feb 2021 11:03:22 +0000 (12:03 +0100)]
buildman: 'Thread' object has no attribute 'isAlive'

The isAlive() method was deprecated in Python 3.8 and has been removed in
Python 3.9. See https://bugs.python.org/issue37804. Use is_alive() instead.

Since Python 2.6 is_alive() has been a synonym for isAlive(). So there
should be no problems for users using elder Python 3 versions.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoefi_loader: fix get_last_capsule()
Heinrich Schuchardt [Tue, 9 Feb 2021 19:20:34 +0000 (20:20 +0100)]
efi_loader: fix get_last_capsule()

fix get_last_capsule() leads to writes beyond the stack allocated buffer.
This was indicated when enabling the stack protector.

utf16_utf8_strcpy() only stops copying when reaching '\0'. The current
invocation always writes beyond the end of value[].

The output length of utf16_utf8_strcpy() may be longer than the number of
UTF-16 tokens. E.g has "CapsuleКиев" has 11 UTF-16 tokens but 15 UTF-8
tokens. Hence, using utf16_utf8_strcpy() without checking the input may
lead to further writes beyond value[].

The current invocation of strict_strtoul() reads beyond the end of value[].

A non-hexadecimal value after "Capsule" (e.g. "CapsuleZZZZ") must result in
an error. We cat catch this by checking the return value of strict_strtoul().

A value that is too short after "Capsule" (e.g. "Capsule0") must result in
an error. We must check the string length of value[].

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: '.' and '..' are directories
Heinrich Schuchardt [Tue, 9 Feb 2021 16:45:33 +0000 (17:45 +0100)]
efi_loader: '.' and '..' are directories

'.' and '..' are directories. So when looking for capsule files it is
sufficient to check that the attribute EFI_FILE_DIRECTORY is not set. We
don't have to check for these special names.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: don't load beyond VirtualSize
Asherah Connor [Tue, 9 Feb 2021 06:19:48 +0000 (06:19 +0000)]
efi_loader: don't load beyond VirtualSize

PE section table entries' SizeOfRawData must be a multiple of
FileAlignment, and thus may be rounded up and larger than their
VirtualSize.

We should not load beyond the VirtualSize, which is "the total size of
the section when loaded into memory" -- we may clobber real data at the
target in some other section, since we load sections in reverse order
and sections are usually laid out sequentially.

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoMerge tag 'u-boot-atmel-fixes-2021.04-a' of https://gitlab.denx.de/u-boot/custodians...
Tom Rini [Fri, 12 Feb 2021 14:09:10 +0000 (09:09 -0500)]
Merge tag 'u-boot-atmel-fixes-2021.04-a' of https://gitlab.denx.de/u-boot/custodians/u-boot-atmel

First set of u-boot-atmel fixes for 2021.04 cycle:

This small PR includes just two fixes but very important: one revert in
the clk subsystem which fixes the boot on many old boards
(sama5d2_xplained, sama5d4_xplained), which currently crash at boot; and
one small fix related to debug serial on sama7g5ek board.

3 years agoclk: at91: compat: partially revert "dm: Remove uses of device_bind_offset()"
Eugen Hristev [Tue, 2 Feb 2021 08:47:58 +0000 (10:47 +0200)]
clk: at91: compat: partially revert "dm: Remove uses of device_bind_offset()"

Revert changes in at91 compat.c that cause u-boot to fail booting on
sama5d4_xplained and sama5d2_xplained

Log below:

<debug_uart>
No serial driver found
Could not initialize timer (err -19)

Could not initialize timer (err -19)

Could not initialize timer (err -19)

Could not initialize timer (err -19)

Could not initialize timer (err -19)

Could not initialize timer (err -19)

Could not initialize timer (err -19)

Could not initialize timer (err -19)

Fixes: a2703ce10c ("dm: Remove uses of device_bind_offset()")
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: dts: at91: sama7g5ek: enable pull-up for serial debug line
Eugen Hristev [Thu, 28 Jan 2021 08:14:11 +0000 (10:14 +0200)]
ARM: dts: at91: sama7g5ek: enable pull-up for serial debug line

If the serial tx/rx are floating, it can happen that bogus characters
are detected on the line at boot time. This leads to U-boot accidentally
thinking someone pressed a key to stop autoboot, thus stopping booting process.
This can happen if the serial cable is not connected. There are hardware
pull-ups on the board connected to serial cable VBUS.
To solve this when the cable is not plugged, enable internal pull-ups as well
for the tx/rx lines.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
3 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Thu, 11 Feb 2021 01:40:08 +0000 (20:40 -0500)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-usb

- MediaTek updates
- xhci fixes
- dwc2 stm32 compatible update

3 years agousb: dwc2: change compatible st,stm32mp1-hsotg to st,stm32mp15-hsotg
Patrick Delaunay [Tue, 9 Feb 2021 10:14:46 +0000 (11:14 +0100)]
usb: dwc2: change compatible st,stm32mp1-hsotg to st,stm32mp15-hsotg

The Linux kernel v5.7-rc1 introduced the compatible "st,stm32mp15-hsotg".

See Linux kernel commit d49850110434 ("dt-bindings: usb: dwc2: add
support for STM32MP15 SoCs USB OTG HS and FS")

This patch updates the supported compatible in DWC2 driver,
removes the add-on done in U-Boot dtsi and keeps the compatible
defined in SOC dtsi arch/arm/dts/stm32mp151.dtsi:

usbotg_hs: usb-otg@49000000 {
compatible = "st,stm32mp15-hsotg", "snps,dwc2";
reg = <0x49000000 0x10000>;
...
};

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agousb: xhci: Fix compare to use physical addresses in xhci_bulk_tx()
Stefan Roese [Fri, 15 Jan 2021 07:52:56 +0000 (08:52 +0100)]
usb: xhci: Fix compare to use physical addresses in xhci_bulk_tx()

Testing with v2021.01 on MIPS Octeon has shown, that the latest patch
for the "short packet event trb handling" did introduce a bug on
platforms with virtual address != physical address. This patch fixes
this issue by using the correct address types in the compare (both
physical in this case).

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Aaron Williams <awilliams@marvell.com>
Cc: Chandrakala Chavva <cchavva@marvell.com>
Cc: Ran Wang <ran.wang_1@nxp.com>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Marek Vasut <marex@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
3 years agousb: xhci-pci: Check for errors from dm_pci_map_bar()
Pali Rohár [Mon, 18 Jan 2021 11:30:04 +0000 (12:30 +0100)]
usb: xhci-pci: Check for errors from dm_pci_map_bar()

Function dm_pci_map_bar() may fail and returns NULL. Check this to prevent
dereferencing a NULL pointer.

In xhci-pci this may happen when board does not enable CONFIG_PCI_PNP and
PCI_BASE_ADDRESS_0 contains unconfigured zero address.

Signed-off-by: Pali Rohár <pali@kernel.org>
3 years agodt-bindings: usb: mtk-xhci: add optional properies to disable ports
Chunfeng Yun [Wed, 23 Dec 2020 01:52:21 +0000 (09:52 +0800)]
dt-bindings: usb: mtk-xhci: add optional properies to disable ports

Add optional properies to disable usb2 or usb3 ports, they are used
when provided ports are not used on some special platforms.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
3 years agousb: xhci-mtk: support option to disable ports
Chunfeng Yun [Wed, 23 Dec 2020 01:52:20 +0000 (09:52 +0800)]
usb: xhci-mtk: support option to disable ports

Add support to disable specific ports, it's useful for some
scenarios:
1. usb3 PHY is shared whith PCIe or SATA, the corresponding
   usb3 port can be disabled;
2. some usb2 or usb3 ports are not used on special platforms,
   they should be disabled to save power.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
3 years agoMerge tag 'u-boot-amlogic-20210210' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Wed, 10 Feb 2021 12:56:57 +0000 (07:56 -0500)]
Merge tag 'u-boot-amlogic-20210210' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic

- Add configuration helpers for MIPI D-PHY
- generic-phy: add configure op
- Add Amlogic AXG MIPI D-PHY driver & MIPI PCIe Analog PHY driver
- odroid: add runtime detection of the N2/N2+/C4/HC4 variants

3 years agoboard: amlogic: odroid: add runtime detection of the N2/N2+/C4/HC4 variants
Marek Szyprowski [Thu, 4 Feb 2021 09:11:45 +0000 (10:11 +0100)]
board: amlogic: odroid: add runtime detection of the N2/N2+/C4/HC4 variants

Use the ADC channel 1 to check the hardware revision of the board and
detect the N2 vs. N2+ and the C4 vs. HC4 variants. Each of them use
different dtb file, so adjust fdtfile environment variable to the
detected variant.

The ADC min/max values for each variant are taken from the vendor code,
adjusted to the 12-bit ADC driver operation mode (vendor code use 10-bit
mode).

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agophy: Add Amlogic AXG MIPI PCIe Analog PHY driver
Neil Armstrong [Tue, 29 Dec 2020 13:59:01 +0000 (14:59 +0100)]
phy: Add Amlogic AXG MIPI PCIe Analog PHY driver

The Amlogic AXG MIPI + PCIe Analog PHY provides function for both PCIe and
MIPI DSI at the same time, and provides the Analog part of MIPI DSI transmission
and Analog part of the PCIe lines.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agophy: Add Amlogic AXG MIPI D-PHY driver
Neil Armstrong [Tue, 29 Dec 2020 13:59:00 +0000 (14:59 +0100)]
phy: Add Amlogic AXG MIPI D-PHY driver

The Amlogic AXG SoCs embeds a MIPI D-PHY used to communicate with DSI
panels.

This D-PHY depends on a separate analog PHY.

Signed-off-by:Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agogeneric-phy: add configure op
Neil Armstrong [Tue, 29 Dec 2020 13:58:59 +0000 (14:58 +0100)]
generic-phy: add configure op

Add the PHY configure op callback to the generic PHY uclass to permit
configuring the PHY.

It's useful for MIPI DSI PHYs to setup the link timings.

Signed-off-by:Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agophy: dphy: Add configuration helpers
Neil Armstrong [Tue, 29 Dec 2020 13:58:58 +0000 (14:58 +0100)]
phy: dphy: Add configuration helpers

The MIPI D-PHY spec defines default values and boundaries for most of the
parameters it defines. Introduce helpers to help drivers get meaningful
values based on their current parameters, and validate the boundaries of
these parameters if needed.

These helpers and header are taken from Linux commit 9123e3a74ec7 ("Linux 5.9-rc1").

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
3 years agoMerge tag 'u-boot-stm32-20210209' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
Tom Rini [Tue, 9 Feb 2021 22:06:44 +0000 (17:06 -0500)]
Merge tag 'u-boot-stm32-20210209' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm

- Enable the fastboot oem commands in stm32mp15 defconfig
- Fixes pinctrol for stmfx and stm32
- Add support of I2C6_K in stm32mp15 clock driver
- Alignment with Linux kernel device tree v5.11-rc2 for ST boards

3 years agoarm: dts: stm32mp15: alignment with v5.11-rc2
Patrick Delaunay [Mon, 11 Jan 2021 11:33:36 +0000 (12:33 +0100)]
arm: dts: stm32mp15: alignment with v5.11-rc2

Device tree alignment with Linux kernel v5.11-rc2
- fix DCMI DMA features on stm32mp15 family
- Add alternate pinmux for FMC EBI bus
- Harmonize EHCI/OHCI DT nodes name on stm32mp15
- update sdmmc IP version for STM32MP15
- Add LP timer irqs on stm32mp151
- Add LP timer wakeup-source on stm32mp151
- enable HASH by default on stm32mp15
- enable CRC1 by default on stm32mp15
- enable CRYP by default on stm32mp15
- set bus-type in DCMI endpoint for stm32mp157c-ev1 board
- reorder spi4 within stm32mp15-pinctrl
- add STUSB1600 Type-C using I2C4 on stm32mp15xx-dkx
- fix mdma1 clients channel priority level on stm32mp151
- fix dmamux reg property on stm32mp151
- adjust USB OTG gadget fifo sizes in stm32mp151
- update stm32mp151 for remote proc synchronization support
- support child mfd cells for the stm32mp1 TAMP syscon

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoARM: dts: stm32: Fix cosmetic typo: use 'kHz' as kilohertz abbreviation
Fabrice GIRARDOT [Fri, 15 Jan 2021 12:55:01 +0000 (13:55 +0100)]
ARM: dts: stm32: Fix cosmetic typo: use 'kHz' as kilohertz abbreviation

The kilohertz unit abbreviation should read 'kHz'.
Note to STM32 team: modified files were generated, it may be worth
to fix STM32CubeMX tool.

Signed-off-by: Fabrice GIRARDOT <fabrice.girardot@flowbird.group>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoclk: stm32mp1: add support of I2C6_K
Patrick Delaunay [Fri, 22 Jan 2021 14:34:25 +0000 (15:34 +0100)]
clk: stm32mp1: add support of I2C6_K

Add support of missing I2C6_K with bit 3 of RCC_MC_APB5ENSETR =
I2C6EN: I2C6 peripheral clocks enable.

This patch allows customer to use I2C6 in SPL or in U-Boot
as other I2C instance, already support in clk driver.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
3 years agopinctrl: stm32: bind only the enabled GPIO subnode
Patrick Delaunay [Thu, 21 Jan 2021 16:39:08 +0000 (17:39 +0100)]
pinctrl: stm32: bind only the enabled GPIO subnode

Bind only the enabled GPIO subnode, to avoid to probe the node
"gpio-controller" present in SOC dtsi (disabled by default) but
not enabled in the included pincontrol dtsi file.

For example, in stm32mp15xxac-pinctrl.dtsi 2 gpio bank are absent:
 gpioj: gpio@5000b000
 gpiok: gpio@5000c000

Then these GPIO are absent in output of command "dm tree" and
"gpio status -a"

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
3 years agopinctrl: stm32: correct management pin display of OTYPE
Patrick Delaunay [Thu, 21 Jan 2021 16:39:07 +0000 (17:39 +0100)]
pinctrl: stm32: correct management pin display of OTYPE

OTYPE can be used for output or for alternate function to select
PP = push-pull or OP = open-drain mode, according reference manual
(Table 81. Port bit configuration table).

This patch removes this indication for input pins and adds it
for AF and output pins for pinmux command output.

Fixes: b305dbc08b08 ("pinctrl: stm32: display bias information for all pins")

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
3 years agopinctrl: stmfx: Use PINNAME_SIZE for pin's name size
Patrice Chotard [Wed, 20 Jan 2021 12:43:40 +0000 (13:43 +0100)]
pinctrl: stmfx: Use PINNAME_SIZE for pin's name size

Instead of redefining a pin's name size, use PINNAME_SIZE defined
in include/dm/pinctrl.h

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agopinctrl: stmfx: Fix pin configuration issue
Patrice Chotard [Wed, 20 Jan 2021 12:43:39 +0000 (13:43 +0100)]
pinctrl: stmfx: Fix pin configuration issue

pin-controller pin's name must be equal to pin's name used in device
tree with "pins" DT property.

Issue detected on stm32mp157c-ev1 board with goodix touchscreen.
In DT, the goodix's pin is declared in DT with the node:

        goodix_pins: goodix {
pins = "gpio14";
bias-pull-down;
};

Whereas in stmfx pin-controller driver, pin's name are equal to
"stmfx_gpioxx" where xx is the pin number.
This lead to not configure stmfx's pins at probe because pins is
identified by its name (see pinctrl_pin_name_to_selector() in
pinctrl-generic.c) and stmfx pin "gpio14" can't be found.

To fix this issue, come back to the original stmfx pin's name.

Revert "pinctrl: stmfx: update pin name"

This reverts commit 38d30cdcd65c73eeefac5efa328ad444a53b77dd.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrick DELAUNAY <patrick.delaunay@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoconfigs: stm32mp1: enable the fastboot oem command bootbus
Patrick Delaunay [Wed, 9 Sep 2020 13:24:35 +0000 (15:24 +0200)]
configs: stm32mp1: enable the fastboot oem command bootbus

Enable the fastboot oem command bootbus, used to configure the eMMC
boot behavior, with same format than 'mmc bootbus'
and with parameter: boot_bus_width reset_boot_bus_width boot_mode

On stm32mp1 boards the expected command is
$> fastboot oem partconf:0 0 0

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agoconfigs: stm32mp1: enable the fastboot oem command partconf
Patrick Delaunay [Wed, 9 Sep 2020 13:24:34 +0000 (15:24 +0200)]
configs: stm32mp1: enable the fastboot oem command partconf

Enable the fastboot oem command partconf, used to select the correct
eMMC boot partition, with same format than 'mmc partconf'
with parameter: boot_ack boot_partition
On stm32mp1 family:
- boot_ack = 1 (Boot Acknowledge is needed by ROM code)
- boot_partition = 1 or 2 (Boot partition 1 / 2 enabled for boot)

So on EV1 board the expected commands to select boot partition 1 or 2
$> fastboot oem partconf:1 1
$> fastboot oem partconf:1 2

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agoconfigs: stm32mp1: enable the fastboot oem command format
Jean-Philippe ROMAIN [Wed, 9 Sep 2020 13:24:33 +0000 (15:24 +0200)]
configs: stm32mp1: enable the fastboot oem command format

Enable the fastboot oem command format and set the variable
"partitions" with default eMMC partitions list.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Jean-Philippe ROMAIN <jean-philippe.romain@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agoconfigs: stm32mp1: enable fastboot support of eMMC boot partition
Jean-Philippe ROMAIN [Wed, 9 Sep 2020 13:24:32 +0000 (15:24 +0200)]
configs: stm32mp1: enable fastboot support of eMMC boot partition

Activate fastboot support on boot partition for eMMC, mmc1 device
on STMicroelectronics board (EV1).

Signed-off-by: Jean-Philippe ROMAIN <jean-philippe.romain@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
3 years agoMerge git://git.denx.de/u-boot-marvell
Tom Rini [Mon, 8 Feb 2021 15:55:51 +0000 (10:55 -0500)]
Merge git://git.denx.de/u-boot-marvell

- Espressobin: Set default env values at runtime (Pali)
- Espressobin: Set the maximum slave SPI speed to 40MHz (Pali)
- theadorable: PCIe test code enhancement and early deemphasis
  enabling (Stefan)
- pci_mvebu: Disable config access to PCI host bridge ports (Stefan)
- mv_sdhci: parse device-tree entry (Baruch)