oweals/u-boot.git
4 years agoConvert CONFIG_SHOW_BOOT_PROGRESS to Kconfig
Simon Glass [Sun, 21 Jul 2019 02:51:12 +0000 (20:51 -0600)]
Convert CONFIG_SHOW_BOOT_PROGRESS to Kconfig

This converts the following to Kconfig:
   CONFIG_SHOW_BOOT_PROGRESS

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agomain: Use conditional run_preboot_environment_command()
Simon Glass [Sun, 21 Jul 2019 02:51:11 +0000 (20:51 -0600)]
main: Use conditional run_preboot_environment_command()

The function name indicates that it does something, but its entire
operation is actually condition on a CONFIG. Move the condition outside
the function so this is clearer, and use if() instead of #ifdef, like the
reset of the file.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agoMerge tag 'u-boot-amlogic-20190731' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Wed, 31 Jul 2019 20:06:24 +0000 (16:06 -0400)]
Merge tag 'u-boot-amlogic-20190731' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic

- sync Amlogic G12A DT with linux 5.3-rc1
- add support for 4GiB DRAM memory
- add support for Amlogic G12B based Odroid-N2
- small duplicate logic fix for gxbb clock driver

4 years agoMerge branch '2019-07-31-ti-imports'
Tom Rini [Wed, 31 Jul 2019 18:20:55 +0000 (14:20 -0400)]
Merge branch '2019-07-31-ti-imports'

- Various DaVinci fixes
- Migrate am335x_boneblack_vboot to use more DM drivers
- Keystone updates

4 years agoRevert "ARM: davinci: da850: Manual pinmux only when PINCTRL not available"
Adam Ford [Wed, 31 Jul 2019 14:17:31 +0000 (09:17 -0500)]
Revert "ARM: davinci: da850: Manual pinmux only when PINCTRL not available"

This reverts commit 877ab2423bc257045a06bc23d4b9440b82bda6fb.

The above patch was designed to shrink code by only pin-muxing items
needed for SPL in SPL and relying on driver model or SPL to mux other
items.  Unfortunately, da850evm_direct_nor doesn't use SPL so items
that were only muxed during SPL are not muxed causing the board
to no longer boot.

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agonand: davinci: avoid out of bounds array access
Heinrich Schuchardt [Tue, 30 Jul 2019 21:29:21 +0000 (23:29 +0200)]
nand: davinci: avoid out of bounds array access

The array bounds have to be checked before accessing the array element.

Identified by cppcheck.

Fixes: 67ac6ffaeefb ("mtd: nand: davinci: add opportunity to write keystone U-boot image")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agoARM: da850-evm: Remove references to CONFIG_DA850_AM18X_EVM
Adam Ford [Tue, 30 Jul 2019 13:58:58 +0000 (08:58 -0500)]
ARM: da850-evm: Remove references to CONFIG_DA850_AM18X_EVM

With the removal of da850_am18xxevm, there is at least one
whitelisted CONFIG option that can be deleted.  This patch
removes CONFIG_DA850_AM18X_EVM since it's not required any more

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agoARM: dts: da850-evm: Fix MDIO pinmux
Adam Ford [Tue, 30 Jul 2019 13:32:37 +0000 (08:32 -0500)]
ARM: dts: da850-evm: Fix MDIO pinmux

In attempts to speed up SPL and reduce size, the MDIO pin muxing
was inadvertently affected.  Since the ethernet driver will setup
the pin muxing when ethernet is loaded, this patch will also
pinmux the MDIO pins at the same time.  Once an DM compatible
MDIO driver is available, this  can be removed.

