Commit Graph

72541 Commits

Author SHA1 Message Date
Tom Rini
a94ab561e2 Merge branch '2021-04-13-assorted-improvements'
- A large assortment of bug fixes, code cleanups and a few feature
  enhancements.
2021-04-13 09:50:45 -04:00
Marek Vasut
8c4e3b79bd cmd: exit: Fix return value
In case exit is called in a script without parameter, the command
returns -2 ; in case exit is called with a numerical parameter,
the command returns -2 and lower. This leads to the following problem:
=> setenv foo 'echo bar ; exit 1' ; run foo ; echo $?
bar
0
=> setenv foo 'echo bar ; exit 0' ; run foo ; echo $?
bar
0
=> setenv foo 'echo bar ; exit -2' ; run foo ; echo $?
bar
0
That is, no matter what the 'exit' command argument is, the return
value is always 0 and so it is not possible to use script return
value in subsequent tests.

Fix this and simplify the exit command such that if exit is called with
no argument, the command returns 0, just like 'true' in cmd/test.c. In
case the command is called with any argument that is positive integer,
the argument is set as return value.
=> setenv foo 'echo bar ; exit 1' ; run foo ; echo $?
bar
1
=> setenv foo 'echo bar ; exit 0' ; run foo ; echo $?
bar
0
=> setenv foo 'echo bar ; exit -2' ; run foo ; echo $?
bar
0

Note that this does change ABI established in 2004 , although it is
unclear whether that ABI was originally OK or not.

Fixes: c26e454dfc
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Tom Rini <trini@konsulko.com>
2021-04-12 17:45:40 -04:00
Patrick Delaunay
7062d4e815 scmi: translate the resource only when livetree is not activated
Call the translation function on the ofnode_read_resource result only
when the livetree is not activated.

Today of_address_to_resource() calls ofnode_read_resource() for livetree
support and fdt_get_resource() when livetree is not supported.

The fdt_get_resource() doesn't do the address translation
so when it is required when livetree is activated but this address
translation is already done by ofnode_read_resource().

Fixes: 240720e905 ("firmware: scmi: mailbox/smt agent device")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-12 17:45:40 -04:00
Simon Glass
34f8fc7c85 gpio: Drop dm_gpio_set_dir()
This function is not used. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-12 17:45:40 -04:00
Simon Glass
a12aa7995f gpio: i2c-gpio: Drop use of dm_gpio_set_dir()
This is the only driver that uses this function. Update it to use the
alternative which is dm_gpio_clrset_flags().

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Harm Berntsen <harm.berntsen@nedap.com>
2021-04-12 17:45:40 -04:00
Asherah Connor
0219279381 qemu: arm: select QFW, MMIO on qemu-arm
Select CMD_QFW and QFW_MMIO in the qemu-arm board (covers arm and
arm64).

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-04-12 17:45:40 -04:00
Asherah Connor
5830b57bf9 qemu: add MMIO driver for QFW
Add MMIO driver for QFW.

Note that there is no consumer as of this patch.

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-04-12 17:45:40 -04:00
Asherah Connor
69512551aa test: qemu: add qfw sandbox driver, dm tests, qemu tests
A sandbox driver and test are added for the qfw uclass, and a test in
QEMU added for qfw functionality to confirm it doesn't break in real
world use.

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-04-12 17:45:39 -04:00
Asherah Connor
5b0b43e0e2 x86: qemu: move QFW to its own uclass
We move qfw into its own uclass and split the PIO functions into a
specific driver for that uclass.  The PIO driver is selected in the
qemu-x86 board config (this covers x86 and x86_64).

include/qfw.h is cleaned up and documentation added.

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
2021-04-12 17:44:55 -04:00
Patrick Delaunay
2a3f161c8b scmi: correctly configure MMU for SCMI buffer
Align the MMU area for SCMI shared buffer on section size;
use the ALIGN macro in mmu_set_region_dcache_behaviour call.

