platform/kernel/u-boot.git
2 years agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Tue, 5 Apr 2022 12:33:32 +0000 (08:33 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi

A big part is the DM pinctrl driver, which allows us to get rid of quite
some custom pinmux code and make the whole port much more robust. Many
thanks to Samuel for that nice contribution! There are some more or less
cosmetic warnings about missing clocks right now, I will send the trivial
fixes for that later.
Another big chunk is the mkimage upgrade, which adds RISC-V and TOC0
(secure images) support. Both features are unused at the moment, but I
have an always-secure board that will use that once the DT lands in the
kernel.
On top of those big things we have some smaller fixes, improving the
I2C DM support, fixing some H6/H616 early clock setup and improving the
eMMC boot partition support.

The gitlab CI completed successfully, including the build test for all
161 sunxi boards. I also boot tested on a A64, A20, H3, H6, and F1C100
board. USB, SD card, eMMC, and Ethernet all work there (where applicable).

2 years agosunxi: defconfig: enable eMMC boot partition support
Andre Przywara [Mon, 12 Jul 2021 10:06:51 +0000 (11:06 +0100)]
sunxi: defconfig: enable eMMC boot partition support

Now that the SPL can safely detect whether it was loaded from an eMMC
boot partition or the normal user data partition, let's enable this
feature on some boards that feature eMMC storage.

That covers the boards where I could test this on, and allows the same
build to be written to an SD card, eMMC user partition, eMMC boot
partition, or into SPI NOR flash.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: eMMC: Improve automatic boot source detection
Andre Przywara [Mon, 12 Jul 2021 10:06:50 +0000 (11:06 +0100)]
sunxi: eMMC: Improve automatic boot source detection

When the Allwinner BROM loads the SPL from an eMMC boot partition, it
sets the boot source byte to the same value as when booting from the
user data partition. This prevents us from determining the boot source
to load U-Boot proper from the proper partition for sure.

The generic SPL MMC code already looks at the enabled boot partition
number, to load U-Boot proper from the same partition, but this fails
if there is nothing bootable in this partition, as the BROM then
silently falls back to the user data partition, which the SPL misses.

To learn about the actual boot source anyway, we repeat the algorithm
the BROM used to select the boot partition in the first place:
- Test EXT_CSD[179] to check if an eMMC boot partition is enabled.
- Test EXT_CSD[177] to check for valid MMC interface settings.
- Check if BOOT_ACK is enabled.
- Check the beginning of the first sector for a valid eGON signature.
- Load the whole SPL.
- Recalculate the checksum to verify the SPL is valid.

If one of those steps fails, we bail out and continue loading from the
user data partition. Otherwise we load from the selected boot partition.

Since the boot source is needed twice in the boot process, we cache the
result of this test to avoid doing this costly test multiple times.

This allows the very same image file to be put onto an SD card, into the
eMMC user data partition or into the eMMC boot partition, and safely
loads the whole of U-Boot from there.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agospl: mmc: extend spl_mmc_boot_mode() to take mmc argument
Andre Przywara [Mon, 12 Jul 2021 10:06:49 +0000 (11:06 +0100)]
spl: mmc: extend spl_mmc_boot_mode() to take mmc argument

Platforms can overwrite the weak definition of spl_mmc_boot_mode() to
determine where to load U-Boot proper from.
For most of them this is a trivial decision based on Kconfig variables,
but it might be desirable the probe the actual device to answer this
question.

Pass the pointer to the mmc struct to that function, so implementations
can make use of that.

Compile-tested for all users changed.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
Reviewed-by: Ley Foon Tan <ley.foon.tan@inte.com> (for SoCFPGA)
Acked-by: Lokesh Vutla <lokeshvutla@ti.com> (for OMAP and K3)
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agosunxi: clock: H6: Adjust PLL LDO before clock setup
Jernej Skrabec [Sun, 30 Jan 2022 14:27:15 +0000 (15:27 +0100)]
sunxi: clock: H6: Adjust PLL LDO before clock setup

BSP boot0 adjust PLL LDO regulator before clocks are initialized.
Let's do that.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: clock: H6/H616: Add resistor calibration
Jernej Skrabec [Sun, 30 Jan 2022 14:27:14 +0000 (15:27 +0100)]
sunxi: clock: H6/H616: Add resistor calibration

BSP boot0 executes resistor calibration before clocks are initialized.
Let's do that.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: prcm: Add a few registers
Jernej Skrabec [Sun, 30 Jan 2022 14:27:13 +0000 (15:27 +0100)]
sunxi: prcm: Add a few registers

H6 and H616 SPL code has a few writes to unknown PRCM registers. Now
that we know what they are, let's replace magic offsets with proper
register names.

Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: H3: fix non working console on uart2
Angelo Dureghello [Sat, 9 Oct 2021 12:18:59 +0000 (14:18 +0200)]
sunxi: H3: fix non working console on uart2

Fix non working console on uart2, that seems releated to both
Allwinner H2+ and H3.

Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com>
[Andre: remove H2+, rearrange pin setup order]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoAdd ethernet0 alias in Nanopi NEO's device tree
Baltazár Radics [Sat, 26 Mar 2022 12:09:10 +0000 (13:09 +0100)]
Add ethernet0 alias in Nanopi NEO's device tree

This syncs the sun8i-h3-nanopi-neo.dts from the Linux tree, from tag
v5.18-rc1.
The alias is required to enable automatic MAC address generation.

Signed-off-by: Baltazár Radics <baltazar.radics@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoi2c: sun8i_rsb: Add support for DM clocks and resets
Samuel Holland [Fri, 18 Mar 2022 04:52:36 +0000 (23:52 -0500)]
i2c: sun8i_rsb: Add support for DM clocks and resets

Currently, clock/reset setup for this device is handled by a
platform-specific function and is intermixed with non-DM pinctrl
setup. Use the devicetree to get clocks/resets, which disentagles
it from the pinctrl setup in preparation for moving to DM_PINCTRL.

This also has the added benefit of picking the right clock/reset
bits for H6 and new SoCs that have a rearranged PRCM MMIO space.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoi2c: sun8i_rsb: Initialize chips in .child_pre_probe
Samuel Holland [Fri, 18 Mar 2022 04:52:35 +0000 (23:52 -0500)]
i2c: sun8i_rsb: Initialize chips in .child_pre_probe

Chips attached to the RSB bus require an initialization command before
they can be used. (Specifically, this command programs the chip's
runtime address.) The driver does this in its .probe_chip hook, under
the assumption that .probe_chip is called during child probe. This is
not the case; .probe_chip is only called by dm_i2c_probe, which is
intended for use by board-level code, not for chips with OF nodes.

Since this initialization command must be run before a child chip can be
used, do it before probing each child.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoi2c: sun6i_p2wi: Add support for DM clocks and resets
Samuel Holland [Fri, 18 Mar 2022 04:52:34 +0000 (23:52 -0500)]
i2c: sun6i_p2wi: Add support for DM clocks and resets

Currently, clock/reset setup for this device is handled by a
platform-specific function and is intermixed with non-DM pinctrl
setup. Use the devicetree to get clocks/resets, which disentagles
it from the pinctrl setup in preparation for moving to DM_PINCTRL.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoi2c: sun6i_p2wi: Initialize chips in .child_pre_probe
Samuel Holland [Fri, 18 Mar 2022 04:52:33 +0000 (23:52 -0500)]
i2c: sun6i_p2wi: Initialize chips in .child_pre_probe

Chips attached to the P2WI bus require an initialization command before
they can be used. (Specifically, this switches the chip from I2C mode
to P2WI mode.) The driver does this in its .probe_chip hook, under the
assumption that .probe_chip is called during child probe. This is not
the case; .probe_chip is only called by dm_i2c_probe, which is intended
for use by board-level code, not for chips with OF nodes.

Since this initialization command must be run before a child chip can be
used, do it before probing each child.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Support building a SPL as a TOC0 image
Samuel Holland [Fri, 18 Mar 2022 05:00:45 +0000 (00:00 -0500)]
sunxi: Support building a SPL as a TOC0 image

Now that mkimage can generate TOC0 images, and the SPL can interpret
them, hook up the build infrastructure so the user can choose which
image type to build. Since the absolute load address is stored in the
TOC0 header, that information must be passed to mkimage.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Support SPL in both eGON and TOC0 images
Samuel Holland [Fri, 18 Mar 2022 05:00:44 +0000 (00:00 -0500)]
sunxi: Support SPL in both eGON and TOC0 images

SPL uses the image header to detect the boot device and to find the
offset of the next U-Boot stage. Since this information is stored
differently in the eGON and TOC0 image headers, add code to find the
correct value based on the image type currently in use.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agotools: mkimage: Add Allwinner TOC0 support
Samuel Holland [Fri, 18 Mar 2022 05:00:43 +0000 (00:00 -0500)]
tools: mkimage: Add Allwinner TOC0 support

Most Allwinner sunxi SoCs have separate boot ROMs in non-secure and
secure mode. The "non-secure" or "normal" boot ROM (NBROM) uses the
existing sunxi_egon image type. The secure boot ROM (SBROM) uses a
completely different image type, known as TOC0.

A TOC0 image is composed of a header and two or more items. One item
is the firmware binary. The others form a chain linking the firmware
signature to the root-of-trust public key (ROTPK), which has its hash
burned in the SoC's eFuses. Signatures are made using RSA-2048 + SHA256.

The pseudo-ASN.1 structure is manually assembled; this is done to work
around bugs/quirks in the boot ROM, which vary between SoCs. This TOC0
implementation has been verified to work with the A50, A64, H5, H6,
and H616 SBROMs, and it may work with other SoCs.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: specify architecture when generating SPL boot image
Icenowy Zheng [Fri, 15 Oct 2021 01:53:07 +0000 (20:53 -0500)]
sunxi: specify architecture when generating SPL boot image

As mkimage -T sunxi_egon now gains support for -A parameter, specify the
architecture when generating SPL boot image for sunxi.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agomkimage: sunxi_egon: add support for riscv
Icenowy Zheng [Fri, 15 Oct 2021 01:53:06 +0000 (20:53 -0500)]
mkimage: sunxi_egon: add support for riscv

There's now a sun20i family in sunxi, which uses RISC-V CPU.

Add support for making eGON.BT0 image for RISC-V.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agomkimage: sunxi_egon: refactor for multi-architecture support
Icenowy Zheng [Fri, 15 Oct 2021 01:53:05 +0000 (20:53 -0500)]
mkimage: sunxi_egon: refactor for multi-architecture support

Refactor some functions in mkimage sunxi_egon type, in order to prepare
for adding support for more CPU architectures (e.g. RISC-V). In
addition, compatibility for operation w/o specified architecture is
kept, in this case the architecture is assumed as ARM.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agomkimage: add a flag to describe whether -A is specified
Icenowy Zheng [Fri, 15 Oct 2021 01:53:04 +0000 (20:53 -0500)]
mkimage: add a flag to describe whether -A is specified

The sunxi_egon type used to take no -A argument (because we assume sunxi
targets are all ARM). However, as Allwinner D1 appears as the first
RISC-V sunxi target, we need to support -A; in addition, as external
projects rely on U-Boot mkimage to generate sunxi eGON.BT0 header, we
need to keep compatibility with command line without -A.

As the default value of arch in mkimage is not proper (IH_ARCH_PPC
instead of IH_ARCH_INVALID), to keep more compatibility, add an Aflag
field to image parameters to describe whether an architecture is
explicitly specified.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agospi: sun4i_spi: Remove non-DM pin setup
Samuel Holland [Sat, 28 Aug 2021 16:50:28 +0000 (11:50 -0500)]
spi: sun4i_spi: Remove non-DM pin setup

This is now handled automatically by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add SPI0 pinmuxes
Samuel Holland [Sat, 28 Aug 2021 22:05:35 +0000 (17:05 -0500)]
pinctrl: sunxi: Add SPI0 pinmuxes

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopwm: sunxi: Remove non-DM pin setup
Samuel Holland [Sat, 28 Aug 2021 16:50:51 +0000 (11:50 -0500)]
pwm: sunxi: Remove non-DM pin setup

This is now handled automatically by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add the A64 PWM pinmux
Samuel Holland [Sat, 28 Aug 2021 20:52:52 +0000 (15:52 -0500)]
pinctrl: sunxi: Add the A64 PWM pinmux

This is the only possible mux setting for the A64's PWM peripheral.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Remove non-DM MMC pin setup
Samuel Holland [Sat, 28 Aug 2021 16:49:03 +0000 (11:49 -0500)]
sunxi: Remove non-DM MMC pin setup

This is now handled automatically by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add MMC pinmuxes
Samuel Holland [Sat, 28 Aug 2021 21:51:03 +0000 (16:51 -0500)]
pinctrl: sunxi: Add MMC pinmuxes

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoi2c: sun8i_rsb: Only do non-DM pin setup for non-DM I2C
Samuel Holland [Thu, 21 Oct 2021 04:01:29 +0000 (23:01 -0500)]
i2c: sun8i_rsb: Only do non-DM pin setup for non-DM I2C

When the DM_I2C driver is loaded, the pin setup is done automatically
from the device tree by the pinctrl driver.

Clean up the code in the process: remove #ifdefs and recognize that the
pin configuration is the same for all sun8i/sun50i SoCs, not just those
which select CONFIG_MACH_SUN8I.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoi2c: sun6i_p2wi: Only do non-DM pin setup for non-DM I2C
Samuel Holland [Thu, 21 Oct 2021 04:01:29 +0000 (23:01 -0500)]
i2c: sun6i_p2wi: Only do non-DM pin setup for non-DM I2C

When the DM_I2C driver is loaded, the pin setup is done automatically
from the device tree by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Remove options and setup code for I2C2-I2C4
Samuel Holland [Thu, 21 Oct 2021 03:55:06 +0000 (22:55 -0500)]
sunxi: Remove options and setup code for I2C2-I2C4

These options are not currently enabled anywhere. Any new users should
use DM clocks and pinctrl.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add I2C pinmuxes
Samuel Holland [Sat, 28 Aug 2021 20:17:32 +0000 (15:17 -0500)]
pinctrl: sunxi: Add I2C pinmuxes

Where multiple options were available, the one matching board.c and the
device trees was chosen.

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
[Andre: fixup H5 I2C1 pinmux]
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agonet: sun8i_emac: Remove non-DM pin setup
Samuel Holland [Sat, 28 Aug 2021 16:49:40 +0000 (11:49 -0500)]
net: sun8i_emac: Remove non-DM pin setup

This is now handled automatically by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add sun8i EMAC pinmuxes
Samuel Holland [Sat, 28 Aug 2021 18:34:29 +0000 (13:34 -0500)]
pinctrl: sunxi: Add sun8i EMAC pinmuxes

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Remove non-DM GMAC pin setup
Samuel Holland [Sat, 28 Aug 2021 18:16:44 +0000 (13:16 -0500)]
sunxi: Remove non-DM GMAC pin setup

This is now handled automatically by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add sunxi GMAC pinmuxes
Samuel Holland [Sat, 28 Aug 2021 18:13:52 +0000 (13:13 -0500)]
pinctrl: sunxi: Add sunxi GMAC pinmuxes

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agonet: sunxi_emac: Remove non-DM pin setup
Samuel Holland [Sat, 28 Aug 2021 18:22:41 +0000 (13:22 -0500)]
net: sunxi_emac: Remove non-DM pin setup

This is now handled automatically by the pinctrl driver.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add sun4i EMAC pinmuxes
Samuel Holland [Sat, 28 Aug 2021 18:21:36 +0000 (13:21 -0500)]
pinctrl: sunxi: Add sun4i EMAC pinmuxes

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agopinctrl: sunxi: Add UART pinmuxes
Samuel Holland [Sat, 28 Aug 2021 18:00:45 +0000 (13:00 -0500)]
pinctrl: sunxi: Add UART pinmuxes

This includes UART0 and R_UART (s_uart) on all supported platforms, plus
the additional UART configurations from arch/arm/mach-sunxi/board.c.

Pin lists and mux values were taken from the Linux drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: pinctrl: Implement pin configuration
Samuel Holland [Sun, 29 Aug 2021 02:10:47 +0000 (21:10 -0500)]
sunxi: pinctrl: Implement pin configuration

The sunxi pinctrl hardware has bias and drive control. Add driver
support for configuring those options.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: pinctrl: Implement get_pin_muxing function
Samuel Holland [Tue, 17 Aug 2021 05:52:00 +0000 (00:52 -0500)]
sunxi: pinctrl: Implement get_pin_muxing function

The pinmux command uses this function to display pinmux status.

Since the driver cannot map pin numbers to a list of supported
functions, only functions which are common across all pins can be
reported by name.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: pinctrl: Implement pin muxing functions
Samuel Holland [Tue, 17 Aug 2021 04:56:47 +0000 (23:56 -0500)]
sunxi: pinctrl: Implement pin muxing functions

Implement the operations to get pin and function names, and to set the
mux for a pin. The pin count and pin names are calculated as if each
bank has the maximum number of pins. Function names are simply the index
into a list of { function name, mux value } pairs.

We assume all pins associated with a function use the same mux value for
that function. This is generally true within a group of pins on a single
port, but generally false when some peripheral can be muxed to multiple
ports. For example, A64 UART3 uses mux 3 on port D, and mux 2 on port H.
But all of the port D pins use the same mux value, and so do all of the
port H pins. This applies even when the pins for some function are not
contiguous, and when the lower-numbered mux values are unused. A good
example of both of these cases is SPI0 on most SoCs.

This strategy saves a lot of space (which is especially important for
SPL), but where the mux value for a certain function differs across
ports, it forces us to choose a single port for that function at build
time. Since almost all boards use the default (i.e. reference design)
pin muxes[1], this is unlikely to be a problem.

[1]: See commit dda9fa734f81 ("sunxi: Simplify MMC pinmux selection")

Signed-off-by: Samuel Holland <samuel@sholland.org>
[Andre: add comment summarising the commit message]
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: pinctrl: Create the driver skeleton
Samuel Holland [Fri, 13 Aug 2021 01:09:43 +0000 (20:09 -0500)]
sunxi: pinctrl: Create the driver skeleton

Create a do-nothing driver for each sunxi pin controller variant.

Since only one driver can automatically bind to a DT node, since the
GPIO driver already requires a manual binding process, and since the
pinctrl driver needs access to some of the same information, refactor
the GPIO driver to be bound by the pinctrl driver. This commit should
cause no functional change.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoMerge branch 'next'
Tom Rini [Mon, 4 Apr 2022 14:45:33 +0000 (10:45 -0400)]
Merge branch 'next'

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoPrepare v2022.04
Tom Rini [Mon, 4 Apr 2022 14:31:32 +0000 (10:31 -0400)]
Prepare v2022.04

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMerge tag 'u-boot-at91-2022.07-a' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Mon, 4 Apr 2022 12:26:55 +0000 (08:26 -0400)]
Merge tag 'u-boot-at91-2022.07-a' of https://source.denx.de/u-boot/custodians/u-boot-at91 into next

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

