Skip to contentSkip to conversation

Qualcomm IPQ5210 SoC bringup

PATCH In review Varadarajan Narayanan via U-Boot 2 participants 22 messages Jul 22 – Aug 6

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

v8 cover Qualcomm IPQ5210 SoC bringup

Add pinctrl, clock drivers and SPL to support the IPPQ5210 SoC in U-Boot.

The relevant DT files are available in linux-next [1] & [2]

Working features, as tested on RDP504:
* Serial console
* UART
* MMC
* Boot sequence transitions from Boot ROM to U-Boot SPL, proprietary binaries (a.k.a QCLib) load and execute as appropriate and eventual jump to U-Boot.
* The QCLib handles
- DDR initialization
- Clock setup

1 - https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/qcom/ipq5210.dtsi

    https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/qcom/ipq5210-rdp504.dts
    https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/include/dt-bindings/clock/qcom,ipq5210-gcc.h
    https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/include/dt-bindings/reset/qcom,ipq5210-gcc.h

2 - https://lore.kernel.org/linux-arm-msm/[email protected]/

v8: - Rebased on https://source.denx.de/u-boot/custodians/u-boot-snapdragon.git
- Address Casey's review comments on v6
- Spin off GENI Minicore support and mkmbn support as separate patches [PATCH] misc: qcom_geni: Add minicore support - [a] [PATCH 0/3] tools: qcom: mkmbn: Updates to support ipq5210 - [b]
- Re-organize the functions from spl.c into board_spl.c and fit-handler.c and remove spl.c
- Retained R-b tags since the code just moved
- Removed references to MBN and multi-elf creation steps in rdp.rst since mkmbn.py takes care of it
- Add details about the interface table in doc/board/qualcomm/spl-qclib.rst
- May need to update config.mk based on the final shape of mkmbn patches [b]

a - https://patchwork.ozlabs.org/project/uboot/list/?series=514770
b - https://lore.kernel.org/u-boot/[email protected]/

v7: - Fix inadvertant typo in doc/board/qualcomm/rdp.rst
- Pick multiple R-b tags
- No code changes

v6: - Move binman related changes to separate series, so that the
SPL changes can move forward.
- Restore v3 build steps for now
- https://lore.kernel.org/u-boot/[email protected]/

v5: - Reorganize SPL related code into common and SoC specific functions
to allow SoCs to customize according to their boot flow
- Fix documentation related build errors
- Please see the patches for specific changes
- https://lore.kernel.org/u-boot/[email protected]/

v4: - Add binman based image creation support instead of special scripts
- Identify boot media based on PBL shared info instead of CONFIG_xxx
- Address v3 feedback (see individual patch for details)
- https://lore.kernel.org/u-boot/[email protected]/

v3: - Move stack range
- Split spl.c patch
- Move documentation towards the end of the series
- Pick couple of R-b
- https://lore.kernel.org/u-boot/[email protected]/

v2: - Add QCOM_GENI_MINICORE config option
- Move minicore register settings to separate file and include
if QCOM_GENI_MINICORE is enabled
- Remove bootph-all from override dts and moved them to kernel
DT - https://lore.kernel.org/linux-arm-msm/[email protected]/T/#u
- https://lore.kernel.org/u-boot/[email protected]/

v1: https://lore.kernel.org/u-boot/[email protected]/

---
Varadarajan Narayanan (15):
mach-snapdragon: Kconfig: Auto select options based on configs
mach-snapdragon: Add PBL shared data defines
mach-snapdragon: spl: Add support for boot device detection
mach-snapdragon: spl: Update boot device information in SMEM
mach-snapdragon: spl: Add support for MMC booting in SPL
mach-snapdragon: spl: Setup malloc
mach-snapdragon: Kconfig: Add rules to create SPL images
mach-snapdragon: spl: Load next stage FIT image
mach-snapdragon: spl: Add DDR initialization support
dts: ipq5210-rdp504-u-boot: add override dtsi clk/qcom: add clock driver for ipq5210
pinctrl: qcom: Add ipq5210 pinctrl driver
mach-snapdragon: spl: ipq5210: Add SPL support
configs: Add qcom_ipq5210_mmc_defconfig
doc: board/qualcomm: Update RDP documentation

 arch/arm/Kconfig                                |  12 +-
 arch/arm/dts/ipq5210-rdp504-u-boot.dtsi         |  12 +
 arch/arm/mach-snapdragon/Kconfig                |   7 +
 arch/arm/mach-snapdragon/Makefile               |   1 +
 arch/arm/mach-snapdragon/board_spl.c            | 290 +++++++++++++++++++-
 arch/arm/mach-snapdragon/fit-handler.c          | 324 ++++++++++++++++++++++
 arch/arm/mach-snapdragon/include/mach/pbl.h     |  57 ++++
 arch/arm/mach-snapdragon/include/mach/spl.h     |  14 +
 board/qualcomm/config.mk                        |  23 ++
 board/qualcomm/ipq5210/Makefile                 |   3 +
 board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds |  18 ++
 board/qualcomm/ipq5210/spl-ipq5210.c            |  96 +++++++
 configs/qcom_ipq5210_mmc_defconfig              | 113 ++++++++
 doc/board/qualcomm/index.rst                    |   1 +
 doc/board/qualcomm/rdp.rst                      |  79 +++++-
 doc/board/qualcomm/spl-qclib.rst                |  76 ++++++
 drivers/clk/qcom/Kconfig                        |   8 +
 drivers/clk/qcom/Makefile                       |   1 +
 drivers/clk/qcom/clock-ipq5210.c                |  93 +++++++
 drivers/pinctrl/qcom/Kconfig                    |   8 +
 drivers/pinctrl/qcom/Makefile                   |   1 +
 drivers/pinctrl/qcom/pinctrl-ipq5210.c          | 349 ++++++++++++++++++++++++
 include/configs/ipq5210.h                       |  11 +
 23 files changed, 1575 insertions(+), 22 deletions(-)

---
base-commit: e0ef25054db31fee49d031ac337099b12c67e5b8
change-id: 20260722-spl-v8-3cedfa6b90c5
prerequisite-message-id: [email protected]
prerequisite-patch-id: e06f4f15b24c0a2b5999530d2bd810e8d5d25bc4
prerequisite-message-id: [email protected]
prerequisite-patch-id: 285af4539961420776d05b9785fce0d2c6f59faf
prerequisite-patch-id: fca45ce71c1d698831fa90bfc90b2b00817a6bf2
prerequisite-patch-id: c060a5765abbaaf96aebb1925414796edd42ddb8

Best regards,

Signature · 1 line
Varadarajan Narayanan <[email protected]>
#1 lore raw

PATCH v8 1/15 mach-snapdragon: Kconfig: Auto select options based on configs

The commit 0debfe4801bb ("mach-snapdragon: Kconfig: changes / additions to support SPL") auto selects options that may not be applicable to all platforms. This results in warning messages during make xxx_defconfig and/or waiting for user input for on/off or values for certain configs. So auto select options based on the enabled configs in xxx_defconfig.

Fixes 0debfe4801bb ("mach-snapdragon: Kconfig: changes / additions to support SPL")
---
 arch/arm/Kconfig | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm/Kconfig +6 -6
index f307340e3aa..51d60ef65fe 100644
@@ -1147,8 +1147,8 @@ config ARCH_SNAPDRAGON
 	select SPMI
 	select BOARD_LATE_INIT
 	select OF_BOARD
-	select SAVE_PREV_BL_FDT_ADDR if !ENABLE_ARM_SOC_BOOT0_HOOK
-	select LINUX_KERNEL_IMAGE_HEADER if !ENABLE_ARM_SOC_BOOT0_HOOK
+	select SAVE_PREV_BL_FDT_ADDR if !ENABLE_ARM_SOC_BOOT0_HOOK && !SPL
+	select LINUX_KERNEL_IMAGE_HEADER if !ENABLE_ARM_SOC_BOOT0_HOOK && !SPL
 	select SYSRESET
 	select SYSRESET_PSCI if !SPL
 	select ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR
