platform/kernel/u-boot.git
3 years agocbfs: Support reading compression information
Simon Glass [Mon, 15 Mar 2021 05:00:16 +0000 (18:00 +1300)]
cbfs: Support reading compression information

CBFS now supports compressed filed. Add support for reading this
information so that the correct decompression can be applied. The
decompression itself is not implemented in CBFS.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocbfs: Simplify file iteration
Simon Glass [Mon, 15 Mar 2021 05:00:15 +0000 (18:00 +1300)]
cbfs: Simplify file iteration

In file_cbfs_next_file() there is a lot of complicated code to move to
the next file. Use the ALIGN() macros to simplify this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocbfs: Factor out filling a cache node into a new function
Simon Glass [Mon, 15 Mar 2021 05:00:14 +0000 (18:00 +1300)]
cbfs: Factor out filling a cache node into a new function

The file_cbfs_next_file() function is already fairly long. Before
expanding it further, move the core part into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocbfs: Allow file traversal with any CBFS
Simon Glass [Mon, 15 Mar 2021 05:00:13 +0000 (18:00 +1300)]
cbfs: Allow file traversal with any CBFS

The file traversal functions currently use a single global CBFS. In some
cases we need to access multiple CBFSs to obtain different files. Add new
functions to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocbfs: Allow access to CBFS without a header
Simon Glass [Mon, 15 Mar 2021 05:00:12 +0000 (18:00 +1300)]
cbfs: Allow access to CBFS without a header

In some cases CBFS does not start with a header but is just a collection
of files. It is possible to support this so long as the size of the CBFS
is provided.

Update the cbfs_init_mem() function to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosmbios: Allow writing to the coreboot version string
Simon Glass [Mon, 15 Mar 2021 05:00:11 +0000 (18:00 +1300)]
smbios: Allow writing to the coreboot version string

When U-Boot is booted from coreboot the SMBIOS tables are written by
coreboot, not U-Boot. The existing method of updating the BIOS version
string does not work in that case, since gd->smbios_version is only set
when U-Boot writes the tables.

Add a new function which allows the version to be updated by parsing the
tables and writing the string in the correct place. Since coreboot
provides a pointer to the SMBIOS tables in its sysinfo structure, this
makes it easy to do the update.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocbfs: Rename new_node to node
Simon Glass [Mon, 15 Mar 2021 05:00:10 +0000 (18:00 +1300)]
cbfs: Rename new_node to node

Rename this variable since there is no need to distinguish it from an old
node.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agocbfs: Add support for attributes
Simon Glass [Mon, 15 Mar 2021 05:00:09 +0000 (18:00 +1300)]
cbfs: Add support for attributes

CBFS now supports attributes for things that cannot fit in the header as
originally conceived. Add the structures for these.

Also rename attributes_offset to something shorter, to ease code
readability.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agommc: pci_mmc: Set up the card detect
Simon Glass [Mon, 15 Mar 2021 05:00:08 +0000 (18:00 +1300)]
mmc: pci_mmc: Set up the card detect

The driver currently reads the card-detect but does not register it with
the MMC stack. Update this so that card-detect works as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agotegra: i2c: Drop LOG_DEBUG
Simon Glass [Mon, 15 Mar 2021 05:00:07 +0000 (18:00 +1300)]
tegra: i2c: Drop LOG_DEBUG

We should not enable debugging by default. Drop this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: coral: Update the SD card-detect GPIO
Simon Glass [Mon, 15 Mar 2021 05:00:06 +0000 (18:00 +1300)]
x86: coral: Update the SD card-detect GPIO

Since the recent bug fix, it doesn't matter which GPIO phandle is used so
long as the GPIO number is right. Still, we may as well use the correct
one to avoid confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agox86: coral: Put the eMMC first
Simon Glass [Mon, 15 Mar 2021 05:00:05 +0000 (18:00 +1300)]
x86: coral: Put the eMMC first

At present the eMMC device does not have an alias so it appears after
the SD card which is device 1. There is no device 0 which is odd.

Make the eMMC device be the first one. Update the boot script to use the
new device.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agox86: Probe device if needed in intel_gpio_xlate()
Simon Glass [Mon, 15 Mar 2021 05:00:04 +0000 (18:00 +1300)]
x86: Probe device if needed in intel_gpio_xlate()

The Intel GPIO binding allows GPIOs to be globally numbered, so that it
does not matter which GPIO bank is specified in the device tree. This is
convenient and avoid confusion since the banks do not have the same number
of GPIOs and the numbering is not sequential.

The GPIO uclass ensures that the device mentioned in the devicetree
binding is probed. It is fine for the driver to update gpio_desc to point
to a different driver, but this may not have been probed. If it has not
been, then it cannot be claimed since there is no uclass data.

We could handle this in the GPIO uclass but so far it is an unusual
situation so it is probably not worth the extra code. Handle this case in
the GPIO driver by probing the selected device if necessary.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: p2sb: Drop LOG_DEBUG
Simon Glass [Mon, 15 Mar 2021 05:00:03 +0000 (18:00 +1300)]
x86: p2sb: Drop LOG_DEBUG

We should not enable debugging by default. Drop this.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: coral: Add information about building / running
Simon Glass [Mon, 15 Mar 2021 05:00:02 +0000 (18:00 +1300)]
x86: coral: Add information about building / running

Add detailed information on how to build the coral image, since it needs
binary blobs. Provide a way to avoid the memory-training delay.  Also show
the console output from a sample run.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: coral: Free the ACPI GPIOs after using them
Simon Glass [Mon, 15 Mar 2021 05:00:01 +0000 (18:00 +1300)]
x86: coral: Free the ACPI GPIOs after using them