This feature set includes the new driver for the Atmel TCB timer,
alignment in DT for sama7g5 and sama7g5ek board, one Kconfig conversion
for external reset, and the usage of Galois tables from ROM for sama5d2
device.

2 years agoenv: do not fail on non-existing env.in file
Andrey Zhizhikin [Sun, 3 Apr 2022 14:06:03 +0000 (16:06 +0200)]
env: do not fail on non-existing env.in file

If include/generated/env.in does not exist, which is a typical case for
clean build, quiet_cmd_gen_envp command tries to delete this file
unconditionally.

This produces following warning during the build:
  ENVP    include/generated/env.in
rm: cannot remove 'include/generated/env.in': No such file or directory

Add '-f' option to the `rm` command to not complain if file does not
exist.

Fixes: f432eb6d8a9d ("env: Avoid using a leftover text-environment file")
Reviewed-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
2 years agoRevert "global: Remove CONFIG_SYS_EXTRA_OPTIONS support"
Tom Rini [Sat, 2 Apr 2022 22:18:57 +0000 (18:18 -0400)]
Revert "global: Remove CONFIG_SYS_EXTRA_OPTIONS support"

Unfortunately, we require additional logic to buildman to support this
removal and still use SYS_SOC, etc, for build targets.

This reverts commit eeec00072d7a0b5b91896d014618e558ce438738.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMerge branch '2022-04-01-arm-semihosting-cleanups-and-new-features' into next
Tom Rini [Sat, 2 Apr 2022 19:28:43 +0000 (15:28 -0400)]
Merge branch '2022-04-01-arm-semihosting-cleanups-and-new-features' into next