@@ -1161,12 +1161,12 @@ config ARCH_SNAPDRAGON
 	select ENABLE_ARM_SOC_BOOT0_HOOK if SPL
 	select SPL_DM if SPL
 	select SPL_DM_GPIO if SPL
-	select SPL_DM_PMIC if SPL
-	select SPL_DM_USB_GADGET if SPL
+	select SPL_DM_PMIC if SPL && DM_PMIC
+	select SPL_DM_USB_GADGET if SPL && USB
 	select SPL_ENV_SUPPORT if SPL
 	select SPL_EVENT if SPL
 	select SPL_GPIO if SPL
-	select SPL_HAS_BSS_LINKER_SECTION if SPL
+	select SPL_HAS_BSS_LINKER_SECTION if SPL && SPL_SEPARATE_BSS
 	select SPL_LIBCOMMON_SUPPORT if SPL
 	select SPL_LIBDISK_SUPPORT if SPL
 	select SPL_LIBGENERIC_SUPPORT if SPL
@@ -1181,7 +1181,7 @@ config ARCH_SNAPDRAGON
 	select SPL_SPMI_MSM if SPL
 	select SPL_SPRINTF if SPL
 	select SPL_STRTO if SPL
-	select SPL_USB_GADGET if SPL
+	select SPL_USB_GADGET if SPL && USB
 	imply SPL_MMC if SPL
 	imply OF_UPSTREAM
 	imply CMD_DM
Signature · 1 line
2.34.1
#2 lore raw

PATCH v8 2/15 mach-snapdragon: Add PBL shared data defines

In reply to Varadarajan Narayanan via U-Boot

Add structure and enum definitions to be able to parse the information that is passed from PBL. This will be used to identify the boot medium.

---
 arch/arm/mach-snapdragon/include/mach/pbl.h | 57 +++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm/mach-snapdragon/include/mach/pbl.h new file +57 -0
new file mode 100644
index 00000000000..2e6ad13255c
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __PBL_H__
+#define __PBL_H__
+
+enum pbl_shared_data_param_id {
+	PSD_ID_PBL_FW_VERSION			= 0x0,	/* PBL firmware version */
+	PSD_ID_PBL_PATCH_VERSION		= 0x1,	/* Patch version */
+	PSD_ID_RMB_MBOX_BASE_ADDR		= 0x2,	/* Not used */
+	PSD_ID_CPU_BOOT_SPEED_HZ		= 0x3,	/* CPU boot speed (Hz) */
+	PSD_ID_BOOT_MEDIA_TYPE			= 0x4,	/* Boot media type */
+	PSD_ID_IS_EDL_MODE			= 0x5,	/* Emergency Download mode */
+	PSD_ID_DEV_PROG_ELF_ENTRY_ADDR		= 0x6,	/* Not used */
+	PSD_ID_XBL_CONFIG_ELF_ENTRY_ADDR	= 0x7,	/* Not used */
+	PSD_ID_XBL_SC_EXT_ELF_ENTRY_ADDR	= 0x8,	/* Not used */
+	PSD_ID_PBL_TIMESTAMPS_BUFFER_ADDR	= 0x9,	/* PBL logs address */
+	PSD_ID_PBL_TIMESTAMPS_BUFFER_SIZE	= 0xa,	/* PBL log size */
+	PSD_ID_PBL_DEBUG_SHARED_INFO_ADDR	= 0xb,	/* Debug info address */
+	PSD_ID_PBL_DEBUG_SHARED_INFO_SIZE	= 0xc,	/* Debug info size */
+	PSD_ID_TME_CPU_PBL_ROM_BYPASS_FUSE	= 0xd,	/* Secure boot status */
+	PSD_ID_XBL_SC_DEBUG_LOG_ADDR		= 0xe,	/* XBL SC debug log address */
+	PSD_ID_XBL_SC_DEBUG_LOG_SIZE		= 0xf,	/* XBL SC debug log size */
+	PSD_ID_CURRENT_IMAGE_SET		= 0x10,	/* Booted image set */
+	PSD_ID_MEDIA_DATA_INFO_ADDR		= 0x11,	/* Media info pointer */
+	PSD_ID_MEDIA_DATA_INFO_SIZE		= 0x12,	/* Media info size */
+	PBL_SHARED_DATA_PARAM_MAX,
+};
+
+enum pbl_boot_flash_type {
+	PSD_NO_FLASH		= 0,
+	PSD_NOR_FLASH		= 1,
+	PSD_NAND_FLASH		= 2,
+	PSD_ONENAND_FLASH	= 3,
+	PSD_SDC_FLASH		= 4,
+	PSD_MMC_FLASH		= 5,
+	PSD_SPI_FLASH		= 6,
+	PSD_PCIE_FLASH		= 7,
+	PSD_UFS_FLASH		= 8,
+	PSD_RSVD_1_FLASH	= 9,
+	PSD_USB_FLASH		= 10,
+	PSD_SPI_NAND_FLASH	= 11,
+	PSD_SPI_FLASH_GPT	= 12,
+};
+
+struct pbl_shared_data_entry {
+	u32 param_id;
+	ulong value;
+	bool valid;
+};
+
+struct pbl_shared_data {
+	u32 version;
+	u32 num_of_entries;
+	struct pbl_shared_data_entry entry[PBL_SHARED_DATA_PARAM_MAX];
+};
+
+#endif /* __PBL_H__ */
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v8 02/15] mach-snapdragon: Add PBL shared data defines

Hi Varadarajan,

Quoted 2 lines · Varadarajan Narayanan

Add structure and enum definitions to be able to parse the information that is passed from PBL. This will be used to identify the boot medium.

Please add some version identifier here, or at least a comment indicating roughly which SoC families/generations this will work on. As I understand it older SoCs used a different layout here, and it may change in the future too.

An enum describing the version field in the header would be ideal.

This is a case where I would very much like to see a sensible abstraction around this data structure maybe in its own file so that we can gracefully handle additions and changes to the PBL layout.

To that end, I think it would make sense to have these definitions be private with an API exposed instead so we don't leak these implementation details everywhere.

Thanks,
// Casey

Quoted 72 lines
---
 arch/arm/mach-snapdragon/include/mach/pbl.h | 57 +++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
