platform/kernel/u-boot.git
3 years agoMerge tag 'u-boot-rockchip-20201031' of https://gitlab.denx.de/u-boot/custodians...
Tom Rini [Sat, 31 Oct 2020 02:55:16 +0000 (22:55 -0400)]
Merge tag 'u-boot-rockchip-20201031' of https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip

- New PX30 board: Engicam PX30.Core;
- Fix USB HID support for rock960;
- Remove host endianness dependency for rockchip mkimage;
- dts update for rk3288-tinker;
- Enable console MUX for some ROCKPi boards;
- Add config-based ddr selection for px30;

3 years agoMerge tag 'dm-pull-30oct20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
Tom Rini [Fri, 30 Oct 2020 19:24:30 +0000 (15:24 -0400)]
Merge tag 'dm-pull-30oct20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm

of-platdata and dtoc improvements
sandbox SPL tests
binman support for compressed sections

3 years agolog: typo logl_pref in documentation
Heinrich Schuchardt [Fri, 30 Oct 2020 17:50:31 +0000 (18:50 +0100)]
log: typo logl_pref in documentation

The name of structure element logl_prev is not matched by the
documentation.

%s/logl_pref/logl_prev/

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoMerge branch '2020-10-30-misc-changes'
Tom Rini [Fri, 30 Oct 2020 18:17:23 +0000 (14:17 -0400)]
Merge branch '2020-10-30-misc-changes'

- Additional log improvements
- SPI flash environment improvements

3 years agodoc: rockchip: Document Rockchip miniloader flashing
Jagan Teki [Wed, 28 Oct 2020 13:33:48 +0000 (19:03 +0530)]
doc: rockchip: Document Rockchip miniloader flashing

This would be useful and recommended boot flow for new boards
which has doesn't have the DDR support yet in mainline.

Sometimes it is very useful for debugging mainline DDR support.

Documen it for px30 boot flow.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agorockchip: Add Engicam PX30.Core C.TOUCH 2.0
Jagan Teki [Wed, 28 Oct 2020 13:33:47 +0000 (19:03 +0530)]
rockchip: Add Engicam PX30.Core C.TOUCH 2.0

PX30.Core is an EDIMM SOM based on Rockchip PX30 from Engicam.

C.TOUCH 2.0 is a general purpose carrier board with capacitive
touch interface support.

PX30.Core needs to mount on top of this Carrier board for creating
complete PX30.Core C.TOUCH 2.0 board.

Add support for it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agoarm64: dts: rockchip: px30: Add Engicam C.TOUCH 2.0
Jagan Teki [Wed, 28 Oct 2020 13:33:46 +0000 (19:03 +0530)]
arm64: dts: rockchip: px30: Add Engicam C.TOUCH 2.0

Engicam C.TOUCH 2.0 is an EDIMM compliant general purpose
carrier board with capacitive touch interface.

Genaral features:
- TFT 10.1" industrial, 1280x800 LVDS display
- Ethernet 10/100
- Wifi/BT
- USB Type A/OTG
- Audio Out
- CAN
- LVDS panel connector

SOM's like PX30.Core needs to mount on top of this Carrier board
for creating complete PX30.Core C.TOUCH 2.0 board.

Add support for it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agorockchip: Add Engicam PX30.Core EDIMM2.2 Starter Kit
Jagan Teki [Wed, 28 Oct 2020 13:33:45 +0000 (19:03 +0530)]
rockchip: Add Engicam PX30.Core EDIMM2.2 Starter Kit

PX30.Core is an EDIMM SOM based on Rockchip PX30 from Engicam.

EDIMM2.2 Starter Kit is an EDIMM 2.2 Form Factor Capacitive
Evaluation Board from Engicam.

PX30.Core needs to mount on top of this Evaluation board for
creating complete PX30.Core EDIMM2.2 Starter Kit.

Add support for it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agoboard: engicam: Attach i.MX6 common code
Jagan Teki [Wed, 28 Oct 2020 13:33:44 +0000 (19:03 +0530)]
board: engicam: Attach i.MX6 common code

The existing common code for Engicam boards uses i.MX6,
so attach that into i.MX6 Engicam boards so-that adding
new SoC variants of Engicam boards become meaningful.

Add support for it.

Cc: Stefano Babic <sbabic@denx.de>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agorockchip: px30: Add EVB_PX30 Kconfig help
Jagan Teki [Wed, 28 Oct 2020 13:33:43 +0000 (19:03 +0530)]
rockchip: px30: Add EVB_PX30 Kconfig help

TARGET_EVB_PX30 can be possible to use other px30 boards.

Add the help text for existing EVB, so-that the new boards
which are resuing this config option can mention their board
help text.

This would help to track which boards are using EVB_PX30 config.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agoarm64: dts: rockchip: Add Engicam PX30.Core SOM
Michael Trimarchi [Wed, 28 Oct 2020 13:33:42 +0000 (19:03 +0530)]
arm64: dts: rockchip: Add Engicam PX30.Core SOM

PX30.Core is an EDIMM SOM based on Rockchip PX30 from Engicam.

General features:
- Rockchip PX30
- Up to 2GB DDR4
- eMMC 4 GB expandible
- rest of PX30 features

PX30.Core needs to mount on top of Engicam baseboards for creating
complete platform boards.

