]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
14 months agoMerge branch '2023-10-23-bootstd-fixes-and-improvements'
Tom Rini [Mon, 23 Oct 2023 19:01:08 +0000 (15:01 -0400)]
Merge branch '2023-10-23-bootstd-fixes-and-improvements'

- Fix a few bootstd issues that have been reported and ahci support to
  bootstd

14 months agobootstd: sata: bootdev scanning for ahci sata with no drive attached
Tony Dinh [Sat, 7 Oct 2023 03:34:28 +0000 (20:34 -0700)]
bootstd: sata: bootdev scanning for ahci sata with no drive attached

It's normal to have no SATA drive attached to the controller, so return a
successful status when there is no block device found after probing.

Note: this patch depends on the previous patch
https://patchwork.ozlabs.org/project/uboot/patch/20230917230649.30357-1-mibodhi@gmail.com/

Resend the right patch.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
14 months agobootstd: sata: Add bootstd support for ahci sata
Tony Dinh [Wed, 11 Oct 2023 20:26:42 +0000 (13:26 -0700)]
bootstd: sata: Add bootstd support for ahci sata

Add ahci sata bootdev and corresponding hunting function.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
14 months agobootstd: Scan all bootdevs in a boot_targets entry (take 2)
Simon Glass [Mon, 23 Oct 2023 07:02:13 +0000 (00:02 -0700)]
bootstd: Scan all bootdevs in a boot_targets entry (take 2)

When the boot_targets environment variable is used with the distro-boot
scripts, each device is included individually. For example, if there
are three mmc devices, then we will have something like:

   boot_targets="mmc0 mmc1 mmc2"

In contrast, standard boot supports specifying just the uclass, i.e.:

   boot_targets="mmc"

The intention is that this should scan all MMC devices, but in fact it
currently only scans the first.

Update the logic to handle this case, without required BOOTSTD_FULL to
be enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Date Huang <tjjh89017@hotmail.com>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
Reported-by: Ivan Ivanov <ivan.ivanov@suse.com>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>
14 months agobootstd: Correct logic for single uclass
Simon Glass [Mon, 23 Oct 2023 07:02:12 +0000 (00:02 -0700)]
bootstd: Correct logic for single uclass

The current logic for "bootflow mmc" is flawed since it checks the
uclass of the bootdev instead of its parent, the media device. Correct
this and add a test that covers this scenario.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>
14 months agobootstd: Expand boot-ordering test to include USB
Simon Glass [Mon, 23 Oct 2023 07:02:11 +0000 (00:02 -0700)]
bootstd: Expand boot-ordering test to include USB

Scan the USB bus as well, so we can check that different uclasses work
correctly in boot_targets

update the function comment with more detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>
14 months agoRevert "bootstd: Scan all bootdevs in a boot_targets entry"
Simon Glass [Mon, 23 Oct 2023 07:02:10 +0000 (00:02 -0700)]
Revert "bootstd: Scan all bootdevs in a boot_targets entry"

This commit was intended to allow all bootdevs in each boot_targets
entry to be scanned. However it causes bad ordering with bootdevs, e.g.
scanning Ethernet bootdevs when it should be keeping to mmc.

Revert it so we can try another approach.

This reverts commit e824d0d0c219bc6da767f13f90c5b00eefe929f0.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Ivan T.Ivanov <iivanov@suse.de>
14 months agoCI: Re-enable maintainer check
Tom Rini [Mon, 23 Oct 2023 15:37:47 +0000 (11:37 -0400)]
CI: Re-enable maintainer check

At this point we have all of the defconfigs maintained again, so
re-enable the check to prevent further regressions.

Signed-off-by: Tom Rini <trini@konsulko.com>
14 months agoae350: Update defconfig list
Tom Rini [Mon, 23 Oct 2023 15:28:53 +0000 (11:28 -0400)]
ae350: Update defconfig list

Update the list of defconfigs, this was missed with the last pull
request of the u-boot-riscv tree.

Signed-off-by: Tom Rini <trini@konsulko.com>
14 months agoMerge tag 'u-boot-at91-2024.01-b' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Mon, 23 Oct 2023 15:39:38 +0000 (11:39 -0400)]
Merge tag 'u-boot-at91-2024.01-b' of https://source.denx.de/u-boot/custodians/u-boot-at91

Second set of u-boot-at91 features for the 2024.01 cycle

This feature set a new board named Conclusive KSTR sama5d27 with some
small prerequisites patches.