Fixes: 877ab2423bc2 ("ARM: davinci: da850: Manual pinmux only
when PINCTRL not available")

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agoconfigs: am335x_boneblack_vboot_defconfig: Add DM for SPI and Flash devices
Suniel Mahesh [Tue, 30 Jul 2019 07:55:21 +0000 (13:25 +0530)]
configs: am335x_boneblack_vboot_defconfig: Add DM for SPI and Flash devices

This patch adds SPI and SPI_FLASH DM support for verified boot on
TI AM335 chipsets. The following compile warning is removed:

===================== WARNING ======================
This board does not use CONFIG_DM_SPI_FLASH. Please update
the board to use CONFIG_SPI_FLASH before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================

Built and tested on AM335x device (BeagleboneBlack).

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
4 years agoconfigs: am335x_boneblack_vboot_defconfig: Fix regression by enabling BLK and DM...
Suniel Mahesh [Tue, 30 Jul 2019 07:55:20 +0000 (13:25 +0530)]
configs: am335x_boneblack_vboot_defconfig: Fix regression by enabling BLK and DM support, disable in SPL

This patch adds BLK and DM support for verified boot on TI AM335x
chipsets. The following compile warnings are removed:

===================== WARNING ======================
This board does not use CONFIG_DM_MMC. Please update
the board to use CONFIG_DM_MMC before the v2019.04 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_USB. Please update
the board to use CONFIG_DM_USB before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================

BLK and DM_MMC are enabled by default in SPL as well, which is
making the build to break with an overflow(spl image doesn't
fit into SRAM because of size constraints).

  LD      spl/drivers/built-in.o
  LD      spl/u-boot-spl
arm-linux-ld.bfd: u-boot-spl section .u_boot_list will not fit in region .sram
arm-linux-ld.bfd: region .sram overflowed by 116 bytes
make[1]: *** [spl/u-boot-spl] Error 1
make: *** [spl/u-boot-spl] Error 2

For the above reason BLK and DM_MMC is disabled in SPL.
Built and tested on AM335x device (BeagleboneBlack).

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
4 years agoconfigs: j721e_evm_a72: Disable K3_SYSTEM_CONTROLLER
Suman Anna [Mon, 29 Jul 2019 16:48:03 +0000 (11:48 -0500)]
configs: j721e_evm_a72: Disable K3_SYSTEM_CONTROLLER

The K3 System Controller driver is used for loading and starting
the System Firmware, and is used only on R5 SPL. It need not be
enabled and built for the A72 U-Boot and SPL, so disable it from
the j721e_evm_a72 defconfig.

While at this, also remove the unneeded CONFIG_SPL_REMOTEPROC and
CONFIG_CMD_REMOTEPROC as no remoteprocs are now loaded from A72 SPL.

Signed-off-by: Suman Anna <s-anna@ti.com>
4 years agoconfigs: am65x_evm_a53: Disable K3_SYSTEM_CONTROLLER
Suman Anna [Mon, 29 Jul 2019 16:48:02 +0000 (11:48 -0500)]
configs: am65x_evm_a53: Disable K3_SYSTEM_CONTROLLER

The K3 System Controller driver is used for loading and starting
the System Firmware, and is used only on R5 SPL. It need not be
enabled and built for the A53 U-Boot and SPL, so disable it from
both the GP and HS AM65x A53 defconfigs.

While at this, also remove the unneeded CONFIG_SPL_REMOTEPROC and
CONFIG_CMD_REMOTEPROC as no remoteprocs are now loaded from A53 SPL.

Signed-off-by: Suman Anna <s-anna@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agoarm: dts: k3-am654-base-board: Fix cpsw_nuss power-domains property
Suman Anna [Mon, 29 Jul 2019 16:13:41 +0000 (11:13 -0500)]
arm: dts: k3-am654-base-board: Fix cpsw_nuss power-domains property

The commit 355be915ed08 ("arm: dts: k3-am654: Update power-domains
property for each node") has updated the power-domain cells value
and updated power-domains property in various existing dts nodes but
missed updating the cpsw_nuss node. This results in the following
build warning, fix this.

arch/arm/dts/k3-am654-base-board.dtb: Warning (power_domains_property): /interconnect@100000/interconnect@28380000/cpsw_nuss@046000000:power-domains: property size (8) too small for cell size 2
arch/arm/dts/k3-am654-r5-base-board.dtb: Warning (power_domains_property): /interconnect@100000/interconnect@28380000/cpsw_nuss@046000000:power-domains: property size (8) too small for cell size 2

Fixes: 355be915ed08 ("arm: dts: k3-am654: Update power-domains property for each node")
Signed-off-by: Suman Anna <s-anna@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agoARM: da850-evm: Replace CMD_SF with CMD_MTD
Adam Ford [Fri, 26 Jul 2019 23:31:13 +0000 (18:31 -0500)]
ARM: da850-evm: Replace CMD_SF with CMD_MTD

This patch enables MTD and CMD_MTD and it works with SPI NOR,
so the older CMD_SF can be removed.

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agoARM: da850evm: Split MTDPARTS into SPL and u-boot
Adam Ford [Fri, 26 Jul 2019 22:53:45 +0000 (17:53 -0500)]
ARM: da850evm: Split MTDPARTS into SPL and u-boot

The MTDPARTS currently lists just u-boot.ais as 512k in size.
This works when loading the ais file via serial port, but if one
wanted to update just the u-boot portion, it's not really possible.
This patch splits the MTDPARTS into a 32k SPL partiion and a 480k
u-boot partition which allows u-boot.img to be burned to the u-boot
partition.  The remaining partitions are left with the same sizes
and offsets to not break backwards compatibility.

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agoconfigs: am57xx_evm_defconfig: Enable 'dtimg' command
Sam Protsenko [Thu, 25 Jul 2019 17:20:19 +0000 (20:20 +0300)]
configs: am57xx_evm_defconfig: Enable 'dtimg' command

We are going to implement DTBO partition for BeagleBoard X15 further. To
support this, 'dtimg' command must be enabled.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
4 years agoconfigs: am57xx_evm_defconfig: Enable 'bcb' command
Sam Protsenko [Thu, 25 Jul 2019 17:20:18 +0000 (20:20 +0300)]
configs: am57xx_evm_defconfig: Enable 'bcb' command

It is essential to have an access to BCB area of 'misc' partition on
Android devices [1]. For BeagleBoard X15 the 'bcb' command will be
further used for reboot reason implementation and booting to recovery.
It can be also used for debugging reasons, like checking RescueParty
messages in BCB area.

[1] doc/android/bcb.txt

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
4 years agoomap: Correct the fastboot product var
Sam Protsenko [Thu, 25 Jul 2019 17:11:53 +0000 (20:11 +0300)]
omap: Correct the fastboot product var

"fastboot flashall" expects "fastboot getvar product" value to be one of
values provided in android-info.txt file (in AOSP), from "require
board=" list. Before this patch, "am57xx" is returned for all AM57xx
based boards, as it's set in $board env var from SYS_BOARD in
board/ti/am57xx/Kconfig file, which is used for default implementation
of "fastboot getvar product".

In order to fix that inconsistency, let's do next:
  1. In U-Boot: override fastboot.product, reusing the value from
     $board_name
  2. In AOSP: provide values for all AM57xx boards we can use to
     device/ti/beagle_x15/board-info.txt file

This way requirements check in "fastboot flashall" will work as
expected, verifying that user tries to flash images to the board which
those images were built for.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Acked-by: Andrew F. Davis <afd@ti.com>
4 years agoenv: ti: boot: Handle reboot reason from BCB
Sam Protsenko [Thu, 25 Jul 2019 13:20:41 +0000 (16:20 +0300)]
env: ti: boot: Handle reboot reason from BCB

In case of Android boot, reboot reason can be written into BCB (usually
it's an area in 'misc' partition). U-Boot then can obtain that reboot
reason from BCB and handle it accordingly to achieve correct Android
boot flow, like it was suggested in [1]:
  - if it's empty: perform normal Android boot from eMMC
  - if it contains "bootonce-bootloader": get into fastboot mode
  - if it contains "boot-recovery": perform recovery boot

The latter is not implemented yet, as it depends on some features that
are not implemented on TI platforms yet (in AOSP and in U-Boot).

[1] https://marc.info/?l=u-boot&m=152508418909737&w=2

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
4 years agoMerge tag 'mmc-7-31' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc
Tom Rini [Wed, 31 Jul 2019 12:34:35 +0000 (08:34 -0400)]
Merge tag 'mmc-7-31' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmc

A new mmc/sd block test case
Bug fixes for sdhci and mv_sdhci

4 years agoclk: meson: remove duplicate logic
Heinrich Schuchardt [Tue, 30 Jul 2019 21:03:43 +0000 (23:03 +0200)]
clk: meson: remove duplicate logic

First thing we check in meson_clk_set_rate_by_id() is current_rate == rate.
There is not need to check it again.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
4 years agoboard: amlogic: add support for Odroid-N2
Neil Armstrong [Mon, 22 Jul 2019 09:36:14 +0000 (11:36 +0200)]
board: amlogic: add support for Odroid-N2

ODROID-N2 is a single board computer manufactured by Hardkernel Co. Ltd
with the following specifications:

 - Amlogic S922X ARM Cortex-A53 dual-core + Cortex-A73 quad-core SoC
 - 4GB DDR4 SDRAM
 - Gigabit Ethernet
 - HDMI 2.1 4K/60Hz display
 - 40-pin GPIO header
 - 4 x USB 3.0 Host, 1 x USB OTG
 - eMMC, microSD
 - Infrared receiver

The board directory is W400, the name of the Amlogic Reference Design
of Amlogic G12B with Gigabit boards, which will be used for similar
boards.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Mark Kettenis <kettenis@openbsd.org>
4 years agoARM: meson-g12a: Handle 4GiB DRAM size
Neil Armstrong [Mon, 22 Jul 2019 09:32:50 +0000 (11:32 +0200)]
ARM: meson-g12a: Handle 4GiB DRAM size

When configured with 4GiB DRAM size, only 3.8GiB is available, the
I/O beeing mapped in the last 256MiB of the first 4GiB physical memory/

First fixup the mm_region to handle the first 3.8GiB as memory and the
last 256MiB as I/O.

Then limit the real memory reported by the firmware to the available
physical space, 3.8GiB aligned with the mm_region memory zone size.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Mark Kettenis <kettenis@openbsd.org>
4 years agoARM: dts: add support for Odroid-N2
Neil Armstrong [Mon, 22 Jul 2019 09:27:59 +0000 (11:27 +0200)]
ARM: dts: add support for Odroid-N2

Import HardKernel Odroid-N2 DT from Linux 5.3-rc1, commit 5f9e832c1370
("Linus 5.3-rc1") based on an Amlogic G12B S922X SoC.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Mark Kettenis <kettenis@openbsd.org>
4 years agoARM: dts: Sync Amlogic G12A with Linux 5.3-rc1
Neil Armstrong [Mon, 22 Jul 2019 08:06:11 +0000 (10:06 +0200)]
ARM: dts: Sync Amlogic G12A with Linux 5.3-rc1

Sync the Amlogic Meson G12A DT and Bindings file with the Linux 5.3-rc1
from the commit 5f9e832c1370 ("Linus 5.3-rc1").

Also remove the meson-g12a-u-boot.dtsi and meson-g12a-u200-u-boot.dtsi,
now conflicting with the main DT content.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Mark Kettenis <kettenis@openbsd.org>
4 years agommc: relocate code comment
Baruch Siach [Mon, 22 Jul 2019 12:52:12 +0000 (15:52 +0300)]
mmc: relocate code comment

The comment about init op being NULL used to be next to the NULL check
code. Commit 8ca51e51c182 ("dm: mmc: Add a way to use driver model for
MMC operations") separated the comment from the code. Put them back
together.

Fixes: 8ca51e51c182 ("dm: mmc: Add a way to use driver model for MMC operations")
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
4 years agommc: mtk-sd: add WATCHDOG_RESET() to prevent watchdog timeout
Weijie Gao [Fri, 19 Jul 2019 03:04:47 +0000 (11:04 +0800)]
mmc: mtk-sd: add WATCHDOG_RESET() to prevent watchdog timeout

When reading large data in once (reading 512MiB is tested on MT7623), a
watchdog timeout is triggered due to watchdog not being fed.

This patch adds WATCHDOG_RESET() to msdc_start_data() so the watchdog will
be fed every 1024 blocks are read/written.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
4 years agommc: sdhci: fix chip detect gpio property name
Baruch Siach [Mon, 22 Jul 2019 16:14:06 +0000 (19:14 +0300)]
mmc: sdhci: fix chip detect gpio property name

The standard property name for chip-detect gpio is "cd-gpios". All
in-tree DT files use only this name.

Fixes: 451931ea700 ("mmc: sdhci: Read cd-gpio from devicetree")
Cc: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
4 years agommc: mv_sdhci: fix uninitialized pointer deref on probe
Baruch Siach [Mon, 22 Jul 2019 15:55:35 +0000 (18:55 +0300)]
mmc: mv_sdhci: fix uninitialized pointer deref on probe

Since commit 3d296365e4e8 ("mmc: sdhci: Add support for
sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc
field. Move the mmc field initialization before sdhci_setup_cfg()
call to avoid crash on mmc pointer dereference.

Fixes: 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
4 years agotest/py: add MMC/SD block write test
Jean-Jacques Hiblot [Mon, 17 Jun 2019 15:49:21 +0000 (17:49 +0200)]
test/py: add MMC/SD block write test

Add a standalone MMC block write test. This allows direct testing of MMC
access rather than relying on doing so as a side-effect of e.g. DFU or
UMS testing, which may not be enabled on all platforms.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
4 years agoMerge tag 'video-for-2019.10-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 30 Jul 2019 23:19:54 +0000 (19:19 -0400)]
Merge tag 'video-for-2019.10-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot-video

- fix EDID mode filtering
- extend mxc_ipuv3_fb to enable backlight/display
- include fb_base in global_data for DM_VIDEO
- show frame buffer address via board info
  as used to be with legacy VIDEO support

4 years agoMerge tag 'xilinx-for-v2019.10' of https://gitlab.denx.de/u-boot/custodians/u-boot...
Tom Rini [Tue, 30 Jul 2019 23:19:34 +0000 (19:19 -0400)]
Merge tag 'xilinx-for-v2019.10' of https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze

Xilinx/FPGA changes for v2019.10

fpga:
- Xilinx virtex2 cleanup
- Altera cyclon2 cleanup

zynq:
- Minor Kconfig cleanup
- Add psu_init configuration for Z-turn board

zynqmp:
- Add support for pmufw config passing to PMU
- script for psu_init conversion
- zcu1275 renaming

xilinx:
- Add support for UltraZed-EV SoM

4 years agoMerge branch 'master' of git://git.denx.de/u-boot-sh
Tom Rini [Tue, 30 Jul 2019 23:19:04 +0000 (19:19 -0400)]
Merge branch 'master' of git://git.denx.de/u-boot-sh

4 years agoarm64: zynqmp: Do not include pm_cfg_obj.o when SPL is disabled
Michal Simek [Tue, 30 Jul 2019 15:07:27 +0000 (17:07 +0200)]
arm64: zynqmp: Do not include pm_cfg_obj.o when SPL is disabled

xilinx_zynqmp_mini configuration is throwing build error:
readlink: missing operand
Try 'readlink --help' for more information.

because CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE is not defined at all and
Makefile pass ifneq condition. Add SPL_BUILD dependency which is also
reflected in Kconfig.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agomxc_ipuv3_fb.c: enable a backlight on a panel
Heiko Schocher [Mon, 22 Jul 2019 04:49:08 +0000 (06:49 +0200)]
mxc_ipuv3_fb.c: enable a backlight on a panel

check if we get a panel device, if so, enable
the backlight on it.

Signed-off-by: Heiko Schocher <hs@denx.de>
4 years agomxc_ipuv3_fb.c: call display_enable
Heiko Schocher [Mon, 22 Jul 2019 04:49:07 +0000 (06:49 +0200)]
mxc_ipuv3_fb.c: call display_enable

call display_enable, so a display gets enabled.

Signed-off-by: Heiko Schocher <hs@denx.de>
4 years agobdinfo: show fb base with DM_VIDEO
Heiko Schocher [Mon, 22 Jul 2019 04:49:06 +0000 (06:49 +0200)]
bdinfo: show fb base with DM_VIDEO

show Framebuffer base with CONFIG_DM_VIDEO
enabled.

Signed-off-by: Heiko Schocher <hs@denx.de>
4 years agomxc_ipuv3_fb.c: set gd->fb_base
Heiko Schocher [Mon, 22 Jul 2019 04:49:05 +0000 (06:49 +0200)]
mxc_ipuv3_fb.c: set gd->fb_base

set gd->fb_base so it can be shown with bdinfo command.

Signed-off-by: Heiko Schocher <hs@denx.de>
4 years agoglobal_data: enable fb_base for DM_VIDEO
Heiko Schocher [Mon, 22 Jul 2019 04:49:04 +0000 (06:49 +0200)]
global_data: enable fb_base for DM_VIDEO

with CONFIG_VIDEO we store fb base address
in global data fb_base variable. Do this
also in DM_VIDEO case.

Signed-off-by: Heiko Schocher <hs@denx.de>
4 years agocmd: fpga: Change return value to avoid printing usage text
Alexander Dahl [Fri, 28 Jun 2019 12:41:24 +0000 (14:41 +0200)]
cmd: fpga: Change return value to avoid printing usage text

In cmd/fpga.c the commands should return enum command_ret_t, e.g.
CMD_RET_USAGE, CMD_RET_SUCCESS, or CMD_RET_FAILURE. What they actually
do is passing a return value from different 'fpga_' functions.

Passing on a return value of -1 from a called function leads to printing
out usage text. In case of actually correct usage with correctly
specified parameters but some fail at runtime printing out that usage
text is distracting.

The reason is most 'fpga_' functions return either FPGA_SUCCESS or
FPGA_FAIL, the latter was equal to -1 which is the same value as
CMD_RET_USAGE. So just passing on FPGA_FAIL lead to printing out usage.

We should only return CMD_RET_USAGE in cases, where the user sent wrong
input. Every other case should return CMD_RET_SUCCESS or
CMD_RET_FAILURE, and not simply pass an error code.

Simply changing FPGA_FAIL from -1 to 1 gets the job done.

Suggested-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Alexander Dahl <ada@thorsis.com>
4 years agofpga: altera: cyclon2: Check function pointer before calling
Alexander Dahl [Fri, 28 Jun 2019 12:41:23 +0000 (14:41 +0200)]
fpga: altera: cyclon2: Check function pointer before calling

As already done for the 'pre' function, a check is added to not follow a
NULL pointer, if somebody has not assigned a 'post' function.

Signed-off-by: Alexander Dahl <ada@thorsis.com>
4 years agofpga: altera: cyclon2: Fix indentation
Alexander Dahl [Fri, 28 Jun 2019 12:41:22 +0000 (14:41 +0200)]
fpga: altera: cyclon2: Fix indentation

Some code parts stood too far left â€¦

Signed-off-by: Alexander Dahl <ada@thorsis.com>
4 years agofpga: altera: cyclon2: Fix most checkpatch warnings
Alexander Dahl [Fri, 28 Jun 2019 12:41:21 +0000 (14:41 +0200)]
fpga: altera: cyclon2: Fix most checkpatch warnings

Nothing special, but done before further cleanup.

* spacing
* braces
* __FUNCTION__ â†’ __func__

Suggested-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Alexander Dahl <ada@thorsis.com>
4 years agofpga: altera: Add some more device sizes
Alexander Dahl [Fri, 28 Jun 2019 12:41:20 +0000 (14:41 +0200)]
fpga: altera: Add some more device sizes

There seems to be only one place, where this is checked against:
`altera_validate()`. It should be non zero. Otherwise it is only used to
display it, so it probably does not really matter at the moment. But we
had the datasheet open anyway â€¦

Sizes in datasheet are bit counts, display here is in bytes.

Signed-off-by: Alexander Dahl <ada@thorsis.com>
4 years agoarm64: zynqmp: add MAINTAINERS entry for Avnet UltraZed-EV
Luca Ceresoli [Thu, 20 Jun 2019 16:18:16 +0000 (18:18 +0200)]
arm64: zynqmp: add MAINTAINERS entry for Avnet UltraZed-EV

The board was added without adding a MAINTAINERS entry.

Fixes:

  $ ./tools/genboardscfg.py -f
  WARNING: no status info for 'avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0'
  WARNING: no maintainers for 'avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0'
  $

Reported-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agofpga: virtex2: Add slave serial programming support
Robert Hancock [Tue, 18 Jun 2019 15:47:16 +0000 (09:47 -0600)]
fpga: virtex2: Add slave serial programming support

This adds support for slave serial programming, in addition to the
previously supported slave SelectMAP mode. There are two ways that this
can be used:

-Using the clk and wdata callbacks in order to write image data one bit
at a time using pure bit-banging. This works, but is rather painfully
slow with typical image sizes.

-By specifying the wbulkdata callback instead, the image loading process
can be offloaded to SPI hardware. In this mode the clk and wdata
callbacks do not need to be specified. This allows the image to be
loaded much faster, taking only a few seconds with even relatively large
images.

Slave serial programming has been tested on the Kintex-7 series of
FPGAs.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agofpga: virtex2: Add additional clock cycles after DONE assertion
Robert Hancock [Tue, 18 Jun 2019 15:47:15 +0000 (09:47 -0600)]
fpga: virtex2: Add additional clock cycles after DONE assertion

Some Xilinx FPGA configuration options can result in the startup
sequence extending past the end of the FPGA bitstream. Continue applying
CCLK clock cycles for 8 cycles after DONE is asserted in order to ensure
the startup sequence is complete, as recommended by Xilinx.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agofpga: virtex2: Split out image writing from pre/post operations
Robert Hancock [Tue, 18 Jun 2019 15:47:14 +0000 (09:47 -0600)]
fpga: virtex2: Split out image writing from pre/post operations

This is in preparation for adding slave serial programming support,
which uses the same pre/post operations as slave SelectMAP, to avoid
duplicating code.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agofpga: virtex2: added Kconfig option
Robert Hancock [Tue, 18 Jun 2019 15:47:13 +0000 (09:47 -0600)]
fpga: virtex2: added Kconfig option

Add an option to allow this driver to be selected with Kconfig. As noted
in the description, this driver should also work with many newer Xilinx
FPGA families as the programming methods are essentially the same.

Also added a missing FPGA_XILINX dependency to the similar Spartan 3
driver.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agofpga: virtex2: cosmetic: Cleanup code style
Robert Hancock [Tue, 18 Jun 2019 15:47:12 +0000 (09:47 -0600)]
fpga: virtex2: cosmetic: Cleanup code style

Address Checkpatch warnings in virtex2 code prior to making other
changes. No functional change intended.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoarm64: zynqmp: add support for Avnet UltraZed-EV Starter Kit
Luca Ceresoli [Tue, 11 Jun 2019 16:39:41 +0000 (18:39 +0200)]
arm64: zynqmp: add support for Avnet UltraZed-EV Starter Kit

Avnet UltraZed-EV Starter Kit is composed by the UltraZed-EV SoM and the
only publicly-available compatible carrier card. The SoM is based on the EV
version of the Xilinx ZynqMP SoC+FPGA.

The psu_init_gpl.c file has been generated from the board definition files
at [0] using Vivado 2018.3 and then minimized by
tools/zynqmp_psu_init_minimize.sh. Manually removed serdes init code since
it is not mentioned in device tree and fixed a checkpatch error.

[0] https://github.com/Avnet/bdf/tree/3686c9ff7d2f0467fb4fcf39f861b8d6ff183b12/ultrazed_7ev_cc/1.1

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agotools: zynqmp_psu_init_minimize.sh: fix return lines coding style
Luca Ceresoli [Tue, 11 Jun 2019 16:39:40 +0000 (18:39 +0200)]
tools: zynqmp_psu_init_minimize.sh: fix return lines coding style

Remove unneeded parenthess around return value. E.g.:
    return (0);   ->   return 0;

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoARM: zynq: Add configuration for Z-turn board
Anton Gerasimov [Tue, 4 Jun 2019 20:10:49 +0000 (22:10 +0200)]
ARM: zynq: Add configuration for Z-turn board

Basic (PS-only) configuration based on Vivado board files by
Sergiusz Bazanski <sergius@q3k.org>

Signed-off-by: Anton Gerasimov <tossel@gmail.com>
4 years agocmd: fpga: correct typo, capitalize "Xilinx"
Robert P. J. Day [Tue, 28 May 2019 15:33:27 +0000 (11:33 -0400)]
cmd: fpga: correct typo, capitalize "Xilinx"

A couple minor tweaks to printed strings in cmd/fpga.c.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoarm64: zynqmp: add tool to minimize psu_init_gpl.c files
Luca Ceresoli [Fri, 24 May 2019 13:40:02 +0000 (15:40 +0200)]
arm64: zynqmp: add tool to minimize psu_init_gpl.c files

This script transforms a pair of psu_init_gpl.c and .h files produced by
the Xilinx Vivado tool for ZynqMP into a smaller psu_init_gpl.c file that
is almost checkpatch compliant.

Based on a script by Michal Simek.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoarm64: zynqmp: xil_io.h: declare functions as static
Luca Ceresoli [Fri, 24 May 2019 13:40:01 +0000 (15:40 +0200)]
arm64: zynqmp: xil_io.h: declare functions as static

Fixes sparse warnings when building zynqmp defconfigs:
  ./board/xilinx/zynqmp/xil_io.h:12:6: warning: symbol 'Xil_Out32' was not declared. Should it be static?
  ./board/xilinx/zynqmp/xil_io.h:17:5: warning: symbol 'Xil_In32' was not declared. Should it be static?
  ./board/xilinx/zynqmp/xil_io.h:22:6: warning: symbol 'usleep' was not declared. Should it be static?

Also add __maybe_unused to usleep() since it is not used by minimized
psu_init_gpl.c files, so it would warn as "defined but not used".

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoarm64: zynqmp: add tool to convert PMU config object .c to binary
Luca Ceresoli [Tue, 21 May 2019 16:06:44 +0000 (18:06 +0200)]
arm64: zynqmp: add tool to convert PMU config object .c to binary

The recently-added ZYNQMP_SPL_PM_CFG_OBJ_FILE option allows SPL to load a
PMUFW configuration object from a binary blob. However the configuration
object is produced by Xilinx proprietary tools as a C source file and no
tool exists to easily convert it to a binary blob in an embedded Linux
build system for U-Boot to use.

Add a simple Python script to do the conversion.

It is definitely not a complete C language parser, but it is enough to
parse the known patterns generated by Xilinx tools, including:

 - defines
 - literal integers, optionally with a 'U' suffix
 - bitwise OR between them

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoarm64: zynqmp: spl: install a PMU firmware config object at runtime
Luca Ceresoli [Tue, 21 May 2019 16:06:43 +0000 (18:06 +0200)]
arm64: zynqmp: spl: install a PMU firmware config object at runtime

Optionally allow U-Boot to load a configuration object into the Power
Management Unit (PMU) firmware on Xilinx ZynqMP.

The configuration object is required by the PMU FW to enable most SoC
peripherals. So far the only way to boot using U-Boot SPL was to hard-code
the configuration object in the PMU firmware. Allow a different boot
process, where the PMU FW is equal for any ZynqMP chip and its
configuration is passed at runtime by U-Boot SPL.

All the code for Inter-processor communication with the PMU is isolated in
a new file (pmu_ipc.c). The code is inspired by the same feature as
implemented in the Xilinx First Stage Bootloader (FSBL) and Arm Trusted
Firmware:

 * https://github.com/Xilinx/embeddedsw/blob/fb647e6b4c00f5154eba52a88b948195b6f1dc2b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_misc_drivers.c#L295
 * https://github.com/ARM-software/arm-trusted-firmware/blob/c48d02bade88b07fa7f43aa44e5217f68e5d047f/plat/xilinx/zynqmp/pm_service/pm_api_sys.c#L357

SPL logs on the console before loading the configuration object:

  U-Boot SPL 2019.07-rc1-00511-gaec224515c87 (May 15 2019 - 08:43:41 +0200)
  Loading PMUFW cfg obj (2008 bytes)
  EL Level: EL3
  ...

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoarm64: zynqmp: Rename zc1275 to zcu1275
Michal Simek [Tue, 21 May 2019 10:07:23 +0000 (12:07 +0200)]
arm64: zynqmp: Rename zc1275 to zcu1275

Name of this platform has changed and released to customers that's why
name has also changed.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Series-to: uboot

4 years agoARM: zynq: delete long-dead CONFIG_USB_CABLE_CHECK
Robert P. J. Day [Thu, 18 Apr 2019 14:50:23 +0000 (10:50 -0400)]
ARM: zynq: delete long-dead CONFIG_USB_CABLE_CHECK

This Kbuild option disappeared way back in 2014:

 commit 75504e9592745021006cb8905b5ff5a51d9d1cb3
 Author: Mateusz Zalega <m.zalega@samsung.com>
 Date:   Wed Apr 30 13:07:48 2014 +0200

    ... snip ...

    CONFIG_USB_CABLE_CHECK was removed.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
4 years agoPrepare v2019.10-rc1 v2019.10-rc1
Tom Rini [Tue, 30 Jul 2019 01:16:16 +0000 (21:16 -0400)]
Prepare v2019.10-rc1

Signed-off-by: Tom Rini <trini@konsulko.com>
4 years agoMerge tag 'dm-pull-29jul19' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
Tom Rini [Mon, 29 Jul 2019 21:59:51 +0000 (17:59 -0400)]
Merge tag 'dm-pull-29jul19' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm

binman support for replacing files

4 years agoMerge branch '2019-07-29-ti-imports'
Tom Rini [Mon, 29 Jul 2019 21:59:15 +0000 (17:59 -0400)]
Merge branch '2019-07-29-ti-imports'

- More DaVinci DM migration, drop am18xx EVM platform
- Keystone bug fix

4 years agoarm: mach-keystone: Use appended original image size in image processing
Andrew F. Davis [Tue, 16 Jul 2019 13:49:38 +0000 (09:49 -0400)]
arm: mach-keystone: Use appended original image size in image processing

When an image is signed/encrypted on K2 devices the image may get padded
to meet alignment requirements for the signature/encryption type. The
original size is appended as 4 bytes little-endian to the end of the
final image.

Normally the trailing extra bytes are ignored and so restoring the
exact original size is not important. In the case of initrd the
original size is important as the kernel uses it to look for
additional filesystem data and can do the wrong thing when the
size is not correct.

Read off the original size and report it back from the image post
processing stage.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agoconfigs: omapl138_lcdk: enable NAND self-init in SPL
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:10 +0000 (08:58 +0200)]
configs: omapl138_lcdk: enable NAND self-init in SPL

Now that we have enabled the driver-model in SPL, we can remove the
code disabling NAND self-init in SPL from the config include for
omapl138-lcdk.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agodavinci: omapl138-lcdk: enable driver-model in SPL
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:09 +0000 (08:58 +0200)]
davinci: omapl138-lcdk: enable driver-model in SPL

Enable CONFIG_SPL_DM and enable the driver model for serial by defining
an appropriate device in the board file for da850-lcdk.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agodavinci: omapl138-lcdk: remove unneeded includes
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:08 +0000 (08:58 +0200)]
davinci: omapl138-lcdk: remove unneeded includes

There's no SPI on da850-lcdk. Remove unnecessary includes.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agodavinci: omapl138-lcdk: enable CONFIG_USE_TINY_PRINTF
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:07 +0000 (08:58 +0200)]
davinci: omapl138-lcdk: enable CONFIG_USE_TINY_PRINTF

We're working towards enabling the driver-model in SPL for da850-lcdk.
Enable CONFIG_USE_TINY_PRINTF in defconfig to reduce SPL size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agodavinci: omapl138-lcdk: enable SPL_SYS_MALLOC_SIMPLE
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:06 +0000 (08:58 +0200)]
davinci: omapl138-lcdk: enable SPL_SYS_MALLOC_SIMPLE