arch/arm/mach-snapdragon/include/mach/pbl.h new file +57 -0
new file mode 100644
index 00000000000..2e6ad13255c
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __PBL_H__
+#define __PBL_H__
+
+enum pbl_shared_data_param_id {
+	PSD_ID_PBL_FW_VERSION			= 0x0,	/* PBL firmware version */
+	PSD_ID_PBL_PATCH_VERSION		= 0x1,	/* Patch version */
+	PSD_ID_RMB_MBOX_BASE_ADDR		= 0x2,	/* Not used */
+	PSD_ID_CPU_BOOT_SPEED_HZ		= 0x3,	/* CPU boot speed (Hz) */
+	PSD_ID_BOOT_MEDIA_TYPE			= 0x4,	/* Boot media type */
+	PSD_ID_IS_EDL_MODE			= 0x5,	/* Emergency Download mode */
+	PSD_ID_DEV_PROG_ELF_ENTRY_ADDR		= 0x6,	/* Not used */
+	PSD_ID_XBL_CONFIG_ELF_ENTRY_ADDR	= 0x7,	/* Not used */
+	PSD_ID_XBL_SC_EXT_ELF_ENTRY_ADDR	= 0x8,	/* Not used */
+	PSD_ID_PBL_TIMESTAMPS_BUFFER_ADDR	= 0x9,	/* PBL logs address */
+	PSD_ID_PBL_TIMESTAMPS_BUFFER_SIZE	= 0xa,	/* PBL log size */
+	PSD_ID_PBL_DEBUG_SHARED_INFO_ADDR	= 0xb,	/* Debug info address */
+	PSD_ID_PBL_DEBUG_SHARED_INFO_SIZE	= 0xc,	/* Debug info size */
+	PSD_ID_TME_CPU_PBL_ROM_BYPASS_FUSE	= 0xd,	/* Secure boot status */
+	PSD_ID_XBL_SC_DEBUG_LOG_ADDR		= 0xe,	/* XBL SC debug log address */
+	PSD_ID_XBL_SC_DEBUG_LOG_SIZE		= 0xf,	/* XBL SC debug log size */
+	PSD_ID_CURRENT_IMAGE_SET		= 0x10,	/* Booted image set */
+	PSD_ID_MEDIA_DATA_INFO_ADDR		= 0x11,	/* Media info pointer */
+	PSD_ID_MEDIA_DATA_INFO_SIZE		= 0x12,	/* Media info size */
+	PBL_SHARED_DATA_PARAM_MAX,
+};
+
+enum pbl_boot_flash_type {
+	PSD_NO_FLASH		= 0,
+	PSD_NOR_FLASH		= 1,
+	PSD_NAND_FLASH		= 2,
+	PSD_ONENAND_FLASH	= 3,
+	PSD_SDC_FLASH		= 4,
+	PSD_MMC_FLASH		= 5,
+	PSD_SPI_FLASH		= 6,
+	PSD_PCIE_FLASH		= 7,
+	PSD_UFS_FLASH		= 8,
+	PSD_RSVD_1_FLASH	= 9,
+	PSD_USB_FLASH		= 10,
+	PSD_SPI_NAND_FLASH	= 11,
+	PSD_SPI_FLASH_GPT	= 12,
+};
+
+struct pbl_shared_data_entry {
+	u32 param_id;
+	ulong value;
+	bool valid;
+};
+
+struct pbl_shared_data {
+	u32 version;
+	u32 num_of_entries;
+	struct pbl_shared_data_entry entry[PBL_SHARED_DATA_PARAM_MAX];
+};
+
+#endif /* __PBL_H__ */
Signature · 1 line
// Casey (she/her)
#4 lore raw

PATCH v8 3/15 mach-snapdragon: spl: Add support for boot device detection

In reply to Varadarajan Narayanan via U-Boot

Save the boot parameters passed from the boot rom and use that to identify the boot device.

---
 arch/arm/mach-snapdragon/board_spl.c | 63 ++++++++++++++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 3 deletions(-)
arch/arm/mach-snapdragon/board_spl.c +60 -3
index d69f3e8aafe..6ae59481ba9 100644
@@ -5,8 +5,13 @@
  * Copyright (c) 2026 Michael Srba <[email protected]>
  */
 
+#include <asm/system.h>
 #include <hang.h>
+#include <malloc.h>
 #include <spl.h>
+#include <mach/pbl.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 /* in SPL, we always use internal DT */
 int board_fdt_blob_setup(void **fdtp)
@@ -21,10 +26,62 @@ __weak void reset_cpu(void)
 	hang();
 }
 
+static struct pbl_shared_data g_psd __section(".data");
+
+void save_boot_params(ulong r0, ulong r1, ulong r2, ulong r3)
+{
+	unsigned long sctlr;
+	struct pbl_shared_data *psd;
+
+	sctlr = get_sctlr();
+	set_sctlr(sctlr & ~(CR_M));	/* Disable MMU */
+
+	psd = (struct pbl_shared_data *)r0;
+
+	if (!psd || psd->num_of_entries < PBL_SHARED_DATA_PARAM_MAX)
+		goto out;
+
+	memcpy(&g_psd, psd, sizeof(g_psd));
+
+out:
+	save_boot_params_ret();
+}
+
 u32 spl_boot_device(void)
 {
-	/* TODO: check boot reason to support UFS and sdcard */
-	u32 boot_device = BOOT_DEVICE_DFU;
+	struct pbl_shared_data *psd = &g_psd;
+
+#ifdef DEBUG
+	for (int i  = 0; psd && i < psd->num_of_entries; i++) {
+		printf("entry[0x%x] = %d 0x%08x %d\n", i,
+		       psd->entry[i].param_id, psd->entry[i].value,
+		       psd->entry[i].valid);
+	}
+#endif
+
+	if (psd->entry[PSD_ID_IS_EDL_MODE].valid &&
+	    psd->entry[PSD_ID_IS_EDL_MODE].value) {
+		printf("Selected boot device: DFU\n");
+		return BOOT_DEVICE_DFU;
+	}
+
+	if (psd->entry[PSD_ID_BOOT_MEDIA_TYPE].valid) {
+		switch (psd->entry[PSD_ID_BOOT_MEDIA_TYPE].value) {
+		case PSD_MMC_FLASH:
+			printf("Selected boot device: MMC\n");
+			return BOOT_DEVICE_MMC1;
+		case PSD_NOR_FLASH:
+			printf("Selected boot device: NOR\n");
+			return BOOT_DEVICE_NOR;
+		case PSD_NAND_FLASH:
+			printf("Selected boot device: NAND\n");
+			return BOOT_DEVICE_NAND;
+		case PSD_UFS_FLASH:
+			printf("Selected boot device: UFS\n");
+			return BOOT_DEVICE_UFS;
+		}
+	}
 
-	return boot_device;
+	pr_err("No boot device configured\n");
+	return BOOT_DEVICE_NONE;
 }
Signature · 1 line
2.34.1
#5 lore raw

PATCH v8 4/15 mach-snapdragon: spl: Update boot device information in SMEM

In reply to Varadarajan Narayanan via U-Boot

Update the SMEM with the boot device information got from the boot rom.

---
 arch/arm/mach-snapdragon/board_spl.c | 46 ++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +46 -0
index 6ae59481ba9..69a32e5d8cf 100644
@@ -85,3 +85,49 @@ u32 spl_boot_device(void)
 	pr_err("No boot device configured\n");
 	return BOOT_DEVICE_NONE;
 }
+
+#if IS_ENABLED(CONFIG_SPL_SMEM)
+/**
+ * qcom_spl_populate_smem() - Populate shared memory (SMEM) information.
+ * @ctx:	Pointer to the global SPL context.
+ *
+ * This function initializes and populates various SMEM items with boot-related
+ * information, such as flash type, try-mode status, and ATF enable status.
+ * Return: 0 on success, or a negative error code on failure.
+ */
+static int qcom_spl_populate_smem(void *ctx)
+{
+	int ret;
+	size_t size;
+	struct udevice *smem;
+	u32 *fltype;
+
+	ret = uclass_get_device(UCLASS_SMEM, 0, &smem);
+	if (ret) {
+		pr_err("Failed to find SMEM node (%d)\n", ret);
+		return ret;
+	}
+
+	size = sizeof(u32);
+	ret = smem_alloc(smem, -1, SMEM_BOOT_FLASH_TYPE, size);
+	if (ret) {
+		pr_err("Failed to alloc item: SMEM_BOOT_FLASH_TYPE (%d)\n", ret);
+		return ret;
+	}
+
+	fltype = (u32 *)smem_get(smem, -1, SMEM_BOOT_FLASH_TYPE, &size);
+	if (!fltype) {
+		pr_err("Failed to get item: SMEM_BOOT_FLASH_TYPE\n");
+		return -ENOENT;
+	}
+
+	if (IS_ENABLED(CONFIG_SPL_MMC)) {
+		*fltype = SMEM_BOOT_MMC_FLASH;
+		return 0;
+	}
+
+	pr_err("Boot medium not specified\n");
+
+	return -ENOENT;
+}
+#endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH v8 04/15] mach-snapdragon: spl: Update boot device information in SMEM