Since commit d877f8fd0f ("arm: provide a function for boards init
code to modify MMU virtual-physical map") the parameter of
mmu_set_region_dcache_behaviour need to be MMU_SECTION_SIZE
aligned.

Fixes: 240720e905 ("firmware: scmi: mailbox/smt agent device")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
2021-04-12 17:44:55 -04:00
Trevor Woerner
dc514d7ea2 moveconfig.py: add to the "do not process" list
Skip the processing of *.aml and *.dat files while iterating through the
source in order to process header files.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
2021-04-12 17:44:55 -04:00
Sean Anderson
d9c3050710 checkpatch: Add warnings for using strn(cat|cpy)
strn(cat|cpy) has a bad habit of not nul-terminating the destination,
resulting in constructions like

	strncpy(foo, bar, sizeof(foo) - 1);
	foo[sizeof(foo) - 1] = '\0';

However, it is very easy to forget about this behavior and accidentally
leave a string unterminated. This has shown up in some recent coverity
scans [1, 2] (including code recently touched by yours truly).

Fortunately, the guys at OpenBSD came up with strl(cat|cpy), which always
nul-terminate strings. These functions are already in U-Boot, so we should
encourage new code to use them instead of strn(cat|cpy).

[1] https://lists.denx.de/pipermail/u-boot/2021-March/442888.html
[2] https://lists.denx.de/pipermail/u-boot/2021-January/438073.html

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:44:55 -04:00
Sean Anderson
69a7529831 fastboot: Fix possible buffer overrun
This fixes several uses of strn(cpy|cat) which did not terminate their
destinations properly.

Fixes de1728ce4c ("fastboot: Allow u-boot-style partitions")

Reported-by: Coverity Scan
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2021-04-12 17:44:55 -04:00
Sean Anderson
c4ac52f55d test: Add test for strlcat
This test is adapted from glibc, which is very concerned about alignment.
It also tests strlcpy by dependency.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:44:55 -04:00
Sean Anderson
9af869c414 lib: string: Implement strlcat
This introduces strlcat, which provides a safer interface than strncat. It
never copies more than its size bytes, including the terminating nul. In
addition, it never reads past dest[size - 1], even if dest is not
nul-terminated.

This also removes the stub for dwc3 now that we have a proper
implementation.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:44:55 -04:00
Sean Anderson
d3358ecc54 lib: string: Fix strlcpy return value
strlcpy should always return the number of bytes copied. We were
accidentally missing the nul-terminator. We also always used to return a
non-zero value, even if we did not actually copy anything.

Fixes: 23cd138503 ("Integrate USB gadget layer and USB CDC driver layer")

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2021-04-12 17:44:55 -04:00
Ilias Apalodimas
92e8489611 tee: optee: Change printing during optee_probe
Right now the error messages when optee has a version mismatch or shared
memory is not configured are done with a debug().
That's not very convenient since you have to enable debugging to figure
out what's going on, although this is an actual error.

So let's switch the debug() -> dev_err() and report those explicitly.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-12 17:44:55 -04:00
Asherah Connor
ac3821430e terminal: only serial_reinit_all if available
serial_reinit_all() is only available if CONFIG_SERIAL is defined (i.e.
!CONFIG_DM_SERIAL).

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:44:55 -04:00
Asherah Connor
5c935eb6f7 terminal: correct stdio_dev invocations
stdio_dev methods have taken a pointer to themselves since 709ea543
(nearly 7 years ago).

Signed-off-by: Asherah Connor <ashe@kivikakk.ee>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:44:55 -04:00
Heiko Schocher
05a0776ed5 rtc: add support for rv3028 rtc
Add support for rtc3028 rtc from microcrystal.
based on linux dirver:
commit a38fd8748464: ("Linux 5.12-rc2")

Signed-off-by: Heiko Schocher <hs@denx.de>

Reviewed-by: Stefan Roese <sr@denx.de>
2021-04-12 17:44:55 -04:00
Etienne Carriere
3dfd739370 test: scmi: add local variables for scmi agent reference
Add local variables agent0/agent1 to refer to SCMI sandbox context
agent and ease readability of the test.

For consistency, rename regul_dev to regul0_dev and remove sandbox_voltd
in dm_test_scmi_voltage_domains().

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:17:11 -04:00
Etienne Carriere
c3bba708da firmware: scmi: fix inline comments and minor coding style issues
Fix inline comments and empty line in scmi driver and test files.

Remove test on IS_ENABLED(CONFIG_*_SCMI) in test/dm/scmi.c since these
configuration are expected enabled when CONFIG_FIRMWARE_SCMI is enabled
in sandbox configuration.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-04-12 17:17:11 -04:00
Etienne Carriere
0124218b8b firmware: scmi: sandbox test for voltage regulator
Implement sandbox regulator devices for SCMI voltage domains
and test them in DM scmi tests.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-04-12 17:17:11 -04:00
Etienne Carriere
1f213ee4db firmware: scmi: voltage regulator
Implement voltage regulators interfaced by the SCMI voltage domain
protocol. The DT bindings are defined in the Linux kernel since
SCMI voltage domain and regulators patches [1] and [2] integration
in v5.11-rc7.

Link: [1] 0f80fcec08
Link: [2] 2add5cacff
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-04-12 17:17:11 -04:00
Stefan Herbrechtsmeier
d46933839f disk: gpt: verify alternate LBA points to last usable LBA
The gpt command require the GPT backup header at the standard location
at the end of the device. Check the alternate LBA value before reading
the GPT backup header from the last usable LBA of the device.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-12 17:17:11 -04:00
Sean Anderson
b935d19066 cmd: xtrace: Convert to bool
This variable is a boolean, not a string.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-12 17:17:11 -04:00
Phil Sutter
a62de442e4 pci: Mark 64bit Memory BARs as such
Just a bit more info to the reader.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Stefan Roese <sr@denx.de>
2021-04-12 17:17:11 -04:00
Sean Anderson
9539f71675 hush: Fix assignments being misinterpreted as commands
If there were no variable substitutions in a command, then initial
assignments would be misinterpreted as commands, instead of being skipped
over. This is demonstrated by the following example:

	=> foo=bar echo baz
	Unknown command 'foo=bar' - try 'help'

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2021-04-12 17:17:11 -04:00
Farhan Ali
c146de4872 mtd: Update fail_addr when erase fails due to bad blocks
For all other erase failures, the fail_addr is updated with the
failing address. Only in the case of erase failure due to bad block
detection, the fail_addr is not updated. This change simply updates
the fail_addr for this specific scenario so that it is consistent with
the rest of the code.

Signed-off-by: Farhan Ali <farhan.ali@broadcom.com>
2021-04-12 17:17:11 -04:00
Peter Robinson
bedab97a21 Tegra: remove e2220-1170 board
It's an old bringup board with out upstream Linux or L4T support

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Tom Warren <twarren@nvidia.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
2021-04-12 17:17:11 -04:00
Heinrich Schuchardt
0ca7c4d964 bootm: do not hang on failure
On ARMv8 systems

    load mmc 0:1 $loadaddr  vmlinuz-5.10.0-3-arm64
    booti

leads to a hanging system requiring to physically reset the system:

    FDT and ATAGS support not compiled in - hanging
    ### ERROR ### Please RESET the board ###

For systems where physical access is difficult hanging is a poor choice.
It is preferable to reset the system when U-Boot reaches a state that is
not recoverable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 17:17:11 -04:00
Joel Stanley
a479f103dc hash: Allow for SHA512 hardware implementations
Similar to support for SHA1 and SHA256, allow the use of hardware hashing
engine by enabling the algorithm and setting  CONFIG_SHA_HW_ACCEL /
CONFIG_SHA_PROG_HW_ACCEL.

Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-04-12 17:17:11 -04:00
Joel Stanley
ba13978311 hw_sha: Fix coding style errors
Checkpatch complains about:

 ERROR: "foo * bar" should be "foo *bar"

and

 CHECK: Alignment should match open parenthesis

Signed-off-by: Joel Stanley <joel@jms.id.au>
2021-04-12 14:25:31 -04:00
Patrick Delaunay
a2535243e0 lib: optee: migration optee_copy_fdt_nodes for OF_LIVE support
The optee_copy_fdt_nodes is only used to copy op-tee nodes
of U-Boot device tree (from gd->fdt_blob when OF_LIVE is not activated)
to external device tree but it is not compatible with OF_LIVE.

This patch migrates all used function fdt_ functions to read node on
old_blob to ofnode functions, compatible with OF_LIVE and remove this
parameter "old_blob".

The generated "device tree" is checked on stm32mp platform with OF_LIVE
activated.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-04-12 14:25:31 -04:00
Jaehoon Chung
67696abf1f power: pmic: remove pmic_max77696.c file
Remove pmic_max77696.c file.
The maintaining pmic_max77696.c file is useless.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-04-12 14:25:30 -04:00
Jaehoon Chung
e316aa5858 board: warp: add power_max77696_init() function
Add power_max77696_init() function.
Since warp doesn't support DM, the keeping its code in board file is
better than maintainig the file of driver.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-04-12 14:24:33 -04:00
Dario Binacchi
5532262d46 test: pinmux: add test for 'pinctrl-single' driver
The test adds two pinmux nodes to the device tree, one to test when a
register changes only one pin's mux (pinctrl-single,pins), and the other
to test when more than one pin's mux is changed (pinctrl-single,bits).
This required replacing the controller's register access functions when
the driver is used on sandbox.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
76d470de1a pinctrl: single: add get_pin_muxing operation
It allows to display the muxing of a given pin. Inspired by more recent
versions of the Linux driver, in addition to the address and the value
of the configuration register I added the pin function retrieved from
the DT. In doing so, the information displayed does not depend on the
platform, being a generic type driver, and it can be useful for debug
purposes.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
0b12162910 pinctrl: single: add get_pin_name operation
It returns the name of the requested pin.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
1dd7ae20de pinctrl: single: add get_pins_count operation
It returns the number of selectable pins.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
180531fc2f pinctrl: single: add register access functions
The configuration of pinmux registers was implemented with duplicate
code which can be removed by adding two functions for read/write access.
Access to 8-bit registers has also been added.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
d85b93e80b pinctrl: single: change function mask default value
The patch is inspired by more recent versions of the Linux driver.
Replacing the default value 0xffffffff of the function mask with 0 is
certainly more conservative in case the "pinctrl-single,function-mask"
DT property is missing.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
971c64a452 pinctrl: single: check "register-width" DT property
In more recent versions of the Linux kernel the driver's probe function
returns an error if the "pinctrl-single,register-width" DT property is
missing. The lack of this information, in fact, does not allow to know
whether to access the registers of the controller at 8, 16, ... bits.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Dario Binacchi
9fd8a430f3 pinctrl: single: get register area size by device API
Use dev_read_addr_size to get size of the controller's register area.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2021-04-12 11:17:15 +05:30
Dario Binacchi
fcf6a2b30a pinctrl: single: fix debug messages formatting
The dev_dbg(dev, "  reg/val 0x%pa/0x%08x\n", &reg, val); prints the 'reg'
address preceded by the prefix 0x0x instead of 0x. This because the
printf '%pa' format specifier already prepends the prefix '0x' to the
address displayed.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2021-04-12 11:17:15 +05:30
Dario Binacchi
9b884e79a6 pinctrl: single: fix offset management
The pinmux configuration DT node of a peripheral does not define a
physical address but an offset. Only by adding it to the base address of
the controller it is possible to calculate the physical address of the
register to be configured. Printing an offset also requires a different
formatting option than a physical address.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2021-04-12 11:17:15 +05:30
Dario Binacchi
6719294694 pinctrl: single: fix the loop counter variable type
The 'n' variable is used as a loop counter, not as a physical address,
and is used in a comparison with an int. So it makes sense to change
its type from phys_addr_t to int.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2021-04-12 11:17:15 +05:30
Dario Binacchi
4ace4fa697 pinctrl: single: fix format of structure documentation
U-Boot adopted the kernel-doc annotation style.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-12 11:17:15 +05:30
Adam Ford
099c9a47c9 configs: omap35_logic_somlv: Fix MMC booting
A previous patch had removed the GPIO nodes from being built
into the SPL Device tree, but CONFIG_SPL_GPIO_SUPPORT remained
which makes the MMC card detect fail and the board does not boot.
Fix this by disabling CONFIG_SPL_GPIO_SUPPORT.

Fixes: 6f1efe81aa ("configs: omap3/35_logic and omap3/35_logic_somlv: Reduce SPL size")
Signed-off-by: Adam Ford <aford173@gmail.com>
2021-04-12 08:38:49 +05:30
Tom Rini
3b676a1662 Merge branch '2021-04-11-remove-non-migrated-boards'
- Remove a large number of boards that have not migrated to DM_MMC, for
  which the migration deadline with 2 years ago at v2019.04.
2021-04-11 14:11:05 -04:00