This brings in two related series.  The first from Andre:

This series is the continuation of last year's effort to support the new
Armv8-R64 application profile. This led to a significant rework of the
existing fastmodel (FVP) support, to both upgrade it to newest U-Boot
standards (OF_CONTROL and distro_boot support), but also to generalise
the code, so that plugging in the v8-R64 support in the last patch gets
much easier. This is because apart from the twisted memory map between
the two profiles there is actually little difference, when it comes to
U-Boot relevant parts of the hardware.

I kept the legacy semihosting support (which picks up magic files from
the current directory), but if that fails, we go and try virtio-blk
(.iso installer images work), then virtio-net.

Please have a look, and give it a try, if possible. Both the v8-R and
v8-A FVP models are available for free on the Arm website[1].

Patch 01/11 fixes a regression introduced in December, it should be
applied now. The rest of the patches are for the next merge window.

[1]
https://developer.arm.com/tools-and-software/simulation-models/fast-models

And the second from Sean (where we exclude 27, 28 and 29 for now):
This cleans up the semihosting code and adds the following new features:

- hostfs support (like sandbox)
- support for being used as a SPL boot device
- serial device support
- falling back to normal drivers if semihosting is disabled

The main device affected by these changes is vexpress64, so I'd
appreciate
if Andre (or anyone else) could try booting.

