[PATCH 2/2] topic: Use distro_boot for topic-miami boards
Adjust configuration and devicetree so the topic-miami board actually boots. Replace the custom scripting and just use distro_boot. Override the standard zynq routines. The board attempts to boot from SD card first, and falls back to booting UBIFS from the QSPI NOR flash. Signed-off-by: Mike Looijmans --- arch/arm/dts/zynq-topic-miami.dts | 33 - configs/topic_miami_defconfig | 20 +- include/configs/topic_miami.h | 116 ++ 3 files changed, 88 insertions(+), 81 deletions(-) diff --git a/arch/arm/dts/zynq-topic-miami.dts b/arch/arm/dts/zynq-topic-miami.dts index 8307a2ef9dd..29f0a4f8280 100644 --- a/arch/arm/dts/zynq-topic-miami.dts +++ b/arch/arm/dts/zynq-topic-miami.dts @@ -11,6 +11,10 @@ model = "Topic Miami Zynq Board"; compatible = "topic,miami", "xlnx,zynq-7000"; + config { + u-boot,spl-payload-offset = <0x2>; + }; + aliases { serial0 = &uart0; spi0 = &qspi; @@ -35,6 +39,7 @@ status = "okay"; num-cs = <1>; flash@0 { + bootph-all; compatible = "st,m25p80", "n25q256a", "jedec,spi-nor"; m25p,fast-read; reg = <0x0>; @@ -44,24 +49,12 @@ #address-cells = <1>; #size-cells = <1>; partition@0 { - label = "qspi-u-boot-spl"; - reg = <0x0 0x1>; - }; - partition@1 { - label = "qspi-u-boot-img"; - reg = <0x1 0x6>; + label = "qspi-boot-bin"; + reg = <0x0 0x10>; }; - partition@7 { - label = "qspi-device-tree"; - reg = <0x7 0x1>; - }; - partition@8 { - label = "qspi-linux"; - reg = <0x8 0x40>; - }; - partition@48 { + partition@10 { label = "qspi-rootfs"; - reg = <0x48 0x1b8>; + reg = <0x10 0>; }; }; }; @@ -74,6 +67,14 @@ &i2c1 { status = "okay"; clock-frequency = <40>; + /* GPIO expander */ + gpioex: pca953x@41 { + compatible = "nxp,pca9536"; + reg = <0x41>; + gpio-line-names = "USB_RESET", "VTT_SHDWN_N", "V_PRESENT", "DEBUG_PRESENT"; + gpio-controller; + #gpio-cells = <2>; + }; }; &clkc { diff --git a/configs/topic_miami_defconfig b/configs/topic_miami_defconfig index 039ac710b38..e71e1063835 100644 --- a/configs/topic_miami_defconfig +++ b/configs/topic_miami_defconfig @@ -28,7 +28,6 @@ CONFIG_SYS_CUSTOM_LDSCRIPT=y CONFIG_SYS_LDSCRIPT="arch/arm/mach-zynq/u-boot.lds" CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTDELAY=0 -CONFIG_BOOTCOMMAND="if mmcinfo; then if fatload mmc 0 0x190 ${bootscript}; then source 0x190; fi; fi; run $modeboot" CONFIG_USE_PREBOOT=y CONFIG_SYS_PBSIZE=2077 CONFIG_CLOCKS=y @@ -40,15 +39,25 @@ CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x2 CONFIG_SYS_PROMPT="zynq-uboot> " CONFIG_SYS_MAXARGS=32 +# CONFIG_CMD_BOOTEFI is not set +# CONFIG_CMD_ELF is not set +# CONFIG_CMD_SPL is not set CONFIG_CMD_THOR_DOWNLOAD=y CONFIG_THOR_RESET_OFF=y +# CONFIG_CMD_SAVEENV is not set CONFIG_CMD_MEMTEST=y CONFIG_CMD_DFU=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_MTD=y CONFIG_CMD_USB=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_CACHE=y +# CONFIG_CMD_EFICONFIG is not set +CONFIG_CMD_SQUASHFS=y +CONFIG_MTDIDS_DEFAULT="nor0=spi0.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:0x10(qspi-boot-bin),-(qspi-rootfs)" +CONFIG_CMD_UBI=y CONFIG_OF_EMBED=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y @@ -56,14 +65,18 @@ CONFIG_NO_NET=y CONFIG_SPL_DM_SEQ_ALIAS=y CONFIG_DFU_RAM=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x60 -CONFIG_FPGA_XILINX=y -CONFIG_FPGA_ZYNQPL=y +CONFIG_DM_PCA953X=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_CADENCE=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ZYNQ=y +CONFIG_DM_MTD=y +CONFIG_MTD_BLOCK=y CONFIG_SPI_FLASH_STMICRO=y # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set +CONFIG_SPI_FLASH_MTD=y +CONFIG_MTD_UBI_BEB_LIMIT=0 +CONFIG_UBI_BLOCK=y CONFIG_DEBUG_UART_ZYNQ=y CONFIG_ARM_DCC=y CONFIG_ZYNQ_SERIAL=y @@ -79,3 +92,4 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x0300 CONFIG_CI_UDC=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_SYS_TIMER_COUNTS_DOWN=y +CONFIG_LZ4=y diff --git a/include/configs/topic_miami.h b/include/configs/topic_miami.h index 06276175455..5530d36339c 100644 --- a/include/configs/topic_miami.h +++ b/include/configs/topic_miami.h @@ -9,75 +9,67 @@ #ifndef __CONFIG_TOPIC_MIAMI_H #define __CONFIG_TOPIC_MIAMI_H -/* Speed up boot time by ignoring the environment which we never used */ +#
[PATCH 1/2] xilinx: Allow alternative boot strategies in zynq-common.h
Allow config headers that include zynq-common.h to provide their own (distro) boot strategies. This is implemented by skipping the section when BOOT_ENV has already been defined. Signed-off-by: Mike Looijmans --- include/configs/zynq-common.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 37c77aa1611..ad872c9d922 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -48,6 +48,9 @@ #define BOOTENV #else +/* Only use this section if no BOOTENV has been configured yet */ +#ifndef BOOTENV + #ifdef CONFIG_CMD_MMC #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1) #else @@ -167,6 +170,9 @@ BOOT_TARGET_DEVICES_DHCP(func) #include + +#endif /* BOOTENV */ + #endif /* CONFIG_XPL_BUILD */ /* Default environment */ -- 2.43.0 Met vriendelijke groet / kind regards, Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: mike.looijm...@topic.nl W: www.topic.nl Please consider the environment before printing this e-mail
[PATCH v2 1/1] common: edid: update timing selection logic
From: Jonas Schwöbel Older EDID timing algorithms relied solely on detailed timings, typically optimized for a display's native resolution. This caused issues with newer 4K panels on older hardware, which couldn't handle those high resolutions. To address this, the algorithm now also considers standard timings, offering lower, compatible resolutions. Future improvements may include checking established timings for even broader compatibility. Signed-off-by: Jonas Schwöbel Signed-off-by: Svyatoslav Ryhel --- common/edid.c | 308 -- 1 file changed, 273 insertions(+), 35 deletions(-) diff --git a/common/edid.c b/common/edid.c index 48a737690db..e2ac7100a88 100644 --- a/common/edid.c +++ b/common/edid.c @@ -16,6 +16,197 @@ #include #include +#define TIMING(c, ha, hfp, hbp, hsl, va, vfp, vbp, vsl, f) \ + .pixelclock = { (c), (c), (c) },\ + .hactive = { (ha), (ha), (ha) },\ + .hfront_porch = { (hfp), (hfp), (hfp) },\ + .hback_porch = { (hbp), (hbp), (hbp) }, \ + .hsync_len = { (hsl), (hsl), (hsl) }, \ + .vactive = { (va), (va), (va) },\ + .vfront_porch = { (vfp), (vfp), (vfp) },\ + .vback_porch = { (vbp), (vbp), (vbp) }, \ + .vsync_len = { (vsl), (vsl), (vsl) }, \ + .flags = (f) + +static const struct display_timing dmt_timings[] = { + { TIMING(3150, 640, 32, 64, 96, 350, 32, 3, 60, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(3150, 640, 32, 64, 96, 400, 1, 3, 41, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(3550, 720, 36, 72, 108, 400, 1, 3, 42, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(25175000, 640, 16, 96, 48, 480, 10, 2, 33, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(3150, 640, 24, 40, 128, 480, 9, 3, 28, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(3150, 640, 16, 64, 120, 480, 1, 3, 16, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(3600, 640, 56, 56, 80, 480, 1, 3, 25, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(3600, 800, 24, 72, 128, 600, 1, 2, 22, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(4000, 800, 40, 128, 88, 600, 1, 4, 23, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(5000, 800, 56, 120, 64, 600, 37, 6, 23, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(4950, 800, 16, 80, 160, 600, 1, 3, 21, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(5625, 800, 32, 64, 152, 600, 1, 3, 27, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(7325, 800, 48, 32, 80, 600, 3, 4, 29, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(3375, 848, 16, 112, 112, 480, 6, 8, 23, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(4490, 1024, 8, 176, 56, 768, 0, 8, 41, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(6500, 1024, 24, 136, 160, 768, 3, 6, 29, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(7500, 1024, 24, 136, 144, 768, 3, 6, 29, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(7875, 1024, 16, 96, 176, 768, 1, 3, 28, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(9450, 1024, 48, 96, 208, 768, 1, 3, 36, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(11550, 1024, 48, 32, 80, 768, 3, 4, 38, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(10800, 1152, 64, 128, 256, 864, 1, 3, 32, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(7425, 1280, 110, 40, 220, 720, 5, 5, 20, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(6825, 1280, 48, 32, 80, 768, 3, 7, 12, +DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_LOW) }, + { TIMING(7950, 1280, 64, 128, 192, 768, 3, 7, 20, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(10225, 1280, 80, 128, 208, 768, 3, 7, 27, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_HIGH) }, + { TIMING(11750, 1280, 80, 136, 216, 768, 3, 7, 31, +DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_HIGH) },
[PATCH v2 0/1] common: edid: update timing selection logic
Older EDID timing algorithms relied solely on detailed timings, typically optimized for a display's native resolution. This caused issues with newer 4K panels on older hardware, which couldn't handle those high resolutions. To address this, the algorithm now also considers standard timings, offering lower, compatible resolutions. Future improvements may include checking established timings for even broader compatibility. --- Changes in v2: - shuffle code to improve readability and avoid duplicates --- Jonas Schwöbel (1): common: edid: update timing selection logic common/edid.c | 308 -- 1 file changed, 273 insertions(+), 35 deletions(-) -- 2.43.0
Re: [PATCH v1 6/6] configs: add qcom_ipq5424_mmc_defconfig
Hi Varadarajan, Thanks for the series, and apologies for the slow reply, i've been out sick and still finding my feet again. On 3/4/25 11:01, Varadarajan Narayanan wrote: Introduce a defconfig for the Qualcomm IPQ5424 SoC based RDPs. Presently supports eMMC. Per the flash memory layout, U-Boot size cannot exceed 756KB. With this defconfig, u-boot.mbn size is ~480KB. What are the differences between this and the other new IPQ platform? Can they share a defconfig? Alternatively, could most of the things here be de-duplicated so there is a "base" config which they both #include (similarly to qcm6490_defconfig) this way we can nicely keep track of what parts of board specific. If you'd prefer to keep it this way that's fine too. Should I be expecting more platforms like this? Kind regards, Signed-off-by: Varadarajan Narayanan --- configs/qcom_ipq5424_mmc_defconfig | 83 ++ 1 file changed, 83 insertions(+) create mode 100644 configs/qcom_ipq5424_mmc_defconfig diff --git a/configs/qcom_ipq5424_mmc_defconfig b/configs/qcom_ipq5424_mmc_defconfig new file mode 100644 index 00..0dd46680b0 --- /dev/null +++ b/configs/qcom_ipq5424_mmc_defconfig @@ -0,0 +1,83 @@ +CONFIG_ARM=y +CONFIG_SKIP_LOWLEVEL_INIT=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_SYS_INIT_SP_BSS_OFFSET=1572864 +CONFIG_ARCH_SNAPDRAGON=y +CONFIG_NR_DRAM_BANKS=24 +CONFIG_DEFAULT_DEVICE_TREE="qcom/ipq5424-rdp466" +CONFIG_SYS_LOAD_ADDR=0x5000 +CONFIG_FIT=y +CONFIG_FIT_VERBOSE=y +# CONFIG_EFI_LOADER is not set +# CONFIG_EFI_BINARY_EXEC is not set +# CONFIG_EFI_VARIABLE_FILE_STORE is not set +# CONFIG_PXE_UTILS is not set +# CONFIG_BOOTSTD is not set +# CONFIG_BOOTMETH_VBE is not set +CONFIG_BOOTDELAY=2 +CONFIG_OF_BOARD_SETUP=y +CONFIG_USE_PREBOOT=y +CONFIG_LOG_MAX_LEVEL=9 +CONFIG_LOG_DEFAULT_LEVEL=4 +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y +CONFIG_CMD_PART=y +CONFIG_OF_LIVE=y +CONFIG_USE_DEFAULT_ENV_FILE=y +CONFIG_DEFAULT_ENV_FILE="board/qualcomm/default.env" +CONFIG_CLK=y +CONFIG_CLK_QCOM_IPQ5424=y +CONFIG_DFU_MMC=y +CONFIG_DFU_SCSI=y +CONFIG_SYS_DFU_DATA_BUF_SIZE=0x20 +CONFIG_MSM_GPIO=y +CONFIG_PINCTRL=y +CONFIG_PINCONF=y +CONFIG_PINCTRL_QCOM_IPQ5424=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_ADMA=y +CONFIG_MMC_SDHCI_MSM=y +CONFIG_MMC_HS200_SUPPORT=y +CONFIG_DM_MDIO=y +CONFIG_DM_ETH_PHY=y +CONFIG_DWC_ETH_QOS=y +CONFIG_DWC_ETH_QOS_QCOM=y +CONFIG_RGMII=y +CONFIG_PHY=y +CONFIG_PHY_QCOM_QMP_UFS=y +CONFIG_PHY_QCOM_QUSB2=y +CONFIG_SCSI=y +CONFIG_MSM_SERIAL=y +CONFIG_MSM_GENI_SERIAL=y +CONFIG_SOC_QCOM=y +CONFIG_DEBUG_UART=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_DEBUG_UART_BASE=0x1a84000 +CONFIG_DEBUG_UART_MSM_GENI=y +CONFIG_DEBUG_UART_CLOCK=14745600 +CONFIG_TEXT_BASE=0x8a38 +CONFIG_REMAKE_ELF=y +CONFIG_FIT=y +CONFIG_FIT_VERBOSE=y +CONFIG_BOOTSTD_FULL=y +CONFIG_SYS_CBSIZE=1024 +CONFIG_SYS_PBSIZE=1024 +CONFIG_OF_LIVE=y +CONFIG_MSM_SERIAL=y +CONFIG_DM_EVENT=y +CONFIG_ENV_IS_IN_MMC=y +CONFIG_ENV_SIZE=0x4 +CONFIG_ENV_OFFSET=0 +CONFIG_PARTITIONS=y +CONFIG_PARTITION_UUIDS=y +CONFIG_MTD=y +CONFIG_MTD_PARTS=y +CONFIG_HUSH_PARSER=y +CONFIG_PARTITIONS=y +CONFIG_EFI_PARTITION=y +# CONFIG_I2C is not set +# CONFIG_INPUT is not set +# CONFIG_SCSI is not set +# CONFIG_SPMI is not set -- Caleb (they/them)
Re: [PATCH] cmd: version: Get information about GCC and LD back
On Mon, Mar 10, 2025 at 08:49:32AM +0100, Michal Simek wrote: > > > On 3/6/25 15:12, Michal Simek wrote: > > > > > > On 3/6/25 15:02, Tom Rini wrote: > > > On Thu, Mar 06, 2025 at 11:12:30AM +0100, Michal Simek wrote: > > > > U-Boot version command is no longer showing information about GCC and > > > > LD. > > > > The reason is that version.h has been removed that's why > > > > CC_VERSION_STRING > > > > and LD_VERSION_STRING are not pass. > > > > Values are generated to generated/version_autogenerated.h which is > > > > sourced > > > > in version.h. > > > > > > > > Fixes: 54ecce2cbf90 ("version: Separate our version string from > > > > the version command") > > > > Signed-off-by: Michal Simek > > > > --- > > > > > > > > Tom: Not sure if this has been done on purpose or not but this issue has > > > > been reported by our regression team. > > > > > > It wasn't on purpose, no. Did you put this through CI / confirm > > > sandbox_nocmdline still builds? > > > > Nope I did not. > > CI is not reporting any issue. > > https://source.denx.de/u-boot/custodians/u-boot-microblaze/-/pipelines/25029 Thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH v1] config: falcon: move CFG_SYS_SPI_* to Kconfig
On Mon, Mar 10, 2025 at 07:06:46PM +0530, Anshul Dalal wrote: > CFG_SYS_SPI_* are used in falcon boot to specify the offsets and size of > the repsective payloads. This patch moves them to Kconfig keeping the > values consistent for each of the effected boards. > > Signed-off-by: Anshul Dalal > --- > Tested: > * U-boot CI: https://github.com/u-boot/u-boot/pull/750 Thanks for doing the move. Once Fabio's comments are included: Reviewed-by: Tom Rini -- Tom signature.asc Description: PGP signature
[PATCH v2 4/4] doc: board/qualcomm: describe phone support and bringup
Add some documentation which attempts to describe Qualcomm smartphone support with the qcom-phone.config fragment, as well as a high level debugging guide for diagnosing U-Boot issues when UART and framebuffer are unavailable. Reviewed-by: Simon Glass Signed-off-by: Caleb Connolly --- doc/board/qualcomm/board.rst | 5 ++ doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/phones.rst | 122 ++ 3 files changed, 128 insertions(+) diff --git a/doc/board/qualcomm/board.rst b/doc/board/qualcomm/board.rst index 4d793209f9e31e6447c696ccd07af206dba99645..003d59a18ebd3f19db568fa59e9fd06906e209f2 100644 --- a/doc/board/qualcomm/board.rst +++ b/doc/board/qualcomm/board.rst @@ -89,8 +89,13 @@ Or for db410c (and other boards not supported by the generic target):: make CROSS_COMPILE=aarch64-linux-gnu- O=.output dragonboard410c_defconfig make O=.output -j$(nproc) +Or for smartphones:: + + make CROSS_COMPILE=aarch64-linux-gnu- O=.output qcom_defconfig qcom-phone.config + make O=.output -j$(nproc) + - gzip u-boot:: gzip u-boot-nodtb.bin diff --git a/doc/board/qualcomm/index.rst b/doc/board/qualcomm/index.rst index 8c7969987a9704bd6044197574f8da16b3848bd4..db59b81134b84cd5865a07cd1a294de9bdf12c5f 100644 --- a/doc/board/qualcomm/index.rst +++ b/doc/board/qualcomm/index.rst @@ -9,4 +9,5 @@ Qualcomm dragonboard410c rb3gen2 board debugging + phones diff --git a/doc/board/qualcomm/phones.rst b/doc/board/qualcomm/phones.rst new file mode 100644 index ..d9a582f5abec7801cad997ccae464975dfb24ac3 --- /dev/null +++ b/doc/board/qualcomm/phones.rst @@ -0,0 +1,122 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. sectionauthor:: Caleb Connolly + +== +Booting U-Boot on Qualcomm smartphones +== + +About this +-- + +This page attempts to the describe U-Boot support for Qualcomm phones, as a user guide but also a +technical introduction to How Stuff Works to help new porters. + +In broad strokes, U-Boot should boot if the SoC is supported, and the device is already capable of +booting an upstream Linux kernel. + +The list of supported Qualcomm SoCs changes often, for now it is best to look in +``drivers/clk/qcom/`` to get a rough idea. + +For building instructions, see :doc:`board`. + +Phone bringup +- + +It is usually easier to get Linux booting first, there are many good resources for this such as the +`postmarketOS wiki`_. Once the device can boot Linux with logs on the display and ideally USB gadget +support, it is highly likely that U-Boot will boot as well. + +For logs on display, you should have a simple framebuffer node defined in your DT, newer devices +require that this follow the downstream naming scheme (that the DTB is compiled with labels enabled +and the framebuffer reserved-memory region is labelled ``cont_splash``). Once this is working in +Linux it should also work in U-Boot. + +In practise, U-Boot still has many more papercuts than Linux, which can be sticking points when +porting a new device. In particular, drivers failing to bind/probe (especially pre-relocation) can +be tricky to debug without UART since U-Boot will simply panic with no way to inform you of +the error. As a result, bringing up a new device can be quite frustrating, but there are quite a few +things you can try. + +The phone config + + +Since most phones lack a physical keyboard or serial port, a special config fragment and environment +file can be used to provide a more seamless experience. This can be enabled by generating the config +with:: + + make CROSS_COMPILE=aarch64-linux-gnu- O=.output qcom_defconfig qcom-phone.config + +The config and associated environment file can be found in board/qualcomm/. The main changes are: + +- Panic on hang (so the panic message can be read on the display) +- Boot retry (to automatically open and re-open the bootmenu) +- A boot menu with helpful shortcuts (including USB console gadget) +- Launch the boot menu if power is held during boot or on boot failure + +Hang/crash bisection + + +Without a way to get logs, we can still get quite far with only a few bits of information: what +happens when you ``fastboot boot u-boot.img``? + +Does the device disconnect? +^^^ + +This can be verified by watching ``dmesg -w``. If it stays connected, it likely means the boot image +doesn't match what the bootloader expected, use ``unpack_bootimg`` to compare it with a known-good +boot image (ideally one with an upstream kernel). + +Does the device hang? +^ + +If it stays on a black screen and does nothing, then that's a hang! Since ``qcom-phone.config`` +enables CONFIG_PANIC_HANG, this likely means that you're successfully executing U-Boot code (yay!), +but something is causing a p
[PATCH 08/19] arm: mach-k3: am62a7_init: Resume on LPM exit
When exiting a low power mode with DDR self-refresh, we can directly resume after DDR setup is done. Call the common function to resume. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/am62ax/am62a7_init.c | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/arm/mach-k3/am62ax/am62a7_init.c b/arch/arm/mach-k3/am62ax/am62a7_init.c index 7697e365c6ea1b9a4819fe813a63d4ee8fc9de8f..a7f7b9b5c2eb48a1049d1a79980e0cff83321a98 100644 --- a/arch/arm/mach-k3/am62ax/am62a7_init.c +++ b/arch/arm/mach-k3/am62ax/am62a7_init.c @@ -166,6 +166,15 @@ void board_init_f(ulong dummy) ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) panic("DRAM init failed: %d\n", ret); + + if (wkup_ctrl_is_lpm_exit()) { + u64 meta_data_addr; + + ret = wkup_r5f_am62_lpm_meta_data_addr(&meta_data_addr); + if (ret) + panic("Failed to get LPM meta data address %d\n", ret); + lpm_resume_from_ddr(meta_data_addr); + } #endif setup_qos(); -- 2.47.2
Re: [PATCH 06/10] test/py: Rework test_eficonfig to not use virt-make-fs
Hi Tom, I've never really looked at our fs helper functions but this looks reasonable On Fri, 7 Mar 2025 at 01:23, Tom Rini wrote: > > The problem with using "virt-make-fs" to make a filesystem image is that > it is extremely slow. Switch to using the fs_helper functions we have > instead from the filesystem tests as these can add files to images and > are significantly faster and still do not require root access. > > As this test already had a number of internal functions, add a > prepare_image function to do this part of the test. > > Signed-off-by: Tom Rini > --- > I noted to Heinrich in private that this test is currently disabled. I > re-enabled it locally to verify that the disk image is created correctly > still. > > Cc: Ilias Apalodimas > Cc: Heinrich Schuchardt > --- > .../{test_eficonfig => }/test_eficonfig.py| 53 --- > test/py/tests/test_eficonfig/conftest.py | 40 -- > 2 files changed, 46 insertions(+), 47 deletions(-) > rename test/py/tests/{test_eficonfig => }/test_eficonfig.py (89%) > delete mode 100644 test/py/tests/test_eficonfig/conftest.py > > diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py > b/test/py/tests/test_eficonfig.py > similarity index 89% > rename from test/py/tests/test_eficonfig/test_eficonfig.py > rename to test/py/tests/test_eficonfig.py > index d98de5249dfd..caccd1f42190 100644 > --- a/test/py/tests/test_eficonfig/test_eficonfig.py > +++ b/test/py/tests/test_eficonfig.py > @@ -2,13 +2,57 @@ > """ Unit test for UEFI menu-driven configuration > """ > > +import pytest > +import shutil > import pytest > import time > +from subprocess import call, check_call, CalledProcessError > +from tests import fs_helper > > @pytest.mark.boardspec('sandbox') > @pytest.mark.buildconfigspec('cmd_eficonfig') > @pytest.mark.buildconfigspec('cmd_bootefi_bootmgr') > -def test_efi_eficonfig(u_boot_console, efi_eficonfig_data): > +def test_efi_eficonfig(u_boot_console): > + > +def prepare_image(u_boot_config): > +"""Set up a file system to be used in UEFI "eficonfig" command > + tests. This creates a disk image with the following files: > + initrd-1.img > + initrd-2.img > + initrddump.efi > + > +Args: > +u_boot_config -- U-Boot configuration. > + > +Return: > +A path to disk image to be used for testing > + > +""" > +try: > +image_path, mnt_point = fs_helper.setup_image(u_boot_config, 0, > + 0xc, > + > basename='test_eficonfig') > + > +with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') > as file: > +file.write("initrd 1") > + > +with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') > as file: > +file.write("initrd 2") > + > +shutil.copyfile(u_boot_config.build_dir + > '/lib/efi_loader/initrddump.efi', > +mnt_point + '/initrddump.efi') > + > +fsfile = fs_helper.mk_fs(u_boot_console.config, 'vfat', 0x10, > + 'test_eficonfig', mnt_point) > +check_call(f'dd if={fsfile} of={image_path} bs=1M seek=1', > shell=True) > + > +yield image_path > +except CalledProcessError as err: > +pytest.skip('Preparing test_eficonfig image failed') > +call('rm -f %s' % image_path, shell=True) > +finally: > +call('rm -rf %s' % mnt_point, shell=True) > +call('rm -f %s' % image_path, shell=True) > > def send_user_input_and_wait(user_str, expect_str): > time.sleep(0.1) # TODO: does not work correctly without sleep > @@ -57,12 +101,6 @@ def test_efi_eficonfig(u_boot_console, > efi_eficonfig_data): > > Args: > u_boot_console -- U-Boot console > -efi__data -- Path to the disk image used for testing. > - Test disk image has following files. > - initrd-1.img > - initrd-2.img > - initrddump.efi > - > """ > # This test passes for unknown reasons in the bowels of U-Boot. It needs > to > # be replaced with a unit test. > @@ -71,6 +109,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data): > # Restart the system to clean the previous state > u_boot_console.restart_uboot() > > +efi_eficonfig_data = prepare_image(u_boot_console.config) > with u_boot_console.temporary_timeout(500): > # > # Test Case 1: Check the menu is displayed > diff --git a/test/py/tests/test_eficonfig/conftest.py > b/test/py/tests/test_eficonfig/conftest.py > deleted file mode 100644 > index 0a82fbefd752.. > --- a/test/py/tests/test_eficonfig/conftest.py > +++ /dev/null > @@ -1,40 +0,0 @@ > -# S
Re: [PATCH 08/10] test/py: Rework test_efi_secboot to not use virt-make-fs
On Fri, 7 Mar 2025 at 01:23, Tom Rini wrote: > > The problem with using "virt-make-fs" to make a filesystem image is that > it is extremely slow. Switch to using the fs_helper functions we have > instead from the filesystem tests as these can add files to images and > are significantly faster and still do not require root access. > > Signed-off-by: Tom Rini > --- > Cc: Ilias Apalodimas > Cc: Heinrich Schuchardt > --- > test/py/tests/test_efi_secboot/conftest.py | 32 ++ > 1 file changed, 15 insertions(+), 17 deletions(-) > > diff --git a/test/py/tests/test_efi_secboot/conftest.py > b/test/py/tests/test_efi_secboot/conftest.py > index 0fa0747fc764..bd05bfc55c7d 100644 > --- a/test/py/tests/test_efi_secboot/conftest.py > +++ b/test/py/tests/test_efi_secboot/conftest.py > @@ -5,6 +5,7 @@ > """Fixture for UEFI secure boot test.""" > > from subprocess import call, check_call, CalledProcessError > +from tests import fs_helper > import pytest > from defs import * > > @@ -19,13 +20,10 @@ def efi_boot_env(request, u_boot_config): > Return: > A path to disk image to be used for testing > """ > -image_path = u_boot_config.persistent_data_dir > -image_path = image_path + '/test_efi_secboot.img' > > try: > -mnt_point = u_boot_config.build_dir + '/mnt_efisecure' > -check_call('rm -rf {}'.format(mnt_point), shell=True) > -check_call('mkdir -p {}'.format(mnt_point), shell=True) > +image_path, mnt_point = fs_helper.setup_image(u_boot_config, 0, 0xc, > + > basename='test_efi_secboot') > > # suffix > # *.key: RSA private key in PEM > @@ -123,9 +121,9 @@ def efi_boot_env(request, u_boot_config): > % (mnt_point, EFITOOLS_PATH), > shell=True) > > -check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat {} > {}'.format( > -mnt_point, image_path), shell=True) > -check_call('rm -rf {}'.format(mnt_point), shell=True) > +fsfile = fs_helper.mk_fs(u_boot_config, 'vfat', 0x100, > + 'test_efi_secboot', mnt_point) > +check_call(f'dd if={fsfile} of={image_path} bs=1M seek=1', > shell=True) > > except CalledProcessError as exception: > pytest.skip('Setup failed: %s' % exception.cmd) > @@ -133,7 +131,8 @@ def efi_boot_env(request, u_boot_config): > else: > yield image_path > finally: > -call('rm -f %s' % image_path, shell=True) > +call('rm -rf %s' % mnt_point, shell=True) > +call('rm -f %s %s' % (image_path, fsfile), shell=True) > > # > # Fixture for UEFI secure boot test of intermediate certificates > @@ -154,13 +153,10 @@ def efi_boot_env_intca(request, u_boot_config): > Return: > A path to disk image to be used for testing > """ > -image_path = u_boot_config.persistent_data_dir > -image_path = image_path + '/test_efi_secboot_intca.img' > > try: > -mnt_point = u_boot_config.persistent_data_dir + > '/mnt_efi_secboot_intca' > -check_call('rm -rf {}'.format(mnt_point), shell=True) > -check_call('mkdir -p {}'.format(mnt_point), shell=True) > +image_path, mnt_point = fs_helper.setup_image(u_boot_config, 0, 0xc, > + > basename='test_efi_secboot_intca') > > # Create signature database > # PK > @@ -242,8 +238,9 @@ def efi_boot_env_intca(request, u_boot_config): > check_call('cd %s; cat TestSub.crt TestRoot.crt > TestSubRoot.crt; > %ssbsign --key TestCert.key --cert TestCert.crt --addcert TestSubRoot.crt > --out helloworld.efi.signed_abc helloworld.efi' > % (mnt_point, SBSIGN_PATH), shell=True) > > -check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat {} > {}'.format(mnt_point, image_path), shell=True) > -check_call('rm -rf {}'.format(mnt_point), shell=True) > +fsfile = fs_helper.mk_fs(u_boot_config, 'vfat', 0x100, > + 'test_efi_secboot_intca', mnt_point) > +check_call(f'dd if={fsfile} of={image_path} bs=1M seek=1', > shell=True) > > except CalledProcessError as e: > pytest.skip('Setup failed: %s' % e.cmd) > @@ -251,4 +248,5 @@ def efi_boot_env_intca(request, u_boot_config): > else: > yield image_path > finally: > -call('rm -f %s' % image_path, shell=True) > +call('rm -rf %s' % mnt_point, shell=True) > +call('rm -f %s %s' % (image_path, fsfile), shell=True) > -- > 2.43.0 > Acked-by: Ilias Apalodimas
Re: [PATCH v1 1/2] ARM: tegra: clock: fix PLLD/PLLD2 related clock calculations
ср, 5 бер. 2025 р. о 16:35 Svyatoslav Ryhel пише: > > ср, 5 бер. 2025 р. о 16:02 Thierry Reding пише: > > > > On Wed, Mar 05, 2025 at 03:52:36PM +0200, Svyatoslav Ryhel wrote: > > > ср, 5 бер. 2025 р. о 15:47 Thierry Reding пише: > > > > > > > > On Wed, Mar 05, 2025 at 01:12:12PM +0200, Svyatoslav Ryhel wrote: > > > > > From: Jonas Schwöbel > > > > > > > > > > While PLLD/D2 is the nominal parent clock, all derived clocks are > > > > > generated > > > > > from its single output, plld_out0, which is PLLD/D2 divided by two. > > > > > Direct > > > > > use of PLLD/D2 is absent in peripheral clock configurations. > > > > > Therefore, > > > > > clock derivation formulas must take in account this division. > > > > > > > > > > Signed-off-by: Jonas Schwöbel > > > > > Signed-off-by: Svyatoslav Ryhel > > > > > --- > > > > > arch/arm/mach-tegra/clock.c | 30 +- > > > > > 1 file changed, 29 insertions(+), 1 deletion(-) > > > > > > > > In Linux we ended up exposing the _out0 branches of the display clocks. > > > > Wouldn't that be a better way to describe this? > > > > > > > > Thierry > > > > > > You are not satisfied with the description or with solution? > > > > I meant the solution. However I might have misunderstood what you're > > doing here. This is actually computing the rate of the _out0 branches, > > which are the ones listed in the DTS files as parents, correct? > > > > Basically this is u-boot equivalent of Linux approach, well its final > stage. This patch does 2 things. First, it updates pll_rate[id] value > if rate is changed which was not done since usually PLL do not need > updates till we hit display clocks. Second, it fixes display clock > children divider calculation taking in account that raw plld/d2 freq > is halved. And all this does not break existing drivers which use plld > in any way (I have checked that on all generations till t124 > including). > > Introducing plld_out0 instead of plld Tegra wide will basically add > more confusion and possibly hidden regressions since all drivers using > plld as parent take in account this quirk. > If you have no suggestions, objections or proposals, I assume this patch can be accepted. > > Thierry
[PATCH v1 2/3] riscv: Select appropriate image type
Select between the 32-bit or 64-bit arch type for the image headers depending on how the build is configured. Signed-off-by: Mayuresh Chitale --- arch/riscv/dts/binman.dtsi | 14 ++ arch/riscv/include/asm/u-boot.h | 4 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/riscv/dts/binman.dtsi b/arch/riscv/dts/binman.dtsi index 0405faca574..a1a566b511b 100644 --- a/arch/riscv/dts/binman.dtsi +++ b/arch/riscv/dts/binman.dtsi @@ -5,6 +5,12 @@ #include +#ifdef CONFIG_64BIT +#define ARCH "riscv64" +#else +#define ARCH "riscv" + +#endif / { binman: binman { multiple-images; @@ -31,7 +37,7 @@ description = "U-Boot"; type = "standalone"; os = "U-Boot"; - arch = "riscv"; + arch = ARCH; compression = "none"; load = /bits/ 64 ; @@ -44,7 +50,7 @@ description = "Linux"; type = "standalone"; os = "Linux"; - arch = "riscv"; + arch = ARCH; compression = "none"; load = /bits/ 64 ; @@ -57,7 +63,7 @@ tee { description = "OP-TEE"; type = "tee"; - arch = "riscv"; + arch = ARCH; compression = "none"; os = "tee"; load = /bits/ 64 ; @@ -71,7 +77,7 @@ description = "OpenSBI fw_dynamic Firmware"; type = "firmware"; os = "opensbi"; - arch = "riscv"; + arch = ARCH; compression = "none"; load = /bits/ 64 ; entry = /bits/ 64 ; diff --git a/arch/riscv/include/asm/u-boot.h b/arch/riscv/include/asm/u-boot.h index d5e1d5f3231..a90cc4c21cf 100644 --- a/arch/riscv/include/asm/u-boot.h +++ b/arch/riscv/include/asm/u-boot.h @@ -23,6 +23,10 @@ #include /* For image.h:image_check_target_arch() */ +#ifdef CONFIG_64BIT +#define IH_ARCH_DEFAULT IH_ARCH_RISCV64 +#else #define IH_ARCH_DEFAULT IH_ARCH_RISCV +#endif #endif /* _U_BOOT_H_ */ -- 2.43.0
Re: [PATCH v7 2/8] efi_loader: install device-tree on configuration table on every invocation
Hi Sughosh, [...] > { > - unsigned long fdt_pages; > efi_status_t ret = 0; > void *fdt, *new_fdt; > - u64 new_fdt_addr; > - uint fdt_size; > + static u64 new_fdt_addr; > + static ulong fdt_pages; efi_uintn_t fdt_pages > + ulong fdt_size; > + > + if ((new_fdt_addr && !fdt_pages) || (fdt_pages && !new_fdt_addr)) { Is there a case when this can happen? I think we can just get rid of it entirely > + log_err("%s: Fdt address/size not in the right state\n", > + __func__); > + return EFI_INVALID_PARAMETER; > + } > + > + if (new_fdt_addr) { > + log_debug("%s: Found allocated memory at %#llx, with %#lx > pages\n", > + __func__, new_fdt_addr, fdt_pages); > + ret = efi_free_pages(new_fdt_addr, fdt_pages); > + if (ret != EFI_SUCCESS) { > + log_err("Unable to free up existing FDT memory > region\n"); > + return ret; > + } > + } > > /* [...] Chers /Ilias
Re: [PATCH v7 1/8] efi_loader: remove unused code from copy_fdt()
On 11.03.25 14:21, Ilias Apalodimas wrote: Heinrich, do you remember why this was originally here? I looked at 6422820ac3e59 which moved that code around, but the same code was there as well On Mon, 10 Mar 2025 at 13:58, Sughosh Ganu wrote: There is logic in the copy_fdt() function which is iterating over the platform's DRAM banks and setting the fdt_ram_start variable. However, this variable is not used subsequently in the function. Remove this superfluous code. Signed-off-by: Sughosh Ganu --- Changes since V6: New patch lib/efi_loader/efi_helper.c | 14 +- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 04b2efc4a3b..15ad042bc61 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -454,23 +454,11 @@ efi_status_t efi_env_set_load_options(efi_handle_t handle, */ static efi_status_t copy_fdt(void **fdtp) { - unsigned long fdt_ram_start = -1L, fdt_pages; + unsigned long fdt_pages; efi_status_t ret = 0; void *fdt, *new_fdt; u64 new_fdt_addr; uint fdt_size; - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - u64 ram_start = gd->bd->bi_dram[i].start; - u64 ram_size = gd->bd->bi_dram[i].size; - - if (!ram_size) - continue; - - if (ram_start < fdt_ram_start) - fdt_ram_start = ram_start; - } The removed code was introduced by Alex in 2016 with patch ad0c1a3d2cea ("efi_loader: Put fdt into convenient location"). Writing the device-tree at the start of RAM may have worked for some boards at the time but on many others this would be inside reserved memory. Reviewed-by: Heinrich Schuchardt /* * Give us at least 12 KiB of breathing room in case the device tree -- 2.34.1 Reviewed-by: Ilias Apalodimas
Re: [PATCH v3 06/14] uthread: add cooperative multi-tasking interface
On Tue, 4 Mar 2025 at 17:31, Jerome Forissier wrote: > > Add a new internal API called uthread (Kconfig symbol: UTHREAD) which > provides cooperative multi-tasking. The goal is to be able to improve > the performance of some parts of U-Boot by overlapping lengthy > operations, and also implement background jobs in the U-Boot shell. > Each uthread has its own stack allocated on the heap. The default stack > size is defined by the UTHREAD_STACK_SIZE symbol and is used when > uthread_create() receives zero for the stack_sz argument. > > The implementation is based on context-switching via initjmp()/setjmp()/ > longjmp() and is inspired from barebox threads [1]. A notion of thread > group helps with dependencies, such as when a thread needs to block > until a number of other threads have returned. > > The name "uthread" comes from "user-space threads" because the > scheduling happens with no help from a higher privileged mode, contrary > to more complex models where kernel threads are defined. But the 'u' > may as well stand for 'U-Boot' since the bootloader may actually be > running at any privilege level and the notion of user vs. kernel may > not make much sense in this context. > > [1] https://github.com/barebox/barebox/blob/master/common/bthread.c > > Signed-off-by: Jerome Forissier > --- > doc/api/index.rst | 1 + > doc/api/uthread.rst | 7 +++ > include/uthread.h | 123 +++ > lib/Kconfig | 21 +++ > lib/Makefile| 2 + > lib/uthread.c | 139 > 6 files changed, 293 insertions(+) > create mode 100644 doc/api/uthread.rst > create mode 100644 include/uthread.h > create mode 100644 lib/uthread.c > > diff --git a/doc/api/index.rst b/doc/api/index.rst > index 0dc9ad45d41..506843ed74a 100644 > --- a/doc/api/index.rst > +++ b/doc/api/index.rst > @@ -29,3 +29,4 @@ U-Boot API documentation > sysreset > timer > unicode > + uthread > diff --git a/doc/api/uthread.rst b/doc/api/uthread.rst > new file mode 100644 > index 000..21233ff6b22 > --- /dev/null > +++ b/doc/api/uthread.rst > @@ -0,0 +1,7 @@ > +.. SPDX-License-Identifier: GPL-2.0-or-later > + > +Uthread API > +=== > + > +.. kernel-doc:: include/uthread.h > + :internal: > diff --git a/include/uthread.h b/include/uthread.h > new file mode 100644 > index 000..ec3034c097a > --- /dev/null > +++ b/include/uthread.h > @@ -0,0 +1,123 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > +/* > + * Copyright 2025 Linaro Limited > + */ > + > +#include > +#include > +#include > + > +#ifndef _UTHREAD_H_ > +#define _UTHREAD_H_ > + > +/** > + * DOC: Overview > + * > + * The uthread framework is a basic task scheduler that allows to run > functions > + * "in parallel" on a single CPU core. The scheduling is cooperative, not > + * preemptive -- meaning that context switches from one task to another task > is > + * voluntary, via a call to uthread_schedule(). This characteristic makes > thread > + * synchronization much easier, because a thread cannot be interrupted in the > + * middle of a critical section (reading from or writing to shared state, for > + * instance). > + * > + * CONFIG_UTHREAD in lib/Kconfig enables the uthread framework. When > disabled, > + * the uthread_create() and uthread_schedule() functions may still be used > so > + * that code differences between uthreads enabled and disabled can be > reduced to > + * a minimum. > + */ > + > +/** > + * struct uthread - a thread object > + * > + * @fn: thread entry point > + * @arg: argument passed to the entry point when the thread is started > + * @ctx: context to resume execution of this thread (via longjmp()) > + * @stack: initial stack pointer for the thread > + * @done: true once @fn has returned, false otherwise > + * @grp_id: user-supplied identifier for this thread and possibly others. A > + * thread can belong to zero or one group (not more), and a group may contain > + * any number of threads. > + * @list: link in the global scheduler list > + */ > +struct uthread { > + void (*fn)(void *); > + void *arg; > + jmp_buf ctx; > + void *stack; > + bool done; > + unsigned int grp_id; > + struct list_head list; > +}; > + > +#ifdef CONFIG_UTHREAD > + > +/** > + * uthread_create() - Create a uthread object and make it ready for execution > + * > + * Threads are automatically deleted when they return from their entry point. > + * > + * @uthr: a pointer to a user-allocated uthread structure to store > information > + * about the new thread, or NULL to let the framework allocate and manage its > + * own structure. > + * @fn: the thread's entry point > + * @arg: argument passed to the thread's entry point > + * @stack_sz: stack size for the new thread (in bytes). The stack is > allocated > + * on the heap. > + * @grp_id: an optional thread group ID that the new thread should belong to > + * (zero for no group) > + *
[PATCH v3] spl: return header size to spl_load in os boot
During linux build process the header size is computed including the BSS whereas it's removed when creating the uncompressed image. Therefore the size of the uncompressed image on filesystem will be smaller than the size specified in the header. This causes issues when loading the kernel image from the SPL (as in falcon boot) with spl_load since it compares the read file size from the FS to the header size form the image. Which leads to the following check in `include/spl_load.h` failing to -EIO when loading kernel image: return read < spl_image->size ? -EIO : 0; Therefore we should return the header size back to spl_load instead of the file size in falcon boot when not loading a FIT image. Bug report: https://lore.kernel.org/u-boot/20250214111656.2358748-1-ansh...@ti.com/ Fixes: 775074165d97 ("spl: Add generic spl_load function") Reported-by: Anshul Dalal Reviewed-by: Sean Anderson Signed-off-by: Anshul Dalal --- Changes in v3: * Added header check for FIT image instead of using CMD_BOOTI v2: https://lore.kernel.org/u-boot/20250225142522.9069-1-ansh...@ti.com/ Changes in v2: * Add R-by and fixes tags * Expanded commit description with more information v1: https://lore.kernel.org/u-boot/20250221151752.2618666-1-ansh...@ti.com/ --- common/spl/spl_ext.c | 8 common/spl/spl_fat.c | 7 +++ 2 files changed, 15 insertions(+) diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c index c5478820a9b..7e0274a3058 100644 --- a/common/spl/spl_ext.c +++ b/common/spl/spl_ext.c @@ -11,12 +11,20 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset, ulong size, void *buf) { + struct legacy_img_hdr *header; int ret; loff_t actlen; ret = ext4fs_read(buf, file_offset, size, &actlen); if (ret) return ret; + + if (CONFIG_IS_ENABLED(OS_BOOT)) { + header = (struct legacy_img_hdr *)buf; + if (image_get_magic(header) != FDT_MAGIC) + return size; + } + return actlen; } diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index fce451b7664..f426a068ff9 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -47,6 +47,7 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition) static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset, ulong size, void *buf) { + struct legacy_img_hdr *header; loff_t actread; int ret; char *filename = load->priv; @@ -55,6 +56,12 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset, if (ret) return ret; + if (CONFIG_IS_ENABLED(OS_BOOT)) { + header = (struct legacy_img_hdr *)buf; + if (image_get_magic(header) != FDT_MAGIC) + return size; + } + return actread; } -- 2.43.0
[PATCH v1] spl: remove usage of CMD_(BOOTI|BOOTZ) from image parsing
Using CMD_* configs from spl doesn't make logical sense. Therefore this patch removes the check for CONFIG_CMD_BOOT(I|Z) from the image parsing code during falcon boot and adds compilation targets for image.c and zimage.c on SPL_OS_BOOT. More info: https://lore.kernel.org/u-boot/20250310135544.GV2640854@bill-the-cat/ Signed-off-by: Anshul Dalal --- arch/arm/lib/Makefile | 3 +-- common/spl/spl.c | 6 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 1c95dd6fed2..0e36d493aee 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -36,8 +36,7 @@ obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o else obj-$(CONFIG_$(PHASE_)FRAMEWORK) += spl.o ifdef CONFIG_SPL_FRAMEWORK -obj-$(CONFIG_CMD_BOOTI) += image.o -obj-$(CONFIG_CMD_BOOTZ) += zimage.o +obj-$(CONFIG_SPL_OS_BOOT) += image.o zimage.o endif obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 76fd56dfe4b..79149ba07db 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -335,8 +335,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image, panic("** no mkimage signature but raw image not supported"); } - if (CONFIG_IS_ENABLED(OS_BOOT) && IS_ENABLED(CONFIG_CMD_BOOTI)) { - ulong start, size; + if (CONFIG_IS_ENABLED(OS_BOOT)) { + ulong start, size, end; if (!booti_setup((ulong)header, &start, &size, 0)) { spl_image->name = "Linux"; @@ -349,8 +349,6 @@ int spl_parse_image_header(struct spl_image_info *spl_image, spl_image->load_addr, spl_image->size); return 0; } - } else if (CONFIG_IS_ENABLED(OS_BOOT) && IS_ENABLED(CONFIG_CMD_BOOTZ)) { - ulong start, end; if (!bootz_setup((ulong)header, &start, &end)) { spl_image->name = "Linux"; -- 2.43.0
Reading QSPI on zynq7 broken since commit 9bb02f7f4533
After a bisect session, turned out this causes my topic-miami board to fail to boot from QSPI: Commit 9bb02f7f4533: "mtd: spi-nor: Fix the spi_nor_read() when config SPI_STACKED_PARALLEL is enabled" I haven't determined yet what the bug is exactly. The board has a single QSPI chip attached to a 7-series Zynq. SPL fails to read from it since this commit. -- Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: mike.looijm...@topic.nl W: www.topic.nl
Re: [PATCH 07/10] test/py: Rework test_efi_capsule to not use virt-make-fs
On Fri, 7 Mar 2025 at 01:23, Tom Rini wrote: > > The problem with using "virt-make-fs" to make a filesystem image is that > it is extremely slow. Switch to using the fs_helper functions we have > instead from the filesystem tests as these can add files to images and > are significantly faster and still do not require root access. > > The main change here is that our mount point directory has changed from > "test_efi_capsule" to "scratch" and so we need to update other functions > too. As the disk image that we get created doesn't have a GPT, invoke > sgdisk to do a conversion first. > > Signed-off-by: Tom Rini > --- > I tested this as much as I could with an empty > board/sandbox/capsule_pub_esl_good.esl which did show me a few issues > along the way so I am reasonably confident, but this really does need to > be tested on a platform where all tests are run for real. > > Cc: Ilias Apalodimas > Cc: Heinrich Schuchardt > --- > .../tests/test_efi_capsule/capsule_common.py | 2 +- > test/py/tests/test_efi_capsule/conftest.py| 21 --- > 2 files changed, 14 insertions(+), 9 deletions(-) > > diff --git a/test/py/tests/test_efi_capsule/capsule_common.py > b/test/py/tests/test_efi_capsule/capsule_common.py > index fc0d851c619a..68b2e48bf5a5 100644 > --- a/test/py/tests/test_efi_capsule/capsule_common.py > +++ b/test/py/tests/test_efi_capsule/capsule_common.py > @@ -136,7 +136,7 @@ def do_reboot_dtb_specified(u_boot_config, > u_boot_console, dtb_filename): > u_boot_console -- A console connection to U-Boot. > dtb_filename -- DTB file name. > """ > -mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' > +mnt_point = u_boot_config.persistent_data_dir + '/scratch' > u_boot_console.config.dtb = mnt_point + CAPSULE_DATA_DIR \ > + f'/{dtb_filename}' > u_boot_console.restart_uboot() > diff --git a/test/py/tests/test_efi_capsule/conftest.py > b/test/py/tests/test_efi_capsule/conftest.py > index 61eab5112a17..7f8a3de46171 100644 > --- a/test/py/tests/test_efi_capsule/conftest.py > +++ b/test/py/tests/test_efi_capsule/conftest.py > @@ -7,6 +7,7 @@ > import os > > from subprocess import call, check_call, CalledProcessError > +from tests import fs_helper > import pytest > from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH > > @@ -21,12 +22,12 @@ def efi_capsule_data(request, u_boot_config): > request -- Pytest request object. > u_boot_config -- U-Boot configuration. > """ > -mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' > -data_dir = mnt_point + CAPSULE_DATA_DIR > -install_dir = mnt_point + CAPSULE_INSTALL_DIR > -image_path = u_boot_config.persistent_data_dir + '/test_efi_capsule.img' > - > try: > +image_path, mnt_point = fs_helper.setup_image(u_boot_config, 0, 0xc, > + > basename='test_efi_capsule') > +data_dir = mnt_point + CAPSULE_DATA_DIR > +install_dir = mnt_point + CAPSULE_INSTALL_DIR > + > # Create a target device > check_call('dd if=/dev/zero of=./spi.bin bs=1MiB count=16', > shell=True) > > @@ -88,11 +89,15 @@ def efi_capsule_data(request, u_boot_config): > check_call('cp %s/Test* %s' % (u_boot_config.build_dir, data_dir), > shell=True) > os.environ['PYTHONPATH'] = pythonpath > > -# Create a disk image with EFI system partition > -check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s > %s' % > - (mnt_point, image_path), shell=True) > +# Create a 16MiB partition as the EFI system partition in the disk > +# image > +fsfile = fs_helper.mk_fs(u_boot_config, 'vfat', 0x100, > + 'test_efi_capsule', mnt_point) > +check_call(f'dd if={fsfile} of={image_path} bs=1M seek=1', > shell=True) > +check_call('sgdisk --mbrtogpt %s' % image_path, shell=True) > check_call('sgdisk %s -A 1:set:0 -t > 1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B' % > image_path, shell=True) > +call('rm -f %s' % fsfile, shell=True) > > except CalledProcessError as exception: > pytest.skip('Setup failed: %s' % exception.cmd) > -- > 2.43.0 > Acked-by: Ilias Apalodimas
[PATCH 12/19] arm64: dts: ti: k3-am62a-main: Add C7xv device node
From: Jai Luthra AM62A SoCs have a C7xv DSP subsystem with Analytics engine capability. This subsystem is intended for deep learning purposes. Define the device node for C7xv DSP. Signed-off-by: Jai Luthra Signed-off-by: Hari Nagalla Signed-off-by: Judith Mendez Acked-by: Andrew Davis Link: https://lore.kernel.org/r/20250210221530.1234009-5...@ti.com Signed-off-by: Markus Schneider-Pargmann --- dts/upstream/src/arm64/ti/k3-am62a-main.dtsi | 12 1 file changed, 12 insertions(+) diff --git a/dts/upstream/src/arm64/ti/k3-am62a-main.dtsi b/dts/upstream/src/arm64/ti/k3-am62a-main.dtsi index a93e2cd7b8c74ab942612d1090939614066e9d2b..805cde942b97f0b6069d505ec90b8201255e5eec 100644 --- a/dts/upstream/src/arm64/ti/k3-am62a-main.dtsi +++ b/dts/upstream/src/arm64/ti/k3-am62a-main.dtsi @@ -1124,6 +1124,18 @@ power-domains = <&k3_pds 204 TI_SCI_PD_EXCLUSIVE>; }; + c7x_0: dsp@7e00 { + compatible = "ti,am62a-c7xv-dsp"; + reg = <0x00 0x7e00 0x00 0x0010>; + reg-names = "l2sram"; + ti,sci = <&dmsc>; + ti,sci-dev-id = <208>; + ti,sci-proc-ids = <0x04 0xff>; + resets = <&k3_reset 208 1>; + firmware-name = "am62a-c71_0-fw"; + status = "disabled"; + }; + e5010: jpeg-encoder@fd2 { compatible = "ti,am62a-jpeg-enc", "img,e5010-jpeg-enc"; reg = <0x00 0xfd2 0x00 0x100>, -- 2.47.2
Re: [PATCH v2 1/1] cmd: simplify eficonfig_init()
On Mon, 10 Mar 2025 at 08:13, Heinrich Schuchardt wrote: > > As the system table already has pointers to the Simple Text Input and > Output Protocols we can directly use these instead of calling > OpenProtocol. > > Signed-off-by: Heinrich Schuchardt > --- > v2: > remove unused variable handler > --- > cmd/eficonfig.c | 19 ++- > 1 file changed, 2 insertions(+), 17 deletions(-) > > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c > index e08b6ba4a5d..629bf1b82c7 100644 > --- a/cmd/eficonfig.c > +++ b/cmd/eficonfig.c > @@ -2283,26 +2283,11 @@ static efi_status_t eficonfig_init(void) > { > efi_status_t ret = EFI_SUCCESS; > static bool init; > - struct efi_handler *handler; > unsigned long columns, rows; > > if (!init) { > - ret = efi_search_protocol(efi_root, > &efi_guid_text_input_protocol, &handler); > - if (ret != EFI_SUCCESS) > - return ret; > - > - ret = efi_protocol_open(handler, (void **)&cin, efi_root, > NULL, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL); > - if (ret != EFI_SUCCESS) > - return ret; > - ret = efi_search_protocol(efi_root, > &efi_guid_text_output_protocol, &handler); > - if (ret != EFI_SUCCESS) > - return ret; > - > - ret = efi_protocol_open(handler, (void **)&cout, efi_root, > NULL, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL); > - if (ret != EFI_SUCCESS) > - return ret; > + cout = systab.con_out; > + cin = systab.con_in; > > cout->query_mode(cout, cout->mode->mode, &columns, &rows); > avail_row = rows - (EFICONFIG_MENU_HEADER_ROW_NUM + > -- > 2.48.1 > Reviewed-by: Ilias Apalodimas
[PATCH v1 3/3] booti/bootm: riscv: Verify image arch type
Unlike ARM and X86, booting 32-bit images on 64-bit CPUs is currently not supported for Risc-V. Hence, for bootm, disallow booting a FIT or a legacy image that was built for an arch type which is different than the current arch and for booti, set the arch type to be the same as the current arch. Signed-off-by: Mayuresh Chitale --- arch/riscv/lib/bootm.c | 4 cmd/booti.c| 5 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index 76c610bcee0..90f71bee6a5 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -94,6 +94,10 @@ static void boot_jump_linux(struct bootm_headers *images, int flag) announce_and_cleanup(fake); if (!fake) { + if (images->os.arch != IH_ARCH_DEFAULT) { + printf("Image arch not compatible with host arch.\n"); + hang(); + } if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) { #ifdef CONFIG_SMP ret = smp_call_function(images->ep, diff --git a/cmd/booti.c b/cmd/booti.c index 1a57fe91397..00921ec4a9d 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -131,7 +131,10 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) images.os.os = IH_OS_LINUX; if (IS_ENABLED(CONFIG_RISCV_SMODE)) - images.os.arch = IH_ARCH_RISCV; + if (IS_ENABLED(CONFIG_64BIT)) + images.os.arch = IH_ARCH_RISCV64; + else + images.os.arch = IH_ARCH_RISCV; else if (IS_ENABLED(CONFIG_ARM64)) images.os.arch = IH_ARCH_ARM64; -- 2.43.0
[PATCH v1 0/3] Risc-V 32 bit/64 bit images
This series adds support for building different images for 32-bit vs 64-bit Risc-V CPUs and also for verifying the target arch of an image before booting it. Changes from RFC: - Rebase on latest master branch - Improve commit message for patch 3 Mayuresh Chitale (3): riscv: image: Add new image type for RV64 riscv: Select appropriate image type booti/bootm: riscv: Verify image arch type arch/riscv/dts/binman.dtsi | 14 ++ arch/riscv/include/asm/u-boot.h | 4 arch/riscv/lib/bootm.c | 4 boot/image.c| 3 ++- cmd/booti.c | 5 - include/image.h | 1 + 6 files changed, 25 insertions(+), 6 deletions(-) -- 2.43.0
[PATCH 03/16] efi_loader: efi_net: Reuse efi_net_obj's
Signed-off-by: Adriano Cordova --- lib/efi_loader/efi_net.c | 81 +--- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 8c0a3f5243c..d84fa6c2bc6 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -1162,29 +1162,35 @@ static int efi_netobj_init(struct efi_net_obj *netobj) } /* Allocate an aligned transmit buffer */ - transmit_buffer = calloc(1, PKTSIZE_ALIGN + PKTALIGN); - if (!transmit_buffer) - goto out_of_resources; - transmit_buffer = (void *)ALIGN((uintptr_t)transmit_buffer, PKTALIGN); - netobj->transmit_buffer = transmit_buffer; + if (!netobj->transmit_buffer) { + transmit_buffer = calloc(1, PKTSIZE_ALIGN + PKTALIGN); + if (!transmit_buffer) + goto out_of_resources; + transmit_buffer = (void *)ALIGN((uintptr_t)transmit_buffer, PKTALIGN); + netobj->transmit_buffer = transmit_buffer; + } /* Allocate a number of receive buffers */ - receive_buffer = calloc(ETH_PACKETS_BATCH_RECV, - sizeof(*receive_buffer)); - if (!receive_buffer) - goto out_of_resources; - for (i = 0; i < ETH_PACKETS_BATCH_RECV; i++) { - receive_buffer[i] = malloc(PKTSIZE_ALIGN); - if (!receive_buffer[i]) + if (!netobj->receive_buffer) { + receive_buffer = calloc(ETH_PACKETS_BATCH_RECV, + sizeof(*receive_buffer)); + if (!receive_buffer) goto out_of_resources; + for (i = 0; i < ETH_PACKETS_BATCH_RECV; i++) { + receive_buffer[i] = malloc(PKTSIZE_ALIGN); + if (!receive_buffer[i]) + goto out_of_resources; + } + netobj->receive_buffer = receive_buffer; } - netobj->receive_buffer = receive_buffer; - receive_lengths = calloc(ETH_PACKETS_BATCH_RECV, -sizeof(*receive_lengths)); - if (!receive_lengths) - goto out_of_resources; - netobj->receive_lengths = receive_lengths; + if (!netobj->receive_lengths) { + receive_lengths = calloc(ETH_PACKETS_BATCH_RECV, +sizeof(*receive_lengths)); + if (!receive_lengths) + goto out_of_resources; + netobj->receive_lengths = receive_lengths; + } /* Hook net up to the device list */ efi_add_handle(&netobj->header); @@ -1301,12 +1307,6 @@ failure_to_add_protocol: printf("ERROR: Failure to add protocol\n"); return -1; out_of_resources: - free(transmit_buffer); - if (receive_buffer) - for (i = 0; i < ETH_PACKETS_BATCH_RECV; i++) - free(receive_buffer[i]); - free(receive_buffer); - free(receive_lengths); printf("ERROR: Out of memory\n"); return -1; } @@ -1367,22 +1367,35 @@ int efi_net_register(void *ctx, struct event *event) // Find a slot for this efi_net_obj seq_num = -1; + // Try to recycle for (i = 0; i < MAX_EFI_NET_OBJS; i++) { - if (!net_objs[i]) { + if (net_objs[i] && !net_objs[i]->dev) { seq_num = i; break; } } + if (seq_num < 0) { + for (i = 0; i < MAX_EFI_NET_OBJS; i++) { + if (!net_objs[i]) { + seq_num = i; + break; + } + } + } if (seq_num < 0) return -1; - netobj = calloc(1, sizeof(*netobj)); + if (!net_objs[seq_num]) { + netobj = calloc(1, sizeof(*netobj)); + net_objs[seq_num] = netobj; + } else { + netobj = net_objs[seq_num]; + } if (!netobj) goto out_of_resources; netobj->dev = dev; netobj->efi_seq_num = seq_num; - net_objs[seq_num] = netobj; printf("efi_net registered device number %d\n", netobj->efi_seq_num); return 0; out_of_resources: @@ -1429,17 +1442,10 @@ int efi_net_unregister(void *ctx, struct event *event) if (!netobj) return 0; - // Remove from the list - net_objs[i] = NULL; + // Mark as free in the list + netobj->dev = NULL; if (efi_netobj_is_active(netobj)) { - free(netobj->transmit_buffer); - if (netobj->receive_buffer) - for (i = 0; i < ETH_PACKETS_BATCH_RECV; i++) - free(netobj->receive_buffer[i]); - free(netobj->receive_buffer);
[PATCH 01/16] efi_driver: efi_net: Add EFI network device driver
Register the U-boot ethernet udevices in the EFI network stack as efi_net_obj when they get probed, and unregister them when the udevice gets removed Signed-off-by: Adriano Cordova --- include/efi_loader.h| 10 +- lib/efi_driver/Makefile | 1 + lib/efi_driver/efi_net_device.c | 89 +++ lib/efi_driver/efi_uclass.c | 2 +- lib/efi_loader/efi_net.c| 263 +--- lib/efi_loader/efi_setup.c | 4 +- 6 files changed, 305 insertions(+), 64 deletions(-) create mode 100644 lib/efi_driver/efi_net_device.c diff --git a/include/efi_loader.h b/include/efi_loader.h index e9c10819ba2..9c5ddc12cea 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -656,9 +656,13 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, const char *pdevname); /* Called by bootefi to make GOP (graphical) interface available */ efi_status_t efi_gop_register(void); -/* Called by bootefi to make the network interface available */ -efi_status_t efi_net_register(struct udevice *dev); -efi_status_t efi_net_do_start(struct udevice *dev); +/* Called to register an EFI network device */ +int efi_net_register(void *ctx, struct event *event); +/* Called to unregister an EFI network device */ +int efi_net_unregister(void *ctx, struct event *event); +/* Called to initialized registered network devices */ +efi_status_t efi_net_init(void); +efi_status_t efi_net_do_start(void); /* Called by efi_net_register to make the ip4 config2 protocol available */ efi_status_t efi_ipconfig_register(const efi_handle_t handle, struct efi_ip4_config2_protocol *ip4config); diff --git a/lib/efi_driver/Makefile b/lib/efi_driver/Makefile index 0da20fe91d3..08489064c7a 100644 --- a/lib/efi_driver/Makefile +++ b/lib/efi_driver/Makefile @@ -9,4 +9,5 @@ obj-y += efi_uclass.o ifeq ($(CONFIG_PARTITIONS),y) obj-y += efi_block_device.o endif +obj-$(CONFIG_NETDEVICES) += efi_net_device.o obj-$(CONFIG_SYSRESET_SBI) += efi_reset_riscv.o diff --git a/lib/efi_driver/efi_net_device.c b/lib/efi_driver/efi_net_device.c new file mode 100644 index 000..f2167485ab9 --- /dev/null +++ b/lib/efi_driver/efi_net_device.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * EFI network driver + * + */ + +#include +#include +#include +#include +#include +#include +#include + +/** + * efi_net_bind_drv() - TODO + * + * @this: driver binding protocol + * @handle:handle + * @interface: block io protocol + * Return: status code + */ +static efi_status_t efi_net_bind_drv( + struct efi_driver_binding_extended_protocol *this, + efi_handle_t handle, void *interface) +{ + + EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, interface); + + + return EFI_UNSUPPORTED; +} + +/** + * efi_net_init_drv() - initialize network device driver + * + * @this: extended driver binding protocol + * Return: status code + */ +static efi_status_t +efi_net_init_drv(struct efi_driver_binding_extended_protocol *this) +{ + int ret; + struct udevice *dev; + struct event event; + + for (uclass_find_first_device(UCLASS_ETH, &dev); dev; +uclass_find_next_device(&dev)) { + if (dev_get_flags(dev) & DM_FLAG_ACTIVATED) { + memcpy(&event.data, &dev, sizeof(dev)); + ret = efi_net_register(NULL, &event); + if (ret) { + log_err("Failed registering %s in EFI net\n", dev->name); + return EFI_OUT_OF_RESOURCES; + } + } + + } + + ret = event_register("efi_net register", EVT_DM_POST_PROBE, +efi_net_register, this); + if (ret) { + log_err("Event registration for efi_net register failed\n"); + return EFI_OUT_OF_RESOURCES; + } + + ret = event_register("efi_net unregister", EVT_DM_PRE_REMOVE, +efi_net_unregister, this); + if (ret) { + log_err("Event registration for efi_net unregister failed\n"); + return EFI_OUT_OF_RESOURCES; + } + + return EFI_SUCCESS; +} + +/* EFI driver operators */ +static const struct efi_driver_ops driver_ops = { + .protocol = &efi_net_guid, + .init = efi_net_init_drv, + .bind = efi_net_bind_drv, +}; + +/* Identify as EFI driver */ +U_BOOT_DRIVER(efi_net) = { + .name = "efi_net", + .id = UCLASS_EFI_LOADER, + .ops= &driver_ops, +}; diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 495be53cb77..fc8808374a1 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -76,7 +76,7 @@ static efi_status_t EFIAPI efi_uc_supported
[PATCH 04/16] efi_loader: efi_net: Let efi_net_obj store pointers to efi_simple_network, efi_simple_network_mode, and the efi handle
This way the protocol and the handle can be externally provided. This comes in preparation to support ConnectController. Signed-off-by: Adriano Cordova --- lib/efi_loader/efi_net.c | 119 --- 1 file changed, 75 insertions(+), 44 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index d84fa6c2bc6..a40d319a27f 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -67,7 +67,7 @@ static int next_dhcp_entry; /** * struct efi_net_obj - EFI object representing a network interface * - * @header:EFI object header + * @handle:EFI object handle * @dev: net udevice * @net: simple network protocol interface * @net_mode: status of the network interface @@ -86,10 +86,10 @@ static int next_dhcp_entry; * @efi_seq_num: sequence number of the EFI net object. */ struct efi_net_obj { - struct efi_object header; + efi_handle_t handle; struct udevice *dev; - struct efi_simple_network net; - struct efi_simple_network_mode net_mode; + struct efi_simple_network *net; + struct efi_simple_network_mode *net_mode; struct efi_pxe_base_code_protocol pxe; struct efi_pxe_mode pxe_mode; #if IS_ENABLED(CONFIG_EFI_IP4_CONFIG2_PROTOCOL) @@ -120,7 +120,7 @@ static struct efi_net_obj *net_objs[MAX_EFI_NET_OBJS]; */ static bool efi_netobj_is_active(struct efi_net_obj *netobj) { - if (!netobj || !efi_search_obj(&netobj->header)) + if (!netobj || !efi_search_obj(netobj->handle)) return false; return true; @@ -138,7 +138,7 @@ static struct efi_net_obj *efi_netobj_from_snp(struct efi_simple_network *snp) int i; for (i = 0; i < MAX_EFI_NET_OBJS; i++) { - if (net_objs[i] && &net_objs[i]->net == snp) { + if (net_objs[i] && net_objs[i]->net == snp) { // Do not register duplicate devices return net_objs[i]; } @@ -1020,7 +1020,7 @@ efi_status_t efi_netobj_set_dp(struct efi_net_obj *netobj, struct efi_device_pat return EFI_OUT_OF_RESOURCES; phandler = NULL; - ret = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + ret = efi_search_protocol(netobj->handle, &efi_guid_device_path, &phandler); if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) return ret; @@ -1029,14 +1029,14 @@ efi_status_t efi_netobj_set_dp(struct efi_net_obj *netobj, struct efi_device_pat goto add; // If it is already installed, try to update it - ret = efi_reinstall_protocol_interface(&netobj->header, &efi_guid_device_path, + ret = efi_reinstall_protocol_interface(netobj->handle, &efi_guid_device_path, phandler->protocol_interface, new_net_dp); if (ret != EFI_SUCCESS) return ret; return EFI_SUCCESS; add: - ret = efi_add_protocol(&netobj->header, &efi_guid_device_path, + ret = efi_add_protocol(netobj->handle, &efi_guid_device_path, new_net_dp); if (ret != EFI_SUCCESS) return ret; @@ -1059,7 +1059,7 @@ static struct efi_device_path *efi_netobj_get_dp(struct efi_net_obj *netobj) return NULL; phandler = NULL; - r = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + r = efi_search_protocol(netobj->handle, &efi_guid_device_path, &phandler); if (r != EFI_SUCCESS && r != EFI_NOT_FOUND) return NULL; @@ -1161,6 +1161,16 @@ static int efi_netobj_init(struct efi_net_obj *netobj) return 0; } + if (!netobj->net) + netobj->net = calloc(1, sizeof(*netobj->net)); + if (!netobj->net) + goto out_of_resources; + + if (!netobj->net_mode) + netobj->net_mode = calloc(1, sizeof(*netobj->net_mode)); + if (!netobj->net_mode) + goto out_of_resources; + /* Allocate an aligned transmit buffer */ if (!netobj->transmit_buffer) { transmit_buffer = calloc(1, PKTSIZE_ALIGN + PKTALIGN); @@ -1193,41 +1203,44 @@ static int efi_netobj_init(struct efi_net_obj *netobj) } /* Hook net up to the device list */ - efi_add_handle(&netobj->header); + efi_add_handle(netobj->handle); + if (efi_link_dev(netobj->handle, dev)) + goto out_of_resources; /* Fill in object data */ - r = efi_add_protocol(&netobj->header, &efi_net_guid, -&netobj->net); + r = efi_add_protocol(netobj->handle, &efi_net_guid, +netobj->net); if (r != EFI_SUCCESS) goto failure_to_add_protocol; -
[PATCH 02/16] efi_loader: efi_net: check efi_search_protocol return value
Signed-off-by: Adriano Cordova --- lib/efi_loader/efi_net.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 0334eedaf5c..8c0a3f5243c 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -1020,7 +1020,9 @@ efi_status_t efi_netobj_set_dp(struct efi_net_obj *netobj, struct efi_device_pat return EFI_OUT_OF_RESOURCES; phandler = NULL; - efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + ret = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) + return ret; // If the device path protocol is not yet installed, install it if (!phandler) @@ -1051,12 +1053,15 @@ add: static struct efi_device_path *efi_netobj_get_dp(struct efi_net_obj *netobj) { struct efi_handler *phandler; + efi_status_t r; if (!efi_netobj_is_active(netobj)) return NULL; phandler = NULL; - efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + r = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + if (r != EFI_SUCCESS && r != EFI_NOT_FOUND) + return NULL; if (phandler && phandler->protocol_interface) return efi_dp_dup(phandler->protocol_interface); @@ -1444,7 +1449,9 @@ int efi_net_unregister(void *ctx, struct event *event) return -1; phandler = NULL; - efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + ret = efi_search_protocol(&netobj->header, &efi_guid_device_path, &phandler); + if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND) + return -1; if (phandler && phandler->protocol_interface) interface = phandler->protocol_interface; -- 2.48.1
[PATCH 00/16] EFI net driver - series 2/2: Support multiple EFI net objects
This series finishes adding support for multiple network interfaces in the EFI network stack. This series relies on "EFI net driver - series 1/2: Support multiple EFI net objects". In this series two drivers are introduced: first, an EFI driver that manages handles that have the efi simple network protocol installed, second, and an ethernet driver that implements ethernet operations using a working efi simple network protocol as a backend. The U-Boot code will call connect_controller for each U-Boot net udevice after creating an efi_net_obj for it, and the first driver will pick it up. If connect_controller gets called for a handle with an already existing efi simple network protocol on it, the first driver will create a U-Boot net udevice managed by the second driver, and an efi_net_obj will be created too. Adriano Cordova (16): efi_driver: efi_net: Add EFI network device driver efi_loader: efi_net: check efi_search_protocol return value efi_loader: efi_net: Reuse efi_net_obj's efi_loader: efi_net: Let efi_net_obj store pointers to efi_simple_network, efi_simple_network_mode, and the efi handle efi_net: efi_loader: Add efi_netobj_alloc to allocate an efi_net_obj efi_loader: efi_net: Manage EFI net objects with efi_[dis]connect_controller eth_uclass: Add eth_create_device to create a net udevice efi_driver: efi_net: UCLASS_ETH driver for EFI net devices efi_driver: efi_uclass: Add unbind method to efi_driver_ops efi_driver: efi_net: Add efi_net_unbind_drv method to efi_net driver efi_loader: efi_net: Add http, ip4_config2, and pxe on demand efi_loader: efi_net: add snp_owner field to efi_net_obj struct efi_selftest: Add selftest for counting EFI netdevices py/tests: test_efi_selftest: Add test for counting EFI netdevices py/tests: test_efi_selftest: Add test for removing EFI netdevices efi_selftest: Add test for efi_netdev driver include/efi_driver.h | 4 + include/efi_loader.h | 30 +- include/net-common.h | 2 + lib/efi_driver/Makefile| 1 + lib/efi_driver/efi_net_device.c| 290 + lib/efi_driver/efi_uclass.c| 6 +- lib/efi_loader/efi_http.c | 30 +- lib/efi_loader/efi_ipconfig.c | 36 +- lib/efi_loader/efi_net.c | 665 +++-- lib/efi_loader/efi_setup.c | 4 +- lib/efi_selftest/Makefile | 2 +- lib/efi_selftest/efi_selftest_net_device.c | 65 ++ lib/efi_selftest/efi_selftest_net_driver.c | 310 ++ net/eth-uclass.c | 32 + test/py/tests/test_efi_selftest.py | 45 ++ 15 files changed, 1330 insertions(+), 192 deletions(-) create mode 100644 lib/efi_driver/efi_net_device.c create mode 100644 lib/efi_selftest/efi_selftest_net_device.c create mode 100644 lib/efi_selftest/efi_selftest_net_driver.c -- 2.48.1
[PATCH 08/16] efi_driver: efi_net: UCLASS_ETH driver for EFI net devices
Ethernet driver that uses an underlying efi_simple_network_protocol to send packages. Signed-off-by: Adriano Cordova --- include/efi_loader.h| 12 +++ lib/efi_driver/efi_net_device.c | 159 2 files changed, 171 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index 38ea0c5c672..35f500fd97d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -656,6 +656,18 @@ int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, const char *pdevname); /* Called by bootefi to make GOP (graphical) interface available */ efi_status_t efi_gop_register(void); + +/** + * struct efi_netdev_plat - attributes of a network device + * + * @handle:handle of the controller on which this driver is installed + * @snp: simple network protocol proxied by this driver + */ +struct efi_netdev_plat { + efi_handle_t handle; + struct efi_simple_network *snp; + void *buffer; +}; /* Called to register an EFI network device */ int efi_net_register(void *ctx, struct event *event); /* Called to unregister an EFI network device */ diff --git a/lib/efi_driver/efi_net_device.c b/lib/efi_driver/efi_net_device.c index 90d695da2b1..3838cc47158 100644 --- a/lib/efi_driver/efi_net_device.c +++ b/lib/efi_driver/efi_net_device.c @@ -7,11 +7,146 @@ #include #include #include +#include #include #include #include #include +#define DEFAULT_EFI_NET_BUFFER_SIZE 1024 + +int efi_net_start(struct udevice *dev) +{ + struct efi_netdev_plat *plat; + efi_status_t ret; + + plat = dev_get_plat(dev); + if (!plat || !plat->snp) + return -1; + + ret = plat->snp->start(plat->snp); + if (ret != EFI_SUCCESS) + return -1; + ret = plat->snp->initialize(plat->snp, 0, 0); + if (ret != EFI_SUCCESS) + return -1; + + return 0; +} + +int efi_net_send(struct udevice *dev, void *packet, int length) +{ + struct efi_netdev_plat *plat; + efi_status_t ret; + + plat = dev_get_plat(dev); + if (!plat || !plat->snp) + return -1; + + ret = plat->snp->transmit(plat->snp, 0, length, packet, NULL, NULL, NULL); + if (ret != EFI_SUCCESS) + return -1; + + return 0; +} + +int efi_net_recv(struct udevice *dev, int flags, uchar **packetp) +{ + struct efi_netdev_plat *plat; + efi_status_t ret; + size_t buffer_size; + + plat = dev_get_plat(dev); + if (!plat || !plat->snp) + return -1; + + if (plat->buffer) + free(plat->buffer); + + buffer_size = DEFAULT_EFI_NET_BUFFER_SIZE; + plat->buffer = calloc(1, buffer_size); + ret = plat->snp->receive(plat->snp, NULL, &buffer_size, plat->buffer, +NULL, NULL, NULL); + + if (ret == EFI_BUFFER_TOO_SMALL) { + free(plat->buffer); + plat->buffer = calloc(1, buffer_size); + ret = plat->snp->receive(plat->snp, NULL, &buffer_size, plat->buffer, +NULL, NULL, NULL); + } + + if (ret != EFI_SUCCESS || ret != EFI_NOT_READY) + return -1; + + *packetp = plat->buffer; + return buffer_size; +} + +void efi_net_stop(struct udevice *dev) +{ + struct efi_netdev_plat *plat; + + plat = dev_get_plat(dev); + if (!plat || !plat->snp) + return; + + plat->snp->stop(plat->snp); +} + +/** + * efi_netdev_create() - create a net udevice for a handle + * + * @handle:handle + * @interface: simple network protocol + * Return: status code + */ +static efi_status_t +efi_netdev_create(efi_handle_t handle, void *interface) +{ + struct udevice *dev = NULL, *parent = dm_root(); + efi_status_t ret; + char *name; + struct efi_netdev_plat *plat; + static int devnum; + + name = calloc(1, 18); /* strlen("efinet#2147483648") + 1 */ + if (!name) + return EFI_OUT_OF_RESOURCES; + sprintf(name, "efinet#%d", devnum); + devnum++; + + /* Create driver model udevice for the EFI block io device */ + if (eth_create_device(parent, "efi_netdev", name, &dev)) { + ret = EFI_OUT_OF_RESOURCES; + free(name); + goto err; + } + + plat = dev_get_plat(dev); + plat->handle = handle; + plat->snp = interface; + + if (efi_link_dev(handle, dev)) { + ret = EFI_OUT_OF_RESOURCES; + goto err; + } + + if (device_probe(dev)) { + ret = EFI_DEVICE_ERROR; + goto err; + } + EFI_PRINT("%s: net udevice '%s' created\n", __func__, dev->name); + + return EFI_SUCCESS; + +err: + efi_unlink_dev(handle); + if (dev) + device_unbind(dev); + + return ret; +} + /**
[PATCH 06/16] efi_loader: efi_net: Manage EFI net objects with efi_[dis]connect_controller
For U-Boot devices connect_controller gets called in efi_netobj_init Signed-off-by: Adriano Cordova --- include/efi_loader.h| 2 +- lib/efi_driver/efi_net_device.c | 4 +--- lib/efi_loader/efi_net.c| 30 -- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 9c5ddc12cea..38ea0c5c672 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -660,7 +660,7 @@ efi_status_t efi_gop_register(void); int efi_net_register(void *ctx, struct event *event); /* Called to unregister an EFI network device */ int efi_net_unregister(void *ctx, struct event *event); -/* Called to initialized registered network devices */ +/* Called to initialized registered EFI network devices */ efi_status_t efi_net_init(void); efi_status_t efi_net_do_start(void); /* Called by efi_net_register to make the ip4 config2 protocol available */ diff --git a/lib/efi_driver/efi_net_device.c b/lib/efi_driver/efi_net_device.c index f2167485ab9..90d695da2b1 100644 --- a/lib/efi_driver/efi_net_device.c +++ b/lib/efi_driver/efi_net_device.c @@ -24,11 +24,9 @@ static efi_status_t efi_net_bind_drv( struct efi_driver_binding_extended_protocol *this, efi_handle_t handle, void *interface) { - EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, interface); - - return EFI_UNSUPPORTED; + return EFI_SUCCESS; } /** diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index a14ecf3d182..fd43eec4c03 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -1127,7 +1127,7 @@ efi_status_t efi_net_do_start(void) int i, r; for (i = 0; i < MAX_EFI_NET_OBJS; i++) { - if (net_objs[i]) { + if (net_objs[i] && net_objs[i]->dev) { r = efi_netobj_start(net_objs[i]); if (r) return EFI_DEVICE_ERROR; @@ -1200,7 +1200,7 @@ static int efi_netobj_init(struct efi_net_obj *netobj) /* Fill in object data */ r = efi_add_protocol(netobj->handle, &efi_net_guid, -netobj->net); + netobj->net); if (r != EFI_SUCCESS) goto failure_to_add_protocol; @@ -1248,12 +1248,16 @@ static int efi_netobj_init(struct efi_net_obj *netobj) netobj->pxe.set_packets = efi_pxe_base_code_set_packets; netobj->pxe.mode = &netobj->pxe_mode; + r = EFI_CALL(efi_connect_controller(netobj->handle, NULL, NULL, 0)); + if (r != EFI_SUCCESS) + return -1; + /* * Scan dhcp entries for one corresponding * to this udevice, from newest to oldest */ i = (next_dhcp_entry + MAX_NUM_DHCP_ENTRIES - 1) % MAX_NUM_DHCP_ENTRIES; - for (j = 0; dhcp_cache[i].is_valid && j < MAX_NUM_DHCP_ENTRIES; + for (j = 0; dev && dhcp_cache[i].is_valid && j < MAX_NUM_DHCP_ENTRIES; i = (i + MAX_NUM_DHCP_ENTRIES - 1) % MAX_NUM_DHCP_ENTRIES, j++) { if (dev == dhcp_cache[i].dev) { netobj->pxe_mode.dhcp_ack = *dhcp_cache[i].dhcp_ack; @@ -1305,7 +1309,6 @@ static int efi_netobj_init(struct efi_net_obj *netobj) if (r != EFI_SUCCESS) goto failure_to_add_protocol; #endif - printf("efi_net init device number %d\n", netobj->efi_seq_num); return 0; failure_to_add_protocol: printf("ERROR: Failure to add protocol\n"); @@ -1426,7 +1429,8 @@ int efi_net_register(void *ctx, struct event *event) { struct udevice *dev; enum uclass_id id; - int i; + struct efi_net_obj *netobj; + int i, r; dev = event->data.dm.dev; if (!dev) { @@ -1445,9 +1449,19 @@ int efi_net_register(void *ctx, struct event *event) } } - if (!efi_netobj_alloc(NULL, NULL, dev)) + netobj = efi_netobj_alloc(NULL, NULL, dev); + + if (!netobj) return -1; + if (efi_obj_list_initialized == EFI_SUCCESS) { + if (!efi_netobj_is_active(netobj)) { + r = efi_netobj_init(netobj); + if (r) + return -1; + } + } + return 0; } @@ -1491,6 +1505,10 @@ int efi_net_unregister(void *ctx, struct event *event) return 0; if (efi_netobj_is_active(netobj)) { + ret = EFI_CALL(efi_disconnect_controller(netobj->handle, NULL, NULL)); + if (ret != EFI_SUCCESS) + return -1; + ret = EFI_CALL(efi_close_event(netobj->wait_for_packet)); if (ret != EFI_SUCCESS) return -1; -- 2.48.1
[PATCH 05/16] efi_net: efi_loader: Add efi_netobj_alloc to allocate an efi_net_obj
Rework the logic to allocate an efi_net_obj and its members. An efi_net_obj now gets allocated only in efi_netobj_alloc. Signed-off-by: Adriano Cordova --- lib/efi_loader/efi_net.c | 131 --- 1 file changed, 80 insertions(+), 51 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index a40d319a27f..a14ecf3d182 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -1152,19 +1152,10 @@ static int efi_netobj_init(struct efi_net_obj *netobj) size_t *receive_lengths = NULL; int i, j; - if (!netobj || efi_netobj_is_active(netobj)) + if (!netobj || !netobj->net || efi_netobj_is_active(netobj)) return 0; dev = netobj->dev; - if (!dev) { - /* No network device active, don't expose any */ - return 0; - } - - if (!netobj->net) - netobj->net = calloc(1, sizeof(*netobj->net)); - if (!netobj->net) - goto out_of_resources; if (!netobj->net_mode) netobj->net_mode = calloc(1, sizeof(*netobj->net_mode)); @@ -1344,6 +1335,84 @@ efi_status_t efi_net_init(void) return EFI_SUCCESS; } +/** + * efi_netobj_alloc() - allocate an efi_net_obj from either a simple + * network protocol interface or a net udevice + * + * @handle:EFI handle + * @net: pointer to simple network protocol + * @dev: pointer to net udevice + * Return: pointer to EFI net object, NULL on error + */ +struct efi_net_obj *efi_netobj_alloc(efi_handle_t handle, + struct efi_simple_network *net, + struct udevice *dev) +{ + int i; + struct efi_net_obj *netobj; + + // Find a slot for this efi_net_obj + + // Try to recycle + for (i = 0; i < MAX_EFI_NET_OBJS; i++) { + if (net_objs[i] && !net_objs[i]->net && !net_objs[i]->dev && !net_objs[i]->handle) + break; + } + if (i == MAX_EFI_NET_OBJS) { + for (i = 0; i < MAX_EFI_NET_OBJS; i++) { + if (!net_objs[i]) + break; + } + } + if (i == MAX_EFI_NET_OBJS) + return NULL; + + if (!net_objs[i]) { + netobj = calloc(1, sizeof(*netobj)); + net_objs[i] = netobj; + } else { + netobj = net_objs[i]; + } + if (!netobj) + return NULL; + + if (netobj->net) { + if (netobj->net->mode) + free(netobj->net->mode); + free(netobj->net); + } + + if (handle) { + netobj->handle = handle; + } + else { + netobj->handle = calloc(1, sizeof(*netobj->handle)); + if (!netobj->handle) { + free(netobj); + return NULL; + } + } + + if (net) { + netobj->net = net; + netobj->net_mode = net->mode; + } else { + netobj->net = calloc(1, sizeof(*netobj->net)); + if (!netobj->net) { + free(netobj->handle); + free(netobj); + return NULL; + } + } + + netobj->dev = dev; + netobj->efi_seq_num = i; + + printf("\nefi_net: allocated EFI net device %d\n", netobj->efi_seq_num); + + return netobj; +} + /** * efi_net_register() - register a net device * @@ -1356,9 +1425,7 @@ efi_status_t efi_net_init(void) int efi_net_register(void *ctx, struct event *event) { struct udevice *dev; - int seq_num; enum uclass_id id; - struct efi_net_obj *netobj; int i; dev = event->data.dm.dev; @@ -1378,48 +1445,10 @@ int efi_net_register(void *ctx, struct event *event) } } - // Find a slot for this efi_net_obj - seq_num = -1; - // Try to recycle - for (i = 0; i < MAX_EFI_NET_OBJS; i++) { - if (net_objs[i] && !net_objs[i]->dev) { - seq_num = i; - break; - } - } - if (seq_num < 0) { - for (i = 0; i < MAX_EFI_NET_OBJS; i++) { - if (!net_objs[i]) { - seq_num = i; - break; - } - } - } - if (seq_num < 0) + if (!efi_netobj_alloc(NULL, NULL, dev)) return -1; - if (!net_objs[seq_num]) { - netobj = calloc(1, sizeof(*netobj)); - net_objs[seq_num] = netobj; - } else { - netobj = net_objs[seq_num]; - } - if (!netobj) - goto out_of_resources; - - netobj->handle = calloc(1, sizeof(*netobj->handle)
[PATCH 07/16] eth_uclass: Add eth_create_device to create a net udevice
This comes in preparation to support calling connect_controller with a handle with the efi_simple_network_protocol installed. Signed-off-by: Adriano Cordova --- include/net-common.h | 2 ++ net/eth-uclass.c | 32 2 files changed, 34 insertions(+) diff --git a/include/net-common.h b/include/net-common.h index 1d507b13b06..ba343af4c66 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -203,6 +203,8 @@ int eth_receive(void *packet, int length); /* Receive a packet*/ extern void (*push_packet)(void *packet, int length); #endif int eth_rx(void); /* Check for received packets */ +int eth_create_device(struct udevice *parent, const char *drv_name, + const char *name, struct udevice **devp); /** * reset_phy() - Reset the Ethernet PHY diff --git a/net/eth-uclass.c b/net/eth-uclass.c index f82f23e..952df419b70 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -12,10 +12,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include "eth_internal.h" @@ -528,6 +530,36 @@ int eth_initialize(void) return num_devices; } +int eth_create_device(struct udevice *parent, const char *drv_name, + const char *name, struct udevice **devp) +{ + char temp[40], *str; + int devnum; + struct uclass *uc; + int ret; + + ret = uclass_get(UCLASS_ETH, &uc); + if (ret) + return -1; + + devnum = uclass_find_next_free_seq(uc); + if (devnum < 0) + return -1; + + snprintf(temp, sizeof(temp), "%s_eth%d", name, devnum); + temp[sizeof(temp) - 1] = '\0'; + str = strdup(temp); + + ret = device_bind_driver(parent, drv_name, str, devp); + if (ret) { + free(str); + return ret; + } + device_set_name_alloced(*devp); + + return 0; +} + static int eth_post_bind(struct udevice *dev) { struct eth_uclass_priv *priv = uclass_get_priv(dev->uclass); -- 2.48.1
[PATCH 09/16] efi_driver: efi_uclass: Add unbind method to efi_driver_ops
Signed-off-by: Adriano Cordova --- include/efi_driver.h| 4 lib/efi_driver/efi_uclass.c | 4 2 files changed, 8 insertions(+) diff --git a/include/efi_driver.h b/include/efi_driver.h index 63a95e4cf80..8f785f79459 100644 --- a/include/efi_driver.h +++ b/include/efi_driver.h @@ -36,6 +36,8 @@ struct efi_driver_binding_extended_protocol { * driver binding protocol. * @bind: Function called by the EFI uclass to attach the * driver to EFI driver to a handle. + * @unbind:Function called by the EFI uclass to detach the + * driver to EFI driver to a handle. */ struct efi_driver_ops { const efi_guid_t *protocol; @@ -43,6 +45,8 @@ struct efi_driver_ops { efi_status_t (*init)(struct efi_driver_binding_extended_protocol *this); efi_status_t (*bind)(struct efi_driver_binding_extended_protocol *this, efi_handle_t handle, void *interface); + efi_status_t (*unbind)(struct efi_driver_binding_extended_protocol *this, + efi_handle_t handle); }; #endif /* _EFI_DRIVER_H */ diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index fc8808374a1..36a86817eb7 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -249,6 +249,10 @@ static efi_status_t EFIAPI efi_uc_stop( if (ret != EFI_SUCCESS) log_err("Cannot free EFI memory pool\n"); + ret = bp->ops->unbind(bp, controller_handle); + if (ret != EFI_SUCCESS) + goto out; + /* Detach driver from controller */ ret = efi_close_protocol(controller_handle, bp->ops->protocol, this->driver_binding_handle, -- 2.48.1
[PATCH 11/16] efi_loader: efi_net: Add http, ip4_config2, and pxe on demand
Add http and ip4_config2 only if they are not already provided in the handle. The current use of pxe is only to store an ip address if a dhcp ack is received, this address is used by grub. Add pxe only if a dhcp ack is actually received. Signed-off-by: Adriano Cordova --- include/efi_loader.h | 8 +- lib/efi_loader/efi_http.c | 30 - lib/efi_loader/efi_ipconfig.c | 36 +- lib/efi_loader/efi_net.c | 203 +++--- 4 files changed, 199 insertions(+), 78 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 35f500fd97d..ad234dbe6b3 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -677,10 +677,14 @@ efi_status_t efi_net_init(void); efi_status_t efi_net_do_start(void); /* Called by efi_net_register to make the ip4 config2 protocol available */ efi_status_t efi_ipconfig_register(const efi_handle_t handle, - struct efi_ip4_config2_protocol *ip4config); + struct efi_ip4_config2_protocol **ip4config); +efi_status_t efi_ipconfig_unregister(const efi_handle_t handle, +struct efi_ip4_config2_protocol *ip4config); /* Called by efi_net_register to make the http protocol available */ efi_status_t efi_http_register(const efi_handle_t handle, - struct efi_service_binding_protocol *http_service_binding); + struct efi_service_binding_protocol **http_service_binding); +efi_status_t efi_http_unregister(const efi_handle_t handle, +struct efi_service_binding_protocol *http_service_binding); /* Called by bootefi to make the watchdog available */ efi_status_t efi_watchdog_register(void); efi_status_t efi_initrd_register(void); diff --git a/lib/efi_loader/efi_http.c b/lib/efi_loader/efi_http.c index 189317fe2d2..dcef875f5b5 100644 --- a/lib/efi_loader/efi_http.c +++ b/lib/efi_loader/efi_http.c @@ -486,23 +486,45 @@ static efi_status_t EFIAPI efi_http_service_binding_destroy_child( * */ efi_status_t efi_http_register(const efi_handle_t handle, - struct efi_service_binding_protocol *http_service_binding) + struct efi_service_binding_protocol **http_service_binding) { efi_status_t r = EFI_SUCCESS; + r = efi_allocate_pool(EFI_LOADER_DATA, sizeof(**http_service_binding), + (void **)http_service_binding); + if (r != EFI_SUCCESS) + return r; r = efi_add_protocol(handle, &efi_http_service_binding_guid, -http_service_binding); +*http_service_binding); if (r != EFI_SUCCESS) goto failure_to_add_protocol; - http_service_binding->create_child = efi_http_service_binding_create_child; - http_service_binding->destroy_child = efi_http_service_binding_destroy_child; + (*http_service_binding)->create_child = efi_http_service_binding_create_child; + (*http_service_binding)->destroy_child = efi_http_service_binding_destroy_child; return EFI_SUCCESS; failure_to_add_protocol: return r; } +/** + * efi_http_unregister() - unregister the http protocol + * + */ +efi_status_t efi_http_unregister(const efi_handle_t handle, +struct efi_service_binding_protocol *http_service_binding) +{ + efi_status_t r = EFI_SUCCESS; + + r = efi_uninstall_protocol(handle, &efi_http_service_binding_guid, + http_service_binding, true); + if (r != EFI_SUCCESS) + return r; + efi_free_pool(http_service_binding); + + return EFI_SUCCESS; +} + enum efi_http_status_code efi_u32_to_httpstatus(u32 status) { switch (status) { diff --git a/lib/efi_loader/efi_ipconfig.c b/lib/efi_loader/efi_ipconfig.c index 9f51f77fa9a..18f659f4ed1 100644 --- a/lib/efi_loader/efi_ipconfig.c +++ b/lib/efi_loader/efi_ipconfig.c @@ -194,12 +194,18 @@ static efi_status_t EFIAPI efi_ip4_config2_unregister_notify(struct efi_ip4_conf * */ efi_status_t efi_ipconfig_register(const efi_handle_t handle, - struct efi_ip4_config2_protocol *ip4config) + struct efi_ip4_config2_protocol **ip4config) { efi_status_t r = EFI_SUCCESS; + if (!ip4config) + return EFI_INVALID_PARAMETER; + + r = efi_allocate_pool(EFI_LOADER_DATA, sizeof(**ip4config), (void **)ip4config); + if (r != EFI_SUCCESS) + return r; r = efi_add_protocol(handle, &efi_ip4_config2_guid, -ip4config); +*ip4config); if (r != EFI_SUCCESS) { log_err("ERROR: Failure to add protocol\n"); return r; @@ -207,10 +213,28 @@ efi_status_t efi_ipconfig_register(const e
[PATCH 12/16] efi_loader: efi_net: add snp_owner field to efi_net_obj struct
Two efi_net_obj's could share the same efi_simple_network_protocol interface. For example, say a working U-Boot net device is registered in the EFI subsystem, this will create an instance of an efi simple network protocol. Then another handle, say handle A, could be created using this same efi simple network protocol interface, and connect controller could be called. A U-Boot udevice would be created for handle A and it would be registered in the EFI subsystem as an efi_net_obj with the same simple network protocol interface as the efi_net_obj we started with. Signed-off-by: Adriano Cordova --- lib/efi_loader/efi_net.c | 51 +--- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 5a00e7a570c..3ad51d343da 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -110,6 +110,7 @@ struct efi_net_obj { struct efi_event *wait_for_packet; struct efi_event *network_timer_event; int efi_seq_num; + bool snp_owner; }; static int curr_efi_net_obj; @@ -134,15 +135,17 @@ static bool efi_netobj_is_active(struct efi_net_obj *netobj) * * * @snp: pointer to the simple network protocol + * @bool: snp owner * Return: pointer to efi_net_obj, NULL on error */ -static struct efi_net_obj *efi_netobj_from_snp(struct efi_simple_network *snp) +static struct efi_net_obj *efi_netobj_from_snp(struct efi_simple_network *snp, + bool snp_owner) { int i; for (i = 0; i < MAX_EFI_NET_OBJS; i++) { - if (net_objs[i] && net_objs[i]->net == snp) { - // Do not register duplicate devices + if (net_objs[i] && net_objs[i]->net == snp && + (!snp_owner || net_objs[i]->snp_owner)) { return net_objs[i]; } } @@ -171,7 +174,7 @@ static efi_status_t EFIAPI efi_net_start(struct efi_simple_network *this) goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); if (this->mode->state != EFI_NETWORK_STOPPED) { ret = EFI_ALREADY_STARTED; @@ -207,7 +210,7 @@ static efi_status_t EFIAPI efi_net_stop(struct efi_simple_network *this) goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); if (this->mode->state == EFI_NETWORK_STOPPED) { ret = EFI_NOT_STARTED; @@ -250,7 +253,7 @@ static efi_status_t EFIAPI efi_net_initialize(struct efi_simple_network *this, r = EFI_INVALID_PARAMETER; goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); switch (this->mode->state) { case EFI_NETWORK_INITIALIZED: @@ -347,7 +350,7 @@ static efi_status_t EFIAPI efi_net_shutdown(struct efi_simple_network *this) ret = EFI_INVALID_PARAMETER; goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); switch (this->mode->state) { case EFI_NETWORK_INITIALIZED: @@ -553,7 +556,7 @@ static efi_status_t EFIAPI efi_net_get_status(struct efi_simple_network *this, goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); switch (this->mode->state) { case EFI_NETWORK_STOPPED: @@ -614,7 +617,7 @@ static efi_status_t EFIAPI efi_net_transmit goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); /* We do not support jumbo packets */ if (buffer_size > PKTSIZE_ALIGN) { @@ -712,7 +715,7 @@ static efi_status_t EFIAPI efi_net_receive goto out; } - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); switch (this->mode->state) { case EFI_NETWORK_STOPPED: @@ -870,7 +873,7 @@ static void EFIAPI efi_network_timer_notify(struct efi_event *event, if (!this || this->mode->state != EFI_NETWORK_INITIALIZED) goto out; - nt = efi_netobj_from_snp(this); + nt = efi_netobj_from_snp(this, true); curr_efi_net_obj = nt->efi_seq_num; // The following only happens if the net obj was removed but the event @@ -1205,7 +1208,7 @@ static int efi_netobj_init(struct efi_net_obj *netobj) dev = netobj->dev; - if (efi_netobj_is_active(netobj)) + if (efi_netobj_is_active(netobj) || !netobj->snp_owner) goto set_timers; if (!netobj->net_mode) @@ -1417,6 +1420,7 @@ struct efi_net_obj *efi_netobj_alloc(efi_handle_t handle, free(netobj->net->mode); free(netobj->net); } + netobj->net = NULL; if (
[PATCH 10/16] efi_driver: efi_net: Add efi_net_unbind_drv method to efi_net driver
Signed-off-by: Adriano Cordova --- lib/efi_driver/efi_net_device.c | 44 + 1 file changed, 44 insertions(+) diff --git a/lib/efi_driver/efi_net_device.c b/lib/efi_driver/efi_net_device.c index 3838cc47158..bc4edde19b0 100644 --- a/lib/efi_driver/efi_net_device.c +++ b/lib/efi_driver/efi_net_device.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -172,6 +173,48 @@ static efi_status_t efi_net_bind_drv( return EFI_SUCCESS; } +/** + * efi_net_unbind_drv() - TODO + * + * @this: driver binding protocol + * @handle:handle + * Return: status code + */ +static efi_status_t efi_net_unbind_drv( + struct efi_driver_binding_extended_protocol *this, + efi_handle_t handle) +{ + EFI_PRINT("%s: handle %p\n", __func__, handle); + + struct driver *drv; + struct udevice *dev; + int r; + + if (!handle || !handle->dev) + return EFI_DEVICE_ERROR; + + drv = lists_driver_lookup_name("efi_netdev"); + if (!drv) { + log_err("Cannot find driver 'efi_netdev'\n"); + return EFI_DEVICE_ERROR; + } + + if (drv == handle->dev->driver) { + dev = handle->dev; + r = efi_unlink_dev(handle); + if (r) + return EFI_DEVICE_ERROR; + r = device_remove(dev, DM_REMOVE_NORMAL); + if (r) + return EFI_DEVICE_ERROR; + r = device_unbind(dev); + if (r) + return EFI_DEVICE_ERROR; + } + + return EFI_SUCCESS; +} + /** * efi_net_init_drv() - initialize network device driver * @@ -236,6 +279,7 @@ static const struct efi_driver_ops driver_ops = { .protocol = &efi_net_guid, .init = efi_net_init_drv, .bind = efi_net_bind_drv, + .unbind = efi_net_unbind_drv, }; /* Identify as EFI driver */ -- 2.48.1
[PATCH 13/16] efi_selftest: Add selftest for counting EFI netdevices
Signed-off-by: Adriano Cordova --- lib/efi_selftest/Makefile | 2 +- lib/efi_selftest/efi_selftest_net_device.c | 65 ++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/efi_selftest/efi_selftest_net_device.c diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 17fbfad116f..f7e8f02cb20 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -51,7 +51,7 @@ efi_selftest_variables_runtime.o \ efi_selftest_watchdog.o obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o -obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o +obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o efi_selftest_net_device.o obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_http.o obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_ipconfig.o diff --git a/lib/efi_selftest/efi_selftest_net_device.c b/lib/efi_selftest/efi_selftest_net_device.c new file mode 100644 index 000..51963eb328c --- /dev/null +++ b/lib/efi_selftest/efi_selftest_net_device.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * efi_selftest_net_device + * + */ + +#include +#include + +static struct efi_boot_services *boottime; + +/* + * Setup unit test. + * + * @handle:handle of the loaded image + * @systable: system table + * Return: EFI_ST_SUCCESS for success + */ +static int setup(const efi_handle_t handle, +const struct efi_system_table *systable) +{ + efi_uintn_t num_handles; + efi_handle_t *handles; + + boottime = systable->boottime; + + num_handles = 0; + boottime->locate_handle_buffer(BY_PROTOCOL, &efi_net_guid, + NULL, &num_handles, &handles); + efi_st_printf("Detected %u active EFI net devices\n", (unsigned int)num_handles); + + return EFI_ST_SUCCESS; +} + +/* + * Execute unit test. + * + * + * Return: EFI_ST_SUCCESS for success + */ +static int execute(void) +{ + return EFI_ST_SUCCESS; +} + +/* + * Tear down unit test. + * + * Return: EFI_ST_SUCCESS for success + */ +static int teardown(void) +{ + int exit_status = EFI_ST_SUCCESS; + + return exit_status; +} + +EFI_UNIT_TEST(netdevices) = { + .name = "netdevices", + .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, + .setup = setup, + .execute = execute, + .teardown = teardown, + .on_request = true, +}; -- 2.48.1
[PATCH 16/16] efi_selftest: Add test for efi_netdev driver
Signed-off-by: Adriano Cordova --- lib/efi_selftest/Makefile | 2 +- lib/efi_selftest/efi_selftest_net_driver.c | 310 + 2 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 lib/efi_selftest/efi_selftest_net_driver.c diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index f7e8f02cb20..df51e0cfd1b 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -51,7 +51,7 @@ efi_selftest_variables_runtime.o \ efi_selftest_watchdog.o obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o -obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o efi_selftest_net_device.o +obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o efi_selftest_net_device.o efi_selftest_net_driver.o obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_http.o obj-$(CONFIG_EFI_HTTP_PROTOCOL) += efi_selftest_ipconfig.o diff --git a/lib/efi_selftest/efi_selftest_net_driver.c b/lib/efi_selftest/efi_selftest_net_driver.c new file mode 100644 index 000..0bd130cb067 --- /dev/null +++ b/lib/efi_selftest/efi_selftest_net_driver.c @@ -0,0 +1,310 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * efi_selftest_net_driver + * + */ + +#include +#include + +static struct efi_boot_services *boottime; +static efi_handle_t test_handle; +static struct efi_service_binding_protocol *http_service; +static struct efi_http_protocol *http; +static efi_handle_t http_protocol_handle; +static int callback_done; + +static const efi_guid_t efi_http_guid = EFI_HTTP_PROTOCOL_GUID; +static const efi_guid_t efi_http_service_binding_guid = EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID; + +/* + * Setup unit test. + * + * @handle:handle of the loaded image + * @systable: system table + * Return: EFI_ST_SUCCESS for success + */ +static int setup(const efi_handle_t handle, +const struct efi_system_table *systable) +{ + efi_status_t ret; + struct efi_http_config_data http_config; + struct efi_httpv4_access_point ipv4_node; + void *snp; + + boottime = systable->boottime; + + ret = boottime->locate_protocol(&efi_net_guid, + NULL, &snp); + if (ret != EFI_SUCCESS || !snp) { + efi_st_printf("No simple network protocol available, can't proceed with the test\n"); + return EFI_ST_SUCCESS; + } + + test_handle = NULL; + ret = boottime->install_protocol_interface(&test_handle, &efi_net_guid, + EFI_NATIVE_INTERFACE, snp); + if (ret != EFI_SUCCESS) { + efi_st_printf("Can't install simple network protocol\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->connect_controller(test_handle, NULL, NULL, false); + if (ret != EFI_SUCCESS) { + efi_st_printf("Failed connecting controller\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->open_protocol(test_handle, + &efi_http_service_binding_guid, + (void **)&http_service, 0, 0, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS || !http_service) { + efi_st_printf("Failed opening http service binding protocol\n"); + return EFI_ST_FAILURE; + } + + http_protocol_handle = NULL; + ret = http_service->create_child(http_service, &http_protocol_handle); + if (ret != EFI_SUCCESS || !http_protocol_handle) { + efi_st_error("Failed to create an http service instance\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->open_protocol(http_protocol_handle, &efi_http_guid, + (void **)&http, 0, 0, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (ret != EFI_SUCCESS || !http) { + efi_st_error("Failed to open http protocol\n"); + return EFI_ST_FAILURE; + } + efi_st_printf("HTTP Service Binding: child created successfully\n"); + + http_config.http_version = HTTPVERSION11; + http_config.is_ipv6 = false; + http_config.access_point.ipv4_node = &ipv4_node; + ipv4_node.use_default_address = true; + + ret = http->configure(http, &http_config); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to configure http instance\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; +} + +static void EFIAPI efi_test_http_callback(struct efi_event *event, void *context) +{ + callback_done = 1; +} + +/* + * Execute unit test. + * + * + * Return: EFI_ST_SUCCESS for success + */ +static int execute(void) +{ + efi_status_t ret; + struct efi_http_request_data request_data; + struct efi_http_message request_message; + struct efi_http_token request_token; + struct efi_http_response_data response_data; + st
[PATCH 14/16] py/tests: test_efi_selftest: Add test for counting EFI netdevices
Signed-off-by: Adriano Cordova --- test/py/tests/test_efi_selftest.py | 21 + 1 file changed, 21 insertions(+) diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 310d8ed294a..af9992a6f7f 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -195,3 +195,24 @@ def test_efi_selftest_tcg2(u_boot_console): if u_boot_console.p.expect(['Summary: 0 failures', 'Press any key']): raise Exception('Failures occurred during the EFI selftest') u_boot_console.restart_uboot() + +@pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.buildconfigspec('cmd_dm') +def test_efi_selftest_count_netdevices(u_boot_console): +"""Test the EFI net device driver + +u_boot_console -- U-Boot console + +This function counts the number of ETH_UCLASS probed udevices +calls the EFI net device selftest to check that the EFI driver +sees the same. +""" +u_boot_console.restart_uboot() +response = u_boot_console.run_command('dm tree') +lines = response.splitlines()[2:] +ethernet_count = sum(1 for line in lines if line.strip().startswith('ethernet') and '[ + ]' in line) + +u_boot_console.run_command(cmd='setenv efi_selftest netdevices') +u_boot_console.run_command('bootefi selftest', wait_for_prompt=False) +if u_boot_console.p.expect([f'Detected {ethernet_count} active EFI net devices']): +raise Exception('Failures occurred during the EFI selftest') -- 2.48.1
[PATCH 15/16] py/tests: test_efi_selftest: Add test for removing EFI netdevices
Signed-off-by: Adriano Cordova --- test/py/tests/test_efi_selftest.py | 24 1 file changed, 24 insertions(+) diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index af9992a6f7f..2b7944d1983 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -216,3 +216,27 @@ def test_efi_selftest_count_netdevices(u_boot_console): u_boot_console.run_command('bootefi selftest', wait_for_prompt=False) if u_boot_console.p.expect([f'Detected {ethernet_count} active EFI net devices']): raise Exception('Failures occurred during the EFI selftest') + +@pytest.mark.buildconfigspec('cmd_bootefi_selftest') +@pytest.mark.buildconfigspec('cmd_dm') +@pytest.mark.buildconfigspec('cmd_bind') +def test_efi_selftest_remove_netdevices(u_boot_console): +"""Test the EFI net device driver + +u_boot_console -- U-Boot console + +This function removes all the ETH_UCLASS udevices and +calls the EFI net device selftest to check that the EFI driver +sees the same. +""" +u_boot_console.restart_uboot() +response = u_boot_console.run_command('dm tree') +lines = response.splitlines()[2:] +ethernet_count = sum(1 for line in lines if line.strip().startswith('ethernet') and '[ + ]' in line) + +for i in range(ethernet_count): +u_boot_console.run_command(f'unbind ethernet {i}') +u_boot_console.run_command(cmd='setenv efi_selftest netdevices') +u_boot_console.run_command('bootefi selftest', wait_for_prompt=False) +if u_boot_console.p.expect(['Detected 0 active EFI net devices']): +raise Exception('Failures occurred during the EFI selftest') -- 2.48.1
[PATCH 06/19] arm: mach-k3: common: Add lpm_resume_from_ddr
This is a common function that helps to resume from DDR. There are two pointers which are fetched from DDR to resume, the TIFS context pointer which points to the context in DDR. There is another pointer to the DM loadaddr to jump back into DM. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/common.c | 45 + arch/arm/mach-k3/common.h | 1 + 2 files changed, 46 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index e3554ee6aa8957b8cfcacb452ba391d7b3abf2a9..2d9f34e61d916ce3a252e9cc3c2fd5475e60799e 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -152,6 +152,51 @@ bool wkup_ctrl_is_lpm_exit(void) wkup_ctrl_canuart_magic_word_set(); } +#if IS_ENABLED(CONFIG_K3_IODDR) +static int lpm_restore_context(u64 ctx_addr) +{ + struct ti_sci_handle *ti_sci = get_ti_sci_handle(); + int ret; + + ret = ti_sci->ops.lpm_ops.restore_context(ti_sci, ctx_addr); + if (ret) + printf("Failed to restore context from DDR %d\n", ret); + + return ret; +} + +struct lpm_meta_data { + u64 dm_jump_address; + u64 tifs_context_save_address; + u64 reserved[30]; +} __packed__; + +void __noreturn lpm_resume_from_ddr(u64 meta_data_addr) +{ + struct lpm_meta_data *lpm_data = (struct lpm_meta_data *)meta_data_addr; + typedef void __noreturn (*image_entry_noargs_t)(void); + image_entry_noargs_t image_entry; + int ret; + + ret = lpm_restore_context(lpm_data->tifs_context_save_address); + if (ret) + panic("Failed to restore context from 0x%p\n", + (void *)lpm_data->tifs_context_save_address); + + image_entry = (image_entry_noargs_t)(u64 *)lpm_data->dm_jump_address; + printf("Resuming from DDR, jumping to stored DM loadaddr 0x%p, TIFS context restored from 0x%p\n", + image_entry, (void *)lpm_data->tifs_context_save_address); + + image_entry(); +} +#else + +void __noreturn lpm_resume_from_ddr(u64 meta_data_addr) +{ + panic("No IO+DDR support"); +} +#endif + bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data) { if (strncmp(data->header, K3_ROM_BOOT_HEADER_MAGIC, 7)) diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index 5d347c7252d18c06dac21813b8247fa2c57902bc..47f2dbf2accd9029d6f1905fe8d3f93381032a81 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -47,6 +47,7 @@ void do_board_detect(void); void ti_secure_image_check_binary(void **p_image, size_t *p_size); void wkup_ctrl_remove_can_io_isolation_if_set(void); bool wkup_ctrl_is_lpm_exit(void); +void lpm_resume_from_ddr(u64 meta_data_addr); #if (IS_ENABLED(CONFIG_K3_QOS)) void setup_qos(void); -- 2.47.2
Re: [PATCH 00/19] am62: IO+DDR resume support
Hi Markus, On Tue, 11 Mar 2025 at 16:02, Markus Schneider-Pargmann wrote: > > Hi, > > this series introduces support to resume from IO+DDR. IO+DDR is a low > power mode of am62a and am62p in which nearly everything is powered off > except DDR which is in self-refresh and a few pins which detect > activity and can wakeup the system again. > > On resume uboot SPL is loaded and checks if this is a IO+DDR resume. If > it is, the DDR initialization sequence in k3-ddrss differs slightly as > it has to get the DDR out of the self-refresh. > > Afterwards a specific address determined from DT is used to get the > metadata that stores relevant context addresses. The context is restored > using the tisci message TI_SCI_MSG_MIN_CONTEXT_RESTORE. At the end all > further initializations are skipped and uboot SPL directly jumps into > the DM resume address which takes care of the rest. > > The devicetree R5F related patches were picked up from the mailinglist > and are required to find the correct address of the metadata. > > k3-ddrss is using absolute register accesses at the moment. I am trying > to submit syscon DT patches upstream to access these through syscon, > unfortunately there is ongoing discussion regarding syscon. > > I tested this on am62a. > > Best, > Markus > > To: Tom Rini > To: Vignesh Raghavendra > To: Bryan Brattlof > To: Sumit Garg > Cc: u-boot@lists.denx.de > > Cc: Vishal Mahaveer > Cc: Kevin Hilman > Cc: Dhruva Gole > Cc: Sebin Francis > Cc: Kendall Willis > Cc: Akashdeep Kaur > > Signed-off-by: Markus Schneider-Pargmann > --- > Devarsh Thakkar (3): > arm64: dts: ti: k3-am62a-wakeup: Add R5F device node > arm64: dts: ti: k3-am62a7-sk: Enable IPC with remote processors > arm64: dts: ti: k3-am62p5-sk: Enable IPC with remote processors > > Hari Nagalla (2): > arm64: dts: ti: k3-am62a-mcu: Add R5F remote proc node > arm64: dts: ti: k3-am62x-sk-common: Enable IPC with remote processors > > Jai Luthra (1): > arm64: dts: ti: k3-am62a-main: Add C7xv device node > > Markus Schneider-Pargmann (13): > arm: mach-k3: Remove CANUART IO isolation > arm: mach-k3: Kconfig: Add symbols for IO+DDR Low Power Mode > ram: k3-ddrss: Add support for DDR in self-refresh > firmware: ti_sci: Add TI_SCI_MSG_MIN_CONTEXT_RESTORE > arm: mach-k3: common: Add CANUART wakeup check helpers > arm: mach-k3: common: Add lpm_resume_from_ddr > arm: mach-k3: common: Helper for LPM meta data address from DT > arm: mach-k3: am62a7_init: Resume on LPM exit > arm: mach-k3: am62p5_init: Resume on LPM exit > arm: dts: k3-am62a: Add r5 device nodes > arm: dts: k3-am62p: Add r5 device nodes > configs: am62ax_evm_r5: Enable IODDR resume support > configs: am62p_evm_r5_defconfig: Enable IODDR resume support > > arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 16 +++ > arch/arm/dts/k3-am62p5-sk-u-boot.dtsi | 20 +++ > arch/arm/mach-k3/Kconfig | 9 ++ > arch/arm/mach-k3/am62ax/am62a7_init.c | 11 ++ > arch/arm/mach-k3/am62px/am62p5_init.c | 12 ++ > arch/arm/mach-k3/am62x/am625_init.c | 2 + > arch/arm/mach-k3/common.c | 162 + > arch/arm/mach-k3/common.h | 4 + > arch/arm/mach-k3/include/mach/hardware.h | 32 + > configs/am62ax_evm_r5_defconfig | 1 + > configs/am62px_evm_r5_defconfig | 1 + > drivers/firmware/ti_sci.c | 38 + > drivers/firmware/ti_sci.h | 14 ++ > drivers/ram/k3-ddrss/k3-ddrss.c | 165 > ++ > dts/upstream/src/arm64/ti/k3-am62a-main.dtsi | 12 ++ > dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi | 25 > dts/upstream/src/arm64/ti/k3-am62a-wakeup.dtsi| 25 > dts/upstream/src/arm64/ti/k3-am62a7-sk.dts| 96 - > dts/upstream/src/arm64/ti/k3-am62p5-sk.dts| 50 ++- > dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi | 35 - The dts/upstream is a git subtree and is rather a snapshot of upstream devicetree-rebasing repo. It's not allowed to directly patch it but rather we need to resync or cherry-pick patches from upstream [1]. So rather than picking patches from ML, you should wait for them to land in the Linux kernel for a cherry-pick to work. Or otherwise you can choose to rely on *-u-boot.dtsi for the time being. [1] https://docs.u-boot.org/en/latest/develop/devicetree/control.html#resyncing-with-devicetree-rebasing -Sumit > include/linux/soc/ti/ti_sci_protocol.h| 9 ++ > 21 files changed, 721 insertions(+), 18 deletions(-) > --- > base-commit: a517796cfa5d8f4ca2f0c11c78c24a08a102c047 > change-id: 20250306-topic-am62-ioddr-v2025-04-rc1-0b3a0ffe92b1 > > Best regards, > -- > Markus Schneider-Pargmann >
Re: [PATCH 1/2] xilinx: Allow alternative boot strategies in zynq-common.h
On 3/11/25 08:01, Mike Looijmans wrote: Allow config headers that include zynq-common.h to provide their own (distro) boot strategies. This is implemented by skipping the section when BOOT_ENV has already been defined. Signed-off-by: Mike Looijmans --- include/configs/zynq-common.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 37c77aa1611..ad872c9d922 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -48,6 +48,9 @@ #define BOOTENV #else +/* Only use this section if no BOOTENV has been configured yet */ +#ifndef BOOTENV + #ifdef CONFIG_CMD_MMC #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1) #else @@ -167,6 +170,9 @@ BOOT_TARGET_DEVICES_DHCP(func) #include + +#endif /* BOOTENV */ + #endif /* CONFIG_XPL_BUILD */ /* Default environment */ Why are you sending this again? M
Re: [PATCH v2 4/4] drivers: i2c: Kconfig: Add CONFIG_SYS_I2C_OMAP24XX_REPEATED_START
Hello Aniket, On 10.03.25 11:36, Aniket Limaye wrote: Add a Kconfig option to disable sending Stop conditions between multiple i2c_msgs within a single xfer. Enable this config by default for ARCH_K3 platforms. Signed-off-by: Aniket Limaye --- v2: - CONFIG_I2C_REPEATED_START -> CONFIG_SYS_I2C_OMAP24XX_REPEATED_START - Link to v1: https://lore.kernel.org/u-boot/20250304220546.866602-4-a-lim...@ti.com/ --- drivers/i2c/Kconfig | 9 + 1 file changed, 9 insertions(+) Thanks! 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 v3 14/14] MAINTAINERS: add UTHREAD
On Tue, 4 Mar 2025 at 17:31, Jerome Forissier wrote: > > Add myself as the maintainer for the UTHREAD framework, the spawn/wait > commands and the associated tests. > > Signed-off-by: Jerome Forissier > --- > MAINTAINERS | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index c1851280e6e..27887bca55d 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1800,6 +1800,15 @@ T: git > https://source.denx.de/u-boot/custodians/u-boot-usb.git topic-xhci > F: drivers/usb/host/xhci* > F: include/usb/xhci.h > > +UTHREAD > +M: Jerome Forissier > +S: Maintained > +F: lib/uthread.c > +F: include/uthread.h > +F: test/lib/uthread.c > +F: cmd/spawn.c > +F: test/cmd/spawn.c > + > UUID testing > M: Abdellatif El Khlifi > S: Maintained > -- > 2.43.0 > Acked-by: Ilias Apalodimas
Re: [PATCH 2/5] arm: include asm-generic/int-ll64.h in setjmp.h
On Sun, 2 Mar 2025 at 16:22, Heinrich Schuchardt wrote: > > Don't assume that u32 and u64 are already defined. > > Signed-off-by: Heinrich Schuchardt > --- > arch/arm/include/asm/setjmp.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h > index 662bec86321..9a7f5af9f8f 100644 > --- a/arch/arm/include/asm/setjmp.h > +++ b/arch/arm/include/asm/setjmp.h > @@ -7,6 +7,8 @@ > #ifndef _SETJMP_H_ > #define _SETJMP_H_ 1 > > +#include > + > /* > * This really should be opaque, but the EFI implementation wrongly > * assumes that a 'struct jmp_buf_data' is defined. > -- > 2.48.1 > Reviewed-by: Ilias Apalodimas
[PATCH v2 0/4] Better smartphone support (Qualcomm)
Improve support for running U-Boot on [Qualcomm] smartphones, with: * A boot menu which can be entered by holding power during boot * Hang on panic (so errors can be read on the display) * Serial gadget which can be enabled by holding volume down or via boot menu In its current form, U-Boot's boot menu is perfectly adequate, however once an option is picked U-Boot will never return to the menu, always to the CLI. On a phone (with no keyboard), dropping to the CLI effectively makes the device unusable until manually rebooted, since there is no way to run any commands... To rectify this, let's revive CONFIG_BOOT_RETRY for the hush parser and add an option CONFIG_RETRY_BOOTCMD to run the contents of "bootcmd". This provides for a flexible menu system which we can enter and exit. See qcom-phone.env in patch 1 for more details. Finally, provide some rough-ish documentation to describe how Qualcomm phone support works and outline some debugging steps for when UART and the framebuffer are unavailable. --- Changes in v3: - Minor wording/clarification improvements in docs - Introduce CONFIG_RETRY_BOOTCMD rather than changing the default behaviour. - Enable some more gadgets in the phone config fragment. - Link to v2: https://lore.kernel.org/u-boot/20241004-qcom-phones-v2-0-c7ab67ac3...@linaro.org Changes in v2: - Fix CONFIG_BUTTON_REMAP_PHONE_KEYS name in qcom-phone.config - Add Tom and Simon to CC - Link to v1: https://lore.kernel.org/r/20240831-qcom-phones-v1-0-08614edd8...@linaro.org --- Caleb Connolly (4): board/qualcomm: introduce phone config cli_hush: support running bootcmd on boot retry bootretry: check for bootretry variable changes doc: board/qualcomm: describe phone support and bringup board/qualcomm/qcom-phone.config | 17 ++ board/qualcomm/qcom-phone.env| 49 boot/Kconfig | 7 +++ boot/bootretry.c | 2 + common/cli_hush.c| 6 +- common/cli_hush_upstream.c | 6 +- doc/board/qualcomm/board.rst | 5 ++ doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/phones.rst| 122 +++ 9 files changed, 211 insertions(+), 4 deletions(-) --- base-commit: 78f8c8c58f7d3f7c3a26af4afbd08aba21c14c90 Caleb Connolly
[PATCH v2 1/4] board/qualcomm: introduce phone config
Phones don't have keyboards! Introduce a phone-specific config fragment and associated environment file to make U-Boot more useful on these devices. This allows for navigating via the buttons and enabling various USB gadget modes or displaying info about U-Boot. Reviewed-by: Simon Glass Signed-off-by: Caleb Connolly --- board/qualcomm/qcom-phone.config | 17 ++ board/qualcomm/qcom-phone.env| 49 2 files changed, 66 insertions(+) diff --git a/board/qualcomm/qcom-phone.config b/board/qualcomm/qcom-phone.config new file mode 100644 index ..a2aa882285b61746a243a7a1c7c384f33839f1b2 --- /dev/null +++ b/board/qualcomm/qcom-phone.config @@ -0,0 +1,17 @@ +# Settings for phones +CONFIG_DEFAULT_ENV_FILE="board/qualcomm/qcom-phone.env" +# Hang on panic so the error message can be read +CONFIG_PANIC_HANG=y +# We use pause in various places to allow text to be read +# before it scrolls off the screen +CONFIG_CMD_PAUSE=y +CONFIG_BOOT_RETRY=y +CONFIG_BOOT_RETRY_TIME=1 +CONFIG_BUTTON_REMAP_PHONE_KEYS=y +CONFIG_RETRY_BOOTCMD=y +CONFIG_FASTBOOT_BUF_ADDR=0x1A00 +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_USB_FUNCTION_ACM=y + +# Many phones don't actually define a serial port in their DTS +# CONFIG_REQUIRE_SERIAL_CONSOLE is not set diff --git a/board/qualcomm/qcom-phone.env b/board/qualcomm/qcom-phone.env new file mode 100644 index ..2a0791c888c62b9f2257448358dd196a02e4b6fb --- /dev/null +++ b/board/qualcomm/qcom-phone.env @@ -0,0 +1,49 @@ +bootdelay=0 +bootretry=1 +stdin=serial,button-kbd +stdout=serial,vidconsole +stderr=serial,vidconsole + +# Fastboot is keen to use the address from kconfig, but we +# allocate its buffer at runtime. +fastboot=fastboot -l $fastboot_addr_r usb 0 + +# Shortcut to enable USB serial gadget and disable bootretry +serial_gadget=setenv stdin serial,button-kbd,usbacm; \ + setenv stdout serial,vidconsole,usbacm; \ + setenv stderr serial,vidconsole,usbacm; \ + setenv bootretry -1; \ + echo Enabled U-Boot console serial gadget + +# bootretry will run this command over and over, if we fail once +# then bail out to the boot menu instead (with a pause to read +# the error message) +bootcmd=bootefi bootmgr; pause; run menucmd + +# When entering the menu (either from button press or failed boot) +# remap bootcmd so it will re-open the menu and we won't get stuck +# at the console with no way to type +menucmd=setenv bootcmd run menucmd; bootmenu -1 + +# Pause is used so the output can be read on the display +bootmenu_0=Boot=bootefi bootmgr; pause +bootmenu_1=Enable serial console gadget=run serial_gadget +bootmenu_2=Enable USB mass storage=ums 0 scsi 0 +bootmenu_3=Reset device=reset +bootmenu_4=Dump clocks=clk dump; pause +bootmenu_5=Dump environment=printenv; pause +bootmenu_6=Board info=bdinfo; pause +bootmenu_7=Dump bootargs=fdt print /chosen bootargs; pause +bootmenu_8=Enable fastboot mode=run fastboot +# Disabling bootretry means we'll just drop the shell +bootmenu_9=Drop to shell=setenv bootretry -1 + +# Allow holding the power button while U-Boot loads to enter +# the boot menu +button_cmd_0_name=pwrkey +button_cmd_0=run menucmd + +# Hold volume down to drop to a shell with the USB serial gadget +# enabled for debugging +button_cmd_1_name=Volume down +button_cmd_1=run serial_gadget -- 2.48.1
[PATCH v2 2/4] cli_hush: support running bootcmd on boot retry
Introduce a new config option: RETRY_BOOTCMD. When enabled this causes hush shell to re-run "bootcmd" when the auto-boot counter times out. Signed-off-by: Caleb Connolly --- boot/Kconfig | 7 +++ common/cli_hush.c | 6 -- common/cli_hush_upstream.c | 6 -- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/boot/Kconfig b/boot/Kconfig index c09a98c3233ceb1c68024a193d7dafdce6b83903..4db13dcb9a51940c358f754d9ff91e88bebd96b1 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -1711,8 +1711,15 @@ config RESET_TO_RETRY help After the countdown timed out, the board will be reset to restart again. +config RETRY_BOOTCMD + bool "Run bootcmd on retry" + depends on BOOT_RETRY && HUSH_PARSER && !RESET_TO_RETRY + help + If this option is enabled, the "bootcmd" will be run after the + countdown times out. + endmenu menu "Image support" diff --git a/common/cli_hush.c b/common/cli_hush.c index a6a8edce1f43cf4f28fdfc0d8da9b6e180c23cd4..bb134cce18dad8dddb54d7b038ca105853fc3eda 100644 --- a/common/cli_hush.c +++ b/common/cli_hush.c @@ -1027,10 +1027,12 @@ static void get_user_input(struct in_str *i) if (n == -2) { puts("\nTimeout waiting for command\n"); # ifdef CONFIG_RESET_TO_RETRY do_reset(NULL, 0, 0, NULL); -# else -# error "This currently only works with CONFIG_RESET_TO_RETRY enabled" +# elif IS_ENABLED(CONFIG_RETRY_BOOTCMD) + strcpy(console_buffer, "run bootcmd\n"); +# else +# error "This only works with CONFIG_RESET_TO_RETRY or CONFIG_BOOT_RETRY_COMMAND enabled" # endif } #endif if (n == -1 ) { diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c index ab5aa5f9b36a91e09f8fcfcbb8b31afa0892e6bc..748ef60ac90b8af8052631c7ad3a6aed2629140b 100644 --- a/common/cli_hush_upstream.c +++ b/common/cli_hush_upstream.c @@ -2906,10 +2906,12 @@ static void get_user_input(struct in_str *i) if (n == -2) { puts("\nTimeout waiting for command\n"); # ifdef CONFIG_RESET_TO_RETRY do_reset(NULL, 0, 0, NULL); -# else -# error "This currently only works with CONFIG_RESET_TO_RETRY enabled" +# elif IS_ENABLED(CONFIG_RETRY_BOOTCMD) + strcpy(console_buffer, "run bootcmd\n"); +# else +# error "This only works with CONFIG_RESET_TO_RETRY or CONFIG_BOOT_RETRY_COMMAND enabled" # endif } # endif if (n == -1 ) { -- 2.48.1
[PATCH v2 3/4] bootretry: check for bootretry variable changes
To enable more complex sequencing of the bootmenu, autoboot, and bootretry, handle changes to the bootretry variable between tries. This makes it possible to turn bootretry off (e.g. to drop to a shell) and then back on again. This makes it possible to have a persistent bootmenu (the only way to navigate U-Boot on devices like smartphones which lack a physical keyboard) by having bootcmd be defined to launch the bootmenu. This allows for menu options like enabling USB mass storage gadget to return back to the boot menu once the gadget is shut down. Reviewed-by: Tom Rini Signed-off-by: Caleb Connolly --- boot/bootretry.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boot/bootretry.c b/boot/bootretry.c index 587b2de7d6b08db07e1dea512a834cb5590c2d12..a60767eaa2ee51970e4695e487ce5651575079ba 100644 --- a/boot/bootretry.c +++ b/boot/bootretry.c @@ -36,8 +36,10 @@ void bootretry_init_cmd_timeout(void) * reset command line timeout to retry_time seconds */ void bootretry_reset_cmd_timeout(void) { + /* Parse changes to bootretry */ + bootretry_init_cmd_timeout(); endtime = endtick(retry_time); } int bootretry_tstc_timeout(void) -- 2.48.1
Re: boottime->efi_allocate_pages() returning EFI_NOT_FOUND
+CC Ard On Sat, 8 Mar 2025 at 19:36, Ben Schneider wrote: > > On Wednesday, March 5th, 2025 at 12:20 AM, Heinrich Schuchardt > wrote: > > > > On 3/5/25 09:13, Sughosh Ganu wrote: > > > > > > Can you check what is the address being asked for in the > > > lmb_alloc_addr() function. > > > > maybe also add a call to lmb_dump_all_force() > > Thank you both! This was exactly what I needed. This appears to be > a kernel bug in randomalloc.c which always breaks out of a loop > after only one iteration[1] which is unlikely to be the intention. > > Ben > > [1] > https://github.com/torvalds/linux/blob/master/drivers/firmware/efi/libstub/randomalloc.c#L133 FWIW we discussed this in the kernel mailing list as well [0]. Ben can you apply [1] and see if it fixes your problem? [0] https://lore.kernel.org/linux-efi/cac_iwj+9dnswd7qcc7v8uxsaoabtzx7qtya7yo8py5peuhd...@mail.gmail.com/T/#t [1] https://patchwork.ozlabs.org/project/uboot/list/?series=446790 Cheers /Ilias
Re: [PATCH 1/2] xilinx: Allow alternative boot strategies in zynq-common.h
On 11-03-2025 09:03, Michal Simek wrote: On 3/11/25 08:01, Mike Looijmans wrote: Allow config headers that include zynq-common.h to provide their own (distro) boot strategies. This is implemented by skipping the section when BOOT_ENV has already been defined. Signed-off-by: Mike Looijmans --- include/configs/zynq-common.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 37c77aa1611..ad872c9d922 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -48,6 +48,9 @@ #define BOOTENV #else +/* Only use this section if no BOOTENV has been configured yet */ +#ifndef BOOTENV + #ifdef CONFIG_CMD_MMC #define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1) #else @@ -167,6 +170,9 @@ BOOT_TARGET_DEVICES_DHCP(func) #include + +#endif /* BOOTENV */ + #endif /* CONFIG_XPL_BUILD */ /* Default environment */ Why are you sending this again? Sorry, forgot to mention. Sending it in a single batch shows why I want this change... The first one got out because I forgot to say "-n" to patman, but it was fine as it is, so I didn't recall it. -- Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: mike.looijm...@topic.nl W: www.topic.nl
[PATCH v2 2/8] mach-k3: fix reading size and addr from fdt on R5
fdtdec_get_addr_size uses architecture dependent datatypes which causes the 32-bit R5 to fail when reading the 64-bit size and addr fields of reg nodes from the fdt. This changes it to a common api for both 64 and 32 bit platforms. Now fdt fixups can be applied to the fdt from R5. Signed-off-by: Anshul Dalal --- arch/arm/mach-k3/common_fdt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/common_fdt.c b/arch/arm/mach-k3/common_fdt.c index 4a016711566..02a3e2c7748 100644 --- a/arch/arm/mach-k3/common_fdt.c +++ b/arch/arm/mach-k3/common_fdt.c @@ -139,7 +139,9 @@ int fdt_fixup_reserved(void *blob, const char *name, return -EINVAL; if (!strncmp(node_name, name, strlen(name))) { /* Read out old size first */ - addr = fdtdec_get_addr_size(blob, subnode, "reg", &size); + addr = fdtdec_get_addr_size_fixed( + blob, subnode, "reg", 0, 8 / sizeof(fdt32_t), + 8 / sizeof(fdt32_t), &size, false); if (addr == FDT_ADDR_T_NONE) return -EINVAL; new_size = size; -- 2.43.0
Re: [PATCH v3 07/14] cyclic: invoke uthread_schedule() from schedule()
On 04.03.25 16:24, Jerome Forissier wrote: Make the schedule() call from the CYCLIC framework a uthread scheduling point too. This makes sense since schedule() is called from a lot of places where uthread_schedule() needs to be called. Signed-off-by: Jerome Forissier Reviewed-by: Ilias Apalodimas Reviewed-by: Stefan Roese Thanks, Stefan --- common/cyclic.c | 3 +++ include/u-boot/schedule.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/common/cyclic.c b/common/cyclic.c index fad071a39c6..b695f092f52 100644 --- a/common/cyclic.c +++ b/common/cyclic.c @@ -16,6 +16,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -100,6 +101,8 @@ void schedule(void) */ if (gd) cyclic_run(); + + uthread_schedule(); } int cyclic_unregister_all(void) diff --git a/include/u-boot/schedule.h b/include/u-boot/schedule.h index 4fd34c41229..4605971fdcb 100644 --- a/include/u-boot/schedule.h +++ b/include/u-boot/schedule.h @@ -3,6 +3,8 @@ #ifndef _U_BOOT_SCHEDULE_H #define _U_BOOT_SCHEDULE_H +#include + #if CONFIG_IS_ENABLED(CYCLIC) /** * schedule() - Schedule all potentially waiting tasks @@ -17,6 +19,7 @@ void schedule(void); static inline void schedule(void) { + uthread_schedule(); } #endif Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de
[PATCH v2 0/8] Add falcon support for am62a, 62p and 62x
This patch set adds support for falcon boot on AM62a, 62p and 62x by bypassing A53 SPL and U-boot. Existing Boot flow: R5 SPL -> ATF -> A53 SPL -> U-Boot -> Linux Kernel Updated flow: R5 SPL -> ATF -> Linux Kernel U-boot's falcon flow expects the jump from SPL to kernel to happen on the same core which is not directly applicable for our heterogeneous platforms since ATF, OPTEE and other non SPL binaries from tispl.bin should be loaded before the kernel by the R5 SPL. So we have to use a non std flow to bypass A53 SPL and U-Boot, we first load the newly added tispl_falcon.bin instead of tispl.bin which lacks u-boot-spl.bin (A53's SPL) and the corresponding fdt. This sets up dm, tifs, optee and atf. Once loaded, we load the kernel and the dtb (with fixups) at ATF's PRELOADED_BL33_BASE and K3_HW_CONFIG_BASE. NOTE: Since we're now using the SPL to load the kernel and kernel expects a 2MiB aligned load address, the existing PRELOADED_BL33_BASE has to be changed for ATF to 0x8020. This patch depends on: * [PATCH v3] spl: return header size to spl_load in os boot [1] * [PATCH v2] config: falcon: move CFG_SYS_SPI_* to Kconfig [2] * [PATCH v1] spl: remove usage of CMD_(BOOTI|BOOTZ) from image parsing [3] [1]: https://lore.kernel.org/u-boot/20250311093546.3371193-1-ansh...@ti.com/ [2]: https://lore.kernel.org/u-boot/20250311044414.3155688-1-ansh...@ti.com/ [3]: https://lore.kernel.org/u-boot/20250311093709.3372104-1-ansh...@ti.com/ Signed-off-by: Anshul Dalal --- Changes in v2: * Move to CONFIG_SYS_SPI_* as per [2] * Remove the need for CMD_BOOTI as per [3] v1: https://lore.kernel.org/u-boot/20250307075541.2571104-1-ansh...@ti.com/ --- Anshul Dalal (8): spl: Kconfig: allow K3 devices to use falcon mode mach-k3: fix reading size and addr from fdt on R5 arm: dts: am62a: allow booting from eMMC arch: arm: k3-binman: add fit for falcon boot mach-k3: add eMMC FS boot support for am62[ap] mach-k3: sysfw-loader: update img_hdr for falcon config: add falcon boot config fragment for am62x mach-k3: common: add falcon support for 62[axp] arch/arm/dts/k3-am625-sk-binman.dtsi | 64 arch/arm/dts/k3-am62a-sk-binman.dtsi | 64 arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 4 + arch/arm/dts/k3-am62p-sk-binman.dtsi | 51 + arch/arm/dts/k3-binman.dtsi | 53 + arch/arm/mach-k3/am62ax/am62a7_init.c | 4 + arch/arm/mach-k3/am62px/am62p5_init.c | 4 + arch/arm/mach-k3/common.c | 105 ++ arch/arm/mach-k3/common_fdt.c | 4 +- arch/arm/mach-k3/r5/sysfw-loader.c| 6 +- common/spl/Kconfig| 3 +- configs/am62x_r5_falcon.config| 36 + 12 files changed, 395 insertions(+), 3 deletions(-) create mode 100644 configs/am62x_r5_falcon.config -- 2.43.0
[PATCH v2 1/8] spl: Kconfig: allow K3 devices to use falcon mode
Falcon mode was disabled for TI_SECURE_DEVICE at commit e95b9b4437bc ("ti_armv7_common: Disable Falcon Mode on HS devices") for older 32-bit HS devices and can be enabled on K3 devices. For secure boot, the kernel with x509 headers can be packaged in a fit container (fitImage) signed with TIFS keys for authentication. We also set the default SPL_PAYLOAD_ARGS_ADDR which holds the DTB to match ATF's K3_HW_CONFIG_BASE. Signed-off-by: Anshul Dalal --- common/spl/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 21a5cefee7a..caa6c50c176 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1148,7 +1148,7 @@ config SPL_ONENAND_SUPPORT config SPL_OS_BOOT bool "Activate Falcon Mode" - depends on !TI_SECURE_DEVICE + depends on !TI_SECURE_DEVICE || ARCH_K3 help Enable booting directly to an OS from SPL. for more info read doc/README.falcon @@ -1156,6 +1156,7 @@ config SPL_OS_BOOT config SPL_PAYLOAD_ARGS_ADDR hex "Address in memory to load 'args' file for Falcon Mode to" depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT + default 0x8200 if ARCH_K3 default 0x8800 if ARCH_OMAP2PLUS default 0x9900 if ARCH_SC5XX && SC59X_64 default 0xA000 if ARCH_SC5XX && TARGET_SC594_SOM_EZKIT -- 2.43.0
[PATCH v2 4/8] arch: arm: k3-binman: add fit for falcon boot
This adds creation of tispl_falcon.bin for the am62a, 62p and 62x. The contents are the same as the existing tispl.bin but A53's spl and the fdt have been removed as they are not needed in falcon boot. This reduces boot time since the payload size is smaller and we also aren't authenticating the spl and fdt in secure boot. Signed-off-by: Anshul Dalal --- arch/arm/dts/k3-am625-sk-binman.dtsi | 64 arch/arm/dts/k3-am62a-sk-binman.dtsi | 64 arch/arm/dts/k3-am62p-sk-binman.dtsi | 51 ++ arch/arm/dts/k3-binman.dtsi | 53 +++ 4 files changed, 232 insertions(+) diff --git a/arch/arm/dts/k3-am625-sk-binman.dtsi b/arch/arm/dts/k3-am625-sk-binman.dtsi index 534eb14795b..5ca1a4b28e8 100644 --- a/arch/arm/dts/k3-am625-sk-binman.dtsi +++ b/arch/arm/dts/k3-am625-sk-binman.dtsi @@ -219,6 +219,70 @@ }; }; + ti-falcon { + insert-template = <&ti_falcon_template>; + + fit { + images { + tifsstub-hs { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-hs"; + load = <0x9dc0>; + entry = <0x9dc0>; + blob-ext { + filename = "tifsstub.bin_hs"; + }; + }; + tifsstub-fs { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-fs"; + load = <0x9dc0>; + entry = <0x9dc0>; + blob-ext { + filename = "tifsstub.bin_fs"; + }; + }; + tifsstub-gp { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-gp"; + load = <0x9dc0>; + entry = <0x9dc0>; + blob-ext { + filename = "tifsstub.bin_gp"; + }; + }; + dm { + ti-secure { + content = <&dm_falcon>; + keyfile = "custMpk.pem"; + }; + dm_falcon: ti-dm { + filename = "ti-dm.bin"; + }; + }; + }; + + configurations { + default = "conf-0"; + conf-0 { + description = "k3-am625-sk-falcon"; + firmware = "atf"; + loadables = "tee", "tifsstub-hs", "tifsstub-fs", + "tifsstub-gp", "dm"; + }; + }; + }; + }; + ti-spl { insert-template = <&ti_spl_template>; diff --git a/arch/arm/dts/k3-am62a-sk-binman.dtsi b/arch/arm/dts/k3-am62a-sk-binman.dtsi index 2a8c260387b..4433f98801c 100644 --- a/arch/arm/dts/k3-am62a-sk-binman.dtsi +++ b/arch/arm/dts/k3-am62a-sk-binman.dtsi @@ -211,6 +211,70 @@ }; }; + ti-falcon { + insert-template = <&ti_falcon_template>; + + fit { + images { + tifsstub-hs { + description = "TIFSSTUB"; + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "tifsstub-hs"; +
[PATCH v2 8/8] mach-k3: common: add falcon support for 62[axp]
We use the spl_board_prepare_for_boot hook to call k3_falcon_prep which is ran after tispl is loaded but before jump_to_image. In here, we find the boot media and load the image just as std falcon flow (since spl_start_uboot returns 0 now). Once the kernel and args are loaded, we perform fdt fixups on the fdt accompanying the kernel (if loaded as FIT) or the loaded up args and return. Now when the flow goes to jump_to_image, we do the regular pre-jump procedure and jump to ATF which jumps to the kernel directly since we have already loaded the kernel and dtb at their respective addresses (PRELOADED_BL33_BASE and K3_HW_CONFIG_BASE). Signed-off-by: Anshul Dalal --- arch/arm/mach-k3/common.c | 105 ++ 1 file changed, 105 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index fa8cd93d664..6e41aa8318b 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -263,8 +263,113 @@ static __maybe_unused void k3_dma_remove(void) pr_warn("DMA Device not found (err=%d)\n", rc); } +#if IS_ENABLED(CONFIG_SPL_OS_BOOT) && !IS_ENABLED(CONFIG_ARM64) +static bool tispl_loaded; + +int spl_start_uboot(void) +{ + if (!tispl_loaded) + return 1; + return 0; +} + +static int k3_falcon_fdt_fixup(void *fdt) +{ + struct disk_partition info; + struct blk_desc *dev_desc; + char bootmedia[32]; + char bootpart[32]; + char str[256]; + int ret; + + strcpy(bootmedia, env_get("boot")); + strcpy(bootpart, env_get("bootpart")); + ret = blk_get_device_part_str(bootmedia, bootpart, &dev_desc, &info, 0); + if (ret < 0) + printf("Failed to get part details for %s %s [%d]\n", bootmedia, + bootpart, ret); + sprintf(str, "console=%s root=PARTUUID=%s rootwait", env_get("console"), + info.uuid); + ret = fdt_find_and_setprop(fdt, "/chosen", "bootargs", str, + strlen(str) + 1, 1); + if (ret) { + printf("Could not set bootargs: %s\n", fdt_strerror(ret)); + return ret; + } + debug("Set bootargs to: %s\n", str); + +#ifdef CONFIG_OF_BOARD_SETUP + ret = ft_board_setup(fdt, gd->bd); + if (ret) { + printf("Failed in board fdt fixups: %s\n", fdt_strerror(ret)); + return ret; + } +#endif + +#ifdef CONFIG_OF_SYSTEM_SETUP + ret = ft_system_setup(fdt, gd->bd); + if (ret) { + printf("Failed in system fdt fixups: %s\n", fdt_strerror(ret)); + return ret; + } +#endif + + return 0; +} + +static int k3_falcon_prep(void) +{ + struct spl_image_loader *loader, *drv; + struct spl_image_info kernel_image; + struct spl_boot_device bootdev; + int ret = -ENXIO, n_ents; + void *fdt; + + tispl_loaded = true; + memset(&kernel_image, '\0', sizeof(kernel_image)); + drv = ll_entry_start(struct spl_image_loader, spl_image_loader); + n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader); + bootdev.boot_device = spl_boot_device(); + if (bootdev.boot_device == BOOT_DEVICE_SPI) { + if (strcmp(env_get("mmcdev"), "1") == 0) + bootdev.boot_device = BOOT_DEVICE_MMC; + else + bootdev.boot_device = BOOT_DEVICE_EMMC; + } + bootdev.boot_device_name = NULL; + + for (loader = drv; loader != drv + n_ents; loader++) { + if (bootdev.boot_device != loader->boot_device) + continue; + if (loader) { + printf("Loading falcon payload from %s\n", + spl_loader_name(loader)); + ret = loader->load_image(&kernel_image, &bootdev); + if (ret) + continue; + + fdt = spl_image_fdt_addr(&kernel_image); + if (!fdt) + fdt = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; + ret = k3_falcon_fdt_fixup(fdt); + if (ret) { + printf("Failed performing fdt fixups in falcon flow: [%d]\n", + ret); + return ret; + } + return 0; + } + } + + return ret; +} +#endif + void spl_board_prepare_for_boot(void) { +#if IS_ENABLED(CONFIG_SPL_OS_BOOT) && !IS_ENABLED(CONFIG_ARM64) + k3_falcon_prep(); +#endif #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) dcache_disable(); #endif -- 2.43.0
[PATCH v2 6/8] mach-k3: sysfw-loader: update img_hdr for falcon
The returned legacy_img_hdr is used by booti_setup to compute the load address for the kernel image. This change ensures the kernel load address is CONFIG_SYS_LOAD_ADDR in falcon boot. Signed-off-by: Anshul Dalal --- arch/arm/mach-k3/r5/sysfw-loader.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-k3/r5/sysfw-loader.c b/arch/arm/mach-k3/r5/sysfw-loader.c index 188731e673d..19607606965 100644 --- a/arch/arm/mach-k3/r5/sysfw-loader.c +++ b/arch/arm/mach-k3/r5/sysfw-loader.c @@ -89,7 +89,11 @@ static void *sysfw_load_address; struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size) { if (sysfw_loaded) - return (struct legacy_img_hdr *)(CONFIG_TEXT_BASE + offset); + if (IS_ENABLED(CONFIG_SPL_OS_BOOT)) + return (struct legacy_img_hdr *)CONFIG_SYS_LOAD_ADDR; + else + return (struct legacy_img_hdr *)(CONFIG_TEXT_BASE + +offset); else if (sysfw_load_address) return sysfw_load_address; else -- 2.43.0
[PATCH v2 7/8] config: add falcon boot config fragment for am62x
This fragment enables falcon boot for the am62x, 62a and 62p. To have enough stack and heap space for loading kernel image as FIT, the memory map was modified as shown below, the PRELOADED_BL33_BASE in ATF has to also be updated to 0x8020 since the kernel requires to be loaded at 2MiB aligned address. Memory Map (changed addresses marked with *): 0x8000 +---+ Start of DDR 512KiB | ATF reserved memory space | CONFIG_K3_ATF_LOAD_ADDR 0x8008 +---+ 1.5MiB |Unused | 0x8020 +---+ PRELOADED_BL33_BASE* in ATF | | CONFIG_SYS_LOAD_ADDR* (load 30MiB | Kernel + initramfs Image| address for kernel) | | 0x8200 +---+ K3_HW_CONFIG_BASE in ATF | | CONFIG_SPL_PAYLOAD_ARGS_ADDR* 1MiB | Kernel DTB | | | 0x8210 +---+ CONFIG_SPL_LOAD_FIT_ADDRESS* | | 55MiB |Initial Download Region for FIT| | | 0x8580 +---+ | | | R5 U-Boot SPL Stack + Heap | 56MiB | (size defined by| | SPL_STACK_R_MALLOC_SIMPLE_LEN)| | | 0x8900 +---+ CONFIG_SPL_STACK_R_ADDR* 344MiB | Device Manager (DM) | 0x9e80 +---+ BL32_BASE in ATF 24MiB | OPTEE | 0xa000 +---+ End of DDR (512MiB) Signed-off-by: Anshul Dalal --- configs/am62x_r5_falcon.config | 36 ++ 1 file changed, 36 insertions(+) create mode 100644 configs/am62x_r5_falcon.config diff --git a/configs/am62x_r5_falcon.config b/configs/am62x_r5_falcon.config new file mode 100644 index 000..6c2f1e08f3b --- /dev/null +++ b/configs/am62x_r5_falcon.config @@ -0,0 +1,36 @@ +# Enable falcon mode +CONFIG_SPL_OS_BOOT=y + +# We use envs for setting bootargs and optionally for `falcon_(image|args)_file` +CONFIG_SPL_ENV_SUPPORT=y + +# Perform FDT fixups from SPL +CONFIG_OF_SYSTEM_SETUP=y + +# Enabling this causes issues with EMMC FS boot, +# When enabled the SPL tries to detect FS on boot[01] hw partition which fails +# since we need the raw tiboot3.bin there for the board to boot instead +CONFIG_SUPPORT_EMMC_BOOT=n + +# Used as the 2MiB aligned load address for kernel +CONFIG_SYS_LOAD_ADDR=0x8020 +CONFIG_SPL_LOAD_FIT_ADDRESS=0x8210 +CONFIG_SPL_STACK_R_ADDR=0x8900 +CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x380 +CONFIG_SYS_BOOTM_LEN=0x1e0 + +# Loading tispl_falcon instead of tispl which has fdt and A53 spl saves time +CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="tispl_falcon.bin" +CONFIG_SPL_FS_LOAD_KERNEL_NAME="Image" +# We don't use the args file when loading fitImage since it has dtb pre-packaged +# this is only useful while reading the raw kernel image from FS +CONFIG_SPL_FS_LOAD_ARGS_NAME="falcon.dtb" + +# Disabled to save space on the spl +CONFIG_SPL_YMODEM_SUPPORT=n + +# During SPI boot, kernel and args are loaded from the eMMC or SD and not SPI, +# therefore we don't actually make use of these config values. +CONFIG_SYS_SPI_KERNEL_OFFS=0 +CONFIG_SYS_SPI_ARGS_OFFS=0 +CONFIG_SYS_SPI_ARGS_SIZE=0 -- 2.43.0
[PATCH v2 5/8] mach-k3: add eMMC FS boot support for am62[ap]
This makes spl_mmc_boot_mode consistent across am62x, 62a and 62p. If MMCSD_MODE_EMMCBOOT is returned, FS boot fails since it checks for FS on the hardware partitions, not the UDA. So to allow FS boot from EMMC, the function should return MMCSD_MODE_FS instead which allows us to read from FS on the UDA. Signed-off-by: Anshul Dalal --- arch/arm/mach-k3/am62ax/am62a7_init.c | 4 arch/arm/mach-k3/am62px/am62p5_init.c | 4 2 files changed, 8 insertions(+) diff --git a/arch/arm/mach-k3/am62ax/am62a7_init.c b/arch/arm/mach-k3/am62ax/am62a7_init.c index 698e6d5c587..47280da2f83 100644 --- a/arch/arm/mach-k3/am62ax/am62a7_init.c +++ b/arch/arm/mach-k3/am62ax/am62a7_init.c @@ -207,6 +207,10 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) switch (bootmode) { case BOOT_DEVICE_EMMC: + if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT)) + return MMCSD_MODE_EMMCBOOT; + if (IS_ENABLED(CONFIG_SPL_FS_FAT) || IS_ENABLED(CONFIG_SPL_FS_EXT4)) + return MMCSD_MODE_FS; return MMCSD_MODE_EMMCBOOT; case BOOT_DEVICE_MMC: if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) diff --git a/arch/arm/mach-k3/am62px/am62p5_init.c b/arch/arm/mach-k3/am62px/am62p5_init.c index 14a46fa28d2..ec705b9d284 100644 --- a/arch/arm/mach-k3/am62px/am62p5_init.c +++ b/arch/arm/mach-k3/am62px/am62p5_init.c @@ -262,6 +262,10 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) switch (bootmode) { case BOOT_DEVICE_EMMC: + if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT)) + return MMCSD_MODE_EMMCBOOT; + if (IS_ENABLED(CONFIG_SPL_FS_FAT) || IS_ENABLED(CONFIG_SPL_FS_EXT4)) + return MMCSD_MODE_FS; return MMCSD_MODE_EMMCBOOT; case BOOT_DEVICE_MMC: if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) -- 2.43.0
[PATCH v1 2/2] arm: socfpga: spl: Notify SDM on FSBL execution
From: Alif Zakuan Yuslaimi Send out "HPS_STAGE_NOTIFY" mailbox command to the Secure Device Manager (SDM) in SPL to inform SDM on FSBL execution. This is necessary for the SDM to recognize that the FSBL stage has begun its execution and should be made as early as possible in the FSBL process. Therefore, the mailbox will initialize and send out the notification right after the completion of timer initialization. Signed-off-by: Mahesh Rao Signed-off-by: Alif Zakuan Yuslaimi --- arch/arm/mach-socfpga/spl_agilex.c | 6 -- arch/arm/mach-socfpga/spl_agilex5.c | 6 -- arch/arm/mach-socfpga/spl_n5x.c | 6 -- arch/arm/mach-socfpga/spl_s10.c | 6 -- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-socfpga/spl_agilex.c b/arch/arm/mach-socfpga/spl_agilex.c index 52617a39cca..91c27a5543d 100644 --- a/arch/arm/mach-socfpga/spl_agilex.c +++ b/arch/arm/mach-socfpga/spl_agilex.c @@ -50,6 +50,10 @@ void board_init_f(ulong dummy) timer_init(); + mbox_init(); + + mbox_hps_stage_notify(HPS_EXECUTION_STATE_FSBL); + sysmgr_pinmux_init(); ret = uclass_get_device(UCLASS_CLK, 0, &dev); @@ -77,8 +81,6 @@ void board_init_f(ulong dummy) } #endif - mbox_init(); - #ifdef CONFIG_CADENCE_QSPI mbox_qspi_open(); #endif diff --git a/arch/arm/mach-socfpga/spl_agilex5.c b/arch/arm/mach-socfpga/spl_agilex5.c index 3451611082d..a9aad5350d2 100644 --- a/arch/arm/mach-socfpga/spl_agilex5.c +++ b/arch/arm/mach-socfpga/spl_agilex5.c @@ -62,6 +62,10 @@ void board_init_f(ulong dummy) timer_init(); + mbox_init(); + + mbox_hps_stage_notify(HPS_EXECUTION_STATE_FSBL); + ret = uclass_get_device(UCLASS_CLK, 0, &dev); if (ret) { debug("Clock init failed: %d\n", ret); @@ -100,8 +104,6 @@ void board_init_f(ulong dummy) } } - mbox_init(); - if (IS_ENABLED(CONFIG_CADENCE_QSPI)) mbox_qspi_open(); diff --git a/arch/arm/mach-socfpga/spl_n5x.c b/arch/arm/mach-socfpga/spl_n5x.c index 5ff137e5c6f..81283ef7162 100644 --- a/arch/arm/mach-socfpga/spl_n5x.c +++ b/arch/arm/mach-socfpga/spl_n5x.c @@ -49,6 +49,10 @@ void board_init_f(ulong dummy) timer_init(); + mbox_init(); + + mbox_hps_stage_notify(HPS_EXECUTION_STATE_FSBL); + sysmgr_pinmux_init(); preloader_console_init(); @@ -84,8 +88,6 @@ void board_init_f(ulong dummy) } #endif - mbox_init(); - #ifdef CONFIG_CADENCE_QSPI mbox_qspi_open(); #endif diff --git a/arch/arm/mach-socfpga/spl_s10.c b/arch/arm/mach-socfpga/spl_s10.c index 53852cb7443..fa83ff96adc 100644 --- a/arch/arm/mach-socfpga/spl_s10.c +++ b/arch/arm/mach-socfpga/spl_s10.c @@ -52,6 +52,10 @@ void board_init_f(ulong dummy) socfpga_per_reset(SOCFPGA_RESET(OSC1TIMER0), 0); timer_init(); + mbox_init(); + + mbox_hps_stage_notify(HPS_EXECUTION_STATE_FSBL); + sysmgr_pinmux_init(); /* configuring the HPS clocks */ @@ -84,8 +88,6 @@ void board_init_f(ulong dummy) } #endif - mbox_init(); - #ifdef CONFIG_CADENCE_QSPI mbox_qspi_open(); #endif -- 2.25.1
[PATCH 14/19] arm64: dts: ti: k3-am62p5-sk: Enable IPC with remote processors
From: Devarsh Thakkar For each remote proc, reserve memory for IPC and bind the mailbox assignments. Two memory regions are reserved for each remote processor. The first region of 1MB of memory is used for Vring shared buffers and the second region is used as external memory to the remote processor for the resource table and for tracebuffer allocations. Signed-off-by: Devarsh Thakkar Signed-off-by: Hari Nagalla Signed-off-by: Judith Mendez Link: https://lore.kernel.org/r/20250210221530.1234009-7...@ti.com Signed-off-by: Markus Schneider-Pargmann --- dts/upstream/src/arm64/ti/k3-am62p5-sk.dts | 50 ++ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/dts/upstream/src/arm64/ti/k3-am62p5-sk.dts b/dts/upstream/src/arm64/ti/k3-am62p5-sk.dts index 7f3dc39e12bc9ca4a746ff092f946b84a36404b3..37ff0dc54ba8eea4197079b04ada032dd73119d4 100644 --- a/dts/upstream/src/arm64/ti/k3-am62p5-sk.dts +++ b/dts/upstream/src/arm64/ti/k3-am62p5-sk.dts @@ -48,6 +48,30 @@ #size-cells = <2>; ranges; + mcu_r5fss0_core0_dma_memory_region: mcu-r5fss-dma-memory-region@9b80 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9b80 0x00 0x10>; + no-map; + }; + + mcu_r5fss0_core0_memory_region: mcu-r5fss-memory-region@9b90 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9b90 0x00 0xf0>; + no-map; + }; + + wkup_r5fss0_core0_dma_memory_region: r5f-dma-memory@9c80 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9c80 0x00 0x10>; + no-map; + }; + + wkup_r5fss0_core0_memory_region: r5f-memory@9c90 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9c90 0x00 0x1e0>; + no-map; + }; + secure_tfa_ddr: tfa@9e78 { reg = <0x00 0x9e78 0x00 0x8>; no-map; @@ -57,12 +81,6 @@ reg = <0x00 0x9e80 0x00 0x0180>; /* for OP-TEE */ no-map; }; - - wkup_r5fss0_core0_memory_region: r5f-dma-memory@9c90 { - compatible = "shared-dma-pool"; - reg = <0x00 0x9c90 0x00 0x01e0>; - no-map; - }; }; vmain_pd: regulator-0 { @@ -634,6 +652,26 @@ }; }; +&wkup_r5fss0 { + status = "okay"; +}; + +&wkup_r5fss0_core0 { + mboxes = <&mailbox0_cluster0 &mbox_r5_0>; + memory-region = <&wkup_r5fss0_core0_dma_memory_region>, + <&wkup_r5fss0_core0_memory_region>; +}; + +&mcu_r5fss0 { + status = "okay"; +}; + +&mcu_r5fss0_core0 { + mboxes = <&mailbox0_cluster1 &mbox_mcu_r5_0>; + memory-region = <&mcu_r5fss0_core0_dma_memory_region>, + <&mcu_r5fss0_core0_memory_region>; +}; + &main_uart0 { pinctrl-names = "default"; pinctrl-0 = <&main_uart0_pins_default>; -- 2.47.2
[PATCH 10/19] arm64: dts: ti: k3-am62a-mcu: Add R5F remote proc node
From: Hari Nagalla AM62A SoCs have a single R5F core in the MCU voltage domain. Add the R5FSS node with the child node for core0 in MCU voltage domain .dtsi file. Signed-off-by: Hari Nagalla Signed-off-by: Judith Mendez Acked-by: Andrew Davis Link: https://lore.kernel.org/r/20250210221530.1234009-3...@ti.com Signed-off-by: Markus Schneider-Pargmann --- dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi | 25 + 1 file changed, 25 insertions(+) diff --git a/dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi b/dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi index 0469c766b769e46068f23e0073f951aa094c456f..1178cc6a9be8ce295f15f6131ae8434fa7c4d0c6 100644 --- a/dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi +++ b/dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi @@ -175,4 +175,29 @@ bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; status = "disabled"; }; + + mcu_r5fss0: r5fss@7900 { + compatible = "ti,am62-r5fss"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x7900 0x00 0x7900 0x8000>, +<0x7902 0x00 0x7902 0x8000>; + power-domains = <&k3_pds 7 TI_SCI_PD_EXCLUSIVE>; + status = "disabled"; + + mcu_r5fss0_core0: r5f@7900 { + compatible = "ti,am62-r5f"; + reg = <0x7900 0x8000>, + <0x7902 0x8000>; + reg-names = "atcm", "btcm"; + ti,sci = <&dmsc>; + ti,sci-dev-id = <9>; + ti,sci-proc-ids = <0x03 0xff>; + resets = <&k3_reset 9 1>; + firmware-name = "am62a-mcu-r5f0_0-fw"; + ti,atcm-enable = <0>; + ti,btcm-enable = <1>; + ti,loczrama = <0>; + }; + }; }; -- 2.47.2
[PATCH 18/19] configs: am62ax_evm_r5: Enable IODDR resume support
Enable K3_IODDR to enable support to resume from DDR after exiting IO+DDR. Signed-off-by: Markus Schneider-Pargmann --- configs/am62ax_evm_r5_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig index 1f7750c4c031a273321df60e3feb39a8f34b0e42..8cccd2dc2fe06ec69ff07389abda6f6fa81ff711 100644 --- a/configs/am62ax_evm_r5_defconfig +++ b/configs/am62ax_evm_r5_defconfig @@ -107,3 +107,4 @@ CONFIG_SPL_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_LIB_RATIONAL=y CONFIG_SPL_LIB_RATIONAL=y +CONFIG_K3_IODDR=y -- 2.47.2
[PATCH 16/19] arm: dts: k3-am62a: Add r5 device nodes
These are needed in SPL to be able to resume from DDR immediately after booting from IO+DDR. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 16 1 file changed, 16 insertions(+) diff --git a/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi b/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi index 7dfbeb10c323bbe1f935a50e3efc87b3276f044e..31cd27670e61ae662ba718daea5307217a143ce8 100644 --- a/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi +++ b/arch/arm/dts/k3-am62a7-sk-u-boot.dtsi @@ -14,6 +14,14 @@ memory@8000 { bootph-all; }; + + reserved-memory { + bootph-pre-ram; + }; +}; + +&wkup_r5fss0_core0_memory_region { + bootph-pre-ram; }; &cbass_main { @@ -68,6 +76,14 @@ bootph-all; }; +&wkup_r5fss0 { + bootph-pre-ram; +}; + +&wkup_r5fss0_core0 { + bootph-pre-ram; +}; + &cbass_wakeup { bootph-all; }; -- 2.47.2
[PATCH 03/19] ram: k3-ddrss: Add support for DDR in self-refresh
In IO+DDR the DDR is kept in self-refresh while the SoC cores are powered off completely. During boot the normal initialization routine of DDR is slightly different to exit self-refresh and keep the DDR contents. Signed-off-by: Markus Schneider-Pargmann --- drivers/ram/k3-ddrss/k3-ddrss.c | 165 1 file changed, 165 insertions(+) diff --git a/drivers/ram/k3-ddrss/k3-ddrss.c b/drivers/ram/k3-ddrss/k3-ddrss.c index ff87faf6a22419e54d3639817ad2b884a97a3911..d7ae6e9ef24d5aebdb61656e6ca797b1799ca0f6 100644 --- a/drivers/ram/k3-ddrss/k3-ddrss.c +++ b/drivers/ram/k3-ddrss/k3-ddrss.c @@ -57,6 +57,16 @@ #define DDRSS_V2A_INT_SET_REG_ECC2BERR_EN BIT(4) #define DDRSS_V2A_INT_SET_REG_ECCM1BERR_EN BIT(5) +#define K3_WKUP_CTRL_MMR0_DDR16SS_PMCTRL 0x430080d0 +#define K3_WKUP_CTRL_MMR0_DDR16SS_PMCTRL_DATA_RET_LD BIT(31) +#define K3_WKUP_CTRL_MMR0_DDR16SS_PMCTRL_DATA_RETENTION_MASK GENMASK(3, 0) + +#define K3_WKUP_CTRL_MMR_CANUART_WAKE_STAT10x430c +#define K3_WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODEBIT(0) + +#define K3_WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT0x4318 +#define K3_WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT_MW 0x55 + #define SINGLE_DDR_SUBSYSTEM 0x1 #define MULTI_DDR_SUBSYSTEM0x2 @@ -189,6 +199,32 @@ struct reginitdata { #define DENALI_CTL_0_DRAM_CLASS_DDR4 0xA #define DENALI_CTL_0_DRAM_CLASS_LPDDR4 0xB +#define K3_DDRSS_CFG_DENALI_CTL_20 0x0050 +#define K3_DDRSS_CFG_DENALI_CTL_20_PHY_INDEP_TRAIN_MODEBIT(24) +#define K3_DDRSS_CFG_DENALI_CTL_21 0x0054 +#define K3_DDRSS_CFG_DENALI_CTL_21_PHY_INDEP_INIT_MODE BIT(8) +#define K3_DDRSS_CFG_DENALI_CTL_1060x01a8 +#define K3_DDRSS_CFG_DENALI_CTL_106_PWRUP_SREFRESH_EXITBIT(16) +#define K3_DDRSS_CFG_DENALI_CTL_1600x0280 +#define K3_DDRSS_CFG_DENALI_CTL_160_LP_CMD_MASK GENMASK(14, 8) +#define K3_DDRSS_CFG_DENALI_CTL_160_LP_CMD_ENTRY BIT(9) +#define K3_DDRSS_CFG_DENALI_CTL_1690x02a4 +#define K3_DDRSS_CFG_DENALI_CTL_169_LP_AUTO_EXIT_EN_MASK GENMASK(27, 24) +#define K3_DDRSS_CFG_DENALI_CTL_169_LP_AUTO_ENTRY_EN_MASK GENMASK(19, 16) +#define K3_DDRSS_CFG_DENALI_CTL_169_LP_STATE_MASK GENMASK(14, 8) +#define K3_DDRSS_CFG_DENALI_CTL_169_LP_STATE_SHIFT 8 +#define K3_DDRSS_CFG_DENALI_CTL_3450x0564 +#define K3_DDRSS_CFG_DENALI_CTL_345_INT_STATUS_LOWPOWER_SHIFT 16 +#define K3_DDRSS_CFG_DENALI_CTL_3530x0584 +#define K3_DDRSS_CFG_DENALI_CTL_353_INT_ACK_LOWPOWER_SHIFT 16 +#define K3_DDRSS_CFG_DENALI_PI_6 0x2018 +#define K3_DDRSS_CFG_DENALI_PI_6_PI_DFI_PHYMSTR_STATE_SEL_RBIT(8) +#define K3_DDRSS_CFG_DENALI_PI_146 0x2248 +#define K3_DDRSS_CFG_DENALI_PI_150 0x2258 +#define K3_DDRSS_CFG_DENALI_PI_150_PI_DRAM_INIT_EN BIT(8) +#define K3_DDRSS_CFG_DENALI_PHY_1820 0x5C70 +#define K3_DDRSS_CFG_DENALI_PHY_1820_SET_DFI_INPUT_2_SHIFT 16 + #define TH_OFFSET_FROM_REG(REG, SHIFT, offset) do {\ char *i, *pstr = xstr(REG); offset = 0;\ for (i = &pstr[SHIFT]; *i != '\0'; ++i) {\ @@ -775,10 +811,125 @@ static void k3_ddrss_lpddr4_ecc_init(struct k3_ddrss_desc *ddrss) writel(val, base + DDRSS_ECC_CTRL_REG); } +static void k3_ddrss_reg_update_bits(void __iomem *addr, u32 offset, u32 mask, u32 set) +{ + u32 val = readl(addr + offset); + + val &= ~mask; + val |= set; + writel(val, addr + offset); +} + +static void k3_ddrss_self_refresh_exit(struct k3_ddrss_desc *ddrss) +{ + k3_ddrss_reg_update_bits(ddrss->ddrss_ctl_cfg, +K3_DDRSS_CFG_DENALI_CTL_169, + K3_DDRSS_CFG_DENALI_CTL_169_LP_AUTO_EXIT_EN_MASK | + K3_DDRSS_CFG_DENALI_CTL_169_LP_AUTO_ENTRY_EN_MASK, +0x0); + k3_ddrss_reg_update_bits(ddrss->ddrss_ctl_cfg, +K3_DDRSS_CFG_DENALI_PHY_1820, +0, +BIT(2) << K3_DDRSS_CFG_DENALI_PHY_1820_SET_DFI_INPUT_2_SHIFT); + k3_ddrss_reg_update_bits(ddrss->ddrss_ctl_cfg, +K3_DDRSS_CFG_DENALI_CTL_106, +0, + K3_DDRSS_CFG_DENALI_CTL_106_PWRUP_SREFRESH_EXIT); + writel(0, ddrss->ddrss_ctl_cfg + K3_DDRSS_CFG_DENALI_PI_146); + k3_ddrss_reg_update_bits(ddrss->ddrss_ctl_cfg, +K3_DDRSS_CFG_DENALI_PI_150, +K3_DDRSS_CFG_DENALI_PI_150_PI_DRAM_INIT_EN, +
[PATCH 17/19] arm: dts: k3-am62p: Add r5 device nodes
These are needed in SPL to be able to resume from DDR immediately after booting from IO+DDR. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/dts/k3-am62p5-sk-u-boot.dtsi | 20 1 file changed, 20 insertions(+) diff --git a/arch/arm/dts/k3-am62p5-sk-u-boot.dtsi b/arch/arm/dts/k3-am62p5-sk-u-boot.dtsi index cf087c6e343a8af6f4bb2093bb6c3f28395a2686..8c2b198dede03fd77f16786f8743313a34902e46 100644 --- a/arch/arm/dts/k3-am62p5-sk-u-boot.dtsi +++ b/arch/arm/dts/k3-am62p5-sk-u-boot.dtsi @@ -11,8 +11,28 @@ stdout-path = "serial2:115200n8"; tick-timer = &main_timer0; }; + + reserved-memory { + bootph-pre-ram; + }; +}; + +&wkup_r5fss0_core0_memory_region { + bootph-pre-ram; +}; + +&cbass_wakeup { + bootph-pre-ram; }; &dmsc { bootph-pre-ram; }; + +&wkup_r5fss0 { + bootph-pre-ram; +}; + +&wkup_r5fss0_core0 { + bootph-pre-ram; +}; -- 2.47.2
[PATCH 19/19] configs: am62p_evm_r5_defconfig: Enable IODDR resume support
Enable K3_IODDR to enable support to resume from DDR after exiting IO+DDR. Signed-off-by: Markus Schneider-Pargmann --- configs/am62px_evm_r5_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/am62px_evm_r5_defconfig b/configs/am62px_evm_r5_defconfig index c3adfb8697a73198298e8e9d955d1f1829cabfd6..be580100d9f4d098f642db3b35b979ea10f96096 100644 --- a/configs/am62px_evm_r5_defconfig +++ b/configs/am62px_evm_r5_defconfig @@ -124,3 +124,4 @@ CONFIG_SPL_TIMER=y CONFIG_OMAP_TIMER=y CONFIG_LIB_RATIONAL=y CONFIG_SPL_LIB_RATIONAL=y +CONFIG_K3_IODDR=y -- 2.47.2
[PATCH 01/19] arm: mach-k3: Remove CANUART IO isolation
After leaving the Partial-IO mode or other deep sleep states, the IO isolation needs to be removed. This routine is shared by at least am62, am62a and am62p. The original function for testing was developed by Akashdeep Kaur Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/am62ax/am62a7_init.c| 2 ++ arch/arm/mach-k3/am62px/am62p5_init.c| 2 ++ arch/arm/mach-k3/am62x/am625_init.c | 2 ++ arch/arm/mach-k3/common.c| 56 arch/arm/mach-k3/common.h| 1 + arch/arm/mach-k3/include/mach/hardware.h | 29 + 6 files changed, 92 insertions(+) diff --git a/arch/arm/mach-k3/am62ax/am62a7_init.c b/arch/arm/mach-k3/am62ax/am62a7_init.c index 78153c97a58aff99dba8a76d915802be37d58745..7697e365c6ea1b9a4819fe813a63d4ee8fc9de8f 100644 --- a/arch/arm/mach-k3/am62ax/am62a7_init.c +++ b/arch/arm/mach-k3/am62ax/am62a7_init.c @@ -90,6 +90,8 @@ void board_init_f(ulong dummy) /* Init DM early */ spl_early_init(); + wkup_ctrl_remove_can_io_isolation_if_set(); + /* * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and * MAIN_UART1 modules and continue regardless of the result of pinctrl. diff --git a/arch/arm/mach-k3/am62px/am62p5_init.c b/arch/arm/mach-k3/am62px/am62p5_init.c index 7a24cf39c7b87ed9e2c7debbfc6889c29af2f1ef..a61dcaeb00f799a1f9c42f48d63c42815c4dcae3 100644 --- a/arch/arm/mach-k3/am62px/am62p5_init.c +++ b/arch/arm/mach-k3/am62px/am62p5_init.c @@ -148,6 +148,8 @@ void board_init_f(ulong dummy) if (ret) panic("spl_early_init() failed: %d\n", ret); + wkup_ctrl_remove_can_io_isolation_if_set(); + /* * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and * MAIN_UART1 modules and continue regardless of the result of pinctrl. diff --git a/arch/arm/mach-k3/am62x/am625_init.c b/arch/arm/mach-k3/am62x/am625_init.c index 595fc391ac5aac4b5591cead15f21abf044165cf..87ec23e7869a43fe947a7fa646a950da6cff5d13 100644 --- a/arch/arm/mach-k3/am62x/am625_init.c +++ b/arch/arm/mach-k3/am62x/am625_init.c @@ -194,6 +194,8 @@ void board_init_f(ulong dummy) /* Init DM early */ spl_early_init(); + wkup_ctrl_remove_can_io_isolation_if_set(); + /* * Process pinctrl for the serial0 and serial3, aka WKUP_UART0 and * MAIN_UART1 modules and continue regardless of the result of pinctrl. diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index fa8cd93d664858560227f82d474d0a4d559338a8..ef40d623058072e89e9b3e53fc0f7ea6b78f96e3 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -30,6 +30,9 @@ #include #include #include +#include + +#define CLKSTOP_TRANSITION_TIMEOUT_MS 10 #include @@ -78,6 +81,59 @@ void mmr_unlock(uintptr_t base, u32 partition) writel(CTRLMMR_LOCK_KICK1_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK1); } +static void wkup_ctrl_remove_can_io_isolation(void) +{ + const void *wait_reg = (const void *)(WKUP_CTRL_MMR0_BASE + + WKUP_CTRL_MMR_CANUART_WAKE_STAT1); + int ret; + u32 reg = 0; + + /* Program magic word */ + reg = readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL); + reg |= WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW << WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW_SHIFT; + writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL); + + /* Set enable bit. */ + reg |= WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW_LOAD_EN; + writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL); + + /* Clear enable bit. */ + reg &= ~WKUP_CTRL_MMR_CANUART_WAKE_CTRL_MW_LOAD_EN; + writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL); + + /* wait for CAN_ONLY_IO signal to be 0 */ + ret = wait_for_bit_32(wait_reg, + WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE, + false, + CLKSTOP_TRANSITION_TIMEOUT_MS, + false); + if (ret < 0) + return; + + /* Reset magic word */ + writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_CTRL); + + /* Remove WKUP IO isolation */ + reg = readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0); + reg = reg & WKUP_CTRL_MMR_PMCTRL_IO_0_WRITE_MASK & ~WKUP_CTRL_MMR_PMCTRL_IO_0_GLOBAL_WUEN_0; + writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0); + + /* clear global IO isolation */ + reg = readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0); + reg = reg & WKUP_CTRL_MMR_PMCTRL_IO_0_WRITE_MASK & ~WKUP_CTRL_MMR_PMCTRL_IO_0_IO_ISO_CTRL_0; + writel(reg, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_0); + + writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_DEEPSLEEP_CTRL); + writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR
[PATCH 00/19] am62: IO+DDR resume support
Hi, this series introduces support to resume from IO+DDR. IO+DDR is a low power mode of am62a and am62p in which nearly everything is powered off except DDR which is in self-refresh and a few pins which detect activity and can wakeup the system again. On resume uboot SPL is loaded and checks if this is a IO+DDR resume. If it is, the DDR initialization sequence in k3-ddrss differs slightly as it has to get the DDR out of the self-refresh. Afterwards a specific address determined from DT is used to get the metadata that stores relevant context addresses. The context is restored using the tisci message TI_SCI_MSG_MIN_CONTEXT_RESTORE. At the end all further initializations are skipped and uboot SPL directly jumps into the DM resume address which takes care of the rest. The devicetree R5F related patches were picked up from the mailinglist and are required to find the correct address of the metadata. k3-ddrss is using absolute register accesses at the moment. I am trying to submit syscon DT patches upstream to access these through syscon, unfortunately there is ongoing discussion regarding syscon. I tested this on am62a. Best, Markus To: Tom Rini To: Vignesh Raghavendra To: Bryan Brattlof To: Sumit Garg Cc: u-boot@lists.denx.de Cc: Vishal Mahaveer Cc: Kevin Hilman Cc: Dhruva Gole Cc: Sebin Francis Cc: Kendall Willis Cc: Akashdeep Kaur Signed-off-by: Markus Schneider-Pargmann --- Devarsh Thakkar (3): arm64: dts: ti: k3-am62a-wakeup: Add R5F device node arm64: dts: ti: k3-am62a7-sk: Enable IPC with remote processors arm64: dts: ti: k3-am62p5-sk: Enable IPC with remote processors Hari Nagalla (2): arm64: dts: ti: k3-am62a-mcu: Add R5F remote proc node arm64: dts: ti: k3-am62x-sk-common: Enable IPC with remote processors Jai Luthra (1): arm64: dts: ti: k3-am62a-main: Add C7xv device node Markus Schneider-Pargmann (13): arm: mach-k3: Remove CANUART IO isolation arm: mach-k3: Kconfig: Add symbols for IO+DDR Low Power Mode ram: k3-ddrss: Add support for DDR in self-refresh firmware: ti_sci: Add TI_SCI_MSG_MIN_CONTEXT_RESTORE arm: mach-k3: common: Add CANUART wakeup check helpers arm: mach-k3: common: Add lpm_resume_from_ddr arm: mach-k3: common: Helper for LPM meta data address from DT arm: mach-k3: am62a7_init: Resume on LPM exit arm: mach-k3: am62p5_init: Resume on LPM exit arm: dts: k3-am62a: Add r5 device nodes arm: dts: k3-am62p: Add r5 device nodes configs: am62ax_evm_r5: Enable IODDR resume support configs: am62p_evm_r5_defconfig: Enable IODDR resume support arch/arm/dts/k3-am62a7-sk-u-boot.dtsi | 16 +++ arch/arm/dts/k3-am62p5-sk-u-boot.dtsi | 20 +++ arch/arm/mach-k3/Kconfig | 9 ++ arch/arm/mach-k3/am62ax/am62a7_init.c | 11 ++ arch/arm/mach-k3/am62px/am62p5_init.c | 12 ++ arch/arm/mach-k3/am62x/am625_init.c | 2 + arch/arm/mach-k3/common.c | 162 + arch/arm/mach-k3/common.h | 4 + arch/arm/mach-k3/include/mach/hardware.h | 32 + configs/am62ax_evm_r5_defconfig | 1 + configs/am62px_evm_r5_defconfig | 1 + drivers/firmware/ti_sci.c | 38 + drivers/firmware/ti_sci.h | 14 ++ drivers/ram/k3-ddrss/k3-ddrss.c | 165 ++ dts/upstream/src/arm64/ti/k3-am62a-main.dtsi | 12 ++ dts/upstream/src/arm64/ti/k3-am62a-mcu.dtsi | 25 dts/upstream/src/arm64/ti/k3-am62a-wakeup.dtsi| 25 dts/upstream/src/arm64/ti/k3-am62a7-sk.dts| 96 - dts/upstream/src/arm64/ti/k3-am62p5-sk.dts| 50 ++- dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi | 35 - include/linux/soc/ti/ti_sci_protocol.h| 9 ++ 21 files changed, 721 insertions(+), 18 deletions(-) --- base-commit: a517796cfa5d8f4ca2f0c11c78c24a08a102c047 change-id: 20250306-topic-am62-ioddr-v2025-04-rc1-0b3a0ffe92b1 Best regards, -- Markus Schneider-Pargmann
[PATCH 15/19] arm64: dts: ti: k3-am62x-sk-common: Enable IPC with remote processors
From: Hari Nagalla For each remote proc, reserve memory for IPC and bind the mailbox assignments. Two memory regions are reserved for each remote processor. The first region of 1MB of memory is used for Vring shared buffers and the second region is used as external memory to the remote processor for the resource table and for tracebuffer allocations. Signed-off-by: Devarsh Thakkar Signed-off-by: Hari Nagalla Signed-off-by: Judith Mendez Link: https://lore.kernel.org/r/20250210221530.1234009-8...@ti.com Signed-off-by: Markus Schneider-Pargmann --- dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi | 35 +++ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi b/dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi index 6957b3e44c82f169e77aee94d19c709ccc1ff610..816d9fca27a8e288c4eb45d781a5cad86765574d 100644 --- a/dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi +++ b/dts/upstream/src/arm64/ti/k3-am62x-sk-common.dtsi @@ -68,6 +68,18 @@ no-map; }; + wkup_r5fss0_core0_dma_memory_region: r5f-dma-memory@9da0 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9da0 0x00 0x10>; + no-map; + }; + + wkup_r5fss0_core0_memory_region: r5f-memory@9db0 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9db0 0x00 0xc0>; + no-map; + }; + secure_tfa_ddr: tfa@9e78 { reg = <0x00 0x9e78 0x00 0x8>; alignment = <0x1000>; @@ -79,12 +91,6 @@ alignment = <0x1000>; no-map; }; - - wkup_r5fss0_core0_dma_memory_region: r5f-dma-memory@9db0 { - compatible = "shared-dma-pool"; - reg = <0x00 0x9db0 0x00 0xc0>; - no-map; - }; }; leds { @@ -470,10 +476,17 @@ }; &mailbox0_cluster0 { + status = "okay"; + mbox_m4_0: mbox-m4-0 { ti,mbox-rx = <0 0 0>; ti,mbox-tx = <1 0 0>; }; + + mbox_r5_0: mbox-r5-0 { + ti,mbox-rx = <2 0 0>; + ti,mbox-tx = <3 0 0>; + }; }; &mcu_m4fss { @@ -483,6 +496,16 @@ status = "okay"; }; +&wkup_r5fss0 { + status = "okay"; +}; + +&wkup_r5fss0_core0 { + mboxes = <&mailbox0_cluster0 &mbox_r5_0>; + memory-region = <&wkup_r5fss0_core0_dma_memory_region>, + <&wkup_r5fss0_core0_memory_region>; +}; + &usbss0 { bootph-all; status = "okay"; -- 2.47.2
[PATCH 05/19] arm: mach-k3: common: Add CANUART wakeup check helpers
Add dedicated helper functions to check CANUART wake registers and magic word. This helps determining if we are in a wakeup or if CAN IO isolation has to be removed. Also add a helper to detect a low power mode exit/resume. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/common.c| 22 -- arch/arm/mach-k3/common.h| 1 + arch/arm/mach-k3/include/mach/hardware.h | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index ef40d623058072e89e9b3e53fc0f7ea6b78f96e3..e3554ee6aa8957b8cfcacb452ba391d7b3abf2a9 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -127,13 +127,31 @@ static void wkup_ctrl_remove_can_io_isolation(void) writel(0, WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_PMCTRL_IO_GLB); } +static bool wkup_ctrl_canuart_wakeup_active(void) +{ + return !!(readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_STAT1) & + WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE); +} + +static bool wkup_ctrl_canuart_magic_word_set(void) +{ + return readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT) == + WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT_MW; +} + void wkup_ctrl_remove_can_io_isolation_if_set(void) { - if (readl(WKUP_CTRL_MMR0_BASE + WKUP_CTRL_MMR_CANUART_WAKE_STAT1) & - WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE) + if (wkup_ctrl_canuart_wakeup_active() && !wkup_ctrl_canuart_magic_word_set()) wkup_ctrl_remove_can_io_isolation(); } +bool wkup_ctrl_is_lpm_exit(void) +{ + return IS_ENABLED(CONFIG_K3_IODDR) && + wkup_ctrl_canuart_wakeup_active() && + wkup_ctrl_canuart_magic_word_set(); +} + bool is_rom_loaded_sysfw(struct rom_extended_boot_data *data) { if (strncmp(data->header, K3_ROM_BOOT_HEADER_MAGIC, 7)) diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index 0359fea5675bdaf8cdde7989eebac1a695a065ba..5d347c7252d18c06dac21813b8247fa2c57902bc 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -46,6 +46,7 @@ struct ti_sci_handle *get_ti_sci_handle(void); void do_board_detect(void); void ti_secure_image_check_binary(void **p_image, size_t *p_size); void wkup_ctrl_remove_can_io_isolation_if_set(void); +bool wkup_ctrl_is_lpm_exit(void); #if (IS_ENABLED(CONFIG_K3_QOS)) void setup_qos(void); diff --git a/arch/arm/mach-k3/include/mach/hardware.h b/arch/arm/mach-k3/include/mach/hardware.h index bd7407a4b9498207d94a35d8f73b852c7528a086..949badb18dc453421ce0f0d403554ac604cf4534 100644 --- a/arch/arm/mach-k3/include/mach/hardware.h +++ b/arch/arm/mach-k3/include/mach/hardware.h @@ -118,6 +118,9 @@ K3_SOC_ID(j722s, J722S) #define WKUP_CTRL_MMR_CANUART_WAKE_STAT1 0x1830c #define WKUP_CTRL_MMR_CANUART_WAKE_STAT1_CANUART_IO_MODE BIT(0) +#define WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT 0x18318 +#define WKUP_CTRL_MMR_CANUART_WAKE_OFF_MODE_STAT_MW0x55 + #define WKUP_CTRL_MMR_PMCTRL_IO_0 0x18084 #define WKUP_CTRL_MMR_PMCTRL_IO_0_ISOCLK_OVRD_0BIT(0) #define WKUP_CTRL_MMR_PMCTRL_IO_0_ISOOVR_EXTEND_0 BIT(4) -- 2.47.2
[PATCH 09/19] arm: mach-k3: am62p5_init: Resume on LPM exit
When exiting a low power mode with DDR self-refresh, we can directly resume after DDR setup is done. Call the common function to resume. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/am62px/am62p5_init.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/mach-k3/am62px/am62p5_init.c b/arch/arm/mach-k3/am62px/am62p5_init.c index a61dcaeb00f799a1f9c42f48d63c42815c4dcae3..af63cbe3191526add83652af4003974cbaeff0e5 100644 --- a/arch/arm/mach-k3/am62px/am62p5_init.c +++ b/arch/arm/mach-k3/am62px/am62p5_init.c @@ -223,6 +223,16 @@ void board_init_f(ulong dummy) spl_enable_cache(); setup_qos(); + + if (wkup_ctrl_is_lpm_exit()) { + u64 meta_data_addr; + + ret = wkup_r5f_am62_lpm_meta_data_addr(&meta_data_addr); + if (ret) + panic("Failed to get LPM meta data address %d\n", ret); + lpm_resume_from_ddr(meta_data_addr); + } + debug("am62px_init: %s done\n", __func__); fixup_a53_cpu_freq_by_speed_grade(); -- 2.47.2
[PATCH v1 1/2] arm: socfpga: mailbox: Notify SDM on HPS code execution stages
From: Alif Zakuan Yuslaimi Introducing a new mailbox command "HPS_STAGE_NOTIFY" to notify Secure Device Manager (SDM) on the stage of HPS code execution. Generally, there are three main code execution stages: First Stage Boot Loader (FSBL) which is U-Boot SPL, Second Stage Boot Loader (SSBL) which is U-Boot, and the Operating System (OS) which is Linux. This enables the user to query the SDM for HPS error details. Signed-off-by: Alif Zakuan Yuslaimi --- arch/arm/mach-socfpga/include/mach/mailbox_s10.h | 4 arch/arm/mach-socfpga/mailbox_s10.c | 12 2 files changed, 16 insertions(+) diff --git a/arch/arm/mach-socfpga/include/mach/mailbox_s10.h b/arch/arm/mach-socfpga/include/mach/mailbox_s10.h index 45cc9912f94..2099c51b682 100644 --- a/arch/arm/mach-socfpga/include/mach/mailbox_s10.h +++ b/arch/arm/mach-socfpga/include/mach/mailbox_s10.h @@ -128,6 +128,7 @@ enum ALT_SDM_MBOX_RESP_CODE { #define MBOX_QSPI_CLOSE51 #define MBOX_QSPI_DIRECT 59 #define MBOX_REBOOT_HPS71 +#define MBOX_HPS_STAGE_NOTIFY 93 /* Mailbox registers */ #define MBOX_CIN 0 /* command valid offset */ @@ -385,6 +386,8 @@ enum MBOX_CFGSTAT_MINOR_ERR_CODE { #define RCF_SOFTFUNC_STATUS_SEU_ERROR BIT(3) #define RCF_PIN_STATUS_NSTATUS BIT(31) +#define HPS_EXECUTION_STATE_FSBL 0 + int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg, u8 urgent, u32 *resp_buf_len, u32 *resp_buf); int mbox_send_cmd_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg, @@ -401,6 +404,7 @@ int mbox_qspi_open(void); #endif int mbox_reset_cold(void); +int mbox_hps_stage_notify(u32 execution_stage); int mbox_get_fpga_config_status(u32 cmd); int mbox_get_fpga_config_status_psci(u32 cmd); #endif /* _MAILBOX_S10_H_ */ diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c index b69bd3e47ec..f9c34e85711 100644 --- a/arch/arm/mach-socfpga/mailbox_s10.c +++ b/arch/arm/mach-socfpga/mailbox_s10.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -474,6 +475,17 @@ int __secure mbox_send_cmd_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, urgent, resp_buf_len, resp_buf); } +int mbox_hps_stage_notify(u32 execution_stage) +{ +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ATF) + return smc_send_mailbox(MBOX_HPS_STAGE_NOTIFY, 1, &execution_stage, + 0, 0, NULL); +#else + return mbox_send_cmd(MBOX_ID_UBOOT, MBOX_HPS_STAGE_NOTIFY, +MBOX_CMD_DIRECT, 1, &execution_stage, 0, 0, NULL); +#endif +} + int mbox_send_cmd_only(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg) { return mbox_send_cmd_only_common(id, cmd, is_indirect, len, arg); -- 2.25.1
[PATCH v1 0/2] Add HPS Notification for HPS boot stages
From: Alif Zakuan Yuslaimi Introduce a new mailbox command to notify the Secure Device Manager (SDM) on the stage of HPS code execution. Generally, there are three main code execution stages: First Stage Boot Loader (FSBL) which is U-Boot SPL, Second Stage Boot Loader (SSBL) which is U-Boot, and the Operating System (OS) which is Linux. This enables the user to query the SDM for HPS error details. Alif Zakuan Yuslaimi (2): arm: socfpga: mailbox: Notify SDM on HPS code execution stages arm: socfpga: spl: Notify SDM on FSBL execution arch/arm/mach-socfpga/include/mach/mailbox_s10.h | 4 arch/arm/mach-socfpga/mailbox_s10.c | 12 arch/arm/mach-socfpga/spl_agilex.c | 6 -- arch/arm/mach-socfpga/spl_agilex5.c | 6 -- arch/arm/mach-socfpga/spl_n5x.c | 6 -- arch/arm/mach-socfpga/spl_s10.c | 6 -- 6 files changed, 32 insertions(+), 8 deletions(-) -- 2.25.1
RE: [PATCH] drivers: ddr: altera: Fix integer overflow during size calculation
> -Original Message- > From: Ravulapalli, Naresh Kumar > Sent: Friday, March 7, 2025 6:29 PM > To: u-boot@lists.denx.de > Cc: Marek Vasut ; Simon Goldschmidt > ; Chee, Tien Fong > ; Meng, Tingting ; > Tom Rini ; Ravulapalli, Naresh Kumar > > Subject: [PATCH] drivers: ddr: altera: Fix integer overflow during size > calculation > > Data structure, dramaddrw, is defined as u32. Compiler performs 32-bit > arithmetic and logic operations on this data structure. Fix is provided to > avoid > integer overflow while performing shifting operations greater than 32-bit. > > Signed-off-by: Naresh Kumar Ravulapalli > > --- > drivers/ddr/altera/sdram_soc64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/ddr/altera/sdram_soc64.c > b/drivers/ddr/altera/sdram_soc64.c > index c8c9211adc..75c6de1e4e 100644 > --- a/drivers/ddr/altera/sdram_soc64.c > +++ b/drivers/ddr/altera/sdram_soc64.c > @@ -249,7 +249,7 @@ phys_size_t sdram_calculate_size(struct > altera_sdram_plat *plat) > > DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) + > > DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw)); > > - size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) & > + size *= ((phys_size_t)2 << (hmc_ecc_readl(plat, DDRIOCTRL) & > DDR_HMC_DDRIOCTRL_IOSIZE_MSK)); > > return size; > -- > 2.35.3 Reviewed-by: Tien Fong Chee Best regards, Tien Fong
RE: [PATCH 1/2] arch: arm: dts: Enable kernel itb file generation for Agilex5 SoCFPGA
> -Original Message- > From: Ravulapalli, Naresh Kumar > Sent: Tuesday, March 4, 2025 1:07 PM > To: u-boot@lists.denx.de > Cc: Marek Vasut ; Simon Goldschmidt > ; Chee, Tien Fong > ; Meng, Tingting ; > Tom Rini ; Ng, Boon Khai ; > Jit Loon Lim ; Alif Zakuan Yuslaimi > ; Ravulapalli, Naresh Kumar > > Subject: [PATCH 1/2] arch: arm: dts: Enable kernel itb file generation for > Agilex5 SoCFPGA > > Load and entry addresses are corrected for Agilex5 SoCFPGA board which > would enable to generate the kernel itb file with the right addresses. > > Signed-off-by: Naresh Kumar Ravulapalli > > --- > arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi | 5 + > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi > b/arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi > index 15306db600..93a8e0697d 100644 > --- a/arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi > +++ b/arch/arm/dts/socfpga_soc64_fit-u-boot.dtsi > @@ -106,8 +106,13 @@ > arch = "arm64"; > os = "linux"; > compression = "none"; > + #if > IS_ENABLED(CONFIG_TARGET_SOCFPGA_AGILEX5) > + load = <0x8600>; > + entry = <0x8600>; > + #else > load = <0x600>; > entry = <0x600>; > + #endif > kernel_blob: blob-ext { > filename = "Image"; > }; > -- > 2.35.3 Reviewed-by: Tien Fong Chee Best regards, Tien Fong
[PATCH 13/19] arm64: dts: ti: k3-am62a7-sk: Enable IPC with remote processors
From: Devarsh Thakkar For each remote proc, reserve memory for IPC and bind the mailbox assignments. Two memory regions are reserved for each remote processor. The first region of 1MB of memory is used for Vring shared buffers and the second region is used as external memory to the remote processor for the resource table and for tracebuffer allocations. Signed-off-by: Devarsh Thakkar Signed-off-by: Hari Nagalla Signed-off-by: Judith Mendez Acked-by: Andrew Davis Link: https://lore.kernel.org/r/20250210221530.1234009-6...@ti.com Signed-off-by: Markus Schneider-Pargmann --- dts/upstream/src/arm64/ti/k3-am62a7-sk.dts | 96 -- 1 file changed, 90 insertions(+), 6 deletions(-) diff --git a/dts/upstream/src/arm64/ti/k3-am62a7-sk.dts b/dts/upstream/src/arm64/ti/k3-am62a7-sk.dts index a6f0d87a50d8a7ebdb61e609e8071d6681dbec9a..ac67c51caa2111db1283060af7ccc7b7780bf204 100644 --- a/dts/upstream/src/arm64/ti/k3-am62a7-sk.dts +++ b/dts/upstream/src/arm64/ti/k3-am62a7-sk.dts @@ -49,6 +49,42 @@ linux,cma-default; }; + c7x_0_dma_memory_region: c7x-dma-memory@9980 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9980 0x00 0x10>; + no-map; + }; + + c7x_0_memory_region: c7x-memory@9990 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9990 0x00 0xf0>; + no-map; + }; + + mcu_r5fss0_core0_dma_memory_region: r5f-dma-memory@9b80 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9b80 0x00 0x10>; + no-map; + }; + + mcu_r5fss0_core0_memory_region: r5f-dma-memory@9b90 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9b90 0x00 0xf0>; + no-map; + }; + + wkup_r5fss0_core0_dma_memory_region: r5f-dma-memory@9c80 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9c80 0x00 0x10>; + no-map; + }; + + wkup_r5fss0_core0_memory_region: r5f-dma-memory@9c90 { + compatible = "shared-dma-pool"; + reg = <0x00 0x9c90 0x00 0x1e0>; + no-map; + }; + secure_tfa_ddr: tfa@9e78 { reg = <0x00 0x9e78 0x00 0x8>; alignment = <0x1000>; @@ -60,12 +96,6 @@ alignment = <0x1000>; no-map; }; - - wkup_r5fss0_core0_memory_region: r5f-dma-memory@9c90 { - compatible = "shared-dma-pool"; - reg = <0x00 0x9c90 0x00 0x01e0>; - no-map; - }; }; opp-table { @@ -737,3 +767,57 @@ }; }; }; + +&mailbox0_cluster0 { + status = "okay"; + + mbox_r5_0: mbox-r5-0 { + ti,mbox-rx = <0 0 0>; + ti,mbox-tx = <1 0 0>; + }; +}; + +&mailbox0_cluster1 { + status = "okay"; + + mbox_c7x_0: mbox-c7x-0 { + ti,mbox-rx = <0 0 0>; + ti,mbox-tx = <1 0 0>; + }; +}; + +&mailbox0_cluster2 { + status = "okay"; + + mbox_mcu_r5_0: mbox-mcu-r5-0 { + ti,mbox-rx = <0 0 0>; + ti,mbox-tx = <1 0 0>; + }; +}; + +&wkup_r5fss0 { + status = "okay"; +}; + +&wkup_r5fss0_core0 { + mboxes = <&mailbox0_cluster0>, <&mbox_r5_0>; + memory-region = <&wkup_r5fss0_core0_dma_memory_region>, + <&wkup_r5fss0_core0_memory_region>; +}; + +&mcu_r5fss0 { + status = "okay"; +}; + +&mcu_r5fss0_core0 { + mboxes = <&mailbox0_cluster2>, <&mbox_mcu_r5_0>; + memory-region = <&mcu_r5fss0_core0_dma_memory_region>, + <&mcu_r5fss0_core0_memory_region>; +}; + +&c7x_0 { + mboxes = <&mailbox0_cluster1>, <&mbox_c7x_0>; + memory-region = <&c7x_0_dma_memory_region>, + <&c7x_0_memory_region>; + status = "okay"; +}; -- 2.47.2
[PATCH 04/19] firmware: ti_sci: Add TI_SCI_MSG_MIN_CONTEXT_RESTORE
This patch adds code to be able to call TI_SCI_MSG_MIN_CONTEXT_RESTORE. The context needs to be restored after booting SPL when resuming from IO+DDR. Signed-off-by: Markus Schneider-Pargmann --- drivers/firmware/ti_sci.c | 38 ++ drivers/firmware/ti_sci.h | 14 + include/linux/soc/ti/ti_sci_protocol.h | 9 3 files changed, 61 insertions(+) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 190a1e3f5fc3713464b0cbf3ae8c35e3f185a353..f8270d2aa206412989d025502ddf297bc2d433dd 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -2608,6 +2608,41 @@ static int ti_sci_cmd_change_fwl_owner(const struct ti_sci_handle *handle, return ret; } +static int ti_sci_cmd_restore_context(const struct ti_sci_handle *handle, u64 ctx_addr) +{ + struct ti_sci_msg_min_restore_context_req req; + struct ti_sci_msg_hdr *resp; + struct ti_sci_info *info; + struct ti_sci_xfer *xfer; + int ret = 0; + + if (IS_ERR(handle)) + return PTR_ERR(handle); + if (!handle) + return -EINVAL; + + info = handle_to_ti_sci_info(handle); + + xfer = ti_sci_setup_one_xfer(info, TI_SCI_MSG_MIN_CONTEXT_RESTORE, +TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, +(u32 *)&req, sizeof(req), sizeof(*resp)); + if (IS_ERR(xfer)) { + ret = PTR_ERR(xfer); + return ret; + } + + req.ctx_lo = (u32)(ctx_addr & 0x); + req.ctx_hi = (u32)(ctx_addr >> 32); + + ret = ti_sci_do_xfer(info, xfer); + if (ret) { + dev_err(info->dev, "Failed restoring context %d\n", ret); + return ret; + } + + return ret; +} + /* * ti_sci_setup_ops() - Setup the operations structures * @info: pointer to TISCI pointer @@ -2625,6 +2660,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info) struct ti_sci_rm_psil_ops *psilops = &ops->rm_psil_ops; struct ti_sci_rm_udmap_ops *udmap_ops = &ops->rm_udmap_ops; struct ti_sci_fwl_ops *fwl_ops = &ops->fwl_ops; + struct ti_sci_lpm_ops *lpm_ops = &ops->lpm_ops; bops->board_config = ti_sci_cmd_set_board_config; bops->board_config_rm = ti_sci_cmd_set_board_config_rm; @@ -2689,6 +2725,8 @@ static void ti_sci_setup_ops(struct ti_sci_info *info) fwl_ops->set_fwl_region = ti_sci_cmd_set_fwl_region; fwl_ops->get_fwl_region = ti_sci_cmd_get_fwl_region; fwl_ops->change_fwl_owner = ti_sci_cmd_change_fwl_owner; + + lpm_ops->restore_context = ti_sci_cmd_restore_context; } /** diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h index bb8bc7beeadbed5415eb4450735d488de019e9af..e8fdc652b855e9057b734c3e4f526e380d0b78bd 100644 --- a/drivers/firmware/ti_sci.h +++ b/drivers/firmware/ti_sci.h @@ -43,6 +43,9 @@ #define TI_SCI_MSG_QUERY_CLOCK_FREQ0x010d #define TI_SCI_MSG_GET_CLOCK_FREQ 0x010e +/* Low Power Mode Requests */ +#define TI_SCI_MSG_MIN_CONTEXT_RESTORE 0x0308 + /* Processor Control Messages */ #define TISCI_MSG_PROC_REQUEST 0xc000 #define TISCI_MSG_PROC_RELEASE 0xc001 @@ -1530,4 +1533,15 @@ struct ti_sci_msg_fwl_change_owner_info_resp { u16 owner_permission_bits; } __packed; +/** + * struct ti_sci_msg_min_restore_context_req - Request to restore context from DDR + * + * @hdr: Generic Header + */ +struct ti_sci_msg_min_restore_context_req { + struct ti_sci_msg_hdr hdr; + u32 ctx_lo; + u32 ctx_hi; +} __packed; + #endif /* __TI_SCI_H */ diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h index 8e4c43cef3111412b5d894ad29152dde92822a64..1bf261368ca23ab03c60d25732b3e1f7d368b0ec 100644 --- a/include/linux/soc/ti/ti_sci_protocol.h +++ b/include/linux/soc/ti/ti_sci_protocol.h @@ -594,6 +594,14 @@ struct ti_sci_fwl_ops { int (*change_fwl_owner)(const struct ti_sci_handle *handle, struct ti_sci_msg_fwl_owner *owner); }; +/** + * struct ti_sci_lpm_ops - Low Power Mode operations + * @restore_context: Request restoring context from DDR. + */ +struct ti_sci_lpm_ops { + int (*restore_context)(const struct ti_sci_handle *handle, u64 ctx_addr); +}; + /** * struct ti_sci_ops - Function support for TI SCI * @board_ops: Miscellaneous operations @@ -615,6 +623,7 @@ struct ti_sci_ops { struct ti_sci_rm_psil_ops rm_psil_ops; struct ti_sci_rm_udmap_ops rm_udmap_ops; struct ti_sci_fwl_ops fwl_ops; + struct ti_sci_lpm_ops lpm_ops; }; /** -- 2.47.2
[PATCH 07/19] arm: mach-k3: common: Helper for LPM meta data address from DT
Add a small helper that uses memory regions referenced by the R5 devicetree node to calculate the LPM meta data address. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/common.c | 43 +++ arch/arm/mach-k3/common.h | 1 + 2 files changed, 44 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 2d9f34e61d916ce3a252e9cc3c2fd5475e60799e..7ec1f864a63d33ef1fd5576fb828c289dc5cf98a 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -16,6 +16,8 @@ #include #include "common.h" #include +#include +#include #include #include #include @@ -33,6 +35,7 @@ #include #define CLKSTOP_TRANSITION_TIMEOUT_MS 10 +#define K3_R5_MEMREGION_LPM_METADATA_OFFSET0x108000 #include @@ -153,6 +156,42 @@ bool wkup_ctrl_is_lpm_exit(void) } #if IS_ENABLED(CONFIG_K3_IODDR) +int wkup_r5f_am62_lpm_meta_data_addr(u64 *meta_data_addr) +{ + struct ofnode_phandle_args memregion_phandle; + ofnode memregion; + ofnode wkup_bus; + int ret; + + wkup_bus = ofnode_path("/bus@f/bus@b0"); + if (!ofnode_valid(wkup_bus)) { + printf("Failed to find wkup bus\n"); + return -EINVAL; + } + + memregion = ofnode_by_compatible(wkup_bus, "ti,am62-r5f"); + if (!ofnode_valid(memregion)) { + printf("Failed to find r5f devicetree node ti,am62-r5f\n"); + return -EINVAL; + } + + ret = ofnode_parse_phandle_with_args(memregion, "memory-region", NULL, +0, 1, &memregion_phandle); + if (ret) { + printf("Failed to parse phandle for second memory region\n"); + return ret; + } + + ret = ofnode_read_u64_index(memregion_phandle.node, "reg", 0, meta_data_addr); + if (ret) { + printf("Failed to read memory region offset\n"); + return ret; + } + + *meta_data_addr += K3_R5_MEMREGION_LPM_METADATA_OFFSET; + + return 0; +} static int lpm_restore_context(u64 ctx_addr) { struct ti_sci_handle *ti_sci = get_ti_sci_handle(); @@ -190,6 +229,10 @@ void __noreturn lpm_resume_from_ddr(u64 meta_data_addr) image_entry(); } #else +int wkup_r5f_am62_lpm_meta_data_addr(u64 *meta_data_addr) +{ + return -EINVAL; +} void __noreturn lpm_resume_from_ddr(u64 meta_data_addr) { diff --git a/arch/arm/mach-k3/common.h b/arch/arm/mach-k3/common.h index 47f2dbf2accd9029d6f1905fe8d3f93381032a81..c50dd3b76b37f762f345ae48dd2537ace5df3c02 100644 --- a/arch/arm/mach-k3/common.h +++ b/arch/arm/mach-k3/common.h @@ -47,6 +47,7 @@ void do_board_detect(void); void ti_secure_image_check_binary(void **p_image, size_t *p_size); void wkup_ctrl_remove_can_io_isolation_if_set(void); bool wkup_ctrl_is_lpm_exit(void); +int wkup_r5f_am62_lpm_meta_data_addr(u64 *meta_data_addr); void lpm_resume_from_ddr(u64 meta_data_addr); #if (IS_ENABLED(CONFIG_K3_QOS)) -- 2.47.2
[PATCH 02/19] arm: mach-k3: Kconfig: Add symbols for IO+DDR Low Power Mode
There is one new symbol to enable support to resume from IO+DDR where the SoC is turned off and DDR is in self-refresh. The other symbol is the address of a memory region to be used to store meta data. This has to be the same address as is used by the firmware. Signed-off-by: Markus Schneider-Pargmann --- arch/arm/mach-k3/Kconfig | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig index a3ac490f677429b851b4b4b3d6753ef6997884c9..1e6deb3b9cf1c5a8091a88d8c825ebdbb681424a 100644 --- a/arch/arm/mach-k3/Kconfig +++ b/arch/arm/mach-k3/Kconfig @@ -150,6 +150,15 @@ config K3_DM_FW bootloader, it makes RM and PM services not being available during R5 SPL execution time. +config K3_IODDR + bool "Enable IO+DDR Low Power Mode support" + depends on SPL && (SOC_K3_AM62A7 || SOC_K3_AM62P5) + default n + help + Enable support for IO+DDR Low Power Mode. If this is enabled and a + resume from IO+DDR is detected, metadata in the DDR is used to + restore TIFS and resume DM. + config K3_X509_SWRV int "SWRV for X509 certificate used for boot images" default 1 -- 2.47.2
Re: [PATCH v7 1/8] efi_loader: remove unused code from copy_fdt()
Heinrich, do you remember why this was originally here? I looked at 6422820ac3e59 which moved that code around, but the same code was there as well On Mon, 10 Mar 2025 at 13:58, Sughosh Ganu wrote: > > There is logic in the copy_fdt() function which is iterating over the > platform's DRAM banks and setting the fdt_ram_start variable. However, > this variable is not used subsequently in the function. Remove this > superfluous code. > > Signed-off-by: Sughosh Ganu > --- > Changes since V6: New patch > > lib/efi_loader/efi_helper.c | 14 +- > 1 file changed, 1 insertion(+), 13 deletions(-) > > diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c > index 04b2efc4a3b..15ad042bc61 100644 > --- a/lib/efi_loader/efi_helper.c > +++ b/lib/efi_loader/efi_helper.c > @@ -454,23 +454,11 @@ efi_status_t efi_env_set_load_options(efi_handle_t > handle, > */ > static efi_status_t copy_fdt(void **fdtp) > { > - unsigned long fdt_ram_start = -1L, fdt_pages; > + unsigned long fdt_pages; > efi_status_t ret = 0; > void *fdt, *new_fdt; > u64 new_fdt_addr; > uint fdt_size; > - int i; > - > - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { > - u64 ram_start = gd->bd->bi_dram[i].start; > - u64 ram_size = gd->bd->bi_dram[i].size; > - > - if (!ram_size) > - continue; > - > - if (ram_start < fdt_ram_start) > - fdt_ram_start = ram_start; > - } > > /* > * Give us at least 12 KiB of breathing room in case the device tree > -- > 2.34.1 > Reviewed-by: Ilias Apalodimas
Re: [PATCH 1/4] airoha: Add initial support for Airoha AN7581 SoC
On Sun, Mar 09, 2025 at 03:06:43PM +0100, Christian Marangi wrote: > Add initial support for Airoha AN7581 SoC. This adds the initial Kconfig > and Makefile entry for the SoC, an initial RFB DTS and initial config > for it. Also add the initial code for cpu and RAM initialization. > > Signed-off-by: Christian Marangi [snip] > diff --git a/arch/arm/mach-airoha/Kconfig b/arch/arm/mach-airoha/Kconfig > new file mode 100644 > index 000..0470a01034f > --- /dev/null > +++ b/arch/arm/mach-airoha/Kconfig > @@ -0,0 +1,44 @@ > +if ARCH_AIROHA > + > +config SYS_SOC > + default "airoha" > + > +config SYS_VENDOR > + default "airoha" > + > +choice > + prompt "Airoha board select" > + > +config TARGET_AN7581 > + bool "Airoha AN7581 SoC" > + select ARM64 > + help > + The Airoha EN7581 is a ARM-based SoC with a quad-core Cortex-A7 > + including NEON and GPU, Mali-450 graphics, several DDR3 options, > + crypto engine, built-in Wi-Fi / Bluetooth combo chip, JPEG decoder, > + video interfaces supporting HDMI and MIPI, and video codec support. > + Peripherals include Gigabit Ethernet, switch, USB3.0 and OTG, PCIe, > + I2S, PCM, S/PDIF, UART, SPI, I2C, IR TX/RX, and PWM. > + > +endchoice > + > +config SYS_BOARD > + string "Board name" > + default "an7581" if TARGET_AN7581 > + default "" > + help > + This option contains information about board name. > + Based on this option board// will > + be used. > + > +config SYS_CONFIG_NAME > + string "Board configuration name" > + default "an7581" if TARGET_AN7581 > + default "" > + help > + This option contains information about board configuration name. > + Based on this option include/configs/.h header > + will be used for board configuration. We shouldn't prompt for SYS_BOARD / SYS_CONFIG_NAME and instead just provide the values here. [snip] > diff --git a/board/airoha/an7581/MAINTAINERS b/board/airoha/an7581/MAINTAINERS > new file mode 100644 > index 000..480b89a73aa > --- /dev/null > +++ b/board/airoha/an7581/MAINTAINERS > @@ -0,0 +1,6 @@ > +AN7581 > +M: Christian Marangi > +S: Maintained > +F: board/airoha/an7581 > +F: include/configs/an7581.h > +F: configs/an7581_rfb_defconfig You should probably use the "N:" syntax here and say "N: an7581" to catch all the files later on too. Perhaps also "N: airoha" to catch the drivers you add later. > diff --git a/configs/an7581_evb_defconfig b/configs/an7581_evb_defconfig > new file mode 100644 > index 000..b37511c026e > --- /dev/null > +++ b/configs/an7581_evb_defconfig This doesn't appear to be the output of "make savedefconfig" so please re-sync it with that. > diff --git a/include/configs/an7581.h b/include/configs/an7581.h > new file mode 100644 > index 000..901d99b3456 > --- /dev/null > +++ b/include/configs/an7581.h > @@ -0,0 +1,19 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Configuration for Airoha AN7581 > + */ > + > +#ifndef __AN7581_H > +#define __AN7581_H > + > +#include > + > +#define CONFIG_SYS_UBOOT_BASECONFIG_TEXT_BASE > + > +#define CFG_SYS_INIT_RAM_ADDR CONFIG_TEXT_BASE > +#define CFG_SYS_INIT_RAM_SIZE SZ_2M > + > +/* DRAM */ > +#define CONFIG_SYS_SDRAM_BASE0x8000 You cannot set CONFIG symbols in this file anymore. -- Tom signature.asc Description: PGP signature
[PATCH v1] config: falcon: move CFG_SYS_SPI_* to Kconfig
CFG_SYS_SPI_* are used in falcon boot to specify the offsets and size of the repsective payloads. This patch moves them to Kconfig keeping the values consistent for each of the effected boards. Signed-off-by: Anshul Dalal --- Tested: * U-boot CI: https://github.com/u-boot/u-boot/pull/750 --- common/spl/Kconfig | 18 ++ common/spl/spl_spi.c | 9 + configs/am57xx_evm_defconfig | 3 +++ configs/am57xx_hs_evm_defconfig | 3 +++ configs/am57xx_hs_evm_usb_defconfig | 3 +++ configs/display5_defconfig | 3 +++ configs/display5_factory_defconfig | 3 +++ configs/dra7xx_evm_defconfig | 3 +++ configs/dra7xx_hs_evm_defconfig | 3 +++ configs/dra7xx_hs_evm_usb_defconfig | 3 +++ configs/imx28_xea_defconfig | 3 +++ configs/xilinx_zynq_virt_defconfig | 3 +++ configs/xilinx_zynqmp_kria_defconfig | 3 +++ configs/xilinx_zynqmp_virt_defconfig | 3 +++ include/configs/am57xx_evm.h | 16 include/configs/display5.h | 5 - include/configs/dra7xx_evm.h | 16 include/configs/xea.h| 6 -- include/configs/xilinx_zynqmp.h | 6 -- include/configs/zynq-common.h| 8 20 files changed, 59 insertions(+), 61 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 94e118f8465..7ff0b468954 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1431,6 +1431,24 @@ config SYS_SPI_U_BOOT_OFFS Address within SPI-Flash from where the u-boot payload is fetched from. +config SYS_SPI_KERNEL_OFFS + hex "Falcon mode: address of kernel payload in SPI flash" + depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT + help +Address within SPI-Flash from where the kernel payload is feteched +in falcon boot. + +config SYS_SPI_ARGS_OFFS + hex "Falcon mode: address of args payload in SPI flash" + depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT + help +Address within SPI-Flash from where the args payload (usually the +dtb) is feteched in falcon boot. + +config SYS_SPI_ARGS_SIZE + hex "Falcon mode: size of args payload in SPI flash" + depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT + config SPL_THERMAL bool "Driver support for thermal devices" help diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 691a431a926..00dbd3011f0 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -82,13 +82,14 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, #if CONFIG_IS_ENABLED(OS_BOOT) if (spl_start_uboot()) { int err = spl_load(spl_image, bootdev, &load, 0, - CFG_SYS_SPI_KERNEL_OFFS); + CONFIG_SYS_SPI_KERNEL_OFFS); if (!err) /* Read device tree. */ - return spi_flash_read(flash, CFG_SYS_SPI_ARGS_OFFS, - CFG_SYS_SPI_ARGS_SIZE, - (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); + return spi_flash_read( + flash, CONFIG_SYS_SPI_ARGS_OFFS, + CONFIG_SYS_SPI_ARGS_SIZE, + (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); } #endif diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index d10d2a5940f..0cfad501298 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -41,6 +41,9 @@ CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR=0x1500 CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS=0x200 CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x4 +CONFIG_SYS_SPI_KERNEL_OFFS=0x1E +CONFIG_SYS_SPI_ARGS_OFFS=0x14 +CONFIG_SYS_SPI_ARGS_SIZE=0x8 CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_ADTIMG=y CONFIG_CMD_ABOOTIMG=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 5cacd7f9cc5..14700d59bdb 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -39,6 +39,9 @@ CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img" CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x4 +CONFIG_SYS_SPI_KERNEL_OFFS=0x1E +CONFIG_SYS_SPI_ARGS_OFFS=0x14 +CONFIG_SYS_SPI_ARGS_SIZE=0x8 CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_ADTIMG=y CONFIG_CMD_ABOOTIMG=y diff --git a/configs/am57xx_hs_evm_usb_defconfig b/configs/am57xx_hs_evm_usb_defconfig index d865b123b90..634294e4766 100644 --- a/configs/am57xx_hs_evm_usb_defconfig +++ b/configs/am57xx_hs_evm_usb_defconfig @@ -41,6 +41,9 @@ CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img" CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x4 +CONFIG_SYS_SPI_KERNEL_OFFS=0x1E +CONFIG_SYS_SPI_ARGS_OFFS=0x14 +CONFIG_SYS_SPI_ARGS_SIZE=0x8 CONFIG_SPL_YMODEM_SUPPO
[PATCH v7 5/8] efi_loader: preserve installer images in pmem
From: Ilias Apalodimas One of the problems OS installers face, when running in EFI, is that the mounted ISO after calling ExitBootServices goes away. For some distros this is a problem since they rely on finding some core packages before continuing the installation. Distros have works around this -- e.g Fedora has a special kernel command line parameter called inst.stage2 [0]. ACPI has NFIT and NVDIMM support to provide ramdisks to the OS, but we don't have anything in place for DTs. Linux and device trees have support for persistent memory devices. It's worth noting that for linux to instantiate the /dev/pmemX device, the memory described in the pmem node has to be omitted from the EFI memory map we hand over to the OS if ZONE_DEVICES and SPARSEMEM is enabled. With those enabled the pmem driver ends up calling devm_memremap_pages() instead of devm_memremap(). The latter works whether the memory is omitted or marked as reserved, but mapping pages only works if the memory is omitted. On top of that, depending on how the kernel is configured, that memory area must be page aligned or 2MB aligned. PowerPC is an exception here and requires 16MB alignment, but since we don't have EFI support for it, limit the alignment to 2MB. Ensure that the ISO image is 2MB aligned and remove the region occupied by the image from the EFI memory map. Signed-off-by: Ilias Apalodimas Signed-off-by: Sughosh Ganu --- Changes since V6: None lib/efi_loader/efi_bootmgr.c | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index c6124c590d9..081eff057f4 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include static const struct efi_boot_services *bs; static const struct efi_runtime_services *rs; @@ -362,13 +364,16 @@ static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size, } /* -* TODO: expose the ramdisk to OS. -* Need to pass the ramdisk information by the architecture-specific -* methods such as 'pmem' device-tree node. +* Linux supports 'pmem' which allows OS installers to find, reclaim +* the mounted images and continue the installation since the contents +* of the pmem region are treated as local media. +* +* The memory regions used for it needs to be carved out of the EFI +* memory map. */ - ret = efi_add_memory_map(addr, size, EFI_RESERVED_MEMORY_TYPE); + ret = efi_remove_memory_map(addr, size, EFI_CONVENTIONAL_MEMORY); if (ret != EFI_SUCCESS) { - log_err("Memory reservation failed\n"); + log_err("Failed to reserve memory\n"); goto err; } @@ -490,6 +495,13 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, ret = EFI_INVALID_PARAMETER; goto err; } + /* +* Depending on the kernel configuration, pmem memory area must be page +* aligned or 2MB aligned. PowerPC is an exception here and requires +* 16MB alignment, but since we don't have EFI support for it, limit +* the alignment to 2MB. +*/ + image_size = ALIGN(image_size, SZ_2M); /* * If the file extension is ".iso" or ".img", mount it and try to load -- 2.34.1
Re: [PATCH v2] amd: versal2: Add the UFS boot mode support
On 2/25/25 04:28, Venkatesh Yadav Abbarapu wrote: Add the UFS boot mode support and update the boot_targets with ufs mode. If the UFS device is not accessible from APU and running this is detected as a warning, as the device is not accessible. Signed-off-by: Venkatesh Yadav Abbarapu --- Changes in v2: - Use uclass_get_device() with index 0, as we have single UFS controller. --- arch/arm/mach-versal2/include/mach/hardware.h | 1 + board/amd/versal2/board.c | 10 ++ 2 files changed, 11 insertions(+) diff --git a/arch/arm/mach-versal2/include/mach/hardware.h b/arch/arm/mach-versal2/include/mach/hardware.h index 42e3061a0ae..022c8b3c832 100644 --- a/arch/arm/mach-versal2/include/mach/hardware.h +++ b/arch/arm/mach-versal2/include/mach/hardware.h @@ -67,6 +67,7 @@ struct crp_regs { #define USB_MODE 0x0007 #define OSPI_MODE 0x0008 #define SELECTMAP_MODE0x000A +#define UFS_MODE 0x000B #define SD1_LSHFT_MODE0x000E /* SD1 Level shifter */ #define JTAG_MODE 0x #define BOOT_MODE_USE_ALT 0x100 diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c index 5651d516a9e..220ab63c994 100644 --- a/board/amd/versal2/board.c +++ b/board/amd/versal2/board.c @@ -252,6 +252,16 @@ static int boot_targets_setup(void) mode = "mmc"; bootseq = dev_seq(dev); break; + case UFS_MODE: + puts("UFS_MODE\n"); + if (uclass_get_device(UCLASS_UFS, 0, &dev)) { + debug("UFS driver for UFS device is not present\n"); + break; + } + debug("ufs device found at %p\n", dev); + + mode = "ufs"; + break; default: printf("Invalid Boot Mode:0x%x\n", bootmode); break; Applied. M
[PATCH v3 1/8] legacy-net: wget: fix wget_info handling after new tcp legacy stack
Check wget_info->buffer_size for overflow and do not clean the wget_info struct on failure, let the owner of the struct handle the error. The latter is necesary , e.g., for when a request fails because the provided buffer was too small. Signed-off-by: Adriano Cordova --- (no changes since v1) net/wget.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/net/wget.c b/net/wget.c index 0b082c61947..c73836cbc9d 100644 --- a/net/wget.c +++ b/net/wget.c @@ -53,6 +53,9 @@ static inline int store_block(uchar *src, unsigned int offset, unsigned int len) ulong store_addr = image_load_addr + offset; uchar *ptr; + // Avoid overflow + if (wget_info->buffer_size && wget_info->buffer_size < offset + len) + return -1; if (CONFIG_IS_ENABLED(LMB) && wget_info->set_bootdev) { if (store_addr < image_load_addr || lmb_read_check(store_addr, len)) { @@ -98,12 +101,6 @@ static void tcp_stream_on_closed(struct tcp_stream *tcp) net_set_state(wget_loop_state); if (wget_loop_state != NETLOOP_SUCCESS) { net_boot_file_size = 0; - if (wget_info->status_code == HTTP_STATUS_OK) { - wget_info->status_code = HTTP_STATUS_BAD; - wget_info->hdr_cont_len = 0; - if (wget_info->headers) - wget_info->headers[0] = 0; - } printf("\nwget: Transfer Fail, TCP status - %d\n", tcp->status); return; } @@ -212,6 +209,11 @@ static void tcp_stream_on_rcv_nxt_update(struct tcp_stream *tcp, u32 rx_bytes) "wget: Connected Len %lu\n", content_length); wget_info->hdr_cont_len = content_length; + if (wget_info->buffer_size && wget_info->buffer_size < wget_info->hdr_cont_len){ + tcp_stream_reset(tcp); + goto end; + } + } net_boot_file_size = rx_bytes - http_hdr_size; @@ -227,7 +229,9 @@ static int tcp_stream_rx(struct tcp_stream *tcp, u32 rx_offs, void *buf, int len if ((max_rx_pos == (u32)(-1)) || (max_rx_pos < rx_offs + len - 1)) max_rx_pos = rx_offs + len - 1; - store_block(buf, rx_offs - http_hdr_size, len); + // Avoid overflow + if (store_block(buf, rx_offs - http_hdr_size, len) < 0) + return -1; return len; } -- 2.48.1
Re: [PATCH 00/17] Various toolchain compatibility fixes/improvements
On Fri, Mar 07, 2025 at 10:48:11PM -0800, Sam Edwards wrote: > On Thu, Mar 6, 2025 at 7:47 AM Tom Rini wrote: > > > > On Wed, Mar 05, 2025 at 07:46:56PM -0800, Sam Edwards wrote: > > > On Sun, Feb 23, 2025 at 9:55 PM Sam Edwards wrote: > > > > > > > > Long time no see, U-Boot folks! > > > > > > > > This patchset consists of various bug fixes and correctness > > > > improvements that > > > > I discovered while attempting to add first-class LLVM support to the > > > > build > > > > system. These patches are NOT related to LLVM support directly; rather, > > > > they > > > > address existing issues that should be resolved regardless of future > > > > changes. > > > > For the most part, the patches are mutually independent and can be > > > > reviewed and > > > > applied separately. If any patch is not suitable for merging now, feel > > > > free to > > > > skip it: I will incorporate feedback and revisit those changes as part > > > > of the > > > > upcoming LLVM support patchset. I'd like this patchset to be evaluated > > > > on its > > > > own merits, based on the current state of the code, without > > > > consideration for > > > > future LLVM support. > > > > > > > > Note that the issues addressed in this patchset do not occur when > > > > U-Boot is > > > > built using the GCC/GNU toolchain. These bugs seem to be specific to > > > > builds > > > > using other toolchains, like LLVM, and do not appear to affect users > > > > relying on > > > > GCC/GNU. Therefore, I see no need to rush these changes into the stable > > > > branch. > > > > > > > > Again, these patches are mostly independent/reorderable... > > > > ...except that: "arm: Add aligned-memory aliases to eabi_compat" > > > > ...depends on: "arm: Add __aeabi_memclr in eabi_compat" > > > > > > > > Warm regards, > > > > Sam > > > > > > Hi Tom, > > > > > > I noticed that all patches in this series have been marked 'Changes > > > Requested' on Patchwork. While some patches do need changes, this > > > series was intended as a set of independent submissions: each patch > > > can be accepted, rejected, or reordered without affecting the others. > > > Would it be possible to reconsider the remaining patches for review > > > without resending the series? > > > > > > I'd like to withdraw the following patches: > > > > > > - [06/17] arm: Use -mstrict-align when the MMU is off (Incorrect approach) > > > - [11/17] makefile: Fix symbol typo in binary_size_check (Will follow > > > Simon's suggestion for a more comprehensive fix across architectures > > > in a future submission) > > > > > > The feedback I've received so far was mostly requests for > > > clarification, which I believe I've addressed in my replies. Please > > > let me know if anything remains unclear or if further adjustments are > > > needed. > > > > > > Thank you so much for your time! > > > > It's *really* hard to track parts of a series in that way. If they > > aren't intended to be applied all in one go, please post them > > individually as v2s. The clarifications likely mean a bit more rewording > > of the commit messages are in order. > > > > If it's really hard on your end to resend things, I can go and poke > > through the series (once Ilias has had time to do the reviews I see he > > promised). > > Hi Tom, > > Well... that's "hard" but not "really hard" for me, so I think what > I'll pitch is this: let's let Ilias (and others if so inclined) have a > week to pick through the series (thanks Ilias!) and offer feedback; > I'll resend any patches that get no/positive feedback as a v2 series > (where the "just skip any patch deemed objectionable" option will > still apply), and any patches that need reworking can be part of my > upcoming LLVM support series. Would that work? Yes, thanks! -- Tom signature.asc Description: PGP signature
Re: [PULL] Pull request for u-boot master / v2025.04 = u-boot-stm32-20250310
On Mon, Mar 10, 2025 at 01:21:27PM +0100, Patrice CHOTARD wrote: > Hi Tom > > Please pull the STM32 related patches for u-boot/master, v2025.04 = > u-boot-stm32-20250310 > > CI status: > https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/25054 > > Thanks > Patrice > > > The following changes since commit dc0ee458f1afae4cb5c8a7b2c875bb24ffdf71ca: > > Prepare v2025.04-rc3 (2025-02-24 16:53:59 -0600) > > are available in the Git repository at: > > https://source.denx.de/u-boot/custodians/u-boot-stm.git > u-boot-stm32-20250310 > > for you to fetch changes up to f5ee0f2bf7b008dc92315c10239e8d537877c0de: > > ARM: stm32mp: Fix dram_bank_mmu_setup() for ram_top=0 (2025-03-10 09:39:30 > +0100) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
[PATCH] ARM: dts: imx: Drop bogus regulator extras on DH i.MX6 DHCOM DRC02
The regulator extras should be placed in the USB H1 regulator node, the /regulator-usb-h1-vbus. They are already present there in the upstream DT, so delete this bogus node entirely. Signed-off-by: Marek Vasut --- Cc: "NXP i.MX U-Boot Team" Cc: Andreas Geisreiter Cc: Christoph Niedermaier Cc: Fabio Estevam Cc: Tom Rini Cc: u-b...@dh-electronics.com Cc: u-boot@lists.denx.de --- arch/arm/dts/imx6qdl-dhcom-u-boot.dtsi | 5 - 1 file changed, 5 deletions(-) diff --git a/arch/arm/dts/imx6qdl-dhcom-u-boot.dtsi b/arch/arm/dts/imx6qdl-dhcom-u-boot.dtsi index 740a24d96ec..300e355c8ef 100644 --- a/arch/arm/dts/imx6qdl-dhcom-u-boot.dtsi +++ b/arch/arm/dts/imx6qdl-dhcom-u-boot.dtsi @@ -27,11 +27,6 @@ }; }; -®_usb_otg_vbus { - gpio = <&gpio3 31 GPIO_ACTIVE_HIGH>; - enable-active-high; -}; - &wdog1 { bootph-pre-ram; }; -- 2.47.2
Re: [PATCH] mcheck: Fix SPDX License Identifier to LGPL-2.1-or-later
On Sat, 01 Mar 2025 11:14:12 +0100, Diederik de Haas wrote: > The GPL-2.1+ SPDX License Identifier doesn't exist, but luckily the full > license text was available which shows that GPL-2.1+ was a typo and it > should have been LGPL-2.1-or-later. > As the '+' in LGPL-2.1+ is deprecated in SPDX 3.0, use the preferred > identifier, which is '-or-later'. > > Normally the full license header is removed when switching to SPDX > License Identifiers, so do that now. > > [...] Applied to u-boot/master, thanks! [1/1] mcheck: Fix SPDX License Identifier to LGPL-2.1-or-later commit: 31378bd6fc909afabee69f425bf663002277eecf -- Tom
[PATCH v2] config: falcon: move CFG_SYS_SPI_* to Kconfig
CFG_SYS_SPI_* are used in falcon boot to specify the offsets and size of the respective payloads. This patch moves them to Kconfig keeping the values consistent for each of the affected boards. Reviewed-by: Tom Rini Reviewed-by: Fabio Estevam Signed-off-by: Anshul Dalal --- Tested: * U-boot CI: https://github.com/u-boot/u-boot/pull/750 Changes in v2: * Spell fixes in commit message and Kconfig help * Remove redundant header linux/sizes.h from xea.h * Add Reviewed-by tags form Tom Rini and Fabio Estevam v1: https://lore.kernel.org/u-boot/20250310133647.2712374-1-ansh...@ti.com/ --- common/spl/Kconfig | 18 ++ common/spl/spl_spi.c | 9 + configs/am57xx_evm_defconfig | 3 +++ configs/am57xx_hs_evm_defconfig | 3 +++ configs/am57xx_hs_evm_usb_defconfig | 3 +++ configs/display5_defconfig | 3 +++ configs/display5_factory_defconfig | 3 +++ configs/dra7xx_evm_defconfig | 3 +++ configs/dra7xx_hs_evm_defconfig | 3 +++ configs/dra7xx_hs_evm_usb_defconfig | 3 +++ configs/imx28_xea_defconfig | 3 +++ configs/xilinx_zynq_virt_defconfig | 3 +++ configs/xilinx_zynqmp_kria_defconfig | 3 +++ configs/xilinx_zynqmp_virt_defconfig | 3 +++ include/configs/am57xx_evm.h | 16 include/configs/display5.h | 5 - include/configs/dra7xx_evm.h | 16 include/configs/xea.h| 8 include/configs/xilinx_zynqmp.h | 6 -- include/configs/zynq-common.h| 8 20 files changed, 59 insertions(+), 63 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 94e118f8465..21a5cefee7a 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1431,6 +1431,24 @@ config SYS_SPI_U_BOOT_OFFS Address within SPI-Flash from where the u-boot payload is fetched from. +config SYS_SPI_KERNEL_OFFS + hex "Falcon mode: address of kernel payload in SPI flash" + depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT + help +Address within SPI-Flash from where the kernel payload is fetched +in falcon boot. + +config SYS_SPI_ARGS_OFFS + hex "Falcon mode: address of args payload in SPI flash" + depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT + help +Address within SPI-Flash from where the args payload (usually the +dtb) is fetched in falcon boot. + +config SYS_SPI_ARGS_SIZE + hex "Falcon mode: size of args payload in SPI flash" + depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT + config SPL_THERMAL bool "Driver support for thermal devices" help diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 691a431a926..00dbd3011f0 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -82,13 +82,14 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, #if CONFIG_IS_ENABLED(OS_BOOT) if (spl_start_uboot()) { int err = spl_load(spl_image, bootdev, &load, 0, - CFG_SYS_SPI_KERNEL_OFFS); + CONFIG_SYS_SPI_KERNEL_OFFS); if (!err) /* Read device tree. */ - return spi_flash_read(flash, CFG_SYS_SPI_ARGS_OFFS, - CFG_SYS_SPI_ARGS_SIZE, - (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); + return spi_flash_read( + flash, CONFIG_SYS_SPI_ARGS_OFFS, + CONFIG_SYS_SPI_ARGS_SIZE, + (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR); } #endif diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig index d10d2a5940f..0cfad501298 100644 --- a/configs/am57xx_evm_defconfig +++ b/configs/am57xx_evm_defconfig @@ -41,6 +41,9 @@ CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR=0x1500 CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS=0x200 CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x4 +CONFIG_SYS_SPI_KERNEL_OFFS=0x1E +CONFIG_SYS_SPI_ARGS_OFFS=0x14 +CONFIG_SYS_SPI_ARGS_SIZE=0x8 CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_ADTIMG=y CONFIG_CMD_ABOOTIMG=y diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig index 5cacd7f9cc5..14700d59bdb 100644 --- a/configs/am57xx_hs_evm_defconfig +++ b/configs/am57xx_hs_evm_defconfig @@ -39,6 +39,9 @@ CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img" CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x4 +CONFIG_SYS_SPI_KERNEL_OFFS=0x1E +CONFIG_SYS_SPI_ARGS_OFFS=0x14 +CONFIG_SYS_SPI_ARGS_SIZE=0x8 CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_CMD_ADTIMG=y CONFIG_CMD_ABOOTIMG=y diff --git a/configs/am57xx_hs_evm_usb_defconfig b/configs/am57xx_hs_evm_usb_defconfig index d865b123b90..634294e4766 100644 --- a/configs/am57xx_hs_evm_usb_defconfig +++ b/configs/am57xx
Re: [PATCH v2 2/3] ARM: dts: stm32: drop "st,led1" compatible
On 2/25/25 10:53, Patrice CHOTARD wrote: > > > On 2/24/25 19:39, Dario Binacchi wrote: >> It is pointless to use the custom compatible "st,led1" when >> stm32746g-eval.dts and stm32f769-disco.dts already contain the >> "gpio-leds" compatible, which is specifically used for GPIO LEDs >> management. >> >> Signed-off-by: Dario Binacchi >> >> --- >> >> Changes in v2: >> - Drop leds node from stm32f746-disco-u-boot.dtsi >> >> arch/arm/dts/stm32746g-eval-u-boot.dtsi| 5 - >> arch/arm/dts/stm32f746-disco-u-boot.dtsi | 5 - >> arch/arm/dts/stm32f769-disco-u-boot.dtsi | 5 - >> board/st/stm32f746-disco/stm32f746-disco.c | 16 >> 4 files changed, 31 deletions(-) >> >> diff --git a/arch/arm/dts/stm32746g-eval-u-boot.dtsi >> b/arch/arm/dts/stm32746g-eval-u-boot.dtsi >> index f64329287357..32b5c7cea4b8 100644 >> --- a/arch/arm/dts/stm32746g-eval-u-boot.dtsi >> +++ b/arch/arm/dts/stm32746g-eval-u-boot.dtsi >> @@ -22,11 +22,6 @@ >> mmc0 = &sdio1; >> spi0 = &qspi; >> }; >> - >> -led1 { >> -compatible = "st,led1"; >> -led-gpio = <&gpiof 10 0>; >> -}; >> }; >> >> &fmc { >> diff --git a/arch/arm/dts/stm32f746-disco-u-boot.dtsi >> b/arch/arm/dts/stm32f746-disco-u-boot.dtsi >> index a79fca261a2c..38d797e49a0a 100644 >> --- a/arch/arm/dts/stm32f746-disco-u-boot.dtsi >> +++ b/arch/arm/dts/stm32f746-disco-u-boot.dtsi >> @@ -22,11 +22,6 @@ >> mmc0 = &sdio1; >> spi0 = &qspi; >> }; >> - >> -led1 { >> -compatible = "st,led1"; >> -led-gpio = <&gpioi 1 0>; >> -}; >> }; >> >>> diff --git a/arch/arm/dts/stm32f769-disco-u-boot.dtsi >> b/arch/arm/dts/stm32f769-disco-u-boot.dtsi >> index a50fba64dcd2..7c99a6e61b68 100644 >> --- a/arch/arm/dts/stm32f769-disco-u-boot.dtsi >> +++ b/arch/arm/dts/stm32f769-disco-u-boot.dtsi >> @@ -23,11 +23,6 @@ >> spi0 = &qspi; >> }; >> >> -led1 { >> -compatible = "st,led1"; >> -led-gpio = <&gpioj 5 0>; >> -}; >> - >> panel: panel { >> compatible = "orisetech,otm8009a"; >> reset-gpios = <&gpioj 15 1>; >> diff --git a/board/st/stm32f746-disco/stm32f746-disco.c >> b/board/st/stm32f746-disco/stm32f746-disco.c >> index 65a39d965c72..72f479cea66f 100644 >> --- a/board/st/stm32f746-disco/stm32f746-disco.c >> +++ b/board/st/stm32f746-disco/stm32f746-disco.c >> @@ -78,22 +78,6 @@ u32 spl_boot_device(void) >> >> int board_late_init(void) >> { >> -struct gpio_desc gpio = {}; >> -int node; >> - >> -node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1"); >> -if (node < 0) >> -return -1; >> - >> -gpio_request_by_name_nodev(offset_to_ofnode(node), "led-gpio", 0, &gpio, >> - GPIOD_IS_OUT); >> - >> -if (dm_gpio_is_valid(&gpio)) { >> -dm_gpio_set_value(&gpio, 0); >> -mdelay(10); >> -dm_gpio_set_value(&gpio, 1); >> -} >> - >> return 0; >> } >> > > Reviewed-by: Patrice Chotard > > Thanks > Patrice Applied to u-boot-stm32/next Thanks Patrice
Re: [PATCH 11/12] pytest: requirements.txt: Include setuptools
On Sat, Mar 08, 2025 at 09:12:15PM +0100, Marek Vasut wrote: > This seems to be needed for filesystem tests at least on > ubuntu 22.04 machines. Add setuptools into requirements.txt . > > Signed-off-by: Marek Vasut > --- > Cc: Baruch Siach > Cc: Francesco Dolcini > Cc: Heinrich Schuchardt > Cc: Hiago De Franco > Cc: Ilias Apalodimas > Cc: Nam Cao > Cc: Simon Glass > Cc: Sughosh Ganu > Cc: Tom Rini > Cc: u-boot@lists.denx.de > --- > test/py/requirements.txt | 1 + > 1 file changed, 1 insertion(+) This belongs in the requirements.txt for the tool that requires setuptools, not pytest. It's also listed as a required host tool / package in doc/builds/gcc.rst. Having just re-created the requirements.txt file, I don't want to add things that will get dropped again the next time. -- Tom signature.asc Description: PGP signature
Re: [PATCH v5 7/8] env: Provide a work-around for unquoting fdtfile
On Wed, 13 Nov 2024 08:09:37 -0700, Simon Glass wrote: > Some boards use a CONFIG option to specify the value of this variable. > This is normally handled by efi_get_distro_fdt_name() but in the case > of sunxi this does not work, since 'soc' is sunxi, but the files are > in the allwinner directory. > > Provide a work-around for this particular case. > > [...] Applied to u-boot/next, thanks! [7/8] env: Provide a work-around for unquoting fdtfile commit: d085e692c98d0d7b57cc577ed9befda159cd4a40 -- Tom
Re: [PATCH 02/10] cmd: Kconfig: enable CMD_BOOTI for ARCH_K3
On Mon, Mar 10, 2025 at 10:48:47AM +0530, Anshul Dalal wrote: > On Fri Mar 7, 2025 at 9:50 PM IST, Tom Rini wrote: > > On Fri, Mar 07, 2025 at 09:43:19PM +0530, Anshul Dalal wrote: > > > On Fri Mar 7, 2025 at 9:20 PM IST, Tom Rini wrote: > > > > On Fri, Mar 07, 2025 at 01:25:30PM +0530, Anshul Dalal wrote: > > > > > > > > > This allows us to load the kernel image to memory on 32-bit R5 SPL. > > > > > > > > > > Signed-off-by: Anshul Dalal > > > > > --- > > > > > cmd/Kconfig | 2 +- > > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/cmd/Kconfig b/cmd/Kconfig > > > > > index a04fcaa0e08..66145a001b8 100644 > > > > > --- a/cmd/Kconfig > > > > > +++ b/cmd/Kconfig > > > > > @@ -357,7 +357,7 @@ config CMD_BOOTZ > > > > > > > > > > config CMD_BOOTI > > > > > bool "booti" > > > > > - depends on ARM64 || RISCV || SANDBOX > > > > > + depends on ARM64 || RISCV || SANDBOX || ARCH_K3 > > > > > > > > How are you using "booti" on the R5 part of K3? This shouldn't be > > > > useful... > > > > > > This is necessary to allow us to call booti_setup [the code path > > > responsible for parsing uncompressed kernel image] from > > > spl_parse_image_header at common/spl/spl.c:338 when loading the Image. > > > > OK, so please update arch/arm/lib/Makefile with something like: > > ifdef CONFIG_ARCH_K3 > > obj-$(CONFIG_SPL_OS_BOOT) += booti.o > > endif > > We would still have to have CMD_BOOTI enabled even with this change > because of the check at common/spl/spl.c:338. I suggest we proceed with > my original set of changes instead. No, things need to be reworked more then as it doesn't make logical sense to enable a command in SPL (where there are no commands). It's odd enough that we need to enable support for image formats that don't exist on 32bit arm, on 32bit arm. What's there in common/spl/spl.c:338 (and the next check) is a short-hand. -- Tom signature.asc Description: PGP signature
[PATCH v2 0/4] omap24xx_i2c: Enable Repeated Start functionality
This series implements Repeated Start functionality for the DM_I2C xfer API (omap_i2c_xfer()) First, split out the actual implementation for each individual i2c msg transfer into a new function __omap24_i2c_xfer_msg() and use this to implement omap_i2c_xfer(). Then, add support for the Repeated Start condition in omap_i2c_xfer() through the CONFIG_I2C_REPEATED_START option. Also add this config to Kconfig and enable it for ARCH_K3 platforms by default. Test logs (On AM68-SK with DEBUG enabled): https://gist.github.com/aniket-l/e6d78d52c172ebb475552929b71736a9 Boot logs on k3: https://gist.github.com/aniket-l/110ee4f950ef05027a12bafa96431936 --- v2: - Add another patch to remove unused CONFIG_I2C_REPEATED_START - use new CONFIG_SYS_I2C_OMAP24XX_REPEATED_START - Return right error codes and update debug prints to be driver specific - patch formatting updates - Link to v1: https://lore.kernel.org/u-boot/20250304220546.866602-1-a-lim...@ti.com/ Aniket Limaye (4): i2c: omap24xx_i2c: Remove unused CONFIG_I2C_REPEATED_START i2c: omap24xx_i2c: Use new function __omap24_i2c_xfer_msg() i2c: omap24xx_i2c: support CONFIG for repeated start in DM_I2C xfer drivers: i2c: Kconfig: Add CONFIG_SYS_I2C_OMAP24XX_REPEATED_START drivers/i2c/Kconfig| 9 ++ drivers/i2c/omap24xx_i2c.c | 165 ++--- 2 files changed, 144 insertions(+), 30 deletions(-) -- 2.48.1
Re: [PATCH 12/12] test_fs: Add exfat tests
On Sat, Mar 08, 2025 at 09:12:16PM +0100, Marek Vasut wrote: > Add tests for the exfat filesystem. These tests are largely an > extension of the FS_GENERIC tests with the following notable > exceptions. > > The filesystem image for exfat tests is generated using combination > of exfatutils mkfs.exfat and python fattools. The fattols are capable Did you mean "exfatprogs" and not "exfatutils" ? But we need to update tools/docker/Dockerfile to list the tool there. > of generating exfat filesystem images too, but this is not used, the Presumably because "fattools mkfat" seems to have further external dependencies and so would be more of a pain to use. > fattools are only used as a replacement for dosfstools 'mcopy' and > 'mdir', which are used to insert files and directories into existing > fatfs images and list existing fatfs images respectively, without the > need for superuser access to mount such images. > > The exfat filesystem has no filesystem specific command, there is only > the generic filesystem command interface, therefore check_ubconfig() > has to special case exfat and skip check for CONFIG_CMD_EXFAT and > instead check for CONFIG_FS_EXFAT. > > Signed-off-by: Marek Vasut > --- > Cc: Baruch Siach > Cc: Francesco Dolcini > Cc: Heinrich Schuchardt > Cc: Hiago De Franco > Cc: Ilias Apalodimas > Cc: Nam Cao > Cc: Simon Glass > Cc: Sughosh Ganu > Cc: Tom Rini > Cc: u-boot@lists.denx.de > --- > test/py/requirements.txt | 1 + > test/py/tests/fs_helper.py| 8 ++-- > test/py/tests/test_fs/conftest.py | 20 +++- > test/py/tests/test_fs/test_ext.py | 20 ++-- > 4 files changed, 32 insertions(+), 17 deletions(-) We also need to update test/py/tests/test_fs/fstest_helpers.py to know to call fsck.exfat. [snip] > @@ -64,6 +66,8 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, > size_gran = 0x10): > check_call(f'tune2fs -O ^metadata_csum {fs_img}', shell=True) > elif fs_lnxtype == 'vfat' and src_dir: > check_call(f'mcopy -i {fs_img} -vsmpQ {src_dir}/* ::/', > shell=True) > +elif fs_lnxtype == 'exfat' and src_dir: > +check_call(f'fattools cp {src_dir}/* {fs_img}', shell=True) > return fs_img > except CalledProcessError: > call(f'rm -f {fs_img}', shell=True) A cleanup to use fattools in both cases would be nice, as a follow-up. Otherwise looks good, thanks! -- Tom signature.asc Description: PGP signature