Re: [PATCH v1 6/6] spinand: bind UBI block
Hello Alexey, On 06.03.24 14:49, Alexey Romanov wrote: UBI block is virtual block device, which is an abstraction over MTD layer. Therefore it is logical to use it in combination with MTD drivers. Signed-off-by: Alexey Romanov --- drivers/mtd/nand/spi/core.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index f2ec32e1d0..32705e1e2a 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1182,7 +1183,13 @@ static void spinand_cleanup(struct spinand_device *spinand) static int spinand_bind(struct udevice *dev) { struct spinand_plat *plat = dev_get_plat(dev); - return mtd_bind(dev, &plat->mtd); + int ret; + + ret = mtd_bind(dev, &plat->mtd); + if (ret) + return ret; + + return ubi_bind(dev); What is with boards which do not use ubi block or CONFIG_BLK at all? bye, Heiko -- -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v1 5/6] disk: support UBI partitions
Hello Alexey, On 06.03.24 14:49, Alexey Romanov wrote: UBI partition is abstraction over UBI volumes. Can be used by UBI block device. Signed-off-by: Alexey Romanov --- drivers/mtd/ubi/Makefile | 1 + drivers/mtd/ubi/part.c | 99 include/part.h | 2 + 3 files changed, 102 insertions(+) create mode 100644 drivers/mtd/ubi/part.c diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile index 67b1a05348..e443f3585e 100644 --- a/drivers/mtd/ubi/Makefile +++ b/drivers/mtd/ubi/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o obj-y += misc.o obj-y += debug.o obj-$(CONFIG_BLK) += block.o +obj-y += part.o May it is good to have this as an Kconfig option? So boards which do not use UBI block will save code size... Beside of this: Reviewed-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v1 4/6] disk: don't try search for partition type if already set
Hello Alexey, On 06.03.24 14:49, Alexey Romanov wrote: Block devices can already set partition type at initialization stage, so, in this case is no point in searching for partition type. Signed-off-by: Alexey Romanov --- disk/part.c | 7 +++ 1 file changed, 7 insertions(+) Reviewed-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v1 3/6] drivers: introduce UBI block abstraction
Hello Alexey, On 06.03.24 14:49, Alexey Romanov wrote: UBI block is an virtual device, that runs on top of the MTD layer. The blocks are UBI volumes. Intended to be used in combination with other MTD drivers. Despite the fact that it, like mtdblock abstraction, it used with UCLASS_MTD, they can be used together on the system without conflicting. For example, using bcb command: # Trying to load bcb via mtdblock: $ bcb load mtd 0 mtd_partition_name # Trying to load bcb via UBI block: $ bcb load ubi 1 ubi_volume_name User always must attach UBI layer (for example, using ubi_part()) before using UBI block device. Signed-off-by: Alexey Romanov --- drivers/block/blk-uclass.c | 1 + drivers/mtd/ubi/Makefile | 1 + drivers/mtd/ubi/block.c| 130 + include/ubi_uboot.h| 4 ++ 4 files changed, 136 insertions(+) create mode 100644 drivers/mtd/ubi/block.c Reviewed-by: Heiko Schocher Acked-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v1 2/6] ubi: allow to write to volume with offset
Hello Alexey, On 06.03.24 14:49, Alexey Romanov wrote: Introduce ubi_volume_offset_write() helper, which allow to write to ubi volume with specified offset. Signed-off-by: Alexey Romanov --- cmd/ubi.c | 71 +++-- env/ubi.c | 10 +++ include/ubi_uboot.h | 2 +- 3 files changed, 74 insertions(+), 9 deletions(-) Reviewed-by: Heiko Schocher Acked-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v1 1/6] ubi: allow to read from volume with offset
Hello Alexey, On 06.03.24 14:49, Alexey Romanov wrote: Now user can pass an additional parameter 'offset' to ubi_volume_read() function. Signed-off-by: Alexey Romanov --- cmd/ubi.c | 6 +++--- env/ubi.c | 6 +++--- include/ubi_uboot.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) Reviewed-by: Heiko Schocher Acked-by: Heiko Schocher bye, Heiko -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: h...@denx.de
Re: [PATCH v7] remoteproc: uclass: Add methods to load firmware to rproc and boot rproc
On Thu, 21 Mar 2024 15:58:19 +0530, MD Danish Anwar wrote: > Add APIs to set a firmware_name to a rproc and boot the rproc with the > same firmware. > > Clients can call rproc_set_firmware() API to set firmware_name for a rproc > whereas rproc_boot() will load the firmware set by rproc_set_firmware() to > a buffer by calling request_firmware_into_buf(). rproc_boot() will then > load the firmware file to the remote processor and start the remote > processor. > > [...] Applied to u-boot/next, thanks! -- Tom
Re: [PATCH v3 0/2] Add remoteproc driver support for J721S2 SoC
On Tue, 12 Mar 2024 15:14:34 +0530, Apurva Nandan wrote: > This series adds relevant ip data in remoteproc driver for j721s2 compatible. > > Logs: > https://gist.githubusercontent.com/apurvanandan1997/276098af439e11105ab9f809159fcc98/raw/ > > Changes in v3: > - Removed j721s2.env patch from the series > > [...] Applied to u-boot/next, thanks! -- Tom
Re: [PATCH] arm: dts: kirkwood: Enable upstream DT on Kirkwood boards
Hi Michael, On Fri, Mar 22, 2024 at 2:10 PM Michael Walle wrote: > > Hi Tony, > > On Fri Mar 22, 2024 at 3:17 AM CET, Tony Dinh wrote: > > Enable OF_UPSTREAM to use upstream DT and add marvell/ prefix to the > > DEFAULT_DEVICE_TREE for Kirkwood boards. And so we can directly build > > DTBs from dts/upstream/src/arm/marvell, and including *-u-boot.dtsi > > files from arch/arm/dts/ directory. > > Thanks for taking care. > > > Signed-off-by: Tony Dinh > > Tested-by: Michael Walle # on lschlv2 > > lsxl should work too as it is just different in memory and cpu > frequency settings. > > > --- > > > > arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi | 6 -- > > arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi | 6 -- > > arch/arm/dts/kirkwood-lschlv2.dts > arch/arm/dts/kirkwood-lsxhl.dts > > Should be then be removed. Thanks for the lschlv2 review/test! I plan to send a follow-up patch to remove the corresponding DTS and DTSI files. All the best, Tony > > -michael
Re: [PATCH] arm: dts: kirkwood: Enable upstream DT on Kirkwood boards
Hi Tony, On Fri Mar 22, 2024 at 3:17 AM CET, Tony Dinh wrote: > Enable OF_UPSTREAM to use upstream DT and add marvell/ prefix to the > DEFAULT_DEVICE_TREE for Kirkwood boards. And so we can directly build > DTBs from dts/upstream/src/arm/marvell, and including *-u-boot.dtsi > files from arch/arm/dts/ directory. Thanks for taking care. > Signed-off-by: Tony Dinh Tested-by: Michael Walle # on lschlv2 lsxl should work too as it is just different in memory and cpu frequency settings. > --- > > arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi | 6 -- > arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi | 6 -- arch/arm/dts/kirkwood-lschlv2.dts arch/arm/dts/kirkwood-lsxhl.dts Should be then be removed. -michael
[PATCH v2 3/3] rockchip: spl: Add SPI NOR flash to boot_devices array
Add missing boot source id <-> device tree node path mapping for SPI NOR flash on PX30, RK3288, RK3308, RK3368 and RV1126. Signed-off-by: Jonas Karlman --- v2: - New patch --- arch/arm/mach-rockchip/px30/px30.c | 1 + arch/arm/mach-rockchip/rk3288/rk3288.c | 1 + arch/arm/mach-rockchip/rk3308/rk3308.c | 1 + arch/arm/mach-rockchip/rk3368/rk3368.c | 1 + arch/arm/mach-rockchip/rv1126/rv1126.c | 1 + 5 files changed, 5 insertions(+) diff --git a/arch/arm/mach-rockchip/px30/px30.c b/arch/arm/mach-rockchip/px30/px30.c index b4f655fa4b3e..2ec3289d75b7 100644 --- a/arch/arm/mach-rockchip/px30/px30.c +++ b/arch/arm/mach-rockchip/px30/px30.c @@ -19,6 +19,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { [BROM_BOOTSOURCE_EMMC] = "/mmc@ff39", + [BROM_BOOTSOURCE_SPINOR] = "/spi@ff3a/flash@0", [BROM_BOOTSOURCE_SD] = "/mmc@ff37", }; diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c b/arch/arm/mach-rockchip/rk3288/rk3288.c index c77c56c1dab5..70cf50029121 100644 --- a/arch/arm/mach-rockchip/rk3288/rk3288.c +++ b/arch/arm/mach-rockchip/rk3288/rk3288.c @@ -28,6 +28,7 @@ DECLARE_GLOBAL_DATA_PTR; const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { [BROM_BOOTSOURCE_EMMC] = "/mmc@ff0f", + [BROM_BOOTSOURCE_SPINOR] = "/spi@ff13/flash@0", [BROM_BOOTSOURCE_SD] = "/mmc@ff0c", }; diff --git a/arch/arm/mach-rockchip/rk3308/rk3308.c b/arch/arm/mach-rockchip/rk3308/rk3308.c index 27a748327e31..b3ffabc5449a 100644 --- a/arch/arm/mach-rockchip/rk3308/rk3308.c +++ b/arch/arm/mach-rockchip/rk3308/rk3308.c @@ -141,6 +141,7 @@ enum { const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { [BROM_BOOTSOURCE_EMMC] = "/mmc@ff49", + [BROM_BOOTSOURCE_SPINOR] = "/spi@ff4c/flash@0", [BROM_BOOTSOURCE_SD] = "/mmc@ff48", }; diff --git a/arch/arm/mach-rockchip/rk3368/rk3368.c b/arch/arm/mach-rockchip/rk3368/rk3368.c index 651ba1090206..8f5ca1dfa7c9 100644 --- a/arch/arm/mach-rockchip/rk3368/rk3368.c +++ b/arch/arm/mach-rockchip/rk3368/rk3368.c @@ -55,6 +55,7 @@ struct mm_region *mem_map = rk3368_mem_map; const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { [BROM_BOOTSOURCE_EMMC] = "/mmc@ff0f", + [BROM_BOOTSOURCE_SPINOR] = "/spi@ff12/flash@0", [BROM_BOOTSOURCE_SD] = "/mmc@ff0c", }; diff --git a/arch/arm/mach-rockchip/rv1126/rv1126.c b/arch/arm/mach-rockchip/rv1126/rv1126.c index 8589c46f10aa..40eb9eb7b196 100644 --- a/arch/arm/mach-rockchip/rv1126/rv1126.c +++ b/arch/arm/mach-rockchip/rv1126/rv1126.c @@ -15,6 +15,7 @@ const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { [BROM_BOOTSOURCE_EMMC] = "/mmc@ffc5", + [BROM_BOOTSOURCE_SPINOR] = "/spi@ffc9/flash@0", [BROM_BOOTSOURCE_SD] = "/mmc@ffc6", }; -- 2.43.2
[PATCH v2 2/3] rockchip: spl: Cache boot source id for later use
Rockchip BROM writes a boot source id at CFG_IRAM_BASE + 0x10, this id indicates from what storage media TPL/SPL was loaded from. SPL uses this id to determine what device "same-as-spl" represent when determining from where FIT should be loaded. This works as long as the boot_devices array contain a matching id <-> node path entry. However, SPL typically load a small part of TF-A into SRAM and on RK3399 this overwrites the CFG_IRAM_BASE + 0x10 addr used for boot source id. For affected devices the u-boot,spl-boot-device would not be set when booting from SPI flash and the flash@0 node was not explicitly listed in the u-boot,spl-boot-order prop. Here boot source id is 3 before FIT images is loaded, and 0 after: U-Boot SPL 2024.04-rc4 (Mar 15 2024 - 17:26:19 +) board_spl_was_booted_from: brom_bootdevice_id 3 maps to '/spi@ff1d/flash@0' Trying to boot from SPI ## Checking hash(es) for config config-1 ... OK ## Checking hash(es) for Image atf-1 ... sha256+ OK ## Checking hash(es) for Image u-boot ... sha256+ OK ## Checking hash(es) for Image fdt-1 ... sha256+ OK ## Checking hash(es) for Image atf-2 ... sha256+ OK ## Checking hash(es) for Image atf-3 ... sha256+ OK board_spl_was_booted_from: failed to resolve brom_bootdevice_id 0 spl_decode_boot_device: could not find udevice for /mmc@fe33 spl_decode_boot_device: could not find udevice for /mmc@fe32 spl_perform_fixups: could not map boot_device to ofpath: -19 Use a static brom_bootsource_id_cache to save the boot source id after an initial read from SRAM to fix this, this allow spl_perform_fixups() to resolve correct boot source path for "same-as-spl" after SPL have loaded TF-A related FIT images into memory. With this the spl-boot-device prop can correctly be resolved to the SPI flash node in the control FDT: => fdt addr ${fdtcontroladdr} Working FDT set to f1ee6710 => fdt list /chosen chosen { u-boot,spl-boot-device = "/spi@ff1d/flash@0"; stdout-path = "serial2:150n8"; u-boot,spl-boot-order = "same-as-spl", "/mmc@fe33", "/mmc@fe32"; }; Fixes: d57e16c7e712 ("rockchip: find U-boot proper boot device by inverting the logic that sets it") Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- v2: - Only cache boot source id that can be resolved to a node path - Make use of the new BROM_BOOTSOURCE_UNKNOWN enum value - Update commit message - Add fixes tag - Collect r-b tag --- arch/arm/mach-rockchip/spl.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index 1586a093fc37..3ce7e792b5a2 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -32,18 +32,26 @@ __weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = { const char *board_spl_was_booted_from(void) { - u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR); + static u32 brom_bootsource_id_cache = BROM_BOOTSOURCE_UNKNOWN; + u32 bootdevice_brom_id; const char *bootdevice_ofpath = NULL; + if (brom_bootsource_id_cache != BROM_BOOTSOURCE_UNKNOWN) + bootdevice_brom_id = brom_bootsource_id_cache; + else + bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR); + if (bootdevice_brom_id < ARRAY_SIZE(boot_devices)) bootdevice_ofpath = boot_devices[bootdevice_brom_id]; - if (bootdevice_ofpath) + if (bootdevice_ofpath) { + brom_bootsource_id_cache = bootdevice_brom_id; debug("%s: brom_bootdevice_id %x maps to '%s'\n", __func__, bootdevice_brom_id, bootdevice_ofpath); - else + } else { debug("%s: failed to resolve brom_bootdevice_id %x\n", __func__, bootdevice_brom_id); + } return bootdevice_ofpath; } -- 2.43.2
[PATCH v2 1/3] rockchip: bootrom: Sync bootsource id enum from bootrom
From: Jason Zhu Add more bootsource id: 1. BROM_BOOTSOURCE_UNKNOWN 2. BROM_BOOTSOURCE_I2C 3. BROM_BOOTSOURCE_SPI Signed-off-by: Jason Zhu [jo...@kwiboo.se: Update commit message] Signed-off-by: Jonas Karlman --- v2: - New patch --- arch/arm/include/asm/arch-rockchip/bootrom.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/include/asm/arch-rockchip/bootrom.h b/arch/arm/include/asm/arch-rockchip/bootrom.h index 4276a0f6811a..ecf3b4e7428c 100644 --- a/arch/arm/include/asm/arch-rockchip/bootrom.h +++ b/arch/arm/include/asm/arch-rockchip/bootrom.h @@ -43,11 +43,14 @@ void back_to_bootrom(enum rockchip_bootrom_cmd brom_cmd); * Boot-device identifiers as used by the BROM */ enum { + BROM_BOOTSOURCE_UNKNOWN = 0, BROM_BOOTSOURCE_NAND = 1, BROM_BOOTSOURCE_EMMC = 2, BROM_BOOTSOURCE_SPINOR = 3, BROM_BOOTSOURCE_SPINAND = 4, BROM_BOOTSOURCE_SD = 5, + BROM_BOOTSOURCE_I2C = 8, + BROM_BOOTSOURCE_SPI = 9, BROM_BOOTSOURCE_USB = 10, BROM_LAST_BOOTSOURCE = BROM_BOOTSOURCE_USB }; -- 2.43.2
[PATCH v2 0/3] rockchip: spl: Cache boot source id for later use
This series fixes an issue where /chosen/u-boot,spl-boot-device prop cannot be resolved to the SPI flash node path in spl_perform_fixups() if the affected device was booted from SPI flash. Changes in v2: - Add patch that sync boot source id enum with bootrom - Add patch that adds missing SPI flash node path for SoCs with DTs having a jedec,spi-nor compatible flash@0 node. - Only cache boot source id that can be resolved to a node path - Make use of synced BROM_BOOTSOURCE_UNKNOWN enum value - Update commit message - Add fixes tag - Collect r-b tag Jason Zhu (1): rockchip: bootrom: Sync bootsource id enum from bootrom Jonas Karlman (2): rockchip: spl: Cache boot source id for later use rockchip: spl: Add SPI NOR flash to boot_devices array arch/arm/include/asm/arch-rockchip/bootrom.h | 3 +++ arch/arm/mach-rockchip/px30/px30.c | 1 + arch/arm/mach-rockchip/rk3288/rk3288.c | 1 + arch/arm/mach-rockchip/rk3308/rk3308.c | 1 + arch/arm/mach-rockchip/rk3368/rk3368.c | 1 + arch/arm/mach-rockchip/rv1126/rv1126.c | 1 + arch/arm/mach-rockchip/spl.c | 14 +++--- 7 files changed, 19 insertions(+), 3 deletions(-) -- 2.43.2
Re: [PATCH] arm64: Fix map_range() not splitting mapped blocks
On Fri, Mar 22, 2024 at 4:31 PM Fabio Estevam wrote: > As Pierre's explanation addresses Marc's concern, > do you think this can go to 2024.01 to fix the boot regression on imx8qxp/8qm? I meant 2024.04, sorry.
Re: [PATCH] arm64: Fix map_range() not splitting mapped blocks
Hi Tom, On Tue, Mar 19, 2024 at 9:39 AM Pierre-Clément Tosi wrote: > For most AArch64 U-Boot ports (including the i.MX family), the answer is > trivial > because they use the arch code i.e. setup_all_pgtables(). However, as > fsl-layerscape re-implements mmu_setup(), it had to be looked at separately, > hence my question, which you answered above. As Pierre's explanation addresses Marc's concern, do you think this can go to 2024.01 to fix the boot regression on imx8qxp/8qm? Thanks
Re: [PATCH v1] board: toradex: verdin-am62_r5: Increase SPL_STACK_R_MALLOC_SIMPLE_LEN
On Wed, 20 Mar 2024 13:48:45 -0300, Hiago De Franco wrote: > Increase the SPL_STACK_R_MALLOC_SIMPLE_LEN to 0x20 to accommodate the > size of tispl.bin fit image. With the recent upgrade of ti-linux-firmware > from version v9.1.0 to v9.2.5, the size of tispl.bin fit image has > increased to 1.4MB, causing allocation errors in the R5 SPL: > > ``` > alloc space exhausted > Could not get FIT buffer of 1325056 bytes > check CONFIG_SPL_SYS_MALLOC_SIZE > ``` > > [...] Applied to u-boot/master, thanks! -- Tom
Re: [PATCH 1/1] .mailmap entry for Masahisa Kojima
On Mon, 18 Mar 2024 11:47:16 +0100, Heinrich Schuchardt wrote: > The Linaro mail address is not valid anymore. > > Applied to u-boot/master, thanks! -- Tom
Re: [PATCH] arm: dts: k3-am625-verdin-r5: Change CPU frequency to 800MHz
On Tue, 19 Mar 2024 11:04:27 -0300, Joao Paulo Goncalves wrote: > The lowest speed grade of Toradex AM62 SoMs is K speed, resulting in a > max value of 800MHz for the CPU operating frequency. A solution with > runtime selection of the CPU frequency is already planned to avoid these > kinds of problems in the future. > > Applied to u-boot/master, thanks! -- Tom
Re: [PATCH 1/2] clk: clk-imx8qxp: Add LPUART IPG entries
On Fri, 08 Mar 2024 17:13:15 -0300, Fabio Estevam wrote: > Since commit cc7df0b9e8bc ("serial: lpuart: Enable IPG clock") > the colibri-imx8qxp board no longer boots. > > The reason is that the imx8qxp clock driver does not handle the > LPUART IPG clocks inside get_rate(), set_rate() and enable() functions. > > Fix the boot regression by adding the LPUART IPG entries. > > [...] Applied to u-boot/master, thanks! -- Tom
Re: inconsistent wget behavior
Hi Paul, On Sun, Feb 11, 2024 at 4:42 PM Paul Liu wrote: > > Hi Fabio, > > I'm on vacation now (Chinese new year). I hope I'll find some time to revive > my imx8 board. > I've tried sandbox and qemu. Both of them are not reproducible. I'm wondering > if it could be some packet loss that causes the issue. Because sandbox and > qemu there won't be any missing packets because of loopback devices. Have you had a chance to reproduce the issue on your imx8mm board?
Re: [PATCH v2 2/2] rockchip: rock-pi-4-rk3399: enable booting from SPI flash
Hi Jonas, On Mon, 2024-03-18 at 11:37 +0100, Jonas Karlman wrote: > Hi Christopher, > > On 2024-03-15 13:01, Christopher Obbard wrote: > > Some variants of the ROCK Pi 4 series have an SPI flash chip populated > > which can be booted from. This patch enables support in U-Boot for > > building the image for the SPI flash, support for booting U-Boot from the > > SPI flash chip and support in U-Boot for accessing the SPI flash using > > `sf` commands. > > > > Not all variants (e.g. ROCK Pi 4B, ROCK 4 Model C Plus, ROCK 4SE) come > > populated with an SPI flash chip, but have the footprint on the board so > > a user could solder their own to the board. With this patchset applied, > > these board variants without an SPI flash chip still boot from MMC. > > > > I have enabled support for both Winbond and XTX SPI flash devices since > > different hardware variants have different devices populated: > > > > - `rockpi4_v13_sch_20181112.pdf` contains a Winbond part `W25Q64FWZPIG` > > - `rockpi4_v14_sch_20210114.pdf` contains an XTX part `XT25F32BWOIGT` > > > > The ROCK Pi 4 I have is marked as "ROCK PI 4 v1.48" and contains an SPI > > flash chip from XTX: > > > > => sf probe > > SF: Detected xt25f32 with page size 256 Bytes, erase size 4 KiB, total > > 4 MiB > > > > In the interest of supporting all board variants and not regressing > > existing users who boot from MMC, I have enabled support for booting from > > both SPI flash chip variants in the defconfig and left the environment > > storage location as MMC to not break existing users who have the > > environment stored on MMC. > > > > Signed-off-by: Christopher Obbard > > With a small nit below this is: > > Reviewed-by: Jonas Karlman > > > > > --- > > > > Changes in v2: > > - Rebase on top of rockchip/for-next. > > - Sync configuration changes with savedefconfig. > > - Remove GigaDevice SPI flash chip support (suggested by Kever Y). > > - Re-enable CONFIG_SPL_FIT_SIGNATURE=y (fixed in rockchip/for-next, solves > > multiple problems mentioned in v1. Thanks Jonas!). > > - Remove spl-boot-order from rk3399-rock-pi-4a-u-boot.dtsi (suggested by > > Jonas K). > > - Enable CONFIG_SPI_FLASH_SFDP_SUPPORT=y (suggested by Jonas K). > > > > arch/arm/dts/rk3399-rock-pi-4a-u-boot.dtsi | 7 +++ > > configs/rock-pi-4-rk3399_defconfig | 17 ++--- > > 2 files changed, 21 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm/dts/rk3399-rock-pi-4a-u-boot.dtsi > > b/arch/arm/dts/rk3399-rock-pi-4a-u-boot.dtsi > > index 85ee5770add..38385621deb 100644 > > --- a/arch/arm/dts/rk3399-rock-pi-4a-u-boot.dtsi > > +++ b/arch/arm/dts/rk3399-rock-pi-4a-u-boot.dtsi > > @@ -4,3 +4,10 @@ > > */ > > > > #include "rk3399-rock-pi-4-u-boot.dtsi" > > + > > +&spi1 { > > + flash@0 { > > + bootph-pre-ram; > > + bootph-some-ram; > > + }; > > +}; > > diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4- > > rk3399_defconfig > > index bca44beca12..315b8b853fc 100644 > > --- a/configs/rock-pi-4-rk3399_defconfig > > +++ b/configs/rock-pi-4-rk3399_defconfig > > @@ -3,25 +3,30 @@ CONFIG_SKIP_LOWLEVEL_INIT=y > > CONFIG_COUNTER_FREQUENCY=2400 > > CONFIG_ARCH_ROCKCHIP=y > > CONFIG_NR_DRAM_BANKS=1 > > +CONFIG_SF_DEFAULT_SPEED=1000 > > CONFIG_ENV_OFFSET=0x3F8000 > > CONFIG_DEFAULT_DEVICE_TREE="rk3399-rock-pi-4a" > > CONFIG_OF_LIBFDT_OVERLAY=y > > CONFIG_DM_RESET=y > > CONFIG_ROCKCHIP_RK3399=y > > +CONFIG_ROCKCHIP_SPI_IMAGE=y > > CONFIG_TARGET_ROCKPI4_RK3399=y > > CONFIG_DEBUG_UART_BASE=0xFF1A > > CONFIG_DEBUG_UART_CLOCK=2400 > > +CONFIG_SPL_SPI_FLASH_SUPPORT=y > > +CONFIG_SPL_SPI=y > > CONFIG_SYS_LOAD_ADDR=0x800800 > > CONFIG_PCI=y > > CONFIG_DEBUG_UART=y > > # CONFIG_ANDROID_BOOT_IMAGE is not set > > CONFIG_SPL_FIT_SIGNATURE=y > > -CONFIG_LEGACY_IMAGE_FORMAT=y > > This may stop scripts from working. > > I am getting very close to send out a big rk3399 DT sync and update > series [1] on top of your series. That series will move to imply > LEGACY_IMAGE_FORMAT in Kconfig file, so this does not matter that much. > > Please let me know if you will revert this line or if I should send out > my series on top of this patch as-is :-) Thanks for the review! I will spin v3 of this series next week. > > [1] https://github.com/Kwiboo/u-boot-rockchip/commits/rk3399-2024.07-wip > > Regards, > Jonas > > > CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock-pi-4a.dtb" > > CONFIG_DISPLAY_BOARDINFO_LATE=y > > -CONFIG_SPL_MAX_SIZE=0x2e000 > > +CONFIG_SPL_MAX_SIZE=0x4 > > CONFIG_SPL_PAD_TO=0x7f8000 > > # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set > > +CONFIG_SPL_SPI_LOAD=y > > +CONFIG_SYS_SPI_U_BOOT_OFFS=0xE > > CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y > > CONFIG_TPL=y > > CONFIG_CMD_BOOTZ=y > > @@ -40,14 +45,20 @@ CONFIG_SPL_OF_CONTROL=y > > CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names > > interrupt-parent assigned-clocks assigned-clock-rates assigned-clock- > > parents"
Re: [PATCH v3 04/11] imx8mp: power-domain: Don't power off pd_bus
On 3/22/24 5:55 AM, Sumit Garg wrote: Hi, I think if people are concerned about power consumption then it should be implemented properly in U-Boot to remove all the DT based devices before passing on control to the next stage. I would expect imx8mp_hsiomix_off() to be called either on 'usb stop' or just before Linux boots (esp. at that point), so if you do not power off the bus domain before booting Linux, you may hand over a device which was not fully power cycled. Unfortunately that's the current situation I see. IMO, the better solution would be to just remove all the DT devices before passing on control to Linux. That should automatically power off devices. Doesn't CONFIG_DM_DEVICE_REMOVE=y do something like that already ? I just did simple experiment via following diff: diff --git a/drivers/power/domain/imx8mp-hsiomix.c b/drivers/power/domain/imx8mp-hsiomix.c index 6188a04c45e..0ddcd39923a 100644 --- a/drivers/power/domain/imx8mp-hsiomix.c +++ b/drivers/power/domain/imx8mp-hsiomix.c @@ -101,6 +101,7 @@ static int imx8mp_hsiomix_set(struct power_domain *power_domain, bool power_on) if (gpr_reg0_bits) setbits_le32(priv->base + GPR_REG0, gpr_reg0_bits); } else { + while(1); if (gpr_reg0_bits) clrbits_le32(priv->base + GPR_REG0, gpr_reg0_bits); The boot doesn't hang suggesting that CONFIG_DM_DEVICE_REMOVE=y isn't effective to remove any DT devices. It can for sure be another followup series to make it effective. That's odd. Please try and edit drivers/core/device-remove.c , look up device_remove() at the end , and see if the remove is being called on the hsiomix device . You might need to add some sort of printf() there, but that's where the removal happens. The removal before boot is I think called from drivers/core/root.c dm_remove_devices_flags(), which itself is called from arch/arm/lib/bootm.c announce_and_cleanup() .
Re: [PATCH] arm64: zynqmp: Also support JTAG as alternative boot mode
On 3/22/24 07:53, Michal Simek wrote: > > > On 3/21/24 17:20, Sean Anderson wrote: >> On 3/20/24 07:18, Michal Simek wrote: >>> if (reg >> BOOT_MODE_ALT_SHIFT) condition rules out alternative jtag boot >>> mode which is 0. When 0 was used origin(HW) boot mode was used instead. >>> That's why directly fill reg variable with requested boot mode and don't >>> let code to read value back. "else" part of code remain unchanged. >>> >>> Signed-off-by: Michal Simek >>> --- >>> >>> arch/arm/mach-zynqmp/spl.c | 5 +++-- >>> 1 file changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c >>> index 5af735aa5cef..979ff3aef6c2 100644 >>> --- a/arch/arm/mach-zynqmp/spl.c >>> +++ b/arch/arm/mach-zynqmp/spl.c >>> @@ -91,13 +91,14 @@ u32 spl_boot_device(void) >>> #if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED) >>> /* Change default boot mode at run-time */ >>> + reg = CONFIG_SPL_ZYNQMP_ALT_BOOTMODE; >>> writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, >>> &crlapb_base->boot_mode); >>> -#endif >>> - >>> +#else >>> reg = readl(&crlapb_base->boot_mode); >>> if (reg >> BOOT_MODE_ALT_SHIFT) >>> reg >>= BOOT_MODE_ALT_SHIFT; >>> +#endif >>> bootmode = reg & BOOT_MODES_MASK; >>> >> >> Looks fine; can we change this to >> >> if (IS_ENABLED(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)) { >> ... >> } else { >> ... >> } > > Issue is that CONFIG_SPL_ZYNQMP_ALT_BOOTMODE symbol is not defined and > depends on CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED. It means you get > compilation error. > That symbol can be setup and then what you have above can work. > Is it worth? TBH I don't have preference. Please take a look at patch below. > (And if v1 is fine then at least there should be added depends on > SPL_ZYNQMP_ALT_BOOTMODE_ENABLED to SPL_ZYNQMP_ALT_BOOTMODE which is missing > there now). > > Thanks, > Michal > > diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig > index eee34380f0a0..75d3ec916a66 100644 > --- a/arch/arm/mach-zynqmp/Kconfig > +++ b/arch/arm/mach-zynqmp/Kconfig > @@ -145,7 +145,7 @@ config ZYNQ_SDHCI_MAX_FREQ > > config SPL_ZYNQMP_ALT_BOOTMODE > hex > - default 0x0 if JTAG_MODE > + default 0x0 > default 0x1 if QSPI_MODE_24BIT > default 0x2 if QSPI_MODE_32BIT > default 0x3 if SD_MODE > diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c > index 979ff3aef6c2..bbbf684ae496 100644 > --- a/arch/arm/mach-zynqmp/spl.c > +++ b/arch/arm/mach-zynqmp/spl.c > @@ -89,16 +89,16 @@ u32 spl_boot_device(void) > u32 reg = 0; > u8 bootmode; > > -#if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED) > - /* Change default boot mode at run-time */ > - reg = CONFIG_SPL_ZYNQMP_ALT_BOOTMODE; > - writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, > - &crlapb_base->boot_mode); > -#else > - reg = readl(&crlapb_base->boot_mode); > - if (reg >> BOOT_MODE_ALT_SHIFT) > - reg >>= BOOT_MODE_ALT_SHIFT; > -#endif > + if (IS_ENABLED(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)) { > + /* Change default boot mode at run-time */ > + reg = CONFIG_SPL_ZYNQMP_ALT_BOOTMODE; > + writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, > + &crlapb_base->boot_mode); > + } else { > + reg = readl(&crlapb_base->boot_mode); > + if (reg >> BOOT_MODE_ALT_SHIFT) > + reg >>= BOOT_MODE_ALT_SHIFT; > + } > > bootmode = reg & BOOT_MODES_MASK; > > > Reviewed-by: Sean Anderson
Re: [PATCH v3 07/11] phy: phy-imx8m-pcie: Add support for i.MX8M{M/P} PCIe PHY
On 3/22/24 5:36 AM, Sumit Garg wrote: On Fri, 22 Mar 2024 at 00:47, Marek Vasut wrote: On 3/21/24 1:40 PM, Sumit Garg wrote: On Thu, 14 Mar 2024 at 09:46, Marek Vasut wrote: On 3/12/24 8:03 AM, Sumit Garg wrote: Add initial support for i.MX8M{M/P} PCIe PHY. On i.MX8M{M/P} SoCs PCIe PHY initialization moved to this standalone PHY driver. Inspired from counterpart Linux kernel v6.8-rc3 driver: drivers/phy/freescale/phy-fsl-imx8m-pcie.c. Use last Linux kernel driver reference commit 7559e7572c03 ("phy: Explicitly include correct DT includes"). [...] +static int imx8_pcie_phy_probe(struct udevice *dev) +{ + struct imx8_pcie_phy *imx8_phy = dev_get_priv(dev); + ofnode gpr; + int ret = 0; + + imx8_phy->drvdata = (void *)dev_get_driver_data(dev); + imx8_phy->base = dev_read_addr(dev); + if (!imx8_phy->base) + return -EINVAL; + + /* get PHY refclk pad mode */ + dev_read_u32(dev, "fsl,refclk-pad-mode", &imx8_phy->refclk_pad_mode); + + imx8_phy->tx_deemph_gen1 = dev_read_u32_default(dev, + "fsl,tx-deemph-gen1", + 0); + imx8_phy->tx_deemph_gen2 = dev_read_u32_default(dev, + "fsl,tx-deemph-gen2", + 0); + imx8_phy->clkreq_unused = dev_read_bool(dev, "fsl,clkreq-unsupported"); + + /* Grab GPR config register range */ + gpr = ofnode_by_compatible(ofnode_null(), imx8_phy->drvdata->gpr); + if (ofnode_equal(gpr, ofnode_null())) { + dev_err(dev, "unable to find GPR node\n"); + return -ENODEV; + } + + imx8_phy->iomuxc_gpr = syscon_node_to_regmap(gpr); + if (IS_ERR(imx8_phy->iomuxc_gpr)) { + dev_err(dev, "unable to find iomuxc registers\n"); + return PTR_ERR(imx8_phy->iomuxc_gpr); + } syscon_regmap_lookup_by_compatible() should simplify these two steps ^ . After a close look, that API isn't supported by U-Boot yet. So I will keep the existing implementation with your review tag. I hope that's fine with you. Oh, uh, I had a local patch from previous round of PCIe experiments, I just sent it out, you are on CC. Can you do a follow up fix once this series V4 is in ? Sure I can do that as a followup once your patch is merged. Follow up, yes please. Let's not stuff this series with more stuff anymore, so it can go in.
Re: [PATCH v4 00/11] imx8mp: Enable PCIe/NVMe support
Hi Sumit, On Thu, Mar 21, 2024 at 11:55 AM Sumit Garg wrote: > Changes in v4: > - Incorporated misc comments from Marek and added his review tag. > - Dropped patch #4 (imx8mp: power-domain: Don't power off pd_bus) > since power domain off path is never excercised for DT based devices. > - Added patch#8 as suggested by Peter to describe older pcie_imx.c > driver as legacy one. v4 looks good, thanks. I'll wait a few days and will queue it to next.
Re: [PATCH 00/12] arm: xea: Provide support for different XEA board HW versions
Hi Lukasz, On Fri, Mar 22, 2024 at 8:43 AM Lukasz Majewski wrote: > arch/arm/dts/Makefile | 3 +- > arch/arm/dts/imx28-xea-1-u-boot.dtsi | 11 > arch/arm/dts/imx28-xea-1.dts | 8 +++ > arch/arm/dts/imx28-xea-2-u-boot.dtsi | 11 > arch/arm/dts/imx28-xea-2.dts | 8 +++ > arch/arm/dts/imx28-xea-u-boot.dtsi| 1 - > .../arm/dts/{imx28-xea.dts => imx28-xea.dtsi} | 0 This rename deviates from the upstream devicetree name. Ideally, we should convert to OF_UPSTREAM available in U-Boot next. > board/liebherr/xea/spl_xea.c | 21 +++--- > board/liebherr/xea/xea.c | 65 +++ > board/liebherr/xea/xea.env| 4 +- > configs/imx28_xea_defconfig | 5 +- > configs/imx28_xea_sb_defconfig| 5 +- > 12 files changed, 128 insertions(+), 14 deletions(-) > create mode 100644 arch/arm/dts/imx28-xea-1-u-boot.dtsi > create mode 100644 arch/arm/dts/imx28-xea-1.dts > create mode 100644 arch/arm/dts/imx28-xea-2-u-boot.dtsi > create mode 100644 arch/arm/dts/imx28-xea-2.dts > rename arch/arm/dts/{imx28-xea.dts => imx28-xea.dtsi} (100%) You should upstream imx28-xea-1.dts and imx28-xea-2.dts first.
[PATCH 3/4] arm: dts: k3-*-binman.dtsi: Clean up and templatize boot binaries
Clean up templatized boot binaries for all K3 boards. This includes modifying the k3-binman.dtsi to use SPL_BOARD_DTB, BOARD_DESCRIPTION and UBOOT_BOARD_DESCRIPTION from the files that include it to further reuse code. All k3--binman.dtsi will contain only templates. Only required boot binaries can be built from the templates in the boards' respective -u-boot.dtsi file (or k3--binman.dtsi if it exists). This allows clear distinction between the SoC common stuff vs. what is additionally needed to boot up a specific board. Signed-off-by: Neha Malcom Francis --- arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi | 161 +- arch/arm/dts/k3-am625-phycore-som-binman.dtsi | 291 + arch/arm/dts/k3-am625-r5-beagleplay.dts | 39 --- arch/arm/dts/k3-am625-sk-binman.dtsi | 148 + arch/arm/dts/k3-am625-sk-u-boot.dtsi | 42 +++ .../dts/k3-am625-verdin-wifi-dev-binman.dtsi | 296 +- arch/arm/dts/k3-am62a-sk-binman.dtsi | 146 + arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 42 +++ arch/arm/dts/k3-am642-evm-u-boot.dtsi | 42 +++ arch/arm/dts/k3-am642-sk-u-boot.dtsi | 42 +++ arch/arm/dts/k3-am64x-binman.dtsi | 239 +- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 49 +++ arch/arm/dts/k3-am65x-binman.dtsi | 144 + .../arm/dts/k3-am68-sk-base-board-u-boot.dtsi | 26 ++ arch/arm/dts/k3-am69-sk-u-boot.dtsi | 31 +- arch/arm/dts/k3-binman.dtsi | 96 ++ arch/arm/dts/k3-j7200-binman.dtsi | 145 + .../k3-j7200-common-proc-board-u-boot.dtsi| 40 +++ .../dts/k3-j721e-beagleboneai64-u-boot.dtsi | 154 + arch/arm/dts/k3-j721e-binman.dtsi | 262 +++- .../k3-j721e-common-proc-board-u-boot.dtsi| 84 + arch/arm/dts/k3-j721e-r5-beagleboneai64.dts | 91 +- arch/arm/dts/k3-j721e-sk-u-boot.dtsi | 84 + arch/arm/dts/k3-j721s2-binman.dtsi| 231 +- .../k3-j721s2-common-proc-board-u-boot.dtsi | 42 +++ arch/arm/dts/k3-j784s4-binman.dtsi| 154 + arch/arm/dts/k3-j784s4-evm-u-boot.dtsi| 42 +++ 27 files changed, 858 insertions(+), 2305 deletions(-) diff --git a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi index cca0f44b7d8..fc1898f1510 100644 --- a/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi +++ b/arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi @@ -6,7 +6,11 @@ * Copyright (C) 2022-2023 Robert Nelson, BeagleBoard.org Foundation */ -#include "k3-binman.dtsi" +#define SPL_BOARD_DTB "spl/dts/k3-am625-beagleplay.dtb" +#define BOARD_DESCRIPTION "k3-am625-beagleplay" +#define UBOOT_BOARD_DESCRIPTION "U-Boot for AM625 BeaglePlay" + +#include "k3-am625-sk-binman.dtsi" / { chosen { @@ -61,155 +65,24 @@ >; }; -#ifdef CONFIG_TARGET_AM625_A53_BEAGLEPLAY - -#define SPL_NODTB "spl/u-boot-spl-nodtb.bin" -#define SPL_AM625_BEAGLEPLAY_DTB "spl/dts/k3-am625-beagleplay.dtb" -#define UBOOT_NODTB "u-boot-nodtb.bin" -#define AM625_BEAGLEPLAY_DTB "arch/arm/dts/k3-am625-beagleplay.dtb" +#ifndef CONFIG_ARM64 &binman { - ti-dm { - filename = "ti-dm.bin"; - blob-ext { - filename = "ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f"; - }; + tiboot3-am62x-gp { + insert-template = <&tiboot3_am62x_gp>; }; +}; - ti-spl_unsigned { - filename = "tispl.bin_unsigned"; - pad-byte = <0xff>; - - fit { - description = "Configuration to load ATF and SPL"; - #address-cells = <1>; - - images { - - atf { - description = "ARM Trusted Firmware"; - type = "firmware"; - arch = "arm64"; - compression = "none"; - os = "arm-trusted-firmware"; - load = ; - entry = ; - atf-bl31 { - filename = "bl31.bin"; - }; - }; - - tee { - description = "OP-TEE"; - type = "tee"; - arch = "arm64"; - compression = "none"; - os = "tee"; - load = ; - entry = ; - tee-os { - filename
[PATCH 2/4] tools: binman: control.py: Delete template nodes after parsing
Dynamically going through the subnode array and deleting leads to templates being skipped from deletion when templates are consecutive in the subnode list. Prevent this from happening by first parsing the DT and then deleting the nodes. Signed-off-by: Neha Malcom Francis --- tools/binman/control.py | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index 2f00279232b..1c4e6a581f9 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -522,9 +522,13 @@ def _ProcessTemplates(parent): def _RemoveTemplates(parent): """Remove any templates in the binman description """ +del_nodes = [] for node in parent.subnodes: if node.name.startswith('template'): -node.Delete() +del_nodes.append(node) + +for node in del_nodes: +node.Delete() def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): """Prepare the images to be processed and select the device tree -- 2.34.1
[PATCH 1/4] configs: j721e_sk: Move to separate defconfig for J721E SK board
Add defconfig for J721E SK R5 and A72 configuration. This includes and modifies the J721E EVM defconfigs: j721e_evm_r5_defconfig -> j721e_sk_r5_defconfig j721e_evm_a72_defconfig -> j721e_sk_a72_defconfig Signed-off-by: Neha Malcom Francis --- board/ti/j721e/MAINTAINERS | 2 ++ configs/j721e_evm_a72_defconfig | 2 +- configs/j721e_evm_r5_defconfig | 2 +- configs/j721e_sk_a72_defconfig | 9 + configs/j721e_sk_r5_defconfig | 10 ++ 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 configs/j721e_sk_a72_defconfig create mode 100644 configs/j721e_sk_r5_defconfig diff --git a/board/ti/j721e/MAINTAINERS b/board/ti/j721e/MAINTAINERS index f5ca7d06a34..06aba53d9b0 100644 --- a/board/ti/j721e/MAINTAINERS +++ b/board/ti/j721e/MAINTAINERS @@ -5,5 +5,7 @@ F: board/ti/j721e F: include/configs/j721e_evm.h F: configs/j721e_evm_r5_defconfig F: configs/j721e_evm_a72_defconfig +F: configs/j721e_sk_r5_defconfig +F: configs/j721e_sk_a72_defconfig F: configs/j7200_evm_r5_defconfig F: configs/j7200_evm_a72_defconfig diff --git a/configs/j721e_evm_a72_defconfig b/configs/j721e_evm_a72_defconfig index 019ddcca7e8..34f7eeebbd5 100644 --- a/configs/j721e_evm_a72_defconfig +++ b/configs/j721e_evm_a72_defconfig @@ -85,7 +85,7 @@ CONFIG_MMC_SPEED_MODE_SET=y # CONFIG_SPL_EFI_PARTITION is not set CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y -CONFIG_OF_LIST="k3-j721e-common-proc-board k3-j721e-sk" +CONFIG_OF_LIST="k3-j721e-common-proc-board" CONFIG_MULTI_DTB_FIT=y CONFIG_SPL_MULTI_DTB_FIT=y CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig index 4d4b96dec6b..49da2550ead 100644 --- a/configs/j721e_evm_r5_defconfig +++ b/configs/j721e_evm_r5_defconfig @@ -81,7 +81,7 @@ CONFIG_CMD_MTDPARTS=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y CONFIG_SPL_MULTI_DTB_FIT=y -CONFIG_SPL_OF_LIST="k3-j721e-r5-common-proc-board k3-j721e-r5-sk" +CONFIG_SPL_OF_LIST="k3-j721e-r5-common-proc-board" CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y diff --git a/configs/j721e_sk_a72_defconfig b/configs/j721e_sk_a72_defconfig new file mode 100644 index 000..8907b8ae58f --- /dev/null +++ b/configs/j721e_sk_a72_defconfig @@ -0,0 +1,9 @@ +#include + +CONFIG_ARM=y +CONFIG_ARCH_K3=y +CONFIG_SOC_K3_J721E=y +CONFIG_TARGET_J721E_A72_EVM=y + +CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-sk" +CONFIG_OF_LIST="k3-j721e-sk" diff --git a/configs/j721e_sk_r5_defconfig b/configs/j721e_sk_r5_defconfig new file mode 100644 index 000..b361c691747 --- /dev/null +++ b/configs/j721e_sk_r5_defconfig @@ -0,0 +1,10 @@ +#include + +CONFIG_ARM=y +CONFIG_ARCH_K3=y +CONFIG_SOC_K3_J721E=y +CONFIG_TARGET_J721E_R5_EVM=y + +CONFIG_DEFAULT_DEVICE_TREE="k3-j721e-r5-sk" +CONFIG_SPL_OF_LIST="k3-j721e-r5-sk" +CONFIG_OF_LIST="k3-j721e-r5-sk" -- 2.34.1
[PATCH 0/4] Cleanup K3 binman templating
This series does primarily three things: 1. Split out the common J721E defconfig for both EVM and SK 2. Cleanup k3-j721e-binman.dtsi to be SoC specific binman nodes and -u-boot.dtsi files of the respective boards can pick and edit according to their board. This is based on the discussion [1] and this is the primary goal of this series 3. Move J721E EVM and SK to using OF_UPSTREAM This series depends on series [2] and patch [3] which implement OF_UPSTREAM. Also received input from Nishanth to clean up the unnecessary artifacts in the final build directory (maybe populate them in another directory), working on that as well but didn't want to delay v1 further considering I'm modifying a bunch of board builds and would like some friendly build tests and boot tests for them. [1] https://lore.kernel.org/u-boot/20240123205255.i7eynu6vdpoxwybf@irregular/ [2] https://lore.kernel.org/u-boot/20240222093607.3085545-1-sumit.g...@linaro.org/ [3] https://lore.kernel.org/u-boot/20240205-am62px-wip-rebasing-v3-11-04cbb42ea...@ti.com/ Changes since RFC: https://lore.kernel.org/all/20240228112042.3437691-1-n-fran...@ti.com/ - cleaned out FDT descriptions and blobs using macros (Manorit) - modified J721E defconfigs to include missed out configs (Andrew) Boot logs: https://gist.github.com/nehamalcom/07dc7f95173f0bb67a8a26a6b3ab2b00 Neha Malcom Francis (4): configs: j721e_sk: Move to separate defconfig for J721E SK board tools: binman: control.py: Delete template nodes after parsing arm: dts: k3-*-binman.dtsi: Clean up and templatize boot binaries arm: dts: k3-j721e: Move to OF_UPSTREAM arch/arm/dts/Makefile |4 +- arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi | 161 +- arch/arm/dts/k3-am625-phycore-som-binman.dtsi | 291 +- arch/arm/dts/k3-am625-r5-beagleplay.dts | 39 - arch/arm/dts/k3-am625-sk-binman.dtsi | 148 +- arch/arm/dts/k3-am625-sk-u-boot.dtsi | 42 + .../dts/k3-am625-verdin-wifi-dev-binman.dtsi | 296 +- arch/arm/dts/k3-am62a-sk-binman.dtsi | 146 +- arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 42 + arch/arm/dts/k3-am642-evm-u-boot.dtsi | 42 + arch/arm/dts/k3-am642-sk-u-boot.dtsi | 42 + arch/arm/dts/k3-am64x-binman.dtsi | 239 +- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 49 + arch/arm/dts/k3-am65x-binman.dtsi | 144 +- .../arm/dts/k3-am68-sk-base-board-u-boot.dtsi | 26 + arch/arm/dts/k3-am69-sk-u-boot.dtsi | 31 +- arch/arm/dts/k3-binman.dtsi | 96 + arch/arm/dts/k3-j7200-binman.dtsi | 145 +- .../k3-j7200-common-proc-board-u-boot.dtsi| 40 + .../dts/k3-j721e-beagleboneai64-u-boot.dtsi | 154 +- arch/arm/dts/k3-j721e-binman.dtsi | 262 +- .../k3-j721e-common-proc-board-u-boot.dtsi| 84 + arch/arm/dts/k3-j721e-common-proc-board.dts | 976 -- arch/arm/dts/k3-j721e-main.dtsi | 2741 - arch/arm/dts/k3-j721e-mcu-wakeup.dtsi | 681 arch/arm/dts/k3-j721e-r5-beagleboneai64.dts | 91 +- arch/arm/dts/k3-j721e-sk-u-boot.dtsi | 84 + arch/arm/dts/k3-j721e-sk.dts | 1074 --- arch/arm/dts/k3-j721e-som-p0.dtsi | 446 --- arch/arm/dts/k3-j721e-thermal.dtsi| 75 - arch/arm/dts/k3-j721e.dtsi| 176 -- arch/arm/dts/k3-j721s2-binman.dtsi| 231 +- .../k3-j721s2-common-proc-board-u-boot.dtsi | 42 + arch/arm/dts/k3-j784s4-binman.dtsi| 154 +- arch/arm/dts/k3-j784s4-evm-u-boot.dtsi| 42 + board/ti/j721e/MAINTAINERS|2 + configs/j721e_evm_a72_defconfig |5 +- configs/j721e_evm_r5_defconfig|2 +- configs/j721e_sk_a72_defconfig|9 + configs/j721e_sk_r5_defconfig | 10 + tools/binman/control.py |6 +- 41 files changed, 889 insertions(+), 8481 deletions(-) delete mode 100644 arch/arm/dts/k3-j721e-common-proc-board.dts delete mode 100644 arch/arm/dts/k3-j721e-main.dtsi delete mode 100644 arch/arm/dts/k3-j721e-mcu-wakeup.dtsi delete mode 100644 arch/arm/dts/k3-j721e-sk.dts delete mode 100644 arch/arm/dts/k3-j721e-som-p0.dtsi delete mode 100644 arch/arm/dts/k3-j721e-thermal.dtsi delete mode 100644 arch/arm/dts/k3-j721e.dtsi create mode 100644 configs/j721e_sk_a72_defconfig create mode 100644 configs/j721e_sk_r5_defconfig -- 2.34.1
[PATCH] board: phytec: phycore_imx8mp.env fix netboot issues
The "run netargs" command should come later in the "netboot" command order when using dhcp since it sets the server and client ip addresses. The previous order led to misconfigured kernel boot params and thus kernel panic when serverip was not manually set. Further, following Linux FHS 3.0, change the nfsroot default directory to /srv/nfs. Fixes: 60f64bec414e ("board: phytec: phycore_imx8mp: Add fec support") Signed-off-by: Yannic Moog --- Depends on [1] which is on next already. [1] https://lore.kernel.org/u-boot/20240312085957.902398-1-l.anderw...@phytec.de/ --- board/phytec/phycore_imx8mp/phycore_imx8mp.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/phytec/phycore_imx8mp/phycore_imx8mp.env b/board/phytec/phycore_imx8mp/phycore_imx8mp.env index fae3e992654..7f6c5fd2c76 100644 --- a/board/phytec/phycore_imx8mp/phycore_imx8mp.env +++ b/board/phytec/phycore_imx8mp/phycore_imx8mp.env @@ -46,17 +46,17 @@ netargs= nfsroot=${serverip}:${nfsroot},v3,tcp netboot= echo Booting from net ...; - run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${loadaddr} ${image}; + run netargs; if ${get_cmd} ${fdt_addr} ${fdt_file}; then booti ${loadaddr} - ${fdt_addr}; else echo WARN: Cannot load the DT; fi; -nfsroot=/nfs +nfsroot=/srv/nfs sd_dev=1 --- base-commit: 86b79cf131b64eadae023a127921893d30503093 change-id: 20240322-phycore_mx8mp_netboot_fixes-337ceb4ba0cc Best regards, -- Yannic Moog
Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'
HI On Fri, Mar 22, 2024 at 1:02 PM Alexander Dahl wrote: > > Hello Michael, > > Am Fri, Mar 22, 2024 at 12:54:27PM +0100 schrieb Michael Nazzareno Trimarchi: > > HI > > > > On Fri, Mar 22, 2024 at 12:46 PM Alexander Dahl wrote: > > > > > > Hello Mihai, > > > > > > Am Fri, Mar 22, 2024 at 10:02:29AM + schrieb mihai.s...@microchip.com: > > > > Hi Michael, > > > > > > > > --- > > > > > > > > I think this command can be really useful. > > > > Let try to have more testing on more boards > > > > > > > > - > > > > > > > > I managed to test the command on sama7g54-curiosity board. > > > > > > Thanks for that. Nice to see it works on other variants of the SoC > > > family. > > > > > > > I also forced timing mode 5 from controller driver > > > > (conf->timings.sdr.tRC_min < 2). > > > > > > You did a similar thing for the sam9x75. These boards/socs seem to > > > have a newer SMC / HSMC controller than sama5d2 or sam9x60? The > > > driver claims all the (H)SMC incarnations do _not_ support these EDO > > > modes 4 and 5. Maybe someone could have a deeper look at the > > > datasheets of the newer SoCs and propose a patch to support those > > > newer controllers in the atmel nand-controller driver? I guess the > > > problem is the same in Linux, right? > > > > > > Greets > > > Alex > > > > > > > > > > > => nand onfi 0 > > > > => hsmc decode > > > > > > > > MCK rate: 200 MHz > > > > > > > > HSMC_SETUP3:0x0004 > > > > HSMC_PULSE3:0x140a140a > > > > HSMC_CYCLE3:0x00140014 > > > > HSMC_TIMINGS3: 0x880805f4 > > > > HSMC_MODE3: 0x001f0003 > > > > NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 > > > > (100 ns) > > > >NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 > > > > (100 ns) > > > > NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 > > > > (100 ns) > > > >NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 > > > > (100 ns) > > > > TDF optimization enabled > > > > TDF cycles: 15 (75 ns) > > > > Data Bus Width: 8-bit bus > > > > NWAIT Mode: 0 > > > > Write operation controlled by NWE signal > > > > Read operation controlled by NRD signal > > > > NFSEL (NAND Flash Selection) is set > > > > OCMS (Off Chip Memory Scrambling) is disabled > > > > TWB (WEN High to REN to Busy): 64 (320 ns) > > > > TRR (Ready to REN Low Delay): 64 (320 ns) > > > > TAR (ALE to REN Low Delay):5 (25 ns) > > > > TADL (ALE to Data Start): 71 (355 ns) > > > > TCLR (CLE to REN Low Delay): 4 (20 ns) > > > > > > > > => time nand torture 0x100 0x100 > > > > > > > > NAND torture: device 0 offset 0x100 size 0x100 (block size > > > > 0x4) > > > > Passed: 64, failed: 0 > > > > > > > > time: 22.638 seconds > > > > > > > > => nand onfi 5 > > > > => hsmc decode > > > > > > > > MCK rate: 200 MHz > > > > > > > > HSMC_SETUP3:0x0001 > > > > HSMC_PULSE3:0x07040502 > > > > HSMC_CYCLE3:0x00070005 > > > > HSMC_TIMINGS3: 0x880402f2 > > > > HSMC_MODE3: 0x001f0003 > > > > NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 > > > > ns) > > > >NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 > > > > (35 ns) > > > > NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 > > > > ns) > > > >NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 > > > > (25 ns) > > > > TDF optimization enabled > > > > TDF cycles: 15 (75 ns) > > > > Data Bus Width: 8-bit bus > > > > NWAIT Mode: 0 > > > > Write operation controlled by NWE signal > > > > Read operation controlled by NRD signal > > > > NFSEL (NAND Flash Selection) is set > > > > OCMS (Off Chip Memory Scrambling) is disabled > > > > TWB (WEN High to REN to Busy): 64 (320 ns) > > > > TRR (Ready to REN Low Delay): 4 (20 ns) > > > > TAR (ALE to REN Low Delay):2 (10 ns) > > > > TADL (ALE to Data Start): 71 (355 ns) > > > > TCLR (CLE to REN Low Delay): 2 (10 ns) > > > > > > > > => time nand torture 0x100 0x100 > > > > > > > > NAND torture: device 0 offset 0x100 size 0x100 (block size > > > > 0x4) > > > > Passed: 64, failed: 0 > > > > > > > > time: 11.661 seconds > > > > > > > > => nand info > > > > > > > > Device 0: nand0, sector size 256 KiB > > > > Manufacturer MACRONIX > > > > Model MX30LF4G28AD > > > > Device size512 MiB > > > > Page size 4096 b > > > > OOB size 256 b > > > > Erase size 262144 b > > > > ecc strength 8 bits > > > > ecc step size 512 b > > > > subpagesize 4096 b > > > > options 0x40004200 > > > > bbt options 0x00028000 > > > > > > > > Best regards, > > > > Mihai Sain > > > > I'm in favor to have it even cover by one soc family. I would like to > > confirm on imx6 and imx8. If you are not in a rush. > > Let's us test too > > Agreed. Th
Re: [PATCH v2 24/24] dts: support building all dtb files for a specific vendor
On 3/21/24 22:04, Caleb Connolly wrote: This adjusts OF_UPSTREAM to behave more like the kernel by allowing for all the devicetree files for a given vendor to be compiled. This is useful for Qualcomm in particular as most boards are supported by a single U-Boot build just provided with a different DT. Signed-off-by: Caleb Connolly --- dts/Kconfig | 24 scripts/Makefile.dts | 13 + 2 files changed, 37 insertions(+) diff --git a/dts/Kconfig b/dts/Kconfig index b9b6367154ef..6883a000a052 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -100,8 +100,32 @@ config OF_UPSTREAM However, newer boards whose devicetree source files haven't landed in the dts/upstream subtree, they can override this option to have the DT build from existing U-Boot tree location instead. +config OF_UPSTREAM_BUILD_VENDOR + bool "Build all devicetree files for a particular vendor" + depends on OF_UPSTREAM + help + Enable building all devicetree files for a particular vendor. This + is useful for generic U-Boot configurations where many boards can + be supported with a single binary. + + This is only available for platforms using upstream devicetree. + +config OF_UPSTREAM_VENDOR + string "Vendor to build all upstream devicetree files for" + depends on OF_UPSTREAM_BUILD_VENDOR + default "qcom" if ARCH_SNAPDRAGON + default "rockchip" if ARCH_ROCKCHIP + default "amlogic" if ARCH_MESON + default "allwinner" if ARCH_SUNXI + default "mediatek" if ARCH_MEDIATEK + default "marvell" if ARCH_MVEBU || ARCH_KIRKWOOD + default "xilinx" if ARCH_VERSAL || ARCH_ZYNQ This is not enough it should be ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || ARCH_VERSAL_NET Thanks, Michal
Re: [PATCH v2 16/24] xlnx: drop dt-binding headers
On 3/21/24 22:03, Caleb Connolly wrote: Drop in favour of dts/upstream Signed-off-by: Caleb Connolly --- include/dt-bindings/clock/xlnx-versal-clk.h| 123 --- include/dt-bindings/clock/xlnx-zynqmp-clk.h| 126 include/dt-bindings/dma/xlnx-zynqmp-dpdma.h| 16 --- include/dt-bindings/pinctrl/pinctrl-zynqmp.h | 19 include/dt-bindings/power/xlnx-zynqmp-power.h | 50 -- include/dt-bindings/reset/xlnx-versal-resets.h | 105 include/dt-bindings/reset/xlnx-zynqmp-resets.h | 130 - 7 files changed, 569 deletions(-) diff --git a/include/dt-bindings/clock/xlnx-versal-clk.h b/include/dt-bindings/clock/xlnx-versal-clk.h deleted file mode 100644 index 264d634d226e.. --- a/include/dt-bindings/clock/xlnx-versal-clk.h +++ /dev/null @@ -1,123 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (C) 2019 Xilinx Inc. - * - */ - -#ifndef _DT_BINDINGS_CLK_VERSAL_H -#define _DT_BINDINGS_CLK_VERSAL_H - -#define PMC_PLL1 -#define APU_PLL2 -#define RPU_PLL3 -#define CPM_PLL4 -#define NOC_PLL5 -#define PLL_MAX6 -#define PMC_PRESRC 7 -#define PMC_POSTCLK8 -#define PMC_PLL_OUT9 -#define PPLL 10 -#define NOC_PRESRC 11 -#define NOC_POSTCLK12 -#define NOC_PLL_OUT13 -#define NPLL 14 -#define APU_PRESRC 15 -#define APU_POSTCLK16 -#define APU_PLL_OUT17 -#define APLL 18 -#define RPU_PRESRC 19 -#define RPU_POSTCLK20 -#define RPU_PLL_OUT21 -#define RPLL 22 -#define CPM_PRESRC 23 -#define CPM_POSTCLK24 -#define CPM_PLL_OUT25 -#define CPLL 26 -#define PPLL_TO_XPD27 -#define NPLL_TO_XPD28 -#define APLL_TO_XPD29 -#define RPLL_TO_XPD30 -#define EFUSE_REF 31 -#define SYSMON_REF 32 -#define IRO_SUSPEND_REF33 -#define USB_SUSPEND34 -#define SWITCH_TIMEOUT 35 -#define RCLK_PMC 36 -#define RCLK_LPD 37 -#define WDT38 -#define TTC0 39 -#define TTC1 40 -#define TTC2 41 -#define TTC3 42 -#define GEM_TSU43 -#define GEM_TSU_LB 44 -#define MUXED_IRO_DIV2 45 -#define MUXED_IRO_DIV4 46 -#define PSM_REF47 -#define GEM0_RX48 -#define GEM0_TX49 -#define GEM1_RX50 -#define GEM1_TX51 -#define CPM_CORE_REF 52 -#define CPM_LSBUS_REF 53 -#define CPM_DBG_REF54 -#define CPM_AUX0_REF 55 -#define CPM_AUX1_REF 56 -#define QSPI_REF 57 -#define OSPI_REF 58 -#define SDIO0_REF 59 -#define SDIO1_REF 60 -#define PMC_LSBUS_REF 61 -#define I2C_REF62 -#define TEST_PATTERN_REF 63 -#define DFT_OSC_REF64 -#define PMC_PL0_REF65 -#define PMC_PL1_REF66 -#define PMC_PL2_REF67 -#define PMC_PL3_REF68 -#define CFU_REF69 -#define SPARE_REF 70 -#define NPI_REF71 -#define HSM0_REF 72 -#define HSM1_REF 73 -#define SD_DLL_REF 74 -#define FPD_TOP_SWITCH 7
[PATCH v2 2/2] arm64: zynqmp: Add MTD partition handling for dfu_alt_info generation
Generate dfu_alt_info generation based on information from MTD partitions. mtd_found_part() is trying to identify MTD partition which code is running from. If partitions are not defined and location is not found it is going to previous behavior. Signed-off-by: Michal Simek --- Changes in v2: - Update logic based on 1/2 patch board/xilinx/zynqmp/zynqmp.c | 55 ++-- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 3844a9c9a8ff..2522024b4082 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -626,6 +626,31 @@ enum env_location env_get_location(enum env_operation op, int prio) #define DFU_ALT_BUF_LENSZ_1K +static void mtd_found_part(u32 *base, u32 *size) +{ + struct mtd_info *part, *mtd; + + mtd_probe_devices(); + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + list_for_each_entry(part, &mtd->partitions, node) { + debug("0x%012llx-0x%012llx : \"%s\"\n", + part->offset, part->offset + part->size, + part->name); + + if (*base >= part->offset && + *base < part->offset + part->size) { + debug("Found my partition: %d/%s\n", + part->index, part->name); + *base = part->offset; + *size = part->size; + break; + } + } + } +} + void set_dfu_alt_info(char *interface, char *devstr) { int multiboot, bootseq = 0, len = 0; @@ -670,17 +695,29 @@ void set_dfu_alt_info(char *interface, char *devstr) break; case QSPI_MODE_24BIT: case QSPI_MODE_32BIT: - len += snprintf(buf + len, DFU_ALT_BUF_LEN, - "sf 0:0=boot.bin raw %x 0x150", - multiboot * SZ_32K); -#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) - if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + { + u32 base = multiboot * SZ_32K; + u32 size = 0x150; + u32 limit = size; + + mtd_found_part(&base, &limit); + +#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) + size = limit; + limit = CONFIG_SYS_SPI_U_BOOT_OFFS; +#endif + len += snprintf(buf + len, DFU_ALT_BUF_LEN, - ";%s raw 0x%x 0x50", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, - multiboot * SZ_32K + - CONFIG_SYS_SPI_U_BOOT_OFFS); + "sf 0:0=boot.bin raw 0x%x 0x%x", + base, limit); +#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) + if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s raw 0x%x 0x%x", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + base + limit, size - limit); #endif + } break; default: return; -- 2.44.0
[PATCH v2 1/2] arm64: zynqmp: Generate desc when SPL_FS_LOAD_PAYLOAD_NAME is valid
Generate description only when CONFIG_SPL_FS_LOAD_PAYLOAD_NAME is not empty. When name is empty there is no reason to generate description for it because it is not aligned with dfu rules. Signed-off-by: Michal Simek --- Changes in v2: - New patch is series coming from discussion at https://lore.kernel.org/all/561f9d0ee96ebb6cd674042f269f280ab68fbbac.1708705118.git.michal.si...@amd.com/ board/xilinx/zynqmp/zynqmp.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index ba49eb7be229..3844a9c9a8ff 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -661,8 +661,11 @@ void set_dfu_alt_info(char *interface, char *devstr) len += snprintf(buf + len, DFU_ALT_BUF_LEN, ".bin fat %d 1", bootseq); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) - len += snprintf(buf + len, DFU_ALT_BUF_LEN, ";%s fat %d 1", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); + if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s fat %d 1", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + bootseq); #endif break; case QSPI_MODE_24BIT: @@ -671,10 +674,12 @@ void set_dfu_alt_info(char *interface, char *devstr) "sf 0:0=boot.bin raw %x 0x150", multiboot * SZ_32K); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) - len += snprintf(buf + len, DFU_ALT_BUF_LEN, - ";%s raw 0x%x 0x50", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, - multiboot * SZ_32K + CONFIG_SYS_SPI_U_BOOT_OFFS); + if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s raw 0x%x 0x50", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + multiboot * SZ_32K + + CONFIG_SYS_SPI_U_BOOT_OFFS); #endif break; default: -- 2.44.0
Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'
Hello Michael, Am Fri, Mar 22, 2024 at 12:54:27PM +0100 schrieb Michael Nazzareno Trimarchi: > HI > > On Fri, Mar 22, 2024 at 12:46 PM Alexander Dahl wrote: > > > > Hello Mihai, > > > > Am Fri, Mar 22, 2024 at 10:02:29AM + schrieb mihai.s...@microchip.com: > > > Hi Michael, > > > > > > --- > > > > > > I think this command can be really useful. > > > Let try to have more testing on more boards > > > > > > - > > > > > > I managed to test the command on sama7g54-curiosity board. > > > > Thanks for that. Nice to see it works on other variants of the SoC > > family. > > > > > I also forced timing mode 5 from controller driver > > > (conf->timings.sdr.tRC_min < 2). > > > > You did a similar thing for the sam9x75. These boards/socs seem to > > have a newer SMC / HSMC controller than sama5d2 or sam9x60? The > > driver claims all the (H)SMC incarnations do _not_ support these EDO > > modes 4 and 5. Maybe someone could have a deeper look at the > > datasheets of the newer SoCs and propose a patch to support those > > newer controllers in the atmel nand-controller driver? I guess the > > problem is the same in Linux, right? > > > > Greets > > Alex > > > > > > > > => nand onfi 0 > > > => hsmc decode > > > > > > MCK rate: 200 MHz > > > > > > HSMC_SETUP3:0x0004 > > > HSMC_PULSE3:0x140a140a > > > HSMC_CYCLE3:0x00140014 > > > HSMC_TIMINGS3: 0x880805f4 > > > HSMC_MODE3: 0x001f0003 > > > NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 > > > (100 ns) > > >NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 > > > (100 ns) > > > NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 > > > (100 ns) > > >NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 > > > (100 ns) > > > TDF optimization enabled > > > TDF cycles: 15 (75 ns) > > > Data Bus Width: 8-bit bus > > > NWAIT Mode: 0 > > > Write operation controlled by NWE signal > > > Read operation controlled by NRD signal > > > NFSEL (NAND Flash Selection) is set > > > OCMS (Off Chip Memory Scrambling) is disabled > > > TWB (WEN High to REN to Busy): 64 (320 ns) > > > TRR (Ready to REN Low Delay): 64 (320 ns) > > > TAR (ALE to REN Low Delay):5 (25 ns) > > > TADL (ALE to Data Start): 71 (355 ns) > > > TCLR (CLE to REN Low Delay): 4 (20 ns) > > > > > > => time nand torture 0x100 0x100 > > > > > > NAND torture: device 0 offset 0x100 size 0x100 (block size > > > 0x4) > > > Passed: 64, failed: 0 > > > > > > time: 22.638 seconds > > > > > > => nand onfi 5 > > > => hsmc decode > > > > > > MCK rate: 200 MHz > > > > > > HSMC_SETUP3:0x0001 > > > HSMC_PULSE3:0x07040502 > > > HSMC_CYCLE3:0x00070005 > > > HSMC_TIMINGS3: 0x880402f2 > > > HSMC_MODE3: 0x001f0003 > > > NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 > > > ns) > > >NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 > > > ns) > > > NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 > > > ns) > > >NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 > > > ns) > > > TDF optimization enabled > > > TDF cycles: 15 (75 ns) > > > Data Bus Width: 8-bit bus > > > NWAIT Mode: 0 > > > Write operation controlled by NWE signal > > > Read operation controlled by NRD signal > > > NFSEL (NAND Flash Selection) is set > > > OCMS (Off Chip Memory Scrambling) is disabled > > > TWB (WEN High to REN to Busy): 64 (320 ns) > > > TRR (Ready to REN Low Delay): 4 (20 ns) > > > TAR (ALE to REN Low Delay):2 (10 ns) > > > TADL (ALE to Data Start): 71 (355 ns) > > > TCLR (CLE to REN Low Delay): 2 (10 ns) > > > > > > => time nand torture 0x100 0x100 > > > > > > NAND torture: device 0 offset 0x100 size 0x100 (block size > > > 0x4) > > > Passed: 64, failed: 0 > > > > > > time: 11.661 seconds > > > > > > => nand info > > > > > > Device 0: nand0, sector size 256 KiB > > > Manufacturer MACRONIX > > > Model MX30LF4G28AD > > > Device size512 MiB > > > Page size 4096 b > > > OOB size 256 b > > > Erase size 262144 b > > > ecc strength 8 bits > > > ecc step size 512 b > > > subpagesize 4096 b > > > options 0x40004200 > > > bbt options 0x00028000 > > > > > > Best regards, > > > Mihai Sain > > I'm in favor to have it even cover by one soc family. I would like to > confirm on imx6 and imx8. If you are not in a rush. > Let's us test too Agreed. This is a generic nand command, so it would of course be reasonable to test it on multiple nand controllers. I'm afraid I currently have only at91 boards on my desk for which I have a recent U-Boot _and_ a NAND chip soldered. So take your time for this patch. If you don't mind I would be happy if you could merge the four trivial patches w
Re: [PATCH] arm64: zynqmp: Add MTD partition handling for dfu_alt_info generation
On 2/23/24 17:18, Michal Simek wrote: Generate dfu_alt_info generation based on information from MTD partitions. mtd_found_part() is trying to identify MTD partition which code is running from. If partitions are not defined and location is not found it is going to previous behavior. Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 52 +++- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index ba49eb7be229..eee89284de9d 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -626,6 +626,31 @@ enum env_location env_get_location(enum env_operation op, int prio) #define DFU_ALT_BUF_LEN SZ_1K +static void mtd_found_part(u32 *base, u32 *size) +{ + struct mtd_info *part, *mtd; + + mtd_probe_devices(); + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + list_for_each_entry(part, &mtd->partitions, node) { + debug("0x%012llx-0x%012llx : \"%s\"\n", + part->offset, part->offset + part->size, + part->name); + + if (*base >= part->offset && + *base < part->offset + part->size) { + debug("Found my partition: %d/%s\n", + part->index, part->name); + *base = part->offset; + *size = part->size; + break; + } + } + } +} + void set_dfu_alt_info(char *interface, char *devstr) { int multiboot, bootseq = 0, len = 0; @@ -667,15 +692,28 @@ void set_dfu_alt_info(char *interface, char *devstr) break; case QSPI_MODE_24BIT: case QSPI_MODE_32BIT: - len += snprintf(buf + len, DFU_ALT_BUF_LEN, - "sf 0:0=boot.bin raw %x 0x150", - multiboot * SZ_32K); + { + u32 base = multiboot * SZ_32K; + u32 size = 0x150; + u32 limit = size; + + mtd_found_part(&base, &limit); + +#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) + size = limit; + limit = CONFIG_SYS_SPI_U_BOOT_OFFS; +#endif + + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + "sf 0:0=boot.bin raw 0x%x 0x%x", + base, limit); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) - len += snprintf(buf + len, DFU_ALT_BUF_LEN, - ";%s raw 0x%x 0x50", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, - multiboot * SZ_32K + CONFIG_SYS_SPI_U_BOOT_OFFS); + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s raw 0x%x 0x%x", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + base + limit, size - limit); #endif + } break; default: return; Based on discussion here https://lore.kernel.org/all/561f9d0ee96ebb6cd674042f269f280ab68fbbac.1708705118.git.michal.si...@amd.com/ I will send updated version of this patch. M
Re: [PATCH] arm64: zynqmp: Do not describe u-boot.itb if SPL is disabled
On 2/23/24 17:18, Michal Simek wrote: There is no reason to describe u-boot.itb on system without SPL. Pretty much this is cover all systems which are using only boot.bin which contains all images inside. Signed-off-by: Michal Simek --- board/xilinx/common/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 9641ed307b75..4f38b7d27684 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -43,7 +43,7 @@ struct efi_fw_image fw_images[] = { .image_index = 1, }, #endif -#if defined(XILINX_UBOOT_IMAGE_GUID) +#if defined(XILINX_UBOOT_IMAGE_GUID) && defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) { .image_type_id = XILINX_UBOOT_IMAGE_GUID, .fw_name = u"XILINX-UBOOT", Applied. M
Re: [PATCH v3 4/6] usb: Add environment based device ignorelist
On 3/22/24 8:47 AM, Janne Grunau via B4 Relay wrote: [...] @@ -1099,6 +1142,20 @@ int usb_select_config(struct usb_device *dev) le16_to_cpus(&dev->descriptor.idProduct); le16_to_cpus(&dev->descriptor.bcdDevice); + /* ignore devices from usb_ignorelist */ + err = usb_device_is_ignored(dev->descriptor.idVendor, + dev->descriptor.idProduct); + if (err == -ENODEV) { + dev_dbg(dev->dev, "Ignoring USB device 0x%x:0x%x\n", + dev->descriptor.idVendor, dev->descriptor.idProduct); + return err; + } else if (err == -EINVAL) { + printf("usb_ignorelist parse error in \"%s\"\n", + env_get("usb_ignorelist")); Please use dev_err() here consistently with dev_dbg() above. With that fixed: Reviewed-by: Marek Vasut Thanks !
Re: [PATCH] arm64: zynqmp: Do not setup default SPL options without SPL
On 3/12/24 16:51, Michal Simek wrote: mach Kconfig file select some options independently of if SPL is actually enabled. It ends up in situation that SPL is disabled but symbols are still present in .config. That's why add SPL dependency for them but also group them with other SPL options in ARCH_ZYNQMP fragment with using imply option. This should ensure the same behavior as default y. Also fixed SPL_ZYNQMP_PSU_INIT_ENABLED for the same. Signed-off-by: Michal Simek --- arch/arm/Kconfig | 8 arch/arm/mach-zynqmp/Kconfig | 27 ++- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fde85dc0d537..0cf85edcb45d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1325,6 +1325,14 @@ config ARCH_ZYNQMP select SPL_DM_SPI_FLASH if SPL_DM_SPI select SPL_DM_MAILBOX if SPL imply SPL_FIRMWARE if SPL + imply SPL_FS_FAT if SPL + imply SPL_LIBCOMMON_SUPPORT if SPL + imply SPL_LIBDISK_SUPPORT if SPL + imply SPL_LIBGENERIC_SUPPORT if SPL + imply SPL_MMC if SPL && MMC_SDHCI_ZYNQ + imply SPL_SERIAL if SPL + imply SPL_SPI if SPL && ZYNQ_QSPI + imply SPL_SPI_FLASH_SUPPORT if SPL && ZYNQ_QSPI select SPL_SEPARATE_BSS if SPL select SUPPORT_SPL imply ZYNQMP_IPI if DM_MAILBOX diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig index 7e7c87d16fa9..eee34380f0a0 100644 --- a/arch/arm/mach-zynqmp/Kconfig +++ b/arch/arm/mach-zynqmp/Kconfig @@ -1,29 +1,5 @@ if ARCH_ZYNQMP -config SPL_FS_FAT - default y - -config SPL_LIBCOMMON_SUPPORT - default y - -config SPL_LIBDISK_SUPPORT - default y - -config SPL_LIBGENERIC_SUPPORT - default y - -config SPL_MMC - default y if MMC_SDHCI_ZYNQ - -config SPL_SERIAL - default y - -config SPL_SPI_FLASH_SUPPORT - default y if ZYNQ_QSPI - -config SPL_SPI - default y if ZYNQ_QSPI - config SYS_BOARD string "Board name" default "zynqmp" @@ -143,7 +119,8 @@ config ZYNQMP_PSU_INIT_ENABLED config SPL_ZYNQMP_PSU_INIT_ENABLED bool "Include psu_init in SPL" - default y if SPL + depends on SPL + default y select BOARD_EARLY_INIT_F help Include psu_init by default in SPL. Applied. M
Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'
HI On Fri, Mar 22, 2024 at 12:46 PM Alexander Dahl wrote: > > Hello Mihai, > > Am Fri, Mar 22, 2024 at 10:02:29AM + schrieb mihai.s...@microchip.com: > > Hi Michael, > > > > --- > > > > I think this command can be really useful. > > Let try to have more testing on more boards > > > > - > > > > I managed to test the command on sama7g54-curiosity board. > > Thanks for that. Nice to see it works on other variants of the SoC > family. > > > I also forced timing mode 5 from controller driver > > (conf->timings.sdr.tRC_min < 2). > > You did a similar thing for the sam9x75. These boards/socs seem to > have a newer SMC / HSMC controller than sama5d2 or sam9x60? The > driver claims all the (H)SMC incarnations do _not_ support these EDO > modes 4 and 5. Maybe someone could have a deeper look at the > datasheets of the newer SoCs and propose a patch to support those > newer controllers in the atmel nand-controller driver? I guess the > problem is the same in Linux, right? > > Greets > Alex > > > > > => nand onfi 0 > > => hsmc decode > > > > MCK rate: 200 MHz > > > > HSMC_SETUP3:0x0004 > > HSMC_PULSE3:0x140a140a > > HSMC_CYCLE3:0x00140014 > > HSMC_TIMINGS3: 0x880805f4 > > HSMC_MODE3: 0x001f0003 > > NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 > > ns) > >NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 > > (100 ns) > > NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 > > ns) > >NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 > > (100 ns) > > TDF optimization enabled > > TDF cycles: 15 (75 ns) > > Data Bus Width: 8-bit bus > > NWAIT Mode: 0 > > Write operation controlled by NWE signal > > Read operation controlled by NRD signal > > NFSEL (NAND Flash Selection) is set > > OCMS (Off Chip Memory Scrambling) is disabled > > TWB (WEN High to REN to Busy): 64 (320 ns) > > TRR (Ready to REN Low Delay): 64 (320 ns) > > TAR (ALE to REN Low Delay):5 (25 ns) > > TADL (ALE to Data Start): 71 (355 ns) > > TCLR (CLE to REN Low Delay): 4 (20 ns) > > > > => time nand torture 0x100 0x100 > > > > NAND torture: device 0 offset 0x100 size 0x100 (block size 0x4) > > Passed: 64, failed: 0 > > > > time: 22.638 seconds > > > > => nand onfi 5 > > => hsmc decode > > > > MCK rate: 200 MHz > > > > HSMC_SETUP3:0x0001 > > HSMC_PULSE3:0x07040502 > > HSMC_CYCLE3:0x00070005 > > HSMC_TIMINGS3: 0x880402f2 > > HSMC_MODE3: 0x001f0003 > > NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns) > >NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns) > > NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns) > >NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns) > > TDF optimization enabled > > TDF cycles: 15 (75 ns) > > Data Bus Width: 8-bit bus > > NWAIT Mode: 0 > > Write operation controlled by NWE signal > > Read operation controlled by NRD signal > > NFSEL (NAND Flash Selection) is set > > OCMS (Off Chip Memory Scrambling) is disabled > > TWB (WEN High to REN to Busy): 64 (320 ns) > > TRR (Ready to REN Low Delay): 4 (20 ns) > > TAR (ALE to REN Low Delay):2 (10 ns) > > TADL (ALE to Data Start): 71 (355 ns) > > TCLR (CLE to REN Low Delay): 2 (10 ns) > > > > => time nand torture 0x100 0x100 > > > > NAND torture: device 0 offset 0x100 size 0x100 (block size 0x4) > > Passed: 64, failed: 0 > > > > time: 11.661 seconds > > > > => nand info > > > > Device 0: nand0, sector size 256 KiB > > Manufacturer MACRONIX > > Model MX30LF4G28AD > > Device size512 MiB > > Page size 4096 b > > OOB size 256 b > > Erase size 262144 b > > ecc strength 8 bits > > ecc step size 512 b > > subpagesize 4096 b > > options 0x40004200 > > bbt options 0x00028000 > > > > Best regards, > > Mihai Sain I'm in favor to have it even cover by one soc family. I would like to confirm on imx6 and imx8. If you are not in a rush. Let's us test too Michael -- Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 mich...@amarulasolutions.com __ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 i...@amarulasolutions.com www.amarulasolutions.com
Re: [PATCH] arm64: zynqmp: Also support JTAG as alternative boot mode
On 3/21/24 17:20, Sean Anderson wrote: On 3/20/24 07:18, Michal Simek wrote: if (reg >> BOOT_MODE_ALT_SHIFT) condition rules out alternative jtag boot mode which is 0. When 0 was used origin(HW) boot mode was used instead. That's why directly fill reg variable with requested boot mode and don't let code to read value back. "else" part of code remain unchanged. Signed-off-by: Michal Simek --- arch/arm/mach-zynqmp/spl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c index 5af735aa5cef..979ff3aef6c2 100644 --- a/arch/arm/mach-zynqmp/spl.c +++ b/arch/arm/mach-zynqmp/spl.c @@ -91,13 +91,14 @@ u32 spl_boot_device(void) #if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED) /* Change default boot mode at run-time */ + reg = CONFIG_SPL_ZYNQMP_ALT_BOOTMODE; writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, &crlapb_base->boot_mode); -#endif - +#else reg = readl(&crlapb_base->boot_mode); if (reg >> BOOT_MODE_ALT_SHIFT) reg >>= BOOT_MODE_ALT_SHIFT; +#endif bootmode = reg & BOOT_MODES_MASK; Looks fine; can we change this to if (IS_ENABLED(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)) { ... } else { ... } Issue is that CONFIG_SPL_ZYNQMP_ALT_BOOTMODE symbol is not defined and depends on CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED. It means you get compilation error. That symbol can be setup and then what you have above can work. Is it worth? TBH I don't have preference. Please take a look at patch below. (And if v1 is fine then at least there should be added depends on SPL_ZYNQMP_ALT_BOOTMODE_ENABLED to SPL_ZYNQMP_ALT_BOOTMODE which is missing there now). Thanks, Michal diff --git a/arch/arm/mach-zynqmp/Kconfig b/arch/arm/mach-zynqmp/Kconfig index eee34380f0a0..75d3ec916a66 100644 --- a/arch/arm/mach-zynqmp/Kconfig +++ b/arch/arm/mach-zynqmp/Kconfig @@ -145,7 +145,7 @@ config ZYNQ_SDHCI_MAX_FREQ config SPL_ZYNQMP_ALT_BOOTMODE hex - default 0x0 if JTAG_MODE + default 0x0 default 0x1 if QSPI_MODE_24BIT default 0x2 if QSPI_MODE_32BIT default 0x3 if SD_MODE diff --git a/arch/arm/mach-zynqmp/spl.c b/arch/arm/mach-zynqmp/spl.c index 979ff3aef6c2..bbbf684ae496 100644 --- a/arch/arm/mach-zynqmp/spl.c +++ b/arch/arm/mach-zynqmp/spl.c @@ -89,16 +89,16 @@ u32 spl_boot_device(void) u32 reg = 0; u8 bootmode; -#if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED) - /* Change default boot mode at run-time */ - reg = CONFIG_SPL_ZYNQMP_ALT_BOOTMODE; - writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, - &crlapb_base->boot_mode); -#else - reg = readl(&crlapb_base->boot_mode); - if (reg >> BOOT_MODE_ALT_SHIFT) - reg >>= BOOT_MODE_ALT_SHIFT; -#endif + if (IS_ENABLED(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)) { + /* Change default boot mode at run-time */ + reg = CONFIG_SPL_ZYNQMP_ALT_BOOTMODE; + writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, + &crlapb_base->boot_mode); + } else { + reg = readl(&crlapb_base->boot_mode); + if (reg >> BOOT_MODE_ALT_SHIFT) + reg >>= BOOT_MODE_ALT_SHIFT; + } bootmode = reg & BOOT_MODES_MASK;
Re: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'
Hello Mihai, Am Fri, Mar 22, 2024 at 10:02:29AM + schrieb mihai.s...@microchip.com: > Hi Michael, > > --- > > I think this command can be really useful. > Let try to have more testing on more boards > > - > > I managed to test the command on sama7g54-curiosity board. Thanks for that. Nice to see it works on other variants of the SoC family. > I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min > < 2). You did a similar thing for the sam9x75. These boards/socs seem to have a newer SMC / HSMC controller than sama5d2 or sam9x60? The driver claims all the (H)SMC incarnations do _not_ support these EDO modes 4 and 5. Maybe someone could have a deeper look at the datasheets of the newer SoCs and propose a patch to support those newer controllers in the atmel nand-controller driver? I guess the problem is the same in Linux, right? Greets Alex > > => nand onfi 0 > => hsmc decode > > MCK rate: 200 MHz > > HSMC_SETUP3:0x0004 > HSMC_PULSE3:0x140a140a > HSMC_CYCLE3:0x00140014 > HSMC_TIMINGS3: 0x880805f4 > HSMC_MODE3: 0x001f0003 > NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 > ns) >NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 > ns) > NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 > ns) >NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 > ns) > TDF optimization enabled > TDF cycles: 15 (75 ns) > Data Bus Width: 8-bit bus > NWAIT Mode: 0 > Write operation controlled by NWE signal > Read operation controlled by NRD signal > NFSEL (NAND Flash Selection) is set > OCMS (Off Chip Memory Scrambling) is disabled > TWB (WEN High to REN to Busy): 64 (320 ns) > TRR (Ready to REN Low Delay): 64 (320 ns) > TAR (ALE to REN Low Delay):5 (25 ns) > TADL (ALE to Data Start): 71 (355 ns) > TCLR (CLE to REN Low Delay): 4 (20 ns) > > => time nand torture 0x100 0x100 > > NAND torture: device 0 offset 0x100 size 0x100 (block size 0x4) > Passed: 64, failed: 0 > > time: 22.638 seconds > > => nand onfi 5 > => hsmc decode > > MCK rate: 200 MHz > > HSMC_SETUP3:0x0001 > HSMC_PULSE3:0x07040502 > HSMC_CYCLE3:0x00070005 > HSMC_TIMINGS3: 0x880402f2 > HSMC_MODE3: 0x001f0003 > NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns) >NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns) > NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns) >NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns) > TDF optimization enabled > TDF cycles: 15 (75 ns) > Data Bus Width: 8-bit bus > NWAIT Mode: 0 > Write operation controlled by NWE signal > Read operation controlled by NRD signal > NFSEL (NAND Flash Selection) is set > OCMS (Off Chip Memory Scrambling) is disabled > TWB (WEN High to REN to Busy): 64 (320 ns) > TRR (Ready to REN Low Delay): 4 (20 ns) > TAR (ALE to REN Low Delay):2 (10 ns) > TADL (ALE to Data Start): 71 (355 ns) > TCLR (CLE to REN Low Delay): 2 (10 ns) > > => time nand torture 0x100 0x100 > > NAND torture: device 0 offset 0x100 size 0x100 (block size 0x4) > Passed: 64, failed: 0 > > time: 11.661 seconds > > => nand info > > Device 0: nand0, sector size 256 KiB > Manufacturer MACRONIX > Model MX30LF4G28AD > Device size512 MiB > Page size 4096 b > OOB size 256 b > Erase size 262144 b > ecc strength 8 bits > ecc step size 512 b > subpagesize 4096 b > options 0x40004200 > bbt options 0x00028000 > > Best regards, > Mihai Sain
[PATCH 12/12] arm: env: Add support for booting different HW revisions of XEA boards
In the scenario of recovery, the FitImage is used to boot the system. This patch provides support for deciding which dtb configuration shall be used. Signed-off-by: Lukasz Majewski --- board/liebherr/xea/xea.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/liebherr/xea/xea.env b/board/liebherr/xea/xea.env index ac6ac898ec..9dec4016a0 100644 --- a/board/liebherr/xea/xea.env +++ b/board/liebherr/xea/xea.env @@ -112,7 +112,7 @@ sf_swu= sf read ${loadaddr} ${sf_kernel_offset} ${sf_swu_size} ; setenv bootargs root=/dev/ram0 rw ; run addargs ; - bootm ${loadaddr} ; + bootm ${loadaddr}#conf-imx28-${arch}-${board_som_rev}.dtb ; fi net_mmc= if run netload mmcargs addargs ; then -- 2.39.2
[PATCH 11/12] arm: xea: Print information about XEA's SoM HW revision
As now XEA has its second HW revision - this information is printed when u-boot proper starts. Signed-off-by: Lukasz Majewski --- board/liebherr/xea/xea.c | 9 + 1 file changed, 9 insertions(+) diff --git a/board/liebherr/xea/xea.c b/board/liebherr/xea/xea.c index 5bac614153..876e8a70ab 100644 --- a/board/liebherr/xea/xea.c +++ b/board/liebherr/xea/xea.c @@ -294,6 +294,15 @@ int board_late_init(void) } #endif +#if defined(CONFIG_DISPLAY_BOARDINFO) +int checkboard(void) +{ + printf("Board: LWE XEA SoM HW rev %d\n", get_som_rev()); + + return 0; +} +#endif + int dram_init(void) { return mxs_dram_init(); -- 2.39.2
[PATCH 10/12] config: xea: Enable late board initialization to set revision variable
The 'board_som_rev' environment variable will be used to point correct configuration from the Linux FIT file. Signed-off-by: Lukasz Majewski --- board/liebherr/xea/xea.c | 12 configs/imx28_xea_defconfig| 1 + configs/imx28_xea_sb_defconfig | 1 + 3 files changed, 14 insertions(+) diff --git a/board/liebherr/xea/xea.c b/board/liebherr/xea/xea.c index 615d266b8f..5bac614153 100644 --- a/board/liebherr/xea/xea.c +++ b/board/liebherr/xea/xea.c @@ -282,6 +282,18 @@ int board_init(void) return 0; } +#if defined(CONFIG_BOARD_LATE_INIT) +int board_late_init(void) +{ + int ret = env_set_ulong("board_som_rev", get_som_rev()); + + if (ret) + printf("Cannot set XEA's SoM revision env variable!\n"); + + return 0; +} +#endif + int dram_init(void) { return mxs_dram_init(); diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig index bc8c167b1f..c416635b24 100644 --- a/configs/imx28_xea_defconfig +++ b/configs/imx28_xea_defconfig @@ -39,6 +39,7 @@ CONFIG_BOOTCOMMAND="run ${bootpri} ; run ${bootsec}" CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="run prebootcmd" CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_BOARD_LATE_INIT=y CONFIG_SPL_NO_BSS_LIMIT=y CONFIG_SPL_BOARD_INIT=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set diff --git a/configs/imx28_xea_sb_defconfig b/configs/imx28_xea_sb_defconfig index 691edc2834..78e59b4cb2 100644 --- a/configs/imx28_xea_sb_defconfig +++ b/configs/imx28_xea_sb_defconfig @@ -23,6 +23,7 @@ CONFIG_BOOTARGS="console=ttyAMA0,115200n8" CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="run prebootcmd" CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_BOARD_LATE_INIT=y # CONFIG_SPL_FRAMEWORK is not set CONFIG_SPL_NO_BSS_LIMIT=y CONFIG_SPL_BOARD_INIT=y -- 2.39.2
[PATCH 09/12] arm: config: xea: Enable support for multiple DTBs for XEA board
After this change u-boot proper is able to support two HW revisions of the XEA board. Signed-off-by: Lukasz Majewski --- configs/imx28_xea_defconfig| 2 ++ configs/imx28_xea_sb_defconfig | 2 ++ 2 files changed, 4 insertions(+) diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig index 42cbc3d34c..bc8c167b1f 100644 --- a/configs/imx28_xea_defconfig +++ b/configs/imx28_xea_defconfig @@ -81,6 +81,8 @@ CONFIG_CMD_MTDPARTS=y CONFIG_DOS_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_OF_LIST="imx28-xea-1 imx28-xea-2" +CONFIG_MULTI_DTB_FIT=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent interrupts" CONFIG_SPL_OF_PLATDATA=y # CONFIG_SPL_OF_PLATDATA_PARENT is not set diff --git a/configs/imx28_xea_sb_defconfig b/configs/imx28_xea_sb_defconfig index 30b3568e7f..691edc2834 100644 --- a/configs/imx28_xea_sb_defconfig +++ b/configs/imx28_xea_sb_defconfig @@ -55,6 +55,8 @@ CONFIG_CMD_FS_GENERIC=y CONFIG_CMD_MTDPARTS=y CONFIG_OF_CONTROL=y CONFIG_SPL_OF_CONTROL=y +CONFIG_OF_LIST="imx28-xea-1 imx28-xea-2" +CONFIG_MULTI_DTB_FIT=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent interrupts" CONFIG_SPL_OF_PLATDATA=y # CONFIG_SPL_OF_PLATDATA_PARENT is not set -- 2.39.2
[PATCH 08/12] arm: spl: Add definition for PHY reset GPIO for XEA HW rev. 2
The imx287 based XEA board's revision 2 uses GPIO_3_21 for PHY reset It is safe to keep the GPIO_2_13 as well, as in the SPL SPI1 is not used for transmission. This simplifies the code, as the proper configuration is performed either in falcon boot's read DTB or in u-boot proper (with correct FIT configuration chosen). Signed-off-by: Lukasz Majewski --- board/liebherr/xea/spl_xea.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/liebherr/xea/spl_xea.c b/board/liebherr/xea/spl_xea.c index 71194db235..6cf8f8390e 100644 --- a/board/liebherr/xea/spl_xea.c +++ b/board/liebherr/xea/spl_xea.c @@ -225,7 +225,8 @@ const iomux_cfg_t iomux_setup[] = { MX28_PAD_ENET0_TXD0__ENET0_TXD0 | MUX_CONFIG_ENET, MX28_PAD_ENET0_TXD1__ENET0_TXD1 | MUX_CONFIG_ENET, MX28_PAD_ENET0_TXD3__ENET1_TXD1 | MUX_CONFIG_ENET, - MX28_PAD_SSP1_CMD__GPIO_2_13, /* PHY reset */ + MX28_PAD_SSP1_CMD__GPIO_2_13, /* PHY reset HW Rev. 1*/ + MX28_PAD_SAIF0_LRCLK__GPIO_3_21, /* PHY reset HW Rev. 2*/ /* TIVA boot control */ MX28_PAD_GPMI_RDY3__GPIO_0_23 | MUX_CONFIG_BOOT, /* TIVA0 */ -- 2.39.2
[PATCH 07/12] dts: xea: Add device tree description for XEA HW rev. 2
For SPL and u-boot proper, the difference between revsions boils down only to the GPIO pin for PHY reset. Signed-off-by: Lukasz Majewski --- arch/arm/dts/Makefile| 3 ++- arch/arm/dts/imx28-xea-2-u-boot.dtsi | 11 +++ arch/arm/dts/imx28-xea-2.dts | 8 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/imx28-xea-2-u-boot.dtsi create mode 100644 arch/arm/dts/imx28-xea-2.dts diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 4fc508bcfc..69131599ae 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -879,7 +879,8 @@ dtb-$(CONFIG_TARGET_MX23_OLINUXINO) += \ dtb-$(CONFIG_MX28) += \ imx28-evk.dtb \ - imx28-xea-1.dtb + imx28-xea-1.dtb \ + imx28-xea-2.dtb dtb-$(CONFIG_MX51) += \ imx51-babbage.dtb diff --git a/arch/arm/dts/imx28-xea-2-u-boot.dtsi b/arch/arm/dts/imx28-xea-2-u-boot.dtsi new file mode 100644 index 00..6ce82531d5 --- /dev/null +++ b/arch/arm/dts/imx28-xea-2-u-boot.dtsi @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright 2024 + * Lukasz Majewski, DENX Software Engineering, lu...@denx.de + */ + +#include "imx28-xea-u-boot.dtsi" + +&mac0 { + phy-reset-gpios = <&gpio3 21 GPIO_ACTIVE_LOW>; +}; diff --git a/arch/arm/dts/imx28-xea-2.dts b/arch/arm/dts/imx28-xea-2.dts new file mode 100644 index 00..8cb1190ba5 --- /dev/null +++ b/arch/arm/dts/imx28-xea-2.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright 2024 + * Lukasz Majewski, DENX Software Engineering, lu...@denx.de + */ + +/dts-v1/; +#include "imx28-xea.dtsi" -- 2.39.2
[PATCH 06/12] arm: xea: Add support for multiple dtbs in u-boot
As XEA board uses imx287, which has some constrains on SPL (u-boot.sb) size - it must be less than ~55 KiB, multiple boards versions are included in u-boot proper's FIT image. The decision of using proper configuration is based on information passed from SPL (u-boot.sb) in OCRAM dedicated location (0xE000 - 2). This board also uses falcon boot for production setup, so the proper dtb is flashed during production (also based on GPIO values describing HW ID). Signed-off-by: Lukasz Majewski --- board/liebherr/xea/xea.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/board/liebherr/xea/xea.c b/board/liebherr/xea/xea.c index d9cf27c81b..615d266b8f 100644 --- a/board/liebherr/xea/xea.c +++ b/board/liebherr/xea/xea.c @@ -287,6 +287,21 @@ int dram_init(void) return mxs_dram_init(); } +#if defined(CONFIG_MULTI_DTB_FIT) +int board_fit_config_name_match(const char *name) +{ + u8 rev_id = get_som_rev(); + char board[11]; + + sprintf(board, "imx28-xea-%d", rev_id); + + if (!strncmp(name, board, sizeof(board))) + return 0; + + return -EINVAL; +} +#endif + #ifdef CONFIG_OF_BOARD_SETUP static int fdt_fixup_l2switch(void *blob) { -- 2.39.2
[PATCH 05/12] dts: xea: Remove outdated comment
The comment in u-boot specific adjustment to XEA DTS is not valid anymore. Signed-off-by: Lukasz Majewski --- arch/arm/dts/imx28-xea-1-u-boot.dtsi | 4 1 file changed, 4 deletions(-) diff --git a/arch/arm/dts/imx28-xea-1-u-boot.dtsi b/arch/arm/dts/imx28-xea-1-u-boot.dtsi index 2903be2089..6cb6c66924 100644 --- a/arch/arm/dts/imx28-xea-1-u-boot.dtsi +++ b/arch/arm/dts/imx28-xea-1-u-boot.dtsi @@ -4,10 +4,6 @@ * Lukasz Majewski, DENX Software Engineering, lu...@denx.de */ -/* - * The minimal augmentation DTS U-Boot file to allow eMMC driver - * configuration in SPL for falcon boot. - */ #include "imx28-xea-u-boot.dtsi" &mac0 { -- 2.39.2
[PATCH 04/12] dts: xea: Move phy-reset-gpios property to version specific DTS file
The DTS description in XEA for mac0 node in u-boot differs considerably from what we do have available in Linux, as u-boot is not supporting L2 switch (i.e. 'fixed-link' property is used). To facilitate HW revision management - this particular property has been moved to version specific file. Signed-off-by: Lukasz Majewski --- arch/arm/dts/imx28-xea-1-u-boot.dtsi | 4 arch/arm/dts/imx28-xea-u-boot.dtsi | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/imx28-xea-1-u-boot.dtsi b/arch/arm/dts/imx28-xea-1-u-boot.dtsi index 4b2b21eeae..2903be2089 100644 --- a/arch/arm/dts/imx28-xea-1-u-boot.dtsi +++ b/arch/arm/dts/imx28-xea-1-u-boot.dtsi @@ -9,3 +9,7 @@ * configuration in SPL for falcon boot. */ #include "imx28-xea-u-boot.dtsi" + +&mac0 { + phy-reset-gpios = <&gpio2 13 GPIO_ACTIVE_LOW>; +}; diff --git a/arch/arm/dts/imx28-xea-u-boot.dtsi b/arch/arm/dts/imx28-xea-u-boot.dtsi index bdbeca528c..13a581f7a6 100644 --- a/arch/arm/dts/imx28-xea-u-boot.dtsi +++ b/arch/arm/dts/imx28-xea-u-boot.dtsi @@ -50,7 +50,6 @@ pinctrl-names = "default"; pinctrl-0 = <&mac0_pins_a>; phy-supply = <®_fec_3v3>; - phy-reset-gpios = <&gpio2 13 GPIO_ACTIVE_LOW>; phy-reset-duration = <1>; phy-reset-post-delay = <1>; status = "okay"; -- 2.39.2
[PATCH 03/12] arm: xea: Rename imx28-xea.dts to imx28-xea-1.dts
The former imx28-xea.dts file has been renamed to imx28-xea.dtsi, which is included to new imx28-xea-1.dts file. This is a preparatory work to add support for multiple versions of XEA boards to u-boot. Signed-off-by: Lukasz Majewski --- arch/arm/dts/Makefile | 2 +- arch/arm/dts/imx28-xea-1-u-boot.dtsi | 11 +++ arch/arm/dts/imx28-xea-1.dts | 8 arch/arm/dts/{imx28-xea.dts => imx28-xea.dtsi} | 0 board/liebherr/xea/xea.env | 2 +- configs/imx28_xea_defconfig| 2 +- configs/imx28_xea_sb_defconfig | 2 +- 7 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 arch/arm/dts/imx28-xea-1-u-boot.dtsi create mode 100644 arch/arm/dts/imx28-xea-1.dts rename arch/arm/dts/{imx28-xea.dts => imx28-xea.dtsi} (100%) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index b102ffb5f6..4fc508bcfc 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -879,7 +879,7 @@ dtb-$(CONFIG_TARGET_MX23_OLINUXINO) += \ dtb-$(CONFIG_MX28) += \ imx28-evk.dtb \ - imx28-xea.dtb + imx28-xea-1.dtb dtb-$(CONFIG_MX51) += \ imx51-babbage.dtb diff --git a/arch/arm/dts/imx28-xea-1-u-boot.dtsi b/arch/arm/dts/imx28-xea-1-u-boot.dtsi new file mode 100644 index 00..4b2b21eeae --- /dev/null +++ b/arch/arm/dts/imx28-xea-1-u-boot.dtsi @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright 2024 + * Lukasz Majewski, DENX Software Engineering, lu...@denx.de + */ + +/* + * The minimal augmentation DTS U-Boot file to allow eMMC driver + * configuration in SPL for falcon boot. + */ +#include "imx28-xea-u-boot.dtsi" diff --git a/arch/arm/dts/imx28-xea-1.dts b/arch/arm/dts/imx28-xea-1.dts new file mode 100644 index 00..8cb1190ba5 --- /dev/null +++ b/arch/arm/dts/imx28-xea-1.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright 2024 + * Lukasz Majewski, DENX Software Engineering, lu...@denx.de + */ + +/dts-v1/; +#include "imx28-xea.dtsi" diff --git a/arch/arm/dts/imx28-xea.dts b/arch/arm/dts/imx28-xea.dtsi similarity index 100% rename from arch/arm/dts/imx28-xea.dts rename to arch/arm/dts/imx28-xea.dtsi diff --git a/board/liebherr/xea/xea.env b/board/liebherr/xea/xea.env index 043099ae87..ac6ac898ec 100644 --- a/board/liebherr/xea/xea.env +++ b/board/liebherr/xea/xea.env @@ -3,7 +3,7 @@ bootpri=mmc_mmc bootsec=sf_swu consdev=ttyAMA0 baudrate=115200 -dtbfile=imx28-xea.dtb +dtbfile=imx28-xea-1.dtb rootdev=/dev/mmcblk0p2 netdev=eth0 swufile=swupdate-image-xea-upd.itb diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig index 64a0561a34..42cbc3d34c 100644 --- a/configs/imx28_xea_defconfig +++ b/configs/imx28_xea_defconfig @@ -11,7 +11,7 @@ CONFIG_SF_DEFAULT_SPEED=4000 CONFIG_IMX_CONFIG="" CONFIG_DM_GPIO=y CONFIG_SPL_DM_SPI=y -CONFIG_DEFAULT_DEVICE_TREE="imx28-xea" +CONFIG_DEFAULT_DEVICE_TREE="imx28-xea-1" CONFIG_SPL_TEXT_BASE=0x1000 CONFIG_TARGET_XEA=y CONFIG_SPL_MXS_PMU_MINIMAL_VDD5V_CURRENT=y diff --git a/configs/imx28_xea_sb_defconfig b/configs/imx28_xea_sb_defconfig index 9872d35c1b..30b3568e7f 100644 --- a/configs/imx28_xea_sb_defconfig +++ b/configs/imx28_xea_sb_defconfig @@ -9,7 +9,7 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_SF_DEFAULT_SPEED=4000 CONFIG_DM_GPIO=y CONFIG_SPL_DM_SPI=y -CONFIG_DEFAULT_DEVICE_TREE="imx28-xea" +CONFIG_DEFAULT_DEVICE_TREE="imx28-xea-1" CONFIG_SPL_TEXT_BASE=0x1000 CONFIG_TARGET_XEA=y CONFIG_SPL=y -- 2.39.2
[PATCH] xilinx: Do not call private env_get_location() when !ENV_IS_NOWHERE
Private function for finding out location of environment is not working when ENV_IS_NOWHERE is disabled. The reason is that current fallback is ENVL_UNKNOWN when CONFIG_ENV_IS_NOWHERE is not enabled. The code could be updated like this - return ENVL_NOWHERE; + if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE)) + return ENVL_NOWHERE; + return ENVL_UNKNOWN; But then boot is still not working because ENVL_UNKNOWN has no driver and env_init() returns -ENODEV. That's why it is better not to define board specific env_get_location() because then weak env_get_location() is used which is going over env_locations[] and returning locations which are actually enabled in u-boot instance. Signed-off-by: Michal Simek --- board/xilinx/versal-net/board.c | 2 ++ board/xilinx/versal/board.c | 2 ++ board/xilinx/zynqmp/zynqmp.c| 2 ++ 3 files changed, 6 insertions(+) diff --git a/board/xilinx/versal-net/board.c b/board/xilinx/versal-net/board.c index aecaeb657453..da03024e162f 100644 --- a/board/xilinx/versal-net/board.c +++ b/board/xilinx/versal-net/board.c @@ -372,6 +372,7 @@ void reset_cpu(void) { } +#if defined(CONFIG_ENV_IS_NOWHERE) enum env_location env_get_location(enum env_operation op, int prio) { u8 bootmode = versal_net_get_bootmode(); @@ -401,3 +402,4 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_NOWHERE; } } +#endif diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index 8c2e614ad8a0..4f6d56119db1 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -291,6 +291,7 @@ void reset_cpu(void) { } +#if defined(CONFIG_ENV_IS_NOWHERE) enum env_location env_get_location(enum env_operation op, int prio) { u32 bootmode = versal_get_bootmode(); @@ -320,3 +321,4 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_NOWHERE; } } +#endif diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index ba49eb7be229..79daaf8723ac 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -588,6 +588,7 @@ int mmc_get_env_dev(void) return bootseq; } +#if defined(CONFIG_ENV_IS_NOWHERE) enum env_location env_get_location(enum env_operation op, int prio) { u32 bootmode = zynqmp_get_bootmode(); @@ -621,6 +622,7 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_NOWHERE; } } +#endif #if defined(CONFIG_SET_DFU_ALT_INFO) -- 2.44.0
[PATCH 02/12] arm: xea: Add support for reading SoM (CPU) and base board HW revision
The XEA board now has several HW revisions for both SoM and base boards. This patch provides support for reading those revision ID values in SPL (u-boot.sb) and then pass this information to u-boot proper, as the maximal SPL size (~55KiB) is not allowing for having FIT support in it. It was necessary to handle reading GPIOs values solely in u-boot proper as one configuration (i.e. 'single binary' - imx28_xea_sb_defconfig) is not using SPL framework. Signed-off-by: Lukasz Majewski --- board/liebherr/xea/spl_xea.c | 11 +++ board/liebherr/xea/xea.c | 29 + 2 files changed, 40 insertions(+) diff --git a/board/liebherr/xea/spl_xea.c b/board/liebherr/xea/spl_xea.c index 551ed6fbae..71194db235 100644 --- a/board/liebherr/xea/spl_xea.c +++ b/board/liebherr/xea/spl_xea.c @@ -230,6 +230,17 @@ const iomux_cfg_t iomux_setup[] = { /* TIVA boot control */ MX28_PAD_GPMI_RDY3__GPIO_0_23 | MUX_CONFIG_BOOT, /* TIVA0 */ MX28_PAD_GPMI_WRN__GPIO_0_25 | MUX_CONFIG_BOOT, /* TIVA1 */ + + /* HW revision ID Base Board */ + MX28_PAD_LCD_D12__GPIO_1_12, + MX28_PAD_LCD_D13__GPIO_1_13, + MX28_PAD_LCD_D14__GPIO_1_14, + + /* HW revision ID (SoM) */ + MX28_PAD_LCD_D15__GPIO_1_15, + MX28_PAD_LCD_D16__GPIO_1_16, + MX28_PAD_LCD_D17__GPIO_1_17, + MX28_PAD_LCD_D18__GPIO_1_18, }; u32 mxs_dram_vals[] = { diff --git a/board/liebherr/xea/xea.c b/board/liebherr/xea/xea.c index c8ac526cb4..d9cf27c81b 100644 --- a/board/liebherr/xea/xea.c +++ b/board/liebherr/xea/xea.c @@ -48,6 +48,35 @@ DECLARE_GLOBAL_DATA_PTR; * Functions */ +/* + * Reading the HW ID number for XEA SoM module + * + * GPIOs from Port 1 (GPIO1_15, GPIO1_16, GPIO1_17 and GPIO1_18) + * are used to store HW revision information. + * Reading of GPIOs values is performed before the Device Model is + * bring up as the proper DTB needs to be chosen first. + * + * Moreover, this approach is required as "single binary" configuration + * of U-Boot (imx28_xea_sb_defconfig) is NOT using SPL framework, so + * only minimal subset of functionality is provided when ID is read. + * + * Hence, the direct registers' access. + */ +#define XEA_SOM_HW_ID_GPIO_PORT (MXS_PINCTRL_BASE + (0x0900 + ((1) * 0x10))) +#define XEA_SOM_REV_MASK GENMASK(18, 15) +#define XEA_SOM_REV_SHIFT 15 + +static inline u8 get_som_rev(void) +{ + struct mxs_register_32 *reg = + (struct mxs_register_32 *)XEA_SOM_HW_ID_GPIO_PORT; + + u32 tmp = ~readl(®->reg); + u8 id = (tmp & XEA_SOM_REV_MASK) >> XEA_SOM_REV_SHIFT; + + return id; +} + static void init_clocks(void) { /* IO0 clock at 480MHz */ -- 2.39.2
[PATCH 01/12] arm: spl: xea: Remove I2S pins configuration from early initialization
XEA is not supporting and using I2S codec, so there is no need to configure pins for it. Signed-off-by: Lukasz Majewski --- board/liebherr/xea/spl_xea.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/board/liebherr/xea/spl_xea.c b/board/liebherr/xea/spl_xea.c index df354cac64..551ed6fbae 100644 --- a/board/liebherr/xea/spl_xea.c +++ b/board/liebherr/xea/spl_xea.c @@ -112,13 +112,6 @@ const iomux_cfg_t iomux_setup[] = { MX28_PAD_I2C0_SCL__I2C0_SCL, MX28_PAD_I2C0_SDA__I2C0_SDA, - /* I2S Codec */ - MX28_PAD_SAIF0_BITCLK__SAIF0_BITCLK, - MX28_PAD_SAIF0_LRCLK__SAIF0_LRCLK, - MX28_PAD_SAIF0_MCLK__SAIF0_MCLK, - MX28_PAD_SAIF0_SDATA0__SAIF0_SDATA0, - MX28_PAD_SAIF1_SDATA0__SAIF1_SDATA0, - /* PWR-Hold */ MX28_PAD_SPDIF__GPIO_3_27, -- 2.39.2
[PATCH 00/12] arm: xea: Provide support for different XEA board HW versions
This patch set provides support for different XEA board revisions. Due to very limited SPL size, the board's switch DTB decision is performed very early in u-boot proper; before driver model is set. Adjustments for DTS between revisions are for the u-boot adjustment code (i.e. tweaks due to functionality not supported in u-boot), hence there is no need to update them from Linux upstream DTS. Lukasz Majewski (12): arm: spl: xea: Remove I2S pins configuration from early initialization arm: xea: Add support for reading SoM (CPU) and base board HW revision arm: xea: Rename imx28-xea.dts to imx28-xea-1.dts dts: xea: Move phy-reset-gpios property to version specific DTS file dts: xea: Remove outdated comment arm: xea: Add support for multiple dtbs in u-boot dts: xea: Add device tree description for XEA HW rev. 2 arm: spl: Add definition for PHY reset GPIO for XEA HW rev. 2 arm: config: xea: Enable support for multiple DTBs for XEA board config: xea: Enable late board initialization to set revision variable arm: xea: Print information about XEA's SoM HW revision arm: env: Add support for booting different HW revisions of XEA boards arch/arm/dts/Makefile | 3 +- arch/arm/dts/imx28-xea-1-u-boot.dtsi | 11 arch/arm/dts/imx28-xea-1.dts | 8 +++ arch/arm/dts/imx28-xea-2-u-boot.dtsi | 11 arch/arm/dts/imx28-xea-2.dts | 8 +++ arch/arm/dts/imx28-xea-u-boot.dtsi| 1 - .../arm/dts/{imx28-xea.dts => imx28-xea.dtsi} | 0 board/liebherr/xea/spl_xea.c | 21 +++--- board/liebherr/xea/xea.c | 65 +++ board/liebherr/xea/xea.env| 4 +- configs/imx28_xea_defconfig | 5 +- configs/imx28_xea_sb_defconfig| 5 +- 12 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 arch/arm/dts/imx28-xea-1-u-boot.dtsi create mode 100644 arch/arm/dts/imx28-xea-1.dts create mode 100644 arch/arm/dts/imx28-xea-2-u-boot.dtsi create mode 100644 arch/arm/dts/imx28-xea-2.dts rename arch/arm/dts/{imx28-xea.dts => imx28-xea.dtsi} (100%) -- 2.39.2
Re: [PATCH v3 01/20] configs: fwu: remove FWU configs for metadata V2 support
On Fri, 22 Mar 2024 at 12:58, Sughosh Ganu wrote: > > Support is to be added in the following commits for the FWU metadata > version 2. Disable the FWU feature on platforms that enable it for the > V2 addition work. > > Signed-off-by: Sughosh Ganu > --- > Changes since V2: None > > configs/corstone1000_defconfig | 2 -- > configs/sandbox64_defconfig | 1 - > configs/synquacer_developerbox_defconfig | 4 > 3 files changed, 7 deletions(-) > > diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig > index 8b2f77f648..29d7550afb 100644 > --- a/configs/corstone1000_defconfig > +++ b/configs/corstone1000_defconfig > @@ -24,7 +24,6 @@ CONFIG_LOGLEVEL=7 > CONFIG_BOARD_LATE_INIT=y > CONFIG_SYS_PROMPT="corstone1000# " > # CONFIG_CMD_CONSOLE is not set > -CONFIG_CMD_FWU_METADATA=y > CONFIG_CMD_BOOTZ=y > # CONFIG_CMD_XIMG is not set > CONFIG_CMD_GPT=y > @@ -67,4 +66,3 @@ CONFIG_FFA_SHARED_MM_BUF_OFFSET=0 > CONFIG_FFA_SHARED_MM_BUF_ADDR=0x0200 > CONFIG_EFI_CAPSULE_ON_DISK=y > CONFIG_EFI_IGNORE_OSINDICATIONS=y > -CONFIG_FWU_MULTI_BANK_UPDATE=y > diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig > index 3be9a00a85..7e8200e70c 100644 > --- a/configs/sandbox64_defconfig > +++ b/configs/sandbox64_defconfig > @@ -272,7 +272,6 @@ CONFIG_EFI_CAPSULE_ON_DISK=y > CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y > CONFIG_EFI_SECURE_BOOT=y > CONFIG_TEST_FDTDEC=y > -CONFIG_FWU_MULTI_BANK_UPDATE=y > CONFIG_UNIT_TEST=y > CONFIG_UT_TIME=y > CONFIG_UT_DM=y > diff --git a/configs/synquacer_developerbox_defconfig > b/configs/synquacer_developerbox_defconfig > index 2a0407de40..616d410074 100644 > --- a/configs/synquacer_developerbox_defconfig > +++ b/configs/synquacer_developerbox_defconfig > @@ -11,14 +11,12 @@ CONFIG_DM_GPIO=y > CONFIG_DEFAULT_DEVICE_TREE="synquacer-sc2a11-developerbox" > CONFIG_SYS_LOAD_ADDR=0x8000 > CONFIG_TARGET_DEVELOPERBOX=y > -CONFIG_FWU_NUM_IMAGES_PER_BANK=1 > CONFIG_AHCI=y > CONFIG_FIT=y > CONFIG_SYS_BOOTM_LEN=0x80 > CONFIG_BOOTSTAGE_STASH_SIZE=4096 > CONFIG_HUSH_PARSER=y > CONFIG_SYS_MAXARGS=128 > -CONFIG_CMD_FWU_METADATA=y > CONFIG_CMD_IMLS=y > CONFIG_CMD_ERASEENV=y > CONFIG_CMD_NVEDIT_EFI=y > @@ -53,7 +51,6 @@ CONFIG_DFU_TFTP=y > CONFIG_DFU_MTD=y > CONFIG_DFU_RAM=y > CONFIG_DFU_SF=y > -CONFIG_FWU_MDATA_MTD=y > CONFIG_DM_I2C=y > CONFIG_SYS_I2C_SYNQUACER=y > CONFIG_MMC_SDHCI=y > @@ -96,4 +93,3 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y > CONFIG_EFI_CAPSULE_ON_DISK=y > CONFIG_EFI_IGNORE_OSINDICATIONS=y > CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y > -CONFIG_FWU_MULTI_BANK_UPDATE=y > -- > 2.34.1 > Reviewed-by: Ilias Apalodimas
Re: [PATCH v3 19/20] MAINTAINERS: add entry for FWU multi bank update feature
On Fri, 22 Mar 2024 at 12:59, Sughosh Ganu wrote: > > Add an entry for the FWU Multi Bank Update feature. > > Signed-off-by: Sughosh Ganu > --- > Changes since V2: > * New patch > > MAINTAINERS | 8 > 1 file changed, 8 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index cd9b2d42e8..5409b1d78a 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1147,6 +1147,14 @@ T: git > https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq.git > F: drivers/watchdog/sp805_wdt.c > F: drivers/watchdog/sbsa_gwdt.c > > +FWU Multi Bank Update > +M: Sughosh Ganu > +S: Maintained > +T: git https://source.denx.de/u-boot/custodians/u-boot-efi.git > +F: lib/fwu_updates/* > +F: drivers/fwu-mdata/* > +F: tools/mkfwumdata.c > + > GATEWORKS_SC > M: Tim Harvey > S: Maintained > -- > 2.34.1 > Reviewed-by: Ilias Apalodimas
[PATCH] spl: riscv: opensbi: fix check of PAYLOAD_ARGS_ADDR
When Falcon Mode is enabled on RISC-V, use CONFIG_VAL to check PAYLOAD_ARGS_ADDR, not CONFIG_IS_ENABLED. Signed-off-by: Randolph --- common/spl/spl_opensbi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c index 8127ebc946..ec62aab929 100644 --- a/common/spl/spl_opensbi.c +++ b/common/spl/spl_opensbi.c @@ -66,7 +66,7 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image) * Moving DTB in front of the kernel can avoid the error. */ #if CONFIG_IS_ENABLED(LOAD_FIT_OPENSBI_OS_BOOT) && \ -CONFIG_IS_ENABLED(PAYLOAD_ARGS_ADDR) +CONFIG_VAL(PAYLOAD_ARGS_ADDR) memcpy((void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, spl_image->fdt_addr, fdt_totalsize(spl_image->fdt_addr)); spl_image->fdt_addr = map_sysmem(CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0); -- 2.34.1
[PATCH v3 20/20] configs: fwu: re-enable FWU configs
Now that support for FWU metadata version 2 has been added, the feature can be enabled on platforms which had enabled it. A new config symbol for selecting the metadata version for the platform is also being added. Signed-off-by: Sughosh Ganu --- Changes since V2: * Add config symbol for selecting either of the two metadata versions. configs/corstone1000_defconfig | 3 +++ configs/sandbox64_defconfig | 2 ++ configs/synquacer_developerbox_defconfig | 4 3 files changed, 9 insertions(+) diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig index 29d7550afb..ab4e0fefc9 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig @@ -24,6 +24,7 @@ CONFIG_LOGLEVEL=7 CONFIG_BOARD_LATE_INIT=y CONFIG_SYS_PROMPT="corstone1000# " # CONFIG_CMD_CONSOLE is not set +CONFIG_CMD_FWU_METADATA=y CONFIG_CMD_BOOTZ=y # CONFIG_CMD_XIMG is not set CONFIG_CMD_GPT=y @@ -66,3 +67,5 @@ CONFIG_FFA_SHARED_MM_BUF_OFFSET=0 CONFIG_FFA_SHARED_MM_BUF_ADDR=0x0200 CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_IGNORE_OSINDICATIONS=y +CONFIG_FWU_MULTI_BANK_UPDATE=y +CONFIG_FWU_MDATA_V1=y diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 7e8200e70c..7b316f0d80 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -272,6 +272,8 @@ CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y +CONFIG_FWU_MULTI_BANK_UPDATE=y +CONFIG_FWU_MDATA_V1=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y diff --git a/configs/synquacer_developerbox_defconfig b/configs/synquacer_developerbox_defconfig index 616d410074..7e1aeac217 100644 --- a/configs/synquacer_developerbox_defconfig +++ b/configs/synquacer_developerbox_defconfig @@ -17,6 +17,7 @@ CONFIG_SYS_BOOTM_LEN=0x80 CONFIG_BOOTSTAGE_STASH_SIZE=4096 CONFIG_HUSH_PARSER=y CONFIG_SYS_MAXARGS=128 +CONFIG_CMD_FWU_METADATA=y CONFIG_CMD_IMLS=y CONFIG_CMD_ERASEENV=y CONFIG_CMD_NVEDIT_EFI=y @@ -51,6 +52,7 @@ CONFIG_DFU_TFTP=y CONFIG_DFU_MTD=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y +CONFIG_FWU_MDATA_MTD=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_SYNQUACER=y CONFIG_MMC_SDHCI=y @@ -93,3 +95,5 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_IGNORE_OSINDICATIONS=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y +CONFIG_FWU_MULTI_BANK_UPDATE=y +CONFIG_FWU_MDATA_V2=y -- 2.34.1
[PATCH v3 19/20] MAINTAINERS: add entry for FWU multi bank update feature
Add an entry for the FWU Multi Bank Update feature. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch MAINTAINERS | 8 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index cd9b2d42e8..5409b1d78a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1147,6 +1147,14 @@ T: git https://source.denx.de/u-boot/custodians/u-boot-fsl-qoriq.git F: drivers/watchdog/sp805_wdt.c F: drivers/watchdog/sbsa_gwdt.c +FWU Multi Bank Update +M: Sughosh Ganu +S: Maintained +T: git https://source.denx.de/u-boot/custodians/u-boot-efi.git +F: lib/fwu_updates/* +F: drivers/fwu-mdata/* +F: tools/mkfwumdata.c + GATEWORKS_SC M: Tim Harvey S: Maintained -- 2.34.1
[PATCH v3 18/20] doc: fwu: make changes to reflect support for FWU metadata v2
The FWU Update Agent in U-Boot supports both versions of the FWU metadata. Make changes in the documentation to reflect this. Signed-off-by: Sughosh Ganu --- Changes since V2: * Changes to indicate support for both v1 and v2 instead of only v2. doc/board/socionext/developerbox.rst | 7 +-- doc/develop/uefi/fwu_updates.rst | 20 +++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/doc/board/socionext/developerbox.rst b/doc/board/socionext/developerbox.rst index 46712c379b..863761c6e2 100644 --- a/doc/board/socionext/developerbox.rst +++ b/doc/board/socionext/developerbox.rst @@ -116,6 +116,7 @@ configs/synquacer_developerbox_defconfig enables default FWU configuration :: CONFIG_FWU_NUM_BANKS=2 CONFIG_FWU_NUM_IMAGES_PER_BANK=1 CONFIG_CMD_FWU_METADATA=y + CONFIG_FWU_MDATA_V2=y And build it:: @@ -129,7 +130,9 @@ And build it:: By default, the CONFIG_FWU_NUM_BANKS and CONFIG_FWU_NUM_IMAGES_PER_BANKS are set to 2 and 1 respectively. This uses FIP (Firmware Image Package) type image which contains TF-A, U-Boot and OP-TEE (the OP-TEE is optional). -You can use fiptool to compose the FIP image from those firmware images. +You can use fiptool to compose the FIP image from those firmware +images. There are two versions of the FWU metadata, of which the +platform enables version 2 by default. Rebuild SCP firmware @@ -194,7 +197,7 @@ following UUIDs. These UUIDs are used for making a FWU metadata image. -u-boot$ ./tools/mkfwumdata -i 1 -b 2 \ +u-boot$ ./tools/mkfwumdata -v 2 -i 1 -b 2 \ 17e86d77-41f9-4fd7-87ec-a55df9842de5,10c36d7d-ca52-b843-b7b9-f9d6c501d108,5a66a702-99fd-4fef-a392-c26e261a2828,a8f868a1-6e5c-4757-878d-ce63375ef2c0 \ ../devbox-fwu-mdata.img diff --git a/doc/develop/uefi/fwu_updates.rst b/doc/develop/uefi/fwu_updates.rst index e4709d82b4..51e8a28efe 100644 --- a/doc/develop/uefi/fwu_updates.rst +++ b/doc/develop/uefi/fwu_updates.rst @@ -46,6 +46,8 @@ The feature can be enabled by specifying the following configs:: CONFIG_FWU_NUM_BANKS= CONFIG_FWU_NUM_IMAGES_PER_BANK= +CONFIG_FWU_MDATA_V1=y or CONFIG_FWU_MDATA_V2=y + in the .config file By enabling the CONFIG_CMD_FWU_METADATA config option, the @@ -58,6 +60,14 @@ enable the FWU Multi Bank Update functionality. Please refer to the section :ref:`uefi_capsule_update_ref` for more details on generation of the UEFI capsule. +FWU Metadata + + +U-Boot supports both versions(1 and 2) of the FWU metadata defined in +the two revisions of the specification. Support can be enabled for +either of the two versions through a config flag. The mkfwumdata tool +can generate metadata for both the supported versions. + Setting up the device for GPT partitioned storage - @@ -94,12 +104,12 @@ of. Each GPT partition entry in the GPT header has two GUIDs:: * UniquePartitionGUID The PartitionTypeGUID value should correspond to the -``image_type_uuid`` field of the FWU metadata. This field is used to +``image_type_guid`` field of the FWU metadata. This field is used to identify a given type of updatable firmware image, e.g. U-Boot, OP-TEE, FIP etc. This GUID should also be used for specifying the `--guid` parameter when generating the capsule. -The UniquePartitionGUID value should correspond to the ``image_uuid`` +The UniquePartitionGUID value should correspond to the ``image_guid`` field in the FWU metadata. This GUID is used to identify images of a given image type in different banks. @@ -108,8 +118,8 @@ metadata partitions. This would be the PartitionTypeGUID for the metadata partitions. Similarly, the UEFI specification defines the ESP GUID to be be used. -When generating the metadata, the ``image_type_uuid`` and the -``image_uuid`` values should match the *PartitionTypeGUID* and the +When generating the metadata, the ``image_type_guid`` and the +``image_guid`` values should match the *PartitionTypeGUID* and the *UniquePartitionGUID* values respectively. Performing the Update @@ -181,5 +191,5 @@ empty capsule would be:: Links - -* [1] https://developer.arm.com/documentation/den0118/a/ - FWU Specification +* [1] https://developer.arm.com/documentation/den0118/ - FWU Specification * [2] https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf - Dependable Boot Specification -- 2.34.1
[PATCH v3 16/20] tools: mkfwumdata: add logic to append vendor data to the FWU metadata
The version 2 of the FWU metadata allows for appending opaque vendor specific data to the metadata structure. Add support for appending this data to the metadata. The vendor specific data needs to be provided through a file, passed through a command-line parameter. Make corresponding changes to the tool's manpage. Signed-off-by: Sughosh Ganu --- Changes since V2: * Added documentation changes. doc/mkfwumdata.1 | 7 tools/mkfwumdata.c | 99 +++--- 2 files changed, 91 insertions(+), 15 deletions(-) diff --git a/doc/mkfwumdata.1 b/doc/mkfwumdata.1 index 5e61c615ea..2ed0fb100b 100644 --- a/doc/mkfwumdata.1 +++ b/doc/mkfwumdata.1 @@ -10,6 +10,7 @@ mkfwumdata \- create FWU metadata image .OP \-a activeidx .OP \-p previousidx .OP \-g +.OP \-V vendor-file .BI \-i\~ imagecount .BI \-b\~ bankcount .I UUIDs @@ -57,6 +58,12 @@ Convert the as GUIDs before use. . .TP +.B \-V +Pass +.IR vendor-file +for appending vendor data to the metadata. Supported only with version 2. +. +.TP .B \-i Specify there are .IR imagecount diff --git a/tools/mkfwumdata.c b/tools/mkfwumdata.c index 634453d421..fbc2067bc1 100644 --- a/tools/mkfwumdata.c +++ b/tools/mkfwumdata.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include @@ -36,9 +38,7 @@ typedef uint64_t u64; #include -/* TODO: Endianness conversion may be required for some arch. */ - -static const char *opts_short = "b:i:a:p:v:gh"; +static const char *opts_short = "b:i:a:p:v:V:gh"; static struct option options[] = { {"banks", required_argument, NULL, 'b'}, @@ -47,6 +47,7 @@ static struct option options[] = { {"active-bank", required_argument, NULL, 'a'}, {"previous-bank", required_argument, NULL, 'p'}, {"version", required_argument, NULL, 'v'}, + {"vendor-file", required_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, }; @@ -61,6 +62,7 @@ static void print_usage(void) "\t-a, --active-bank Active bank (default=0)\n" "\t-p, --previous-bankPrevious active bank (default=active_bank - 1)\n" "\t-g, --guid Use GUID instead of UUID\n" + "\t-V, --vendor-file Vendor data file to append to the metadata\n" "\t-h, --help print a help message\n" ); fprintf(stderr, " UUIDs list syntax:\n" @@ -80,6 +82,8 @@ struct fwu_mdata_object { size_t banks; size_t size; u8 version; + size_t vsize; + void *vbuf; struct fwu_mdata *mdata; }; @@ -98,7 +102,7 @@ static bool supported_mdata_version(unsigned long version) } static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks, - u8 version) + u8 version, size_t vendor_size) { struct fwu_mdata_object *mobj; @@ -115,6 +119,9 @@ static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks, sizeof(struct fwu_fw_store_desc) + (sizeof(struct fwu_image_entry) + sizeof(struct fwu_image_bank_info) * banks) * images; + + mobj->size += vendor_size; + mobj->vsize = vendor_size; } mobj->images = images; @@ -122,12 +129,21 @@ static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks, mobj->version = version; mobj->mdata = calloc(1, mobj->size); - if (!mobj->mdata) { - free(mobj); - return NULL; + if (!mobj->mdata) + goto alloc_err; + + if (vendor_size) { + mobj->vbuf = calloc(1, mobj->vsize); + if (!mobj->vbuf) + goto alloc_err; } return mobj; + +alloc_err: + free(mobj->mdata); + free(mobj); + return NULL; } static struct fwu_image_entry * @@ -297,6 +313,7 @@ static void fwu_fill_version_specific_mdata(struct fwu_mdata_object *mobj) static int fwu_parse_fill_uuids(struct fwu_mdata_object *mobj, char *uuids[]) { struct fwu_mdata *mdata = mobj->mdata; + char *vdata; int i, ret; mdata->version = mobj->version; @@ -311,24 +328,65 @@ static int fwu_parse_fill_uuids(struct fwu_mdata_object *mobj, char *uuids[]) return ret; } + if (mobj->vsize) { + vdata = (char *)mobj->mdata + (mobj->size - mobj->vsize); + memcpy(vdata, mobj->vbuf, mobj->vsize); + } + mdata->crc32 = crc32(0, (const unsigned char *)&mdata->version, mobj->size - sizeof(uint32_t)); return 0; } -static int -fwu_make_mdata(size_t images, size_t banks, u8 version, char *uuids[], - char *output) +static int fwu_rea
[PATCH v3 17/20] test: fwu: make changes to the FWU metadata access test
Make changes to the FWU metadata access tests corresponding to the changes in the FWU metadata access code. Signed-off-by: Sughosh Ganu --- Changes since V2: * Make changes to have the test work with v1 metadata. * Make changes to have the test work with updated logic in fwu code. test/dm/fwu_mdata.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/dm/fwu_mdata.c b/test/dm/fwu_mdata.c index 52018f610f..621ba647d9 100644 --- a/test/dm/fwu_mdata.c +++ b/test/dm/fwu_mdata.c @@ -93,6 +93,10 @@ static int dm_test_fwu_mdata_read(struct unit_test_state *uts) struct udevice *dev; struct fwu_mdata mdata = { 0 }; + ut_assertok(setup_blk_device(uts)); + ut_assertok(populate_mmc_disk_image(uts)); + ut_assertok(write_mmc_blk_device(uts)); + /* * Trigger lib/fwu_updates/fwu.c fwu_boottime_checks() * to populate g_dev global pointer in that library. @@ -100,9 +104,7 @@ static int dm_test_fwu_mdata_read(struct unit_test_state *uts) event_notify_null(EVT_MAIN_LOOP); ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev)); - ut_assertok(setup_blk_device(uts)); - ut_assertok(populate_mmc_disk_image(uts)); - ut_assertok(write_mmc_blk_device(uts)); + ut_assertok(fwu_init()); ut_assertok(fwu_get_mdata(&mdata)); @@ -118,18 +120,20 @@ static int dm_test_fwu_mdata_write(struct unit_test_state *uts) struct udevice *dev; struct fwu_mdata mdata = { 0 }; + ut_assertok(setup_blk_device(uts)); + ut_assertok(populate_mmc_disk_image(uts)); + ut_assertok(write_mmc_blk_device(uts)); + /* * Trigger lib/fwu_updates/fwu.c fwu_boottime_checks() * to populate g_dev global pointer in that library. */ event_notify_null(EVT_MAIN_LOOP); - ut_assertok(setup_blk_device(uts)); - ut_assertok(populate_mmc_disk_image(uts)); - ut_assertok(write_mmc_blk_device(uts)); ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev)); + ut_assertok(fwu_init()); ut_assertok(fwu_get_mdata(&mdata)); active_idx = (mdata.active_index + 1) % CONFIG_FWU_NUM_BANKS; -- 2.34.1
[PATCH v3 15/20] tools: mkfwumdata: add support for metadata version 2
Add support for generating the FWU metadata version 2. The tool now requires the version to be provided as a command-line option. Make corresponding changes to the tool's manpage. Signed-off-by: Sughosh Ganu --- Changes since V2: * Support both metadata versions instead of only v2. doc/mkfwumdata.1 | 9 ++- tools/mkfwumdata.c | 148 - 2 files changed, 127 insertions(+), 30 deletions(-) diff --git a/doc/mkfwumdata.1 b/doc/mkfwumdata.1 index 7dd718b26e..5e61c615ea 100644 --- a/doc/mkfwumdata.1 +++ b/doc/mkfwumdata.1 @@ -6,6 +6,7 @@ mkfwumdata \- create FWU metadata image . .SH SYNOPSIS .SY mkfwumdata +.OP \-v version .OP \-a activeidx .OP \-p previousidx .OP \-g @@ -28,6 +29,12 @@ creates metadata info to be used with FWU. Print usage information and exit. . .TP +.B \-v +Set +.IR version +as the metadata version to generate. Valid values 1 or 2. +. +.TP .B \-a Set .IR activeidx @@ -81,7 +88,7 @@ Create a metadata image with 2 banks and 1 image/bank, BankAct=0, BankPrev=1: .EX .in +4 $ \c -.B mkfwumdata \-a 0 \-p 1 \-b 2 \-i 1 \& +.B mkfwumdata \-v 2 \-a 0 \-p 1 \-b 2 \-i 1 \& .in +6 .B 17e86d77-41f9-4fd7-87ec-a55df9842de5,\& .B 10c36d7d-ca52-b843-b7b9-f9d6c501d108,\& diff --git a/tools/mkfwumdata.c b/tools/mkfwumdata.c index b2d90ca7c9..634453d421 100644 --- a/tools/mkfwumdata.c +++ b/tools/mkfwumdata.c @@ -10,28 +10,35 @@ #include #include #include -#include #include +#include +#include #include -/* This will dynamically allocate the fwu_mdata */ -#define CONFIG_FWU_NUM_BANKS 0 -#define CONFIG_FWU_NUM_IMAGES_PER_BANK 0 - -/* Since we can not include fwu.h, redefine version here. */ -#define FWU_MDATA_VERSION 1 - typedef uint8_t u8; typedef int16_t s16; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; +#undef CONFIG_FWU_NUM_BANKS +#undef CONFIG_FWU_NUM_IMAGES_PER_BANK + +/* This will dynamically allocate the fwu_mdata */ +#define CONFIG_FWU_NUM_BANKS 0 +#define CONFIG_FWU_NUM_IMAGES_PER_BANK 0 + +/* version 2 supports maximum of 4 banks */ +#define MAX_BANKS_V2 4 + +#define BANK_INVALID (u8)0xFF +#define BANK_ACCEPTED (u8)0xFC + #include /* TODO: Endianness conversion may be required for some arch. */ -static const char *opts_short = "b:i:a:p:gh"; +static const char *opts_short = "b:i:a:p:v:gh"; static struct option options[] = { {"banks", required_argument, NULL, 'b'}, @@ -39,6 +46,7 @@ static struct option options[] = { {"guid", required_argument, NULL, 'g'}, {"active-bank", required_argument, NULL, 'a'}, {"previous-bank", required_argument, NULL, 'p'}, + {"version", required_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}, }; @@ -49,6 +57,7 @@ static void print_usage(void) fprintf(stderr, "Options:\n" "\t-i, --images Number of images (mandatory)\n" "\t-b, --banksNumber of banks (mandatory)\n" + "\t-v, --version Metadata version (mandatory)\n" "\t-a, --active-bank Active bank (default=0)\n" "\t-p, --previous-bankPrevious active bank (default=active_bank - 1)\n" "\t-g, --guid Use GUID instead of UUID\n" @@ -70,13 +79,26 @@ struct fwu_mdata_object { size_t images; size_t banks; size_t size; + u8 version; struct fwu_mdata *mdata; }; static int previous_bank, active_bank; static bool __use_guid; -static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks) +static bool supported_mdata_version(unsigned long version) +{ + switch (version) { + case 1: + case 2: + return true; + default: + return false; + } +} + +static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks, + u8 version) { struct fwu_mdata_object *mobj; @@ -84,11 +106,20 @@ static struct fwu_mdata_object *fwu_alloc_mdata(size_t images, size_t banks) if (!mobj) return NULL; - mobj->size = sizeof(struct fwu_mdata) + - (sizeof(struct fwu_image_entry) + -sizeof(struct fwu_image_bank_info) * banks) * images; + if (version == 1) { + mobj->size = sizeof(struct fwu_mdata) + + (sizeof(struct fwu_image_entry) + +sizeof(struct fwu_image_bank_info) * banks) * images; + } else { + mobj->size = sizeof(struct fwu_mdata) + + sizeof(struct fwu_fw_store_desc) + + (sizeof(struct fwu_image_entry) + +sizeof(struct fwu_image_bank_info) * banks) * images; + } + mobj->images = images; m
[PATCH v3 14/20] cmd: fwu: make changes for supporting FWU metadata version 2
Add support for displaying data specific to FWU metadata version 2. Because the size of the v2 metadata structure is read from the structure itself, allocate memory for the metadata structure by first getting the size of the structure. Signed-off-by: Sughosh Ganu --- Changes since V2: * Earlier patch was migrating to v2 only support. These changes support both versions. cmd/fwu_mdata.c | 39 ++- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c index 5ecda455df..3c8be576ac 100644 --- a/cmd/fwu_mdata.c +++ b/cmd/fwu_mdata.c @@ -13,27 +13,33 @@ #include -static void print_mdata(struct fwu_mdata *mdata) +static void print_mdata(struct fwu_data *data) { int i, j; struct fwu_image_entry *img_entry; struct fwu_image_bank_info *img_info; printf("\tFWU Metadata\n"); - printf("crc32: %#x\n", mdata->crc32); - printf("version: %#x\n", mdata->version); - printf("active_index: %#x\n", mdata->active_index); - printf("previous_active_index: %#x\n", mdata->previous_active_index); + printf("crc32: %#x\n", data->crc32); + printf("version: %#x\n", data->version); + printf("active_index: %#x\n", data->active_index); + printf("previous_active_index: %#x\n", data->previous_active_index); + + if (data->version == 2) { + for (i = 0; i < 4; i++) + printf("bank_state[%d]: %#x\n", + i, data->bank_state[i]); + } printf("\tImage Info\n"); for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { - img_entry = &mdata->img_entry[i]; + img_entry = &data->fwu_images[i]; printf("\nImage Type Guid: %pUL\n", - &img_entry->image_type_uuid); - printf("Location Guid: %pUL\n", &img_entry->location_uuid); + &img_entry->image_type_guid); + printf("Location Guid: %pUL\n", &img_entry->location_guid); for (j = 0; j < CONFIG_FWU_NUM_BANKS; j++) { img_info = &img_entry->img_bank_info[j]; - printf("Image Guid: %pUL\n", &img_info->image_uuid); + printf("Image Guid: %pUL\n", &img_info->image_guid); printf("Image Acceptance: %s\n", img_info->accepted == 0x1 ? "yes" : "no"); } @@ -43,20 +49,11 @@ static void print_mdata(struct fwu_mdata *mdata) int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - int ret = CMD_RET_SUCCESS, res; - struct fwu_mdata mdata; - - res = fwu_get_mdata(&mdata); - if (res < 0) { - log_err("Unable to get valid FWU metadata\n"); - ret = CMD_RET_FAILURE; - goto out; - } + struct fwu_data *data = fwu_get_data(); - print_mdata(&mdata); + print_mdata(data); -out: - return ret; + return CMD_RET_SUCCESS; } U_BOOT_CMD( -- 2.34.1
[PATCH v3 13/20] fwu: mtd: obtain image information from version agnostic structure
Make changes to the functions used for generating the DFU's alt variable so that the FWU image information is obtained from the common version agnostic structure instead of reading the metadata. While here, also update the name of the field used for storing the image GUID in the FWU metadata. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch lib/fwu_updates/fwu_mtd.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/fwu_updates/fwu_mtd.c b/lib/fwu_updates/fwu_mtd.c index f4e0e3107b..e8211dd5ba 100644 --- a/lib/fwu_updates/fwu_mtd.c +++ b/lib/fwu_updates/fwu_mtd.c @@ -136,7 +136,7 @@ static int gen_image_alt_info(char *buf, size_t len, /* Query a partition by image UUID */ bank = &img->img_bank_info[i]; - uuid_bin_to_str(bank->image_uuid.b, uuidbuf, UUID_STR_FORMAT_STD); + uuid_bin_to_str(bank->image_guid.b, uuidbuf, UUID_STR_FORMAT_STD); mtd_img_info = mtd_img_by_uuid(uuidbuf); if (!mtd_img_info) { @@ -163,17 +163,13 @@ static int gen_image_alt_info(char *buf, size_t len, int fwu_gen_alt_info_from_mtd(char *buf, size_t len, struct mtd_info *mtd) { - struct fwu_mdata mdata; int i, l, ret; - - ret = fwu_get_mdata(&mdata); - if (ret < 0) { - log_err("Failed to get the FWU mdata.\n"); - return ret; - } + struct fwu_data *data = fwu_get_data(); + struct fwu_image_entry *img_entry; for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { - ret = gen_image_alt_info(buf, len, &mdata.img_entry[i], mtd); + img_entry = &data->fwu_images[i]; + ret = gen_image_alt_info(buf, len, img_entry, mtd); if (ret) break; -- 2.34.1
[PATCH v3 12/20] fwu: mtd: get MTD partition specific info from driver
Information about FWU images on MTD partitions is now stored with the corresponding driver instead of a global variable. Get this information from the driver. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch lib/fwu_updates/fwu_mtd.c | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/fwu_updates/fwu_mtd.c b/lib/fwu_updates/fwu_mtd.c index d48de19009..f4e0e3107b 100644 --- a/lib/fwu_updates/fwu_mtd.c +++ b/lib/fwu_updates/fwu_mtd.c @@ -15,16 +15,21 @@ #include -struct fwu_mtd_image_info -fwu_mtd_images[CONFIG_FWU_NUM_BANKS * CONFIG_FWU_NUM_IMAGES_PER_BANK]; - static struct fwu_mtd_image_info *mtd_img_by_uuid(const char *uuidbuf) { - int num_images = ARRAY_SIZE(fwu_mtd_images); + int num_images; + struct fwu_mdata_mtd_priv *mtd_priv = dev_get_priv(fwu_get_dev()); + struct fwu_mtd_image_info *image_info = mtd_priv->fwu_mtd_images; + + if (!image_info) + return NULL; + + num_images = CONFIG_FWU_NUM_BANKS * + CONFIG_FWU_NUM_IMAGES_PER_BANK; for (int i = 0; i < num_images; i++) - if (!strcmp(uuidbuf, fwu_mtd_images[i].uuidbuf)) - return &fwu_mtd_images[i]; + if (!strcmp(uuidbuf, image_info[i].uuidbuf)) + return &image_info[i]; return NULL; } -- 2.34.1
[PATCH v3 11/20] fwu: mtd: remove unused argument from function call
The third argument passed to the function gen_image_alt_info() is not used and is superfluous. Remove this unused argument from the function call. Fixes: 4898679e190 (FWU: Add FWU metadata access driver for MTD storage regions) Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch lib/fwu_updates/fwu_mtd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fwu_updates/fwu_mtd.c b/lib/fwu_updates/fwu_mtd.c index 69cd3d7001..d48de19009 100644 --- a/lib/fwu_updates/fwu_mtd.c +++ b/lib/fwu_updates/fwu_mtd.c @@ -107,7 +107,7 @@ __weak int fwu_plat_get_alt_num(struct udevice *dev, efi_guid_t *image_id, return fwu_mtd_get_alt_num(image_id, alt_num, "nor1"); } -static int gen_image_alt_info(char *buf, size_t len, int sidx, +static int gen_image_alt_info(char *buf, size_t len, struct fwu_image_entry *img, struct mtd_info *mtd) { char *p = buf, *end = buf + len; @@ -168,8 +168,7 @@ int fwu_gen_alt_info_from_mtd(char *buf, size_t len, struct mtd_info *mtd) } for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { - ret = gen_image_alt_info(buf, len, i * CONFIG_FWU_NUM_BANKS, -&mdata.img_entry[i], mtd); + ret = gen_image_alt_info(buf, len, &mdata.img_entry[i], mtd); if (ret) break; -- 2.34.1
[PATCH v3 10/20] fwu: add config symbols for enabling FWU metadata versions
Support has been added for version 2 of the FWU metadata structure. Add config symbols to enable either of the two versions. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch lib/fwu_updates/Kconfig | 14 ++ lib/fwu_updates/Makefile | 2 ++ 2 files changed, 16 insertions(+) diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig index d35247d0e5..51b7fbbefd 100644 --- a/lib/fwu_updates/Kconfig +++ b/lib/fwu_updates/Kconfig @@ -31,4 +31,18 @@ config FWU_TRIAL_STATE_CNT the platform is allowed to boot in Trial State after an update. +config FWU_MDATA_V1 + bool "Enable support FWU Metadata version 1" + help + The FWU specification supports two versions of the + metadata structure. This option enables support for FWU + Metadata version 1 access. + +config FWU_MDATA_V2 + bool "Enable support FWU Metadata version 2" + help + The FWU specification supports two versions of the + metadata structure. This option enables support for FWU + Metadata version 2 access. + endif diff --git a/lib/fwu_updates/Makefile b/lib/fwu_updates/Makefile index c9e3c06b48..3681bef46c 100644 --- a/lib/fwu_updates/Makefile +++ b/lib/fwu_updates/Makefile @@ -6,3 +6,5 @@ obj-$(CONFIG_FWU_MULTI_BANK_UPDATE) += fwu.o obj-$(CONFIG_FWU_MDATA_GPT_BLK) += fwu_gpt.o obj-$(CONFIG_FWU_MDATA_MTD) += fwu_mtd.o +obj-$(CONFIG_FWU_MDATA_V1) += fwu_v1.o +obj-$(CONFIG_FWU_MDATA_V2) += fwu_v2.o -- 2.34.1
[PATCH v3 09/20] capsule: fwu: transition the platform state on a successful update
Transition the platform to either Trial State or Regular State on a successful update. Do this by calling the fwu_state_machine_updates() API function. For version 1 of the FWU metadata, the transition to Trial State is done by starting the Trial State counter, while for version 2, in addition to the counter, the bank_state field of the FWU metadata is also updated to Valid. For transitioning the platform to Regular State, no action is needed with version 1 of the FWU metadata structure, while for version 2, the bank_state field is set to Accepted. Signed-off-by: Sughosh Ganu --- Changes since V2: * Earlier patch was catering to v2 only support. These changes support both versions of metadata. lib/efi_loader/efi_capsule.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index de0d49ebeb..0937800e58 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -480,6 +480,11 @@ static __maybe_unused efi_status_t fwu_empty_capsule_process( if (ret != EFI_SUCCESS) log_err("Unable to set the Accept bit for the image %pUs\n", image_guid); + + status = fwu_state_machine_updates(0, active_idx); + if (status < 0) + ret = EFI_DEVICE_ERROR; + } return ret; @@ -521,11 +526,10 @@ static __maybe_unused efi_status_t fwu_post_update_process(bool fw_accept_os) log_err("Failed to update FWU metadata index values\n"); } else { log_debug("Successfully updated the active_index\n"); - if (fw_accept_os) { - status = fwu_trial_state_ctr_start(); - if (status < 0) - ret = EFI_DEVICE_ERROR; - } + status = fwu_state_machine_updates(fw_accept_os ? 1 : 0, + update_index); + if (status < 0) + ret = EFI_DEVICE_ERROR; } return ret; -- 2.34.1
[PATCH v3 08/20] fwu: make changes to access version agnostic structure fields
With addition of support for version 2 of the FWU metadata structure, the metadata information is collected into a version agnostic structure. Make changes to the FWU functions so that the information that was earlier obtained by reading the metadata structure is now obtained through this version agnostic structure. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch include/fwu.h | 49 +- lib/fwu_updates/fwu.c | 204 -- 2 files changed, 186 insertions(+), 67 deletions(-) diff --git a/include/fwu.h b/include/fwu.h index 082b5481d1..77ec65e618 100644 --- a/include/fwu.h +++ b/include/fwu.h @@ -79,9 +79,18 @@ struct fwu_mdata_ops { bool primary, uint32_t size); }; -#define FWU_MDATA_VERSION 0x1 #define FWU_IMAGE_ACCEPTED 0x1 +#define FWU_BANK_INVALID (uint8_t)0xFF +#define FWU_BANK_VALID (uint8_t)0xFE +#define FWU_BANK_ACCEPTED (uint8_t)0xFC + +enum { + PRIMARY_PART = 1, + SECONDARY_PART, + BOTH_PARTS, +}; + /* * GUID value defined in the FWU specification for identification * of the FWU metadata partition. @@ -313,6 +322,44 @@ int fwu_gen_alt_info_from_mtd(char *buf, size_t len, struct mtd_info *mtd); */ int fwu_mtd_get_alt_num(efi_guid_t *image_guid, u8 *alt_num, const char *mtd_dev); +/** + * fwu_mdata_copies_allocate() - Allocate memory for metadata + * @mdata_size: Size of the metadata structure + * + * Allocate memory for storing both the copies of the FWU metadata. The + * copies are then used as a cache for storing FWU metadata contents. + * + * Return: 0 if OK, -ve on error + */ +int fwu_mdata_copies_allocate(u32 mdata_size); + +/** + * fwu_get_dev() - Return the FWU metadata device + * + * Return the pointer to the FWU metadata device. + * + * Return: Pointer to the FWU metadata dev + */ +struct udevice *fwu_get_dev(void); + +/** + * fwu_get_data() - Return the version agnostic FWU structure + * + * Return the pointer to the version agnostic FWU structure. + * + * Return: Pointer to the FWU data structure + */ +struct fwu_data *fwu_get_data(void); + +/** + * fwu_sync_mdata() - Update given meta-data partition(s) with the copy provided + * @data: FWU Data structure + * @part: Bitmask of FWU metadata partitions to be written to + * + * Return: 0 if OK, -ve on error + */ +int fwu_sync_mdata(struct fwu_mdata *mdata, int part); + /** * fwu_populate_mdata_image_info() - Populate the image information * of the metadata diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c index 86518108c2..5dfea2a4d8 100644 --- a/lib/fwu_updates/fwu.c +++ b/lib/fwu_updates/fwu.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -17,7 +18,7 @@ #include -static struct fwu_mdata g_mdata; /* = {0} makes uninit crc32 always invalid */ +struct fwu_data g_fwu_data; static struct udevice *g_dev; static u8 in_trial; static u8 boottime_check; @@ -27,12 +28,6 @@ enum { IMAGE_ACCEPT_CLEAR, }; -enum { - PRIMARY_PART = 1, - SECONDARY_PART, - BOTH_PARTS, -}; - static int trial_counter_update(u16 *trial_state_ctr) { bool delete; @@ -106,23 +101,9 @@ out: return ret; } -static int in_trial_state(struct fwu_mdata *mdata) +static u32 in_trial_state(void) { - u32 i, active_bank; - struct fwu_image_entry *img_entry; - struct fwu_image_bank_info *img_bank_info; - - active_bank = mdata->active_index; - img_entry = &mdata->img_entry[0]; - for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { - img_bank_info = &img_entry[i].img_bank_info[active_bank]; - if (!img_bank_info->accepted) { - log_info("System booting in Trial State\n"); - return 1; - } - } - - return 0; + return g_fwu_data.trial_state; } static int fwu_get_image_type_id(u8 image_index, efi_guid_t *image_type_id) @@ -141,17 +122,70 @@ static int fwu_get_image_type_id(u8 image_index, efi_guid_t *image_type_id) return -ENOENT; } +static int mdata_crc_check(struct fwu_mdata *mdata) +{ + int ret; + u32 calc_crc32; + uint32_t mdata_size; + void *buf = &mdata->version; + + ret = fwu_get_mdata_size(&mdata_size); + if (ret) + return ret; + + calc_crc32 = crc32(0, buf, mdata_size - sizeof(u32)); + return calc_crc32 == mdata->crc32 ? 0 : -EINVAL; +} + +static void fwu_data_crc_update(uint32_t crc32) +{ + g_fwu_data.crc32 = crc32; +} + +/** + * fwu_get_data() - Return the version agnostic FWU structure + * + * Return the pointer to the version agnostic FWU structure. + * + * Return: Pointer to the FWU data structure + */ +struct fwu_data *fwu_get_data(void) +{ + return &g_fwu_data; +} + +static void fwu_populate_mdata_bank_index(struct fwu_data *fwu_data) +{ + struct fwu_mdata *mdata = fwu_data->fwu
[PATCH v3 07/20] fwu: metadata: add functions for handling version specific metadata fields
Support is being added in U-Boot for version 2 of the FWU metadata. Support for this version is to co-exist with version 1 support. To achieve this, a common, version agnostic structure has been added to keep information provided by the FWU metadata structure. Add API's to handle the version specific FWU metadata fields. The version agnostic structure gets initialized at boot by reading the FWU metadata. Updates to the FWU metadata result in the API's getting called to populate the version specific fields of the strucure, before the metadata gets written to the storage media. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch include/fwu.h| 57 + lib/fwu_updates/fwu_v1.c | 167 + lib/fwu_updates/fwu_v2.c | 260 +++ 3 files changed, 484 insertions(+) create mode 100644 lib/fwu_updates/fwu_v1.c create mode 100644 lib/fwu_updates/fwu_v2.c diff --git a/include/fwu.h b/include/fwu.h index e681e91027..082b5481d1 100644 --- a/include/fwu.h +++ b/include/fwu.h @@ -313,4 +313,61 @@ int fwu_gen_alt_info_from_mtd(char *buf, size_t len, struct mtd_info *mtd); */ int fwu_mtd_get_alt_num(efi_guid_t *image_guid, u8 *alt_num, const char *mtd_dev); +/** + * fwu_populate_mdata_image_info() - Populate the image information + * of the metadata + * @data: Version agnostic FWU metadata information + * + * Populate the image information in the FWU metadata by copying it + * from the version agnostic structure. This is done before the + * metadata gets written to the storage media. + * + * Return: None + */ +void fwu_populate_mdata_image_info(struct fwu_data *data); + +/** + * fwu_get_mdata_size() - Get the FWU metadata size + * @mdata_size: Size of the metadata structure + * + * Get the size of the FWU metadata from the structure. This is later used + * to allocate memory for the structure. + * + * Return: 0 if OK, -ve on error + */ +int fwu_get_mdata_size(uint32_t *mdata_size); + +/** + * fwu_state_machine_updates() - Update FWU state of the platform + * @trial_state: Is platform transitioning into Trial State + * @update_index: Bank number to which images have been updated + * + * On successful completion of updates, transition the platform to + * either Trial State or Regular State. + * + * To transition the platform to Trial State, start the + * TrialStateCtr counter, followed by setting the value of bank_state + * field of the metadata to Valid state(applicable only in version 2 + * of metadata). + * + * In case, the platform is to transition directly to Regular State, + * update the bank_state field of the metadata to Accepted + * state(applicable only in version 2 of metadata). + * + * Return: 0 if OK, -ve on error + */ +int fwu_state_machine_updates(bool trial_state, uint32_t update_index); + +/** + * fwu_init() - FWU specific initialisations + * + * Carry out some FWU specific initialisations including allocation + * of memory for the metadata copies, and reading the FWU metadata + * copies into the allocated memory. The metadata fields are then + * copied into a version agnostic structure. + * + * Return: 0 if OK, -ve on error + */ +int fwu_init(void); + #endif /* _FWU_H_ */ diff --git a/lib/fwu_updates/fwu_v1.c b/lib/fwu_updates/fwu_v1.c new file mode 100644 index 00..efb8d51500 --- /dev/null +++ b/lib/fwu_updates/fwu_v1.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2024, Linaro Limited + */ + +#include +#include + +#include + +#define FWU_MDATA_VERSION 0x1U + +static uint32_t fwu_check_trial_state(struct fwu_mdata *mdata, uint32_t bank) +{ + u32 i; + struct fwu_image_entry *img_entry; + struct fwu_image_bank_info *img_bank_info; + + img_entry = &mdata->img_entry[0]; + for (i = 0; i < CONFIG_FWU_NUM_IMAGES_PER_BANK; i++) { + img_bank_info = &img_entry[i].img_bank_info[bank]; + if (!img_bank_info->accepted) { + return 1; + } + } + + return 0; +} + +static void fwu_data_init(void) +{ + size_t image_info_size; + void *dst_img_info, *src_img_info; + struct fwu_data *data = fwu_get_data(); + struct fwu_mdata *mdata = data->fwu_mdata; + + data->crc32 = mdata->crc32; + data->version = mdata->version; + data->active_index = mdata->active_index; + data->previous_active_index = mdata->previous_active_index; + + data->metadata_size = sizeof(struct fwu_mdata); + data->num_banks = CONFIG_FWU_NUM_BANKS; + data->num_images = CONFIG_FWU_NUM_IMAGES_PER_BANK; + fwu_plat_get_bootidx(&data->boot_index); + data->trial_state = fwu_check_trial_state(mdata, data->boot_index); + + src_img_info = &mdata->img_entry[0]; + dst_img_info = &data->fwu_images[0]; + image_info_size = sizeof(data->fwu_images); + + memcpy(dst_img_info, src_img_info, image_info_size); +} + +static int fw
[PATCH v3 06/20] fwu: metadata: add a version agnostic structure
The FWU specification now has two versions of the FWU metadata structure, and both are to be supported. Introduce a version agnostic structure for storing information about the FWU updatable images. This allows for a split of common version agnostic FWU code and version specific code. The version specific code is then responsible for arranging the data as per the corresponding metadata structure before it gets written to the metadata partitions. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch include/fwu.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/include/fwu.h b/include/fwu.h index 6c4d218e13..e681e91027 100644 --- a/include/fwu.h +++ b/include/fwu.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -35,6 +36,23 @@ struct fwu_mdata_mtd_priv { struct fwu_mtd_image_info *fwu_mtd_images; }; +struct fwu_data { + uint32_t crc32; + uint32_t version; + uint32_t active_index; + uint32_t previous_active_index; + uint32_t metadata_size; + uint32_t boot_index; + uint32_t num_banks; + uint32_t num_images; + uint8_t bank_state[4]; + bool trial_state; + + struct fwu_mdata *fwu_mdata; + + struct fwu_image_entry fwu_images[CONFIG_FWU_NUM_IMAGES_PER_BANK]; +}; + struct fwu_mdata_ops { /** * read_mdata() - Populate the asked FWU metadata copy -- 2.34.1
[PATCH v3 05/20] fwu: metadata: add support for version 2 of the structure
Add support for version 2 of the FWU metadata structure. The top level structure is kept separate through a config symbol. Most of the fields, primarily used for providing information on updatable images are common across the two versions. Also change a few existing structure members used for image identification to reflect the fact that these are GUIDs, and not UUIDs. Signed-off-by: Sughosh Ganu --- Changes since V2: * New patch which retains support for V1 of metadata include/fwu_mdata.h | 71 + 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/include/fwu_mdata.h b/include/fwu_mdata.h index 56189e2f40..d2521f39b4 100644 --- a/include/fwu_mdata.h +++ b/include/fwu_mdata.h @@ -11,7 +11,7 @@ /** * struct fwu_image_bank_info - firmware image information - * @image_uuid: Guid value of the image in this bank + * @image_guid: Guid value of the image in this bank * @accepted: Acceptance status of the image * @reserved: Reserved * @@ -20,15 +20,15 @@ * acceptance status */ struct fwu_image_bank_info { - efi_guid_t image_uuid; + efi_guid_t image_guid; uint32_t accepted; uint32_t reserved; } __packed; /** * struct fwu_image_entry - information for a particular type of image - * @image_type_uuid: Guid value for identifying the image type - * @location_uuid: Guid of the storage volume where the image is located + * @image_type_guid: Guid value for identifying the image type + * @location_guid: Guid of the storage volume where the image is located * @img_bank_info: Array containing properties of images * * This structure contains information on various types of updatable @@ -36,11 +36,35 @@ struct fwu_image_bank_info { * information per bank. */ struct fwu_image_entry { - efi_guid_t image_type_uuid; - efi_guid_t location_uuid; + efi_guid_t image_type_guid; + efi_guid_t location_guid; struct fwu_image_bank_info img_bank_info[CONFIG_FWU_NUM_BANKS]; } __packed; +/** + * struct fwu_fw_store_desc - FWU updatable image information + * @num_banks: Number of firmware banks + * @num_images: Number of images per bank + * @img_entry_size: The size of the img_entry array + * @bank_info_entry_size: The size of the img_bank_info array + * @img_entry: Array of image entries each giving information on a image + * + * This image descriptor structure contains information on the number of + * updatable banks and images per bank. It also gives the total sizes of + * the fwu_image_entry and fwu_image_bank_info arrays. This structure is + * only present in version 2 of the metadata structure. + */ +struct fwu_fw_store_desc { + uint8_t num_banks; + uint8_t reserved; + uint16_t num_images; + uint16_t img_entry_size; + uint16_t bank_info_entry_size; + + struct fwu_image_entry img_entry[CONFIG_FWU_NUM_IMAGES_PER_BANK]; +} __packed; + +#if defined(CONFIG_FWU_MDATA_V1) /** * struct fwu_mdata - FWU metadata structure for multi-bank updates * @crc32: crc32 value for the FWU metadata @@ -65,4 +89,39 @@ struct fwu_mdata { struct fwu_image_entry img_entry[CONFIG_FWU_NUM_IMAGES_PER_BANK]; } __packed; +#else /* CONFIG_FWU_MDATA_V1 */ +/** + * struct fwu_mdata - FWU metadata structure for multi-bank updates + * @crc32: crc32 value for the FWU metadata + * @version: FWU metadata version + * @active_index: Index of the bank currently used for booting images + * @previous_active_inde: Index of the bank used before the current bank + *being used for booting + * @metadata_size: Size of the entire metadata structure, including the + * image descriptors + * @desc_offset: The offset from the start of this structure where the + * image descriptor structure starts. 0 if absent + * @bank_state: State of each bank, valid, invalid or accepted + * @fw_desc: The structure describing the FWU updatable images + * + * This is the top level structure used to store all information for performing + * multi bank updates on the platform. This contains info on the bank being + * used to boot along with the information on state of individual banks. + */ +struct fwu_mdata { + uint32_t crc32; + uint32_t version; + uint32_t active_index; + uint32_t previous_active_index; + uint32_t metadata_size; + uint16_t desc_offset; + uint16_t reserved1; + uint8_t bank_state[4]; + uint32_t reserved2; + + // struct fwu_fw_store_desc fw_desc; +} __packed; + +#endif /* CONFIG_FWU_MDATA_V1 */ + #endif /* _FWU_MDATA_H_ */ -- 2.34.1
[PATCH v3 04/20] drivers: fwu: mtd: allocate buffer for image info dynamically
The FWU metadata access driver for MTD partitioned devices currently uses a statically allocated array for storing the updatable image information. This array depends on the number of banks and images per bank. With migration of the FWU metadata to version 2, these parameters are now obtained at runtime from the metadata. Make changes to the FWU metadata access driver for MTD devices to allocate memory for the image information dynamically in the driver's probe function, after having obtained the number of banks and images per bank by reading the metadata. Move the image information as part of the driver's private structure, instead of using a global variable. Signed-off-by: Sughosh Ganu --- Changes since V2: None drivers/fwu-mdata/raw_mtd.c | 68 +++-- include/fwu.h | 9 + 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/drivers/fwu-mdata/raw_mtd.c b/drivers/fwu-mdata/raw_mtd.c index 9f3f1dc213..78a709f766 100644 --- a/drivers/fwu-mdata/raw_mtd.c +++ b/drivers/fwu-mdata/raw_mtd.c @@ -12,22 +12,11 @@ #include #include -/* Internal helper structure to move data around */ -struct fwu_mdata_mtd_priv { - struct mtd_info *mtd; - char pri_label[50]; - char sec_label[50]; - u32 pri_offset; - u32 sec_offset; -}; - enum fwu_mtd_op { FWU_MTD_READ, FWU_MTD_WRITE, }; -extern struct fwu_mtd_image_info fwu_mtd_images[]; - static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size) { return !do_div(size, mtd->erasesize); @@ -134,7 +123,7 @@ static int flash_partition_offset(struct udevice *dev, const char *part_name, fd return (int)size; } -static int fwu_mdata_mtd_of_to_plat(struct udevice *dev) +static int get_fwu_mdata_dev(struct udevice *dev) { struct fwu_mdata_mtd_priv *mtd_priv = dev_get_priv(dev); const fdt32_t *phandle_p = NULL; @@ -144,8 +133,6 @@ static int fwu_mdata_mtd_of_to_plat(struct udevice *dev) fdt_addr_t offset; int ret, size; u32 phandle; - ofnode bank; - int off_img; /* Find the FWU mdata storage device */ phandle_p = ofnode_get_property(dev_ofnode(dev), @@ -199,8 +186,28 @@ static int fwu_mdata_mtd_of_to_plat(struct udevice *dev) return ret; mtd_priv->sec_offset = offset; - off_img = 0; + return 0; +} + +static int fwu_mtd_image_info_populate(struct udevice *dev, u8 nbanks, + u16 nimages) +{ + struct fwu_mtd_image_info *mtd_images; + struct fwu_mdata_mtd_priv *mtd_priv = dev_get_priv(dev); + struct udevice *mtd_dev = mtd_priv->mtd->dev; + fdt_addr_t offset; + ofnode bank; + int off_img; + u32 total_images; + total_images = nbanks * nimages; + mtd_priv->fwu_mtd_images = malloc(sizeof(struct fwu_mtd_image_info) * + total_images); + if (!mtd_priv->fwu_mtd_images) + return -ENOMEM; + + off_img = 0; + mtd_images = mtd_priv->fwu_mtd_images; ofnode_for_each_subnode(bank, dev_ofnode(dev)) { int bank_num, bank_offset, bank_size; const char *bank_name; @@ -219,8 +226,7 @@ static int fwu_mdata_mtd_of_to_plat(struct udevice *dev) int image_num, image_offset, image_size; const char *uuid; - if (off_img == CONFIG_FWU_NUM_BANKS * - CONFIG_FWU_NUM_IMAGES_PER_BANK) { + if (off_img == total_images) { log_err("DT provides more images than configured!\n"); break; } @@ -230,11 +236,11 @@ static int fwu_mdata_mtd_of_to_plat(struct udevice *dev) ofnode_read_u32(image, "offset", &image_offset); ofnode_read_u32(image, "size", &image_size); - fwu_mtd_images[off_img].start = bank_offset + image_offset; - fwu_mtd_images[off_img].size = image_size; - fwu_mtd_images[off_img].bank_num = bank_num; - fwu_mtd_images[off_img].image_num = image_num; - strcpy(fwu_mtd_images[off_img].uuidbuf, uuid); + mtd_images[off_img].start = bank_offset + image_offset; + mtd_images[off_img].size = image_size; + mtd_images[off_img].bank_num = bank_num; + mtd_images[off_img].image_num = image_num; + strcpy(mtd_images[off_img].uuidbuf, uuid); log_debug("\tImage%d: %s @0x%x\n\n", image_num, uuid, bank_offset + image_offset); off_img++; @@ -246,8 +252,21 @@ static int fwu_mdata_mtd_of_to_plat(struct udevice *dev)
[PATCH v3 03/20] drivers: fwu: add the size parameter to the metadata access API's
In version 2 of the metadata structure, the size of the structure cannot be determined statically at build time. The structure is now broken into the top level structure which contains a field indicating the total size of the structure. Add a size parameter to the metadata access API functions to indicate the number of bytes to be accessed. This is then used to either read the entire structure, or only the top level structure. Signed-off-by: Sughosh Ganu --- Changes since V2: None drivers/fwu-mdata/fwu-mdata-uclass.c | 10 ++ drivers/fwu-mdata/gpt_blk.c | 23 +-- drivers/fwu-mdata/raw_mtd.c | 10 ++ include/fwu.h| 14 ++ 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/drivers/fwu-mdata/fwu-mdata-uclass.c b/drivers/fwu-mdata/fwu-mdata-uclass.c index 0a8edaaa41..145479bab0 100644 --- a/drivers/fwu-mdata/fwu-mdata-uclass.c +++ b/drivers/fwu-mdata/fwu-mdata-uclass.c @@ -20,7 +20,8 @@ * * Return: 0 if OK, -ve on error */ -int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary) +int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary, + uint32_t size) { const struct fwu_mdata_ops *ops = device_get_ops(dev); @@ -29,7 +30,7 @@ int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary) return -ENOSYS; } - return ops->read_mdata(dev, mdata, primary); + return ops->read_mdata(dev, mdata, primary, size); } /** @@ -37,7 +38,8 @@ int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary) * * Return: 0 if OK, -ve on error */ -int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary) +int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary, + uint32_t size) { const struct fwu_mdata_ops *ops = device_get_ops(dev); @@ -46,7 +48,7 @@ int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary) return -ENOSYS; } - return ops->write_mdata(dev, mdata, primary); + return ops->write_mdata(dev, mdata, primary, size); } UCLASS_DRIVER(fwu_mdata) = { diff --git a/drivers/fwu-mdata/gpt_blk.c b/drivers/fwu-mdata/gpt_blk.c index c7284916c4..97eac3611f 100644 --- a/drivers/fwu-mdata/gpt_blk.c +++ b/drivers/fwu-mdata/gpt_blk.c @@ -81,15 +81,14 @@ static int gpt_get_mdata_disk_part(struct blk_desc *desc, return -ENOENT; } -static int gpt_read_write_mdata(struct blk_desc *desc, - struct fwu_mdata *mdata, - u8 access, u32 part_num) +static int gpt_read_write_mdata(struct blk_desc *desc, struct fwu_mdata *mdata, + u8 access, u32 part_num, u32 size) { int ret; u32 len, blk_start, blkcnt; struct disk_partition info; - ALLOC_CACHE_ALIGN_BUFFER_PAD(struct fwu_mdata, mdata_aligned, 1, + ALLOC_CACHE_ALIGN_BUFFER_PAD(u8, mdata_aligned, size, desc->blksz); if (!mdata) @@ -101,7 +100,7 @@ static int gpt_read_write_mdata(struct blk_desc *desc, return -ENOENT; } - len = sizeof(*mdata); + len = size; blkcnt = BLOCK_CNT(len, desc); if (blkcnt > info.size) { log_debug("Block count exceeds FWU metadata partition size\n"); @@ -114,7 +113,7 @@ static int gpt_read_write_mdata(struct blk_desc *desc, log_debug("Error reading FWU metadata from the device\n"); return -EIO; } - memcpy(mdata, mdata_aligned, sizeof(struct fwu_mdata)); + memcpy(mdata, mdata_aligned, size); } else { if (blk_dwrite(desc, blk_start, blkcnt, mdata) != blkcnt) { log_debug("Error writing FWU metadata to the device\n"); @@ -164,7 +163,7 @@ static int fwu_mdata_gpt_blk_probe(struct udevice *dev) } static int fwu_gpt_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, - bool primary) + bool primary, u32 size) { struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); struct blk_desc *desc = dev_get_uclass_plat(priv->blk_dev); @@ -177,11 +176,13 @@ static int fwu_gpt_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, } return gpt_read_write_mdata(desc, mdata, MDATA_READ, - primary ? g_mdata_part[0] : g_mdata_part[1]); + primary ? + g_mdata_part[0] : g_mdata_part[1], + size); } static int fwu_gpt_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, - bool primary) + bool primary, u32 size)
[PATCH v3 02/20] tools: mkfwumdata: fix the size parameter to the fwrite call
The fwrite call returns the number of bytes transferred as part of the write only when the size parameter is 1. Pass the size parameter to the library call as 1 so that the correct number of bytes transferred are returned. Fixes: fdd56bfd3ad ("tools: Add mkfwumdata tool for FWU metadata image") Signed-off-by: Sughosh Ganu --- Changes since V2: None tools/mkfwumdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mkfwumdata.c b/tools/mkfwumdata.c index 9732a8ddc5..b2d90ca7c9 100644 --- a/tools/mkfwumdata.c +++ b/tools/mkfwumdata.c @@ -259,7 +259,7 @@ fwu_make_mdata(size_t images, size_t banks, char *uuids[], char *output) goto done_make; } - ret = fwrite(mobj->mdata, mobj->size, 1, file); + ret = fwrite(mobj->mdata, 1, mobj->size, file); if (ret != mobj->size) ret = -errno; else -- 2.34.1
[PATCH v3 01/20] configs: fwu: remove FWU configs for metadata V2 support
Support is to be added in the following commits for the FWU metadata version 2. Disable the FWU feature on platforms that enable it for the V2 addition work. Signed-off-by: Sughosh Ganu --- Changes since V2: None configs/corstone1000_defconfig | 2 -- configs/sandbox64_defconfig | 1 - configs/synquacer_developerbox_defconfig | 4 3 files changed, 7 deletions(-) diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig index 8b2f77f648..29d7550afb 100644 --- a/configs/corstone1000_defconfig +++ b/configs/corstone1000_defconfig @@ -24,7 +24,6 @@ CONFIG_LOGLEVEL=7 CONFIG_BOARD_LATE_INIT=y CONFIG_SYS_PROMPT="corstone1000# " # CONFIG_CMD_CONSOLE is not set -CONFIG_CMD_FWU_METADATA=y CONFIG_CMD_BOOTZ=y # CONFIG_CMD_XIMG is not set CONFIG_CMD_GPT=y @@ -67,4 +66,3 @@ CONFIG_FFA_SHARED_MM_BUF_OFFSET=0 CONFIG_FFA_SHARED_MM_BUF_ADDR=0x0200 CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_IGNORE_OSINDICATIONS=y -CONFIG_FWU_MULTI_BANK_UPDATE=y diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 3be9a00a85..7e8200e70c 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -272,7 +272,6 @@ CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y -CONFIG_FWU_MULTI_BANK_UPDATE=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y diff --git a/configs/synquacer_developerbox_defconfig b/configs/synquacer_developerbox_defconfig index 2a0407de40..616d410074 100644 --- a/configs/synquacer_developerbox_defconfig +++ b/configs/synquacer_developerbox_defconfig @@ -11,14 +11,12 @@ CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="synquacer-sc2a11-developerbox" CONFIG_SYS_LOAD_ADDR=0x8000 CONFIG_TARGET_DEVELOPERBOX=y -CONFIG_FWU_NUM_IMAGES_PER_BANK=1 CONFIG_AHCI=y CONFIG_FIT=y CONFIG_SYS_BOOTM_LEN=0x80 CONFIG_BOOTSTAGE_STASH_SIZE=4096 CONFIG_HUSH_PARSER=y CONFIG_SYS_MAXARGS=128 -CONFIG_CMD_FWU_METADATA=y CONFIG_CMD_IMLS=y CONFIG_CMD_ERASEENV=y CONFIG_CMD_NVEDIT_EFI=y @@ -53,7 +51,6 @@ CONFIG_DFU_TFTP=y CONFIG_DFU_MTD=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y -CONFIG_FWU_MDATA_MTD=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_SYNQUACER=y CONFIG_MMC_SDHCI=y @@ -96,4 +93,3 @@ CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_IGNORE_OSINDICATIONS=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y -CONFIG_FWU_MULTI_BANK_UPDATE=y -- 2.34.1
[PATCH v3 00/20] FWU: Add support for FWU metadata version 2
The following patch series adds support for version 2 of the FWU metadata. The version 2 metadata structure is defined in the latest revision of the FWU specification [1]. The earlier versions of these patches were migrating to a version 2 only support in U-Boot, similar to TF-A. However, based on feedback from ST [2], this series has been updated to support both versions. A platform would still be needed to enable one of the two versions of metadata through a config symbol. TF-A has code which reads the FWU metadata and boots the platform from the active partition. TF-A has decided to migrate the FWU code to a version 2 only support. These changes have been merged in upstream TF-A. These changes have been tested on the ST DK2 board, which uses the GPT based partitioning scheme. Both V1 and V2 metadata versions have been tested on the DK2 board. These changes need to be tested on platforms with MTD partitioned storage devices. @Michal and @Kojima-san, please help in this testing. Note: The CI is breaking on some sandbox py tests, but the errors look unrelated. I will look into those issues, but the code review can proceed. [1] - https://developer.arm.com/documentation/den0118/latest/ [2] - https://lists.denx.de/pipermail/u-boot/2024-February/546277.html Changes since V2: * New patch which retains support for V1 of metadata * Earlier patch was catering to v2 only support. These changes support both versions of metadata. * Earlier patch was migrating to v2 only support. These changes support both versions. * Support both metadata versions instead of only v2. * Added documentation changes. * Make changes to have the test work with v1 metadata. * Make changes to have the test work with updated logic in fwu code. * Changes to indicate support for both v1 and v2 instead of only v2. * Add config symbol for selecting either of the two metadata versions. Sughosh Ganu (20): configs: fwu: remove FWU configs for metadata V2 support tools: mkfwumdata: fix the size parameter to the fwrite call drivers: fwu: add the size parameter to the metadata access API's drivers: fwu: mtd: allocate buffer for image info dynamically fwu: metadata: add support for version 2 of the structure fwu: metadata: add a version agnostic structure fwu: metadata: add functions for handling version specific metadata fields fwu: make changes to access version agnostic structure fields capsule: fwu: transition the platform state on a successful update fwu: add config symbols for enabling FWU metadata versions fwu: mtd: remove unused argument from function call fwu: mtd: get MTD partition specific info from driver fwu: mtd: obtain image information from version agnostic structure cmd: fwu: make changes for supporting FWU metadata version 2 tools: mkfwumdata: add support for metadata version 2 tools: mkfwumdata: add logic to append vendor data to the FWU metadata test: fwu: make changes to the FWU metadata access test doc: fwu: make changes to reflect support for FWU metadata v2 MAINTAINERS: add entry for FWU multi bank update feature configs: fwu: re-enable FWU configs MAINTAINERS | 8 + cmd/fwu_mdata.c | 39 ++-- configs/corstone1000_defconfig | 1 + configs/sandbox64_defconfig | 1 + configs/synquacer_developerbox_defconfig | 2 +- doc/board/socionext/developerbox.rst | 7 +- doc/develop/uefi/fwu_updates.rst | 20 +- doc/mkfwumdata.1 | 16 +- drivers/fwu-mdata/fwu-mdata-uclass.c | 10 +- drivers/fwu-mdata/gpt_blk.c | 23 +- drivers/fwu-mdata/raw_mtd.c | 78 --- include/fwu.h| 147 - include/fwu_mdata.h | 71 ++- lib/efi_loader/efi_capsule.c | 14 +- lib/fwu_updates/Kconfig | 14 ++ lib/fwu_updates/Makefile | 2 + lib/fwu_updates/fwu.c| 204 -- lib/fwu_updates/fwu_mtd.c| 34 +-- lib/fwu_updates/fwu_v1.c | 167 +++ lib/fwu_updates/fwu_v2.c | 260 +++ test/dm/fwu_mdata.c | 16 +- tools/mkfwumdata.c | 235 22 files changed, 1153 insertions(+), 216 deletions(-) create mode 100644 lib/fwu_updates/fwu_v1.c create mode 100644 lib/fwu_updates/fwu_v2.c -- 2.34.1
Re: [PATCH 05/14] initcall: Adjust the failure message and return value
Hi Simon, út 22. 8. 2023 v 5:18 odesílatel Simon Glass napsal: > Move the failure message outside the loop, so it is easier to follow the > code. Avoid swallowing the error code - just pass it along. > > Drop the initcall-list address from the output. This is confusing since > we show two addresses. Really it is only the function address which is > useful, since it can be looked up in the map, e.g. with: > >grep -A1 -B1 serial_init u-boot.map > > Signed-off-by: Simon Glass > --- > > lib/initcall.c | 12 +++- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/lib/initcall.c b/lib/initcall.c > index 81c5d2450735..0f74cef32f85 100644 > --- a/lib/initcall.c > +++ b/lib/initcall.c > @@ -46,11 +46,13 @@ int initcall_run_list(const init_fnc_t init_sequence[]) > } > > ret = func(); > - if (ret) { > - printf("initcall sequence %p failed at call %p > (err=%d)\n", > - init_sequence, (char *)func - reloc_ofs, > ret); > - return -1; > - } > + } > + > + if (ret) { > + printf("initcall failed at call %p (err=%dE)\n", > + (char *)func - reloc_ofs, ret); > + > + return ret; > } > > return 0; > -- > 2.42.0.rc1.204.g551eb34607-goog > > I am debugging one issue and I get output like this. And I dig into it and find out that failures are not reported on the function which is causing it but on the next one. It is because of pointer is moved to next function; This is what I see. initcall: 08072de8, 0 initcall failed at call 0802b14c (err=-19) And this is the problematic part. for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) { Fix should be of course to get that if(ret) code back but maybe you want to see different solution. Thanks, Michal -- Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
RE: [PATCH v2 6/6] cmd: nand: Add new optional sub-command 'onfi'
Hi Michael, --- I think this command can be really useful. Let try to have more testing on more boards - I managed to test the command on sama7g54-curiosity board. I also forced timing mode 5 from controller driver (conf->timings.sdr.tRC_min < 2). => nand onfi 0 => hsmc decode MCK rate: 200 MHz HSMC_SETUP3:0x0004 HSMC_PULSE3:0x140a140a HSMC_CYCLE3:0x00140014 HSMC_TIMINGS3: 0x880805f4 HSMC_MODE3: 0x001f0003 NCS_RD: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns) NRD: setup: 0 (0 ns), pulse: 10 (50 ns), hold: 10 (50 ns), cycle: 20 (100 ns) NCS_WR: setup: 0 (0 ns), pulse: 20 (100 ns), hold: 0 (0 ns), cycle: 20 (100 ns) NWE: setup: 4 (20 ns), pulse: 10 (50 ns), hold: 6 (30 ns), cycle: 20 (100 ns) TDF optimization enabled TDF cycles: 15 (75 ns) Data Bus Width: 8-bit bus NWAIT Mode: 0 Write operation controlled by NWE signal Read operation controlled by NRD signal NFSEL (NAND Flash Selection) is set OCMS (Off Chip Memory Scrambling) is disabled TWB (WEN High to REN to Busy): 64 (320 ns) TRR (Ready to REN Low Delay): 64 (320 ns) TAR (ALE to REN Low Delay):5 (25 ns) TADL (ALE to Data Start): 71 (355 ns) TCLR (CLE to REN Low Delay): 4 (20 ns) => time nand torture 0x100 0x100 NAND torture: device 0 offset 0x100 size 0x100 (block size 0x4) Passed: 64, failed: 0 time: 22.638 seconds => nand onfi 5 => hsmc decode MCK rate: 200 MHz HSMC_SETUP3:0x0001 HSMC_PULSE3:0x07040502 HSMC_CYCLE3:0x00070005 HSMC_TIMINGS3: 0x880402f2 HSMC_MODE3: 0x001f0003 NCS_RD: setup: 0 (0 ns), pulse: 7 (35 ns), hold: 0 (0 ns), cycle: 7 (35 ns) NRD: setup: 0 (0 ns), pulse: 4 (20 ns), hold: 3 (15 ns), cycle: 7 (35 ns) NCS_WR: setup: 0 (0 ns), pulse: 5 (25 ns), hold: 0 (0 ns), cycle: 5 (25 ns) NWE: setup: 1 (5 ns), pulse: 2 (10 ns), hold: 2 (10 ns), cycle: 5 (25 ns) TDF optimization enabled TDF cycles: 15 (75 ns) Data Bus Width: 8-bit bus NWAIT Mode: 0 Write operation controlled by NWE signal Read operation controlled by NRD signal NFSEL (NAND Flash Selection) is set OCMS (Off Chip Memory Scrambling) is disabled TWB (WEN High to REN to Busy): 64 (320 ns) TRR (Ready to REN Low Delay): 4 (20 ns) TAR (ALE to REN Low Delay):2 (10 ns) TADL (ALE to Data Start): 71 (355 ns) TCLR (CLE to REN Low Delay): 2 (10 ns) => time nand torture 0x100 0x100 NAND torture: device 0 offset 0x100 size 0x100 (block size 0x4) Passed: 64, failed: 0 time: 11.661 seconds => nand info Device 0: nand0, sector size 256 KiB Manufacturer MACRONIX Model MX30LF4G28AD Device size512 MiB Page size 4096 b OOB size 256 b Erase size 262144 b ecc strength 8 bits ecc step size 512 b subpagesize 4096 b options 0x40004200 bbt options 0x00028000 Best regards, Mihai Sain
Re: [PATCH] rockchip: ringneck-px30: put STM32_RST line in input mode instead of output
Hi Kever, On 2/19/24 10:50, Quentin Schulz wrote: Hi Kever, On 2/18/24 02:14, Kever Yang wrote: Hi Quentin, On 2024/2/9 21:18, Quentin Schulz wrote: From: Quentin Schulz The STM32_RST line is routed to the ATtiny microcontroller PA0/RESET/UPDI pin. By driving the PX30 SoC pin as GPIO output high, we prevent external UPDI to be used for flashing without first putting this pin as GPIO input, an extra step we could avoid in userspace. A little confuse here, this GPIO is an output for PX30, right?So the config is: 1. the PX30 SPL init STM32_RST as input, with hardware pull-up the keep STM32 work; The pin needs to be high for STM32, and high **but not driven** for ATtiny in order to allow flashing scripts to work. 2. when need UPDI for flashing, need to set STM32_RST to output and trigger the reset in userspace? For STM32, STM32_RST needs to be driven low, then STM32_BOOT needs to be driven high, then STM32_RST needs to be high to deassert reset. For ATtiny, STM32_RST needs to be NOT driven so that UPDI lines can be used to interact with the MCU. Note that we also have the ability to do bitbang UPDI on that STM32_RST pin but that's another topic (just explaining why it is routed while seemingly useless for ATtiny). All the above is for entering the flashing mode. However, in U-Boot we do NOT want to enter flashing mode, we want to exit it, c.f. https://lore.kernel.org/u-boot/20231103-ringneck-stm32-reset-v2-1-a0e5559f8...@theobroma-systems.com/ An external HW pull-up is required because of glitches on the line when powering up/down. However, this is only done on newer versions of the PCB, so we need to tackle old versions. The old versions do not have this external HW pull-up and the glitch may cause the MCU to enter its flashing mode. Therefore, we force it to exit the flashing mode by always hard resetting it into the normal runtime mode. This is what spl_board_init() does. STM32_RST and STM32_BOOT are controlled by our flashing script for the STM32 variant for the MCU, so the default state when entering the Linux kernel doesn't matter. For the ATtiny MCU variant, we do not handle those GPIOs as part of the flashing script, therefore the default state when entering the Linux kernel should be the expected value for which we can use UPDI to flash the ATtiny. For ATtiny, the reset line is shared between STM32_RST that goes to the SoC and the UPDI lines exposed over the Q7 header. If STM32_RST is driven by the SoC, the UPDI lines won't be able to interact with the MCU. Therefore it needs to be put into input mode, whether in U-Boot or in Linux userspace. Can we have this in the next merge request for next please? Or maybe there's something I need to change here? Cheers, Quentin
Re: [PATCH 1/2] usb: udc: dwc3: Fold board dm_usb_gadget_handle_interrupts() into DWC3 gadget
On jeu., mars 21, 2024 at 20:38, Marek Vasut wrote: > On 3/21/24 11:01 AM, Mattijs Korpershoek wrote: >> Hi Marek, >> >> Thank you for the patch. >> >> On dim., mars 17, 2024 at 05:42, Marek Vasut >> wrote: >> >>> The dm_usb_gadget_handle_interrupts() has no place in board code. Move >>> this into DWC3 driver. The OMAP implementation is special, add new weak >>> dwc3_uboot_interrupt_status() function to decide whether DWC3 interrupt >>> handling should be called, and override it in OMAP DWC3 code, to repair >>> the special OMAP interrupt handling code until OMAP gets switched over >>> to DM UDC proper. >>> >>> Signed-off-by: Marek Vasut >> >> Reviewed-by: Mattijs Korpershoek >> >> Tested that I could scan for usb mass storage and that I can use >> fastboot: >> >> => fastboot usb 0 >> crq->brequest:0x0 >> => usb start >> starting USB... >> Bus usb@ff50: Register 3000140 NbrPorts 3 >> Starting the controller >> USB XHCI 1.10 >> scanning bus usb@ff50 for devices... 3 USB Device(s) found >> scanning usb for storage devices... 1 Storage Device(s) found >> >> => usb storage >>Device 0: Vendor: SanDisk Rev: 1.00 Prod: Ultra >> Type: Removable Hard Disk >> Capacity: 29328.0 MB = 28.6 GB (60063744 x 512) >> >> Tested-by: Mattijs Korpershoek # vim3 > > Thank you! > > Please feel free to pick this via DFU tree in a week or two, so others > can comment on this and test this too. Will do!
Re: [PATCH] usb: gadget: UMS: fix 64-bit division on ARM32
Hi Caleb, On jeu., mars 21, 2024 at 17:01, Caleb Connolly wrote: > On 21/03/2024 16:48, Mattijs Korpershoek wrote: >> Hi Caleb, >> >> Thank you for the patch. >> >> On jeu., mars 21, 2024 at 15:28, Caleb Connolly >> wrote: >> >>> The patch introducing support for dynamic sector sizes changed the types >>> used in some divisions, resulting in the compiler attempting to use >>> libgcc helpers (__aeabi_ldivmod). Replace these divisions with calls to >>> lldiv() to handle this correctly. >>> >>> Fixes: 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes") >>> Signed-off-by: Caleb Connolly >> >> Reviewed-by: Mattijs Korpershoek >> >> Would it be okay if I squashed this into >> commit 74e56e0c5065 ("usb: gadget: UMS: support multiple sector sizes") >> ? >> >> I'd like to not (intentionally) send any patches that don't compile to Tom. > > For sure, feel free to do that. Done, here: https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/304fa0aa445384e5e681a54abf413850591cec10 >> >> >>> --- >>> Hi Mattijs, >>> >>> Sorry for not catching that sooner! I compile tested this locally and a >> >> No worries, thanks a lot for the quick fix. >> >>> CI pipeline is running here: >>> https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/pipelines/20029 >> >> I can see from the above pipeline that some other failures are ongoing, >> but they are not related to lldiv(). >> >> arm-linux-gnueabi-ld.bfd: common/dfu.o: in function `run_usb_dnl_gadget': >> common/dfu.c:82:(.text.run_usb_dnl_gadget+0xd8): undefined reference to >> `dm_usb_gadget_handle_interrupts' >> arm-linux-gnueabi-ld.bfd: common/dfu.c:108:(.text.run_usb_dnl_gadget+0x11c): >> undefined reference to `dm_usb_gadget_handle_interrupts' >> make[1]: *** [Makefile:1793: u-boot] Error > > Ah! I guess this is caused by the "select DM_USB_GADGET" patch... > > You can revert it for now and I'll just select DM_USB_GADGET for qcom. Will do, I'll drop it from the branch. > > It seems like there's a bunch going on around here with the cleanup by > Marek. I can revisit this once that's settled Yeah, we are working on reworking the interrupt handling a bit since it has quite some limitations. >> >> See: >> https://source.denx.de/u-boot/custodians/u-boot-snapdragon/-/jobs/802759#L470 >> >> I suspect that this is related to: >> https://lore.kernel.org/r/all/20240225152715.1821613-1-jo...@kwiboo.se/ > > Is this fixed by the ("usb: udc: dwc3: Fold board > dm_usb_gadget_handle_interrupts() into DWC3") series? Unfortunately, no: https://source.denx.de/u-boot/custodians/u-boot-dfu/-/jobs/803228#L578 >> >> >>> >>> Regards, >>> Caleb >>> --- >>> drivers/usb/gadget/f_mass_storage.c | 13 +++-- >>> 1 file changed, 7 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/usb/gadget/f_mass_storage.c >>> b/drivers/usb/gadget/f_mass_storage.c >>> index d880928044f4..ef90c7ec7fb5 100644 >>> --- a/drivers/usb/gadget/f_mass_storage.c >>> +++ b/drivers/usb/gadget/f_mass_storage.c >>> @@ -239,8 +239,9 @@ >>> /* #define VERBOSE_DEBUG */ >>> /* #define DUMP_MSGS */ >>> >>> #include >>> +#include >>> #include >>> #include >>> #include >>> #include >>> @@ -768,10 +769,10 @@ static int do_read(struct fsg_common *common) >>> } >>> >>> /* Perform the read */ >>> rc = ums[common->lun].read_sector(&ums[common->lun], >>> - file_offset / curlun->blksize, >>> - amount / curlun->blksize, >>> + lldiv(file_offset, curlun->blksize), >>> + lldiv(amount, curlun->blksize), >>> (char __user *)bh->buf); >>> if (!rc) >>> return -EIO; >>> >>> @@ -942,10 +943,10 @@ static int do_write(struct fsg_common *common) >>> amount = bh->outreq->actual; >>> >>> /* Perform the write */ >>> rc = ums[common->lun].write_sector(&ums[common->lun], >>> - file_offset / curlun->blksize, >>> - amount / curlun->blksize, >>> + lldiv(file_offset, >>> curlun->blksize), >>> + lldiv(amount, curlun->blksize), >>>(char __user *)bh->buf); >>> if (!rc) >>> return -EIO; >>> nwritten = rc * curlun->blksize; >>> @@ -1058,10 +1059,10 @@ static int do_verify(struct fsg_common *common) >>> } >>> >>> /* Perform the read */ >>> rc = ums[common->lun].read_sector(&ums[common->lun], >>> - file_offset / curlun->blksize, >>> - amount / curlun->blksize, >>> + lldiv(file_offset, curlun-
Re: [PATCH 0/4] arm: meson: Switch to using upstream DT for GXL, GXM, AXG, G12A, G12B & SM1 SoCs
Hi Viacheslav, On 19/03/2024 15:42, Neil Armstrong wrote: Enable OF_UPSTREAM to use upstream DT and add amlogic/ prefix to the DEFAULT_DEVICE_TREE. And thereby directly build DTB from dts/upstream/src/ including *-u-boot.dtsi files from arch/$(ARCH)/dts/ directory and drop redundant files from arch/arm/dts directory. Only *-u-boot.dtsi files kept in arch/arm/dts directory for these boards. Keep A1 DTs locally since the architecture is still young. CI built & tested at: https://gitlab.com/amlogic-foss/amlogic-u-boot-autotest/-/pipelines/1219273552 Signed-off-by: Neil Armstrong --- Neil Armstrong (4): dts: meson: Switch GXL, GXM & AXG to using upstream DT dts: meson: Drop redundant GXL, GXM & AXG devicetree files Could you run a test run on your boards so make sure is still boots fine ? Thanks, Neil dts: meson-g12a: Switch to using upstream DT dts: meson: Drop redundant G12A, G12B & SM1 devicetree files arch/arm/dts/Makefile | 36 +- arch/arm/dts/meson-axg-jethome-jethub-j100.dts | 361 --- arch/arm/dts/meson-axg-s400.dts| 602 - arch/arm/dts/meson-axg.dtsi| 1957 --- arch/arm/dts/meson-g12-common.dtsi | 2493 arch/arm/dts/meson-g12.dtsi| 385 --- arch/arm/dts/meson-g12a-radxa-zero.dts | 405 arch/arm/dts/meson-g12a-sei510.dts | 566 - arch/arm/dts/meson-g12a-u200.dts | 308 --- arch/arm/dts/meson-g12a.dtsi | 140 -- arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts | 33 - arch/arm/dts/meson-g12b-a311d-khadas-vim3.dts | 41 - arch/arm/dts/meson-g12b-a311d.dtsi | 149 -- arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts | 165 -- arch/arm/dts/meson-g12b-bananapi-cm4.dtsi | 388 --- arch/arm/dts/meson-g12b-bananapi.dtsi | 521 arch/arm/dts/meson-g12b-gsking-x.dts | 133 -- arch/arm/dts/meson-g12b-gtking-pro.dts | 142 -- arch/arm/dts/meson-g12b-gtking.dts | 163 -- arch/arm/dts/meson-g12b-khadas-vim3.dtsi | 107 - arch/arm/dts/meson-g12b-odroid-go-ultra.dts| 722 -- arch/arm/dts/meson-g12b-odroid-n2-plus.dts | 31 - arch/arm/dts/meson-g12b-odroid-n2.dts | 15 - arch/arm/dts/meson-g12b-odroid-n2.dtsi | 303 --- arch/arm/dts/meson-g12b-odroid-n2l.dts | 125 - arch/arm/dts/meson-g12b-odroid.dtsi| 445 arch/arm/dts/meson-g12b-radxa-zero2.dts| 489 arch/arm/dts/meson-g12b-s922x-bananapi-m2s.dts | 14 - arch/arm/dts/meson-g12b-s922x.dtsi | 139 -- arch/arm/dts/meson-g12b-w400.dtsi | 425 arch/arm/dts/meson-g12b.dtsi | 146 -- arch/arm/dts/meson-gx-libretech-pc.dtsi| 447 arch/arm/dts/meson-gx-mali450.dtsi | 61 - arch/arm/dts/meson-gx-p23x-q20x.dtsi | 324 --- arch/arm/dts/meson-gx.dtsi | 675 -- arch/arm/dts/meson-gxl-mali.dtsi | 17 - arch/arm/dts/meson-gxl-s805x-libretech-ac.dts | 319 --- arch/arm/dts/meson-gxl-s805x.dtsi | 23 - arch/arm/dts/meson-gxl-s905d-libretech-pc.dts | 16 - arch/arm/dts/meson-gxl-s905d.dtsi | 12 - .../arm/dts/meson-gxl-s905w-jethome-jethub-j80.dts | 247 -- arch/arm/dts/meson-gxl-s905x-khadas-vim.dts| 237 -- arch/arm/dts/meson-gxl-s905x-libretech-cc-v2.dts | 313 --- arch/arm/dts/meson-gxl-s905x-libretech-cc.dts | 356 --- arch/arm/dts/meson-gxl-s905x-p212.dts | 134 -- arch/arm/dts/meson-gxl-s905x-p212.dtsi | 213 -- arch/arm/dts/meson-gxl-s905x.dtsi | 18 - arch/arm/dts/meson-gxl.dtsi| 940 arch/arm/dts/meson-gxm-gt1-ultimate.dts| 91 - arch/arm/dts/meson-gxm-khadas-vim2.dts | 424 arch/arm/dts/meson-gxm-s912-libretech-pc.dts | 62 - arch/arm/dts/meson-gxm-wetek-core2.dts | 85 - arch/arm/dts/meson-gxm.dtsi| 216 -- arch/arm/dts/meson-khadas-vim3.dtsi| 534 - arch/arm/dts/meson-sm1-bananapi-m2-pro.dts | 97 - arch/arm/dts/meson-sm1-bananapi-m5.dts | 221 -- arch/arm/dts/meson-sm1-bananapi.dtsi | 435 arch/arm/dts/meson-sm1-khadas-vim3l.dts| 113 - arch/arm/dts/meson-sm1-odroid-c4.dts | 48 - arch/arm/dts/meson-sm1-odroid-hc4.dts | 140 -- arch/arm/dts/meson-sm1-odroid.dtsi | 449 arch/arm/dts/meson-sm1-sei610.dts | 616 - arch/arm/dts/meson-sm1.dtsi| 550 - arch
Re: [PATCH v4] cmd: mtd: OTP access support
On 22.03.2024 11:17, Michael Nazzareno Trimarchi wrote: > Hi Arseniy > > On Fri, Mar 22, 2024 at 9:14 AM Arseniy Krasnov > wrote: >> >> Hi, >> >> On 22.03.2024 11:12, Michael Nazzareno Trimarchi wrote: >>> Hi Arseniy >>> >>> On Wed, Mar 20, 2024 at 8:14 PM Arseniy Krasnov >>> wrote: Add access to OTP region. It supports info, dump, write and lock operations. Usage example: 'mtd otpread nand0 u 0 1024' - dump 1024 bytes of user area starting from offset 0 of device 'nand0'. 'mtd otpwrite nand0 10 11223344' - write binary data 0x11, 0x22, 0x33, 0x44 to offset 10 to user area of device 'nand0'. 'mtd otplock nand0 0 1024' - lock 1024 bytes of user area starting from offset 0 of device 'nand0'. 'mtd otpinfo nand0 f' - show info about factory area of device 'nand0'. Signed-off-by: Arseniy Krasnov Reviewed-by: Michael Trimarchi --- Changelog: v1 -> v2: * Remove warning that OTP can't be erased after write. v2 -> v3: * Commit message updated by adding usage. * R-b added. v3 -> v4: * Fix build failure due to invalid format strings for 'printf()'. * Rebase over latest version of cmd/mtd.c. cmd/Kconfig | 1 + cmd/mtd.c | 224 2 files changed, 225 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 7292a150f5..f218dc6cf2 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1363,6 +1363,7 @@ config CMD_MTD bool "mtd" depends on MTD select MTD_PARTITIONS + select HEXDUMP >>> >>> Make those change forced in increase the size of uboot and break this build >>> >>> https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/jobs/802378 >>> >>> I think that those command could be optional and not forced to be >>> included by default >>> >> >> Ah, Ok:) I'll add it as config option which depends on CMD_MTD in the next >> version >> > > I am really glad how you interact with the mailing list ;) and how you > are fast on feedback > Sure, thanks! > > Michael > >> Thanks >> >>> Michael >>> >>> help MTD commands support. diff --git a/cmd/mtd.c b/cmd/mtd.c index e63c011e79..2b03a85ef0 100644 --- a/cmd/mtd.c +++ b/cmd/mtd.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -202,6 +203,219 @@ static bool mtd_oob_write_is_empty(struct mtd_oob_ops *op) return true; } +static int do_mtd_otp_read(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct mtd_info *mtd; + size_t retlen; + off_t from; + size_t len; + bool user; + int ret; + u8 *buf; + + if (argc != 5) + return CMD_RET_USAGE; + + if (!strcmp(argv[2], "u")) + user = true; + else if (!strcmp(argv[2], "f")) + user = false; + else + return CMD_RET_USAGE; + + mtd = get_mtd_by_name(argv[1]); + if (IS_ERR_OR_NULL(mtd)) + return CMD_RET_FAILURE; + + from = simple_strtoul(argv[3], NULL, 0); + len = simple_strtoul(argv[4], NULL, 0); + + ret = CMD_RET_FAILURE; + + buf = malloc(len); + if (!buf) + goto put_mtd; + + printf("Reading %s OTP from 0x%lx, %zu bytes\n", + user ? "user" : "factory", from, len); + + if (user) + ret = mtd_read_user_prot_reg(mtd, from, len, &retlen, buf); + else + ret = mtd_read_fact_prot_reg(mtd, from, len, &retlen, buf); + if (ret) { + free(buf); + pr_err("OTP read failed: %d\n", ret); + ret = CMD_RET_FAILURE; + goto put_mtd; + } + + if (retlen != len) + pr_err("OTP read returns %zu, but %zu expected\n", + retlen, len); + + print_hex_dump("", 0, 16, 1, buf, retlen, true); + + free(buf); + + ret = CMD_RET_SUCCESS; + +put_mtd: + put_mtd_device(mtd); + + return ret; +} + +static int do_mtd_otp_lock(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct mtd_info *mtd; + off_t from; + size_t len; + int ret; + + if (argc != 4) + return CMD_RET_USAGE; + + mtd = get_mtd_by_name(argv[1
Re: [PATCH v4] cmd: mtd: OTP access support
Hi Arseniy On Fri, Mar 22, 2024 at 9:14 AM Arseniy Krasnov wrote: > > Hi, > > On 22.03.2024 11:12, Michael Nazzareno Trimarchi wrote: > > Hi Arseniy > > > > On Wed, Mar 20, 2024 at 8:14 PM Arseniy Krasnov > > wrote: > >> > >> Add access to OTP region. It supports info, dump, write and lock > >> operations. Usage example: > >> > >> 'mtd otpread nand0 u 0 1024' - dump 1024 bytes of user area starting > >> from offset 0 of device 'nand0'. > >> > >> 'mtd otpwrite nand0 10 11223344' - write binary data 0x11, 0x22, 0x33, > >> 0x44 to offset 10 to user area of device 'nand0'. > >> > >> 'mtd otplock nand0 0 1024' - lock 1024 bytes of user area starting > >> from offset 0 of device 'nand0'. > >> > >> 'mtd otpinfo nand0 f' - show info about factory area of device 'nand0'. > >> > >> Signed-off-by: Arseniy Krasnov > >> Reviewed-by: Michael Trimarchi > >> --- > >> Changelog: > >> v1 -> v2: > >> * Remove warning that OTP can't be erased after write. > >> v2 -> v3: > >> * Commit message updated by adding usage. > >> * R-b added. > >> v3 -> v4: > >> * Fix build failure due to invalid format strings for 'printf()'. > >> * Rebase over latest version of cmd/mtd.c. > >> > >> cmd/Kconfig | 1 + > >> cmd/mtd.c | 224 > >> 2 files changed, 225 insertions(+) > >> > >> diff --git a/cmd/Kconfig b/cmd/Kconfig > >> index 7292a150f5..f218dc6cf2 100644 > >> --- a/cmd/Kconfig > >> +++ b/cmd/Kconfig > >> @@ -1363,6 +1363,7 @@ config CMD_MTD > >> bool "mtd" > >> depends on MTD > >> select MTD_PARTITIONS > >> + select HEXDUMP > > > > Make those change forced in increase the size of uboot and break this build > > > > https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/jobs/802378 > > > > I think that those command could be optional and not forced to be > > included by default > > > > Ah, Ok:) I'll add it as config option which depends on CMD_MTD in the next > version > I am really glad how you interact with the mailing list ;) and how you are fast on feedback Michael > Thanks > > > Michael > > > > > >> help > >> MTD commands support. > >> > >> diff --git a/cmd/mtd.c b/cmd/mtd.c > >> index e63c011e79..2b03a85ef0 100644 > >> --- a/cmd/mtd.c > >> +++ b/cmd/mtd.c > >> @@ -11,6 +11,7 @@ > >> #include > >> #include > >> #include > >> +#include > >> #include > >> #include > >> #include > >> @@ -202,6 +203,219 @@ static bool mtd_oob_write_is_empty(struct > >> mtd_oob_ops *op) > >> return true; > >> } > >> > >> +static int do_mtd_otp_read(struct cmd_tbl *cmdtp, int flag, int argc, > >> + char *const argv[]) > >> +{ > >> + struct mtd_info *mtd; > >> + size_t retlen; > >> + off_t from; > >> + size_t len; > >> + bool user; > >> + int ret; > >> + u8 *buf; > >> + > >> + if (argc != 5) > >> + return CMD_RET_USAGE; > >> + > >> + if (!strcmp(argv[2], "u")) > >> + user = true; > >> + else if (!strcmp(argv[2], "f")) > >> + user = false; > >> + else > >> + return CMD_RET_USAGE; > >> + > >> + mtd = get_mtd_by_name(argv[1]); > >> + if (IS_ERR_OR_NULL(mtd)) > >> + return CMD_RET_FAILURE; > >> + > >> + from = simple_strtoul(argv[3], NULL, 0); > >> + len = simple_strtoul(argv[4], NULL, 0); > >> + > >> + ret = CMD_RET_FAILURE; > >> + > >> + buf = malloc(len); > >> + if (!buf) > >> + goto put_mtd; > >> + > >> + printf("Reading %s OTP from 0x%lx, %zu bytes\n", > >> + user ? "user" : "factory", from, len); > >> + > >> + if (user) > >> + ret = mtd_read_user_prot_reg(mtd, from, len, &retlen, buf); > >> + else > >> + ret = mtd_read_fact_prot_reg(mtd, from, len, &retlen, buf); > >> + if (ret) { > >> + free(buf); > >> + pr_err("OTP read failed: %d\n", ret); > >> + ret = CMD_RET_FAILURE; > >> + goto put_mtd; > >> + } > >> + > >> + if (retlen != len) > >> + pr_err("OTP read returns %zu, but %zu expected\n", > >> + retlen, len); > >> + > >> + print_hex_dump("", 0, 16, 1, buf, retlen, true); > >> + > >> + free(buf); > >> + > >> + ret = CMD_RET_SUCCESS; > >> + > >> +put_mtd: > >> + put_mtd_device(mtd); > >> + > >> + return ret; > >> +} > >> + > >> +static int do_mtd_otp_lock(struct cmd_tbl *cmdtp, int flag, int argc, > >> + char *const argv[]) > >> +{ > >> + struct mtd_info *mtd; > >> + off_t from; > >> + size_t len; > >> + int ret; > >> + > >> + if (argc != 4) > >> + return CMD_RET_USAGE; > >> + > >> + mtd = get_mtd_by_name(argv[1]); > >> + if (IS_ERR_OR_NULL(mtd)) > >> + return CMD_RET_FAILURE; > >> + > >> +
Re: [PATCH v3 2/6] usb: xhci: Set up endpoints for the first 2 interfaces
On 3/22/24 08:47, Janne Grunau via B4 Relay wrote: From: Janne Grunau The xhci driver currently only does the necessary initialization for endpoints found in the first interface descriptor. Apple USB keyboards (released 2021) use the second interface descriptor for the HID keyboard boot protocol. To allow USB drivers to use endpoints from other interface descriptors the xhci driver needs to ensure these endpoints are initialized as well. Use USB_MAX_ACTIVE_INTERFACES to control how many interface descriptors are considered during endpoint initialisation. For now define it to 2 as that is sufficient for supporting the Apple keyboards. Reviewed-by: Marek Vasut Reviewed-by: Neal Gompa Signed-off-by: Janne Grunau --- drivers/usb/host/xhci.c | 31 +++ include/usb.h | 6 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 534c4b973f..741e186ee0 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -606,24 +606,28 @@ static int xhci_set_configuration(struct usb_device *udev) int slot_id = udev->slot_id; struct xhci_virt_device *virt_dev = ctrl->devs[slot_id]; struct usb_interface *ifdesc; + unsigned int ifnum; + unsigned int max_ifnum = min((unsigned int)USB_MAX_ACTIVE_INTERFACES, no_of_if being of type u8 limits the number of interfaces to 255. Introducing USB_MAX_ACTIVE_INTERFACES limit us to the first two interfaces. Is this really needed? Handling all interface would avoid the introduction of artificial limitations which may hit us on the next device. Best regards Heinrich +(unsigned int)udev->config.no_of_if); out_ctx = virt_dev->out_ctx; in_ctx = virt_dev->in_ctx; - num_of_ep = udev->config.if_desc[0].no_of_ep; - ifdesc = &udev->config.if_desc[0]; - ctrl_ctx = xhci_get_input_control_ctx(in_ctx); /* Initialize the input context control */ ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG); ctrl_ctx->drop_flags = 0; - /* EP_FLAG gives values 1 & 4 for EP1OUT and EP2IN */ - for (cur_ep = 0; cur_ep < num_of_ep; cur_ep++) { - ep_flag = xhci_get_ep_index(&ifdesc->ep_desc[cur_ep]); - ctrl_ctx->add_flags |= cpu_to_le32(1 << (ep_flag + 1)); - if (max_ep_flag < ep_flag) - max_ep_flag = ep_flag; + for (ifnum = 0; ifnum < max_ifnum; ifnum++) { + ifdesc = &udev->config.if_desc[ifnum]; + num_of_ep = ifdesc->no_of_ep; + /* EP_FLAG gives values 1 & 4 for EP1OUT and EP2IN */ + for (cur_ep = 0; cur_ep < num_of_ep; cur_ep++) { + ep_flag = xhci_get_ep_index(&ifdesc->ep_desc[cur_ep]); + ctrl_ctx->add_flags |= cpu_to_le32(1 << (ep_flag + 1)); + if (max_ep_flag < ep_flag) + max_ep_flag = ep_flag; + } } xhci_inval_cache((uintptr_t)out_ctx->bytes, out_ctx->size); @@ -637,9 +641,12 @@ static int xhci_set_configuration(struct usb_device *udev) xhci_endpoint_copy(ctrl, in_ctx, out_ctx, 0); /* filling up ep contexts */ - err = xhci_init_ep_contexts_if(udev, ctrl, virt_dev, ifdesc); - if (err < 0) - return err; + for (ifnum = 0; ifnum < max_ifnum; ifnum++) { + ifdesc = &udev->config.if_desc[ifnum]; + err = xhci_init_ep_contexts_if(udev, ctrl, virt_dev, ifdesc); + if (err < 0) + return err; + } return xhci_configure_endpoints(udev, false); } diff --git a/include/usb.h b/include/usb.h index 09e3f0cb30..3aafdc8bfd 100644 --- a/include/usb.h +++ b/include/usb.h @@ -49,6 +49,12 @@ extern bool usb_started; /* flag for the started/stopped USB status */ */ #define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 5000 : 1000) +/* + * The xhcd hcd driver prepares only a limited number interfaces / endpoints. + * Define this limit so that drivers do not exceed it. + */ +#define USB_MAX_ACTIVE_INTERFACES 2 + /* device request (setup) */ struct devrequest { __u8requesttype;
Re: [PATCH v4] cmd: mtd: OTP access support
Hi, On 22.03.2024 11:12, Michael Nazzareno Trimarchi wrote: > Hi Arseniy > > On Wed, Mar 20, 2024 at 8:14 PM Arseniy Krasnov > wrote: >> >> Add access to OTP region. It supports info, dump, write and lock >> operations. Usage example: >> >> 'mtd otpread nand0 u 0 1024' - dump 1024 bytes of user area starting >> from offset 0 of device 'nand0'. >> >> 'mtd otpwrite nand0 10 11223344' - write binary data 0x11, 0x22, 0x33, >> 0x44 to offset 10 to user area of device 'nand0'. >> >> 'mtd otplock nand0 0 1024' - lock 1024 bytes of user area starting >> from offset 0 of device 'nand0'. >> >> 'mtd otpinfo nand0 f' - show info about factory area of device 'nand0'. >> >> Signed-off-by: Arseniy Krasnov >> Reviewed-by: Michael Trimarchi >> --- >> Changelog: >> v1 -> v2: >> * Remove warning that OTP can't be erased after write. >> v2 -> v3: >> * Commit message updated by adding usage. >> * R-b added. >> v3 -> v4: >> * Fix build failure due to invalid format strings for 'printf()'. >> * Rebase over latest version of cmd/mtd.c. >> >> cmd/Kconfig | 1 + >> cmd/mtd.c | 224 >> 2 files changed, 225 insertions(+) >> >> diff --git a/cmd/Kconfig b/cmd/Kconfig >> index 7292a150f5..f218dc6cf2 100644 >> --- a/cmd/Kconfig >> +++ b/cmd/Kconfig >> @@ -1363,6 +1363,7 @@ config CMD_MTD >> bool "mtd" >> depends on MTD >> select MTD_PARTITIONS >> + select HEXDUMP > > Make those change forced in increase the size of uboot and break this build > > https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/jobs/802378 > > I think that those command could be optional and not forced to be > included by default > Ah, Ok:) I'll add it as config option which depends on CMD_MTD in the next version Thanks > Michael > > >> help >> MTD commands support. >> >> diff --git a/cmd/mtd.c b/cmd/mtd.c >> index e63c011e79..2b03a85ef0 100644 >> --- a/cmd/mtd.c >> +++ b/cmd/mtd.c >> @@ -11,6 +11,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -202,6 +203,219 @@ static bool mtd_oob_write_is_empty(struct mtd_oob_ops >> *op) >> return true; >> } >> >> +static int do_mtd_otp_read(struct cmd_tbl *cmdtp, int flag, int argc, >> + char *const argv[]) >> +{ >> + struct mtd_info *mtd; >> + size_t retlen; >> + off_t from; >> + size_t len; >> + bool user; >> + int ret; >> + u8 *buf; >> + >> + if (argc != 5) >> + return CMD_RET_USAGE; >> + >> + if (!strcmp(argv[2], "u")) >> + user = true; >> + else if (!strcmp(argv[2], "f")) >> + user = false; >> + else >> + return CMD_RET_USAGE; >> + >> + mtd = get_mtd_by_name(argv[1]); >> + if (IS_ERR_OR_NULL(mtd)) >> + return CMD_RET_FAILURE; >> + >> + from = simple_strtoul(argv[3], NULL, 0); >> + len = simple_strtoul(argv[4], NULL, 0); >> + >> + ret = CMD_RET_FAILURE; >> + >> + buf = malloc(len); >> + if (!buf) >> + goto put_mtd; >> + >> + printf("Reading %s OTP from 0x%lx, %zu bytes\n", >> + user ? "user" : "factory", from, len); >> + >> + if (user) >> + ret = mtd_read_user_prot_reg(mtd, from, len, &retlen, buf); >> + else >> + ret = mtd_read_fact_prot_reg(mtd, from, len, &retlen, buf); >> + if (ret) { >> + free(buf); >> + pr_err("OTP read failed: %d\n", ret); >> + ret = CMD_RET_FAILURE; >> + goto put_mtd; >> + } >> + >> + if (retlen != len) >> + pr_err("OTP read returns %zu, but %zu expected\n", >> + retlen, len); >> + >> + print_hex_dump("", 0, 16, 1, buf, retlen, true); >> + >> + free(buf); >> + >> + ret = CMD_RET_SUCCESS; >> + >> +put_mtd: >> + put_mtd_device(mtd); >> + >> + return ret; >> +} >> + >> +static int do_mtd_otp_lock(struct cmd_tbl *cmdtp, int flag, int argc, >> + char *const argv[]) >> +{ >> + struct mtd_info *mtd; >> + off_t from; >> + size_t len; >> + int ret; >> + >> + if (argc != 4) >> + return CMD_RET_USAGE; >> + >> + mtd = get_mtd_by_name(argv[1]); >> + if (IS_ERR_OR_NULL(mtd)) >> + return CMD_RET_FAILURE; >> + >> + from = simple_strtoul(argv[2], NULL, 0); >> + len = simple_strtoul(argv[3], NULL, 0); >> + >> + ret = mtd_lock_user_prot_reg(mtd, from, len); >> + if (ret) { >> + pr_err("OTP lock failed: %d\n", ret); >> + ret = CMD_RET_FAILURE; >> + goto put_mtd; >> + } >> + >> + ret = CMD_RET_SUCCESS; >> + >> +put_mtd: >> + put_mtd_device(mtd); >> + >> + return ret; >> +} >> + >> +static int do_mtd_otp_write(struct cmd_t
Re: [PATCH v4] cmd: mtd: OTP access support
Hi Arseniy On Wed, Mar 20, 2024 at 8:14 PM Arseniy Krasnov wrote: > > Add access to OTP region. It supports info, dump, write and lock > operations. Usage example: > > 'mtd otpread nand0 u 0 1024' - dump 1024 bytes of user area starting > from offset 0 of device 'nand0'. > > 'mtd otpwrite nand0 10 11223344' - write binary data 0x11, 0x22, 0x33, > 0x44 to offset 10 to user area of device 'nand0'. > > 'mtd otplock nand0 0 1024' - lock 1024 bytes of user area starting > from offset 0 of device 'nand0'. > > 'mtd otpinfo nand0 f' - show info about factory area of device 'nand0'. > > Signed-off-by: Arseniy Krasnov > Reviewed-by: Michael Trimarchi > --- > Changelog: > v1 -> v2: > * Remove warning that OTP can't be erased after write. > v2 -> v3: > * Commit message updated by adding usage. > * R-b added. > v3 -> v4: > * Fix build failure due to invalid format strings for 'printf()'. > * Rebase over latest version of cmd/mtd.c. > > cmd/Kconfig | 1 + > cmd/mtd.c | 224 > 2 files changed, 225 insertions(+) > > diff --git a/cmd/Kconfig b/cmd/Kconfig > index 7292a150f5..f218dc6cf2 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -1363,6 +1363,7 @@ config CMD_MTD > bool "mtd" > depends on MTD > select MTD_PARTITIONS > + select HEXDUMP Make those change forced in increase the size of uboot and break this build https://source.denx.de/u-boot/custodians/u-boot-nand-flash/-/jobs/802378 I think that those command could be optional and not forced to be included by default Michael > help > MTD commands support. > > diff --git a/cmd/mtd.c b/cmd/mtd.c > index e63c011e79..2b03a85ef0 100644 > --- a/cmd/mtd.c > +++ b/cmd/mtd.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -202,6 +203,219 @@ static bool mtd_oob_write_is_empty(struct mtd_oob_ops > *op) > return true; > } > > +static int do_mtd_otp_read(struct cmd_tbl *cmdtp, int flag, int argc, > + char *const argv[]) > +{ > + struct mtd_info *mtd; > + size_t retlen; > + off_t from; > + size_t len; > + bool user; > + int ret; > + u8 *buf; > + > + if (argc != 5) > + return CMD_RET_USAGE; > + > + if (!strcmp(argv[2], "u")) > + user = true; > + else if (!strcmp(argv[2], "f")) > + user = false; > + else > + return CMD_RET_USAGE; > + > + mtd = get_mtd_by_name(argv[1]); > + if (IS_ERR_OR_NULL(mtd)) > + return CMD_RET_FAILURE; > + > + from = simple_strtoul(argv[3], NULL, 0); > + len = simple_strtoul(argv[4], NULL, 0); > + > + ret = CMD_RET_FAILURE; > + > + buf = malloc(len); > + if (!buf) > + goto put_mtd; > + > + printf("Reading %s OTP from 0x%lx, %zu bytes\n", > + user ? "user" : "factory", from, len); > + > + if (user) > + ret = mtd_read_user_prot_reg(mtd, from, len, &retlen, buf); > + else > + ret = mtd_read_fact_prot_reg(mtd, from, len, &retlen, buf); > + if (ret) { > + free(buf); > + pr_err("OTP read failed: %d\n", ret); > + ret = CMD_RET_FAILURE; > + goto put_mtd; > + } > + > + if (retlen != len) > + pr_err("OTP read returns %zu, but %zu expected\n", > + retlen, len); > + > + print_hex_dump("", 0, 16, 1, buf, retlen, true); > + > + free(buf); > + > + ret = CMD_RET_SUCCESS; > + > +put_mtd: > + put_mtd_device(mtd); > + > + return ret; > +} > + > +static int do_mtd_otp_lock(struct cmd_tbl *cmdtp, int flag, int argc, > + char *const argv[]) > +{ > + struct mtd_info *mtd; > + off_t from; > + size_t len; > + int ret; > + > + if (argc != 4) > + return CMD_RET_USAGE; > + > + mtd = get_mtd_by_name(argv[1]); > + if (IS_ERR_OR_NULL(mtd)) > + return CMD_RET_FAILURE; > + > + from = simple_strtoul(argv[2], NULL, 0); > + len = simple_strtoul(argv[3], NULL, 0); > + > + ret = mtd_lock_user_prot_reg(mtd, from, len); > + if (ret) { > + pr_err("OTP lock failed: %d\n", ret); > + ret = CMD_RET_FAILURE; > + goto put_mtd; > + } > + > + ret = CMD_RET_SUCCESS; > + > +put_mtd: > + put_mtd_device(mtd); > + > + return ret; > +} > + > +static int do_mtd_otp_write(struct cmd_tbl *cmdtp, int flag, int argc, > + char *const argv[]) > +{ > + struct mtd_info *mtd; > + size_t retlen; > + size_t binlen; > + u8 *binbuf; > + off_t from; > + int ret; > + > + if (argc != 4) > + return CMD_RET_USAGE; > + > + mtd = get_mtd_by_name(argv[1])
Re: [PATCH 2/5] mmc: zynq-sdhci: refactor tapdelay settings
Hi Venkatesh, we're not using the firmware when running in el3, so that should still work. The sdhci driver needs to know which controller it's operating on and uses the power-domain node for that. I can't add the power domain node without a firmware node (i think?), but the firmware node without a compatible shouldn't be used by anything? Alternatively we could exit without an error from these functions if our node id doesn't match sd0 or sd1. That wouldn't apply any settings, but that's the current behaviour already. Thanks Steffen On Fri, 2024-03-15 at 09:52 +, Abbarapu, Venkatesh wrote: > Hi Steffen, > For mini u-boot cases ZYNQMP_FIRMWARE config is disabled as there > won't be any ATF(TF-A) present. > > Thanks > Venkatesh > > > -Original Message- > > From: Steffen Dirkwinkel > > Sent: Thursday, March 14, 2024 1:23 PM > > To: Kumar, Love ; u-boot@lists.denx.de > > Cc: Algapally Santosh Sagar ; Ashok > > Reddy Soma ; Jaehoon Chung > > ; Johan Jonker ; Simek, > > Michal ; Peng Fan ; Tom > > Rini > > ; Abbarapu, Venkatesh > > > > Subject: Re: [PATCH 2/5] mmc: zynq-sdhci: refactor tapdelay > > settings > > > > Hi Love, > > > > On Thu, 2024-03-14 at 12:15 +0530, Love Kumar wrote: > > > Hi, > > > > > > When we run in el3 for zynqmp board, we are seeing below issue > > > with > > > this > > > patch: > > > > > > > > > Model: ZynqMP MINI EMMC0 > > > Board: Xilinx ZynqMP > > > DRAM: 512 MiB > > > EL Level: EL3 > > > Secure Boot: not authenticated, not encrypted > > > Multiboot: 0 > > > Core: 10 devices, 9 uclasses, devicetree: embed > > > MMC: sdhci@ff16: 0 > > > Loading Environment from ... OK > > > In: dcc > > > Out: dcc > > > Err: dcc > > > ZynqMP> mmc list > > > sdhci@ff16: 0 > > > ZynqMP> mmc dev 0 0 > > > arasan_sdhci sdhci@ff16: Error setting Input Tap Delay > > > sdhci_set_clock: Error while setting tap delay > > > sdhci_send_command: Timeout for status update: 0001 > > > ZynqMP> > > > > Thank you for testing this. > > It looks like the zynqmp-mini-emmc0 device lacks the power-domain > > node > > and doesn't have a sd node id. The code before my change would have > > ignored the unknown node id, applied settings for sdhci1 instead of > > sdhci0 > > and returned without an error. Maybe there's a different way to > > find out > > which sdhci we want to operate on? > > > > Can you try setting the node id in device tree? > > Something like this: > > > > diff --git a/arch/arm/dts/zynqmp-mini-emmc0.dts > > b/arch/arm/dts/zynqmp- > > mini-emmc0.dts > > index 02e80bd85e1..87c4a1b6ad0 100644 > > --- a/arch/arm/dts/zynqmp-mini-emmc0.dts > > +++ b/arch/arm/dts/zynqmp-mini-emmc0.dts > > @@ -7,6 +7,8 @@ > > * Siva Durga Prasad Paladugu > > */ > > > > +#include > > + > > /dts-v1/; > > > > / { > > @@ -41,6 +43,12 @@ > > clock-frequency = <2>; > > }; > > > > + firmware { > > + zynqmp_firmware: zynqmp-firmware { > > + #power-domain-cells = <1>; > > + }; > > + }; > > + > > amba: amba { > > compatible = "simple-bus"; > > #address-cells = <2>; > > @@ -56,6 +64,7 @@ > > reg = <0x0 0xff16 0x0 0x1000>; > > clock-names = "clk_xin", "clk_ahb"; > > clocks = <&clk_xin &clk_xin>; > > + power-domains = <&zynqmp_firmware PD_SD_0>; > > }; > > }; > > }; > > > > Thanks, > > Steffen > > > > > > > > Regards, > > > Love Kumar > > > > > > On 23/02/24 7:36 pm, Steffen Dirkwinkel wrote: > > > > From: Steffen Dirkwinkel > > > > > > > > Previously we were setting in tapdelay for SD1 every time even > > > > if > > > > SD0 was requested. > > > > The SD tapdelay settings are shifted by 16 bits between SD0 and > > > > SD1. > > > > We can use that to make our tapdelay setup simpler. This is > > > > also how > > > > it currently works in arm-trusted-firmware. > > > > > > > > Signed-off-by: Steffen Dirkwinkel > > > > --- > > > > > > > > drivers/mmc/zynq_sdhci.c | 65 > > > > +--- > > > > 1 file changed, 28 insertions(+), 37 deletions(-) > > > > > > > > diff --git a/drivers/mmc/zynq_sdhci.c > > > > b/drivers/mmc/zynq_sdhci.c > > > > index 935540d1719..d4845245b2a 100644 > > > > --- a/drivers/mmc/zynq_sdhci.c > > > > +++ b/drivers/mmc/zynq_sdhci.c > > > > @@ -42,14 +42,11 @@ > > > > #define SD_OTAP_DLY 0xFF180318 > > > > #define SD0_DLL_RST BIT(2) > > > > #define SD1_DLL_RST BIT(18) > > > > +#define SD1_TAP_OFFSET 16 > > > > #define SD0_ITAPCHGWINBIT(9) > > > > -#define SD1_ITAPCHGWIN BIT(25) > > > > #define SD0_ITAPDLYENABIT(8) > > > > -#define SD1_ITAPDLYENA BIT(24) > > > > #define SD0_ITAPDLYSEL_MASK
[PATCH 1/2] doc: man-page for itest
Provide a man-page for the itest command. Signed-off-by: Heinrich Schuchardt --- doc/usage/cmd/itest.rst | 113 doc/usage/index.rst | 1 + 2 files changed, 114 insertions(+) create mode 100644 doc/usage/cmd/itest.rst diff --git a/doc/usage/cmd/itest.rst b/doc/usage/cmd/itest.rst new file mode 100644 index 000..66b466d965c --- /dev/null +++ b/doc/usage/cmd/itest.rst @@ -0,0 +1,113 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +.. index:: + single: itest (command) + +itest command += + +Synopsis + + +:: + +itest[.b | .w | .l | .q | .s] [*] [*] + +Description +--- + +The itest command is used to compare two values. The return value $? is set +accordingly. + +By default it is assumed that the values are 4 byte integers. By appending a +postfix (.b, .w, .l, .q, .s) the size can be specified: + +=== == +postfix meaning +=== == +.b 1 byte integer +.w 2 byte integer +.l 4 byte integer +.q 8 byte integer (only available if CONFIG_PHYS_64BIT=y) +.s string +=== == + +value1, value2 +values to compare. Numeric values are hexadecimal. If '*' is prefixed a +hexadecimal address is passed, which points to the value to be compared. + +op +operator, see table + + == +operator meaning + == +-lt less than +not equal +-ge greater or equal +>= greater or equal +-gt greater than +>greater than + == + +Examples + + +The itest command sets the result variable $? to true (0) or false (1): + +:: + +=> itest 3 < 4; echo $? +0 +=> itest 3 == 4; echo $? +1 + +This value can be used in the :doc:`if ` command: + +:: + +=> if itest 0x3002 < 0x4001; then echo true; else echo false; fi +true + +Numbers will be truncated according to the postfix before comparing: + +:: + +=> if itest.b 0x3002 < 0x4001; then echo true; else echo false; fi +false + +Postfix .s causes a string compare. The string '0xa1234' is alphabetically +smaller than '0xb'. + +=> if itest.s 0xa1234 < 0xb; then echo true; else echo false; fi +true + +A value prefixed by '*' is a pointer to the value in memory. + +:: + +=> mm 0x4000 +4000: 0004 ? +4004: 0003 ? => +=> if itest *0x4000 == 4; then echo true; else echo false; fi +true +=> if itest *0x4004 == 3; then echo true; else echo false; fi +true + +Configuration +- + +The command is only available if CONFIG_CMD_ITEST=y. + +Return value + + +The return value $? is 0 (true) if the condition is true and 1 (false) +otherwise. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 66d73e70cc4..2f211f748ab 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -72,6 +72,7 @@ Shell commands cmd/history cmd/host cmd/if + cmd/itest cmd/imxtract cmd/load cmd/loadb -- 2.43.0
[PATCH 2/2] doc: add reference to itest in if man-page
Add a cross reference to the itest command. Fix a typo: %s/Example/Examples/. Signed-off-by: Heinrich Schuchardt --- doc/usage/cmd/if.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/usage/cmd/if.rst b/doc/usage/cmd/if.rst index 6b3dbe7b0a0..813f903a8d8 100644 --- a/doc/usage/cmd/if.rst +++ b/doc/usage/cmd/if.rst @@ -33,11 +33,11 @@ test statement $? becomes 0 (true) the statements after the **then** statement will be executed. Otherwise the statements after the **else** statement. -Example +Examples + The examples shows how the value of a numeric variable can be tested with -**itest**. +the :doc:`itest ` command. :: -- 2.43.0
[PATCH v3 0/6] USB keyboard improvements for asahi / desktop systems
Apple USB Keyboards from 2021 need quirks to be useable. The boot HID keyboard protocol is unfortunately not described in the first interface descriptor but the second. This needs several changes. The USB keyboard driver has to look at all (2) interface descriptors during probing. Since I didn't want to rebuild the USB driver probe code the Apple keyboards are bound to the keyboard driver via USB vendor and product IDs. To make the keyboards useable on Apple silicon devices the xhci driver needs to initializes rings for the endpoints of the first two interface descriptors. If this is causes concerns regarding regressions or memory use the USB_MAX_ACTIVE_INTERFACES define could be turned into a CONFIG option. Even after this changes the keyboards still do not probe successfully since they apparently do not behave HID standard compliant. They only generate reports on key events. This leads the final check whether the keyboard is operational to fail unless the user presses keys during the probe. Skip this check for known keyboards. Keychron seems to emulate Apple keyboards (some models even "re-use" Apple's USB vendor ID) so apply this quirk as well. Some devices like Yubikeys emulate a keyboard. since u-boot only binds a single keyboard block this kind of devices from the USB keyboard driver. Signed-off-by: Janne Grunau --- Changes in v3: - collected "Reviewed-by:" tags - rename usb_blocklist to usb_ignorelist - use BIT macro for USB KBD quirk bit - refactor usb_device_is_blocked() to use 0 / negated errors as return value, sed -e 's/block/ignore/', simplify it and add comments - rewritten usb_ignorelist documentation - Link to v2: https://lore.kernel.org/r/20240317-asahi-keyboards-v2-0-d3f4b8384...@jannau.net Changes in v2: - rewritten commit message for "[PATCH 2/6] usb: xhci: Set up endpoints for the first 2 interfaces" - Replaced the usb keyboard Yubikey block with an env based USB device blocklist - Use "-EINVAL" as return value in "[PATCH 3/6] usb: xhci: Abort transfers with unallocated rings" - added "Reviewed-by:" tags - Link to v1: https://lore.kernel.org/r/20240221-asahi-keyboards-v1-0-814b2e741...@jannau.net --- Janne Grunau (6): usb: xhci: refactor xhci_set_configuration usb: xhci: Set up endpoints for the first 2 interfaces usb: xhci: Abort transfers with unallocated rings usb: Add environment based device ignorelist usb: kbd: support Apple Magic Keyboards (2021) usb: kbd: Add probe quirk for Apple and Keychron keyboards common/usb.c | 57 common/usb_kbd.c | 59 ++-- doc/usage/environment.rst| 13 + drivers/usb/host/xhci-ring.c | 5 ++ drivers/usb/host/xhci.c | 126 +++ include/env_default.h| 11 include/usb.h| 6 +++ 7 files changed, 228 insertions(+), 49 deletions(-) --- base-commit: 37345abb97ef0dd9c50a03b2a72617612dcae585 change-id: 20240218-asahi-keyboards-f2ddaf0022b2 Best regards, -- Janne Grunau
[PATCH v3 1/6] usb: xhci: refactor xhci_set_configuration
From: Janne Grunau In the next step endpoints for multiple interfaces are set up. Move most of the per endpoint initialization to separate function to avoid another identation level. Reviewed-by: Marek Vasut Reviewed-by: Neal Gompa Signed-off-by: Janne Grunau --- drivers/usb/host/xhci.c | 119 +--- 1 file changed, 73 insertions(+), 46 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index d13cbff9b3..534c4b973f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -475,67 +475,34 @@ static int xhci_configure_endpoints(struct usb_device *udev, bool ctx_change) } /** - * Configure the endpoint, programming the device contexts. + * Fill endpoint contexts for interface descriptor ifdesc. * - * @param udev pointer to the USB device structure - * Return: returns the status of the xhci_configure_endpoints + * @param udev pointer to the USB device structure + * @param ctrl pointer to the xhci pravte device structure + * @param virt_dev pointer to the xhci virtual device structure + * @param ifdesc pointer to the USB interface config descriptor + * Return: returns the status of xhci_init_ep_contexts_if */ -static int xhci_set_configuration(struct usb_device *udev) +static int xhci_init_ep_contexts_if(struct usb_device *udev, + struct xhci_ctrl *ctrl, + struct xhci_virt_device *virt_dev, + struct usb_interface *ifdesc + ) { - struct xhci_container_ctx *in_ctx; - struct xhci_container_ctx *out_ctx; - struct xhci_input_control_ctx *ctrl_ctx; - struct xhci_slot_ctx *slot_ctx; struct xhci_ep_ctx *ep_ctx[MAX_EP_CTX_NUM]; int cur_ep; - int max_ep_flag = 0; int ep_index; unsigned int dir; unsigned int ep_type; - struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); - int num_of_ep; - int ep_flag = 0; u64 trb_64 = 0; - int slot_id = udev->slot_id; - struct xhci_virt_device *virt_dev = ctrl->devs[slot_id]; - struct usb_interface *ifdesc; u32 max_esit_payload; unsigned int interval; unsigned int mult; unsigned int max_burst; unsigned int avg_trb_len; unsigned int err_count = 0; + int num_of_ep = ifdesc->no_of_ep; - out_ctx = virt_dev->out_ctx; - in_ctx = virt_dev->in_ctx; - - num_of_ep = udev->config.if_desc[0].no_of_ep; - ifdesc = &udev->config.if_desc[0]; - - ctrl_ctx = xhci_get_input_control_ctx(in_ctx); - /* Initialize the input context control */ - ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG); - ctrl_ctx->drop_flags = 0; - - /* EP_FLAG gives values 1 & 4 for EP1OUT and EP2IN */ - for (cur_ep = 0; cur_ep < num_of_ep; cur_ep++) { - ep_flag = xhci_get_ep_index(&ifdesc->ep_desc[cur_ep]); - ctrl_ctx->add_flags |= cpu_to_le32(1 << (ep_flag + 1)); - if (max_ep_flag < ep_flag) - max_ep_flag = ep_flag; - } - - xhci_inval_cache((uintptr_t)out_ctx->bytes, out_ctx->size); - - /* slot context */ - xhci_slot_copy(ctrl, in_ctx, out_ctx); - slot_ctx = xhci_get_slot_ctx(ctrl, in_ctx); - slot_ctx->dev_info &= ~(cpu_to_le32(LAST_CTX_MASK)); - slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(max_ep_flag + 1) | 0); - - xhci_endpoint_copy(ctrl, in_ctx, out_ctx, 0); - - /* filling up ep contexts */ for (cur_ep = 0; cur_ep < num_of_ep; cur_ep++) { struct usb_endpoint_descriptor *endpt_desc = NULL; struct usb_ss_ep_comp_descriptor *ss_ep_comp_desc = NULL; @@ -561,7 +528,8 @@ static int xhci_set_configuration(struct usb_device *udev) avg_trb_len = max_esit_payload; ep_index = xhci_get_ep_index(endpt_desc); - ep_ctx[ep_index] = xhci_get_ep_ctx(ctrl, in_ctx, ep_index); + ep_ctx[ep_index] = xhci_get_ep_ctx(ctrl, virt_dev->in_ctx, + ep_index); /* Allocate the ep rings */ virt_dev->eps[ep_index].ring = xhci_ring_alloc(ctrl, 1, true); @@ -614,6 +582,65 @@ static int xhci_set_configuration(struct usb_device *udev) } } + return 0; +} + +/** + * Configure the endpoint, programming the device contexts. + * + * @param udev pointer to the USB device structure + * Return: returns the status of the xhci_configure_endpoints + */ +static int xhci_set_configuration(struct usb_device *udev) +{ + struct xhci_container_ctx *out_ctx; + struct xhci_container_ctx *in_ctx; + struct xhci_input_control_ctx *ctrl_ctx; + struct xhci_slot_ctx *slot_ctx; + int err; + int cur_ep; + int max_ep_flag = 0; + struct xhci_ctrl *ctrl = xhci_get_ctrl(udev); +
[PATCH v3 5/6] usb: kbd: support Apple Magic Keyboards (2021)
From: Janne Grunau Apple USB keyboards (Magic Keyboard from 2021 (product id 0x029c)) carry the HID keyboard boot protocol on the second interface descriptor. Probe via vendor and product IDs since the class/subclass/protocol match uses the first interface descriptor. Probe the two first interface descriptors for the HID keyboard boot protocol. USB configuration descriptor for reference: | Bus 003 Device 002: ID 05ac:029c Apple, Inc. Magic Keyboard | Device Descriptor: | bLength18 | bDescriptorType 1 | bcdUSB 2.00 | bDeviceClass0 [unknown] | bDeviceSubClass 0 [unknown] | bDeviceProtocol 0 | bMaxPacketSize064 | idVendor 0x05ac Apple, Inc. | idProduct 0x029c Magic Keyboard | bcdDevice3.90 | iManufacturer 1 Apple Inc. | iProduct2 Magic Keyboard | iSerial 3 ... | bNumConfigurations 1 | Configuration Descriptor: | bLength 9 | bDescriptorType 2 | wTotalLength 0x003b | bNumInterfaces 2 | bConfigurationValue 1 | iConfiguration 4 Keyboard | bmAttributes 0xa0 | (Bus Powered) | Remote Wakeup | MaxPower 500mA | Interface Descriptor: | bLength 9 | bDescriptorType 4 | bInterfaceNumber0 | bAlternateSetting 0 | bNumEndpoints 1 | bInterfaceClass 3 Human Interface Device | bInterfaceSubClass 0 [unknown] | bInterfaceProtocol 0 | iInterface 5 Device Management | HID Device Descriptor: | bLength 9 | bDescriptorType33 | bcdHID 1.10 | bCountryCode0 Not supported | bNumDescriptors 1 | bDescriptorType34 Report | wDescriptorLength 83 | Report Descriptors: | ** UNAVAILABLE ** | Endpoint Descriptor: | bLength 7 | bDescriptorType 5 | bEndpointAddress 0x81 EP 1 IN | bmAttributes3 | Transfer TypeInterrupt | Synch Type None | Usage Type Data | wMaxPacketSize 0x0010 1x 16 bytes | bInterval 8 | Interface Descriptor: | bLength 9 | bDescriptorType 4 | bInterfaceNumber1 | bAlternateSetting 0 | bNumEndpoints 1 | bInterfaceClass 3 Human Interface Device | bInterfaceSubClass 1 Boot Interface Subclass | bInterfaceProtocol 1 Keyboard | iInterface 6 Keyboard / Boot | HID Device Descriptor: | bLength 9 | bDescriptorType33 | bcdHID 1.10 | bCountryCode 13 International (ISO) | bNumDescriptors 1 | bDescriptorType34 Report | wDescriptorLength 207 | Report Descriptors: | ** UNAVAILABLE ** | Endpoint Descriptor: | bLength 7 | bDescriptorType 5 | bEndpointAddress 0x82 EP 2 IN | bmAttributes3 | Transfer TypeInterrupt | Synch Type None | Usage Type Data | wMaxPacketSize 0x0010 1x 16 bytes | bInterval 8 Reviewed-by: Marek Vasut Reviewed-by: Neal Gompa Signed-off-by: Janne Grunau --- common/usb_kbd.c | 37 ++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 4cbc9acb73..b2361bbf18 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -23,6 +23,14 @@ #include +/* + * USB vendor and product IDs used for quirks. + */ +#define USB_VENDOR_ID_APPLE0x05ac +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_20210x029c +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_20210x029a +#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021 0x029f + /* * If overwrite_console returns 1, the stdin, stderr and stdout * are switched to the serial port, else the settings in the @@ -106,6 +114,8 @@ struct usb_kbd_pdata { unsigned long last_report; struct int_queue *intq; + uint32_tifnum; + uint32_trepeat_delay; uint32_tusb_in_pointer; @@ -150,8 +160,8 @@ static void usb_kbd_put_queue(struct usb_kbd_pdata *data, u8 c) */ static void usb_kbd_setled(struct usb_device *dev) { - struct usb_interface *iface = &dev->config.if_desc[0]; struct usb_kbd_pdata *data = dev->privptr; + struct usb_inter