We're working towards enabling the driver model in SPL for da850-lcdk.
Enable SPL_SYS_MALLOC_SIMPLE in defconfig to reduce SPL size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agodavinci: da850-evm: enable driver model for NAND
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:05 +0000 (08:58 +0200)]
davinci: da850-evm: enable driver model for NAND

Enable the driver-model on da850-evm. We need to add a dummy nand node
to the device tree, as the real nand node is a sub-node of the aemif
device.

On linux the aemif driver populates all its child nodes, but we can't do
it in u-boot currently.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Tested-by: Adam Ford <aford173@gmail.com> #da850-evm
4 years agodavinci: omapl138-lcdk: enable driver model for NAND
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:04 +0000 (08:58 +0200)]
davinci: omapl138-lcdk: enable driver model for NAND

Enable the driver-model on da850-lcdk. We need to add a dummy nand node
to the device tree, as the real nand node is a sub-node of the aemif
device.

On linux the aemif driver populates all its child nodes, but we can't do
it in u-boot currently.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agonand: davinci: add support for driver model
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:03 +0000 (08:58 +0200)]
nand: davinci: add support for driver model

Extend the davinci NAND driver to support the driver model. For now this
doesn't add any device-tree parsing due to the fact that we can't access
the actual nand node on the device-tree - it's a subnode of the aemif
device and we don't have an aemif driver on davinci at the moment.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agonand: davinci: make davinci_nand_init() static
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:02 +0000 (08:58 +0200)]
nand: davinci: make davinci_nand_init() static

