platform/kernel/u-boot.git
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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)

4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 years agodm: test: Build tests for SPL
Simon Glass [Mon, 26 Oct 2020 02:38:26 +0000 (20:38 -0600)]
dm: test: Build tests for SPL

We want to run unit tests in SPL. Add a new Kconfig to control this and
enable it for sandbox_spl

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: core: fix typo in device.h
Dario Binacchi [Sun, 11 Oct 2020 12:27:07 +0000 (14:27 +0200)]
dm: core: fix typo in device.h

Replace 'a the' with 'the' in include/dm/device.h.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agosandbox: make SDL window resizable
Heinrich Schuchardt [Fri, 9 Oct 2020 21:44:11 +0000 (23:44 +0200)]
sandbox: make SDL window resizable

Without resizing the SDL window showed by

    ./u-boot -D -l

is not legible on a high resolution screen.

Allow resizing the window

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agodtoc: Fix widening of int to bytes
Simon Glass [Sat, 3 Oct 2020 17:31:27 +0000 (11:31 -0600)]
dtoc: Fix widening of int to bytes

At present an integer is converted to bytes incorrectly. The whole 32-bit
integer is inserted as the first element of the byte array, and the other
three bytes are skipped. This was not noticed because the unit test did
not check it, and the functional test was checking for wrong values.

Update the code to handle this as a special case. Add one more test to
cover all code paths.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: core: Allow dm_warn() to be used in SPL
Simon Glass [Sat, 3 Oct 2020 17:31:26 +0000 (11:31 -0600)]
dm: core: Allow dm_warn() to be used in SPL

At present this option is disabled in SPL, meaning that warnings are not
displayed. It is sometimes useful to see warnings in SPL for debugging
purposes.

Add a new Kconfig option to permit this.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodtoc: Order the structures internally by name
Simon Glass [Sat, 3 Oct 2020 17:31:25 +0000 (11:31 -0600)]
dtoc: Order the structures internally by name

At present the structures are written in name order, but parents have to
be written before their children, so the file does not end up being in
order. The order of nodes in _valid_nodes matches the order of the
devicetree.

Update the code so that _valid_nodes is in sorted order, by C name of
the structure. This allows us to assign a sequential ordering to each
U_BOOT_DEVICE() declaration.

U-Boot's linker lists are also ordered alphabetically, which means that
the order in the driver_info list will match the order used by dtoc. This
defines an index ('idx') for the U_BOOT_DEVICE declarations. They appear
in alphabetical order, numbered from 0 in _valid_nodes and in the
driver_info linker list.

Add a comment against each declaration, showing the idx value.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodtoc: Document the return value of scan_structs()
Simon Glass [Sat, 3 Oct 2020 17:31:24 +0000 (11:31 -0600)]
dtoc: Document the return value of scan_structs()

Add documentation to this function as well as generate_structs(), where
the return value is ultimately passed in.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agosandbox: Drop ad-hoc device declarations in SPL
Simon Glass [Sat, 3 Oct 2020 17:31:23 +0000 (11:31 -0600)]
sandbox: Drop ad-hoc device declarations in SPL

Since sandbox's SPL is build with of-platadata, we should not use
U_BOOT_DEVICE() declarations as well. Drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: test: Disable some tests that should not run in SPL
Simon Glass [Sat, 3 Oct 2020 15:25:26 +0000 (09:25 -0600)]
dm: test: Disable some tests that should not run in SPL

Tests are easier to run in U-Boot proper. Running them in SPL does not add
test coverage in most cases. Also some tests use features that are not
available in SPL.

Update the build rules to disable these tests in SPL. We still need
test-main to be able to actually run SPL tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: test: Make use of CONFIG_UNIT_TEST
Simon Glass [Sat, 3 Oct 2020 15:25:25 +0000 (09:25 -0600)]
dm: test: Make use of CONFIG_UNIT_TEST

At present we always include test/dm from the main Makefile. We have a
CONFIG_UNIT_TEST that should control whether the test/ directory is built,
so rely on that instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: test: Update Makefile conditions
Simon Glass [Sat, 3 Oct 2020 15:25:24 +0000 (09:25 -0600)]
dm: test: Update Makefile conditions

At present most of the tests in test/Makefile are dependent on
CONFIG_SANDBOX. But this is not ideal since they rely on commands being
available and SPL does not support commands.