Quoted 15 lines · Varadarajan Narayanan

Update the SMEM with the boot device information got from the boot rom.

---
 arch/arm/mach-snapdragon/board_spl.c | 46 ++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +0 -0
index 6ae59481ba9..69a32e5d8cf 100644
@@ -85,3 +85,49 @@ u32 spl_boot_device(void)
 	pr_err("No boot device configured\n");

arch/arm/mach-snapdragon/board_spl.c u32 spl_boot_device(void) · line 95

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +8 -0
 	return BOOT_DEVICE_NONE;
 }
+
+#if IS_ENABLED(CONFIG_SPL_SMEM)
+/**
+ * qcom_spl_populate_smem() - Populate shared memory (SMEM) information.
+ * @ctx:	Pointer to the global SPL context.
+ *
+ * This function initializes and populates various SMEM items with boot-related
+ * information, such as flash type, try-mode status, and ATF enable status.

ATF? what? where?

arch/arm/mach-snapdragon/board_spl.c u32 spl_boot_device(void) · line 105

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+ * Return: 0 on success, or a negative error code on failure.
+ */
+static int qcom_spl_populate_smem(void *ctx)
+{
+	int ret;
+	size_t size;
+	struct udevice *smem;
+	u32 *fltype;
+
+	ret = uclass_get_device(UCLASS_SMEM, 0, &smem);

still not rebased on qcom-next

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+	if (ret) {
+		pr_err("Failed to find SMEM node (%d)\n", ret);
+		return ret;
+	}
+
+	size = sizeof(u32);
+	ret = smem_alloc(smem, -1, SMEM_BOOT_FLASH_TYPE, size);
+	if (ret) {
+		pr_err("Failed to alloc item: SMEM_BOOT_FLASH_TYPE (%d)\n", ret);
+		return ret;

arch/arm/mach-snapdragon/board_spl.c u32 spl_boot_device(void) · line 125

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+	}
+
+	fltype = (u32 *)smem_get(smem, -1, SMEM_BOOT_FLASH_TYPE, &size);
+	if (!fltype) {
+		pr_err("Failed to get item: SMEM_BOOT_FLASH_TYPE\n");
+		return -ENOENT;
+	}
+
+	if (IS_ENABLED(CONFIG_SPL_MMC)) {
+		*fltype = SMEM_BOOT_MMC_FLASH;

missing wmb() ?

Quoted 9 lines
arch/arm/mach-snapdragon/board_spl.c +8 -0
+		return 0;
+	}
+
+	pr_err("Boot medium not specified\n");
+
+	return -ENOENT;
+}
+#endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
Signature · 1 line
// Casey (she/her)
#7 lore raw

PATCH v8 5/15 mach-snapdragon: spl: Add support for MMC booting in SPL

In reply to Varadarajan Narayanan via U-Boot

Add routines to enable U-Boot SPL to be able to proceed with the boot from MMC partitions.

---
 arch/arm/mach-snapdragon/board_spl.c | 107 +++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +107 -0
index 69a32e5d8cf..c5e86458616 100644
@@ -131,3 +131,110 @@ static int qcom_spl_populate_smem(void *ctx)
 	return -ENOENT;
 }
 #endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
+
+#if CONFIG_IS_ENABLED(MMC)
+
+#define QCOM_SPL_FIT_IMG_PARTITION	"0:BOOTLDR"
+
+/**
+ * spl_find_partition_info() - Find partition information by name
+ * @uclass_id: Device class ID (UCLASS_MMC)
+ * @device_num: Device number within the class
+ * @part_name: Name of the partition to find
+ * @info: Pointer to store partition information
+ *
+ * This function provides partition lookup logic for MMC.
+ * Return: Partition number on success, negative error code on failure
+ */
+static int spl_find_partition_info(enum uclass_id uclass_id, int device_num,
+				   const char *part_name,
+				   struct disk_partition *info)
+{
+	int ret;
+	struct blk_desc *desc;
+
+	if (!part_name || !info) {
+		printf("Invalid parameters for partition lookup\n");
+		return -EINVAL;
+	}
+
+	/*
+	 * Get block device descriptor
+	 */
+	desc = blk_get_devnum_by_uclass_id(uclass_id, device_num);
+	if (!desc) {
+		printf("Block device not found for class %d, device %d\n",
+		       uclass_id, device_num);
+		return -ENODEV;
+	}
+
+	/*
+	 * Initialize partition table if needed
+	 */
+	if (desc->part_type == PART_TYPE_UNKNOWN) {
+		printf("Initializing partition table\n");
+		/*
+		 * Prefer EFI/GPT
+		 */
+		desc->part_type = PART_TYPE_EFI;
+	}
+
+	/*
+	 * Find partition by name
+	 */
+	ret = part_get_info_by_name(desc, part_name, info);
+	if (ret < 0) {
+		printf("Partition '%s' not found\n", part_name);
+		return -ENOENT;
+	}
+
+	printf("Found partition '%s' at partition number %d\n", part_name, ret);
+	return ret;
+}
+
+/**
+ * spl_mmc_boot_mode() - Determine the boot mode for MMC
+ * @mmc:	Pointer to the MMC device
+ * @boot_device:	Boot device ID
+ *
+ * Return: MMCSD_MODE_RAW to use raw partition access
+ */
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
+{
+	return MMCSD_MODE_RAW;
+}
+
+/**
+ * spl_mmc_boot_partition() - Determine which partition to boot from
+ * @boot_device:	Boot device ID
+ *
+ * Return: Partition number to boot from, or default partition on error
+ */
+int spl_mmc_boot_partition(const u32 boot_device)
+{
+	int ret;
+	struct disk_partition info;
+
+	ret = spl_find_partition_info(UCLASS_MMC, 0, QCOM_SPL_FIT_IMG_PARTITION, &info);
+#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION)
+	if (ret < 0) {
+		printf("Using default MMC partition %d\n",
+		       CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
+		return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
+	}
+#endif
+	return ret;
+}
+
+/**
+ * spl_mmc_get_uboot_raw_sector() - Find the raw sector offset
+ * @mmc:	Pointer to the MMC device
+ * @raw_sect:	Sector
+ *
+ * Return: 0 if the image is at the starting of the partition without any offset.
+ */
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, ulong raw_sect)
+{
+	return 0;
+}
+#endif /* CONFIG_IS_ENABLED(MMC) */
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH v8 05/15] mach-snapdragon: spl: Add support for MMC booting in SPL

Quoted 22 lines · Varadarajan Narayanan

Add routines to enable U-Boot SPL to be able to proceed with the boot from MMC partitions.

---
 arch/arm/mach-snapdragon/board_spl.c | 107 +++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +4 -0
index 69a32e5d8cf..c5e86458616 100644
@@ -131,3 +131,110 @@ static int qcom_spl_populate_smem(void *ctx)
 	return -ENOENT;
 }
 #endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
+
+#if CONFIG_IS_ENABLED(MMC)
+
+#define QCOM_SPL_FIT_IMG_PARTITION	"0:BOOTLDR"