Possible baseboards are,
- EDIMM2.2
- C.TOUCH 2.0

Add support for it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agoarm64: dts: rockchip: px30: Add Engicam EDIMM2.2 Starter Kit
Jagan Teki [Wed, 28 Oct 2020 13:33:41 +0000 (19:03 +0530)]
arm64: dts: rockchip: px30: Add Engicam EDIMM2.2 Starter Kit

Engicam EDIMM2.2 Starter Kit is an EDIMM 2.2 Form Factor Capacitive
Evaluation Board.

Genaral features:
- LCD 7" C.Touch
- microSD slot
- Ethernet 1Gb
- Wifi/BT
- 2x LVDS Full HD interfaces
- 3x USB 2.0
- 1x USB 3.0
- HDMI Out
- Mini PCIe
- MIPI CSI
- 2x CAN
- Audio Out

SOM's like PX30.Core needs to mount on top of this Evaluation board
for creating complete PX30.Core EDIMM2.2 Starter Kit.

Add support for it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agorockchip: mkimage: Remove host endianness dependency
Samuel Holland [Sat, 24 Oct 2020 16:43:17 +0000 (11:43 -0500)]
rockchip: mkimage: Remove host endianness dependency

The Rockchip boot ROM expects little-endian values in the image header.
When running mkimage on a big-endian machine, these values need to be
byteswapped before writing or verifying the header.

This change fixes cross-compiling U-Boot SPL for the RK3399 SoC from a
big-endian ppc64 host machine.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agorockchip: Enable Console MUX in ROCKPi N8
Jagan Teki [Fri, 23 Oct 2020 19:57:25 +0000 (01:27 +0530)]
rockchip: Enable Console MUX in ROCKPi N8

Enable Console multiplexing in ROCKPi N8 which would is
required to video out the console buffer.

Enable it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agovideo: rockchip: Support 4K resolution for rk3288, HDMI
Jagan Teki [Fri, 23 Oct 2020 19:57:24 +0000 (01:27 +0530)]
video: rockchip: Support 4K resolution for rk3288, HDMI

Like, rk3399 the rk3288 also supports 4K resolution.

So, enable it for rk3288 with HDMI platforms.

Right now, rockchip video drivers are supporting for rk3288,
rk3399 SoC families, so mark the 4K resolution by default
if it's an HDMI video out.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Cc: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agoarm64: dts: rockchip: Add chosen node for ROCK-Pi N8
Jagan Teki [Fri, 23 Oct 2020 19:57:23 +0000 (01:27 +0530)]
arm64: dts: rockchip: Add chosen node for ROCK-Pi N8

Add chosen node in -u-boot.dtsi for ROCK-Pi N8 board.

This will help to get serial out messages.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agorockchip: Enable Console MUX in ROCKPi N10
Jagan Teki [Fri, 23 Oct 2020 19:57:22 +0000 (01:27 +0530)]
rockchip: Enable Console MUX in ROCKPi N10

Enable Console multiplexing in ROCKPi N10 which would is
required to video out the console buffer.

Enable it.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agodoc: Update logging documentation
Sean Anderson [Tue, 27 Oct 2020 23:55:41 +0000 (19:55 -0400)]
doc: Update logging documentation

This updates logging documentation with some examples of the new commands
added in the previous commits. It also removes some items from the to-do
list which have been implemented.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agodoc: Add log kerneldocs to documentation
Sean Anderson [Tue, 27 Oct 2020 23:55:40 +0000 (19:55 -0400)]
doc: Add log kerneldocs to documentation

The functions in log.h are already mostly documented, so add them to the
generated documentation.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest: Add a test for log filter-*
Sean Anderson [Tue, 27 Oct 2020 23:55:39 +0000 (19:55 -0400)]
test: Add a test for log filter-*

This exercises a few success and failure modes of the log filter-*
commands. log filter-list is not tested because it's purely informational.
I don't think there's a good way to test it except by testing if the output
of the command exactly matches a sample run.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocmd: log: Add commands to manipulate filters
Sean Anderson [Tue, 27 Oct 2020 23:55:38 +0000 (19:55 -0400)]
cmd: log: Add commands to manipulate filters

This adds several commands to add, list, and remove log filters. Due to the
complexity of adding a filter, `log filter-list` uses options instead of
positional arguments.

These commands have been added as subcommands to log by using a dash to
join the subcommand and subsubcommand. This is stylistic, and they could be
converted to proper subsubcommands if it is wished.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest: Add a test for getopt
Sean Anderson [Tue, 27 Oct 2020 23:55:37 +0000 (19:55 -0400)]
test: Add a test for getopt

A few of these tests were inspired by those in glibc. The syntax for
invoking test_getopt is a bit funky, but it's necessary so that the CPP can
parse the arguments correctly.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
3 years agolib: Add getopt
Sean Anderson [Tue, 27 Oct 2020 23:55:36 +0000 (19:55 -0400)]
lib: Add getopt

Some commands can get very unweildy if they have too many positional
arguments. Adding options makes them easier to read, remember, and
understand.

This implementation of getopt has been taken from barebox, which has had
option support for quite a while. I have made a few modifications to their
version, such as the removal of opterr in favor of a separate getopt_silent
function. In addition, I have moved all global variables into struct
getopt_context.