Use CONFIG_COMMAND instead. This has the dual purpose of allowing these
tests to be used on other boards and allowing SPL to skip them.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: test: Sort the Makefile
Simon Glass [Sat, 3 Oct 2020 15:25:23 +0000 (09:25 -0600)]
dm: test: Sort the Makefile

Move everything into alphabetical order.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: Avoid using #ifdef for CONFIG_OF_LIVE
Simon Glass [Sat, 3 Oct 2020 15:25:22 +0000 (09:25 -0600)]
dm: Avoid using #ifdef for CONFIG_OF_LIVE

At present this option results in a number of #ifdefs due to the presence
or absence of the global_data of_root member.

Add a few macros to global_data.h to work around this. Update the code
accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: core: Avoid void * in the of-platdata structs
Simon Glass [Sat, 3 Oct 2020 15:25:21 +0000 (09:25 -0600)]
dm: core: Avoid void * in the of-platdata structs

These pointers point to drivers. Update the definition to make this clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodm: core: Expand the comment for DM_GET_DEVICE()
Simon Glass [Sat, 3 Oct 2020 15:25:20 +0000 (09:25 -0600)]
dm: core: Expand the comment for DM_GET_DEVICE()

The current documentation for this is not particularly enlightening. Add
a little more detail.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodtoc: Use a namedtuple for _links
Simon Glass [Sat, 3 Oct 2020 15:25:19 +0000 (09:25 -0600)]
dtoc: Use a namedtuple for _links

The use of strings to access a dict is a bit ugly. Use a namedtuple for
this instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agodtoc: Extract inner loop from output_node()
Simon Glass [Sat, 3 Oct 2020 15:25:18 +0000 (09:25 -0600)]
dtoc: Extract inner loop from output_node()

This function is very long. Put the inner loop in a separate function
to enhance readability.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Support multiple images in the library
Simon Glass [Mon, 28 Sep 2020 00:46:20 +0000 (18:46 -0600)]
binman: Support multiple images in the library

Add support for multiple images, since these are used on x86 now. Select
the first image for now, since that is generally the correct one. At some
point we can add a way to determine which image is currently running.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add a way to read the ROM offset
Simon Glass [Mon, 28 Sep 2020 00:46:19 +0000 (18:46 -0600)]
binman: Add a way to read the ROM offset