arch/arm/mach-snapdragon/board_spl.c static int qcom_spl_populate_smem(void *ctx) · line 147

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+
+/**
+ * spl_find_partition_info() - Find partition information by name
+ * @uclass_id: Device class ID (UCLASS_MMC)
+ * @device_num: Device number within the class
+ * @part_name: Name of the partition to find
+ * @info: Pointer to store partition information
+ *
+ * This function provides partition lookup logic for MMC.
+ * Return: Partition number on success, negative error code on failure

What's missing in the mmc/part framework for this? This "helper" is called once and doesn't really seem to justify itself, please elaborate.

Quoted 18 lines
arch/arm/mach-snapdragon/board_spl.c +18 -0
+ */
+static int spl_find_partition_info(enum uclass_id uclass_id, int device_num,
+				   const char *part_name,
+				   struct disk_partition *info)
+{
+	int ret;
+	struct blk_desc *desc;
+
+	if (!part_name || !info) {
+		printf("Invalid parameters for partition lookup\n");
+		return -EINVAL;
+	}
+
+	/*
+	 * Get block device descriptor
+	 */
+	desc = blk_get_devnum_by_uclass_id(uclass_id, device_num);
+	if (!desc) {

arch/arm/mach-snapdragon/board_spl.c static int qcom_spl_populate_smem(void *ctx) · line 175

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+		printf("Block device not found for class %d, device %d\n",
+		       uclass_id, device_num);
+		return -ENODEV;
+	}
+
+	/*
+	 * Initialize partition table if needed
+	 */
+	if (desc->part_type == PART_TYPE_UNKNOWN) {
+		printf("Initializing partition table\n");

Not sure if I even want to know what this is a workaround for, why can't this be fixed in the proper place?

Quoted 6 lines
arch/arm/mach-snapdragon/board_spl.c +6 -0
+		/*
+		 * Prefer EFI/GPT
+		 */
+		desc->part_type = PART_TYPE_EFI;
+	}
+

arch/arm/mach-snapdragon/board_spl.c static int qcom_spl_populate_smem(void *ctx) · line 191

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+	/*
+	 * Find partition by name
+	 */
+	ret = part_get_info_by_name(desc, part_name, info);
+	if (ret < 0) {
+		printf("Partition '%s' not found\n", part_name);
+		return -ENOENT;
+	}
+
+	printf("Found partition '%s' at partition number %d\n", part_name, ret);

debug()

Quoted 14 lines
arch/arm/mach-snapdragon/board_spl.c +14 -0
+	return ret;
+}
+
+/**
+ * spl_mmc_boot_mode() - Determine the boot mode for MMC
+ * @mmc:	Pointer to the MMC device
+ * @boot_device:	Boot device ID
+ *
+ * Return: MMCSD_MODE_RAW to use raw partition access
+ */
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
+{
+	return MMCSD_MODE_RAW;
+}

arch/arm/mach-snapdragon/board_spl.c static int qcom_spl_populate_smem(void *ctx) · line 215

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+
+/**
+ * spl_mmc_boot_partition() - Determine which partition to boot from
+ * @boot_device:	Boot device ID
+ *
+ * Return: Partition number to boot from, or default partition on error
+ */
+int spl_mmc_boot_partition(const u32 boot_device)
+{
+	int ret;

this can have a better name than "ret"

arch/arm/mach-snapdragon/board_spl.c static int qcom_spl_populate_smem(void *ctx) · line 219

Quoted 4 lines
arch/arm/mach-snapdragon/board_spl.c +4 -0
+	struct disk_partition info;
+
+	ret = spl_find_partition_info(UCLASS_MMC, 0, QCOM_SPL_FIT_IMG_PARTITION, &info);
+#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION)

This entire function isn't even called unless this config option is enabled, so you can drop this. compile time conditional error checking here is incomprehensible

Quoted 5 lines
arch/arm/mach-snapdragon/board_spl.c +5 -0
+	if (ret < 0) {
+		printf("Using default MMC partition %d\n",
+		       CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
+		return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
+	}

arch/arm/mach-snapdragon/board_spl.c static int qcom_spl_populate_smem(void *ctx) · line 234

Quoted 10 lines
arch/arm/mach-snapdragon/board_spl.c +10 -0
+#endif
+	return ret;
+}
+
+/**
+ * spl_mmc_get_uboot_raw_sector() - Find the raw sector offset
+ * @mmc:	Pointer to the MMC device
+ * @raw_sect:	Sector
+ *
+ * Return: 0 if the image is at the starting of the partition without any offset.

this function API is already documented in the header (same for the others in this file), if you want a comment (definitely nice!) then write a normal one not a doc comment that just rewords the existing API. This is noise.

Quoted 7 lines
arch/arm/mach-snapdragon/board_spl.c +6 -0
+ */
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, ulong raw_sect)
+{
+	return 0;
+}
+#endif /* CONFIG_IS_ENABLED(MMC) */
Signature · 1 line
// Casey (she/her)
#9 lore raw

PATCH v8 6/15 mach-snapdragon: spl: Setup malloc

In reply to Varadarajan Narayanan via U-Boot

Setup the malloc base and limit for the SPL to be able to use the memory allocation APIs.

---
 arch/arm/mach-snapdragon/board_spl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +15 -0
index c5e86458616..25b1779391a 100644
@@ -238,3 +238,18 @@ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, ulong raw_sect)
 	return 0;
 }
 #endif /* CONFIG_IS_ENABLED(MMC) */
+
+void qcom_spl_malloc_init_f(void)
+{
+	if (!CONFIG_IS_ENABLED(SYS_MALLOC_F))
+		return;
+	/*
+	 * Set up by crt0.S
+	 */
+	assert(gd->malloc_base);
+	gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
+	gd->malloc_ptr = 0;
+
+	mem_malloc_init(gd->malloc_base, gd->malloc_limit);
+	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
+}
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH v8 06/15] mach-snapdragon: spl: Setup malloc

Quoted 2 lines · Varadarajan Narayanan

Setup the malloc base and limit for the SPL to be able to use the memory allocation APIs.

no caller? No explanation of when/why/where this will be used?

Quoted 32 lines
---
 arch/arm/mach-snapdragon/board_spl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +15 -0
index c5e86458616..25b1779391a 100644
@@ -238,3 +238,18 @@ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, ulong raw_sect)
 	return 0;
 }
 #endif /* CONFIG_IS_ENABLED(MMC) */
+
+void qcom_spl_malloc_init_f(void)
+{
+	if (!CONFIG_IS_ENABLED(SYS_MALLOC_F))
+		return;
+	/*
+	 * Set up by crt0.S
+	 */
+	assert(gd->malloc_base);
+	gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
+	gd->malloc_ptr = 0;
+
+	mem_malloc_init(gd->malloc_base, gd->malloc_limit);
+	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
+}
Signature · 1 line
// Casey (she/her)
#11 lore raw

PATCH v8 7/15 mach-snapdragon: Kconfig: Add rules to create SPL images

In reply to Varadarajan Narayanan via U-Boot

The boot rom expects the secondary boot loader in MBN format followed by the TME executable. Add rules to board/qualcomm/config.mk to create u-boot-spl.mbn and u-boot-spl.melf.

u-boot-spl.melf is the combined multi-elf file that has u-boot-spl.mbn followed by the TME executable.

Additionally, this patch adds a config option to specify the path of the TME executable to be used to create u-boot-spl.melf.

---
 arch/arm/mach-snapdragon/Kconfig |  7 +++++++
 board/qualcomm/config.mk         | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)
arch/arm/mach-snapdragon/Kconfig +7 -0
index ddded0029ef..f1a6e828c3c 100644
@@ -59,6 +59,13 @@ config QCOM_GENERATE_MBN
 	  New platforms can be added to tools/qcom/mkmbn/mkmbn.py if they aren't already
 	  supported.
 
+config QCOM_TMEL_ELF
+	string "TME Elf to concatenate with U-Boot SPL MBN image"
+	depends on SPL
+	help
+	  Path of the TME Elf file to be concatenated to u-boot.mbn to create
+	  boot rom expected multi-elf image
+
 choice
 	prompt "Qualcomm boot0.h workaround"
 	optional