These GPIOs are needed later if Chromium OS verified boot is running,
so free them after use.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agomtd: spi_flash_free()
Heinrich Schuchardt [Wed, 10 Mar 2021 17:23:57 +0000 (18:23 +0100)]
mtd: spi_flash_free()

dfu_free_entities() invoking dfu_free_entity_sf() has let to segementation
faults due to double freeing the same device.

spi_flash_free() is not relevant for the driver model but exists only for
compatibility with old drivers.

We must not remove any device here:

* The device may still be referenced.
* We don't want to have to probe again.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agosandbox: dtsi: add rng
Vincent Stehlé [Wed, 10 Mar 2021 14:33:30 +0000 (15:33 +0100)]
sandbox: dtsi: add rng

Having an rng in the sandbox is useful not only for tests but also for e.g.
UEFI. Therefore, copy the rng node from test.dts to sandbox.dtsi.

In the case of UEFI, it can then be verified with `efidebug dh' that a
"Random Number Generator" protocol is indeed present.

This also fixes the following `bootefi' error:

  Missing RNG device for EFI_RNG_PROTOCOL

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Simon Glass <sjg@chromium.org>
3 years agoMerge tag 'dm-pull-26mar21-take2' of git://git.denx.de/u-boot-dm into next
Tom Rini [Fri, 26 Mar 2021 16:15:26 +0000 (12:15 -0400)]
Merge tag 'dm-pull-26mar21-take2' of git://git.denx.de/u-boot-dm into next

dtoc support for of-platdata-inst
driver model support for of-platdata-inst
support of-platdata-inst on x86 / coral
binman support for exapanded entries
binman convert docs to reST
ti-sysc fix for duplicate uclass driver
patman minor improvements
pylibfdt build only if needed
correct obscure CI error with OF_PLATDATA_INST

3 years agobinman: Update various pieces of the documentation
Simon Glass [Thu, 18 Mar 2021 07:25:17 +0000 (20:25 +1300)]
binman: Update various pieces of the documentation

A few sections are a little out of date now. Update them.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop repetitive heading for each entry
Simon Glass [Thu, 18 Mar 2021 07:25:16 +0000 (20:25 +1300)]
binman: Drop repetitive heading for each entry

Many entries start 'Entry containing a'. This looks fine in the source
code but is annoying when viewed in the htmldocs table of contents. Drop
these unnecessary words.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Incorporate entry documentation
Simon Glass [Thu, 18 Mar 2021 07:25:15 +0000 (20:25 +1300)]
binman: Incorporate entry documentation

Update this to avoid sphinx warnings and incorporate it into the new
documentaiton tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Rearrange documentation into headings
Simon Glass [Thu, 18 Mar 2021 07:25:14 +0000 (20:25 +1300)]
binman: Rearrange documentation into headings

Collect the material into different top-level headings to make it easier
to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: doc: Add documentation to htmldocs
Simon Glass [Thu, 18 Mar 2021 07:25:13 +0000 (20:25 +1300)]
binman: doc: Add documentation to htmldocs

Add a link to binman's documentation and adjust the files so that it is
accessible. Use the name README.rst so it is easy to discover when binman
is installed without U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodoc: Move driver model docs under develop/
Simon Glass [Thu, 18 Mar 2021 07:25:12 +0000 (20:25 +1300)]
doc: Move driver model docs under develop/

These docs are useful for developers, not users. Move them under that
section.

Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodoc: Move UEFI under develop/
Simon Glass [Thu, 18 Mar 2021 07:25:11 +0000 (20:25 +1300)]
doc: Move UEFI under develop/

Much of the content here is useful only for development. Move it under
that section.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agox86: dts: Drop unused CONFIG_SPL
Simon Glass [Thu, 18 Mar 2021 07:25:10 +0000 (20:25 +1300)]
x86: dts: Drop unused CONFIG_SPL

This cannot be used since the previous #elif has already dealt with SPL.
Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: Make use of binman expanded entries
Simon Glass [Thu, 18 Mar 2021 07:25:09 +0000 (20:25 +1300)]
x86: Make use of binman expanded entries

We don't need to spell out the separate pieces of U-Boot phase binaries
anymore. Revert to using the simple entry and let binman do the expansion
itself as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Pass new entry args to binman
Simon Glass [Thu, 18 Mar 2021 07:25:08 +0000 (20:25 +1300)]
Makefile: Pass new entry args to binman

To support the use of 'expanded' entries, binman needs to be told whether
SPL and TPL have a devicetree and whether they need BSS padding. Add these
to the Makefile.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Automatically expand phase binaries into sections
Simon Glass [Thu, 18 Mar 2021 07:25:07 +0000 (20:25 +1300)]
binman: Automatically expand phase binaries into sections

When creating an entry, check for an expanded version of that entry, then
use it instead. This allows, for example use of:

   u-boot {
   };

instead of having to write out in full:

   u-boot {
      type = "section";

      u-boot-nodtb {
      };

      u-boot-dtb {
      };
   };

Add an implementaion of this and associated documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Plumb expanded entries through fully
Simon Glass [Thu, 18 Mar 2021 07:25:06 +0000 (20:25 +1300)]
binman: Plumb expanded entries through fully

Add support for this feature in the control, image and section modules, so
that expanded entries will be selected by default. So far there are no
expanded entry types, so this is a nop.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Allow a way to select expanded entries
Simon Glass [Thu, 18 Mar 2021 07:25:05 +0000 (20:25 +1300)]
binman: Allow a way to select expanded entries