Provide a function to read the ROM offset so that we can store the value
in one place and clients don't need to store it themselves after calling
binman_set_rom_offset().

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agoconfigs: Resync with savedefconfig
Tom Rini [Thu, 29 Oct 2020 14:48:01 +0000 (10:48 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
4 years agoMAINTAINERS, git-mailrc: Update sunxi maintainers
Andre Przywara [Wed, 28 Oct 2020 23:37:43 +0000 (23:37 +0000)]
MAINTAINERS, git-mailrc: Update sunxi maintainers

Maxime mentioned that he feels not having the time to be an Allwinner
maintainer anymore. Take over from him.

Maxime, many thanks for your great work in the past! I hope I can still
relay the occasional technical question to you in the future.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
4 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
Tom Rini [Thu, 29 Oct 2020 13:10:24 +0000 (09:10 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq

- Bug fixes and updates on vid, ls1088a lx2160a and other layerscape
  platforms.
- Add optee_rpmb support for LX2 & Kontron sl28 support

4 years agoPrepare v2021.01-rc1
Tom Rini [Wed, 28 Oct 2020 20:30:06 +0000 (16:30 -0400)]
Prepare v2021.01-rc1

Signed-off-by: Tom Rini <trini@konsulko.com>
4 years agoMerge branch '2020-10-28-mux-driver-framework'
Tom Rini [Wed, 28 Oct 2020 18:50:09 +0000 (14:50 -0400)]
Merge branch '2020-10-28-mux-driver-framework'

- Add a framework for mux drivers

4 years agotest: mux-cmd: Add tests for the 'mux' command
Pratyush Yadav [Fri, 16 Oct 2020 10:46:36 +0000 (16:16 +0530)]
test: mux-cmd: Add tests for the 'mux' command

Tests tests run the three mux subcommands: list, select, and deselect,
and verify that the commands do what we expect.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agocmd: Add a mux command
Pratyush Yadav [Fri, 16 Oct 2020 10:46:35 +0000 (16:16 +0530)]
cmd: Add a mux command

This command lets the user list, select, and deselect mux controllers
introduced with the mux framework on the fly. It has 3 subcommands:
list, select, and deselect.

List: Lists all the mux present on the system. The muxes are listed for
each chip. The chip is identified by its device name. Each chip can have
a number of mux controllers. Each is listed in sequence and is assigned
a sequential ID based on its position in the mux chip. It lists details
like ID, whether the mux is currently selected or not, the current
state, the idle state, and the number of states.

A sample output would look something like:

=> mux list
a-mux-controller:
ID Selected Current State Idle State Num States
0 no         unknown    as-is      0x4
1 no         0x2        0x2        0x10
2 no         0x73       0x73       0x100

another-mux-controller:
ID Selected Current State Idle State Num States
        0       no              0x1             0x1             0x4
        1       no              0x2             0x2             0x4

Select: Selects a given mux and puts it in the specified state. This
subcommand takes 3 arguments: mux chip, mux ID, state to set
the mux in. The arguments mux chip and mux ID are used to identify which
mux needs to be selected, and then it is selected to the given state.
The mux needs to be deselected before it can be selected again in
another state. The state should be a hexadecimal number.

For example:
=> mux list
a-mux-controller:
        ID      Selected        Current State   Idle State      Num States
        0       no              0x1             0x1             0x4
        1       no              0x1             0x1             0x4
=> mux select a-mux-controller 0 0x3
=> mux list
a-mux-controller:
        ID      Selected        Current State   Idle State      Num States
        0       yes             0x3             0x1             0x4
        1       no              0x1             0x1             0x4

Deselect: Deselects a given mux and puts it in its idle state. This
subcommand takes 2 arguments: the mux chip and mux ID to identify which
mux needs to be deselected. So in the above example, we can deselect mux
0 using:

=> mux deselect a-mux-controller 0
=> mux list
a-mux-controller:
        ID      Selected        Current State   Idle State      Num States
        0       no              0x1             0x1             0x4
        1       no              0x1             0x1             0x4

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agotest: Add tests for the multiplexer framework
Jean-Jacques Hiblot [Fri, 16 Oct 2020 10:46:34 +0000 (16:16 +0530)]
test: Add tests for the multiplexer framework

Provide tests to check the behavior of the multiplexer framework.

Two sets of tests are added. One is using an emulated multiplexer driver
that can be used to test basic functionality like select, deselect, etc.
The other is using the mmio mux which adds tests specific to it.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agoKconfig: Increase the pre-relocation memory
Pratyush Yadav [Fri, 16 Oct 2020 10:46:33 +0000 (16:16 +0530)]
Kconfig: Increase the pre-relocation memory

The memory is close to full and adding a syscon node in test.dts makes
it go over the limit and makes malloc() fail on startup.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agodrivers: mux: mmio-based syscon mux controller
Jean-Jacques Hiblot [Fri, 16 Oct 2020 10:46:32 +0000 (16:16 +0530)]
drivers: mux: mmio-based syscon mux controller

This adds a driver for mmio-based syscon multiplexers controlled by
bitfields in a syscon register range.
This is heavily based on the linux mmio-mux driver.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
4 years agodm: board: complete the initialization of the muxes in initr_dm()
Jean-Jacques Hiblot [Fri, 16 Oct 2020 10:46:31 +0000 (16:16 +0530)]
dm: board: complete the initialization of the muxes in initr_dm()

This will probe the multiplexer devices that have a "u-boot,mux-autoprobe"
property. As a consequence they will be put in their idle state.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
4 years agodrivers: Add a new framework for multiplexer devices
Jean-Jacques Hiblot [Fri, 16 Oct 2020 10:46:30 +0000 (16:16 +0530)]
drivers: Add a new framework for multiplexer devices

Add a new subsystem that handles multiplexer controllers. The API is the
same as in Linux.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
[trini: Update some error calls to use different functions or pass
        correct arguments]
Signed-off-by: Tom Rini <trini@konsulko.com>
4 years agoMerge tag 'efi-2021-01-rc2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Wed, 28 Oct 2020 12:35:28 +0000 (08:35 -0400)]
Merge tag 'efi-2021-01-rc2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi

Pull request for UEFI sub-system for efi-2021-01-rc2

A software RTC driver is supplied for UEFI SCT testing.

The following UEFI related bugs are fixed:

* correct handling of daylight saving time in GetTime() and SetTime()
* handling of the gd register in function tracing on RISC-V
* disable U-Boot devices in ExitBootServices()

4 years agoMerge branch '2020-10-27-further-log-enhancements'
Tom Rini [Wed, 28 Oct 2020 12:34:11 +0000 (08:34 -0400)]
Merge branch '2020-10-27-further-log-enhancements'

- Allow for log message continuation.
- Test fix, build time error checking for new categories

4 years agolog: correct and check array size of log categories
Heinrich Schuchardt [Fri, 23 Oct 2020 11:00:01 +0000 (13:00 +0200)]
log: correct and check array size of log categories

The log command has led to NULL dereferences if an unknown category name
name was used due to missing entries in the list of category names.

Add compile time checks for the array sizes of log_cat_name and
log_lvl_name to avoid future mishaps.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agoefi_loader: daylight saving time
Heinrich Schuchardt [Fri, 23 Oct 2020 03:30:29 +0000 (05:30 +0200)]
efi_loader: daylight saving time

Adjust the SetTime() and GetTime() runtime services to correctly convert
the daylight saving time information when communicating with the RTC.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agoefi_loader: Disable devices before handing over control
Ilias Apalodimas [Wed, 21 Oct 2020 22:04:21 +0000 (01:04 +0300)]
efi_loader: Disable devices before handing over control

U-Boot Driver Model is supposed to remove devices with either
DM_REMOVE_ACTIVE_DMA or DM_REMOVE_OS_PREPARE flags set, before exiting.
Our bootm command does that by explicitly calling calling
"dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);" and we also disable any
USB devices.

The EFI equivalent is doing none of those at the moment. As a result
probing an fTPM driver now renders it unusable in Linux. During our
(*probe) callback we open a session with OP-TEE, which is supposed to
close with our (*remove) callback. Since the (*remove) is never called,
once we boot into Linux and try to probe the device again we are getting
a busy error response. Moreover all uclass (*preremove) functions won't
run.

So let's fix this by mimicking what bootm does and disconnect devices
when efi_exit_boot_services() is called.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agoefi_loader: Sort header file ordering
Ilias Apalodimas [Wed, 21 Oct 2020 22:04:20 +0000 (01:04 +0300)]
efi_loader: Sort header file ordering

Order header files according to https://www.denx.de/wiki/U-Boot/CodingStyle

Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agotrace: conserve gd register on RISC-V
Heinrich Schuchardt [Thu, 15 Oct 2020 10:30:09 +0000 (12:30 +0200)]
trace: conserve gd register on RISC-V

An UEFI application may change the value of the register that gd lives in.
But some of our functions like get_ticks() access this register. So we
have to set the gd register to the U-Boot value when entering a trace
point and set it back to the application value when exiting the trace
point.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agortc: provide an emulated RTC
Heinrich Schuchardt [Thu, 22 Oct 2020 21:52:14 +0000 (23:52 +0200)]
rtc: provide an emulated RTC

On a board without hardware clock this software real time clock can be
used. The build time is used to initialize the RTC. So you will have
to adjust the time either manually using the 'date' command  or use
the 'sntp' to update the RTC with the time from a network time server.
See CONFIG_CMD_SNTP and CONFIG_BOOTP_NTPSERVER. The RTC time is
advanced according to CPU ticks.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agoMakefile: provide constant with seconds since epoch
Heinrich Schuchardt [Sun, 25 Oct 2020 06:25:05 +0000 (07:25 +0100)]
Makefile: provide constant with seconds since epoch

Provide a constant U_BOOT_EPOCH with the number of seconds since
1970-01-01. This constant can be used to initialize a software
real time clock until it is updated via the 'sntp' command.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
4 years agotest: log: test message continuation
Heinrich Schuchardt [Sat, 17 Oct 2020 12:31:59 +0000 (14:31 +0200)]
test: log: test message continuation

Provide a unit test checking that a continuation message will use the same
log level and log category as the previous message.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agolog: allow for message continuation
Heinrich Schuchardt [Sat, 17 Oct 2020 12:31:58 +0000 (14:31 +0200)]
log: allow for message continuation

Some drivers use macro pr_cont() for continuing a message sent via printk.
Hence if we want to convert printk messaging to using the logging system,
we must support continuation of log messages too.

As pr_cont() does not provide a message level we need a means of
remembering the last log level.

With the patch a pseudo log level LOGL_CONT as well as a pseudo log
category LOGC_CONT are introduced. Using these results in the application
of the same log level and category as in the previous log message.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agolog: move processing_msg to global data
Heinrich Schuchardt [Sat, 17 Oct 2020 12:31:57 +0000 (14:31 +0200)]
log: move processing_msg to global data

Replace the static variable processing_msg by a field in the global data.
Make the field bool at it can only be true or false.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agonokia_rx51: re-enable CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV
Anatolij Gustschin [Tue, 27 Oct 2020 07:47:17 +0000 (08:47 +0100)]
nokia_rx51: re-enable CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV

With disabled legacy VIDEO option CONSOLE_MUX is not auto-selected
any more, re-enable it.

Fixes: 9dec5a0ea130 ("nokia_rx51: disable obsolete VIDEO config")
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
4 years agoMerge tag 'video-for-2021.01-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot...
Tom Rini [Mon, 26 Oct 2020 21:27:38 +0000 (17:27 -0400)]
Merge tag 'video-for-2021.01-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot-video

 - disable CONFIG_VIDEO to remove DM conversion warnings
   for boards: at91sam9, eb_cpu5282, ls1021aqds, ls1021atwr,
   mx23evk, mx6sxsabresd, mx7dsabresd, nokia_rx51, picosam9g45,
   sansa_fuze_plus, xfi3

4 years agonokia_rx51: disable obsolete VIDEO config
Anatolij Gustschin [Mon, 26 Oct 2020 18:50:58 +0000 (19:50 +0100)]
nokia_rx51: disable obsolete VIDEO config

Disable VIDEO config to fix DM_VIDEO conversion
deadline warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 years agoeb_cpu5282: fix CONFIG_DM_VIDEO build warnings
Anatolij Gustschin [Sun, 18 Oct 2020 18:32:35 +0000 (20:32 +0200)]
eb_cpu5282: fix CONFIG_DM_VIDEO build warnings

Remove CONFIG_VIDEO dependency to fix board removal warnings.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Jens Scharsig <esw@bus-elektronik.de>
4 years agosansa_fuze_plus: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 17:32:06 +0000 (19:32 +0200)]
sansa_fuze_plus: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
4 years agoxfi3: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 16:36:23 +0000 (18:36 +0200)]
xfi3: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
4 years agomx23evk: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 16:33:45 +0000 (18:33 +0200)]
mx23evk: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Otavio Salvador <otavio@ossystems.com.br>
4 years agoat91sam9n12ek: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 17:29:07 +0000 (19:29 +0200)]
at91sam9n12ek: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.
Boards should convert to DM_VIDEO if they need video console
support.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
4 years agoat91sam9: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 16:04:34 +0000 (18:04 +0200)]
at91sam9: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 years agopicosam9g45: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 16:00:35 +0000 (18:00 +0200)]
picosam9g45: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Erik van Luijk <evanluijk@interact.nl>
4 years agols1021atwr: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 15:58:21 +0000 (17:58 +0200)]
ls1021atwr: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 years agols1021aqds: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 15:57:25 +0000 (17:57 +0200)]
ls1021aqds: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Alison Wang <alison.wang@nxp.com>
4 years agoimx: mx7dsabresd: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 15:55:20 +0000 (17:55 +0200)]
imx: mx7dsabresd: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 years agoimx: mx6sxsabresd: disable obsolete VIDEO config
Anatolij Gustschin [Sun, 18 Oct 2020 15:54:05 +0000 (17:54 +0200)]
imx: mx6sxsabresd: disable obsolete VIDEO config