This function is only used within the driver itself. No need
to export it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
4 years agoomapl138_lcdk_defconfig: don't build support for SPI
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:01 +0000 (08:58 +0200)]
omapl138_lcdk_defconfig: don't build support for SPI

The following warning is emited when building u-boot for da850-lcdk:

===================== WARNING ======================
This board does not use CONFIG_DM_SPI. Please update
the board before v2019.04 for no dm conversion
and v2019.07 for partially dm converted drivers.
Failure to update can lead to driver/board removal
See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_SPI_FLASH. Please update
the board to use CONFIG_SPI_FLASH before the v2019.07 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/MIGRATION.txt for more info.
====================================================

While we could fix it by selecting CONFIG_DM_SPI, there's no need to
build it at all as SPI is disabled on da850-lcdk. Remove all unneeded
options from the defconfig.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Heiko Schocher <hs@denx.de>
4 years agoi2c: remove i2c driver-model compatibility layer
Bartosz Golaszewski [Mon, 29 Jul 2019 06:58:00 +0000 (08:58 +0200)]
i2c: remove i2c driver-model compatibility layer

There are no more users of the compatibility layer for i2c. Remove the
driver and all references to it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Heiko Schocher <hs@denx.de>
4 years agosandbox: remove CONFIG_DM_I2C_COMPAT from defconfigs
Bartosz Golaszewski [Mon, 29 Jul 2019 06:57:59 +0000 (08:57 +0200)]
sandbox: remove CONFIG_DM_I2C_COMPAT from defconfigs