Add a new command-line option to disable expanded entries. This is needed
for most tests, since it is much easier to 'factor out' this function into
a separate test and keep the existing packing tests simple.

Add the option and select it by default from tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Allow using an an 'expanded' entry type
Simon Glass [Thu, 18 Mar 2021 07:25:04 +0000 (20:25 +1300)]
binman: Allow using an an 'expanded' entry type

As the first step in supporting expanded entries, add a way for binman to
automatically select an 'expanded' version of an entry type, if requested.
This is controlled by a class method.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Use standard filenames for SPL/TPL devicetree
Simon Glass [Thu, 18 Mar 2021 07:25:03 +0000 (20:25 +1300)]
binman: Use standard filenames for SPL/TPL devicetree

At present, before any entry expansion is done (such as a 'files' entry
expanding out to individual entries for each file it contains), we check
the binman definition (i.e. '/binman' node) to find out what devicetree
files are used in the images.

This is a pain, since the definition may change during expansion. For
example if there is no u-boot-spl-dtb entry in the definition at the start,
we assume that the SPL devicetree is not used. But if an entry later
expands to include this, then we don't notice.

In fact the flexibility provided by the current approach of checking the
definition is not really useful. We know that we can have SPL and TPL
devicetrees. We know the pathname to each, so we can simply check if the
files are present. If they are present, we can prepare them and update
them regardless of whether they are actually used. If they are not present,
we cannot prepare/update them anyway, i.e. an error will be generated.

Simplify state.Prepare() so it uses a hard-coded list of devicetree files.

Note that state.PrepareFromLoadedData() is left untouched, since in that
case we have a complete definition from the loaded file, but cannot of
course rely on the devicetree files that created it still being present.
So in that case we still check the image defitions.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Move the comment for GetFdts() to the base class
Simon Glass [Thu, 18 Mar 2021 07:25:02 +0000 (20:25 +1300)]
binman: Move the comment for GetFdts() to the base class

Like with other methods this comment should be in the base class. Move it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop unnecessary field in output_fdt_info
Simon Glass [Thu, 18 Mar 2021 07:25:01 +0000 (20:25 +1300)]
binman: Drop unnecessary field in output_fdt_info

At present we store an entry as the third field in output_fdt_info[].
This is only used to get the type of the entry. Of course multiple entries
may have this same type. Also the entry type is the key to this dict, so
we can use that instead.

Drop the field and update GetUpdateNodes() to suit. Improve the comment for
output_fdt_info a little while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Use the fake SPL/TPL only if requested
Simon Glass [Thu, 18 Mar 2021 07:25:00 +0000 (20:25 +1300)]
binman: Use the fake SPL/TPL only if requested

At present we always use the main devicetree for SPL/TPL as well when
setting up the state. But this it not needed if there is a real devicetree
for SPL or TPL. In fact it confuses things since we cannot distinguish
between one being provided and using the fake one.

Update the code to create the fakes only when requested. Put the mapping
in a constant so we can use it elsewhere.

Rename 'other_fname' to 'fname' while we are here since there is nothing
'other' about it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Drop unnecessary 'type' property in tests
Simon Glass [Thu, 18 Mar 2021 07:24:59 +0000 (20:24 +1300)]
binman: Drop unnecessary 'type' property in tests

A few tests declare a type when this can be inferred from the node name.
Drop these lines, since it might cause confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Add support for u-boot-tpl-bss-bad
Simon Glass [Thu, 18 Mar 2021 07:24:58 +0000 (20:24 +1300)]
binman: Add support for u-boot-tpl-bss-bad

This entry holds the padding between the end of of TPL binary and the
end of BSS. This region must be left empty so that the devicetree can be
appended correctly and remain accessible without interfering with BSS.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Add support for u-boot-tpl-nodtb
Simon Glass [Thu, 18 Mar 2021 07:24:57 +0000 (20:24 +1300)]
binman: Add support for u-boot-tpl-nodtb

Allow this entry type to be placed in an image. This is the TPL binary,
without a devicetree appended.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Support symbols in u-boot-spl-nodtb
Simon Glass [Thu, 18 Mar 2021 07:24:56 +0000 (20:24 +1300)]
binman: Support symbols in u-boot-spl-nodtb

Since this is an execuable we should be able insert symbol values into it.
Add support for this.

Use common code for this test and the original testSymbols. Use hex
consistently for the values and add some more comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Correct the documentation for u-boot-spl-bss-pad
Simon Glass [Thu, 18 Mar 2021 07:24:55 +0000 (20:24 +1300)]
binman: Correct the documentation for u-boot-spl-bss-pad

The documentation for this entry indicates that the SPL binary is included
along with the padding. It is not, so update it to correct the error.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Tidy up underscores in entry documentation
Simon Glass [Thu, 18 Mar 2021 07:24:54 +0000 (20:24 +1300)]
binman: Tidy up underscores in entry documentation

Several entries currently use an underscore in the entry-type name, but in
fact a hyphen is used. Update the docs to fix this as it might be
confusing.

Also simplify the 'filename' comment and fix the 'operation' typo.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Update entry help for files-align
Simon Glass [Thu, 18 Mar 2021 07:24:53 +0000 (20:24 +1300)]
binman: Update entry help for files-align

Regenerate the entry documentation, which step was missed when the
files-align feature was added.