These changes are motivated by bringup for ls1046a. When forcing JTAG
boot, this device disables most communication peripherals, including
serial and ethernet devices. This appears to be fixed in later
generation devices, but we are stuck with it for now. Semihosting
provides an easy way to run a few console commands.

The patches in this series are organized as follows:

0-4: rST conversions and other documentation updates
5-9: Semihosting cleanups
10-14: Filesystem support (including SPL boot device)
15-16: Serial support
16: Documentation update
17: JTAG boot support for LS1046A
19-25: Semihosting fallback
26-29: DM puts support

The last two groups of patches are "bonus;" the first 17 patches stand
on their own. The last two groups could be broken out as separate
series, but I have kept them in this one to help with my sanity (and not
have to deal with too many outstanding series).

Patch 14 depends on [1] to apply cleanly. Patch 17 depends on [2] for
correctness. This series should be applied to u-boot/next (in
particular, the EROFS series must have been applied).

[1]
https://lore.kernel.org/u-boot/CACRpkdZ+9fmNjC_mvrbPa9-iuTQVd8UkJ7Zpe7cL0c5vZygsVw@mail.gmail.com/T/
[2]
https://lore.kernel.org/u-boot/20220222183840.1355337-2-sean.anderson@seco.com/

2 years agoserial: dm: Add support for puts
Sean Anderson [Tue, 22 Mar 2022 20:59:34 +0000 (16:59 -0400)]
serial: dm: Add support for puts

Some serial drivers can be vastly more efficient when printing multiple
characters at once. Non-DM serial has had a puts option for these sorts
of drivers; implement it for DM serial as well.

Because we have to add carriage returns, we can't just pass the whole
string directly to the serial driver. Instead, we print up to the
newline, then print a carriage return, and then continue on. This is
less efficient, but it is better than printing each character
individually. It also avoids having to allocate memory just to add a few
characters.

Drivers may perform short writes (such as filling a FIFO) and return the
number of characters written in len. We loop over them in the same way
that _serial_putc loops over putc.

This results in around sizeof(void *) growth for all boards with
DM_SERIAL. The full implementation takes around 140 bytes.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agoarm64: ls1046a: Support semihosting fallback
Sean Anderson [Tue, 22 Mar 2022 20:59:33 +0000 (16:59 -0400)]
arm64: ls1046a: Support semihosting fallback

Use the semihosting_enabled function to determine whether or not to
enable semihosting devices. This allows for graceful fallback in the
event a debugger is not attached.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoserial: smh: Initialize serial only if semihosting is enabled
Sean Anderson [Tue, 22 Mar 2022 20:59:32 +0000 (16:59 -0400)]
serial: smh: Initialize serial only if semihosting is enabled

If semihosting is disabled, then the user has no debugger attached, and
will not see any messages. Don't create a serial device in this
instance, to (hopefully) fall back on another working serial device.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm64: Catch non-emulated semihosting calls
Sean Anderson [Tue, 22 Mar 2022 20:59:31 +0000 (16:59 -0400)]
arm64: Catch non-emulated semihosting calls

If a debugger is not attached to U-Boot, semihosting calls will raise a
synchronous abort exception. Try to catch this and disable semihosting
so we can e.g. use another uart if one is available. In the immediate
case, we return an error, since it is not always possible to check for
semihosting beforehand (debug uart, user-initiated load command, etc.)

We handle all possible semihosting instructions, which is probably
overkill. However, we do need to keep track of what instruction set
we're using so that we don't suppress an actual error.

A future enhancement could try to determine semihosting capability by
inspecting the processor state.  There's an example of this at [1] for
RISC-V. The equivalent for ARM would inspect the monitor modei
enable/select bits of the DSCR. However, as the article notes, an
exception handler is still helpful in order to catch disconnected
debuggers.

[1] https://tomverbeure.github.io/2021/12/30/Semihosting-on-RISCV.html#avoiding-hangs-when-a-debugger-is-not-connected

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Add option to detect semihosting
Sean Anderson [Tue, 22 Mar 2022 20:59:30 +0000 (16:59 -0400)]
arm: smh: Add option to detect semihosting

