platform/kernel/u-boot.git
3 years agoMerge tag 'u-boot-stm32-20211012' of https://source.denx.de/u-boot/custodians/u-boot-stm
Tom Rini [Tue, 12 Oct 2021 16:01:00 +0000 (12:01 -0400)]
Merge tag 'u-boot-stm32-20211012' of https://source.denx.de/u-boot/custodians/u-boot-stm

- Disable ATAGS for STM32 MCU and MPU boards
- Disable bi_boot_params for STM32 MCU and MPU boards
- Update stm32-usbphyc node management
- Convert CONFIG_STM32_FLASH to Kconfig for STM32 MCU boards
- Convert some USB config flags to Kconfig for various boards
- Convert CONFIG_BOOTCOMMAND flag to Kconfig for STM32 F429 board
- Remove specific CONFIG_STV0991 flags
- Remove unused CONFIG_USER_LOWLEVEL_INIT flag
- Add ofdata_to_platdata() callback for stm32_spi driver
- Update for stm32f7_i2c driver
- Remove gpio_hog_probe_all() from STM32 MP1 board
- Fix bind command

Signed-off-by: Tom Rini <trini@konsulko.com>
3 years agoMerge tag 'u-boot-at91-2022.01-b' of https://source.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 12 Oct 2021 15:49:15 +0000 (11:49 -0400)]
Merge tag 'u-boot-at91-2022.01-b' of https://source.denx.de/u-boot/custodians/u-boot-at91

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

This small feature set adds the support for PWM driver for the sama5d2
SoC. It also adds a node in the DT for this SoC.