Fixes: 6eb9932668f ("binman: Support alignment of files")

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Document ExpandEntries() in the base class
Simon Glass [Thu, 18 Mar 2021 07:24:52 +0000 (20:24 +1300)]
binman: Document ExpandEntries() in the base class

Move the documentation to the base method as it is with other methods.
Also update it a little while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agobinman: Allow extracting to current directory
Simon Glass [Thu, 18 Mar 2021 07:24:51 +0000 (20:24 +1300)]
binman: Allow extracting to current directory

Extracting files to the current directory is not normally a very friendly
thing to do, but it can be warranted, e.g. in a new temporary dir. At
present binman reports an error when such an attempt is made. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: apl: Use read-only SPL and new of-platdata
Simon Glass [Mon, 15 Mar 2021 04:25:52 +0000 (17:25 +1300)]
x86: apl: Use read-only SPL and new of-platdata

With Apollo Lake, SPL is placed in read-only memory. Set this new option
so that OF_PLATDATA_INST can be used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: coral: Drop TPM and ACPI interrupts from TPL
Simon Glass [Mon, 15 Mar 2021 04:25:51 +0000 (17:25 +1300)]
x86: coral: Drop TPM and ACPI interrupts from TPL

These devices are not actually built in TPL but are currently active in
the TPL devicetree. For of-platdata-inst this means that we will try to
generate devices for them, which fails.

Update them to be active only in U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: coral: Drop ACPI properties from of-platdata
Simon Glass [Mon, 15 Mar 2021 04:25:50 +0000 (17:25 +1300)]
x86: coral: Drop ACPI properties from of-platdata

We don't use these in TPL or SPL, so drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: Don't include reset driver in SPL
Simon Glass [Mon, 15 Mar 2021 04:25:49 +0000 (17:25 +1300)]
x86: Don't include reset driver in SPL

We don't normally need this driver in TPL/SPL, so drop it for now. It can
be enabled by individual boards if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: Support a fake PCI device with of-platdata-inst
Simon Glass [Mon, 15 Mar 2021 04:25:48 +0000 (17:25 +1300)]
x86: Support a fake PCI device with of-platdata-inst

With TPL we don't need full PCI support and it adds to code size. Instead,
a simple_bus driver is good enough to be able to read and write the PCI
config and do a little basic setup.

So at present there are two drivers in U-Boot called pci_x86. One is in
UCLASS_PCI, used in SPL and U-Boot proper. The other is in
UCLASS_SIMPLE_BUS and used only in TPL.

Add a tag to tell dtoc about this, so it knows which one to use when
generating the devices and uclasses.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: itss: Tidy up bind() for of-platdata-inst
Simon Glass [Mon, 15 Mar 2021 04:25:47 +0000 (17:25 +1300)]
x86: itss: Tidy up bind() for of-platdata-inst

With the standard of-platdata we must fix up driver_data manually. With
of-platadata-inst this is not necessary, since it is added to the device
by dtoc.

Update the code to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: apl: Tell of-platdata about a required header file
Simon Glass [Mon, 15 Mar 2021 04:25:46 +0000 (17:25 +1300)]
x86: apl: Tell of-platdata about a required header file

This enum is needed to generate build-time devices. Tell dtoc where to
find the header, to avoid compile errors in the generated code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: apl: Fix the header order in pmc
Simon Glass [Mon, 15 Mar 2021 04:25:45 +0000 (17:25 +1300)]
x86: apl: Fix the header order in pmc

The dm.h header should come first. In fact it needs to, since otherwise
the driver model definitions are not available to dt-structs.h

Fix this, since it causes problems with OF_PLATDATA_INST.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agox86: Define a region for device priv/plat data
Simon Glass [Mon, 15 Mar 2021 04:25:44 +0000 (17:25 +1300)]
x86: Define a region for device priv/plat data

Collect this together in one place, so driver model can access set it up
in a new place if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: doc: Add documentation for of-platdata-inst
Simon Glass [Mon, 15 Mar 2021 04:25:43 +0000 (17:25 +1300)]
dm: doc: Add documentation for of-platdata-inst

Add a description of the new features, along with internal technical
documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: doc: Tidy up of-platdata docs
Simon Glass [Mon, 15 Mar 2021 04:25:42 +0000 (17:25 +1300)]
dm: doc: Tidy up of-platdata docs

This doc has a few pieces that are out-of-date. Fix these. Also we have
started to use 'devicetree' instead of 'device tree' or 'device-tree'
since it is easier to see as a single term, so replace all ocurrences
accordingly.

Also move the caveats to the end, since this is a fairly solid part of
U-Boot now.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Add warnings to private / platform setters
Simon Glass [Mon, 15 Mar 2021 04:25:41 +0000 (17:25 +1300)]
dm: core: Add warnings to private / platform setters

Add a warning to each of these functions so that people do not attempt to
use them outside driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Use separate priv/plat data region
Simon Glass [Mon, 15 Mar 2021 04:25:40 +0000 (17:25 +1300)]
dm: core: Use separate priv/plat data region

Make use of the new priv/plat data region if enabled. This is implemented
as a simple offset from the position set up by dtoc to the new position.

So long as all access goes through dm_priv_to_rw() this is safe.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: Define a region for device priv/plat data
Simon Glass [Mon, 15 Mar 2021 04:25:39 +0000 (17:25 +1300)]
sandbox: Define a region for device priv/plat data

Collect this together in one place, so driver model can access set it up
in a new place if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Allow storing priv/plat data separately
Simon Glass [Mon, 15 Mar 2021 04:25:38 +0000 (17:25 +1300)]
dm: core: Allow storing priv/plat data separately