These functions are intended to support detecting semihosting and
falling back gracefully to alternative implementations. The test starts
by making semihosting call. SYS_ERRNO is chosen because it should not
mutate any state. If this semihosting call results in an exception
(rather than being caught by the debugger), then the exception handler
should call disable_semihosting() and resume execution after the call.

Ideally, this would just be part of semihosting by default, and not a
separate config. However, to reduce space ARM SPL doesn't include
exception vectors by default. This means we can't detect if a
semihosting call failed unless we enable them. To avoid forcing them to
be enabled, we use a separate config option. It might also be possible
to try and detect whether a debugger has enabled (by reading HDE from
DSCR), but I wasn't able to figure out a way to do this from all ELs.

This patch just introduces the generic code to handle detection. The
next patch will implement it for arm64 (but not arm32).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm64: Import some ESR and SPSR defines from Linux
Sean Anderson [Tue, 22 Mar 2022 21:18:37 +0000 (17:18 -0400)]
arm64: Import some ESR and SPSR defines from Linux

This imports some defines for esr and spsr from Linux v5.16. I have
modified the includes and fixed some indentation nits but otherwise it
is the same. There are a lot more defines than we need, but it doesn't
hurt.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm64: Save spsr in pt_regs
Sean Anderson [Tue, 22 Mar 2022 20:59:28 +0000 (16:59 -0400)]
arm64: Save spsr in pt_regs

This register holds "pstate" which includes (among other things) the
instruction mode the CPU was in when the exception was taken. This is
necessary to correctly interpret instructions at elr.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm64: Save esr in pt_regs
Sean Anderson [Tue, 22 Mar 2022 21:17:35 +0000 (17:17 -0400)]
arm64: Save esr in pt_regs

To avoid passing around an extra register everywhere, save esr in
pt_regs like the rest. For proper alignment we need to have a second
(unused) register. All the printfs have to be adjusted, since
it's now an unsigned long and not an int.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agols1046ardb: Add support for JTAG boot
Sean Anderson [Tue, 22 Mar 2022 21:16:05 +0000 (17:16 -0400)]
ls1046ardb: Add support for JTAG boot

This adds support for booting entirely from JTAG while using a
hard-coded RCW. With these steps, it is not necessary to program a
"good" RCW using CodeWarrior. The method here can be performed with any
JTAG adapter supported by OpenOCD, including the on-board CMSIS-DAP
(albeit very slowly).

These steps require LS1046A support in OpenOCD, which was added in [1].

[1] https://sourceforge.net/p/openocd/code/ci/5b70c1f679755677c925b4e6dd2c3d8be4715717/

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
[trini: Add reference to doc/board/nxp/ls1046ardb.rst]

2 years agodoc: smh: Update semihosting documentation
Sean Anderson [Tue, 22 Mar 2022 20:59:25 +0000 (16:59 -0400)]
doc: smh: Update semihosting documentation

This documents how to use semihosting, the new semihosting features, and
how to migrate from smhload.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoserial: Add semihosting driver
Sean Anderson [Tue, 22 Mar 2022 20:59:24 +0000 (16:59 -0400)]
serial: Add semihosting driver

This adds a serial driver which uses semihosting calls to read and write
to the host's console. For convenience, if CONFIG_DM_SERIAL is enabled,
we will instantiate a serial driver. This allows users to enable this
driver (which has no physical device) without modifying their device
trees or board files. We also implement a non-DM driver for SPL, or for
much faster output in U-Boot proper.

There are three ways to print to the console:

Method              Baud
================== =====
smh_putc in a loop   170
smh_puts            1600
smh_write with :tt 20000
================== =====

These speeds were measured using a 175 character message with a J-Link
adapter. For reference, U-Boot typically prints around 2700 characters
during boot on this board. There are two major factors affecting the
speed of these functions. First, each breakpoint incurs a delay. Second,
each debugger memory transaction incurs a delay. smh_putc has a
breakpoint and memory transaction for every character. smh_puts has one
breakpoint, but still has to use a transaction for every character. This
is because we don't know the length up front, so OpenOCD has to check if
each character is nul. smh_write has only one breakpoint and one memory
transfer.

DM serial drivers can only implement a putc interface, so we are stuck
with the slowest API. Non-DM drivers can implement puts, which is vastly
more efficient. When the driver starts up, we try to open :tt. Since
this is an extension, this may fail. If it does, we fall back to
smh_puts. We don't check :semihosting-features, since there are
nonconforming implementations (OpenOCD) which don't implement it (but
*do* implement :tt).

Some semihosting implementations (QEMU) don't handle READC properly. To
work around this, we try to use open/read (much like for stdin) if
possible.

There is no non-blocking I/O available, so we don't implement pending.
This will cause __serial_tstc to always return true. If
CONFIG_SERIAL_RX_BUFFER is enabled, _serial_tstc will try and read
characters forever. To avoid this, we depend on this config being
disabled.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agoarm: smh: Add some functions for working with the host console
Sean Anderson [Tue, 22 Mar 2022 20:59:23 +0000 (16:59 -0400)]
arm: smh: Add some functions for working with the host console

This adds three wrappers around the semihosting commands for reading and
writing to the host console. We use the more standard getc/putc/puts
names instead of readc/writec/write0 for familiarity.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Remove smhload command
Sean Anderson [Tue, 22 Mar 2022 20:59:22 +0000 (16:59 -0400)]
arm: smh: Remove smhload command

This command's functionality is now completely implemented by the
standard fs load command. Convert the vexpress64 boot command (which is
the only user) and remove the implementation.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agocmd: fdt: Use start/size for chosen instead of start/end
Sean Anderson [Tue, 22 Mar 2022 20:59:21 +0000 (16:59 -0400)]
cmd: fdt: Use start/size for chosen instead of start/end

Most U-Boot command deal with start/size instead of start/end. Convert
the "fdt chosen" command to use these semantics as well. The only user
of this subcommand is vexpress, so convert the smhload command to use
this as well. We don't bother renaming the variable in vexpress64's
bootcommand, since it will be rewritten in the next commit.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agofs: Add semihosting filesystem
Sean Anderson [Tue, 22 Mar 2022 20:59:20 +0000 (16:59 -0400)]
fs: Add semihosting filesystem

This adds a filesystem which is backed by the host's filesystem. It is
modeled off of sandboxfs, which has very similar aims. Semihosting
doesn't support listing directories (except with SYS_SYSTEM), so neither
do we. it's possible to optimize a bit for the common case of reading a
whole file by omitting a call to smh_seek, but this is left as a future
optimization.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agospl: Add semihosting boot method
Sean Anderson [Tue, 22 Mar 2022 20:59:19 +0000 (16:59 -0400)]
spl: Add semihosting boot method