DM_VIDEO conversion deadline has passed, disable VIDEO config.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
4 years agoMerge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Mon, 26 Oct 2020 12:25:37 +0000 (08:25 -0400)]
Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-riscv

- No need to check before free in kendryte clk.
- Only enable OF_BOARD_FIXUP if U-Boot is configured for S-Mode.
- Reduce k210 dts DMA block size
- Move timers into drivers/timer
- Correct fu540 dts reg size of clint node

4 years agoriscv: fu540: dts: Correct reg size of clint node
Pragnesh Patel [Tue, 20 Oct 2020 05:33:02 +0000 (11:03 +0530)]
riscv: fu540: dts: Correct reg size of clint node

Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agoriscv: Move timer portions of SiFive CLINT to drivers/timer
Sean Anderson [Mon, 26 Oct 2020 01:46:58 +0000 (21:46 -0400)]
riscv: Move timer portions of SiFive CLINT to drivers/timer

Half of this driver is a DM-based timer driver, and half is RISC-V-specific
IPI code. Move the timer portions in with the other timer drivers. The
KConfig is not moved, since it also enables IPIs. It could also be split
into two configs, but no boards use the timer but not the IPI atm, so I
haven't split it.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agotimer: Add _TIMER suffix to Andes PLMT Kconfig
Sean Anderson [Mon, 26 Oct 2020 01:46:57 +0000 (21:46 -0400)]
timer: Add _TIMER suffix to Andes PLMT Kconfig

