]> git.dujemihanovic.xyz Git - u-boot.git/log
u-boot.git
16 months agoMAINTAINERS: add DT/bindings files to at91 entry
Eugen Hristev [Mon, 7 Aug 2023 07:22:03 +0000 (10:22 +0300)]
MAINTAINERS: add DT/bindings files to at91 entry

With this change the DT and binding files are under the at91 tree
maintainer, and get_maintainer.pl correctly reports the entry.

Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
16 months agoboard: ten64: add missing error checks for retimer power on
Mathew McBride [Mon, 7 Aug 2023 01:41:08 +0000 (01:41 +0000)]
board: ten64: add missing error checks for retimer power on

The retimer reset/power on logic was changed in a recent commit,
however, it neglected to check if the commands sent to the
board microcontroller (to control power to the retimer chip)
actually completed.

Add return checks for these operations so any failures will
be reported to the user.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Fixes: 7a041fea2 ("board: traverse: ten64: ensure retimer reset
is done on new board revisions")

16 months agoARM: renesas: Update MAINTAINERS file
Marek Vasut [Sun, 6 Aug 2023 18:57:34 +0000 (20:57 +0200)]
ARM: renesas: Update MAINTAINERS file

Update MAINTAINERS file. Add missing MAINTAINERS file for Spider,
Whitehawk and V3HSK boards. Update mail addresses. Add file globs
to match on DT and driver files related to these boards.

The GRPEACH and R2DPLUS are special in that they are not R-Car
and have their own set of specialized drivers.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
16 months agoget_maintainer.pl: Add an ignore list for git history
Tom Rini [Mon, 7 Aug 2023 13:20:53 +0000 (09:20 -0400)]
get_maintainer.pl: Add an ignore list for git history

As Pali Rohár has asked to not be copied on changes to files he is not
a specific maintainer of, add his address to .get_maintainer.ignore.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
16 months agoAzure: Squash a number of jobs and re-order slightly
Tom Rini [Fri, 4 Aug 2023 21:07:44 +0000 (17:07 -0400)]
Azure: Squash a number of jobs and re-order slightly

To reduce overall job time, move a number of smaller jobs together.
These should still be safely under 1 hour total time, but reducing the
overall number of jobs should help with the queue slightly.

Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoAzure: Rework Rockchip jobs again
Tom Rini [Fri, 4 Aug 2023 20:46:15 +0000 (16:46 -0400)]
Azure: Rework Rockchip jobs again

The job for rockchip vendor platforms has again gotten close to or
exceeded one hour.  Rework things such that we move the 32bit platforms
back to the general 32bit ARM job (as there's time there) and make these
build only the 64bit platforms.

Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoMerge tag 'dm-pull-5aug23' of https://source.denx.de/u-boot/custodians/u-boot-dm
Tom Rini [Sun, 6 Aug 2023 02:11:04 +0000 (22:11 -0400)]
Merge tag 'dm-pull-5aug23' of https://source.denx.de/u-boot/custodians/u-boot-dm

binman support for Xilinx signing
buildman minor fixes

16 months agobuildman: Drop warning about orphaned defconfigs
Simon Glass [Thu, 3 Aug 2023 18:51:37 +0000 (12:51 -0600)]
buildman: Drop warning about orphaned defconfigs

Some boards use a MAINTAINERS entry to specify common files without
referencing any defconfigs. This is allowed and should not result in a
warning.

Drop the warning in this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agobuildman: Exit after reading toolchain
Simon Glass [Thu, 3 Aug 2023 18:51:36 +0000 (12:51 -0600)]
buildman: Exit after reading toolchain

Recent refactoring changed buildman to continue operation after fetching
a toolchain. Fix this.

Fixes: b8680646521 ("bulidman: Move toolchain handling to a function")
Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agoevent: Fix a wrong type_name from dm_post_init to dm_post_init_f
Jaehoon Chung [Tue, 1 Aug 2023 10:17:00 +0000 (19:17 +0900)]
event: Fix a wrong type_name from dm_post_init to dm_post_init_f

DM_POST_INIT was changed to DM_POST_INIT_F.
To debug correct message, change type_name from dm_post_init to
dm_post_init_f.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
s/an/a/ :
Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agobinman: ftest: Add test for xilinx-bootgen etype
Lukas Funke [Thu, 3 Aug 2023 15:22:14 +0000 (17:22 +0200)]
binman: ftest: Add test for xilinx-bootgen etype

Add test for the 'xilinx-bootgen' etype

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Allow missing bootgen tool; comment testXilinxBootgenMissing() comment:
Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agobinman: etype: Add xilinx-bootgen etype
Lukas Funke [Thu, 3 Aug 2023 15:22:15 +0000 (17:22 +0200)]
binman: etype: Add xilinx-bootgen etype

This adds a new etype 'xilinx-bootgen'. By using this etype it is
possible to created an signed SPL (FSBL in Xilinx terms) for
ZynqMP boards.

The etype uses Xilinx Bootgen tools in order to transform the SPL into
a bootable image and sign the image with a given primary and secondary
public key. For more information to signing the FSBL please refer to the
Xilinx Bootgen documentation.

Here is an example of the etype in use:

    spl {
        filename = "boot.signed.bin";

        xilinx-bootgen {
            pmufw-filename = "pmu-firmware.elf";
            psk-key-name-hint = "psk0";
            ssk-key-name-hint = "ssk0";
            auth-params = "ppk_select=0", "spk_id=0x00000000";

            u-boot-spl-nodtb {
            };
            u-boot-spl-dtb {
            };
        };
    };

For this to work the hash of the primary public key has to be fused
into the ZynqMP device and authentication (RSA_EN) has to be set.

For testing purposes: if ppk hash check should be skipped one can add
the property 'fsbl_config = "bh_auth_enable";' to the etype. However,
this should only be used for testing(!).

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agobinman: btool: Add Xilinx Bootgen btool
Lukas Funke [Thu, 3 Aug 2023 15:22:13 +0000 (17:22 +0200)]
binman: btool: Add Xilinx Bootgen btool

Add the Xilinx Bootgen as bintool. Xilinx Bootgen is used to create
bootable SPL (FSBL in Xilinx terms) images for Zynq/ZynqMP devices. The
btool creates a signed version of the SPL. Additionally to signing the
key source for the decryption engine can be passend to the boot image.

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
16 months agobinman: Renumber 291 and 292 test files
Simon Glass [Thu, 3 Aug 2023 23:23:58 +0000 (17:23 -0600)]
binman: Renumber 291 and 292 test files

These have ended up with the same numbers as earlier files. Fix them.

Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Sat, 5 Aug 2023 16:24:33 +0000 (12:24 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

- Fix some issues with usb gadget ethernet.  A small set of updates for
  docs, etc, is still pending

16 months agocmd: Enable BIND by default if we have USB_ETHER
Tom Rini [Fri, 4 Aug 2023 16:06:21 +0000 (12:06 -0400)]
cmd: Enable BIND by default if we have USB_ETHER

The nature of the network stack means that if we are going to use the
gadget mode USB network driver there's no easy path to implicitly
bind/unbind the driver. Enable the "bind" command by default here so
that we can bind/unbind this as needed.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
16 months agousb: gadget: ether: Handle gadget driver registration in probe and remove
Marek Vasut [Fri, 4 Aug 2023 15:41:11 +0000 (17:41 +0200)]
usb: gadget: ether: Handle gadget driver registration in probe and remove

Move the ethernet gadget driver registration and removal from ethernet
bind and unbind callbacks into driver DM probe and remove callbacks.
This way, when the driver is bound, which is triggered deliberately
using 'bind' command, the USB ethernet gadget driver is instantiated
and bound to the matching UDC. In reverse, when the driver is unbound,
which is again triggered deliberately using 'unbind' command, the USB
ethernet gadget driver instance is removed.

Effectively, this now behaves like running either 'ums' or 'dfu' or
any other commands utilizing USB gadget functionality.

This also drops use of usb_gadget_release() and moves the use of
usb_gadget_initialize() into usb_ether_init() used only by legacy
platforms that do not use 'bind' command properly yet. Those have
no place in drivers.

Signed-off-by: Marek Vasut <marex@denx.de>
Tested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
16 months agousb: gadget: ether: Move probe function above driver structure
Marek Vasut [Fri, 4 Aug 2023 15:41:10 +0000 (17:41 +0200)]
usb: gadget: ether: Move probe function above driver structure

Move the driver probe function above the driver structure, so it
can be placed alongside other related functions, like upcoming
remove function. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
Tested-by: Tom Rini <trini@konsulko.com>
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
16 months agousb: gadget: ether: Inline functions used once
Marek Vasut [Fri, 4 Aug 2023 15:41:09 +0000 (17:41 +0200)]
usb: gadget: ether: Inline functions used once

These functions here are only ever called once since drop of non-DM
networking code. Inline them. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
Tested-by: Tom Rini <trini@konsulko.com>
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
16 months agoMerge branch '2023-08-04-toradex-platform-updates'
Tom Rini [Fri, 4 Aug 2023 20:04:11 +0000 (16:04 -0400)]
Merge branch '2023-08-04-toradex-platform-updates'

Two Toradex platform series.  First, to quote Andrejs:

This series adds Yavia Carrier board name string to the known
Toradex carrier board list, and reworks carrier board and display
adapter name handling.

And then to quote Marcel:
This series adds initial support for the Toradex Verdin AM62 SoM.
The first commit adds resp. PID4s to the ConfigBlock, the second one
fixes an early clocking issue confirmed to be a weird bug in TI's
scripting, the third one fixes some binman labeling issue. And last but
not least support for the Toradex Verdin AM62 is added.

16 months agoboard: toradex: add verdin am62 support
Marcel Ziswiler [Fri, 4 Aug 2023 10:08:08 +0000 (12:08 +0200)]
board: toradex: add verdin am62 support

This adds initial support for the Toradex Verdin AM62 Quad 1GB WB IT
V1.0A module and subsequent V1.1 launch configuration SKUs. They are
strapped to boot from their on-module eMMC. U-Boot supports booting
from the on-module eMMC only, DFU support is disabled for now due to
missing AM62x USB support.

The device trees were taken straight from Linux v6.5-rc1.

Boot sequence is:
SYSFW ---> R5 SPL (both in tiboot3.bin) ---> ATF (TF-A) ---> OP-TEE
  ---> A53 SPL (part of tispl.bin) ---> U-boot proper (u-boot.img)

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Nishanth Menon <nm@ti.com>
16 months agoarm: dts: k3-binman: fix rcfg_yaml and pcfg_yaml labels
Marcel Ziswiler [Fri, 4 Aug 2023 10:08:07 +0000 (12:08 +0200)]
arm: dts: k3-binman: fix rcfg_yaml and pcfg_yaml labels

Fix rcfg_yaml to really point to rm-cfg.yaml and pcfg_yaml to really
point to pm-cfg.yaml which likely is the intention.

While at it also add labels for the remaining items like custmpk_pem,
dkey_pem, bcfg_yaml_sysfw, scfg_yaml_sysfw, pcfg_yaml_sysfw and
rcfg_yaml_sysfw.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
Reviewed-by: Nishanth Menon <nm@ti.com>
16 months agoarm: mach-k3: am62: fix 2nd mux option of clkout0
Marcel Ziswiler [Fri, 4 Aug 2023 10:08:06 +0000 (12:08 +0200)]
arm: mach-k3: am62: fix 2nd mux option of clkout0

Fix second mux option of clkout0 which should really be
DEV_BOARD0_CLKOUT0_IN_PARENT_HSDIV4_16FFT_MAIN_2_HSDIVOUT1_CLK10
rather than twice the same according to [1].

[1] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/am62x/clocks.html#clocks-for-board0-device

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Bryan Brattlof <bb@ti.com>
Reviewed-by: Nishanth Menon <nm@ti.com>
16 months agotoradex: tdx-cfg-block: add verdin am62 skus
Marcel Ziswiler [Fri, 4 Aug 2023 10:08:05 +0000 (12:08 +0200)]
toradex: tdx-cfg-block: add verdin am62 skus

Add initial Verdin AM62 Quad 1GB WB IT prototype and launch
configuration SKUs to ConfigBlock handling.

0069: Verdin AM62 Quad 1GB WB IT
0071: Verdin AM62 Solo 512MB
0072: Verdin AM62 Solo 512MB WB IT
0073: Verdin AM62 Dual 1GB ET
0074: Verdin AM62 Dual 1GB IT
0075: Verdin AM62 Dual 1GB WB IT
0076: Verdin AM62 Quad 2GB WB IT

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com>
16 months agotoradex: tdx-cfg-block: rework display adapter name handling
Max Krummenacher [Tue, 18 Jul 2023 09:07:34 +0000 (11:07 +0200)]
toradex: tdx-cfg-block: rework display adapter name handling

Rework the rather big array of zero length strings with 4 entries of
actual display adapter names to a array of structs which ties a pid4
to its correspondent human readable string.
Provide an accessor to get the string for a given PID4.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
16 months agotoradex: tdx-cfg-block: rework carrier board name handling
Max Krummenacher [Tue, 18 Jul 2023 09:07:33 +0000 (11:07 +0200)]
toradex: tdx-cfg-block: rework carrier board name handling

Rework the rather big array of zero length strings with 4 entries of
actual carrier board names to a array of structs which ties a pid4
to its correspondent human readable string.
Provide an accessor to get the string for a given PID4.
Rework the user of the information to use the accessor.

Note that check_pid8_sanity() is used for early samples of Dahlia and
the development board. Yavia isn't affected.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
16 months agotoradex: tdx-cfg-block: add yavia carrier cfg block info
Max Krummenacher [Tue, 18 Jul 2023 09:07:32 +0000 (11:07 +0200)]
toradex: tdx-cfg-block: add yavia carrier cfg block info

Add the Yavia Carrier board name string to the known carrier
board list.

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
16 months agoMerge branch '2023-08-03-assorted-fixes'
Tom Rini [Thu, 3 Aug 2023 21:45:38 +0000 (17:45 -0400)]
Merge branch '2023-08-03-assorted-fixes'

- More MAINTAINERS file updates, bootstd fixes, a fat fix and debug
  message fix

16 months agobootstd: Init the size before reading extlinux file
Simon Glass [Thu, 27 Jul 2023 03:01:25 +0000 (21:01 -0600)]
bootstd: Init the size before reading extlinux file

The implementation in extlinux_pxe_getfile() does not pass a valid size
to bootmeth_read_file(), so this can fail if the uninited value happens to
be too small.

Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agobootstd: Init the size before reading the devicetree
Simon Glass [Thu, 27 Jul 2023 03:01:24 +0000 (21:01 -0600)]
bootstd: Init the size before reading the devicetree

The implementation in distro_efi_try_bootflow_files() does not pass a
valid size to bootmeth_common_read_file(), so this can fail if the
uninted value happens to be too small.

Fix this.

This was reported by someone but I cannot now find the email.

Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agobootstd: Avoid allocating memory for the EFI file
Simon Glass [Thu, 27 Jul 2023 03:01:23 +0000 (21:01 -0600)]
bootstd: Avoid allocating memory for the EFI file

The current bootflow-iteration algorithm reads the bootflow file into
an allocated memory buffer so it can be examined. This works well in
most cases.

However, while the common case is that the first bootflow is immediately
booted, it is also possible just to scan for available bootflows, perhaps
selecting one to boot later.

Even with the common case, EFI bootflows can be quite large. It doesn't
make sense to read it into an allocated buffer when we have kernel_addr_t
providing a suitable address for it. Even if we do have plenty of malloc()
space available, it is a violation of U-Boot's lazy-init principle to
read the bootflow before it is needed.

So overall it seems better to make a change.

Adjust the logic to read just the size of the EFI file at first. Later,
when the bootflow is booted, read the rest of the file into the designated
kernel buffer.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Da Xue <da@libre.computer>
Reported-by: Vincent Stehlé <vincent.stehle@arm.com>
16 months agobootstd: Use a function to detect network in EFI bootmeth
Simon Glass [Thu, 27 Jul 2023 03:01:22 +0000 (21:01 -0600)]
bootstd: Use a function to detect network in EFI bootmeth

This checks for a network-based bootflow in two places, one of which is
less than ideal. Move the correct test into a function and use it in both
places.

Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agobootflow: Export setup_fs()
Simon Glass [Thu, 27 Jul 2023 03:01:21 +0000 (21:01 -0600)]
bootflow: Export setup_fs()

This function is used in some bootmeth implementations. Export it.

Signed-off-by: Simon Glass <sjg@chromium.org>
16 months agovirtio: provide driver name in debug message
Heinrich Schuchardt [Wed, 26 Jul 2023 15:43:40 +0000 (17:43 +0200)]
virtio: provide driver name in debug message

If a driver cannot be bound, provide the driver name in the debug
message. Now the debug message may look like this:

    (virtio-pci.l#0): virtio-rng driver not configured

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agofat: correct sign for deletion mark
Heinrich Schuchardt [Wed, 26 Jul 2023 08:33:13 +0000 (10:33 +0200)]
fat: correct sign for deletion mark

The FAT file systems uses character '\xe5' to mark a deleted directory
entry. If a file name starts with this character, it is substituted by
'\x05' in the directory entry.

While (signed char)'\xe5' is a negative number 0xe5 is a positive integer
number. We therefore have define a constant DELETED_MARK which matches the
signedness of the characters in the directory entry.

Correct a comparison where we used the constant 0xe5 with the wrong sign.
Use the constant aRING instead of 0x05 like in the rest of the code.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 57b745e2387a ("fs: fat: call set_name() only once")
Fixes: 28cef9ca2e86 ("fs: fat: create correct short names")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agorzn1-snarc: Add missing MAINTAINERS file
Tom Rini [Tue, 25 Jul 2023 22:31:55 +0000 (18:31 -0400)]
rzn1-snarc: Add missing MAINTAINERS file

This should have been included when the platform was added, make one
now.

Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoboard/freescale: Drop two orphaned entries
Tom Rini [Tue, 25 Jul 2023 22:31:54 +0000 (18:31 -0400)]
board/freescale: Drop two orphaned entries

As the defconfig files here have been removed we can also remove the
entries.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agovexpress64: Rework MAINTAINERS file slightly
Tom Rini [Tue, 25 Jul 2023 22:31:53 +0000 (18:31 -0400)]
vexpress64: Rework MAINTAINERS file slightly

Given that we no longer have a configs/vexpress_aemv8a_defconfig file,
drop that and then include at least the aarch64-specific config.h file
here.  Also move Linus and Peter up to the main entry as well so that
they'll get tagged for the board code too and not literally only the
defconfig.

Signed-off-by: Tom Rini <trini@konsulko.com>
16 months agoARM: imx: Update MAINTAINERS file on DH electronics i.MX8M Plus DHCOM
Marek Vasut [Tue, 18 Jul 2023 16:14:35 +0000 (18:14 +0200)]
ARM: imx: Update MAINTAINERS file on DH electronics i.MX8M Plus DHCOM

Make use of globs to cover all the DTs and defconfigs.
Fill in missing DH u-boot list name.

Signed-off-by: Marek Vasut <marex@denx.de>
16 months agofreescale: Remove Rajesh Bhagat MAINTAINERS
Sean Anderson [Tue, 18 Oct 2022 18:12:46 +0000 (14:12 -0400)]
freescale: Remove Rajesh Bhagat MAINTAINERS

Rajesh's email bounces. Remove his email from all boards he maintains.
Fortunately, he has co-maintainers on most boards. I have taken the
liberty of volunteering Pramod to maintain the LS1012AFRDM, since he
also maintains the LS1012AFRWY. Let me know if the board should be
orphaned instead.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
16 months agoMerge tag 'efi-2023-10-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Thu, 3 Aug 2023 16:43:24 +0000 (12:43 -0400)]
Merge tag 'efi-2023-10-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request efi-2023-10-rc2-2

Documentation:

* Move README.falcon to HTML
* Describe usage of QEMU virtio block device
* Add SPDX license identifiers to svg images
* Add more detail to the description of U-Boot boot phases

UEFI:

* Fix buffer overflows
* Fix memory leak in efi_add_memory_map_pg
* Properly check return values of calloc, uuid_str_to_bin,
  efi_parse_pkcs7_header

16 months agoMerge branch '2023-08-03-mediatek-and-ten64-updates'
Tom Rini [Thu, 3 Aug 2023 14:34:04 +0000 (10:34 -0400)]
Merge branch '2023-08-03-mediatek-and-ten64-updates'

Merge in a series for MediaTek update and another for Ten64.

To quote Weijie Gao for MediaTek:
This patch series add support for MediaTek MT7988 SoC with its reference
boards and related drivers.

This patch series add basic boot support on eMMC/SD/SPI-NOR/SPI-NAND for
these boards. The clock, pinctrl drivers and the SoC initializaton code
are also included.

Product spec for MT7988:
https://www.mediatek.com/products/broadband-wifi/mediatek-filogic-880

And to quote Mathew McBride for Ten64:
This is a series of updates for the Ten64 board,
that are part of our firmware releases but not yet upstreamed
into U-Boot.

Changes of note include:

- Turning on standard boot support

  Standard boot improves the user experience over distroboot on Ten64,
  as we had various hacks in our firmware to solve some corner-case
  issues (e.g DTB handling) in distroboot, which are not needed with the
  bootflow system.

- Recognition of the new 'RevD' board variant distributed to OEM
  customers

- Fixing various boot issues related to FIT images and operating systems
  running out of the NAND (OpenWrt, recovery environment).

- A better 'opt-out' solution for fsl_setenv_bootcmd for Layerscape
  platforms booting from TF-A.

  This was discussed when the Ten64 was upstreamed into U-Boot. I think
  declaring fsl_setenv_bootcmd as __weak and allowing individual boards
  to override is the best way to do this without significant rework.
  (We actually depend on a similar feature for the DPAA2/MC firmware
  loading)

Compared to our firmware branch, there is still a few features missing (e.g USB
Hub, fan controller and fixes for the VSC8514). Some of these depend on other
things (like sorting out device tree schemas) so may not appear in mainline
U-Boot for a while yet.

16 months agoboard: ten64: strip extra u-boot compatibles from FDT
Mathew McBride [Fri, 21 Jul 2023 04:39:31 +0000 (04:39 +0000)]
board: ten64: strip extra u-boot compatibles from FDT

The u-boot version of the LS1088A device tree has
an extra compatible (simple-mfd) added to &fsl_mc
to facilitate usage with U-Boot's device model.

Unfortunately FreeBSD will only match the single
"fsl,qoriq-mc" exactly when the node is a "bus"
object, so we need to strip out the extra compatible
before presenting it to the operating system.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: ten64: opt out of fsl_setenv_bootcmd
Mathew McBride [Fri, 21 Jul 2023 04:39:30 +0000 (04:39 +0000)]
board: ten64: opt out of fsl_setenv_bootcmd

Our bootcmd is the same regardless of where the SoC
loaded it's code from, so we don't want
fsl_setenv_bootcmd to do anything.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoarch: arm: fsl-layerscape: allow "opt-out" of fsl_setenv_bootcmd
Mathew McBride [Fri, 21 Jul 2023 04:39:29 +0000 (04:39 +0000)]
arch: arm: fsl-layerscape: allow "opt-out" of fsl_setenv_bootcmd

Allow individual Layerscape boards to opt-out of fsl_setenv_bootcmd
by declaring the original function as weak.

fsl_setenv_bootcmd is used to change the bootcmd based on the
TF-A boot source (e.g QSPI vs SD/MMC) for reasons including
secure boot / integrity measurements and DPAA2 configuration loading.
See previous discussion at [1].

On the Ten64 board, our bootcmd is the same across
all TF-A boot sources so we don't want this behaviour.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
[1] https://patchwork.ozlabs.org/project/uboot/patch/20211110044639.7070-3-matt@traverse.com.au/#2790037

Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: adopt standard boot defaults
Mathew McBride [Fri, 21 Jul 2023 04:39:28 +0000 (04:39 +0000)]
board: traverse: ten64: adopt standard boot defaults

With the previous updates to the device tree, Ten64
can use Standard Boot 'out of the box'.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: ten64: disable watchdog autostart
Mathew McBride [Fri, 21 Jul 2023 04:39:27 +0000 (04:39 +0000)]
board: ten64: disable watchdog autostart

The watchdog driver was previously enabled but not used
until U-Boot's fsl-ls1088a.dtsi was updated to describe them.

Some Linux distributions (e.g Debian 11) do not engage the
SP805 watchdogs, causing unexpected resets after boot.

To conserve the user experience, turn off the autostart,
and we will provide a mechanism to turn them on at boot
via env vars.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: set serial# to be 'label' MAC
Mathew McBride [Fri, 21 Jul 2023 04:39:26 +0000 (04:39 +0000)]
board: traverse: ten64: set serial# to be 'label' MAC

The GE0 (first Gigabit Ethernet interface) is used as the
'serial number' for the board and appliance.

To ensure the 'true' board S/N is available regardless of how
the DPAA2 subsystem is configured, use serial# so it is passed in
the device tree.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: fix allocation order of MAC addresses
Mathew McBride [Fri, 21 Jul 2023 04:39:25 +0000 (04:39 +0000)]
board: traverse: ten64: fix allocation order of MAC addresses

On Ten64 boards, the "serial number" is the MAC address of the
first Gigabit Ethernet interface (labelled GE0 on the appliance),
and counted up from there.

The previous logic did not take into account U-Boot's ordering
of the network interfaces. By setting aliases/ethernetX in the device
tree we can ensure the U-Boot 'ethX' is the same as the labelled
port order on the unit, as well as the one adopted by Linux.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
16 months agoboard: traverse: ten64: init nvme devices in late boot to ensure bootflow availability
Mathew McBride [Fri, 21 Jul 2023 04:39:24 +0000 (04:39 +0000)]
board: traverse: ten64: init nvme devices in late boot to ensure bootflow availability

Ensure nvme devices are scanned before reaching the shell,
otherwise extra user intervention ("nvme scan") is required
before they are visible to bootdev/bootflow.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoconfigs: ten64: enable NVME_PCI
Mathew McBride [Fri, 21 Jul 2023 04:39:23 +0000 (04:39 +0000)]
configs: ten64: enable NVME_PCI

This restores NVMe functionality after PCI(e) NVMe support
was split out from the NVMe driver.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: ten64: add a bootmenu entries for NAND-based entries
Mathew McBride [Fri, 21 Jul 2023 04:39:22 +0000 (04:39 +0000)]
board: ten64: add a bootmenu entries for NAND-based entries

The recovery-firmware and OpenWrt-NAND do not yet have bootflow
/bootstd entrypoints, so add bootmenu entries to make them
accessible.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: add NAND based OpenWrt bootcmd
Mathew McBride [Fri, 21 Jul 2023 04:39:21 +0000 (04:39 +0000)]
board: traverse: ten64: add NAND based OpenWrt bootcmd

The default Ten64 MTD configuration reserves two ubifs partitions
for OpenWrt residing on NAND flash. Add the bootcmd for this system
into the default environment.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: specify bootargs for recovery environment
Mathew McBride [Fri, 21 Jul 2023 04:39:20 +0000 (04:39 +0000)]
board: traverse: ten64: specify bootargs for recovery environment

The recovery environment[1] on the Ten64 is a OpenWrt-
based ramdisk stored on the NAND intended to help with
system setup tasks.

Before the bootargs were not being set for the recovery
command, relying instead on the existing bootargs variable.

Ensure the bootargs are set correctly prior to booting recovery.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
[1] https://ten64doc.traverse.com.au/software/recovery/

Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: update DPAA2 (network) binary path on sdcards
Mathew McBride [Fri, 21 Jul 2023 04:39:19 +0000 (04:39 +0000)]
board: traverse: ten64: update DPAA2 (network) binary path on sdcards

Change the firmware on microSD path to "firmware/traverse/ten64"
as per EBBR section 4.2[1].

The Traverse firmware tools now locate the DPAA2 firmware
and configuration files under that path on the rescue
SD card image.
If a user then installs a standard Linux
distribution over the top of that sdcard, (in theory)
it will be left alone by distribution boot tooling.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
[1] https://arm-software.github.io/ebbr/index.html#firmware-partition-filesystem

Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: fix DPAA2 (network) DPL corruption issue
Mathew McBride [Fri, 21 Jul 2023 04:39:18 +0000 (04:39 +0000)]
board: traverse: ten64: fix DPAA2 (network) DPL corruption issue

The DPAA2 DPL (data plane layout) file was previously
being loaded into 0x80300000, and set to be applied
just before hand off to the kernel.

When a FIT image with a load_address of 0x80000000 was
booted with bootm, the DPL in memory was overwritten.

Move the DPL load to 0x8E000000 (196MiB away from 0x80000000,
and below the other typical load addr of 0x90000000).

Ideally in the future, the DPL lazyapply command
("fsl_mc lazyapply DPL $dpl_addr") should be set to
load the DPL contents into a memory area owned by U-Boot.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: traverse: ten64: ensure retimer reset is done on new board revisions
Mathew McBride [Fri, 21 Jul 2023 04:39:17 +0000 (04:39 +0000)]
board: traverse: ten64: ensure retimer reset is done on new board revisions

Board revision C (production) and later require the SFP+
retimer to be turned on (or reset) on boot, by way of issuing
a command to the board's microcontroller (via I2C).

The comparison statement here was incorrect, as the board
ID decrements every revision (from 0xFF downwards),
so this was matching board RevA,B,C instead of Rev >= C.

Another oops that transpired when working on this issue,
is that if the board controller is not called (such as
CONFIG_TEN64_CONTROLLER=n or earlier board rev), then
the retimer udevice was not obtained. So the board
version check has to be moved inside board_cycle_retimer
(which probes/fetches the retimer device) as well.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
16 months agoboard: traverse: ten64: recognize board revision D
Mathew McBride [Fri, 21 Jul 2023 04:39:16 +0000 (04:39 +0000)]
board: traverse: ten64: recognize board revision D

Ten64 board revision D is a variant that removes the USB hub
and PCIe expander/switch, but is otherwise compatible with the
main production "C" version.

At the same time, revise the printf specifiers (PCB version
"1064-0201%s") to reduce the number of string characters related
to the boot printout.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
16 months agoboard: mediatek: add MT7988 reference boards
Weijie Gao [Wed, 19 Jul 2023 09:17:54 +0000 (17:17 +0800)]
board: mediatek: add MT7988 reference boards

This patch adds general board files based on MT7988 SoCs.

MT7988 uses one mmc controller for booting from both SD and eMMC,
and the pins of mmc controller booting from SD are also shared with
one of spi controllers.
So two configs are need for these boot types:

1. mt7988_rfb_defconfig - SPI-NOR, SPI-NAND and eMMC
2. mt7988_sd_rfb_defconfig - SPI-NAND and SD

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoarm: mediatek: add support for MediaTek MT7988 SoC
Weijie Gao [Wed, 19 Jul 2023 09:17:49 +0000 (17:17 +0800)]
arm: mediatek: add support for MediaTek MT7988 SoC

This patch adds basic support for MediaTek MT7988 SoC.
This includes files that will initialize the SoC after boot and
its device tree.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agotools: mtk_image: use uint32_t for ghf header magic and version
Weijie Gao [Wed, 19 Jul 2023 09:17:45 +0000 (17:17 +0800)]
tools: mtk_image: use uint32_t for ghf header magic and version

This patch converts magic and version fields of ghf common header
to one field with the type of uint32_t to make this header flexible
for futher updates.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: add support for MediaTek MT7988 SoC
Weijie Gao [Wed, 19 Jul 2023 09:17:41 +0000 (17:17 +0800)]
net: mediatek: add support for MediaTek MT7988 SoC

This patch adds support for MediaTek MT7988.

MT7988 features MediaTek NETSYS v3, including three GMACs, and two
of them supports 10Gbps USXGMII.

MT7988 embeds a MT7531 switch (not MCM) which supports accessing
internal registers through MMIO instead of MDIO.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: add support for NETSYS v3
Weijie Gao [Wed, 19 Jul 2023 09:17:37 +0000 (17:17 +0800)]
net: mediatek: add support for NETSYS v3

This patch adds support for NETSYS v3 hardware.
Comparing to NETSYS v2, NETSYS v3 has three GMACs.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: add USXGMII support
Weijie Gao [Wed, 19 Jul 2023 09:17:31 +0000 (17:17 +0800)]
net: mediatek: add USXGMII support

This patch adds support for USXGMII of SoC.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoarm: dts: mediatek: add infracfg registers to support GMAC/USB3 Co-PHY
Weijie Gao [Wed, 19 Jul 2023 09:17:27 +0000 (17:17 +0800)]
arm: dts: mediatek: add infracfg registers to support GMAC/USB3 Co-PHY

This patch adds infracfg to eth node to support enabling GMAC2.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: add support for GMAC/USB3 PHY mux mode for MT7981
Weijie Gao [Wed, 19 Jul 2023 09:17:22 +0000 (17:17 +0800)]
net: mediatek: add support for GMAC/USB3 PHY mux mode for MT7981

MT7981 has its GMAC2 PHY shared with USB3. To enable GMAC2, mux
register must be set to connect the SGMII phy to GMAC2.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoarm: dts: medaitek: convert gmac link mode to 2500base-x
Weijie Gao [Wed, 19 Jul 2023 09:17:18 +0000 (17:17 +0800)]
arm: dts: medaitek: convert gmac link mode to 2500base-x

Now that individual 2.5Gbps SGMII support has been added to
mtk-eth, all boards that use 2.5Gbps link with mt7531 must be
converted to use "2500base-x" instead of "sgmii".

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: add support for SGMII 1Gbps auto-negotiation mode
Weijie Gao [Wed, 19 Jul 2023 09:17:13 +0000 (17:17 +0800)]
net: mediatek: add support for SGMII 1Gbps auto-negotiation mode

Existing SGMII support of mtk-eth is actually a MediaTek-specific
2.5Gbps high-speed SGMII (HSGMII) which does not support
auto-negotiation mode.

This patch adds SGMII 1Gbps auto-negotiation mode and rename the
existing HSGMII to 2500basex.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: add missing static qualifier
Weijie Gao [Wed, 19 Jul 2023 09:17:07 +0000 (17:17 +0800)]
net: mediatek: add missing static qualifier

mt7531_mmd_ind_read and mt753x_switch_init are defined without static.
Since they're not used outside this file, we should add them back.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
fixup to add static qualifier

16 months agonet: mediatek: fix direct MDIO clause 45 access via SoC
Weijie Gao [Wed, 19 Jul 2023 09:17:03 +0000 (17:17 +0800)]
net: mediatek: fix direct MDIO clause 45 access via SoC

The original direct MDIO clause 45 access via SoC is missing the
data output. This patch adds it back to ensure MDIO clause 45 can
work properly for external PHYs.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: optimize the switch reset delay wait time
Weijie Gao [Wed, 19 Jul 2023 09:16:59 +0000 (17:16 +0800)]
net: mediatek: optimize the switch reset delay wait time

Not all switches requires 1 second delay after deasserting reset.
MT7531 requires only maximum 200ms.

This patch defines dedicated reset wait time for each switch chip, and will
significantly improve the boot time for boards using MT7531.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agonet: mediatek: connect switch to PSE only when starting eth is requested
Weijie Gao [Wed, 19 Jul 2023 09:16:54 +0000 (17:16 +0800)]
net: mediatek: connect switch to PSE only when starting eth is requested

So far the switch is initialized in probe stage and is connected to PSE
unconditionally. This will cause all packets being flooded to PSE and may
cause PSE hang before entering linux.

This patch changes the connection between switch and PSE:
- Still initialize switch in probe stage, but disconnect it with PSE
- Connect switch with PSE on eth start
- Disconnect on eth stop

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agopinctrl: mediatek: add pinctrl driver for MT7988 SoC
Weijie Gao [Wed, 19 Jul 2023 09:16:50 +0000 (17:16 +0800)]
pinctrl: mediatek: add pinctrl driver for MT7988 SoC

This patch adds pinctrl and gpio support for MT7988 SoC

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agopinctrl: mediatek: add pinmux_set ops support
Weijie Gao [Wed, 19 Jul 2023 09:16:46 +0000 (17:16 +0800)]
pinctrl: mediatek: add pinmux_set ops support

This patch adds pinmux_set ops for mediatek pinctrl framework

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agopinctrl: mediatek: fix the return value in driving configuration functions
Weijie Gao [Wed, 19 Jul 2023 09:16:42 +0000 (17:16 +0800)]
pinctrl: mediatek: fix the return value in driving configuration functions

The original mediatek pinctrl functions for driving configuration
'mtk_pinconf_drive_set_*' do not return -ENOSUPP even if input
parameters are not supported.
This patch fixes the return value in those functions.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agopinctrl: mediatek: convert most definitions to const
Weijie Gao [Wed, 19 Jul 2023 09:16:37 +0000 (17:16 +0800)]
pinctrl: mediatek: convert most definitions to const

There exists a situation of the mediatek pinctrl driver that may return
wrong pin function value for the pinmux driver:
- All pin function arrays are defined without const
- Some pin function arrays contain all-zero value, e.g.:
  static int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, };
- These arrays will be put into .bss section during compilation
- .bss section has no "a" attribute and does not exist in the final binary
  file after objcopy.
- FDT binary blob is appended to the u-boot binary, which occupies the
  .bss section.
- During board_f stage, .bss has not been initialized, and contains the
  data of FDT, which is not full-zero data.
- pinctrl driver is initialized in board_f stage, and it will get wrong
  data if another driver is going to set default pinctrl.

Since pinmux information and soc data are only meant to be read-only, thus
should be declared as const. This will force all pinctrl data being put
into .rodata section. Since .rodata has "a" attribute, even the all-zero
data will be allocated and filled with correct value in to u-boot binary.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoreset: mediatek: add reset definition for MediaTek MT7988 SoC
Weijie Gao [Wed, 19 Jul 2023 09:16:33 +0000 (17:16 +0800)]
reset: mediatek: add reset definition for MediaTek MT7988 SoC

This patch adds reset bits for MediaTek MT7988

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoclk: mediatek: add clock driver support for MediaTek MT7988 SoC
Weijie Gao [Wed, 19 Jul 2023 09:16:28 +0000 (17:16 +0800)]
clk: mediatek: add clock driver support for MediaTek MT7988 SoC

This patch adds clock driver support for MediaTek MT7988 SoC

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agopwm: mtk: add support for MediaTek MT7988 SoC
Weijie Gao [Wed, 19 Jul 2023 09:16:24 +0000 (17:16 +0800)]
pwm: mtk: add support for MediaTek MT7988 SoC

This patch adds PWM support for MediaTek MT7988 SoC.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoarm: dts: enable i2c support for MediaTek MT7981
Weijie Gao [Wed, 19 Jul 2023 09:16:19 +0000 (17:16 +0800)]
arm: dts: enable i2c support for MediaTek MT7981

This patch enables i2c support for MediaTek MT7981

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoi2c: mediatek: fix I2C usability for MT7981
Weijie Gao [Wed, 19 Jul 2023 09:16:15 +0000 (17:16 +0800)]
i2c: mediatek: fix I2C usability for MT7981

MT7981 actually uses MediaTek I2C controller v3 instead of v1.
This patch adds support for I2C controller v3 fix fixes the I2C usability
for MT7981.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoreset: mediatek: check malloc return valaue before use
Weijie Gao [Wed, 19 Jul 2023 09:16:11 +0000 (17:16 +0800)]
reset: mediatek: check malloc return valaue before use

This patch add missing return value check for allocating the driver's
private data. -ENOMEM will be returned if malloc() fails.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoserial: mtk: initial priv data before using
Weijie Gao [Wed, 19 Jul 2023 09:16:07 +0000 (17:16 +0800)]
serial: mtk: initial priv data before using

This patch ensures driver private data being fully initialized in
_debug_uart_init which is not covered by .priv_auto ops.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Reviewed-by: Stefan Roese <sr@denx.de>
16 months agospi: mtk_spim: clear IRQ enable bits
Weijie Gao [Wed, 19 Jul 2023 09:16:02 +0000 (17:16 +0800)]
spi: mtk_spim: clear IRQ enable bits

In u-boot we don't use IRQ. Instead, we poll busy bit in SPI_STATUS.

However these IRQ enable bits may be set in previous boot stage (BootROM).

If we leave these bits not cleared, although u-boot has disabled IRQ and
nothing will happen, the linux kernel may encounter panic during
initializing the spim driver due to IRQ event happens before IRQ handler
is properly setup.

This patch clear IRQ bits to prevent this from happening.

Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
16 months agospi: mtk_spim: get spi clk rate only once
Weijie Gao [Wed, 19 Jul 2023 09:15:54 +0000 (17:15 +0800)]
spi: mtk_spim: get spi clk rate only once

We don't really need to switch clk rate during operating SPIM controller.
Get clk rate only once at driver probing.

Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
16 months agoboard: mediatek: update config headers
Weijie Gao [Wed, 19 Jul 2023 09:15:47 +0000 (17:15 +0800)]
board: mediatek: update config headers

Remove unused information from include/configs/mtxxxx.h

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoarm: mediatek: retrieve ram_base from dts node for armv8 platform
Weijie Gao [Wed, 19 Jul 2023 09:15:41 +0000 (17:15 +0800)]
arm: mediatek: retrieve ram_base from dts node for armv8 platform

Now we use fdtdec_setup_mem_size_base() to get DRAM base from fdt ram node
and update gd->ram_base. CFG_SYS_SDRAM_BASE is unused and will be removed.

Also, since mt7622 always passes fdt to linux kernel, there's no need to
assign value to gd->bd->bi_boot_params.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
16 months agoefi_loader: check uuid_str_to_bin return value
Masahisa Kojima [Mon, 31 Jul 2023 08:53:02 +0000 (17:53 +0900)]
efi_loader: check uuid_str_to_bin return value

Check the uuid_str_to_bin return value, skip the node
if the image-type-id property is wrong format.

Addresses-Coverity-ID: 463145 ("Error handling issues")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
16 months agoefi_loader: catch out of memory in file_open
Heinrich Schuchardt [Sun, 30 Jul 2023 12:06:06 +0000 (14:06 +0200)]
efi_loader: catch out of memory in file_open

If calloc() return NULL, don't dereference it.

Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: error handling in efi_disk_add_dev
Heinrich Schuchardt [Sun, 30 Jul 2023 12:03:53 +0000 (14:03 +0200)]
efi_loader: error handling in efi_disk_add_dev

* If an error occurs in efi_disk_add_dev(), don't leak resources.
* If calloc() fails while creating the file system protocol interface,
  signal an error.
* Rename efi_simple_file_system() to efi_create_simple_file_system().
* Drop a little helpful debug message.

Fixes: 2a92080d8c44 ("efi_loader: add file/filesys support")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: memory leak efi_add_memory_map_pg
Heinrich Schuchardt [Sun, 30 Jul 2023 10:59:32 +0000 (12:59 +0200)]
efi_loader: memory leak efi_add_memory_map_pg

Don't leak newlist if we error out.

Fixes: 74c16acce30b ("efi_loader: Don't allocate from memory holes")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: out of memory in efi_mem_carve_out
Heinrich Schuchardt [Sun, 30 Jul 2023 10:27:03 +0000 (12:27 +0200)]
efi_loader: out of memory in efi_mem_carve_out

Handle out of memory situation in efi_mem_carve_out().

Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: overflow in efi_allocate_pages
Heinrich Schuchardt [Sun, 30 Jul 2023 09:31:08 +0000 (11:31 +0200)]
efi_loader: overflow in efi_allocate_pages

On 32bit systems (pages << EFI_PAGE_SHIFT) may lead to an overflow which
does not occur in 64bit arithmetics.

An overflow of (pages << EFI_PAGE_SHIFT) on 64bit systems should be treated
as an error.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
16 months agoefi_loader: error handling in tcg2_hash_pe_image()
Heinrich Schuchardt [Mon, 31 Jul 2023 12:11:34 +0000 (14:11 +0200)]
efi_loader: error handling in tcg2_hash_pe_image()

If the hard coded array hash_algo_list[] contains an entry for an
unsupported algorithm, we should not leak resources new_efi and regs.

We should still extend the log with the digests for the supported
algorithms and not write any message.

The same holds true of tcg2_create_digest(): just continue in case
hash_algo_list[] contains an unsupported entry.

Fixes: 163a0d7e2cbd ("efi_loader: add PE/COFF image measurement")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: out of memory in efi_add_memory_map_pg
Heinrich Schuchardt [Sun, 30 Jul 2023 10:36:17 +0000 (12:36 +0200)]
efi_loader: out of memory in efi_add_memory_map_pg

Handle out of memory situation in efi_add_memory_map_pg().

Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_selftest: remove superfluous assignments
Heinrich Schuchardt [Sun, 30 Jul 2023 08:28:10 +0000 (10:28 +0200)]
efi_selftest: remove superfluous assignments

In test_hii_database_list_package_lists() 'ret' is used for the return code
of EFI API calls and 'result' for the return value of the function. Writing
EFI_ST_FAILURE to ret is superfluous.

Fixes: 4c4fb10da294 ("efi_selftest: add HII database protocols test")
Fixes: ee3c8ba85525 ("efi_selftest: fix memory allocation in HII tests")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: fix an IS_ERR() vs NULL check
Dan Carpenter [Thu, 27 Jul 2023 07:16:20 +0000 (10:16 +0300)]
efi_loader: fix an IS_ERR() vs NULL check

The efi_parse_pkcs7_header() function returns NULL on error so the check
for IS_ERR() should be changed to a NULL check.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
16 months agoefi_loader: capsule: enforce guid check in api and capsule_on_disk
AKASHI Takahiro [Thu, 27 Jul 2023 00:38:00 +0000 (09:38 +0900)]
efi_loader: capsule: enforce guid check in api and capsule_on_disk

While UPDATE_CAPSULE api is not fully implemented, this interface and
capsule-on-disk feature should behave in the same way, especially in
handling an empty capsule for fwu multibank, for future enhancement.

So move the guid check into efi_capsule_update_firmware().

Fixed: commit a6aafce494ab ("efi_loader: use efi_update_capsule_firmware() for capsule on disk")
Reported-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reported-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
16 months agoefi_loader: Fix memory corruption on 32bit systems
Dan Carpenter [Wed, 26 Jul 2023 06:54:52 +0000 (09:54 +0300)]
efi_loader: Fix memory corruption on 32bit systems

It's pretty unlikely that anyone is going to be using EFI authentication
on a 32bit system.  However, if you did, the efi_prepare_aligned_image()
function would write 8 bytes of data to the &efi_size variable and it
can only hold 4 bytes so that corrupts memory.

Fixes: 163a0d7e2cbd ("efi_loader: add PE/COFF image measurement")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
16 months agodm: Correct DM_FLAG_ comment
Bin Meng [Mon, 31 Jul 2023 14:01:26 +0000 (22:01 +0800)]
dm: Correct DM_FLAG_ comment

The macros are prefixed with DM_FLAG_, not DM_FLAGS_.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>