This adds a boot method for loading the next stage from the host. It is
mostly modeled off of spl_load_image_ext. I am not really sure why/how
spl_load_image_fat uses three different methods to load the image, but
the simple case seems to work OK for now.

To control the presence of this boot method, we add a config symbol.
While we're at it, we update the original semihosting config symbol.

I think semihosting has some advantages of other forms of JTAG boot.
Common other ways to boot from JTAG include:

- Implementing DDR initialization through JTAG (typically with dozens of
  lines of TCL) and then loading U-Boot. The DDR initialization
  typically uses hard-coded register writes, and is not easily adapted
  to different boards. BOOT_DEVICE_SMH allows booting with SPL,
  leveraging U-Boot's existing DDR initialization code. This is the
  method used by NXP's CodeWarrior IDE on Layerscape processors (see
  AN12270).
- Loading a bootloader into SDRAM, waiting for it to initialize DDR, and
  then loading U-Boot. This is tricky, because the debugger must stop the
  boot after the bootloader has completed its work. Trying to load
  U-Boot too early can cause failure to boot. This is the method used by
  Xilinx with its Zynq(MP) processors.
- Loading SPL with BOOT_DEVICE_RAM and breaking before SPL loads the
  image to load U-Boot at the appropriate place. This can be a bit
  tricky, because the load address is dependent on the header size. An
  elf with symbols must also be used in order to stop at the appropriate
  point. BOOT_DEVICE_SMH can be viewed as an extension of this process,
  where SPL automatically stops and tells the host where to place the
  image.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Add some file manipulation commands
Sean Anderson [Tue, 22 Mar 2022 20:59:18 +0000 (16:59 -0400)]
arm: smh: Add some file manipulation commands

In order to add filesystem support, we will need to be able to seek and
write files. Add the appropriate helper functions.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Document functions in header
Sean Anderson [Tue, 22 Mar 2022 20:59:17 +0000 (16:59 -0400)]
arm: smh: Document functions in header

This adds some documentation for semihosting functions in the header.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Return errno on error
Sean Anderson [Tue, 22 Mar 2022 20:59:16 +0000 (16:59 -0400)]
arm: smh: Return errno on error

Instead of printing in what are now library functions, try to return a
numeric error code. This also adjust some functions (such as read) to
behave more similarly to read(2). For example, we now return the number
of bytes read instead of failing immediately on a short read.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Use numeric modes for smh_open
Sean Anderson [Tue, 22 Mar 2022 20:59:15 +0000 (16:59 -0400)]
arm: smh: Use numeric modes for smh_open

There's no point in using string constants for smh_open if we are just
going to have to parse them. Instead, use numeric modes. The user needs
to be a bit careful with these, since they are much closer semantically
to string modes used by fopen(3) than the numeric modes used with
open(2).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Export semihosting functions
Sean Anderson [Tue, 22 Mar 2022 20:59:14 +0000 (16:59 -0400)]
arm: smh: Export semihosting functions

This exports semihosting functions for use in other files. The header is
in include/ and not arm/include/asm because I anticipate that RISC-V may
want to add their own implementation at some point.

smh_len_fd has been renamed to smh_flen to more closely match the
semihosting spec.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoarm: smh: Add semihosting entry to MAINTAINERS
Sean Anderson [Tue, 22 Mar 2022 20:59:13 +0000 (16:59 -0400)]
arm: smh: Add semihosting entry to MAINTAINERS

These files are spread all over the tree, so just use a regex. Orphaned
for now, since this is more of a "one-off" series. Though I'll be happy
to review patches.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agodoc: ls1046ardb: Document debug uart
Sean Anderson [Tue, 22 Mar 2022 20:59:12 +0000 (16:59 -0400)]
doc: ls1046ardb: Document debug uart

This adds some instructions for enabling the debug uart, including the
correct address and clock rate.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agodoc: ls1046ardb: Expand boot mode section
Sean Anderson [Tue, 22 Mar 2022 20:59:11 +0000 (16:59 -0400)]
doc: ls1046ardb: Expand boot mode section

This adds some additional info about booting from different sources,
including the correct switch positions.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agonxp: ls1046ardb: Convert README to rST
Sean Anderson [Tue, 22 Mar 2022 20:59:10 +0000 (16:59 -0400)]
nxp: ls1046ardb: Convert README to rST

This converts the readme for this board to rST. I have tried not to
change any semantics from the original (though I did convert MB to M).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agodoc: Convert semihosting readme to rST
Sean Anderson [Tue, 22 Mar 2022 20:59:09 +0000 (16:59 -0400)]
doc: Convert semihosting readme to rST

This converts the semihosting readme to rST. I have tried to make only
cosmetic changes, but I did fix up the first link (which was broken).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agovexpress64: Add ARMv8R-64 board variant
Peter Hoyes [Fri, 4 Mar 2022 16:30:18 +0000 (16:30 +0000)]
vexpress64: Add ARMv8R-64 board variant

The ARMv8-R64 architecture introduces optional VMSA (paging based MMU)
support in the EL1/0 translation regime, which makes that part mostly
compatible to ARMv8-A.

Add a new board variant to describe the "BASE-R64" FVP model, which
inherits a lot from the existing v8-A FVP support. One major difference
is that the memory map in "inverted": DRAM starts at 0x0, MMIO is at
2GB [1].

 * Create new TARGET_VEXPRESS64_BASER_FVP target, sharing most of the
   exising configuration.
 * Implement inverted memory map in vexpress_aemv8.h
 * Create vexpress_aemv8r defconfig
 * Provide an MMU memory map for the BASER_FVP
 * Update vexpress64 documentation

At the moment the boot-wrapper is the only supported secure firmware. As
there is no official DT for the board yet, we rely on it being supplied
by the boot-wrapper into U-Boot, so use OF_HAS_PRIOR_STAGE, and go with
a dummy DT for now.

[1] https://developer.arm.com/documentation/100964/1114/Base-Platform/Base---memory/BaseR-Platform-memory-map

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
[Andre: rebase and add Linux kernel header]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
[trini: Add MAINTAINERS entry for Peter]

2 years agovexpress64: pick DRAM size from DT
Andre Przywara [Fri, 4 Mar 2022 16:30:17 +0000 (16:30 +0000)]
vexpress64: pick DRAM size from DT