At present the device priv/data data allocated by dtoc is stored in the
data section along with other variables. On some platforms it is better
to allocate space for it separately, e.g. if SPL is running from read-only
memory.

Create a new space with the same size as that allocated by dtoc, ready for
use.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Move flags to device-runtime info
Simon Glass [Mon, 15 Mar 2021 04:25:37 +0000 (17:25 +1300)]
dm: core: Move flags to device-runtime info

When of-platdata-inst is active, use the flags in the new udevice_rt
table, dropping them from the main struct udevice. This ensures that the
latter is not updated at runtime.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Create a struct for device runtime info
Simon Glass [Mon, 15 Mar 2021 04:25:36 +0000 (17:25 +1300)]
dm: core: Create a struct for device runtime info

At present when driver model needs to change a device it simply updates
the struct udevice structure. But with of-platdata-inst most of the fields
are not modified at runtime. In fact, typically only the flags need to
change.

For systems running SPL from read-only memory it is convenient to separate
out the runtime information, so that the devices don't need to be copied
before being used.

Create a new udevice_rt table, similar to the existing driver_rt. For now
it just holds the flags, although they are not used in this patch.

Add a new Kconfig for the driver_rt data, since this is not needed when
of-platdata-inst is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Add an option to support SPL in read-only memory
Simon Glass [Mon, 15 Mar 2021 04:25:35 +0000 (17:25 +1300)]
dm: core: Add an option to support SPL in read-only memory

Some systems (e.g. x86 APL) run SPL from read-only memory. The device
instances created by dtoc are therefore not writeable. To make things work
we would need to copy the devices to read/write memory.

To avoid this, add an option to use a separate runtime struct for devices,
just as is done for drivers. This can be used to hold information that
changes at runtime, avoiding the need for a copy.

Also add a Kconfig option for read-only SPL, which selects this feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoazure/gitlab: Add tests for sandbox_noinst
Simon Glass [Mon, 15 Mar 2021 04:25:34 +0000 (17:25 +1300)]
azure/gitlab: Add tests for sandbox_noinst

Add this new board to the test plans. Travis-CI is left out, since it is
being removed soon due to lack of capacity.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agotest: Run sandbox_spl tests on sandbox_noinst
Simon Glass [Mon, 15 Mar 2021 04:25:33 +0000 (17:25 +1300)]
test: Run sandbox_spl tests on sandbox_noinst

Run the tests on this build too, to prevent regressions.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: Create a new sandbox_noinst build
Simon Glass [Mon, 15 Mar 2021 04:25:32 +0000 (17:25 +1300)]
sandbox: Create a new sandbox_noinst build

Move sandbox_spl over to use OF_PLATDATA_INST. Create a new board to
test the case when this is not enabled, since we will be keeping that
code around for several months and want to avoid regressions.

Skip the dm_test_of_plat_dev() test since driver info is not available
for OF_PLATDATA_INST.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoRevert "sandbox: Disable I2C emulators in SPL"
Simon Glass [Mon, 15 Mar 2021 04:25:31 +0000 (17:25 +1300)]
Revert "sandbox: Disable I2C emulators in SPL"

With recent changes this can be supported again. Add it back.

This reverts commit d85f2c4f2970d0ec2f5f075de734afd11200d153.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: i2c: Support i2c emulation with of-platdata
Simon Glass [Mon, 15 Mar 2021 04:25:30 +0000 (17:25 +1300)]
sandbox: i2c: Support i2c emulation with of-platdata

At present the i2c emulators require access to the devicetree, which is
not possible (by design) with of-platdata.

Add a way for drivers to record the of-platdata index of their emulator,
so that we can still find the emulator.

This allows i2c emulation to work with of-platdata.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox_spl: Increase SPL malloc() size
Simon Glass [Mon, 15 Mar 2021 04:25:29 +0000 (17:25 +1300)]
sandbox_spl: Increase SPL malloc() size

The test framework reinits driver model tests before running each test.
Since malloc_simple does not support free(), this eventually runs out of
memory.

Fix it for now by increasing the space to 32KB.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodm: Rename device_get_by_driver_info_idx()
Simon Glass [Mon, 15 Mar 2021 04:25:28 +0000 (17:25 +1300)]
dm: Rename device_get_by_driver_info_idx()

This function finds a device by its driver_info index. With
of-platdata-inst we do not use driver_info, but instead instantiate
udevice records at build-time.

However the semantics of using the function are the same in each case:
the caller provides an index and gets back a device.

So rename the function to device_get_by_ofplat_idx(), so that it can be
used for both situations. The caller does not really need to worry about
the details.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agosandbox: i2c: Move platdata structs to header files
Simon Glass [Mon, 15 Mar 2021 04:25:27 +0000 (17:25 +1300)]
sandbox: i2c: Move platdata structs to header files

At present the structs used by these drivers are declared in the C files
and so are not accessible to dtoc. Move them to header files, as required.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Drop uclass_find_device_by_phandle() with of-platdata
Simon Glass [Mon, 15 Mar 2021 04:25:26 +0000 (17:25 +1300)]
dm: core: Drop uclass_find_device_by_phandle() with of-platdata

At present this function is included in the build but with of-platdata it
only services to produce a confusing link error complaining about a call
to dev_read_u32_default().

Drop it so that any call to uclass_find_device_by_phandle() is flagged as
an error, making it easier to see what is going on.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Drop device_get_by_driver_info()
Simon Glass [Mon, 15 Mar 2021 04:25:25 +0000 (17:25 +1300)]
dm: core: Drop device_get_by_driver_info()