14 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Mon, 23 Oct 2023 13:04:55 +0000 (09:04 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi

This is mostly about support for the Allwinner R528/T113s SoC, which is
reportedly the same die as the Allwinner D1, but with the two
Arm Cortex-A7 cores activated instead of the RISC-V one.
Using sunxi code outside of arch/arm proved to be difficult, so apart
from enabling this Arm SoC, the patches also prepare for more refactoring
to get the D1 nicely supported some day:
- We get rid of some Kconfig (hard-)coded GPIO pins, responsible for
  enabling regulators.
- The GPIO code is moved out of arch/arm, into drivers/gpio.
- Some definitions are moved out of header files under asm/arch.
- Some T113s/D1 specific definitions are guarded by a generic Kconfig
  symbol (CONFIG_SUNXI_GEN_NCAT2).
- The DRAM controller initialisation code is located under drivers/ram.
- The base SoC .dtsi files are shared (under arch/riscv, as in Linux).

Of course there are also the usual new SoC specific patches, like clock
and pinmux descriptions, alongside a rework of the pinctrl code, since
Allwinner changed the GPIO register layout, for the first time since
sunxi's inception.
On top of this the PSCI code sees some update, to provide SMP services
for R528/T113s boards. Many thanks to Sam for providing this code and
staying strong through the review cycles.
The final patch enables support for one popular board, I hope to see
more DTs and defconfigs contributed in the future!

Many thanks to all the various contributors, testers and reviewers,
that series was a real team effort!

14 months agoboard: Add support for Conclusive KSTR-SAMA5D27
Artur Rojek [Wed, 18 Oct 2023 14:00:59 +0000 (16:00 +0200)]
board: Add support for Conclusive KSTR-SAMA5D27

Introduce support for Conclusive KSTR-SAMA5D27 Single Board Computer.

Co-developed-by: Jakub Klama <jakub@conclusive.pl>
Signed-off-by: Jakub Klama <jakub@conclusive.pl>
Co-developed-by: Marcin Jabrzyk <marcin@conclusive.pl>
Signed-off-by: Marcin Jabrzyk <marcin@conclusive.pl>
Signed-off-by: Artur Rojek <artur@conclusive.pl>
14 months agoarm: dts: at91: sama5: Add flexcom4 node
Artur Rojek [Wed, 18 Oct 2023 14:00:58 +0000 (16:00 +0200)]
arm: dts: at91: sama5: Add flexcom4 node

Set up flexcom4 for Microchip SAMA5D27 SoC and prepare it for usage in
I2C mode.

Signed-off-by: Artur Rojek <artur@conclusive.pl>
14 months agoevent: add new EVT_SETTINGS_R event
Artur Rojek [Wed, 18 Oct 2023 14:00:57 +0000 (16:00 +0200)]
event: add new EVT_SETTINGS_R event

Introduce EVT_SETTINGS_R, triggered post-relocation and before console
init.

This event gives an option to perform any platform-dependent setup,
which needs to take place before show_board_info(). Usage examples
include readout of EEPROM stored settings.

Signed-off-by: Artur Rojek <artur@conclusive.pl>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agocommon: add prototype & rename populate_serial_number()
Artur Rojek [Wed, 18 Oct 2023 14:00:56 +0000 (16:00 +0200)]
common: add prototype & rename populate_serial_number()

Rename populate_serial_number() to a more descriptive
serial_read_from_eeprom() and provide the missing function prototype.

This is useful for boards that wish to read their serial number from
EEPROM at init.

Signed-off-by: Artur Rojek <artur@conclusive.pl>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoMerge tag 'video-20231022' of https://source.denx.de/u-boot/custodians/u-boot-video
Tom Rini [Mon, 23 Oct 2023 13:04:40 +0000 (09:04 -0400)]
Merge tag 'video-20231022' of https://source.denx.de/u-boot/custodians/u-boot-video

 - updates for pwm_backlight, simple_panel and tegra20 to keep
   fixed/gpio regulator counter in balance

14 months agoMerge tag 'u-boot-amlogic-20231023' of https://source.denx.de/u-boot/custodians/u...
Tom Rini [Mon, 23 Oct 2023 13:04:17 +0000 (09:04 -0400)]
Merge tag 'u-boot-amlogic-20231023' of https://source.denx.de/u-boot/custodians/u-boot-amlogic

- sync A1 with Linux and add missing UART compatible
- fix USB2 gadget init on G12/SM1 based Boards

14 months agosunxi: add MangoPi MQ-R board support
Andre Przywara [Fri, 2 Dec 2022 16:11:36 +0000 (16:11 +0000)]
sunxi: add MangoPi MQ-R board support

The MangoPi MQ-R board uses an Allwinner T113s Soc (with 128MB of
embedded DRAM), support for which was just added to the code.

Since the devicetree was already synced from the latest Linux kernel
tree, all we need is a _defconfig file to add support for the board.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: psci: implement PSCI on R528
Sam Edwards [Thu, 12 Oct 2023 01:47:56 +0000 (19:47 -0600)]
sunxi: psci: implement PSCI on R528

This patch adds the necessary code to make nonsec booting and PSCI
secondary core management functional on the R528/T113.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Tested-by: Maksim Kiselev <bigunclemax@gmail.com>
Tested-by: Kevin Amadiva <kevin.amadiva@mec.at>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: psci: stop modeling register layout with C structs
Sam Edwards [Thu, 12 Oct 2023 01:47:55 +0000 (19:47 -0600)]
sunxi: psci: stop modeling register layout with C structs

Since the sunxi support nowadays generally prefers #defined register
offsets instead of modeling register layouts using C structs, now is a
good time to do this for PSCI as well. This patch moves away from using
the structs `sunxi_cpucfg_reg` and `sunxi_prcm_reg` in psci.c.

The former struct and its associated header file existed only to support
PSCI code, so also delete them altogether.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: psci: refactor register access to separate functions
Sam Edwards [Thu, 12 Oct 2023 01:47:54 +0000 (19:47 -0600)]
sunxi: psci: refactor register access to separate functions

This is to prepare for R528, which does not have the typical
"CPUCFG" block; it has a "CPUX" block which provides these
same functions but is organized differently.

Moving the hardware-access bits to their own functions separates the
logic from the hardware so we can reuse the same logic.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: psci: clean away preprocessor macros
Sam Edwards [Thu, 12 Oct 2023 01:47:53 +0000 (19:47 -0600)]
sunxi: psci: clean away preprocessor macros

This patch restructures psci.c to get away from the "many different
function definitions switched by #ifdef" paradigm to the preferred style
of having a single function definition with `if (IS_ENABLED(...))` to
make the optimizer include only the appropriate function bodies instead.

There are no functional changes here.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: refactor serial base addresses to avoid asm/arch/cpu.h
Andre Przywara [Sat, 2 Jul 2022 23:14:24 +0000 (00:14 +0100)]
sunxi: refactor serial base addresses to avoid asm/arch/cpu.h

At the moment we have each SoC's memory map defined in its own cpu.h,
which is included in include/configs/sunxi_common.h. This will be a
problem with the introduction of Allwinner RISC-V support.

Remove the inclusion of that header file from the common config header,
instead move the required serial base addresses (for the SPL) into a
separate header file. Then include the original cpu.h file only where
we really need it, which is only under arch/arm now.

This disentangles the architecture specific header files from the
generic code.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: R528: add SMHC2 pin pull ups support
Okhunjon Sobirjonov [Mon, 25 Sep 2023 03:43:28 +0000 (06:43 +0300)]
sunxi: R528: add SMHC2 pin pull ups support

Add support for eMMC (SMHC2) pin pull ups for R528 boards.

The D1 and T113s (and even R329) SoCs do not support 8-bit eMMC anymore,
so it's just four data pins to cover here.

Signed-off-by: Okhunjon Sobirjonov <Okhunjon.Sobirjonov@Mec-electronics.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
[Andre: adjust commit message]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: add Allwinner R528/T113 SoC support
Andre Przywara [Tue, 6 Sep 2022 14:59:57 +0000 (15:59 +0100)]
sunxi: add Allwinner R528/T113 SoC support

This adds the remaining code bits to teach U-Boot about Allwinner's
newest SoC generation. This was introduced with the RISC-V based
Allwinner D1 SoC, which actually shares a die with the ARM cores versions
called R528 (BGA, without DRAM) and T113s (QFP, with embedded DRAM).

This adds the new Kconfig stanza, using the two newly introduced symbols
for the new SoC generation and pincontroller. It also adds the new symbols
to the relavent code places, to set all the hardcoded bits directly.

We need one DT override:
The ARM core version of the DT specifies the CPUX watchdog as
"reserved", which means it won't be recognised by U-Boot. Override this
in our generic sunxi-u-boot.dtsi, to let U-Boot pick up this watchdog,
so that the generic reset driver will work.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: add R528/T113-s3/D1(s) DRAM initialisation code
Andre Przywara [Sat, 31 Dec 2022 18:38:21 +0000 (18:38 +0000)]
sunxi: add R528/T113-s3/D1(s) DRAM initialisation code

The Allwinner R528/T113-s/D1/D1s SoCs all share the same die, so use the
same DRAM initialisation code.
Make use of prior art here and lift some code from awboot[1], which
carried init code based on earlier decompilation efforts, but with a
GPL2 license tag.
This code has been heavily reworked and cleaned up, to match previous
DRAM routines for other SoCs, and also to be closer to U-Boot's coding
style and support routines.
The actual DRAM chip timing parameters are included in the main file,
since they cover all DRAM types, and are protected by a new Kconfig
CONFIG_SUNXI_DRAM_TYPE symbol, which allows the compiler to pick only
the relevant settings, at build time.

The relevant DRAM chips/board specific configuration parameters are
delivered via Kconfig, so this code here should work for all supported
SoCs and DRAM chips combinations.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Sam Edwards <CFSworks@gmail.com>
14 months agoKconfig: sunxi: prepare for using drivers/ram/sunxi
Andre Przywara [Sun, 18 Dec 2022 00:12:07 +0000 (00:12 +0000)]
Kconfig: sunxi: prepare for using drivers/ram/sunxi

At the moment all Allwinner DRAM initialisation routines are stored in
arch/arm/mach-sunxi, even though those "drivers" are just a giant
collection of writel's, without any architectural dependency.

The R528/T113-s SoC (with ARM cores) and the D1/D1s Soc (with RISC-V
cores) share the same die, so should share the same DRAM init routines as
well.

To prepare for this, add a new sunxi directory inside drivers/ram, and
add some stub entries to prepare for the addition of the share DRAM code
for those SoCs.

The RISC-V D1(s) SoCs will probably use SPL_DM, so for that SoC this
would be the right directory anyway.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: clock: support D1/R528 PLL6 clock
Andre Przywara [Fri, 2 Dec 2022 21:48:19 +0000 (21:48 +0000)]
sunxi: clock: support D1/R528 PLL6 clock

The PLL_PERIPH0 clock changed a bit in the D1/R528/T113s SoCs: there is
new P0 divider at bits [18:16], and the M divider is 1.

Add code to support this version of "PLL6".

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: clock: D1/R528: Enable PLL LDO during PLL1 setup
Andre Przywara [Fri, 2 Dec 2022 20:30:40 +0000 (20:30 +0000)]
sunxi: clock: D1/R528: Enable PLL LDO during PLL1 setup

The D1/R528/T113s SoCs introduce a new "LDO enable" bit in the CPUX_PLL.
Just enable that when we program that PLL.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agoclk: sunxi: Add support for the D1 CCU
Samuel Holland [Sun, 1 May 2022 03:38:37 +0000 (22:38 -0500)]
clk: sunxi: Add support for the D1 CCU

Since the D1 CCU binding is defined, we can add support for its
gates/resets, following the pattern of the existing drivers.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agopinctrl: sunxi: add Allwinner D1 pinctrl description
Andre Przywara [Mon, 5 Sep 2022 15:25:57 +0000 (16:25 +0100)]
pinctrl: sunxi: add Allwinner D1 pinctrl description

Apart from using the new pinctrl MMIO register layout, the Allwinner D1
and related SoCs still need to usual set of mux values hardcoded in
U-Boot's pinctrl driver.
Add the values we need so far to this list, so that DM based drivers
will just work without further ado.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agosunxi: introduce NCAT2 generation model
Andre Przywara [Wed, 5 Oct 2022 16:54:19 +0000 (17:54 +0100)]
sunxi: introduce NCAT2 generation model

Allwinner seems to typically stick to a common MMIO memory map for
several SoCs, but from time to time does some breaking changes, which
also introduce new generations of some peripherals. The last time this
happened with the H6, which apart from re-organising the base addresses
also changed the clock controller significantly. We added a
CONFIG_SUN50I_GEN_H6 symbol back then to mark SoCs sharing those traits.

Now the Allwinner D1 changes the memory map again, and also extends the
pincontroller, among other peripherals.
To mark this generation of SoCs, add a CONFIG_SUNXI_GEN_NCAT2 symbol,
this name is reportedly used in the Allwinner BSP code, and prevents us
from inventing our own name.

Add this new symbol to some guards that were already checking for the H6
generation, since many features are shared between the two (like the
renovated clock controller).

This paves the way to introduce a first user of this generation.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Samuel Holland <samuel@sholland.org>
14 months agopinctrl: sunxi: add new D1 pinctrl support
Andre Przywara [Tue, 6 Sep 2022 11:12:50 +0000 (12:12 +0100)]
pinctrl: sunxi: add new D1 pinctrl support

For the first time since at least the Allwinner A10 SoCs, the D1 (and
related cores) use a new pincontroller MMIO register layout, so we
cannot use our hardcoded, fixed offsets anymore.
Ideally this would all be handled by devicetree and DM drivers, but for
the DT-less SPL we still need the legacy interfaces.

Add a new Kconfig symbol to differenciate between the two generations of
pincontrollers, and just use that to just switch some basic symbols.
The rest is already abstracted enough, so works out of the box.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Sam Edwards <CFSworks@gmail.com>
Tested-by: Sam Edwards <CFSworks@gmail.com>
Tested-by: Samuel Holland <samuel@sholland.org>
14 months agopinctrl: sunxi: move PIO_BASE into sunxi_gpio.h
Andre Przywara [Tue, 6 Sep 2022 10:50:54 +0000 (11:50 +0100)]
pinctrl: sunxi: move PIO_BASE into sunxi_gpio.h

On the Allwinner platform we were describing a quite comprehensive
memory map in a per-SoC header unser arch/arm.
In the old days that was used by every driver, but nowadays it should
only be needed by SPL drivers (not using the DT). Many addresses in
there were never used, and some are not needed anymore.

To avoid a dependency on CPU specific headers in an arch specific
directory, move the definition of the pinctroller MMIO base address into
the sunxi_gpio.h header, because the SPL routines for GPIO should be the
only one needing this address.
This is a first step towards getting rid of cpu_sun[x]i.h completely,
and allows to remove the inclusion of that file from the sunxi_gpio.h
header.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
14 months agopinctrl: sunxi: remove GPIO_EXTRA_HEADER
Andre Przywara [Tue, 6 Sep 2022 09:36:38 +0000 (10:36 +0100)]
pinctrl: sunxi: remove GPIO_EXTRA_HEADER

U-Boot's generic GPIO_EXTRA_HEADER is a convenience symbol to allow code
to more easily include platform specific GPIO headers. This should not
be needed in a DM world anymore, since the generic GPIO framework
handles that nicely.
For Allwinner boards we still need to deal with non-DM GPIO in the SPL,
but this should become the exception, not the rule.

Make this more obvious by removing the definition of GPIO_EXTRA_HEADER,
and just force every legacy user of platform specific GPIO to include
the new sunxi_gpio.h header explicitly. Everyone doing so should feel
ashamed and should find a way to avoid it from now on.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Samuel Holland <samuel@sholland.org>
14 months agopinctrl: sunxi: remove struct sunxi_gpio
Andre Przywara [Mon, 5 Sep 2022 17:12:39 +0000 (18:12 +0100)]
pinctrl: sunxi: remove struct sunxi_gpio

So far every Allwinner SoC used the same basic pincontroller/GPIO
register frame, and just differed by the number of implemented banks and
pins, plus some special functionality from time to time. However the D1
and successors use a slightly different pinctrl register layout.
Use that opportunity to drop "struct sunxi_gpio", that described that
MMIO frame in a C struct. That approach is somewhat frowned upon in the
Linux world and rarely used there, though still popular with U-Boot.

Switching from a C struct to a "base address plus offset" approach allows
to switch between the two models more dynamically, without reverting to
preprocessor macros and #ifdef's.

Model the pinctrl MMIO register frame in the usual "base address +
offset" way, and replace a hard-to-parse CPP macro with a more readable
static function.
All the users get converted over. There are no functional changes at
this point, it just prepares the stages for the D1 and friends.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Tested-by: Samuel Holland <samuel@sholland.org>
14 months agopinctrl: sunxi: add GPIO in/out wrappers
Andre Przywara [Tue, 6 Sep 2022 09:07:18 +0000 (10:07 +0100)]
pinctrl: sunxi: add GPIO in/out wrappers

So far we were open-coding the pincontroller's GPIO output/input access
in each function using that.

Provide functions that wrap that nicely, and follow the existing pattern
(set/get_{bank,}), so users don't need to know about the internals, and
we can abstract the new D1 pinctrl more easily.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
14 months agopinctrl: sunxi: move pinctrl code
Andre Przywara [Tue, 6 Sep 2022 09:36:38 +0000 (10:36 +0100)]
pinctrl: sunxi: move pinctrl code

Move the existing sunxi-specific low level pinctrl routines from
arch/arm/mach-sunxi into the existing GPIO code under drivers/gpio, so
that the common code can be shared outside of arch/arm.

This also takes the opportunity to move some definitions from our
header file into the driver C file, as they are private to the driver
and are not needed elsewhere.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Tested-by: Samuel Holland <samuel@sholland.org>
14 months agosunxi: remove CONFIG_MACPWR
Andre Przywara [Wed, 8 Jun 2022 13:56:56 +0000 (14:56 +0100)]
sunxi: remove CONFIG_MACPWR

The CONFIG_MACPWR Kconfig symbol is used to point to a GPIO that enables
the power for the Ethernet "MAC" (mostly PHY, really).
In the DT this is described with the phy-supply property in the MAC DT
node, pointing to a (GPIO controlled) regulator. Since we need Ethernet
only in U-Boot proper, and use a DM driver there, we should use the DT
instead of hardcoding this.

Add code to the sun8i_emac and sunxi_emac drivers to check the DT for
that regulator and enable it, at probe time. Then drop the current code
from board.c, which was doing that job before.
This allows us to remove the MACPWR Kconfig definition and the respective
values from the defconfigs.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Sam Edwards <CFSworks@gmail.com>
14 months agonet: sunxi_emac: chase DT nodes to find PHY regulator
Andre Przywara [Tue, 13 Jun 2023 22:35:06 +0000 (23:35 +0100)]
net: sunxi_emac: chase DT nodes to find PHY regulator

At the moment the sun4i EMAC driver relies on hardcoded CONFIG_MACPWR
Kconfig symbols to enable potential PHY regulators. As we want to get rid
of those, we need to find the regulator by chasing up the DT.

The sun4i-emac binding puts the PHY regulator into the MDIO node, which
is the parent of the PHY device. U-Boot does not have (and does not
need) an MDIO driver, so we need to chase down the regulator through the
EMAC node: we follow the "phy-handle" property to find the PHY node,
then go up to its parent, where we find the "phy-supply" link to the
regulator. Let U-Boot find the associated regulator device, and put that
into the private device struct, so we can find and enable the regulator
at probe time, later.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
14 months agosunxi: remove CONFIG_SATAPWR
Andre Przywara [Fri, 15 Jul 2022 15:52:14 +0000 (16:52 +0100)]
sunxi: remove CONFIG_SATAPWR

The CONFIG_SATAPWR Kconfig symbol was used to point to a GPIO that
enables the power for a SATA harddisk.
In the DT this is described with the target-supply property in the AHCI
DT node, pointing to a (GPIO controlled) regulator. Since we need SATA
only in U-Boot proper, and use a DM driver for AHCI there, we should use
the DT instead of hardcoding this.

Add code to the sunxi AHCI driver to check the DT for that regulator and
enable it, at probe time. Then drop the current code from board.c, which
was doing that job before.
This allows us to remove the SATAPWR Kconfig definition and the
respective values from the defconfigs.
We also select the generic fixed regulator driver, which handles those
GPIO controlled regulators.

Please note that the OrangePi Plus is a bit special here, it's a H3
board without native SATA, but with a USB-to-SATA bridge. The DT models
the SATA power via a VBUS supply regulator, which we don't parse yet in
the USB PHY driver. Use the hardcoded CONFIG_USB3_VBUS_PIN for that
board meanwhile.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
14 months agovideo: tegra20: dsi: use regulator_set_enable_if_allowed
Svyatoslav Ryhel [Tue, 3 Oct 2023 06:25:34 +0000 (09:25 +0300)]
video: tegra20: dsi: use regulator_set_enable_if_allowed

With the commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable may be EALREADY or
EBUSY for fixed/gpio regulators and may be further expanded on all
regulators.

Change to use the more relaxed regulator_set_enable_if_allowed to
continue if regulator already was enabled or disabled.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
14 months agovideo: simple_panel: use regulator_set_enable_if_allowed
Svyatoslav Ryhel [Tue, 3 Oct 2023 06:25:33 +0000 (09:25 +0300)]
video: simple_panel: use regulator_set_enable_if_allowed

With the commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable may be EALREADY or
EBUSY for fixed/gpio regulators and may be further expanded on all
regulators.

Change to use the more relaxed regulator_set_enable_if_allowed to
continue if regulator already was enabled or disabled.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
14 months agovideo: pwm_backlight: use regulator_set_enable_if_allowed
Svyatoslav Ryhel [Tue, 3 Oct 2023 06:25:32 +0000 (09:25 +0300)]
video: pwm_backlight: use regulator_set_enable_if_allowed

With the commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable may be EALREADY or
EBUSY for fixed/gpio regulators and may be further expanded on all
regulators.

Change to use the more relaxed regulator_set_enable_if_allowed to
continue if regulator already was enabled or disabled.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
14 months agosunxi: dts: arm: add T113s/D1 DT files from Linux-v6.6-rc6
Andre Przywara [Thu, 19 Oct 2023 14:45:32 +0000 (15:45 +0100)]
sunxi: dts: arm: add T113s/D1 DT files from Linux-v6.6-rc6

This copies in some devicetree files from the official Linux kernel tree,
v6.6-rc6. It covers a board with the Allwinner T113s SoC, which shares
many devices with its RISC-V sibling, the Allwinner D1(s). This is the
reason for the core .dtsi files landing in the arch/riscv directory.

We are only adjusting the include path to accommodate for the differences
in the U-Boot build system.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
14 months agosunxi: dts: arm: update devicetree files from Linux-v6.6-rc6
Andre Przywara [Thu, 19 Oct 2023 14:45:32 +0000 (15:45 +0100)]
sunxi: dts: arm: update devicetree files from Linux-v6.6-rc6

Sync the devicetree files from the official Linux kernel tree, v6.6-rc6.
This is covering Allwinner SoCs with 32-bit ARM cores, minus the T113s
board and related .dtsi files, which come separately.

Only small changes: Bluetooth got enabled on the C.H.I.P., and a clock
got renamed. More interesting is the addition of a board, for which
U-Boot enablement patches are pending.

As before, this omits the non-backwards compatible changes to the R_INTC
controller, to remain compatible with older kernels.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
14 months agosunxi: dts: arm64: update devicetree files from Linux-v6.6-rc6
Andre Przywara [Thu, 19 Oct 2023 14:51:39 +0000 (15:51 +0100)]
sunxi: dts: arm64: update devicetree files from Linux-v6.6-rc6

Sync the devicetree files from the official Linux kernel tree, v6.6-rc6.
This is covering Allwinner SoCs with 64-bit ARM cores.

Only small cosmetic changes (clock name fixed), but we add the DT for
the new OrangePi Zero 3 board, for which U-Boot enablement patches are
pending.

As before, this omits the non-backwards compatible changes to the R_INTC
controller, to remain compatible with older kernels.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
14 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Fri, 20 Oct 2023 13:40:22 +0000 (09:40 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- kirkwood: Pogo v4: Enable LTO (Tony)

14 months agoarm: kirkwood: Pogo v4: Enable LTO
Tony Dinh [Mon, 16 Oct 2023 20:01:41 +0000 (13:01 -0700)]
arm: kirkwood: Pogo v4: Enable LTO

Enable building Pogo V4 u-boot image with LTO, which results in about 30K
reduction in size.

Rebased to latest master and resend.

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
14 months agoMerge branch 'master_uart_test' of https://source.denx.de/u-boot/custodians/u-boot-sh
Tom Rini [Thu, 19 Oct 2023 20:27:09 +0000 (16:27 -0400)]
Merge branch 'master_uart_test' of https://source.denx.de/u-boot/custodians/u-boot-sh

14 months agoserial: sh: Add RZ/G2L SCIF support
Paul Barker [Thu, 19 Oct 2023 14:30:44 +0000 (15:30 +0100)]
serial: sh: Add RZ/G2L SCIF support

Extend the existing driver to support the SCIF serial ports on the
Renesas RZ/G2L (R9A07G044) SoC. This also requires us to ensure that if
there is a reset signal defined in the device tree, it is de-asserted
before we try to talk to the SCIF module.

Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Tested-by: Marek Vasut <marek.vasut+renesas@mailbox.org> # R-Car H3 Salvator-XS
14 months agoserial: sh: Fix error handling
Paul Barker [Thu, 19 Oct 2023 14:30:43 +0000 (15:30 +0100)]
serial: sh: Fix error handling

The current SCIF error handling is broken for the RZ/G2L. After a break
condition has been triggered, the current code is unable to clear the
error and serial port output never resumes.

The RZ/G2L datasheet says that most error conditions are cleared by
resetting the relevant error bits in the FSR & LSR registers to zero.
To clear framing errors on SCIF ports, the invalid data also needs to be
read out of the receive FIFO.

After reviewing datasheets for RZ/G2{H,M,N,E}, R-Car Gen4, R-Car Gen3
and even SH7751 SoCs, it's clear that this is the way to clear errors
for all of these SoCs.

While we're here, annotate the handle_error() function with a couple of
comments as the reads and writes themselves don't immediately make it
clear what we're doing.

Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
Tested-by: Chris Paterson <chris.paterson2@renesas.com> # HiHope RZ/G2M board
Tested-by: Marek Vasut <marek.vasut+renesas@mailbox.org> # R-Car H3 Salvator-XS
14 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Thu, 19 Oct 2023 13:40:04 +0000 (09:40 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-riscv

+ riscv: Add Zbb support
+ riscv: Add preliminary RISC-V falcon mode support
+ riscv: Remove dram_init_banksize()
+ andes: rearrange PLICSW scheme
+ visionfive2: enable bootstage configs

14 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-watchdog
Tom Rini [Thu, 19 Oct 2023 13:39:00 +0000 (09:39 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-watchdog

- sandbox: watchdog: Avoid an error on startup (Simon)
- nuvoton: Fix reset/expire function error (Jim)

14 months agoriscv: Add Zbb support for building U-Boot
Yu Chien Peter Lin [Wed, 9 Aug 2023 10:49:30 +0000 (18:49 +0800)]
riscv: Add Zbb support for building U-Boot

This patch adds ISA string to the -march to generate zbb instructions
for U-Boot binaries, along with optimized string functions introduced
from Linux kernel.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
14 months agoriscv: spl: andes: Move the DTB in front of kernel
Randolph [Thu, 12 Oct 2023 06:35:09 +0000 (14:35 +0800)]
riscv: spl: andes: Move the DTB in front of kernel

Originally, u-boot SPL will place the DTB directly after the kernel,
but the size of the kernel does not include the BSS section, This
means that u-boot SPL places the DTB in the kernel BSS section causing
the DTB to be cleared by the kernel BSS initialisation.

Moving the DTB in front of the kernel can avoid this error.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
14 months agoandes: config: add riscv falcon mode for ae350 platform
Randolph [Thu, 12 Oct 2023 06:35:08 +0000 (14:35 +0800)]
andes: config: add riscv falcon mode for ae350 platform

Fork from ae350_rv[32/64]_spl_[xip]_defconfig and
append CONFIG_SPL_LOAD_FIT_OPENSBI_OS_BOOT=y

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
14 months agospl: riscv: add os type for next booting stage
Randolph [Thu, 12 Oct 2023 06:35:07 +0000 (14:35 +0800)]
spl: riscv: add os type for next booting stage

If SPL_LOAD_FIT_OPENSBI_OS_BOOT is enabled, the function
spl_invoke_opensbi should change the target OS type to IH_OS_LINUX.
OpenSBI will load the Linux image as the next boot stage.
The os_takes_devicetree function returns a value of true or false
depending on whether or not SPL_LOAD_FIT_OPENSBI_OS_BOOT is enabled.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoMakefile: delete file *.itb when make clean
Randolph [Thu, 12 Oct 2023 06:35:06 +0000 (14:35 +0800)]
Makefile: delete file *.itb when make clean

Delete the output file *.itb

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoriscv: dts: binman: add condition for opensbi os boot
Randolph [Thu, 12 Oct 2023 06:35:05 +0000 (14:35 +0800)]
riscv: dts: binman: add condition for opensbi os boot

Add condition for OpenSBI OS boot mode, by default it is not enabled.
By default, binman creates the output file u-boot.itb.
If SPL_OPENSBI_OS_BOOT is enabled, linux.itb will be created
after compilation instead of the default u-boot.itb.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoriscv: kconfig: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol
Randolph [Thu, 12 Oct 2023 06:35:04 +0000 (14:35 +0800)]
riscv: kconfig: introduce SPL_LOAD_FIT_OPENSBI_OS_BOOT symbol

Introduce common Kconfig symbol for riscv architecture.
This symbol SPL_LOAD_FIT_OPENSBI_OS_BOOT is like falcon mode on ARM,
the Falcon boot is a shortcut boot method for SD/eMMC targets. It
skips the loading the RAM version U-Boot. Instead, it will loads
the FIT image and boots directly to Linux.

When SPL_OPENSBI_OS_BOOT is enabled, linux.itb is created after
compilation instead of the default u-boot.itb. It initialises memory
with the U-Boot SPL at the first stage, just as a normal boot process
does at the beginning. Instead of jumping to the U-Boot proper from
OpenSBI before booting the Linux kernel, the RISC-V falcon mode
process jumps directly to the Linux kernel to gain shorter booting time.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agospl: riscv: opensbi: change the default os_type as varible
Randolph [Thu, 12 Oct 2023 06:35:03 +0000 (14:35 +0800)]
spl: riscv: opensbi: change the default os_type as varible

In order to introduce the Opensbi OS boot mode, the next stage boot
image of OpenSBI should be configurable.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoriscv: andes: Rearrange Andes PLICSW to single-bit-per-hart strategy
Randolph [Thu, 12 Oct 2023 05:35:34 +0000 (13:35 +0800)]
riscv: andes: Rearrange Andes PLICSW to single-bit-per-hart strategy

Source hart information is not necessary in IPI, so we could
use single-bit-per-hart strategy to rearrange PLICSW mapping.

Bit 0 of Interrupt Pending Bits is hardwired to 0.
Therefore, we use bit 1 to send IPI to hart 0,
bit 2 to hart 1, ..., and so on.

Signed-off-by: Randolph <randolph@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
14 months agoriscv: binman: Fix compilation error
Mayuresh Chitale [Wed, 11 Oct 2023 15:30:20 +0000 (21:00 +0530)]
riscv: binman: Fix compilation error

Some platforms may not have any DDR memory below 4G and for such platforms
the TEXT_BASE and LOAD addresses etc are all 64 bit addresses due to
which the u-boot build fails with below error:

u-boot/arch/riscv/dts/binman.dtsi:30.14-25
Value out of range for 32-bit array element
u-boot/arch/riscv/dts/binman.dtsi:43.14-25
Value out of range for 32-bit array element
u-boot/arch/riscv/dts/binman.dtsi:44.15-26
Value out of range for 32-bit array element
FATAL ERROR: Syntax error parsing input tree

Fix by setting the address-cells property to 2 and converting load
addresses to 64 bit values.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoconfigs: visionfive2: enable bootstage configs
Chanho Park [Tue, 10 Oct 2023 08:49:18 +0000 (17:49 +0900)]
configs: visionfive2: enable bootstage configs

Enable BOOTSTAGE configuration and its command for visionfive2 board.
The feature can be useful for analyzing the elapsed time between boot
stages.

TODO: define / reserve memory region for boot stage stash

StarFive # bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  3,139,338  3,139,338  board_init_f
  3,176,753     37,415  board_init_r
  4,036,111    859,358  eth_common_init
  4,101,599     65,488  eth_initialize
  4,105,799      4,200  main_loop
  4,145,207     39,408  usb_start
  5,440,963  1,295,756  cli_loop

Accumulated time:
                10,093  dm_f
                15,867  dm_r

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
14 months agoriscv: remove dram_init_banksize()
Heinrich Schuchardt [Tue, 26 Sep 2023 07:16:34 +0000 (09:16 +0200)]
riscv: remove dram_init_banksize()

Remove dram_init_banksize() on the architecture level.

Limiting used RAM to under 4 GiB is only necessary for CPUs which have a
DMA issue. SoC specific code already exists for FU540, FU740, JH7110.

Not all RISC-V boards will have memory below 4 GiB.

A weak implementation of dram_init_banksize() exists in common/board_f.c.

See the discussion in
https://lore.kernel.org/u-boot/545fe813-cb1e-469c-a131-0025c77aeaa2@canonical.com/T/

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
14 months agowdt: nuvoton: Fix reset/expire function error
Jim Liu [Wed, 18 Oct 2023 02:09:00 +0000 (10:09 +0800)]
wdt: nuvoton: Fix reset/expire function error

Fix npcm845 watchdog halt for reset function and expire function.
Reset function is restart wdt.

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
Reviewed-by: Stefan Roese <sr@denx.de>
14 months agosandbox: watchdog: Avoid an error on startup
Simon Glass [Thu, 10 Aug 2023 15:53:13 +0000 (09:53 -0600)]
sandbox: watchdog: Avoid an error on startup

For some time now running sandbox with -T produces an error:

   Core:  270 devices, 95 uclasses, devicetree: board
   WDT:   Not starting wdt-gpio-toggle
   wdt_gpio wdt-gpio-level: Request for wdt gpio failed: -16
   WDT:   Not starting wdt@0
   MMC:   mmc2: 2 (SD), mmc1: 1 (SD), mmc0: 0 (SD)

Use an unallocated GPIO to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 1fc45d6483d ("watchdog: add pulse support to gpio watchdog driver")
Reviewed-by: Stefan Roese <sr@denx.de>
14 months agoMerge branch '2023-10-17-spl-test-some-load-methods'
Tom Rini [Wed, 18 Oct 2023 12:28:00 +0000 (08:28 -0400)]
Merge branch '2023-10-17-spl-test-some-load-methods'

To quote the author:
This series adds some tests for various SPL load methods, with the
intent of helping debug v6 of [1]. With that in mind, notable omissions
include NAND and ROMAPI, which both lack sandbox implementations, and
OS_BOOT, which I have deferred due to its complexity. Semihosting is
also omitted, but I think we can test that with qemu.

In order to test all of these methods, we must first generate suitable
images, possibly on filesystems. While other tests have historically
generated these images using external tools (e.g. mkimage, mkfs, etc.),
I have chosen to generate them on the fly. This is for a few reasons:

- By removing external dependencies on pytest to create certain files,
  the tests become self-contained. This makes them easier to iterate on
  and debug.
- By generating tests at runtime, we can dynamically vary the content.
  This helps detect test failures, as even if tests are loaded to the
  same location, the expected content will be different.
- We are not testing the image parsers themselves (e.g.
  spl_load_simple_fit or fs_read) but rather the load methods (e.g.
  spl_mmc_load_image). It is unnecessary to exercise full functionality
  or generate 100% correct images.
- By reducing functionality to only what is necessary, the complexity of
  various formats can often be greatly reduced.

This series depends on [2-3], which are small fixes identified through
this patch set. The organization of patches in this series is as
follows:

- General fixes for bugs which are unlikely to be triggered outside of
  this series
- Changes to IMX8 container images to facilitate testing
- General prep. work, particularly regarding linker issues
- The tests themselves

Passing CI at [4].

[1] https://lore.kernel.org/all/20230731224304.111081-1-sean.anderson@seco.com/
[2] https://lore.kernel.org/all/20230930204246.515254-1-seanga2@gmail.com/
[3] https://lore.kernel.org/all/20231008014748.1987840-1-seanga2@gmail.com/
[4] https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/18128

14 months agoarm: meson-a1: dts: Sync DT with Linux
Igor Prusov [Tue, 17 Oct 2023 21:32:11 +0000 (00:32 +0300)]
arm: meson-a1: dts: Sync DT with Linux

Import device tree changes from Linux v6.6-rc6 for Amlogic A1 board.

Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20231017213211.121550-3-ivprusov@salutedevices.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
14 months agoserial: amlogic: Add UART compatible for A1 board
Igor Prusov [Tue, 17 Oct 2023 21:32:10 +0000 (00:32 +0300)]
serial: amlogic: Add UART compatible for A1 board

Add additional compatible to allow using serial driver with A1 board.
After compatible change in DTS [1], serial_meson driver should still be
able to work with console device.

[1] https://lore.kernel.org/all/20230705181833.16137-8-ddrokosov@sberdevices.ru/

Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20231017213211.121550-2-ivprusov@salutedevices.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
14 months agophy: meson-g12a-usb2: fix ret check on power_domain_get
Guillaume La Roque [Tue, 17 Oct 2023 18:57:25 +0000 (20:57 +0200)]
phy: meson-g12a-usb2: fix ret check on power_domain_get

Patch which add A1 SoC support create a regression on khadas vim3/vim3l
boards when we try to use fastboot command:

  => fastboot usb 0
  failed to get power domain
  failed to get power domain
  No USB device found
  USB init failed: -19

Add ENOENT check on ret in probe function.

Fixes: 5533c883ce10 ("phy: support Amlogic A1 family")
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20231017185725.809524-1-glaroque@baylibre.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
14 months agotest: spl: Add a test for the SPI load method
Sean Anderson [Sat, 14 Oct 2023 20:48:05 +0000 (16:48 -0400)]
test: spl: Add a test for the SPI load method

Add test for the SPI load method. This one is pretty straightforward. We
can't enable FIT_EXTERNAL with LOAD_FIT_FULL because spl_spi_load_image
doesn't know the total image size and has to guess from fdt_totalsize. This
doesn't include external data, so loading it will fail.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Add a test for the NOR load method
Sean Anderson [Sat, 14 Oct 2023 20:48:04 +0000 (16:48 -0400)]
test: spl: Add a test for the NOR load method

Add a test for the NOR load method. Since NOR is memory-mapped we can
substitute a buffer instead. The only major complication is testing LZMA
decompression.  It's too complex to implement LZMA compression in a test, and we
have no in-tree compressor, so we just include some pre-compressed data. This
data was generated through something like

    generate_data(plain, plain_size, "lzma")
    cat plain.dat | lzma | hexdump -C

and was cleaned up further in my editor.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Add a test for the NET load method
Sean Anderson [Sat, 14 Oct 2023 20:48:03 +0000 (16:48 -0400)]
test: spl: Add a test for the NET load method

Add a test for loading U-Boot over TFTP. As with other sandbox net
routines, we need to initialize our packets manually since things like
net_set_ether and net_set_udp_header always use "our" addresses. We use
BOOTP instead of DHCP, since DHCP has a tag/length-based format which is
harder to parse. Our TFTP implementation doesn't define as many constants
as I'd like, so I create some here. Note that the TFTP block size is
one-based, but offsets are zero-based.

In order to avoid address errors, we need to set up/define some additional
address information settings. dram_init_banksize would be a good candidate
for settig up bi_dram, but it gets called too late in board_init_r.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Add a test for the MMC load method
Sean Anderson [Sat, 14 Oct 2023 20:48:02 +0000 (16:48 -0400)]
test: spl: Add a test for the MMC load method

Add a test for the MMC load method. This shows the general shape of tests
to come: The main test function calls do_spl_test_load with an appropriate
callback to write the image to the medium.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Add a test for spl_blk_load_image
Sean Anderson [Sat, 14 Oct 2023 20:48:01 +0000 (16:48 -0400)]
test: spl: Add a test for spl_blk_load_image

Add a test for spl_blk_load_image, currently used only by NVMe. Because
there is no sandbox NVMe driver, just use MMC instead. Avoid falling back
to raw images to make failures more obvious.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Add functions to create filesystems
Sean Anderson [Sat, 14 Oct 2023 20:48:00 +0000 (16:48 -0400)]
test: spl: Add functions to create filesystems

Add some functions for creating fat/ext2 filesystems with a single file and
a test for them. Filesystems require block devices, and it is easiest to
just use MMC for this. To get an MMC, we must also pull in the test device
tree. SPL_TIMER is necessary for SPL_MMC, perhaps because it uses a timeout.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Add functions to create images
Sean Anderson [Sat, 14 Oct 2023 20:47:59 +0000 (16:47 -0400)]
test: spl: Add functions to create images

This add some basic functions to create images, and a test for said
functions. This is not intended to be a test of the image parsing
functions, but rather a framework for creating minimal images for testing
load methods. That said, it does do an OK job at finding bugs in the image
parsing directly.

Since we have two methods for loading/parsing FIT images, add LOAD_FIT_FULL
as a separate CI run.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Fix spl_test_load not failing if fname doesn't exist
Sean Anderson [Sat, 14 Oct 2023 20:47:58 +0000 (16:47 -0400)]
test: spl: Fix spl_test_load not failing if fname doesn't exist

Returning a negative value from a unit test doesn't automatically fail the
test.  We have to fail an assertion. Modify the test to do so.

This now causes the test to count as a failure on VPL. This is because the
fname of SPL (and U-Boot) is generated with make_exec in os_jump_to_image.
The original name of SPL is gone, and we can't determine the name of U-Boot
from the generated name.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agotest: spl: Split tests up and use some configs
Sean Anderson [Sat, 14 Oct 2023 20:47:57 +0000 (16:47 -0400)]
test: spl: Split tests up and use some configs

In order to make adding new spl unit tests easier, especially when they may
have many dependencies, add some Kconfigs for the existing image test.
Split it into the parts which are generic (such as callbacks) and the
test-specific parts.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agosandbox: Support -T in spl
Sean Anderson [Sat, 14 Oct 2023 20:47:56 +0000 (16:47 -0400)]
sandbox: Support -T in spl

The test devicetree is only compiled for U-Boot proper. When accessing it in
SPL we need to go up one directory.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agospl: Use map_sysmem where appropriate
Sean Anderson [Sat, 14 Oct 2023 20:47:55 +0000 (16:47 -0400)]
spl: Use map_sysmem where appropriate

All "physical" addresses in SPL must be converted to virtual addresses
before access in order for sandbox to work. Add some calls to map_sysmem in
appropriate places. We do not generally call unmap_sysmem, since we need
the image memory to still be mapped when we jump to the image. This doesn't
matter at the moment since unmap_sysmem is a no-op.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agospl: Add callbacks to invalidate cached devices
Sean Anderson [Sat, 14 Oct 2023 20:47:54 +0000 (16:47 -0400)]
spl: Add callbacks to invalidate cached devices

Several SPL functions try to avoid performing initialization twice by
caching devices. This is fine for regular boot, but does not work with
UNIT_TEST, since all devices are torn down after each test. Add some
functions to invalidate the caches which can be called before testing these
load methods.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agonet: bootp: Fall back to BOOTP from DHCP when unit testing
Sean Anderson [Sat, 14 Oct 2023 20:47:53 +0000 (16:47 -0400)]
net: bootp: Fall back to BOOTP from DHCP when unit testing

If we sent a DHCP packet and get a BOOTP response from the server, we
shouldn't try to send a DHCPREQUEST packet, since it won't be DHCPACKed.
Transition straight to BIND. This is only enabled for UNIT_TEST to avoid
bloat, since I suspect the number of BOOTP servers in the wild is
vanishingly small.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agonet: bootp: Move port numbers to header
Sean Anderson [Sat, 14 Oct 2023 20:47:52 +0000 (16:47 -0400)]
net: bootp: Move port numbers to header

These defines are useful when testing bootp.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
14 months agonet: Fix compiling SPL when fastboot is enabled
Sean Anderson [Sat, 14 Oct 2023 20:47:51 +0000 (16:47 -0400)]
net: Fix compiling SPL when fastboot is enabled

When fastboot is enabled in U-Boot proper and SPL_NET is enabled, we will
try to (unsuccessfully) reference it in SPL. Fix these linker errors by
conditioning on SPL_UDP/TCP_FUNCTION_FASTBOOT.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
14 months agofs: ext4: Add some defines for testing
Sean Anderson [Sat, 14 Oct 2023 20:47:50 +0000 (16:47 -0400)]
fs: ext4: Add some defines for testing

Add various defines which are not necessary for reading/writing
filesystems, but which are useful for creating them. These mostly come from
Linux v6.5-rc2 (what I had checked out).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agofs: ext4: Fix building ext4 in SPL if write is enabled
Sean Anderson [Sat, 14 Oct 2023 20:47:49 +0000 (16:47 -0400)]
fs: ext4: Fix building ext4 in SPL if write is enabled

If EXT4_WRITE is enabled, write capabilities will be compiled into SPL, but
not CRC16. Add an option to enable CRC16 to avoid linker errors.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agofs: Disable sandbox filesystem in SPL
Sean Anderson [Sat, 14 Oct 2023 20:47:48 +0000 (16:47 -0400)]
fs: Disable sandbox filesystem in SPL

Don't bother compiling the sandbox filesystem in SPL for now, as it is not
needed.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agolib: acpi: Fix linking SPL when ACPIGEN is enabled
Sean Anderson [Sat, 14 Oct 2023 20:47:47 +0000 (16:47 -0400)]
lib: acpi: Fix linking SPL when ACPIGEN is enabled

lib/acpi/acpigen.o is only compiled into SPL when SPL_ACPIGEN is enabled.
Update several files which reference these functions accordingly.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agospl: Allow enabling SPL_OF_REAL and SPL_OF_PLATDATA at the same time
Sean Anderson [Sat, 14 Oct 2023 20:47:46 +0000 (16:47 -0400)]
spl: Allow enabling SPL_OF_REAL and SPL_OF_PLATDATA at the same time

Sandbox unit tests in U-Boot proper load a test device tree to have some
devices to work with. In order to do the same in SPL, we must enable
SPL_OF_REAL. However, we already have SPL_OF_PLATDATA enabled. When
generating platdata from a devicetree, it is expected that we will not need
devicetree access functions (even though SPL_OF_CONTROL is enabled). This
expectation does not hold for sandbox, so allow user control of
SPL_OF_REAL.

There are several places in the tree where conditions involving OF_PLATDATA
or OF_REAL no longer function correctly when both of these options can be
selected at the same time. Adjust these conditions accordingly.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agoMove i.MX8 container image loading support to common/spl
Sean Anderson [Sat, 14 Oct 2023 20:47:45 +0000 (16:47 -0400)]
Move i.MX8 container image loading support to common/spl

To facilitate testing loading i.MX8 container images, move the
parse-container code to common/spl.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agoarm: imx: Check header before calling spl_load_imx_container
Sean Anderson [Sat, 14 Oct 2023 20:47:44 +0000 (16:47 -0400)]
arm: imx: Check header before calling spl_load_imx_container

Make sure we have an IMX header before calling spl_load_imx_container,
since if we don't it will fail with -ENOENT. This allows us to fall back to
legacy/raw images if they are also enabled.

This is a functional change, one which likely should have been in place
from the start, but a functional change nonetheless. Previously, all
non-IMX8 images (except FITs without FIT_FULL) would be optimized out if
the only image load method enabled supported IMX8 images. With this change,
support for other image types now has an effect.

There are seven boards with SPL_LOAD_IMX_CONTAINER enabled: three with
SPL_BOOTROM_SUPPORT:

    imx93_11x11_evk_ld imx93_11x11_evk imx8ulp_evk

and four with SPL_MMC:

    deneb imx8qxp_mek giedi imx8qm_mek

All of these boards also have SPL_RAW_IMAGE_SUPPORT and
SPL_LEGACY_IMAGE_FORMAT enabled as well. However, none have FIT support
enabled. Of the six load methods affected by this patch, only SPL_MMC and
SPL_BOOTROM_SUPPORT are enabled with SPL_LOAD_IMX_CONTAINER.
spl_romapi_load_image_seekable does not support legacy or raw images, so
there is no growth. However, mmc_load_image_raw_sector does support loading
legacy/raw images. Since these images could not have been booted before, I
have disabled support for legacy/raw images on these four boards. This
reduces bloat from around 800 bytes to around 200.

There are no in-tree boards with SPL_LOAD_IMX_CONTAINER and AHAB_BOOT both
enabled, so we do not need to worry about potentially falling back to
legacy images in a secure boot scenario.

Future work could include merging imx_container.h with imx8image.h, since
they appear to define mostly the same structures.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agoarm: imx: Add function to validate i.MX8 containers
Sean Anderson [Sat, 14 Oct 2023 20:47:43 +0000 (16:47 -0400)]
arm: imx: Add function to validate i.MX8 containers

Add a function to abstract the common task of validating i.MX8 container
image headers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agoarm: imx: Use log_err for errors in read_auth_container
Sean Anderson [Sat, 14 Oct 2023 20:47:42 +0000 (16:47 -0400)]
arm: imx: Use log_err for errors in read_auth_container

To allow for more flexible handling of errors, use log_err instead of
printf.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agoarm: imx: Add newlines after error messages
Sean Anderson [Sat, 14 Oct 2023 20:47:41 +0000 (16:47 -0400)]
arm: imx: Add newlines after error messages

These error messages are missing newlines. Add them.

Fixes: 6e81ca220e0 ("imx: parse-container: Use malloc for container processing")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agoarm: imx: Fix i.MX8 container load address
Sean Anderson [Sat, 14 Oct 2023 20:47:40 +0000 (16:47 -0400)]
arm: imx: Fix i.MX8 container load address

We should load images to their destination, not their entry point.

Fixes: 7b86cd4274e ("imx8: support parsing i.MX8 Container file")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
14 months agospl: fit: Fix entry point for SPL_LOAD_FIT_FULL
Sean Anderson [Sat, 14 Oct 2023 20:47:39 +0000 (16:47 -0400)]
spl: fit: Fix entry point for SPL_LOAD_FIT_FULL

The entry point is not always the same as the load address. Use the value
of the entry property if it exists.

Fixes: 8a9dc16e4d0 ("spl: Add full fitImage support")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 months agospl: nor: Don't allocate header on stack
Sean Anderson [Sat, 14 Oct 2023 20:47:38 +0000 (16:47 -0400)]
spl: nor: Don't allocate header on stack

spl_image_info.name contains a reference to legacy_img_hdr. If we allocate
the latter on the stack, it will be clobbered after we return. This was
addressed for NAND back in 06377c5a1fc ("spl: spl_legacy: Fix NAND boot on
OMAP3 BeagleBoard"), but that commit didn't fix NOR.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>