So far the DRAM size for both the Juno and the FVP model were hardcoded
in our config header file. For the Juno this is fine, as all models have
8 GiB of DRAM, but the DRAM size can be configured on the model command
line.

Drop the fixed DRAM size setup, instead look up the size in the device
tree, that we now have for every board. This allows a user to inject
a DT with the proper size, and be able to use the full amount of DRAM.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: generalise page table generation
Andre Przywara [Fri, 4 Mar 2022 16:30:16 +0000 (16:30 +0000)]
vexpress64: generalise page table generation

In preparation for the ARMv8-R64 FVP support, which has DRAM mapped at
0x0, generalise the page table generation, by using symbolic names for
the address ranges instead of fixed numbers.

We already define the base of the DRAM and MMIO regions, so just use
those symbols in the page table description. Rename V2M_BASE to the more
speaking V2M_DRAM_BASE on the way.

On the VExpress memory map, the address space right after 4GB is of no
particular interest to software, as the whole of DRAM is mapped at 32GB
instead. The first 2 GB alias to the lower 2GB of DRAM mapped below 4GB,
so we skip this part and map some more of the high DRAM, should anyone
need it.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: defconfigs: allow default commands
Andre Przywara [Fri, 4 Mar 2022 16:30:15 +0000 (16:30 +0000)]
vexpress64: defconfigs: allow default commands

Right now the defconfig the Arm VExpress64 boards disables quite some
standard commands, for apparently no good reasons (as image size is
hardly a concern here).

Remove the lines explicitly disabling those features, leaving it to
the U-Boot default settings to set them.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: fvp: add distro_boot support
Andre Przywara [Fri, 4 Mar 2022 16:30:14 +0000 (16:30 +0000)]
vexpress64: fvp: add distro_boot support

So far the FVP model just supports booting through semihosting, so by
loading files from the host the model is running on. This allows for
quick booting of new kernels (or replacing DTBs), but prevents more
featureful boots like using UEFI.

Enable the distro_boot feature, and provide a list of possible boot
sources that U-Boot should check:
- For backwards compatibility we start with semihosting, which gets its
  commands migrated from CONFIG_BOOTCOMMAND into the distro_boot
  infrastructure. This is also slightly tweaked to fail graceful in case
  the required files could not be found.
- Next we try to use a user provided script, that could be easily
  placed into memory using the model command line.
- Since we gained virtio support with the enablement of OF_CONTROL,
  let's check virtio block devices next. This is where UEFI boot can
  be easily used, for instance by providing a distro installer .iso
  file through virtio-blk.
- Networking is now provided by virtio as well, so enable the default
  PXE and DHCP boot flows, mostly because we can.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: move hardware setting from defconfig to Kconfig
Andre Przywara [Fri, 4 Mar 2022 16:30:13 +0000 (16:30 +0000)]
vexpress64: move hardware setting from defconfig to Kconfig

The defconfigs for the Arm Juno board and the FVP model are quite large,
setting a lot of platform-fixed variables like SYS_TEXT_BASE.
As those values are not really a user choice, let's provide default
values for them in our Kconfig file, so a lot of cruft can be removed
from the defconfig files.
This also moves the driver selection out of there, since this is again
not something a user should really decide on. Instead we allow users to
enable or disable subsystems, and select the appropriate drivers based
on that in the Kconfig file.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: config header: unify environment definition
Andre Przywara [Fri, 4 Mar 2022 16:30:12 +0000 (16:30 +0000)]
vexpress64: config header: unify environment definition

The definition of the standard environment variables (kernel_addr_r and
friends) has been improved lately for the FVP model, but the Juno board
is still using some custom scheme.
Since we need to extend this to a third board soon, let's unify the
definition:
- Define the Juno addresses in the same generic way we do for the FVP
  model, and move the actual variable setting out of the board #ifdef's.
- Add the missing addresses for a PXE file and a boot script.
- Cleanup some stale comments on the way.

As the FVP model doesn't have support for distro_boot quite yet, add
a dummy definition for now, to be replaced with the real thing later.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: fvp: enable OF_CONTROL
Andre Przywara [Fri, 4 Mar 2022 16:30:11 +0000 (16:30 +0000)]
vexpress64: fvp: enable OF_CONTROL

The FVP base model is relying on a DT for Linux operation, so there is
no reason we would need to rely on hardcoded information for U-Boot.
Letting U-Boot use a DT will open up the usage of actual peripherals,
beyond the support for semihosting only.

Enable OF_CONTROL in the Kconfig, and use the latest dts files from
Linux. Depending on whether we use the boot-wrapper or TF-A, there is
already a DTB provided or not, respectively.

To cover the boot-wrapper, we add an arm64 Linux kernel header, which
allows the boot-wrapper to treat U-Boot like a Linux kernel. U-Boot will
find the pointer to the DTB in x0, and will use it.

Even though TF-A carries a DT, at the moment this is not made available
to non-secure world, so to not break users, we use the U-Boot provided
DTB copy in that case. For some reason TF-A puts some DT like structure
at the address x0 is pointing at, but that is very small and doesn't
carry any hardware information. Make the code to ignore those small DTBs.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoarm: dts: Add Arm FVP Fastmodel RevC .dts files from Linux
Andre Przywara [Fri, 4 Mar 2022 16:30:10 +0000 (16:30 +0000)]
arm: dts: Add Arm FVP Fastmodel RevC .dts files from Linux

The Arm Fixed Virtual Platform (FVP) is a software model for an
artificial ARM platform, it is available for free on the Arm website[1].

Add the devicetree files for the latest RevC version, as we will need
them to enable OF_CONTROL for the vexpress_aemv8a_semi board.

This is a verbatim copy of the respective files from Linux v5.17-rc6,
which is unchanged from the v5.16 release.

[1] https://developer.arm.com/tools-and-software/simulation-models/fast-models

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agovexpress64: Kconfig: move board definitions out of arch/arm
Andre Przywara [Fri, 4 Mar 2022 16:30:09 +0000 (16:30 +0000)]
vexpress64: Kconfig: move board definitions out of arch/arm

At the moment we define three "VExpress64" boards in arch/arm/Kconfig,
plus have a second Kconfig file in board/armltd/Kconfig.
One of those three boards is actually bogus (TARGET_VEXPRESS64_AEMV8A),
that stanza looks like being forgotten in a previous cleanup.

To remove the clutter from the generic Kconfig file, just define some
ARCH_VEXPRESS64 symbol there, enable some common options, and do the
board/model specific configuration in the board/armltd Kconfig file.