There are no more "real" users of CONFIG_DM_I2C_COMPAT and we'll soon
remove it altogether. Stop building it in sandbox mode.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Heiko Schocher <hs@denx.de>
4 years agodavinci: remove CONFIG_DM_I2C_COMPAT from defconfigs
Bartosz Golaszewski [Mon, 29 Jul 2019 06:57:58 +0000 (08:57 +0200)]
davinci: remove CONFIG_DM_I2C_COMPAT from defconfigs

This option is no longer used on any davinci board but still selected
in defconfigs which causes the following warning:

===================== WARNING ======================
This board uses CONFIG_DM_I2C_COMPAT. Please remove
(possibly in a subsequent patch in your series)
before sending patches to the mailing list.
====================================================

Remove all references to CONFIG_DM_I2C_COMPAT from davinci.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Heiko Schocher <hs@denx.de>
4 years agoARM: da850_am18xxevm: Remove config and references
Adam Ford [Mon, 29 Jul 2019 13:28:39 +0000 (08:28 -0500)]
ARM: da850_am18xxevm: Remove config and references

This board has been abandonded for a while.  I do not have this hardware
and nobody has appeared to notice and/or care that it's orphaned.
Since much of this code is inserted into the da850evm code base, removing
it from support will make da850evm support easier going forward.
This patch removes the da850_am18xxevm_defconfig, README references to this
board and the reference to this board from the MAINTAINERS list.