board/qualcomm/config.mk +23 -0
index 769e4a51ca0..2abecbf8ea5 100644
@@ -12,3 +12,26 @@ quiet_cmd_mkmbn = MBN     $@
 
 u-boot.mbn: u-boot.bin FORCE
 	$(call if_changed,mkmbn)
+
+ifeq ($(CONFIG_QCOM_GENERATE_MBN),y)
+
+quiet_cmd_mksplmbn = SPLMBN     $@
+      cmd_mksplmbn = $(CMD_MKMBN) -o spl/u-boot-spl.mbn -l $(CONFIG_SPL_TEXT_BASE) -s 4 $<
+
+INPUTS-$(CONFIG_SPL) += spl/u-boot-spl.mbn
+
+spl/u-boot-spl.mbn: spl/u-boot-spl.bin FORCE
+	$(call if_changed,mksplmbn)
+
+ifneq ($(wildcard $(CONFIG_QCOM_TMEL_ELF)),)
+
+quiet_cmd_mksplmelf = SPLMELF     $@
+      cmd_mksplmelf = $(CMD_MKMBN) -o spl/u-boot-spl.melf -m spl/u-boot-spl.mbn,$(CONFIG_QCOM_TMEL_ELF) -s 4 $<
+
+INPUTS-$(CONFIG_SPL) += spl/u-boot-spl.melf
+
+spl/u-boot-spl.melf: spl/u-boot-spl.mbn FORCE
+	$(call if_changed,mksplmelf)
+endif	# CONFIG_QCOM_TMEL_ELF
+
+endif	# CONFIG_QCOM_GENERATE_MBN
Signature · 1 line
2.34.1
#12 lore raw

Re: [PATCH v8 07/15] mach-snapdragon: Kconfig: Add rules to create SPL images

Quoted 3 lines · Varadarajan Narayanan

The boot rom expects the secondary boot loader in MBN format followed by the TME executable. Add rules to board/qualcomm/config.mk to create u-boot-spl.mbn and u-boot-spl.melf.

For which SoC families/generations?

Quoted 3 lines

u-boot-spl.melf is the combined multi-elf file that has u-boot-spl.mbn followed by the TME executable.

It's intentional that mkmbn is invoked twice and things are nested?

Quoted 15 lines

Additionally, this patch adds a config option to specify the path of the TME executable to be used to create u-boot-spl.melf.

---
 arch/arm/mach-snapdragon/Kconfig |  7 +++++++
 board/qualcomm/config.mk         | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)
arch/arm/mach-snapdragon/Kconfig +0 -0
index ddded0029ef..f1a6e828c3c 100644

arch/arm/mach-snapdragon/Kconfig config QCOM_GENERATE_MBN · line 64

Quoted 6 lines
arch/arm/mach-snapdragon/Kconfig +3 -0
@@ -59,6 +59,13 @@ config QCOM_GENERATE_MBN
 	  New platforms can be added to tools/qcom/mkmbn/mkmbn.py if they aren't already
 	  supported.
 
+config QCOM_TMEL_ELF
+	string "TME Elf to concatenate with U-Boot SPL MBN image"
+	depends on SPL

depends on QCOM_GENERATE_MBN

Quoted 20 lines
arch/arm/mach-snapdragon/Kconfig +4 -0
+	help
+	  Path of the TME Elf file to be concatenated to u-boot.mbn to create
+	  boot rom expected multi-elf image
+
 choice
 	prompt "Qualcomm boot0.h workaround"
 	optional
board/qualcomm/config.mk +5 -0
index 769e4a51ca0..2abecbf8ea5 100644
@@ -12,3 +12,26 @@ quiet_cmd_mkmbn = MBN     $@
 
 u-boot.mbn: u-boot.bin FORCE
 	$(call if_changed,mkmbn)
+
+ifeq ($(CONFIG_QCOM_GENERATE_MBN),y)
+
+quiet_cmd_mksplmbn = SPLMBN     $@
+      cmd_mksplmbn = $(CMD_MKMBN) -o spl/u-boot-spl.mbn -l $(CONFIG_SPL_TEXT_BASE) -s 4 $<

board/qualcomm/config.mk quiet_cmd_mkmbn = MBN $@ · line 29

Quoted 10 lines
board/qualcomm/config.mk +10 -0
+
+INPUTS-$(CONFIG_SPL) += spl/u-boot-spl.mbn
+
+spl/u-boot-spl.mbn: spl/u-boot-spl.bin FORCE
+	$(call if_changed,mksplmbn)
+
+ifneq ($(wildcard $(CONFIG_QCOM_TMEL_ELF)),)
+
+quiet_cmd_mksplmelf = SPLMELF     $@
+      cmd_mksplmelf = $(CMD_MKMBN) -o spl/u-boot-spl.melf -m spl/u-boot-spl.mbn,$(CONFIG_QCOM_TMEL_ELF) -s 4 $<

you're including u-boot-spl.mbn twice here no??

board/qualcomm/config.mk quiet_cmd_mkmbn = MBN $@ · line 37

Quoted 9 lines
board/qualcomm/config.mk +8 -0
+
+INPUTS-$(CONFIG_SPL) += spl/u-boot-spl.melf
+
+spl/u-boot-spl.melf: spl/u-boot-spl.mbn FORCE
+	$(call if_changed,mksplmelf)
+endif	# CONFIG_QCOM_TMEL_ELF
+
+endif	# CONFIG_QCOM_GENERATE_MBN

I'll try and get around to revieiwng the rest of this series later in the week, no need to respin yet.

Signature · 1 line
// Casey (she/her)
#13 lore raw

Re: [PATCH v8 07/15] mach-snapdragon: Kconfig: Add rules to create SPL images

[...]

Quoted 2 lines

I'll try and get around to revieiwng the rest of this series later in the week, no need to respin yet.

Please let me know if I can respin.

Thanks
Varada

#14 lore raw

PATCH v8 8/15 mach-snapdragon: spl: Load next stage FIT image

In reply to Varadarajan Narayanan via U-Boot

Identify the boot media loader driver and load the FIT image that has the binaries to initialize the DDR, U-Boot proper etc.

---
 arch/arm/mach-snapdragon/board_spl.c | 59 ++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
arch/arm/mach-snapdragon/board_spl.c +59 -0
index 25b1779391a..716a21156e7 100644
@@ -253,3 +253,62 @@ void qcom_spl_malloc_init_f(void)
 	mem_malloc_init(gd->malloc_base, gd->malloc_limit);
 	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
 }