This matches the naming scheme of other timer drivers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agoriscv: Move Andes PLMT driver to drivers/timer
Sean Anderson [Mon, 26 Oct 2020 01:46:56 +0000 (21:46 -0400)]
riscv: Move Andes PLMT driver to drivers/timer

This is a regular timer driver, and should live with the other timer
drivers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agoriscv: k210: Reduce DMA block size
Sean Anderson [Mon, 12 Oct 2020 18:18:15 +0000 (14:18 -0400)]
riscv: k210: Reduce DMA block size

Although the max DMA size supported by the hardware register is 22 bits (or
4M), the Linux driver for this device only supports transfers of up to 2M.
On a device with 8M total memory, I don't think it will make too much of a
difference.

Reported-by: Damien Le Moal <Damien.LeMoal@wdc.com>
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Rick Chen <rick@andestech.com>
4 years agoriscv: Only enable OF_BOARD_FIXUP for S-Mode
Sean Anderson [Sat, 5 Sep 2020 13:22:11 +0000 (09:22 -0400)]
riscv: Only enable OF_BOARD_FIXUP for S-Mode

It is unsafe to enable OF_BOARD_FIXUP only based on OF_SEPARATE.
OF_SEPARATE may indicate that the user wishes U-Boot to use a different
device tree than one obtained via OF_PRIOR_STAGE. However, OF_SEPARATE may
also indicate that the device tree which would be obtained via
OF_PRIOR_STAGE is invalid, nonexistant, or otherwise unusable. In this
latter case, enabling OF_BOARD_FIXUP will result in corruption of the
device tree. To remedy this, only enable OF_BOARD_FIXUP if U-Boot is
configured for S-Mode.