3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Tue, 12 Oct 2021 12:58:58 +0000 (08:58 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi

The bulk of it is Samuel's DM_I2C rework, which removes the nasty I2C
deprecation warnings for most 32-bit boards. It also includes some
smaller refactorings that pave the way for more changes, mostly driven
by needing to support the Allwinner RISC-V SoC later on.

Board wise we gain support for the FriendlyARM NanoPi R1S H5 router
board and official Pinetab support.

Build-tested for all 160 sunxi boards, and boot tested on a A64, A20,
H3, H6, and H616 board. USB, SD card, eMMC, and Ethernet all work there
(where applicable).

3 years agotest/py: Add usb gadget binding test
Patrice Chotard [Fri, 10 Sep 2021 14:16:24 +0000 (16:16 +0200)]
test/py: Add usb gadget binding test

Add a specific usb gadget binding test which check that
binding a driver without compatible string is working as expected.

the command "bind /usb@1 usb_ether" should give the following "dm tree"
command output:

[...]
 usb           0  [   ]   usb_sandbox           |-- usb@1
 usb_hub       0  [   ]   usb_hub               |   |-- hub
 usb_emul      0  [   ]   usb_sandbox_hub       |   |   `-- hub-emul
 usb_emul      1  [   ]   usb_sandbox_flash     |   |       |-- flash-stick@0
 usb_emul      2  [   ]   usb_sandbox_flash     |   |       |-- flash-stick@1
 usb_emul      3  [   ]   usb_sandbox_flash     |   |       |-- flash-stick@2
 usb_emul      4  [   ]   usb_sandbox_keyb      |   |       `-- keyb@3
 eth           4  [   ]   usb_ether             |   `-- usb@1
[...]

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoconfigs: sandbox: add USB_ETHER and GADGET_DOWNLOAD gadget support
Patrice Chotard [Fri, 10 Sep 2021 14:16:23 +0000 (16:16 +0200)]
configs: sandbox: add USB_ETHER and GADGET_DOWNLOAD gadget support

This is needed for new gadget binding test.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agousb: sandbox: Add gadget callbacks
Patrice Chotard [Fri, 10 Sep 2021 14:16:22 +0000 (16:16 +0200)]
usb: sandbox: Add gadget callbacks

Add usb_gadget_handle_interrupts(), usb_gadget_register_driver()
and usb_gadget_unregister_driver() to be able to test
binding usb gadget.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agousb: gadget: Add bcdDevice for the DWC2 USB Gadget Controller
Patrice Chotard [Fri, 10 Sep 2021 14:16:21 +0000 (16:16 +0200)]
usb: gadget: Add bcdDevice for the DWC2 USB Gadget Controller

Add an entry in usb_gadget_controller_number() for the DWC2
gadget controller. It is used to bind the USB Ethernet driver.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reported-by: Herbert Poetzl <herbert@13thfloor.at>
Cc: Marek Vasut <marex@denx.de>
Cc: Herbert Poetzl <herbert@13thfloor.at>
3 years agocmd: bind: Fix driver binding on a device
Patrice Chotard [Fri, 10 Sep 2021 14:16:20 +0000 (16:16 +0200)]
cmd: bind: Fix driver binding on a device

Fix a regression brings by commit 84f8e36f03fa ("cmd: bind: allow to
bind driver with driver data")

As example, the following bind command doesn't work:

   bind /soc/usb-otg@49000000 usb_ether

As usb_ether driver has no compatible string, it can't be find by
lists_bind_fdt(). In bind_by_node_path(), which called lists_bind_fdt(),
the driver entry is known, pass it to lists_bind_fdt() to force the driver
entry selection.

For this, add a new parameter struct *driver to lists_bind_fdt().
Fix also all lists_bind_fdt() callers.

Fixes: 84f8e36f03fa ("cmd: bind: allow to bind driver with driver data")
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reported-by: Herbert Poetzl <herbert@13thfloor.at>
Cc: Marek Vasut <marex@denx.de>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoARM: dts: sama5d2: Add pwm0 definition
Dan Sneddon [Mon, 20 Sep 2021 23:28:46 +0000 (16:28 -0700)]
ARM: dts: sama5d2: Add pwm0 definition

Add node for the PWM0 on the SAMA5D2 SoC.

Signed-off-by: Dan Sneddon <dan.sneddon@microchip.com>
3 years agodt-bindings: pwm: pwm-at91: Add PWM bindings for A5D2
Dan Sneddon [Mon, 20 Sep 2021 23:28:45 +0000 (16:28 -0700)]
dt-bindings: pwm: pwm-at91: Add PWM bindings for A5D2

Document the bindings needed for the PWM device on the SAMA5D2.

Signed-off-by: Dan Sneddon <dan.sneddon@microchip.com>
3 years agopwm: Add PWM driver for SAMA5D2
Dan Sneddon [Mon, 20 Sep 2021 23:28:44 +0000 (16:28 -0700)]
pwm: Add PWM driver for SAMA5D2

Add support for the PWM found on the SAMA5D2 family of devices.

Signed-off-by: Dan Sneddon <dan.sneddon@microchip.com>
3 years agosunxi: Enable DM_I2C for all sunxi boards
Samuel Holland [Fri, 8 Oct 2021 05:17:25 +0000 (00:17 -0500)]
sunxi: Enable DM_I2C for all sunxi boards

Now that the last users of legacy I2C (outside of SPL) have been
resolved, we can enable DM_I2C at the sunxi architecture level.

Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: video: Convert panel I2C to use DM_I2C
Samuel Holland [Fri, 8 Oct 2021 05:17:24 +0000 (00:17 -0500)]
sunxi: video: Convert panel I2C to use DM_I2C

Two displays supported by the sunxi display driver (each one used by a
single board) require initialization over I2C. Both previously used
i2c_soft; replace this with the i2c-gpio instance that already exists in
those boards' device trees (sun5i-a13-utoo-p66 and sun6i-a31-colombus).

Since the i2c-gpio nodes are not referenced by any other node in the
device trees (the device trees have no panel node), the I2C bus is
selected by its node name.

This panel initialization code was the only i2c_soft user, so the
i2c_soft GPIO setup code can be removed now as well.

Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: pmic_bus: Use the DM PMIC interface when possible
Samuel Holland [Fri, 8 Oct 2021 05:17:23 +0000 (00:17 -0500)]
sunxi: pmic_bus: Use the DM PMIC interface when possible

The pmic_bus functions are used in both SPL (for regulator setup) and
U-Boot proper (for regulator setup, SID access, GPIO, and poweroff).

Currently, pmic_bus conflicts with DM_I2C because it uses the legacy I2C
interface. This commit makes pmic_bus dual-compatible with either the
legacy I2C functions or the newly-added PMIC_AXP driver (which uses
DM_I2C). In turn, this allows platforms to start transitioning to DM_I2C
in U-Boot proper, without breaking boards that still depend on the
legacy I2C interface for other reasons.

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>
3 years agosunxi: pmic_bus: Clean up preprocessor conditions
Samuel Holland [Fri, 8 Oct 2021 05:17:22 +0000 (00:17 -0500)]
sunxi: pmic_bus: Clean up preprocessor conditions

Instead of using the SoC symbols to decide the bus type, use whichever
bus driver is actually enabled. This allows collapsing all of the AXP2xx
and AXP8xx variants into one "else" case. It also has the advantage of
falling back to I2C when the other bus drivers are disabled; this works
because all of the PMICs support I2C in addition to other interfaces.

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>
3 years agoi2c: Add a DM_I2C driver for the sun8i RSB controller
Samuel Holland [Fri, 8 Oct 2021 05:17:21 +0000 (00:17 -0500)]
i2c: Add a DM_I2C driver for the sun8i RSB controller

This bus controller is used to communicate with an X-Powers AXP PMIC.
Currently, various drivers access PMIC registers through a platform-
specific non-DM "pmic_bus" interface, which depends on the legacy I2C
framework. In order to convert those drivers to use DM_PMIC, this bus
needs a DM_I2C driver.

Refactor the rsb functions to take the base address as a parameter,
and implement both the existing interface (which is still needed in
SPL) and the DM_I2C interface on top of them.

The register for switching between I2C/P2WI/RSB mode is the same across
all PMIC variants, so move that to the common header.

There are only a couple of pairs of hardware/runtime addresses used
across all PMIC variants. So far the code expected only the "primary"
pair, but some PMICs like the AXP305 and AXP805 use the secondary pair,
so add support for that to the DM driver as well.

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>
3 years agoi2c: Add a DM_I2C driver for the sun6i P2WI controller
Samuel Holland [Fri, 8 Oct 2021 05:17:20 +0000 (00:17 -0500)]
i2c: Add a DM_I2C driver for the sun6i P2WI controller

This bus controller is used to communicate with an X-Powers AXP PMIC.
Currently, various drivers access PMIC registers through a platform-
specific non-DM "pmic_bus" interface, which depends on the legacy I2C
framework. In order to convert those drivers to use DM_PMIC, this bus
needs a DM_I2C driver.

Refactor the p2wi functions to take the base address as a parameter,
and implement both the existing interface (which is still needed in
SPL) and the DM_I2C interface on top of them.

The register for switching between I2C/P2WI/RSB mode is the same across
all PMIC variants. Move that to the common header, so it can be used by
both interface implementations.

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>
3 years agosunxi: pmic_bus: Fix Kconfig dependencies
Samuel Holland [Fri, 8 Oct 2021 05:17:19 +0000 (00:17 -0500)]
sunxi: pmic_bus: Fix Kconfig dependencies

AXP_PMIC_BUS enables communication with a specific AXP PMIC at a
PMIC-dependent I2C/P2WI/RSB bus address. It is automatically selected
as a dependency of the PMIC driver. It should not be selectable by the
user when no PMIC is chosen.

AXP_GPIO uses the pmic_bus functions, and also depends on a specific
PMIC header to pick up register definitions.

Both of these changes have no impact on any existing configs, since
the code does not compile if the dependencies are not met.

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: Select SUN8I_RSB more carefully
Samuel Holland [Fri, 8 Oct 2021 05:17:18 +0000 (00:17 -0500)]
sunxi: Select SUN8I_RSB more carefully

SUN8I_RSB should not be selected by MACH_SUN8I, because the hardware
is not present in half of those SoCs (H3/H5, R40, and V3s). Move the
selection to the SoCs where the hardware actually exists.
As it currently stands, selecting that option also requires using it in
some way, which is not the case for one A80 board. Since we have only
three A80 boards in total, we select it their via their defconfigs.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
[Andre: fixing up Sunchip_CX-A99 build]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: Only initialize legacy I2C when enabled
Samuel Holland [Fri, 8 Oct 2021 05:17:17 +0000 (00:17 -0500)]
sunxi: Only initialize legacy I2C when enabled

CONFIG_SPL_I2C is the wrong symbol to use here. It is the top-level
Kconfig symbol (not specific to either legacy or DM I2C), whereas the
i2c_init() function is specific to legacy I2C. This change fixes a
build failure when enabling SPL_I2C but not SPL_SYS_I2C_LEGACY.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-by: Andre Przywara <andre.przywara@arm.com>
3 years agopower: pmic: Add a driver for X-Powers AXP PMICs
Samuel Holland [Fri, 8 Oct 2021 05:17:16 +0000 (00:17 -0500)]
power: pmic: Add a driver for X-Powers AXP PMICs

These PMICs provide some combination of battery charger, fuel gauge,
GPIOs, regulators, and VBUS routing. These functions are represented
as child nodes in the device tree. Add the minimal driver needed to
probe these child devices and provide the DM_PMIC ops.

Enable the driver by default for SoCs that normally pair with a PMIC.

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>
3 years agopower: pmic: Consistently depend on SPL_DM_PMIC
Samuel Holland [Fri, 8 Oct 2021 05:17:15 +0000 (00:17 -0500)]
power: pmic: Consistently depend on SPL_DM_PMIC

Now that there is a separate symbol to enable DM_PMIC in SPL, update the
the SPL-specific driver symbols to depend on this new option.

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>
3 years agopower: pmic: Consistently depend on DM_PMIC
Samuel Holland [Fri, 8 Oct 2021 05:17:14 +0000 (00:17 -0500)]
power: pmic: Consistently depend on DM_PMIC

Kconfig symbols for two PMIC drivers (PMIC_AS3722 and DM_PMIC_MC34708)
were missing a dependency on DM_PMIC. To fix this inconsistency, and to
keep it from happening again, wrap the driver section with "if DM_PMIC"
instead of using a "depends on DM_PMIC" clause for each driver.

Reviewed-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agoMerge branch '2021-10-11-TI-platform-updates'
Tom Rini [Tue, 12 Oct 2021 02:39:27 +0000 (22:39 -0400)]
Merge branch '2021-10-11-TI-platform-updates'

- Assorted TI platform updates

3 years agoarm: dts: Update IOT2050 device tree files
Jan Kiszka [Tue, 5 Oct 2021 10:04:50 +0000 (12:04 +0200)]
arm: dts: Update IOT2050 device tree files

This fixes the usage of the USB 3.0-capable port under U-Boot as USB
2.0-only port.

Original patch by Chao Zeng.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
3 years agoboard: siemens: iot2050: Adjust to changes in DT and configuration
Jan Kiszka [Tue, 5 Oct 2021 10:04:49 +0000 (12:04 +0200)]
board: siemens: iot2050: Adjust to changes in DT and configuration

Account for the changes done between merge proposal and the final merge.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
3 years agoARM: omap3_logic: Cleanup usage of MUX_VAL
Adam Ford [Sun, 3 Oct 2021 12:31:14 +0000 (07:31 -0500)]
ARM: omap3_logic: Cleanup usage of MUX_VAL

The macro called MUX_VAL generates a writel instruction with
semicolon at the end.  This table was written to use semicolons,
however one was missed:

   MUX_VAL(CP(SYS_BOOT2),      (IEN  | PTD | DIS | M4))    /* GPIO_4 */

Since the extra semicolon is unnecessary with the use of the macro,
remove all of them, and cleanup whitespace.

Reviewed-by: Wolfgang Denk <wd@denx.de>
Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Adam Ford <aford173@gmail.com>
3 years agoclk: ti: add am33xx/am43xx spread spectrum clock support
Dario Binacchi [Sun, 26 Sep 2021 09:58:58 +0000 (11:58 +0200)]
clk: ti: add am33xx/am43xx spread spectrum clock support

The patch enables spread spectrum clocking (SSC) for MPU and LCD PLLs.
As reported by the TI spruh73x/spruhl7x RM, SSC is only supported for
the DISP/LCD and MPU PLLs on am33xx/am43xx. SSC is not supported for
DDR, PER, and CORE PLLs.

Calculating the required values and setting the registers accordingly
was taken from the set_mpu_spreadspectrum routine contained in the
arch/arm/mach-omap2/am33xx/clock_am33xx.c file of the u-boot project.

In locked condition, DPLL output clock = CLKINP *[M/N]. In case of
SSC enabled, the reference manual explains that there is a restriction
of range of M values. Since the clk_ti_am3_dpll_round_rate() attempts
to select the minimum possible N, the value of M obtained is not
guaranteed to be within the range required. With the new "ti,min-div"
parameter it is possible to increase N and consequently M to satisfy the
constraint imposed by SSC.

Link: https://lore.kernel.org/r/20210606202253.31649-6-dariobin@libero.it
Signed-off-by: Dario Binacchi <dariobin@libero.it>
3 years agoARM: dts: am43xx-clocks: add spread spectrum support
Dario Binacchi [Sun, 26 Sep 2021 09:58:57 +0000 (11:58 +0200)]
ARM: dts: am43xx-clocks: add spread spectrum support

Registers for adjusting the spread spectrum clocking (SSC) have been
added. As reported by the TI spruhl7x RM, SSC is supported only for LCD
and MPU PLLs, but the PRCM_CM_SSC_DELTAMSTEP_DPLL_XXX and
PRCM_CM_SSC_MODFREQDIV_DPLL_XXX registers, as well as the enable field
in the PRCM_CM_CLKMODE_DPLL_XXX registers are mapped for all PLLs (CORE,
MPU, DDR, PER, DISP, EXTDEV).

Link: https://lore.kernel.org/r/20210606202253.31649-5-dariobin@libero.it
Signed-off-by: Dario Binacchi <dariobin@libero.it>
3 years agoARM: dts: am33xx-clocks: add spread spectrum support
Dario Binacchi [Sun, 26 Sep 2021 09:58:56 +0000 (11:58 +0200)]
ARM: dts: am33xx-clocks: add spread spectrum support

Registers for adjusting the spread spectrum clocking (SSC) have been
added. As reported by the TI spruh73x RM, SSC is supported only for LCD
and MPU PLLs, but the CM_SSC_DELTAMSTEP_DPLL_XXX and
CM_SSC_MODFREQDIV_DPLL_XXX registers, as well as the enable field in the
CM_CLKMODE_DPLL_XXX registers are mapped for all PLLs (CORE, MPU, DDR,
PER, DISP).

Link: https://lore.kernel.org/r/20210606202253.31649-4-dariobin@libero.it
Signed-off-by: Dario Binacchi <dariobin@libero.it>
3 years agoconfigs: omap3x_logic: Enable LTO on more LogicPD OMAP3 boards
Adam Ford [Sat, 25 Sep 2021 14:58:25 +0000 (09:58 -0500)]
configs: omap3x_logic: Enable LTO on more LogicPD OMAP3 boards

There are five omap3 based boards from LogicPD.  Two of them
have added LTO support. Add the remaining three to use LTO.

Signed-off-by: Adam Ford <aford173@gmail.com>
3 years agosunxi: Add support for FriendlyARM NanoPi R1S H5
Chukun Pan [Sun, 10 Oct 2021 13:36:57 +0000 (21:36 +0800)]
sunxi: Add support for FriendlyARM NanoPi R1S H5

This adds support for the NanoPi R1S H5 board.

Allwinner H5 SoC
512MB DDR3 RAM
10/100/1000M Ethernet x 2
RTL8189ETV WiFi 802.11b/g/n
USB 2.0 host port (A)
MicroSD Slot
Reset button
Serial Debug Port
WAN - LAN - SYS LED

The dts file is taken from Linux 5.14 tag.

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agoclk: sunxi: Add drivers for A31 and H6 PRCM CCUs
Samuel Holland [Sun, 12 Sep 2021 14:47:25 +0000 (09:47 -0500)]
clk: sunxi: Add drivers for A31 and H6 PRCM CCUs

Add a driver so the clocks/resets for these peripherals (especially I2C,
RSB, and UART) can be enabled using the normal uclass methods.

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>
3 years agoclk: sunxi: Add support for I2C gates/resets
Samuel Holland [Sun, 12 Sep 2021 14:47:24 +0000 (09:47 -0500)]
clk: sunxi: Add support for I2C gates/resets

Currently, the I2C clocks are configured in the sunxi board code. Add
the I2C clocks to the DM clock driver so they can be enabled from the
DM I2C driver using the normal uclass methods.

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>
3 years agosunxi: gpio: Remove bank-specific size macros
Samuel Holland [Sat, 11 Sep 2021 21:50:49 +0000 (16:50 -0500)]
sunxi: gpio: Remove bank-specific size macros

Since the beginning, all banks have had space for 32 pins, even when
not all pins were implemented. Let's use a single constant for the GPIO
bank size here, like the GPIO driver is already doing.

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>
3 years agosunxi: gpio: Remove name_to_gpio macro
Samuel Holland [Sat, 11 Sep 2021 21:50:48 +0000 (16:50 -0500)]
sunxi: gpio: Remove name_to_gpio macro

This clarifies which callers must be updated to complete the DM_GPIO
conversion.

The only remaining caller of name_to_gpio in generic code is inside the
!DM_GPIO block in cmd/gpio.c. DM_GPIO is always selected on sunxi, so
that code cannot be reached. And after this commit, there are only two
remaining implementations of name_to_gpio.

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>
3 years agosunxi: Clean up inclusions of asm/arch/gpio.h
Samuel Holland [Sat, 11 Sep 2021 21:50:47 +0000 (16:50 -0500)]
sunxi: Clean up inclusions of asm/arch/gpio.h

As part of migrating to DM_GPIO and DM_PINCTRL, eventually we will
remove the asm/arch/gpio.h header. In preparation, clean up the various
files that include it.

Some files did not contain any GPIO code at all, so this header was
completely unused.

A few files contained only legacy platform-specific GPIO code for
setting up pin muxes. They were left unchanged, as that code will be
completely removed by the DM_PINCTRL migration.

The remaining files contain some combination of DM_GPIO and legacy GPIO
code. For those, switch to including asm/gpio.h (if it wasn't included
already). Right now, this header provides both sets of functions,
because ARCH_SUNXI selects GPIO_EXTRA_HEADER. This will still be the
right header to include once the DM_GPIO migration is complete and
GPIO_EXTRA_HEADER is no longer needed.

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>
3 years agopinephone_defconfig: add support for early-boot status LED
Arnaud Ferraris [Wed, 8 Sep 2021 19:14:20 +0000 (21:14 +0200)]
pinephone_defconfig: add support for early-boot status LED

This commit enables the green status LED (PD18/GPIO 114) on boot in the
SPL, in order to provide visual feedback that the PinePhone is booting.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Tested-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agoboard: sunxi: enable status LED early
Arnaud Ferraris [Wed, 8 Sep 2021 19:14:19 +0000 (21:14 +0200)]
board: sunxi: enable status LED early

For some systems, such as the PinePhone, there is no way for the end
user to make sure the system is indeed booting before the boot script is
executed, which takes several seconds. Therefore, it can be useful to
provide early visual feedback as soon as possible.

In order achieve this goal, this patch initializes the status LED (if
configured) in the SPL.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agogpio: sunxi: Remove the sunxi_name_to_gpio_bank function
Samuel Holland [Sun, 12 Sep 2021 15:28:36 +0000 (10:28 -0500)]
gpio: sunxi: Remove the sunxi_name_to_gpio_bank function

The only caller of this function was the MMC pinmux code, which used it
to parse a string given from a Kconfig symbol. As the Kconfig symbol has
been converted to a Boolean, this function is no longer needed.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agosunxi: Simplify MMC pinmux selection
Samuel Holland [Sun, 12 Sep 2021 15:28:35 +0000 (10:28 -0500)]
sunxi: Simplify MMC pinmux selection

Only one board, Yones Toptech BD1078, actually uses a non-default MMC
pinmux. All other uses of these symbols select the default value or an
invalid value. To simplify things, remove support for the unused pinmux
options, and convert the remaining option to a Boolean.

This allows the pinmux to be chosen by the preprocessor, instead of
having the code parse a string at runtime (for a build-time option!).
Not only does this reduce code size, but it also allows this Kconfig
option to be used in a table-driven DM 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>
3 years agoclk: sunxi: Move header out of arch directory
Samuel Holland [Sun, 12 Sep 2021 16:48:43 +0000 (11:48 -0500)]
clk: sunxi: Move header out of arch directory

The CCU header is only used by the DM drivers, not any platform code.
Its current location adds an artificial dependency on CONFIG_ARM and
ARCH_SUNXI, which will be problematic when adding the CCU driver for
a RISC-V sunxi platform.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agoconfigs: add PineTab defconfig
Arnaud Ferraris [Mon, 6 Sep 2021 21:06:13 +0000 (23:06 +0200)]
configs: add PineTab defconfig

The PineTab device-tree is already in u-boot, this commit adds the
corresponding defconfig, based on pinephone_defconfig.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
3 years agoMerge tag 'video-20211009' of https://source.denx.de/u-boot/custodians/u-boot-video
Tom Rini [Sat, 9 Oct 2021 21:47:27 +0000 (17:47 -0400)]
Merge tag 'video-20211009' of https://source.denx.de/u-boot/custodians/u-boot-video

 - add 30bpp support (EFI, simplefb, vidconsole)
 - fix video console name in CONSOLE_MUX Kconfig help
 - move mxsfb driver config option to Kconfig
 - remove unused mx3fb driver

# gpg verification failed.

3 years agovideo: move MXS to Kconfig
Anatolij Gustschin [Mon, 4 Oct 2021 15:33:12 +0000 (17:33 +0200)]
video: move MXS to Kconfig

Move CONFIG_VIDEO_MXS from board headers to Kconfig
and drop it from obsolete cfb_console driver.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
3 years agovideo: remove not used mx3fb driver
Anatolij Gustschin [Mon, 4 Oct 2021 15:07:14 +0000 (17:07 +0200)]
video: remove not used mx3fb driver

i.MX31 support was removed, and the non dm-video driver
is obsolete and not used. Remove it.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
3 years agocommon: Kconfig: use 'vidconsole' name instead of old 'video'
Anatolij Gustschin [Mon, 4 Oct 2021 14:04:32 +0000 (16:04 +0200)]
common: Kconfig: use 'vidconsole' name instead of old 'video'

After DM_VIDEO conversion the 'vidconsole' is the correct name
for the frame buffer console. 'video' will not work, so update
the description of the config option.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
3 years agolz4: Use a private header for U-Boot
Simon Glass [Sat, 9 Oct 2021 15:28:21 +0000 (09:28 -0600)]
lz4: Use a private header for U-Boot

At present U-Boot has a header file called lz4.h for its own use. If the
host has its own lz4 header file installed (e.g. from the 'liblz4-dev'
package) then host builds will use that instead.

Move the U-Boot file into its own directory, as is done with various
other headers with the same problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoefi_loader: GOP: Fix 30bpp block transfer support
Mark Kettenis [Sat, 25 Sep 2021 20:47:39 +0000 (22:47 +0200)]
efi_loader: GOP: Fix 30bpp block transfer support

Convert pixel values when necessary like we do for 16bpp
framebuffers.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agovideo: simplefb: Add 30bpp support
Mark Kettenis [Sat, 25 Sep 2021 20:47:38 +0000 (22:47 +0200)]
video: simplefb: Add 30bpp support

Recognize the canonical format strings for framebuffers in
30bpp mode and 32/24bpp mode.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
3 years agoefi_loader: GOP: Add 30bpp support
Mark Kettenis [Sat, 25 Sep 2021 20:47:37 +0000 (22:47 +0200)]
efi_loader: GOP: Add 30bpp support

Provide correct framebuffer information for 30bpp modes.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
3 years agovideo: Add 30bpp support
Mark Kettenis [Sat, 25 Sep 2021 20:47:36 +0000 (22:47 +0200)]
video: Add 30bpp support

Add support for 30bpp mode where pixels are picked in 32-bit
integers but use 10 bits instead of 8 bits for each component.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
3 years agoMerge branch '2021-10-08-image-cleanups'
Tom Rini [Fri, 8 Oct 2021 20:02:55 +0000 (16:02 -0400)]
Merge branch '2021-10-08-image-cleanups'

- A large number of image file and tooling related cleanups

3 years agoimage: Split up boot_get_fdt()
Simon Glass [Sun, 26 Sep 2021 01:43:41 +0000 (19:43 -0600)]
image: Split up boot_get_fdt()

This function is far too long. Before trying to remove #ifdefs, split out
the code that deals with selecting the FDT into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Reduce variable scope in boot_get_fdt()
Simon Glass [Sun, 26 Sep 2021 01:43:40 +0000 (19:43 -0600)]
image: Reduce variable scope in boot_get_fdt()

Move the variables declarations to where they are needed, to reduce the
number of #ifdefs needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Remove some #ifdefs from image-fit and image-fit-sig
Simon Glass [Sun, 26 Sep 2021 01:43:39 +0000 (19:43 -0600)]
image: Remove some #ifdefs from image-fit and image-fit-sig

Drop the #ifdefs which are easy to remove without refactoring.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Remove #ifdefs from select_ramdisk()
Simon Glass [Sun, 26 Sep 2021 01:43:38 +0000 (19:43 -0600)]
image: Remove #ifdefs from select_ramdisk()

Use boolean variables to deal with the strange #ifdef logic of this
function, so we can remove the #ifdefs.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Split up boot_get_ramdisk()
Simon Glass [Sun, 26 Sep 2021 01:43:37 +0000 (19:43 -0600)]
image: Split up boot_get_ramdisk()

This function is far too long. Before trying to remove #ifdefs, split out
the code that deals with selecting the ramdisk into a separate function.

Leave the code indented as it was for easier review. The next patch cleans
this up along with checkpatch violations.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Reduce variable scope in boot_get_ramdisk()
Simon Glass [Sun, 26 Sep 2021 01:43:36 +0000 (19:43 -0600)]
image: Reduce variable scope in boot_get_ramdisk()

Move the variables declarations to where they are needed, to reduce the
number of #ifdefs needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Drop most #ifdefs in image-board.c
Simon Glass [Sun, 26 Sep 2021 01:43:35 +0000 (19:43 -0600)]
image: Drop most #ifdefs in image-board.c

Remove ifdefs in this file, so far as possible without too much
refactoring.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Drop #ifdefs for fit_print_contents()
Simon Glass [Sun, 26 Sep 2021 01:43:34 +0000 (19:43 -0600)]
image: Drop #ifdefs for fit_print_contents()

Use a simple return to drop the unwanted code.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Drop unnecessary #ifdefs from image.h
Simon Glass [Sun, 26 Sep 2021 01:43:33 +0000 (19:43 -0600)]
image: Drop unnecessary #ifdefs from image.h

This file has a lot of conditional code and much of it is unnecessary.
Clean this up to reduce the number of build combinations.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Tidy up fit_unsupported_reset()
Simon Glass [Sun, 26 Sep 2021 01:43:32 +0000 (19:43 -0600)]
image: Tidy up fit_unsupported_reset()

This function is only used in one place and does not need to use the
preprocessor. Move it to the C file and convert it to a normal function.

Drop fit_unsupported() since it is not used.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoefi: Correct dependency on FIT_SIGNATURE
Simon Glass [Sun, 26 Sep 2021 01:43:29 +0000 (19:43 -0600)]
efi: Correct dependency on FIT_SIGNATURE

At present EFI_SECURE BOOT selects RSA but does not necessarily enable
FIT_SIGNATURE. Mostly this is fine, but a few boards do not enable it,
so U-Boot tries to do RSA verification when loading FIT images, but it
is not enabled.

This worked because the condition for checking the RSA signature is
wrong in the fit_image_verify_with_data() function. In order to fix it
we need to fix this dependency. Make sure that FIT_SIGNATURE is enabled
so that RSA can be used.

It might be better to avoid using 'select' in this situation.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Drop IMAGE_ENABLE_IGNORE
Simon Glass [Sun, 26 Sep 2021 01:43:28 +0000 (19:43 -0600)]
image: Drop IMAGE_ENABLE_IGNORE

We can use the new host_build() function for this, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Drop IMAGE_OF_SYSTEM_SETUP
Simon Glass [Sun, 26 Sep 2021 01:43:27 +0000 (19:43 -0600)]
image: Drop IMAGE_OF_SYSTEM_SETUP

This is not needed with Kconfig, since we can use IS_ENABLED() easily
enough. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Drop IMAGE_OF_BOARD_SETUP
Simon Glass [Sun, 26 Sep 2021 01:43:26 +0000 (19:43 -0600)]
image: Drop IMAGE_OF_BOARD_SETUP

This is not needed with Kconfig, since we can use IS_ENABLED() easily
enough. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Drop IMAGE_BOOT_GET_CMDLINE
Simon Glass [Sun, 26 Sep 2021 01:43:25 +0000 (19:43 -0600)]
image: Drop IMAGE_BOOT_GET_CMDLINE

This is not needed with Kconfig, since we can use IS_ENABLED() easily
enough and the board code is now in a separate file. Update the only place
where this is used and drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Use the correct checks for CRC32
Simon Glass [Sun, 26 Sep 2021 01:43:24 +0000 (19:43 -0600)]
image: Use the correct checks for CRC32

Add a host Kconfig for CRC32. With this we can use CONFIG_IS_ENABLED(CRC32)
directly in the host build, so drop the unnecessary indirection.

Add a few more conditions to SPL_CRC32 to avoid build failures as well as
TPL_CRC32. Also update hash.c to make crc32 optional and to actually take
notice of SPL_CRC32.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Use Kconfig to enable FIT_RSASSA_PSS on host
Simon Glass [Sun, 26 Sep 2021 01:43:23 +0000 (19:43 -0600)]
image: Use Kconfig to enable FIT_RSASSA_PSS on host

Add a host Kconfig for FIT_RSASSA_PSS. With this we can use
CONFIG_IS_ENABLED(FIT_RSASSA_PSS) directly in the host build, so drop the
forcing of this in the image.h header.

Drop the #ifdef around padding_pss_verify() too since it is not needed.
Use the compiler to check the config where possible, instead of the
preprocessor.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Use Kconfig to enable CONFIG_FIT_VERBOSE on host
Simon Glass [Sun, 26 Sep 2021 01:43:22 +0000 (19:43 -0600)]
image: Use Kconfig to enable CONFIG_FIT_VERBOSE on host

Add a host Kconfig for FIT_VERBOSE. With this we can use
CONFIG_IS_ENABLED(FIT_VERBOSE) directly in the tools build, so drop the
forcing of this in the image.h header.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Drop IMAGE_ENABLE_OF_LIBFDT
Simon Glass [Sun, 26 Sep 2021 01:43:21 +0000 (19:43 -0600)]
image: Drop IMAGE_ENABLE_OF_LIBFDT

Add a host Kconfig for OF_LIBFDT. With this we can use
CONFIG_IS_ENABLED(OF_LIBFDT) directly in the tools build, so drop the
unnecessary indirection.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Drop IMAGE_ENABLE_FIT
Simon Glass [Sun, 26 Sep 2021 01:43:20 +0000 (19:43 -0600)]
image: Drop IMAGE_ENABLE_FIT

Make use of the host Kconfig for FIT. With this we can use
CONFIG_IS_ENABLED(FIT) directly in the host build, so drop the unnecessary
indirection.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agohash: Drop some #ifdefs in hash.c
Simon Glass [Sun, 26 Sep 2021 01:43:19 +0000 (19:43 -0600)]
hash: Drop some #ifdefs in hash.c

We can use the __maybe_unused attribute to avoid some of the #ifdefs in
this file. Update the functions accordingly.

Note: The actual hashing interface is still a mess, with four separate
combinations and lots of #ifdefs. This should really use a driver
approach, e.g. as is done with partition drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agohash: Use Kconfig to enable hashing in host tools and SPL
Simon Glass [Sun, 26 Sep 2021 01:43:18 +0000 (19:43 -0600)]
hash: Use Kconfig to enable hashing in host tools and SPL

At present when building host tools, we force CONFIG_SHAxxx to be enabled
regardless of the board Kconfig setting. This is done in the image.h
header file.

For SPL we currently just assume the algorithm is desired if U-Boot proper
enables it.

Clean this up by adding new Kconfig options to enable hashing on the host,
relying on CONFIG_IS_ENABLED() to deal with the different builds.

Add new SPL Kconfigs for hardware-accelerated hashing, to maintain the
current settings.

This allows us to drop the image.h code and the I_WANT_MD5 hack.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agospl: cypto: Bring back SPL_ versions of SHA
Simon Glass [Sun, 26 Sep 2021 01:43:17 +0000 (19:43 -0600)]
spl: cypto: Bring back SPL_ versions of SHA

Unfortunately these were removed by mistake. This means that adding hash
support to SPL brings in all software algorithms, with a substantial
increase in code size.

The origin of the problem was renaming them to SPL_FIT_xxx and then these
were removed altogether in a later commit.

Add them back. This aligns with CONFIG_MD5, for example, which has an SPL
variant.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: f5bc9c25f31 ("image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxx")
Fixes: eb5171ddec9 ("common: Remove unused CONFIG_FIT_SHAxxx selectors")
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Add Kconfig options for FIT in the tools build
Simon Glass [Sun, 26 Sep 2021 01:43:16 +0000 (19:43 -0600)]
image: Add Kconfig options for FIT in the tools build

In preparation for enabling CONFIG_IS_ENABLED() on the host build, add
some options to enable the various FIT options expected in these tools.
This will ensure that the code builds correctly when CONFIG_TOOLS_xxx
is distinct from CONFIG_xxx.

Drop some #ifdefs which are immediately unnecessary (many more are in
later patches).

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agokconfig: Add tools support to CONFIG_IS_ENABLED()
Simon Glass [Sun, 26 Sep 2021 01:43:15 +0000 (19:43 -0600)]
kconfig: Add tools support to CONFIG_IS_ENABLED()

At present we must separately test for the host build for many options,
since we force them to be enabled. For example, CONFIG_FIT is always
enabled in the host tools, even if CONFIG_FIT is not enabled by the
board itself.

It would be more convenient if we could use, for example,
CONFIG_IS_ENABLED(FIT) and get CONFIG_HOST_FIT, when building for the
host. Add support for this.

With this and the tools_build() function, we should be able to remove all
the #ifdefs currently needed in code that is build by tools and targets.

This will be even nicer when we move to using CONFIG(xxx) everywhere,
since all the #ifdef and IS_ENABLED/CONFIG_IS_ENABLED stuff will go away.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> # b4f73886
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agocompiler: Rename host_build() to tools_build()
Simon Glass [Sun, 26 Sep 2021 01:43:14 +0000 (19:43 -0600)]
compiler: Rename host_build() to tools_build()

With the new TOOLS_LIBCRYPTO and some other changes, it seems that we are
heading towards calling this a tools build rather than a host build,
although of course it does happen on the host.

I cannot think of anything built by the host which cannot be described as
a tool, so rename this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
3 years agoimage: Remove ifdefs around image_setup_linux() el at
Simon Glass [Sat, 25 Sep 2021 13:03:20 +0000 (07:03 -0600)]
image: Remove ifdefs around image_setup_linux() el at

Drop some more ifdefs in image-board.c and also the FPGA part of bootm.c
which calls into it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Avoid #ifdefs for manual relocation
Simon Glass [Sat, 25 Sep 2021 13:03:19 +0000 (07:03 -0600)]
image: Avoid #ifdefs for manual relocation

Add a macro to handle manually relocating a pointer. Update the iamge code
to use this to avoid needing #ifdefs.

This also fixes a bug where the 'done' flag was not set.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Create a function to do manual relocation
Simon Glass [Sat, 25 Sep 2021 13:03:18 +0000 (07:03 -0600)]
image: Create a function to do manual relocation

Rather than adding an #ifdef and open-coding this calculation, add a
helper function to handle it. Use this in the image code.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Split host code out into its own file
Simon Glass [Sat, 25 Sep 2021 13:03:17 +0000 (07:03 -0600)]
image: Split host code out into its own file

To avoid having #ifdefs in a few functions which are completely different
in the board and host code, create a new image-host.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Fix up checkpatch warnings in image-board.c
Simon Glass [Sat, 25 Sep 2021 13:03:16 +0000 (07:03 -0600)]
image: Fix up checkpatch warnings in image-board.c

Tidy up the warnings.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Split board code out into its own file
Simon Glass [Sat, 25 Sep 2021 13:03:15 +0000 (07:03 -0600)]
image: Split board code out into its own file

To avoid a large #ifdef in the image.c file, move the affected code into
a separate file.

Avoid any style fix-ups for easier review. Those are in the next patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Update image_decomp() to avoid ifdefs
Simon Glass [Sat, 25 Sep 2021 13:03:14 +0000 (07:03 -0600)]
image: Update image_decomp() to avoid ifdefs

Adjust this function so that preprocessor macros are not needed. With
this, the host build uses more of the same header files as the target
build.

Rather than definining CONFIG_SYS_MALLOC_LEN, add a CONSERVE_MEMORY
define, since that is the purpose of the value.

This appears to have no impact on code size from a spot check of a few
boards (snow, firefly-rk3288, boston32r2el, m53menlo).

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agogzip: Avoid use of u64
Simon Glass [Sat, 25 Sep 2021 13:03:13 +0000 (07:03 -0600)]
gzip: Avoid use of u64

The gzip API uses the u64 type in it, which is not available in the host
build. This makes it impossible to include the header file.

We could make this type available, but it seems unnecessary. Limiting the
compression size to that of the 'unsigned long' type seems good enough. On
32-bit machines the limit then becomes 4GB, which likely exceeds available
RAM anyway, therefore it should be sufficient. On 64-bit machines this is
effectively u64 anyway.

Update the header file and implementation to use 'ulong' instead of 'u64'.

Add a definition of u32 for the cases that seem to need exactly that
length. This should be safe enough.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Update zstd to avoid reporting error twice
Simon Glass [Sat, 25 Sep 2021 13:03:12 +0000 (07:03 -0600)]
image: Update zstd to avoid reporting error twice

The zstd implementation prints the error in image_decomp() which is
incorrect and does not match other algorithms. Drop this and let the
caller report the error.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoimage: Avoid switch default in image_decomp()
Simon Glass [Sat, 25 Sep 2021 13:03:11 +0000 (07:03 -0600)]
image: Avoid switch default in image_decomp()

At present this function is full of preprocessor macros. Adjust it to
check for an unsupported algorithm after the switch(). This will allow
us to drop the macros.

Fix up the return-value path and an extra blank line while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobtrfs: Use U-Boot API for decompression
Simon Glass [Sat, 25 Sep 2021 13:03:10 +0000 (07:03 -0600)]
btrfs: Use U-Boot API for decompression

Use the common function to avoid code duplication.

Acked-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agozstd: Create a function for use from U-Boot
Simon Glass [Sat, 25 Sep 2021 13:03:09 +0000 (07:03 -0600)]
zstd: Create a function for use from U-Boot

The existing zstd API requires the same sequence of calls to perform its
task. Create a helper for U-Boot, to avoid code duplication, as is done
with other compression algorithms. Make use of of this from the image
code.

Note that the zstd code lacks a test in test/compression.c and this should
be added by the maintainer.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocompiler: Add a comment to host_build()
Simon Glass [Sat, 25 Sep 2021 13:03:08 +0000 (07:03 -0600)]
compiler: Add a comment to host_build()

This function should have a comment explaining what it does. Add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoAdd support for an owned buffer
Simon Glass [Sat, 25 Sep 2021 13:03:07 +0000 (07:03 -0600)]
Add support for an owned buffer

When passing a data buffer back from a function, it is not always clear
who owns the buffer, i.e. who is responsible for freeing the memory used.
An example of this is where multiple files are decompressed from the
firmware image, using a temporary buffer for reading (since the
compressed data has to live somewhere) and producing a temporary or
permanent buffer with the resuilts.

Where the firmware image can be memory-mapped, as on x86, the compressed
data does not need to be buffered, but the complexity of having a buffer
which is either allocated or not, makes the code hard to understand.

Introduce a new 'abuf' which supports simple buffer operations:

- encapsulating a buffer and its size
- either allocated with malloc() or not
- able to be reliably freed if necessary
- able to be converted to an allocated buffer if needed

This simple API makes it easier to deal with allocated and memory-mapped
buffers.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agolib: Add memdup()
Simon Glass [Sat, 25 Sep 2021 13:03:06 +0000 (07:03 -0600)]
lib: Add memdup()

Add a function to duplicate a memory region, a little like strdup().

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Fri, 8 Oct 2021 12:02:47 +0000 (08:02 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- a37xx: pci: Increase PCIe IO size from 64 KiB to 1 MiB (Pali)
- phy: marvell: a3700: Misc improvements (Pali)
- a38x serdes cleanup (Pali)
- A3720 PCIe enhancements (Pali & Marek)
- mvebu: mvebu_armada-8k: Puzzle M801 enhancements (Robert)
- mvebu: x530: Remove custom kwbimage.cfg (Chris)
- mvebu: Select SPL_SKIP_LOWLEVEL_INIT on ARMADA_32BIT (Stefan)

3 years agoboard: dh_stm32mp1: Remove gpio_hog_probe_all() from board
Patrice Chotard [Wed, 1 Sep 2021 09:51:43 +0000 (11:51 +0200)]
board: dh_stm32mp1: Remove gpio_hog_probe_all() from board

DM_GPIO_HOG flag has been replaced by GPIO_HOG flag since a while in
commit 49b10cb49262 ("gpio: fixes for gpio-hog support").

And furthermore, gpio_hog_probe_all() is already called in board_r.c.
So gpio_hog_probe() can be removed from stm32mp1.c.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Marek Vasut <marex@denx.de>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoboard: stm32mp1: Remove gpio_hog_probe_all() from board
Patrice Chotard [Wed, 1 Sep 2021 09:51:42 +0000 (11:51 +0200)]
board: stm32mp1: Remove gpio_hog_probe_all() from board

DM_GPIO_HOG flag has been replaced by GPIO_HOG flag since a while in
commit 49b10cb49262 ("gpio: fixes for gpio-hog support").

And furthermore, gpio_hog_probe_all() is already called in board_r.c.
So gpio_hog_probe() can be removed from stm32mp1.c.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 years agoi2c: stm32f7: compute i2cclk only one time
Patrick Delaunay [Tue, 3 Aug 2021 10:05:15 +0000 (12:05 +0200)]
i2c: stm32f7: compute i2cclk only one time

Compute i2cclk only one time in stm32_i2c_compute_timing()
and remove setup parameter (accessible in i2c_priv).

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
3 years agoi2c: stm32f7: add support for DNF i2c-digital-filter binding
Patrick Delaunay [Tue, 3 Aug 2021 10:05:14 +0000 (12:05 +0200)]
i2c: stm32f7: add support for DNF i2c-digital-filter binding

Add the support for the i2c-digital-filter binding, allowing to enable
the digital filter via the device-tree and indicate its value in the DT

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
3 years agoi2c: stm32f7: fix configuration of the digital filter
Patrick Delaunay [Tue, 3 Aug 2021 10:05:13 +0000 (12:05 +0200)]
i2c: stm32f7: fix configuration of the digital filter

The digital filter related computation are present in the driver
however the programming of the filter within the IP is missing.
The maximum value for the DNF is wrong and should be 15 instead of 16.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>