+
+/**
+ * spl_get_load_buffer() - Allocate a cache-aligned buffer for image loading.
+ * @offset:	Offset (unused, typically 0 for SPL).
+ * @size:	Size of the buffer to allocate.
+ *
+ * Return: Pointer to the allocated buffer, or NULL on failure.
+ */
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
+{
+#ifdef CONFIG_SPL_LOAD_FIT_ADDRESS
+	return (void *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+#else
+	return NULL;
+#endif
+}
+
+/**
+ * board_spl_fit_buffer_addr() - Get the address of the FIT image buffer.
+ * @fit_size:	Size of the FIT image.
+ * @sectors:	Number of sectors.
+ * @bl_len:	Block length.
+ *
+ * Return: Address of the FIT image buffer.
+ */
+void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
+{
+	return spl_get_load_buffer(0, sectors * bl_len);
+}
+
+/**
+ * qcom_spl_loader_pre_ddr() - SPL loader for pre-DDR stage.
+ * @boot_device: Type of boot device.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int qcom_spl_loader_pre_ddr(u8 boot_device)
+{
+	struct spl_image_loader *loader, *drv;
+	struct spl_image_info spl_image = { 0 };
+	struct spl_boot_device boot_dev = { .boot_device = boot_device, };
+	int ret = -ENODEV, n_ents;
+
+	drv = ll_entry_start(struct spl_image_loader, spl_image_loader);
+	n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader);
+
+	for (loader = drv; loader && (loader != drv + n_ents); loader++) {
+		if (boot_device != loader->boot_device)
+			continue;
+
+		ret = loader->load_image(&spl_image, &boot_dev);
+		if (!ret)
+			break;
+
+		printf("%s: Error: %d\n", __func__, ret);
+	}
+
+	return ret;
+}
Signature · 1 line
2.34.1
#15 lore raw

PATCH v8 9/15 mach-snapdragon: spl: Add DDR initialization support

In reply to Varadarajan Narayanan via U-Boot

The U-Boot SPL loads the next stage FIT image into internal SRAM. The binaries are 'external' in this FIT image. The SPL has to load the DDR init binary, i.e. qclib and the DDR parameters i.e. qcconfig used by qclib and invoke the qclib. SPL and qclib exchange information using the interface table described in doc/board/qualcomm/interface-table.rst.

---
 arch/arm/mach-snapdragon/Makefile      |   1 +
 arch/arm/mach-snapdragon/fit-handler.c | 324 +++++++++++++++++++++++++++++++++
 2 files changed, 325 insertions(+)
arch/arm/mach-snapdragon/Makefile +1 -0
index 2360b7c658e..f82ffe8f9d1 100644
@@ -7,6 +7,7 @@ obj-y += mem_map.o
 
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-y += board_spl.o
+obj-y += fit-handler.o
 else
 obj-y += board.o
 obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += capsule_update.o
arch/arm/mach-snapdragon/fit-handler.c new file +324 -0

324 lines not on this page · raw message

Signature · 1 line
2.34.1
#16 lore raw

PATCH v8 10/15 dts: ipq5210-rdp504-u-boot: add override dtsi

In reply to Varadarajan Narayanan via U-Boot

Add initial support for the IPQ5210 MMC based RDP platforms. Remove the bootloader@87800000 reserved memory node. U-Boot proper is built to run in this address range. However, configure_reserved_memory() unmaps this address range since no-map is set in bootloader@87800000 resulting in a crash later, when default_environment is accessed in env_set_default().

---
 arch/arm/dts/ipq5210-rdp504-u-boot.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/dts/ipq5210-rdp504-u-boot.dtsi new file +12 -0
new file mode 100644
index 00000000000..5582de9bebb
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IPQ5210 RDP504 board device tree source
+ *
+ * Copyright (c) 2026 The Linux Foundation. All rights reserved.
+ */
+
+/ {
+	reserved-memory {
+		/delete-node/ bootloader@87800000;
+	};
+};
Signature · 1 line
2.34.1
#17 lore raw

PATCH v8 11/15 clk/qcom: add clock driver for ipq5210

In reply to Varadarajan Narayanan via U-Boot

Add clocks and resets for enabling U-Boot on ipq5210 based RDP platforms.

---
 drivers/clk/qcom/Kconfig         |  8 ++++
 drivers/clk/qcom/Makefile        |  1 +
 drivers/clk/qcom/clock-ipq5210.c | 93 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)
drivers/clk/qcom/Kconfig +8 -0
index 95b650831a3..a142890acdd 100644
@@ -31,6 +31,14 @@ config CLK_QCOM_IPQ4019
 	  on the Snapdragon IPQ4019 SoC. This driver supports the clocks
 	  and resets exposed by the GCC hardware block.
 
+config CLK_QCOM_IPQ5210
+	bool "Qualcomm IPQ5210 GCC"
+	select CLK_QCOM
+	help
+	  Say Y here to enable support for the Global Clock Controller
+	  on the Qualcomm IPQ5210 SoC. This driver supports the clocks
+	  and resets exposed by the GCC hardware block.
+
 config CLK_QCOM_IPQ5424
 	bool "Qualcomm IPQ5424 GCC"
 	select CLK_QCOM
drivers/clk/qcom/Makefile +1 -0
index 1adca029b11..8934635fb48 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_CLK_QCOM_SDM845) += clock-sdm845.o
 obj-$(CONFIG_CLK_QCOM_APQ8016) += clock-apq8016.o
 obj-$(CONFIG_CLK_QCOM_APQ8096) += clock-apq8096.o
 obj-$(CONFIG_CLK_QCOM_IPQ4019) += clock-ipq4019.o
+obj-$(CONFIG_CLK_QCOM_IPQ5210) += clock-ipq5210.o
 obj-$(CONFIG_CLK_QCOM_IPQ5424) += clock-ipq5424.o
 obj-$(CONFIG_CLK_QCOM_IPQ9574) += clock-ipq9574.o
 obj-$(CONFIG_CLK_QCOM_MILOS) += clock-milos.o
drivers/clk/qcom/clock-ipq5210.c new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
2.34.1
#18 lore raw

PATCH v8 12/15 pinctrl: qcom: Add ipq5210 pinctrl driver

In reply to Varadarajan Narayanan via U-Boot

Add pinctrl driver for the TLMM block found in the ipq5210 SoC.

---
 drivers/pinctrl/qcom/Kconfig           |   8 +
 drivers/pinctrl/qcom/Makefile          |   1 +
 drivers/pinctrl/qcom/pinctrl-ipq5210.c | 349 +++++++++++++++++++++++++++++++++
 3 files changed, 358 insertions(+)
drivers/pinctrl/qcom/Kconfig +8 -0
index 7dd3782c14b..dbb51cd7fe6 100644
@@ -38,6 +38,14 @@ config PINCTRL_QCOM_IPQ4019
 	  Say Y here to enable support for pinctrl on the IPQ4019 SoC,
 	  as well as the associated GPIO driver.
 
+config PINCTRL_QCOM_IPQ5210
+	bool "Qualcomm IPQ5210 Pinctrl"
+	default y if PINCTRL_QCOM_GENERIC
+	select PINCTRL_QCOM
+	help
+	  Say Y here to enable support for pinctrl on the IPQ5210 SoC,
+	  as well as the associated GPIO driver.
+
 config PINCTRL_QCOM_IPQ5424
 	bool "Qualcomm IPQ5424 Pinctrl"
 	default y if PINCTRL_QCOM_GENERIC
drivers/pinctrl/qcom/Makefile +1 -0
index a7a9ad03569..9fe32fb8fec 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_PINCTRL_QCOM) += pinctrl-qcom.o
 obj-$(CONFIG_PINCTRL_QCOM_APQ8016) += pinctrl-apq8016.o
 obj-$(CONFIG_PINCTRL_QCOM_IPQ4019) += pinctrl-ipq4019.o
+obj-$(CONFIG_PINCTRL_QCOM_IPQ5210) += pinctrl-ipq5210.o
 obj-$(CONFIG_PINCTRL_QCOM_IPQ5424) += pinctrl-ipq5424.o
 obj-$(CONFIG_PINCTRL_QCOM_IPQ9574) += pinctrl-ipq9574.o
 obj-$(CONFIG_PINCTRL_QCOM_APQ8096) += pinctrl-apq8096.o
drivers/pinctrl/qcom/pinctrl-ipq5210.c new file +349 -0

349 lines not on this page · raw message

Signature · 1 line
2.34.1
#19 lore raw

PATCH v8 13/15 mach-snapdragon: spl: ipq5210: Add SPL support

In reply to Varadarajan Narayanan via U-Boot

This patch adds the basic board init routines that invoke the common and mach-snapdragon specific SPL frameworks to proceed with the hand over from boot rom to the next stage i.e. U-Boot proper. This also provides the linker script to generate the SPL image in the format expected by the boot rom.

---
 arch/arm/mach-snapdragon/include/mach/spl.h     | 14 ++++
 board/qualcomm/ipq5210/Makefile                 |  3 +
 board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds | 18 +++++
 board/qualcomm/ipq5210/spl-ipq5210.c            | 96 +++++++++++++++++++++++++
 include/configs/ipq5210.h                       | 11 +++
 5 files changed, 142 insertions(+)