Fixes: 1c17e55594a394ced7de88d91be294eaf8c564c1
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Leo Liang <ycliang@andestech.com>
4 years agoclk: kendryte: no need to check argument of free()
Heinrich Schuchardt [Tue, 29 Sep 2020 19:52:12 +0000 (21:52 +0200)]
clk: kendryte: no need to check argument of free()

free() checks if its argument is NULL. No need to check it twice.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
4 years agoMerge branch '2020-10-23-misc-changes'
Tom Rini [Sat, 24 Oct 2020 14:49:28 +0000 (10:49 -0400)]
Merge branch '2020-10-23-misc-changes'

Highlights:
- Fix a problem with the bootm overlap tests
- Remove duplicated code in fatwrite
- Cleanup our current "misc" command code and add a new one for misc
  class devices.
- Various GPIO fixes

4 years agopower: regulator: add dummy helper
Peng Fan [Thu, 15 Oct 2020 10:06:48 +0000 (18:06 +0800)]
power: regulator: add dummy helper

Add dummy helper to enabling the header could be included when
DM REGULATOR not enabled.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agophy: nop-phy: add clk bulk
Peng Fan [Thu, 15 Oct 2020 10:05:58 +0000 (18:05 +0800)]
phy: nop-phy: add clk bulk

Add clk bulk for nop-phy driver.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agobootm: fix wrong conditions about images overlap
Jaehoon Chung [Wed, 21 Oct 2020 05:17:03 +0000 (14:17 +0900)]
bootm: fix wrong conditions about images overlap

It doesn't need to consider start byte address.
If ramdisk size is 0x800000 and start address is 0x2700000, then it's
used until 0x02efffff, not 0x02f00000. But it's detected to overlapt RD
image, when kernel start address is 0x02f00000.
Because it's doing wrong calculation about rd_len.
This patch fixed wrong calculation address position when check
condition.

In addition, it needs to check one more condition about overlapping
entire area.

Fixes: commit fbde7589ce30 ("common: bootm: add checks to verify if ramdisk / fdtimage overlaps OS image")

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
4 years agocmd: fat: Use do_save() for fatwrite
Lad Prabhakar [Tue, 20 Oct 2020 07:45:46 +0000 (08:45 +0100)]
cmd: fat: Use do_save() for fatwrite

do_save() function defined in fs.c also supports FAT file system
re-use the same for fatwrite command.

Also fix the FAT test script to match the expected output.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
4 years agotest: unit tests for print_freq(), print_size()
Heinrich Schuchardt [Thu, 22 Oct 2020 19:45:28 +0000 (21:45 +0200)]
test: unit tests for print_freq(), print_size()

Provide unit tests for functions print_freq() and print_size().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>