That allows to streamline and fine tune the configuration later, and
to also pull a lot of "non user choices" out of the defconfigs.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoMerge branch '2022-04-01-Kconfig-migrations-and-cleanups' into next
Tom Rini [Fri, 1 Apr 2022 14:35:19 +0000 (10:35 -0400)]
Merge branch '2022-04-01-Kconfig-migrations-and-cleanups' into next

- Migrate a number of CONFIG symbols to Kconfig.  Of note, with this we
  now complete migration of CONFIG_SYS_EXTRA_OPTIONS.

2 years agoconfigs: Resync with savedefconfig
Tom Rini [Fri, 1 Apr 2022 14:33:18 +0000 (10:33 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoglobal: Remove CONFIG_SYS_EXTRA_OPTIONS support
Tom Rini [Thu, 24 Mar 2022 21:18:06 +0000 (17:18 -0400)]
global: Remove CONFIG_SYS_EXTRA_OPTIONS support

All options have now been migrated to Kconfig correctly so remove this
support.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_MONITOR_BASE to Kconfig
Tom Rini [Thu, 24 Mar 2022 21:18:05 +0000 (17:18 -0400)]
Convert CONFIG_SYS_MONITOR_BASE to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_MONITOR_BASE

Note that for how this is re-used on some PowePC platforms, we introduce
CONFIG_SPL_SYS_MONITOR_BASE and CONFIG_TPL_SYS_MONITOR_BASE and use the
CONFIG_VAL macro to get the correct value at build time, in the code.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_NORFLASH_PS32BIT to Kconfig
Tom Rini [Thu, 24 Mar 2022 21:18:04 +0000 (17:18 -0400)]
Convert CONFIG_NORFLASH_PS32BIT to Kconfig

This converts the following to Kconfig:
   CONFIG_NORFLASH_PS32BIT

Note that we also attempt to correct the behavior of the code here,
which had been testing for "NORFLASH_PS32BIT" which would never be set,
instead check for the now set "CONFIG_NORFLASH_PS32BIT", which results
in some behavior change.

Cc: TsiChung Liew <Tsi-Chung.Liew@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoat91: Switch to SD_BOOT / CONFIG_NAND_BOOT
Tom Rini [Thu, 24 Mar 2022 21:18:03 +0000 (17:18 -0400)]
at91: Switch to SD_BOOT / CONFIG_NAND_BOOT

The values CONFIG_SYS_USE_NANDFLASH and CONFIG_SYS_USE_MMC serve the
same purpose as CONFIG_SD_BOOT / CONFIG_NAND_BOOT so migrate to using
these switches instead as they're already in Kconfig.

Cc: Stelian Pop <stelian@popies.net>
Cc: Heiko Schocher <hs@denx.de>
Cc: Daniel Gorsulowski <daniel.gorsulowski@esd.eu>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SRIO_PCIE_BOOT_SLAVE to Kconfig
Tom Rini [Thu, 24 Mar 2022 21:18:02 +0000 (17:18 -0400)]
Convert CONFIG_SRIO_PCIE_BOOT_SLAVE to Kconfig

This converts the following to Kconfig:
   CONFIG_SRIO_PCIE_BOOT_SLAVE

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_E300 et al to Kconfig
Tom Rini [Thu, 24 Mar 2022 21:18:01 +0000 (17:18 -0400)]
Convert CONFIG_E300 et al to Kconfig

This converts the following to Kconfig:
   CONFIG_E300
   CONFIG_E5500

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agomx53loco: Convert CONFIG_DIALOG_POWER to Kconfig
Tom Rini [Thu, 24 Mar 2022 21:18:00 +0000 (17:18 -0400)]
mx53loco: Convert CONFIG_DIALOG_POWER to Kconfig

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoexynos: Drop CONFIG_DEVICE_TREE_LIST
Tom Rini [Thu, 24 Mar 2022 21:17:59 +0000 (17:17 -0400)]
exynos: Drop CONFIG_DEVICE_TREE_LIST

This value isn't used anywhere, drop it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_DEEP_SLEEP to Kconfig
Tom Rini [Thu, 24 Mar 2022 21:17:58 +0000 (17:17 -0400)]
Convert CONFIG_DEEP_SLEEP to Kconfig

This converts the following to Kconfig:
   CONFIG_DEEP_SLEEP

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoM5329EVB, M5373EVB: Remove CONFIG_NANDFLASH_SIZE
Tom Rini [Thu, 24 Mar 2022 21:17:57 +0000 (17:17 -0400)]
M5329EVB, M5373EVB: Remove CONFIG_NANDFLASH_SIZE

In the case of M5373EVB we always had NANDFLASH_SIZE=16, so just use it
directly.  In the case of M5329EVB we had not removed the rest of NAND
support when saying we didn't have NAND, so instead use that to key off
of rather than NANDFLASH_SIZE.

Cc: TsiChung Liew <Tsi-Chung.Liew@nxp.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agodb-mv784mp-gp: Rename CONFIG_DB_784MP_GP to CONFIG_TARGET_DB_MV784MP_GP
Tom Rini [Thu, 24 Mar 2022 21:17:56 +0000 (17:17 -0400)]
db-mv784mp-gp: Rename CONFIG_DB_784MP_GP to CONFIG_TARGET_DB_MV784MP_GP

The value CONFIG_DB_784MP_GP is only used in the DDR code to refer to
CONFIG_TARGET_DB_MV784MP_GP so just use that second value directly.

Cc: Stefan Roese <sr@denx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agop1_p2_rdb: Remove CONFIG_CPLD_[BO]R_PRELIM
Tom Rini [Wed, 23 Mar 2022 21:20:09 +0000 (17:20 -0400)]
p1_p2_rdb: Remove CONFIG_CPLD_[BO]R_PRELIM

These are not referenced in code, drop.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_CLOCKS to Kconfig
Tom Rini [Wed, 23 Mar 2022 21:20:08 +0000 (17:20 -0400)]
Convert CONFIG_CLOCKS to Kconfig

This converts the following to Kconfig:
   CONFIG_CLOCKS

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_CLOCK_SYNTHESIZER to Kconfig
Tom Rini [Wed, 23 Mar 2022 21:20:07 +0000 (17:20 -0400)]
Convert CONFIG_CLOCK_SYNTHESIZER to Kconfig

This converts the following to Kconfig:
   CONFIG_CLOCK_SYNTHESIZER

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoexynos: Drop CONFIG_CLK_*
Tom Rini [Wed, 23 Mar 2022 21:20:06 +0000 (17:20 -0400)]
exynos: Drop CONFIG_CLK_*

We only set one of these values ever at this point, so remove dead code.

Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Minkyu Kang <mk7.kang@samsung.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>