arch/arm/mach-snapdragon/include/mach/spl.h new file +14 -0
new file mode 100644
index 00000000000..9e09bad82bc
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __SPL_H__
+#define __SPL_H__
+
+void qcom_spl_malloc_init_f(void);
+int qcom_spl_loader_pre_ddr(u8 boot_device);
+int qclib_post_process_from_spl(void);
+void qcom_spl_error_handler(void *arg);
+
+#endif /* __SPL_H__ */
board/qualcomm/ipq5210/Makefile new file +3 -0
new file mode 100644
index 00000000000..d808c106524
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SPL) := spl-ipq5210.o
board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds new file +18 -0
new file mode 100644
index 00000000000..f0ced6765da
@@ -0,0 +1,18 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+PHDRS {
+	ptype PT_LOAD FLAGS(0x7);
+}
+
+ENTRY(_entry)
+
+SECTIONS {
+	. = CONFIG_PLATFORM_ELFENTRY;
+	_entry = . ;
+	data : {
+		*(.data)
+		. = ALIGN(4);
+	} :ptype
+}
board/qualcomm/ipq5210/spl-ipq5210.c new file +96 -0

96 lines not on this page · raw message

include/configs/ipq5210.h new file +11 -0
new file mode 100644
index 00000000000..5cbf838af82
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __CONFIGS_IPQ5210_H
+#define __CONFIGS_IPQ5210_H
+
+#include <linux/sizes.h>
+
+#endif
Signature · 1 line
2.34.1
#20 lore raw

PATCH v8 14/15 configs: Add qcom_ipq5210_mmc_defconfig

In reply to Varadarajan Narayanan via U-Boot

Introduce a defconfig for the Qualcomm IPQ5210 SoC based RDPs. Presently supports eMMC.

---
 configs/qcom_ipq5210_mmc_defconfig | 113 +++++++++++++++++++++++++++++++++++++
 1 file changed, 113 insertions(+)
configs/qcom_ipq5210_mmc_defconfig new file +113 -0
new file mode 100644
index 00000000000..56a22ce346a
@@ -0,0 +1,113 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_SYS_INIT_SP_BSS_OFFSET=0x180000
+CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_EVENT=y
+CONFIG_TEXT_BASE=0x87980000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_ENV_SIZE=0x40000
+CONFIG_ENV_OFFSET=0
+CONFIG_DEFAULT_DEVICE_TREE="qcom/ipq5210-rdp504"
+CONFIG_SYS_LOAD_ADDR=0x90000000
+CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+# CONFIG_BOOTSTD is not set
+CONFIG_OF_BOARD_SETUP=y
+CONFIG_USE_PREBOOT=y
+CONFIG_SYS_PBSIZE=1024
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_EFI_PARTITION=y
+CONFIG_OF_LIVE=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_CLK=y
+CONFIG_CLK_QCOM_IPQ5210=y
+CONFIG_MSM_GPIO=y
+# CONFIG_I2C is not set
+# CONFIG_INPUT is not set
+CONFIG_MISC=y
+CONFIG_QCOM_GENI=y
+CONFIG_QCOM_GENI_MINICORE=y
+CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_MMC_SDHCI=y
+# CONFIG_MMC_SDHCI_ADMA_HELPERS is not set
+# CONFIG_MMC_SDHCI_ADMA is not set
+# CONFIG_MMC_SDHCI_ADMA_FORCE_32BIT is not set
+# CONFIG_MMC_SDHCI_ADMA_64BIT is not set
+CONFIG_MMC_SDHCI_MSM=y
+CONFIG_MTD=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_PINCTRL=y
+CONFIG_PINCONF=y
+CONFIG_PINCTRL_QCOM_IPQ5210=y
+CONFIG_DEBUG_UART_MSM_GENI=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_MSM_SERIAL=y
+CONFIG_MSM_GENI_SERIAL=y
+CONFIG_SOC_QCOM=y
+CONFIG_SPL=y
+CONFIG_SPL_FRAMEWORK=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_GPIO=y
+CONFIG_SPL_DM_GPIO=y
+CONFIG_SPL_DM_RESET=y
+CONFIG_SPL_PINCTRL=y
+CONFIG_SPL_CLK=y
+CONFIG_SPL_DRIVERS_MISC=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_SPL_SERIAL=y
+CONFIG_SPL_SMEM=y
+CONFIG_DM_STATS=y
+CONFIG_SPL_SYS_MALLOC_F=y
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x20000
+CONFIG_SPL_SYS_MALLOC=y
+CONFIG_SYS_MALLOC_DEFAULT_TO_INIT=y
+CONFIG_SPL_HAS_CUSTOM_MALLOC_START=y
+CONFIG_SPL_CUSTOM_SYS_MALLOC_ADDR=0x80008000
+CONFIG_SPL_SYS_MALLOC_SIZE=0x20000
+# CONFIG_SPL_SEPARATE_BSS is not set
+# CONFIG_SPL_USE_TINY_PRINTF is not set
+CONFIG_SPL_BSS_MAX_SIZE=0x4000
+CONFIG_SPL_TEXT_BASE=0x08c2e000
+CONFIG_SPL_MAX_SIZE=0x3D000
+CONFIG_SPL_MMC=y
+CONFIG_SPL_MMC_SDHCI_ADMA=y
+CONFIG_SPL_MMC_WRITE=y
+CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x00
+CONFIG_COUNTER_FREQUENCY=24000000
+CONFIG_SPL_STACKPROTECTOR=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_ATF=y
+CONFIG_SPL_ATF_LOAD_IMAGE_V2=y
+CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
+CONFIG_SPL_HAS_LOAD_FIT_ADDRESS=y
+CONFIG_SPL_LOAD_FIT_ADDRESS=0x08cbe000
+# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
+CONFIG_SPL_HAVE_INIT_STACK=y
+CONFIG_SPL_STACK=0x08c2e000
+# CONFIG_SAVE_PREV_BL_FDT_ADDR is not set
+CONFIG_SPL_EVENT=y
+CONFIG_SYS_BOARD="ipq5210"
+CONFIG_SPL_REMAKE_ELF=y
+CONFIG_SPL_REMAKE_ELF_LDSCRIPT="board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds"
+CONFIG_QCOM_TMEL_ELF="../tmel-ipq52xx-patch.elf"
+CONFIG_QCOM_GENERATE_MBN=y
+CONFIG_SYSRESET_PSCI=y
Signature · 1 line
2.34.1
#21 lore raw

PATCH v8 15/15 doc: board/qualcomm: Update RDP documentation

In reply to Varadarajan Narayanan via U-Boot

index.rst:
- Include 'spl-qclib.rst'

rdp.rst:
- Add details about the SPL & U-Boot proper build steps, converting to flashable images, source URLs for the needed binaries and scripts.
- Update author e-mail id.

spl-qclib.rst:
- Describe the SPL - Qualcomm Library (QCLib) interface used to exchange information between U-Boot SPL and QCLib for initializing the DDR.

---
 doc/board/qualcomm/index.rst     |  1 +
 doc/board/qualcomm/rdp.rst       | 79 +++++++++++++++++++++++++++++++++-------
 doc/board/qualcomm/spl-qclib.rst | 76 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+), 13 deletions(-)
doc/board/qualcomm/index.rst +1 -0
index 56b8d894c2a..ddb75c49bcc 100644
@@ -17,3 +17,4 @@ Qualcomm
    rdp
    signing
    spl
+   spl-qclib
doc/board/qualcomm/rdp.rst +66 -13

99 lines not on this page · raw message

doc/board/qualcomm/spl-qclib.rst new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.34.1