Signed-off-by: Adam Ford <aford173@gmail.com>
4 years agoedid: fix edid_get_timing_validate() mode_valid lookup
Neil Armstrong [Mon, 29 Jul 2019 13:35:18 +0000 (15:35 +0200)]
edid: fix edid_get_timing_validate() mode_valid lookup

Add a condition to the break in the modes lookup, without this
when the first mode is not valid, then edid_get_timing_validate()
return an error instead of checking the next modes.

Fixes: 1c1ed441b0d1 ("edid: add edid_get_timing_validate() variant to filter out edid modes")
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
4 years agoMerge branch '2019-07-29-master-imports'
Tom Rini [Mon, 29 Jul 2019 15:51:17 +0000 (11:51 -0400)]
Merge branch '2019-07-29-master-imports'

- Assorted bug fixes

4 years agoMakefile: fix implementation of BINMAN_DEBUG
Stephen Warren [Fri, 19 Jul 2019 17:21:17 +0000 (11:21 -0600)]
Makefile: fix implementation of BINMAN_DEBUG

binman only accepts the -D argument early on the command-line, yet the
Makefile currently passes it near the end. This causes the build to fail
if this feature is used. Re-order the command-line to fix this.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add command-line support for replacing entries
Simon Glass [Sat, 20 Jul 2019 18:24:15 +0000 (12:24 -0600)]
binman: Add command-line support for replacing entries