This function is now only used in a test. Drop it. Also drop
DM_DRVINFO_GET() which was the only purpose for having the function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoclk: sandbox: Create a special fixed-rate driver
Simon Glass [Mon, 15 Mar 2021 04:25:24 +0000 (17:25 +1300)]
clk: sandbox: Create a special fixed-rate driver

Create a version of this driver for sandbox so that it can use the
of-platdata struct.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoclk: fixed-rate: Export driver parts for OF_PLATDATA_INST
Simon Glass [Mon, 15 Mar 2021 04:25:23 +0000 (17:25 +1300)]
clk: fixed-rate: Export driver parts for OF_PLATDATA_INST

We need to allow SoCs to create their own drivers for this so that they
can use their own of-platdata structs. To minimise code duplication,
export the driver operations and the ofdata_to_plat() setup function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoclk: sandbox: Move priv/plat data to a header file
Simon Glass [Mon, 15 Mar 2021 04:25:22 +0000 (17:25 +1300)]
clk: sandbox: Move priv/plat data to a header file

At present the structs used by this driver are not accessible outside it,
so cannot be used with OF_PLATDATA_INST. Move them to a header file to
fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: test: Avoid destroying uclasses with of-platdata-inst
Simon Glass [Mon, 15 Mar 2021 04:25:21 +0000 (17:25 +1300)]
dm: test: Avoid destroying uclasses with of-platdata-inst

It is not possible to destroy the uclasses when they are created at
build time. Skip this step so that SPL test can complete successfully.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodm: core: Include dt-decl.h automatically
Simon Glass [Mon, 15 Mar 2021 04:25:20 +0000 (17:25 +1300)]
dm: core: Include dt-decl.h automatically

When dt-structs.h is used, include the dt-decl.h header as well, so that
these declarations are available.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Remove old of-platdata files before regenerating
Simon Glass [Wed, 24 Mar 2021 17:40:53 +0000 (06:40 +1300)]
Makefile: Remove old of-platdata files before regenerating

Which files we generate depends on the setting of OF_PLATDATA_INST in the
build. This might change between builds, but the build directory may be
reused.

Leaving old files around is confusing and switching the OF_PLATDATA_INST
setting does not necessarily regenerate the files, e.g. if the devicetree
has not changed.

Remove all the files before regenerating new ones.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Use a variable for generated of-platdata headers
Simon Glass [Wed, 24 Mar 2021 17:40:52 +0000 (06:40 +1300)]
Makefile: Use a variable for generated of-platdata headers

There are actually two generated files but only one is currently mentioned
in the Makefile as a dependency. Put them both in a Makefile variable and
use that instead, to avoid inconsistency.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agodtoc: Only generate the required files
Simon Glass [Wed, 24 Mar 2021 17:40:51 +0000 (06:40 +1300)]
dtoc: Only generate the required files

At present all possible files are generated, even if some of them just
have a header and an empty body. It is better to generate only the files
that are needed, so that the two types of build (based on the setting of
OF_PLATDATA_INST) can be mutually exclusive.