The getopt from barebox also re-orders the arguments passed to it so that
non-options are placed last. This allows users to specify options anywhere.
For example, `ls -l foo/ -R` would be re-ordered to `ls -l -R foo/` as
getopt parsed the options. However, this feature conflicts with the const
argv in cmd_tbl->cmd. This was originally added in 54841ab50c ("Make sure
that argv[] argument pointers are not modified."). The reason stated in
that commit is that hush requires argv to stay unmodified. Has this
situation changed? Barebox also uses hush, and does not have this problem.
Perhaps we could use their fix?

I have assigned maintenance of getopt to Simon Glass, as it is currently
only used by the log command. I would also be fine maintaining it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
3 years agocmd: log: Make "log level" print all log levels
Sean Anderson [Tue, 27 Oct 2020 23:55:35 +0000 (19:55 -0400)]
cmd: log: Make "log level" print all log levels

This makes the log level command print all valid log levels. The default
log level is annotated. This provides an easy way to see which log levels
are compiled-in.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocmd: log: Add commands to list categories and drivers
Sean Anderson [Tue, 27 Oct 2020 23:55:34 +0000 (19:55 -0400)]
cmd: log: Add commands to list categories and drivers

This allows users to query which categories and drivers are available on
their system. This allows them to construct filter-add commands without
(e.g.) adjusting the log format to show categories and drivers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocmd: log: Split off log level parsing
Sean Anderson [Tue, 27 Oct 2020 23:55:33 +0000 (19:55 -0400)]
cmd: log: Split off log level parsing

Move parsing of log level into its own function so it can be re-used. This
also adds support for using log level names instead of just the integer
equivalent.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agocmd: log: Use sub-commands for log
Sean Anderson [Tue, 27 Oct 2020 23:55:32 +0000 (19:55 -0400)]
cmd: log: Use sub-commands for log

This reduces duplicate code, and makes adding new sub-commands easier.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest: Add test for LOGFF_MIN
Sean Anderson [Tue, 27 Oct 2020 23:55:31 +0000 (19:55 -0400)]
test: Add test for LOGFF_MIN

This tests log filters matching on a minimum level.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolog: Add filter flag to match greater than a log level
Sean Anderson [Tue, 27 Oct 2020 23:55:30 +0000 (19:55 -0400)]
log: Add filter flag to match greater than a log level

This is the complement of the existing behavior to match only messages with
a log level less than a threshold. This is primarily useful in conjunction
with LOGFF_DENY.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest: Add tests for LOGFF_DENY
Sean Anderson [Tue, 27 Oct 2020 23:55:29 +0000 (19:55 -0400)]
test: Add tests for LOGFF_DENY

This adds some tests for log filters which deny if they match.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agotest: log: Give tests names instead of numbers
Sean Anderson [Tue, 27 Oct 2020 23:55:28 +0000 (19:55 -0400)]
test: log: Give tests names instead of numbers

Now that the log test command is no more, we can give the log tests proper
names.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
3 years agotest: log: Convert log_test from python to C
Sean Anderson [Tue, 27 Oct 2020 23:55:27 +0000 (19:55 -0400)]
test: log: Convert log_test from python to C

When rebasing this series I had to renumber all my log tests because
someone made another log test in the meantime. This involved updaing a
number in several places (C and python), and it wasn't checked by the
compiler. So I though "how hard could it be to just rewrite in C?" And
though it wasn't hard, it *was* tedious. Tests are numbered the same as
before to allow for easier review.

A note that if a test fails, everything after it will probably also fail.
This is because that test won't clean up its filters.  There's no easy way
to do the cleanup, except perhaps removing all filters in a wrapper
function.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
3 years agolog: Add filter flag to deny on match
Sean Anderson [Tue, 27 Oct 2020 23:55:26 +0000 (19:55 -0400)]
log: Add filter flag to deny on match

Without this flag, log filters can only explicitly accept messages.
Allowing denial makes it easier to filter certain subsystems. Unlike
allow-ing filters, deny-ing filters are added to the beginning of the
filter list. This should do the Right Thing most of the time, but it's
less-universal than allowing filters to be inserted anywhere. If this
becomes a problem, then perhaps log_filter_add* should take a filter number
to insert before/after.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolog: Add function to create a filter with flags
Sean Anderson [Tue, 27 Oct 2020 23:55:25 +0000 (19:55 -0400)]
log: Add function to create a filter with flags

This function exposes a way to specify flags when creating a filter.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolog: Expose some helper functions
Sean Anderson [Tue, 27 Oct 2020 23:55:24 +0000 (19:55 -0400)]
log: Expose some helper functions

These functions are required by "cmd: log: Add commands to manipulate
filters" and "test: Add a test for log filter-*".

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolog: Use CONFIG_IS_ENABLED() for LOG_TEST
Sean Anderson [Tue, 27 Oct 2020 23:55:23 +0000 (19:55 -0400)]
log: Use CONFIG_IS_ENABLED() for LOG_TEST

Checkpatch complains about using #ifdef for CONFIG variables.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolog: Add additional const qualifier to arrays
Sean Anderson [Tue, 27 Oct 2020 23:55:22 +0000 (19:55 -0400)]
log: Add additional const qualifier to arrays

Both these arrays and their members are const. Fixes checkpatch complaint.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agolog: Fix incorrect documentation of log_filter.cat_list
Sean Anderson [Tue, 27 Oct 2020 23:55:21 +0000 (19:55 -0400)]
log: Fix incorrect documentation of log_filter.cat_list

Logging category lists are terminated by LOGC_END, not LOGC_NONE.

Fixes: e9c8d49d54 ("log: Add an implementation of logging")

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agolog: Fix missing negation of ENOMEM
Sean Anderson [Tue, 27 Oct 2020 23:55:20 +0000 (19:55 -0400)]
log: Fix missing negation of ENOMEM

Errors returned should be negative.

Fixes: 45fac9fc18 ("log: Correct missing free() on error in log_add_filter()")

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoimx6: enable early spi environment access on aristainetos boards
Heiko Schocher [Sat, 10 Oct 2020 08:28:06 +0000 (10:28 +0200)]
imx6: enable early spi environment access on aristainetos boards

On aristianetos boards the display type is detected
through "panel" environment variable. Dependend on the
display type we detect the board type and this decides which
DTB we have to use for the board.

So we need early spi environment access.

Signed-off-by: Heiko Schocher <hs@denx.de>
3 years agoenv: Access Environment in SPI flashes before relocation
Heiko Schocher [Sat, 10 Oct 2020 08:28:05 +0000 (10:28 +0200)]
env: Access Environment in SPI flashes before relocation

Enable the new Kconfig option ENV_SPI_EARLY if you want
to use Environment in SPI flash before relocation.
Call env_init() and than you can use env_get_f() for
accessing Environment variables.

Signed-off-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agoenv: split env_import_redund() into 2 functions
Heiko Schocher [Sat, 10 Oct 2020 08:28:04 +0000 (10:28 +0200)]
env: split env_import_redund() into 2 functions

split from env_import_redund() the part which checks
which Environment is valid into a separate function
called env_check_redund() and call it from env_import_redund().

So env_check_redund() can be used from places which also
need to do this checks.

Signed-off-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
3 years agovideo: rockchip: Add missing dpcd_write() call to link_train_ce()
Alper Nebi Yasak [Tue, 6 Oct 2020 20:39:51 +0000 (23:39 +0300)]
video: rockchip: Add missing dpcd_write() call to link_train_ce()

Found this by comparing it to the coreboot driver, a form of this call
was introduced there in their commit b9a7877568cf ("rockchip/*: refactor
edp driver"). This is copy-pasted from U-Boot's link_train_cr() slightly
above it.

Without this on a gru-kevin chromebook, I have:

    clock recovery at voltage 0 pre-emphasis 0
    requested signal parameters: lane 0 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 3.5dB
    using signal parameters: voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 0 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 3.5dB
    using signal parameters: voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 0 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 3.5dB
    using signal parameters: voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 0 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 3.5dB
    using signal parameters: voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 0 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 3.5dB
    using signal parameters: voltage 0.4V pre_emph 3.5dB
    channel eq failed, ret=-5
    link train failed!
    rk_vop_probe() Device failed: ret=-5

With this, it looks like training succeeds:

    clock recovery at voltage 0 pre-emphasis 0
    requested signal parameters: lane 0 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 3.5dB
    using signal parameters: voltage 0.4V pre_emph 3.5dB
    requested signal parameters: lane 0 voltage 0.4V pre_emph 6dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 6dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 6dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 6dB
    using signal parameters: voltage 0.4V pre_emph 6dB
    requested signal parameters: lane 0 voltage 0.4V pre_emph 0dB
    requested signal parameters: lane 1 voltage 0.4V pre_emph 0dB
    requested signal parameters: lane 2 voltage 0.4V pre_emph 0dB
    requested signal parameters: lane 3 voltage 0.4V pre_emph 0dB
    using signal parameters: voltage 0.4V pre_emph 0dB
    channel eq at voltage 0 pre-emphasis 0
    config video failed
    rk_vop_probe() Device failed: ret=-110

The "config video failed" error also goes away when I disable higher
log levels, and it claims to have successfully probed the device.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agoram: rockchip: px30: add a config-based ddr selection
Heiko Stuebner [Thu, 1 Oct 2020 18:40:03 +0000 (20:40 +0200)]
ram: rockchip: px30: add a config-based ddr selection

The SRAM on the PX30 is not big enough to hold multiple DDR configs
so it needs to be selected during build.

So far simply the DDR3 config was always selected and getting DDR4
or LPDDR2/3 initialized would require a code modification.

So add Kconfig options similar to RK3399 to allow selecting the DDR4
and LPDDR2/3 options instead, while DDR3 stays the default as before.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
3 years agorockchip: Rock960: fix up USB support
Peter Robinson [Tue, 29 Sep 2020 13:06:18 +0000 (14:06 +0100)]
rockchip: Rock960: fix up USB support

Fix up USB config options so keyboards and other USB devices work.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Kever Yang<kever.yang@rock-chips.com>
Change-Id: I34b0696e0ac7303186f20c83278dde340399b690

3 years agorockchip: dts: tinker: remove unnecessary node
Stefan Agner [Fri, 4 Sep 2020 14:11:09 +0000 (16:11 +0200)]
rockchip: dts: tinker: remove unnecessary node

The property reg-shift with the same value is present in the base
device tree already. Remove unnecessary node from rk3288-tinker.dts.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agorockchip: dts: tinker: move i2c node to shared device tree
Stefan Agner [Fri, 4 Sep 2020 14:11:08 +0000 (16:11 +0200)]
rockchip: dts: tinker: move i2c node to shared device tree

The I2C EEPROM is present on Tinker Board S as well. Move the i2c node
to the shared, U-Boot specific rk3288-tinker-u-boot.dtsi device tree.

Cc: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agoclk: rockchip: rk3399: implement getting wdt/alive clocks
Jack Mitchell [Thu, 17 Sep 2020 09:42:06 +0000 (10:42 +0100)]
clk: rockchip: rk3399: implement getting wdt/alive clocks

In order to correctly calculate the designware watchdog
timeouts, the watchdog clock is required. Implement required
clocks to facilitate this.

Signed-off-by: Jack Mitchell <ml@embed.me.uk>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
3 years agobinman: Avoid calculated section data repeatedly
Simon Glass [Mon, 26 Oct 2020 23:40:26 +0000 (17:40 -0600)]
binman: Avoid calculated section data repeatedly

Refactor the implementation slightly so that section data is not
rebuilt when it is already available.

We still have GetData() set up to rebuild the section, since we don't
currently track when things change that might affect a section. For
example, if a blob is updated within a section, we must rebuild it.
Tracking that would be possible but is more complex, so it left for
another time.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Support compression of sections
Simon Glass [Mon, 26 Oct 2020 23:40:25 +0000 (17:40 -0600)]
binman: Support compression of sections

With the previous changes, it is now possible to compress entire
sections. Add some tests to check that compression works correctly,
including updating the metadata.

Also update the documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Use the actual contents in CheckSize()
Simon Glass [Mon, 26 Oct 2020 23:40:24 +0000 (17:40 -0600)]
binman: Use the actual contents in CheckSize()

At present this function adds up the total size of entries to work out the
size of a section's contents. With compression this is no-longer enough.

We may as well bite the bullet and build the section contents instead.
Call _BuildSectionData() to get the (possibly compressed) contents and
GetPaddedData() to get the same but with padding added.

Note that this is inefficient since the section contents is calculated
twice. Future work will improve this.

This affects testPackOverlapMap() since the error is reported with a
different section size now (enough to hold the contents). Update that at
the same time.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Update CheckEntries() for compressed sections
Simon Glass [Mon, 26 Oct 2020 23:40:23 +0000 (17:40 -0600)]
binman: Update CheckEntries() for compressed sections

At present this function assumes that the size of a section is at least as
large as its contents. With compression this is often not the case. Relax
this constraint by using the uncompressed size, if available.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop CheckEntries()
Simon Glass [Mon, 26 Oct 2020 23:40:22 +0000 (17:40 -0600)]
binman: Drop CheckEntries()

This method introduces a separation between packing and checking that is
different for sections. In order to handle compression properly, we need
to be able to deal with a section's size being smaller than the
uncompressed size of its contents. It is easier to make this work if
everything happens in the Pack() method.

The only real user of CheckEntries() is entry_Section and it can call it
directly. Drop the call from 'control' and handle it locally.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Call CheckSize() from the section's Pack() method
Simon Glass [Mon, 26 Oct 2020 23:40:21 +0000 (17:40 -0600)]
binman: Call CheckSize() from the section's Pack() method

At present CheckSize() is called from the function that packs the entries.
Move it up to the main Pack() function so that _PackEntries() can just
do the packing.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop the Entry.CheckSize() method
Simon Glass [Mon, 26 Oct 2020 23:40:20 +0000 (17:40 -0600)]
binman: Drop the Entry.CheckSize() method

This is only used by entry_Section and that class already calls it. Avoid
calling it twice. Also drop it from the documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Move sort and expand to the main Pack() function
Simon Glass [Mon, 26 Oct 2020 23:40:19 +0000 (17:40 -0600)]
binman: Move sort and expand to the main Pack() function

At present sorting and expanding entries are side-effects of the
CheckEntries() function. This is a bit confusing, as 'checking' would
not normally involve making changes.

Move these steps into the Pack() function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop Entry.CheckOffset()
Simon Glass [Mon, 26 Oct 2020 23:40:18 +0000 (17:40 -0600)]
binman: Drop Entry.CheckOffset()

This function just calls CheckEntries() in the only non-trivial
implementation. Drop it and use CheckEntries() directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Avoid reporting image-pos with compression
Simon Glass [Mon, 26 Oct 2020 23:40:17 +0000 (17:40 -0600)]
binman: Avoid reporting image-pos with compression

When a section is compressed, all entries within it are grouped together
into a compressed block of data. This obscures the start of each
individual child entry.

Avoid reporting bogus 'image-pos' properties in this case, since it is
not possible to access the entry at the location provided. The entire
section must be decompressed first.

CBFS does not support compressing whole sections, only individual files,
so needs no special handling here.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Set section contents in GetData()
Simon Glass [Mon, 26 Oct 2020 23:40:16 +0000 (17:40 -0600)]
binman: Set section contents in GetData()

Section contents is not set up when ObtainContents() is called, since
packing often changes the layout of the contents. Ensure that the contents
are correctly recorded by making this function regenerate the section. It
is normally only called by the parent section (when packing) or by the
top-level image code, when writing out the image. So the performance
impact is fairly small.

Now that sections have their contents in their 'data' property, update
testSkipAtStartSectionPad() to check it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Store the original data before compression
Simon Glass [Mon, 26 Oct 2020 23:40:15 +0000 (17:40 -0600)]
binman: Store the original data before compression

When compressing an entry, the original uncompressed data is overwritten.
Store it so it is available if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Make section padding consistent with other entries
Simon Glass [Mon, 26 Oct 2020 23:40:14 +0000 (17:40 -0600)]
binman: Make section padding consistent with other entries

At present padding of sections is inconsistent with other entry types, in
that different pad bytes are used.

When a normal entry is padded by its parent, the parent's pad byte is
used. But for sections, the section's pad byte is used.

Adjust logic to always do this the same way.

Note there is still a special case in entry_Section.GetPaddedData() where
an image is padded with the pad byte of the top-level section. This is
necessary since otherwise there would be no way to set the pad byte of
the image, without adding a top-level section to every image.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Move section padding to the parent
Simon Glass [Mon, 26 Oct 2020 23:40:13 +0000 (17:40 -0600)]
binman: Move section padding to the parent

Each section is padded up to its size, if the contents are not large
enough. Move this logic from _BuildSectionData() to
GetPaddedDataForEntry() so that all the padding is in one place.

With this, the testDual test is working again, so enable it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Refactor _BuildSectionData()
Simon Glass [Mon, 26 Oct 2020 23:40:12 +0000 (17:40 -0600)]
binman: Refactor _BuildSectionData()

At present this function does the padding needed around an entry. It is
easier to understand what is going on if we have a function that returns
the contents of an entry, with padding included.

Refactor the code accordingly, adding a new GetPaddedData() method.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Move section-building code into a function
Simon Glass [Mon, 26 Oct 2020 23:40:11 +0000 (17:40 -0600)]
binman: Move section-building code into a function

Create a new _BuildSectionData() to hold the code that is now in
GetData(), so that it is clearly separated from entry.GetData() base
function.

Separate out the 'pad-before' processing to make this easier to
understand.

Unfortunately this breaks the testDual test. Rather than squash several
patches into an un-reviewable glob, disable the test for now.

This also affects testSkipAtStartSectionPad(), although it still not
quite what it should be. Update that temporarily for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Expand docs and test for alignment
Simon Glass [Mon, 26 Oct 2020 23:40:10 +0000 (17:40 -0600)]
binman: Expand docs and test for alignment

Alignment does form part of the entry once the image is written out, but
within binman the entry contents does not include the padding. Add
documentation to make this clear, as well as a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Expand docs and test for padding
Simon Glass [Mon, 26 Oct 2020 23:40:09 +0000 (17:40 -0600)]
binman: Expand docs and test for padding

Padding becomes part of the entry once the image is written out, but
within binman the entry contents does not include the padding. Add
documentation to make this clear, as well as a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Update testPackExtra with more checks
Simon Glass [Mon, 26 Oct 2020 23:40:08 +0000 (17:40 -0600)]
binman: Update testPackExtra with more checks

Check the contents of each section to make sure it is actually in the
right place.

Also fix a whitespace error in the .dts file.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Use 'files-compress' to set compression for files
Simon Glass [Mon, 26 Oct 2020 23:40:07 +0000 (17:40 -0600)]
binman: Use 'files-compress' to set compression for files

At present we use 'compress' as the property to set the compression of
a 'files' entry. But this conflicts with the same property for entries,
of which Entry_section is a subclass.

Strictly speaking, since Entry_files is in fact a subclass of
Entry_section, the files can be compressed individually but also the
section (that contains all the files) can itself be compressed. With this
change, it is possible to express that.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Move CompressData() into Entry base class
Simon Glass [Mon, 26 Oct 2020 23:40:06 +0000 (17:40 -0600)]
binman: Move CompressData() into Entry base class

At present this is only used by blobs. To allow it to be used by other
entry types (such as sections), move it into the base class.

Also read the compression type in the base class.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Expand the error message for breaching a section
Simon Glass [Mon, 26 Oct 2020 23:40:05 +0000 (17:40 -0600)]
binman: Expand the error message for breaching a section

Add in a few more details to this error message to make it easier to see
what is going on.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Remove references to 'image' in entry_Section
Simon Glass [Mon, 26 Oct 2020 23:40:04 +0000 (17:40 -0600)]
binman: Remove references to 'image' in entry_Section

While a section is the base class of Image, it is more correct to refer
to sections in most places in this file. Fix these comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Fix return from u-boot-ucode if there is no DT
Simon Glass [Mon, 26 Oct 2020 23:40:03 +0000 (17:40 -0600)]
binman: Fix return from u-boot-ucode if there is no DT

This should return empty contents, not leave it unset. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Give a sensible error if no command is given
Simon Glass [Mon, 26 Oct 2020 23:40:02 +0000 (17:40 -0600)]
binman: Give a sensible error if no command is given

At present if 'binman' is typed on the command line, a strange error about
a missing argument is displayed. Fix this.

These does not seem to be standard way to add the 'required' argument in
all recent Python versions, so set it manually.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Add tests for skip-at-start sections
Simon Glass [Mon, 26 Oct 2020 23:40:01 +0000 (17:40 -0600)]
binman: Add tests for skip-at-start sections

At present this feature is tested view the end-at-4gb feature. Add some
tests of its own, including the operation of padding.

The third test here shows binman's current, inconsistent approach to
padding in the top-level section. Future patches in this series will
address this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop unused return variable for _DoTestFile()
Simon Glass [Mon, 26 Oct 2020 23:40:00 +0000 (17:40 -0600)]
binman: Drop unused return variable for _DoTestFile()

This function returns the exit code from binman, not any data. Fix up a
few callers in the tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Update the entry docs
Simon Glass [Mon, 26 Oct 2020 23:39:59 +0000 (17:39 -0600)]
binman: Update the entry docs

This has got out of sync with the entries. Regenerate it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: doc: Update the of-platadata documentation
Simon Glass [Sat, 3 Oct 2020 17:31:42 +0000 (11:31 -0600)]
dm: doc: Update the of-platadata documentation

Update this to incorporate the parent feature as well as other recent
developments.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: Don't allow U_BOOT_DEVICE() when of-platdata is used
Simon Glass [Sat, 3 Oct 2020 17:31:41 +0000 (11:31 -0600)]
dm: Don't allow U_BOOT_DEVICE() when of-platdata is used

With of-platdata, the devicetree is supposed to specify all the devices
in the system. So far this hasn't really mattered since of-platdata still
works correctly.

However, new of-platdata features rely on numbering the devices in a
particular order so that they can be referenced by a single integer. It is
tricky to implement this efficiently when other devices are present in the
build.

To address this, disable use of U_BOOT_DEVICE() when of-platdata is
enabled. This seems acceptable as it is not supposed to be used at all,
except in SPL/TPL, where of-platdata is the recommended approach.

This breaks one non-compliant boards at present: mx6cuboxi

Signed-off-by: Simon Glass <sjg@chromium.org>
(disable CONFIG_IMX_THERMAL for mx6cuboxi to avoid a build error)

3 years agoimx: mx6cuboxi: Disable thermal driver in SPL
Simon Glass [Thu, 29 Oct 2020 17:08:25 +0000 (11:08 -0600)]
imx: mx6cuboxi: Disable thermal driver in SPL

This feature is incompatble with of-platdata since it uses the
U_BOOT_DEVICE() macro. With of-platdata the only devices permitted are
those created by dtoc.

The driver is not used in SPL anyway, so exclude it from that build.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
3 years agodm: Use driver_info index instead of pointer
Simon Glass [Sat, 3 Oct 2020 17:31:40 +0000 (11:31 -0600)]
dm: Use driver_info index instead of pointer

At present we use a 'node' pointer in the of-platadata phandle_n_arg
structs. This is a pointer to the struct driver_info for a particular
device, and we can use it to obtain the struct udevice pointer itself.

Since we don't know the struct udevice pointer until it is allocated in
memory, we have to fix up the phandle_n_arg.node at runtime. This is
annoying since it requires that SPL's data is writable and adds a small
amount of extra (generated) code in the dm_populate_phandle_data()
function.

Now that we can find a driver_info by its index, it is easier to put the
index in the phandle_n_arg structures.

Update dtoc to do this, add a new device_get_by_driver_info_idx() to look
up a device by drive_info index and update the tests to match.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: apl: Take advantage of the of-platdata parent support
Simon Glass [Sat, 3 Oct 2020 17:31:39 +0000 (11:31 -0600)]
x86: apl: Take advantage of the of-platdata parent support

Now that parent devices are supported with of-platadata, we don't need the
messy code to fix up the parent pointers and allocations on Apollo Lake.
Put the code behind a condition.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: apl: Enable SPI flash in TPL with APL_SPI_FLASH_BOOT
Simon Glass [Sat, 3 Oct 2020 17:31:38 +0000 (11:31 -0600)]
x86: apl: Enable SPI flash in TPL with APL_SPI_FLASH_BOOT

At present, enabling CONFIG_APL_SPI_FLASH_BOOT does not build since SPI
and SPI flash are not enabled for TPL. Add a condition to fix this and
tidy up a build warning in the SPI-flash driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Convert #ifdef to if() in root.c
Simon Glass [Sat, 3 Oct 2020 17:31:37 +0000 (11:31 -0600)]
dm: core: Convert #ifdef to if() in root.c

Convert a few conditions to use compile-time checks to reduce the number
of build paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: Add a test for of-platdata parent information
Simon Glass [Sat, 3 Oct 2020 17:31:36 +0000 (11:31 -0600)]
dm: Add a test for of-platdata parent information

Add a simple test that we can obtain the correct parent for an I2C
device. This requires updating the driver names to match the compatible
strings, adding them to the devicetree and enabling a few options.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: Support parent devices with of-platdata
Simon Glass [Sat, 3 Oct 2020 17:31:35 +0000 (11:31 -0600)]
dm: Support parent devices with of-platdata

At present of-platdata does not provide parent information. But this is
useful for I2C devices, for example, since it allows them to determine
which bus they are on.

Add support for setting the parent correctly, by storing the parent
driver_info index in dtoc and reading this in lists_bind_drivers(). This
needs multiple passes since we must process children after their parents
already have been bound.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: Fix up building for of-platdata
Simon Glass [Sat, 3 Oct 2020 17:31:34 +0000 (11:31 -0600)]
sandbox: Fix up building for of-platdata

There is no devicetree with of-platdata. Update a few uclasses to allow
them to be built for sandbox_spl. Also drop the i2c-gpio from SPL to avoid
build errors, since it does not support of-platdata.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: Use an allocated array for run-time device info
Simon Glass [Sat, 3 Oct 2020 17:31:33 +0000 (11:31 -0600)]
dm: Use an allocated array for run-time device info

At present we update the driver_info struct with a pointer to the device
that it created (i.e. caused to be bound). This works fine when U-Boot SPL
is stored in read-write memory. But on some platforms, such as Intel
Apollo Lake, it is not possible to update the data memory.

In any case, it is bad form to put this information in a structure that is
in the data region, since it expands the size of the binary.

Create a new driver_rt structure which holds runtime information about
drivers. Update the code to store the device pointer in this instead.
Also update the test check that this works.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Add a test for of-platdata phandles
Simon Glass [Sat, 3 Oct 2020 17:31:32 +0000 (11:31 -0600)]
dm: test: Add a test for of-platdata phandles

We have a test in dtoc for this feature, but not one in U-Boot itself.
Add a simple test that checks that the information comes through
correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Add a check that all devices have a dev value
Simon Glass [Sat, 3 Oct 2020 17:31:31 +0000 (11:31 -0600)]
dm: test: Add a check that all devices have a dev value

With of-platdata, the driver_info struct is updated with the device
pointer when it is bound. This makes it easy for a device to be found by
its driver info with the device_get_by_driver_info() function.

Add a test that all devices (except the root device) have such an entry.
Fix a bug that the function does not set *devp to NULL on failure, which
the documentation asserts.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: Add a C test for of-platdata properties
Simon Glass [Sat, 3 Oct 2020 17:31:28 +0000 (11:31 -0600)]
dm: Add a C test for of-platdata properties

At present properties are tested in a roundabout way. The driver's probe()
method writes out the values of the properties and the Python test checks
the output from U-Boot SPL.

Add a C test which checks these values more directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoAzure/GitLab/Travis: Add SPL unit tests
Simon Glass [Mon, 26 Oct 2020 02:38:36 +0000 (20:38 -0600)]
Azure/GitLab/Travis: Add SPL unit tests

Run SPL unit tests in all test environments.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Drop of-platdata pytest
Simon Glass [Mon, 26 Oct 2020 02:38:35 +0000 (20:38 -0600)]
dm: test: Drop of-platdata pytest

Now that we have a C version of this test, drop the Python implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agotest: Run only the selected SPL test
Simon Glass [Mon, 26 Oct 2020 02:38:34 +0000 (20:38 -0600)]
test: Run only the selected SPL test

Use the new -k option to select the test to run.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: Allow selection of SPL unit tests
Simon Glass [Mon, 26 Oct 2020 02:38:33 +0000 (20:38 -0600)]
sandbox: Allow selection of SPL unit tests

Now that we have more than one test, add a way to select the test to run.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agotest: Run SPL unit tests
Simon Glass [Mon, 26 Oct 2020 02:38:32 +0000 (20:38 -0600)]
test: Run SPL unit tests

Update the 'run' script to include SPL unit tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agopytest: Collect SPL unit tests
Simon Glass [Mon, 26 Oct 2020 02:38:31 +0000 (20:38 -0600)]
pytest: Collect SPL unit tests

Add a new test_spl fixture to handle running SPL unit tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Generate a symbol file for u-boot-spl
Simon Glass [Mon, 26 Oct 2020 02:38:30 +0000 (20:38 -0600)]
Makefile: Generate a symbol file for u-boot-spl

Add a rule to generate u-boot-spl.sym so that pytest can discover the
available unit tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Add a very simple of-platadata test
Simon Glass [Mon, 26 Oct 2020 02:38:29 +0000 (20:38 -0600)]
dm: test: Add a very simple of-platadata test

At present we have a pytest that covers of-platadata. Add a very simple
unit test that just checks that a device can be found. This shows the
ability to write these tests in C.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Add a way to run SPL tests
Simon Glass [Mon, 26 Oct 2020 02:38:28 +0000 (20:38 -0600)]
dm: test: Add a way to run SPL tests

Add a -u flag for U-Boot SPL which requests that unit tests be run. To
make this work, export dm_test_main() and update it to skip test features
that are not used with of-platdata.

To run the tests:

   $ spl/u-boot-spl -u
   U-Boot SPL 2020.10-rc5 (Oct 01 2020 - 07:35:39 -0600)
   Running 0 driver model tests
   Failures: 0

At present there are no SPL unit tests.

Note that there is one wrinkle with these tests. SPL has limited memory
available for allocation. Also malloc_simple does not free memory
(free() is a nop) and running tests repeatedly causes driver-model to
reinit multiple times and allocate memory. Therefore it is not possible
to run more than a few tests at a time. One solution is to increase the
amount of malloc space in sandbox_spl. This is not a problem for pytest,
since it runs each test individually, so for now this is left as is.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Update the test runner to support of-platdata
Simon Glass [Mon, 26 Oct 2020 02:38:27 +0000 (20:38 -0600)]
dm: test: Update the test runner to support of-platdata

At present DM tests assume that a devicetree is available. This is not the
case with of-platadata.

Update the code to add this condition.

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