Add a 'replace' command to binman to permit entries to be replaced, either
individually or all at once (using a filter).

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Correct the error message for invalid path
Simon Glass [Sat, 20 Jul 2019 18:24:14 +0000 (12:24 -0600)]
binman: Correct the error message for invalid path

At present this message references -o for output file. But binman uses -f
now. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Split control.WriteEntryToImage() into separate functions
Simon Glass [Sat, 20 Jul 2019 18:24:13 +0000 (12:24 -0600)]
binman: Split control.WriteEntryToImage() into separate functions

This code has three distinct phases:

1. The image is loaded and the state module is set up
2. The entry is written to the image
3. The image is repacked and written back to the file

Split the code out with three separate functions, one for each phase.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Update control.WriteEntry() to support writing the map
Simon Glass [Sat, 20 Jul 2019 18:24:12 +0000 (12:24 -0600)]
binman: Update control.WriteEntry() to support writing the map

Add the ability to write a new map file. Also tidy up a few comments and
rename a misleading variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Move control.WriteEntry further down the file
Simon Glass [Sat, 20 Jul 2019 18:24:11 +0000 (12:24 -0600)]
binman: Move control.WriteEntry further down the file

Move this function after the extraction logic so we can keep the writing
logic in one place.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Clean up all output directories in tests
Simon Glass [Sat, 20 Jul 2019 18:24:10 +0000 (12:24 -0600)]
binman: Clean up all output directories in tests