This is intended to fix a strange problem sometimes found with CI:

   Building current source for 1 boards (1 thread, 40 jobs per thread)
      sandbox:  +   sandbox_spl
   +drivers/built-in.o: In function `dm_setup_inst':
   +drivers/core/root.c:135: undefined reference to
   `_u_boot_list_2_udevice_2_root'
   +dts/dt-uclass.o:(.u_boot_list_2_uclass_2_serial+0x10): undefined
   reference to `_u_boot_list_2_udevice_2_serial'
   ...

This likely happens when switching from !OF_PLATDATA_INST to
OF_PLATDATA_INST since running 'make xxx_defconfig" does not currently
cause any change in which files are generated. With !OF_PLATDATA_INST
the dt-device.c file has no declarations and this is assumed to be the
starting state. The error above seems to indicate that, after changing
to OF_PLATDATA_INST, the dt-uclass.c file is regenerated but the
dt-device.c files is not. This does not seem possible from the relevant
Makefile.spl rule:

   u-boot-spl-platdata := $(obj)/dts/dt-plat.o $(obj)/dts/dt-uclass.o
$(obj)/dts/dt-device.o

   cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all

   include/generated/dt-structs-gen.h $(u-boot-spl-platdata_c) &: \
$(obj)/$(SPL_BIN).dtb
@[ -d $(obj)/dts ] || mkdir -p $(obj)/dts
$(call if_changed,dtoc)

It seems that this cannot regenerate dt-uclass.c without dt-device.c since
'dtoc all' is used. So here the trail ends for now.

In any case it seems better to generate files that are uses and not bother
with those that serve no purpose. So update dtoc to do this automatically.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Depend only on required of-platdata files
Simon Glass [Wed, 24 Mar 2021 17:40:50 +0000 (06:40 +1300)]
Makefile: Depend only on required of-platdata files

When OF_PLATDATA_INST is enabled, we need dt-uclass.c and dt-device.c for
the build to work. When OF_PLATDATA_INST is not enabled, we only need
dt-plat.c

Update the Makefile rules to indicate this.

At present all files are generated and compiled regardless of which are
actually needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMakefile: Avoid running dtoc every time
Simon Glass [Wed, 24 Mar 2021 17:40:49 +0000 (06:40 +1300)]
Makefile: Avoid running dtoc every time

Since the dst_dir rule always runs, it causes a rebuild of the of-platdata
files even if not needed.

Create the directory inside the rule instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agolibfdt: Tidy up pylibfdt build rule
Simon Glass [Wed, 24 Mar 2021 17:40:48 +0000 (06:40 +1300)]
libfdt: Tidy up pylibfdt build rule

At present the build rule for pylibfdt depends on _libfdt.so but modern
Python versions add a different suffix to the output file, resulting in
something like _libfdt.cpython-38-x86_64-linux-gnu.so

The result is that pylibfdt is rebuilt every time.

Rename the file the standard name so that the rule works correctly. Also
add libfdt.py to the dependencies, so that file is always created if
missing.

Signed-off-by: Simon Glass <sjg@chromium.org>
3 years agoMerge tag 'efi-next' of https://source.denx.de/u-boot/custodians/u-boot-efi into...
Tom Rini [Fri, 26 Mar 2021 02:45:43 +0000 (22:45 -0400)]
Merge tag 'efi-next' of https://source.denx.de/u-boot/custodians/u-boot-efi into next

Pull request for efi-next

New:
provide EFI ESRT table
initrd via Load_File2_Protocol uses boot options
create an S-CRTM event for measured boot

Bug fixes:
avoid double free of SPI device in dfu_free_entity()
avoid memory leak in TCG2 protocol

3 years agoefi_loader: Clean up file size calculations
Ilias Apalodimas [Thu, 25 Mar 2021 19:55:16 +0000 (21:55 +0200)]
efi_loader: Clean up file size calculations

We recently added a common function for calculating file size,
instead of copy pasting the code around.  Switch one of the
occurences over to the common function

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviwed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_selfest: redefine enum efi_test_phase
Heinrich Schuchardt [Wed, 24 Mar 2021 16:48:01 +0000 (17:48 +0100)]
efi_selfest: redefine enum efi_test_phase

Setup will always occur before ExitBootServices(). So eliminate
EFI_SETUP_AFTER_BOOTTIME_EXIT. Put the SetVirtualAddressMap() test into a
separate class so that we can execute it last.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: Add an S-CRTM even for firmware version
Ilias Apalodimas [Wed, 24 Mar 2021 14:50:46 +0000 (16:50 +0200)]
efi_loader: Add an S-CRTM even for firmware version

TCG PC Client Platform Firmware Profile Spec mandates that an S-CRTM
event for the version identifier using the event type EV_S_CRTM_VERSION
must be measured.

So since we are trying to add more conformance into U-Boot, let's add
the event using U_BOOT_VERSION_STRING, extend PCR[0] accordingly and log
it in the EventLog

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: EFI TCG2 free efi memory on protocol failure
Ilias Apalodimas [Thu, 25 Mar 2021 11:31:45 +0000 (13:31 +0200)]
efi_loader: EFI TCG2 free efi memory on protocol failure

Current code doesn't free the efi allocated memory in case the protocol
failed to install

Fixes: c8d0fd582576 ("efi_loader: Introduce eventlog support for TCG2_PROTOCOL")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agotest: test the ESRT creation
Jose Marinho [Thu, 11 Mar 2021 13:18:53 +0000 (13:18 +0000)]
test: test the ESRT creation

This commit slightly extends test_efi_capsule_fw3.

 In order to run the test the following must be added to
 sandbox_defconfig:
  +CONFIG_CMD_SF=y
  +CONFIG_CMD_MEMORY=y
  +CONFIG_CMD_FAT=y
  +CONFIG_DFU=y

 The ESRT is printed in the u-boot shell by calling efidebug esrt.
 The test ensures that, after the capsule is installed, the  ESRT
 contains entries with the GUIDs:
  - EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
  - EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;

test invocation:
 sudo ./test/py/test.py --bd sandbox -k capsule_fw3 -l --build

CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
CC: Sughosh Ganu <sughosh.ganu@linaro.org>
CC: AKASHI Takahiro <takahiro.akashi@linaro.org>
CC: Ilias Apalodimas <ilias.apalodimas@linaro.org>
CC: Andre Przywara <andre.przywara@arm.com>
CC: Alexander Graf <agraf@csgraf.de>
CC: nd@arm.com
Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi: ESRT creation tests
Jose Marinho [Thu, 11 Mar 2021 13:18:52 +0000 (13:18 +0000)]
efi: ESRT creation tests

This commmit exercises the ESRT creation in a EFI selftest.

 A fake FMP, with TEST_ESRT_NUM_ENTRIES FW images, is installed in the
 system leading to the corresponding ESRT entries being populated.
 The ESRT entries are checked against the datastructure used to
 initialize the FMP.

Invocation from the sandbox platform:
add to sandbox_defconfig:
  +CONFIG_CMD_BOOTEFI_SELFTEST=y

 make sandbox_capsule_defconfig all
 ./u-boot -d arch/sandbox/dts/test.dtb
 bootefi selftest

CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
CC: Sughosh Ganu <sughosh.ganu@linaro.org>
CC: AKASHI Takahiro <takahiro.akashi@linaro.org>
CC: Ilias Apalodimas <ilias.apalodimas@linaro.org>
CC: Andre Przywara <andre.przywara@arm.com>
CC: Alexander Graf <agraf@csgraf.de>
CC: nd@arm.com
Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agocmd: efi: ESRT table debug print
Jose Marinho [Thu, 11 Mar 2021 13:18:51 +0000 (13:18 +0000)]
cmd: efi: ESRT table debug print

This commit enables the ESRT printing from the u-boot shell by invoking:
- efidebug capsule esrt

CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
CC: Sughosh Ganu <sughosh.ganu@linaro.org>
CC: AKASHI Takahiro <takahiro.akashi@linaro.org>
CC: Ilias Apalodimas <ilias.apalodimas@linaro.org>
CC: Andre Przywara <andre.przywara@arm.com>
CC: Alexander Graf <agraf@csgraf.de>
CC: nd@arm.com
Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Reviwed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi: Add ESRT to the EFI system table
Jose Marinho [Tue, 2 Mar 2021 17:26:38 +0000 (17:26 +0000)]
efi: Add ESRT to the EFI system table

The ESRT is initialised during efi_init_objlist after
efi_initialize_system_table().

The ESRT is recreated from scratch at the following events:
- successful UpdateCapsule;
- FMP instance install.

The code ensures that every ESRT entry has a unique fw_class value.

Limitations:
- The ESRT is not updated if an FMP instance is uninstalled;
- the fields image_type and flags are in the current implementation left
undefined. Setting these values will require a per-platform function
that returns the image_type/flags as a function of the image fw_class.

CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
CC: Sughosh Ganu <sughosh.ganu@linaro.org>
CC: AKASHI Takahiro <takahiro.akashi@linaro.org>
CC: Ilias Apalodimas <ilias.apalodimas@linaro.org>
CC: Andre Przywara <andre.przywara@arm.com>
CC: Alexander Graf <agraf@csgraf.de>
CC: nd@arm.com
Signed-off-by: Jose Marinho <jose.marinho@arm.com>
Remove two EFI_CALL() indirections.
Move ESRT GUID in efidebug's list of GUIDs.

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agodfu: dfu_sf: avoid double free of SPI device
Heinrich Schuchardt [Thu, 18 Mar 2021 06:46:07 +0000 (07:46 +0100)]
dfu: dfu_sf: avoid double free of SPI device

Multiple DFU entities may share the same SPI device. We must make sure that
the SPI device is only freed once.

When using the driver model it is not necessary to free the SPI device.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Lukasz Majewski <lukma@denx.de>
3 years agoefidebug: add multiple device path instances on Boot####
Ilias Apalodimas [Wed, 17 Mar 2021 19:55:01 +0000 (21:55 +0200)]
efidebug: add multiple device path instances on Boot####

The UEFI spec allows a packed array of UEFI device paths in the
FilePathList[] of an EFI_LOAD_OPTION. The first file path must
describe the loaded image but the rest are OS specific.

Previous patches parse the device path and try to use the second
member of the array as an initrd. So let's modify efidebug slightly
and install the second file described in the command line as the
initrd device path.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: Replace config option for initrd loading
Ilias Apalodimas [Wed, 17 Mar 2021 19:55:00 +0000 (21:55 +0200)]
efi_loader: Replace config option for initrd loading

Up to now we install EFI_LOAD_FILE2_PROTOCOL to load an initrd
unconditionally. Although we correctly return various EFI exit codes
depending on the file status (i.e EFI_NO_MEDIA, EFI_NOT_FOUND etc), the
kernel loader, only falls back to the cmdline interpreted initrd if the
protocol is not installed.

This creates a problem for EFI installers, since they won't be able to
load their own initrd and continue the installation. It also makes the
feature hard to use, since we can either have a single initrd or we have
to recompile u-boot if the filename changes.

So let's introduce a different logic that will decouple the initrd
path from the config option we currently have.
When defining a UEFI BootXXXX we can use the filepathlist and store
a file path pointing to our initrd. Specifically the EFI spec describes:

"The first element of the array is a device path that describes the device
and location of the Image for this load option. Other device paths may
optionally exist in the FilePathList, but their usage is OSV specific"

When the EFI application is launched through the bootmgr, we'll try to
interpret the extra device path. If that points to a file that exists on
our disk, we'll now install the load_file2 and the efi-stub will be able
to use it.

This opens up another path using U-Boot and defines a new boot flow.
A user will be able to control the kernel/initrd pairs without explicit
cmdline args or GRUB.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agoefi_loader: Add helper functions for EFI
Ilias Apalodimas [Wed, 17 Mar 2021 19:54:59 +0000 (21:54 +0200)]
efi_loader: Add helper functions for EFI

A following patch introduces a different logic for loading initrd's
based on the EFI_LOAD_FILE2_PROTOCOL.
Since similar logic can be applied in the future for other system files
(i.e DTBs), let's add some helper functions which will retrieve and
parse file paths stored in EFI variables.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
3 years agoefi_loader: Add device path related functions for initrd via Boot####
Ilias Apalodimas [Wed, 17 Mar 2021 19:54:58 +0000 (21:54 +0200)]
efi_loader: Add device path related functions for initrd via Boot####

On the following patches we allow for an initrd path to be stored in
Boot#### variables.  Specifically we encode in the FIlePathList[] of
the EFI_LOAD_OPTIONS for each Boot#### variable.

The FilePathList[] array looks like this:
kernel - 0xff - VenMedia(initrd GUID) - initrd1 - 0x01 initrd2 - 0xff
So let's add the relevant functions to concatenate and retrieve a device
path based on a Vendor GUID.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reformat function descriptions.
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 years agocmd/load: support uploading EFI binary via UART
Heinrich Schuchardt [Fri, 19 Mar 2021 02:50:57 +0000 (02:50 +0000)]
cmd/load: support uploading EFI binary via UART

When uploading an EFI binary via the UART we have to call
efi_set_bootdev() or we won't be able to execute it.

Put the includes into alphabetic order.

Fixes: 5f59518a7b1a ("efi_loader: setting boot device")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>