At present some tests leave behind output directories. This happens
because some tests call binman, which sets up an output directory, then
call it again, which sets up another output directory and leaves the
original one behind.

Fix this by using a separate temporary directory when binman is called
twice, or by manually removing the output directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add a test function to clean up the output dir
Simon Glass [Sat, 20 Jul 2019 18:24:09 +0000 (12:24 -0600)]
binman: Add a test function to clean up the output dir

Put tearDown()'s logic into a new _CleanupOutputDir() function so that it
can be called from elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Update state when replacing device-tree entries
Simon Glass [Sat, 20 Jul 2019 18:24:08 +0000 (12:24 -0600)]
binman: Update state when replacing device-tree entries

Since the state module holds references to all the device trees used by
binman, it must be updated when the device trees are updated. Add support
for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agopatman: Reset the output directory when it is removed
Simon Glass [Sat, 20 Jul 2019 18:24:07 +0000 (12:24 -0600)]
patman: Reset the output directory when it is removed

At present outdir remains set ever after the output directory has been
removed. Fix this to avoid trying to access it when it is not present.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Support replacing data in a cbfs
Simon Glass [Sat, 20 Jul 2019 18:24:06 +0000 (12:24 -0600)]
binman: Support replacing data in a cbfs

At present binman cannot replace data within a CBFS since it does not
allow rewriting of the files in that CBFS. Implement this by using the
new WriteData() method to handle the case.

Add a header to compressed data so that the amount of compressed data can
be determined without reference to the size of the containing entry. This
allows the entry to be larger that the contents, without causing errors in
decompression. This is necessary to cope with a compressed device tree
being updated in such a way that it shrinks after the entry size is
already set (an obscure case). It is not used with CBFS since it has its
own metadata for this. Increase the number of passes allowed to resolve
the position of entries, to handle this case.

Add a test for this new logic.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Update Entry.WriteData() to handle special sections
Simon Glass [Sat, 20 Jul 2019 18:24:05 +0000 (12:24 -0600)]
binman: Update Entry.WriteData() to handle special sections

At present this method assumes that the parent section does not need
to recalculate its position or adjust any metadata it may contain. But
when the entry changes size this may not be true. Also if the parent
section is more than just a container (e.g. it is a CBFS) then the
section may need to regenerate its output.

Add a new WriteChildData() method to sections and call this from the
WriteData() method, to handle this situation.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Update Entry.ReadEntry() to work through classes
Simon Glass [Sat, 20 Jul 2019 18:24:04 +0000 (12:24 -0600)]
binman: Update Entry.ReadEntry() to work through classes

At present we simply extract the data directly from entries using the
image_pos information. This happens to work on current entry types, but
cannot work if the entry type encodes the data in some way. Update the
ReadData() method to provide the data by calling a new ReadChildData()
method in the parent. This allows the entry_Section class, or possibly
any other container class, to return the correct data in all cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add a prefix before CBFS hex offsets
Simon Glass [Sat, 20 Jul 2019 18:24:03 +0000 (12:24 -0600)]
binman: Add a prefix before CBFS hex offsets

Add a 0x prefix to these errors to avoid confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add a few more features to the wishlist
Simon Glass [Sat, 20 Jul 2019 18:24:02 +0000 (12:24 -0600)]
binman: Add a few more features to the wishlist

Add mention of a few other desirable features that may be implemented in
the future.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Place Intel descriptor at image start
Simon Glass [Sat, 20 Jul 2019 18:24:01 +0000 (12:24 -0600)]
binman: Place Intel descriptor at image start

The Intel descriptor must always appear at the start of an (x86) image,
so it is supposed to position itself there always. However there is no
explicit test for this. Add one and fix a bug introduced by the recent
change to adjust Entry to read the node in a separate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Adjust fmap to ignore CBFS files
Simon Glass [Sat, 20 Jul 2019 18:24:00 +0000 (12:24 -0600)]
binman: Adjust fmap to ignore CBFS files

The FMAP is not intended to show the files inside a CBFS. The FMAP can be
used to locate the CBFS itself, but then the CBFS must be read to find out
what is in it.

Update the FMAP to work this way and add some debugging while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agolibfdt: Copy the struct region in fdt_resize()
Simon Glass [Sat, 20 Jul 2019 18:23:59 +0000 (12:23 -0600)]
libfdt: Copy the struct region in fdt_resize()

At present this function appears to copy only the data before the struct
region and the data in the string region. It does not seem to copy the
struct region itself.

>From the arguments of this function it seems that it should support fdt
and buf being different. This patch attempts to fix this problem.

Upstream commit: c72fa77 libfdt: Copy the struct region in fdt_resize()

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Support shrinking a entry after packing
Simon Glass [Sat, 20 Jul 2019 18:23:58 +0000 (12:23 -0600)]
binman: Support shrinking a entry after packing

Sometimes an entry may shrink after it has already been packed. In that
case we must repack the items. Of course it is always possible to just
leave the entry at its original size and waste space at the end. This is
what binman does by default, since there is the possibility of the entry
changing size every time binman calculates its contents, thus causing a
loop.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Update the _testing entry to support shrinkage
Simon Glass [Sat, 20 Jul 2019 18:23:57 +0000 (12:23 -0600)]
binman: Update the _testing entry to support shrinkage

Sometimes entries shrink after packing. As a start towards supporting
this, update the _testing entry to handle the test case.

Signed-off-by: Simon Glass <sjg@chromium.org>