All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL
@ 2026-10-19 10:48 Balaji Selvanathan
  2026-10-19 10:48 ` [PATCH v4 1/9] spl: ufs: rename SPL_UFS_SUPPORT config to SPL_UFS Balaji Selvanathan
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:48 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan, Sumit Garg

On Lemans EVK, XBL hands over to U-Boot SPL, which loads the
TFA-OPTEE-U-Boot FIT image from a UFS partition. SPL_UFS
currently only works on the RK3576 boards, which load U-Boot from a
fixed sector.

This series builds the UFS/SCSI core in SPL whenever SPL_UFS is set,
adds the Qualcomm UFS host controller and QMP PHY drivers for SPL, and
lets the SPL UFS loader find U-Boot by partition name or number.

This series does not depend on my other SPL series. It is
build tested on rock-4d-rk3576 and nanopi-m5-rk3576, the two existing
SPL_UFS users.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- Drop the five non-UFS patches (GENI, pinctrl, serial,
  PMIC/SPMI) to be sent separately
- Rewrite the cover letter
- Build scsi/ and ufs/ with CONFIG_$(PHASE_)UFS and drop the
  unconditional "obj-y += ufs/"
- Add a SPL_PARTITION_GET_INFO symbol, selected by its users, instead
  of extending the defined() chain in part.h
- Move the Makefile/Kconfig patches ahead of the loader changes
- Link to v3: https://lore.kernel.org/u-boot/20260615-spl_ufs-v3-0-360bceb29596@oss.qualcomm.com/

Changes in v3:
- Simplified partition selection logic in ufs_load_image_raw_partition
- Removed spl: ufs: add SPL_UFS_FS Kconfig and filesystem boot stub
- Link to v2: https://lore.kernel.org/u-boot/20260606-spl_ufs-v2-0-72fed24ef01b@oss.qualcomm.com/

Changes in v2:
- Renamed SPL_UFS_SUPPORT to SPL_UFS for naming consistency.
- Added SPL_UFS_RAW_U_BOOT_USE_SECTOR config to clearly choose between
  sector or partition
- Refactored the codes in common/spl/spl_ufs.c to use helper functions
  to make the codes readable and clear
- Add the filesystem support in SPL UFS as a seperate patch
- Correct SPL_UFS_SUPPORT config name in lib/Makefile
- Added SPL_QCOM_GENI Kconfig and $(PHASE_) support for GENI
- Added SPL_PINCTRL_QCOM_* symbols and $(PHASE_) Makefile
- Added SPL_MSM_SERIAL and SPL_MSM_GENI_SERIAL Kconfig
- Updated Qualcomm PMIC and SPMI Makefiles to use $(PHASE_)
- Link to v1: https://lore.kernel.org/u-boot/20260409-spl_ufs_only-v1-0-f7e0e243d805@oss.qualcomm.com/

---
Balaji Selvanathan (9):
      spl: ufs: rename SPL_UFS_SUPPORT config to SPL_UFS
      lib: update charset.o build rule to use SPL_UFS
      configs: rename SPL_UFS_SUPPORT to SPL_UFS
      ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support
      phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot
      spl: ufs: add Kconfig choice for U-Boot location method
      part: introduce SPL_PARTITION_GET_INFO and select it from consumers
      spl: add UFS boot mode defines to spl.h
      spl: ufs: add partition-based U-Boot loading support

 common/spl/Kconfig                 |  57 ++++++++++++--
 common/spl/Makefile                |   2 +-
 common/spl/spl_ufs.c               | 153 ++++++++++++++++++++++++++++++++-----
 configs/nanopi-m5-rk3576_defconfig |   2 +-
 configs/rock-4d-rk3576_defconfig   |   2 +-
 disk/Kconfig                       |   8 ++
 drivers/Makefile                   |   3 +-
 drivers/phy/qcom/Kconfig           |   7 ++
 drivers/phy/qcom/Makefile          |   2 +-
 drivers/scsi/Makefile              |   2 +-
 drivers/ufs/Kconfig                |  12 ++-
 drivers/ufs/Makefile               |   4 +-
 include/part.h                     |   4 +-
 include/spl.h                      |   4 +
 lib/Makefile                       |   2 +-
 15 files changed, 224 insertions(+), 40 deletions(-)
---
base-commit: 8d534cec0cc0109a37c0ded8854da03f1526dc0e
change-id: 20260615-spl_ufs-5c2c4eb327aa

Best regards,
-- 
Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v4 1/9] spl: ufs: rename SPL_UFS_SUPPORT config to SPL_UFS
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
@ 2026-10-19 10:48 ` Balaji Selvanathan
  2026-10-19 10:48 ` [PATCH v4 2/9] lib: update charset.o build rule to use SPL_UFS Balaji Selvanathan
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:48 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Rename the Kconfig symbol SPL_UFS_SUPPORT to SPL_UFS to align with
the naming convention used by other SPL storage drivers (e.g.,
SPL_SATA, SPL_MMC). This shorter name also works cleanly with the
$(PHASE_) prefix macro in Makefiles, allowing uniform use of
CONFIG_$(PHASE_)UFS across SPL and TPL build rules.

Remove the unnecessary `depends on UFS` from SPL_UFS. This dependency
is not needed because SPL_UFS is a build-time option that can be
independently controlled.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- Use CONFIG_$(PHASE_)UFS for both scsi/ and ufs/ in drivers/Makefile
  and drop the unconditional "obj-y += ufs/"
- Switch drivers/ufs/Makefile's ufs-uclass.o rule to the $(PHASE_)
  prefix macro

Changes in v3:
- Updated commit description to clarify on why SPL_UFS does not
  need to depend on CONFIG_UFS

Changes in v2:
- newly added in v2
---
 common/spl/Kconfig    | 7 +++----
 common/spl/Makefile   | 2 +-
 drivers/Makefile      | 3 +--
 drivers/scsi/Makefile | 2 +-
 drivers/ufs/Kconfig   | 4 ++--
 drivers/ufs/Makefile  | 2 +-
 6 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 4930ecb0861..c837f831212 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1639,9 +1639,8 @@ config SPL_THERMAL
 	  automatic power-off when the temperature gets too high or low. Other
 	  devices may be discrete but connected on a suitable bus.
 
-config SPL_UFS_SUPPORT
+config SPL_UFS
 	bool "Support loading from UFS"
-	depends on UFS
 	select SPL_LOAD_BLOCK
 	help
 	  Enable support for UFS in SPL. This allows
@@ -1650,7 +1649,7 @@ config SPL_UFS_SUPPORT
 
 config SPL_UFS_RAW_U_BOOT_DEVNUM
 	int "SCSI device number of the UFS device to load U-Boot from"
-	depends on SPL_UFS_SUPPORT
+	depends on SPL_UFS
 	default 0
 	help
 	  UFS devices are usually configured with multiple LUNs, which present
@@ -1663,7 +1662,7 @@ config SPL_UFS_RAW_U_BOOT_DEVNUM
 
 config SPL_UFS_RAW_U_BOOT_SECTOR
 	hex "Address on the UFS to load U-Boot from"
-	depends on SPL_UFS_SUPPORT
+	depends on SPL_UFS
 	default 0x800 if ARCH_ROCKCHIP
 	help
 	  Address on the block device to load U-Boot from.
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 9c94e8f143e..9714ada59f4 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -38,7 +38,7 @@ obj-$(CONFIG_$(PHASE_)DFU) += spl_dfu.o
 obj-$(CONFIG_$(PHASE_)SPI_LOAD) += spl_spi.o
 obj-$(CONFIG_$(PHASE_)RAM_SUPPORT) += spl_ram.o
 obj-$(CONFIG_$(PHASE_)USB_SDP_SUPPORT) += spl_sdp.o
-obj-$(CONFIG_$(PHASE_)UFS_SUPPORT) += spl_ufs.o
+obj-$(CONFIG_$(PHASE_)UFS) += spl_ufs.o
 endif
 
 obj-$(CONFIG_$(PHASE_)UPL) += spl_upl.o
diff --git a/drivers/Makefile b/drivers/Makefile
index ff6853b06a2..5fc72932652 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_$(PHASE_)SERIAL) += serial/
 obj-$(CONFIG_$(PHASE_)SPI) += spi/
 obj-$(CONFIG_$(PHASE_)SPMI) += spmi/
 obj-$(CONFIG_$(PHASE_)TIMER) += timer/
+obj-$(CONFIG_$(PHASE_)UFS) += scsi/ ufs/
 obj-$(CONFIG_$(PHASE_)VIRTIO) += virtio/
 obj-$(CONFIG_$(PHASE_)DM_MAILBOX) += mailbox/
 obj-$(CONFIG_$(PHASE_)REMOTEPROC) += remoteproc/
@@ -77,7 +78,6 @@ obj-$(CONFIG_SPL_USB_HOST) += usb/host/
 obj-$(CONFIG_SPL_SATA) += ata/ scsi/
 obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
 obj-$(CONFIG_SPL_THERMAL) += thermal/
-obj-$(CONFIG_SPL_UFS_SUPPORT) += scsi/ ufs/
 
 endif
 endif
@@ -125,7 +125,6 @@ obj-y += thermal/
 obj-$(CONFIG_TEE) += tee/
 obj-$(CONFIG_ARM_FFA_TRANSPORT) += firmware/arm-ffa/
 obj-y += axi/
-obj-y += ufs/
 obj-$(CONFIG_W1) += w1/
 obj-$(CONFIG_W1_EEPROM) += w1-eeprom/
 
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index c9af60d5d03..6d1f57bf101 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -16,7 +16,7 @@ ifdef CONFIG_XPL_BUILD
 ifdef CONFIG_SPL_SATA
 obj-$(CONFIG_SCSI) += scsi.o scsi-uclass.o
 endif
-ifdef CONFIG_SPL_UFS_SUPPORT
+ifdef CONFIG_SPL_UFS
 obj-$(CONFIG_SCSI) += scsi.o scsi-uclass.o
 endif
 endif
diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig
index 6dffdc00b32..8174a7acc5e 100644
--- a/drivers/ufs/Kconfig
+++ b/drivers/ufs/Kconfig
@@ -78,8 +78,8 @@ config UFS_ROCKCHIP
 	depends on UFS
 	depends on DM_GPIO
 	depends on RESET_ROCKCHIP
-	depends on SPL_DM_GPIO || !SPL_UFS_SUPPORT
-	depends on SPL_RESET_ROCKCHIP || !SPL_UFS_SUPPORT
+	depends on SPL_DM_GPIO || !SPL_UFS
+	depends on SPL_RESET_ROCKCHIP || !SPL_UFS
 	help
 	  This selects the Rockchip specific additions to UFSHCD platform driver.
 
diff --git a/drivers/ufs/Makefile b/drivers/ufs/Makefile
index e7f3c1d30c4..7c1db11be7b 100644
--- a/drivers/ufs/Makefile
+++ b/drivers/ufs/Makefile
@@ -3,7 +3,7 @@
 # Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com
 #
 
-obj-$(CONFIG_UFS) += ufs-uclass.o
+obj-$(CONFIG_$(PHASE_)UFS) += ufs-uclass.o
 obj-$(CONFIG_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
 obj-$(CONFIG_UFS_CADENCE) += cdns-platform.o
 obj-$(CONFIG_UFS_MEDIATEK) += ufs-mediatek.o

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 2/9] lib: update charset.o build rule to use SPL_UFS
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
  2026-10-19 10:48 ` [PATCH v4 1/9] spl: ufs: rename SPL_UFS_SUPPORT config to SPL_UFS Balaji Selvanathan
@ 2026-10-19 10:48 ` Balaji Selvanathan
  2026-10-19 10:58   ` Alexey Charkov
  2026-10-19 10:48 ` [PATCH v4 3/9] configs: rename SPL_UFS_SUPPORT to SPL_UFS Balaji Selvanathan
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:48 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Update lib/Makefile to reference CONFIG_$(PHASE_)UFS instead of
CONFIG_$(PHASE_)UFS_SUPPORT for the charset.o build rule, following
the rename of SPL_UFS_SUPPORT to SPL_UFS.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- No code changes, order of this commit is changed

Changes in v3:
- No changes in v3
---
 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Makefile b/lib/Makefile
index 30092dd4a04..0901804323a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -150,7 +150,7 @@ else
 obj-$(CONFIG_$(PHASE_)SPRINTF) += vsprintf.o
 endif
 obj-$(CONFIG_$(PHASE_)STRTO) += strto.o
-obj-$(CONFIG_$(PHASE_)UFS_SUPPORT) += charset.o
+obj-$(CONFIG_$(PHASE_)UFS) += charset.o
 else
 # Main U-Boot always uses the full printf support
 obj-y += vsprintf.o strto.o

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 3/9] configs: rename SPL_UFS_SUPPORT to SPL_UFS
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
  2026-10-19 10:48 ` [PATCH v4 1/9] spl: ufs: rename SPL_UFS_SUPPORT config to SPL_UFS Balaji Selvanathan
  2026-10-19 10:48 ` [PATCH v4 2/9] lib: update charset.o build rule to use SPL_UFS Balaji Selvanathan
@ 2026-10-19 10:48 ` Balaji Selvanathan
  2026-10-20  8:51   ` Neil Armstrong
  2026-10-19 10:48 ` [PATCH v4 4/9] ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support Balaji Selvanathan
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:48 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Update all board defconfigs to use the renamed SPL_UFS config
symbol instead of SPL_UFS_SUPPORT.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- No changes

Changes in v3:
- Added newly in v3
---
 configs/nanopi-m5-rk3576_defconfig | 2 +-
 configs/rock-4d-rk3576_defconfig   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/nanopi-m5-rk3576_defconfig b/configs/nanopi-m5-rk3576_defconfig
index 88b6d0f9e86..edb71b87a7b 100644
--- a/configs/nanopi-m5-rk3576_defconfig
+++ b/configs/nanopi-m5-rk3576_defconfig
@@ -23,7 +23,7 @@ CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
-CONFIG_SPL_UFS_SUPPORT=y
+CONFIG_SPL_UFS=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_MEMINFO_MAP=y
 CONFIG_CMD_ADC=y
diff --git a/configs/rock-4d-rk3576_defconfig b/configs/rock-4d-rk3576_defconfig
index 93faf09962c..96527c3faa0 100644
--- a/configs/rock-4d-rk3576_defconfig
+++ b/configs/rock-4d-rk3576_defconfig
@@ -23,7 +23,7 @@ CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
-CONFIG_SPL_UFS_SUPPORT=y
+CONFIG_SPL_UFS=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_MEMINFO_MAP=y
 CONFIG_CMD_ADC=y

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 4/9] ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
                   ` (2 preceding siblings ...)
  2026-10-19 10:48 ` [PATCH v4 3/9] configs: rename SPL_UFS_SUPPORT to SPL_UFS Balaji Selvanathan
@ 2026-10-19 10:48 ` Balaji Selvanathan
  2026-10-20  8:52   ` Neil Armstrong
  2026-10-19 10:49 ` [PATCH v4 5/9] phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot Balaji Selvanathan
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:48 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Add a new SPL_UFS_QCOM Kconfig option to allow the Qualcomm UFS
host controller driver to be built for SPL on Snapdragon platforms.

Switch the ufs-qcom.o Makefile rule to use the $(PHASE_) prefix
macro so that the correct config symbol (UFS_QCOM/SPL_UFS_QCOM) is
selected automatically depending on whether SPL or U-Boot proper is
being compiled.

Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- Keep only the ufs-qcom.o $(PHASE_) switch here; the ufs-uclass.o
  switch moved to the first commit in the series
- Drop the stray trailing blank line in drivers/ufs/Makefile

Changes in v3:
- No changes in v3
---
 drivers/ufs/Kconfig  | 8 ++++++++
 drivers/ufs/Makefile | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig
index 8174a7acc5e..1d21dde250b 100644
--- a/drivers/ufs/Kconfig
+++ b/drivers/ufs/Kconfig
@@ -55,6 +55,14 @@ config UFS_QCOM
 	  This selects the platform driver for the UFS host
 	  controller present on Qualcomm Snapdragon SoCs.
 
+config SPL_UFS_QCOM
+	bool "Qualcomm Host Controller driver for UFS in SPL"
+	depends on SPL_UFS && ARCH_SNAPDRAGON
+	help
+	  This selects the platform driver for the UFS host controller
+	  present on Qualcomm Snapdragon SoCs for use in SPL. Enable this
+	  to use UFS as a boot device in SPL on Qualcomm platforms.
+
 config UFS_RENESAS
 	bool "Renesas R-Car S4 UFS Controller support"
 	depends on UFS
diff --git a/drivers/ufs/Makefile b/drivers/ufs/Makefile
index 7c1db11be7b..3b927fc49a3 100644
--- a/drivers/ufs/Makefile
+++ b/drivers/ufs/Makefile
@@ -8,7 +8,7 @@ obj-$(CONFIG_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
 obj-$(CONFIG_UFS_CADENCE) += cdns-platform.o
 obj-$(CONFIG_UFS_MEDIATEK) += ufs-mediatek.o
 obj-$(CONFIG_UFS_PCI) += ufs-pci.o
-obj-$(CONFIG_UFS_QCOM) += ufs-qcom.o
+obj-$(CONFIG_$(PHASE_)UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_UFS_RENESAS) += ufs-renesas.o
 obj-$(CONFIG_UFS_RENESAS_GEN5) += ufs-renesas-rcar-gen5.o
 obj-$(CONFIG_UFS_ROCKCHIP) += ufs-rockchip.o

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 5/9] phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
                   ` (3 preceding siblings ...)
  2026-10-19 10:48 ` [PATCH v4 4/9] ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support Balaji Selvanathan
@ 2026-10-19 10:49 ` Balaji Selvanathan
  2026-10-20  8:52   ` Neil Armstrong
  2026-10-19 10:49 ` [PATCH v4 6/9] spl: ufs: add Kconfig choice for U-Boot location method Balaji Selvanathan
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:49 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan, Sumit Garg

Add a new SPL_PHY_QCOM_QMP_UFS Kconfig option to enable the
Qualcomm QMP UFS PHY driver in SPL on Snapdragon platforms.
This is a prerequisite for UFS boot support in SPL.

Switch the phy-qcom-qmp-ufs.o Makefile rule to use the $(PHASE_)
prefix so the correct config symbol is selected automatically
for both SPL and U-Boot proper builds.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- No changes in v4

Changes in v3:
- No changes in v3
---
 drivers/phy/qcom/Kconfig  | 7 +++++++
 drivers/phy/qcom/Makefile | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/qcom/Kconfig b/drivers/phy/qcom/Kconfig
index 1fdadaccb12..8890854f3f0 100644
--- a/drivers/phy/qcom/Kconfig
+++ b/drivers/phy/qcom/Kconfig
@@ -32,6 +32,13 @@ config PHY_QCOM_QMP_UFS
 	help
 	  Enable this to support the UFS QMP PHY on various Qualcomm chipsets.
 
+config SPL_PHY_QCOM_QMP_UFS
+	bool "Qualcomm QMP UFS PHY driver in SPL"
+	depends on SPL_PHY && ARCH_SNAPDRAGON
+	help
+	  Enable this to support the UFS QMP PHY in SPL on various Qualcomm chipsets.
+	  This is required for UFS boot support in SPL.
+
 config PHY_QCOM_QUSB2
 	bool "Qualcomm USB QUSB2 PHY driver"
 	depends on PHY && ARCH_SNAPDRAGON
diff --git a/drivers/phy/qcom/Makefile b/drivers/phy/qcom/Makefile
index 714013dc572..ec99fab4468 100644
--- a/drivers/phy/qcom/Makefile
+++ b/drivers/phy/qcom/Makefile
@@ -2,7 +2,7 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o
 obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o
 obj-$(CONFIG_PHY_QCOM_QMP_COMBO) += phy-qcom-qmp-combo.o
 obj-$(CONFIG_PHY_QCOM_QMP_PCIE) += phy-qcom-qmp-pcie.o
-obj-$(CONFIG_PHY_QCOM_QMP_UFS) += phy-qcom-qmp-ufs.o
+obj-$(CONFIG_$(PHASE_)PHY_QCOM_QMP_UFS) += phy-qcom-qmp-ufs.o
 obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o
 obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2) += phy-qcom-snps-femto-v2.o
 obj-$(CONFIG_PHY_QCOM_SNPS_EUSB2) += phy-qcom-snps-eusb2.o

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 6/9] spl: ufs: add Kconfig choice for U-Boot location method
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
                   ` (4 preceding siblings ...)
  2026-10-19 10:49 ` [PATCH v4 5/9] phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot Balaji Selvanathan
@ 2026-10-19 10:49 ` Balaji Selvanathan
  2026-10-20  8:53   ` Neil Armstrong
  2026-10-19 10:49 ` [PATCH v4 7/9] part: introduce SPL_PARTITION_GET_INFO and select it from consumers Balaji Selvanathan
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:49 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Replace the single SPL_UFS_RAW_U_BOOT_SECTOR config with a Kconfig
choice that lets the user select how U-Boot is located on the UFS
LUN: by absolute sector offset or by partition.

The sector-based path (SPL_UFS_RAW_U_BOOT_USE_SECTOR) retains the
existing SPL_UFS_RAW_U_BOOT_SECTOR option with an explicit default
of 0x0.

The partition-based path (SPL_UFS_RAW_U_BOOT_USE_PARTITION) adds
SPL_UFS_RAW_U_BOOT_PARTITION_NAME and
SPL_UFS_RAW_U_BOOT_PARTITION_NUM, allowing U-Boot to be loaded by
partition name (tried first) or partition number as a fallback.
SPL_LIBDISK_SUPPORT is automatically selected when this path is
chosen.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- No changes

Changes in v3:
- No changes

Changes in v2:
- Introduce SPL_UFS_RAW_U_BOOT_USE_SECTOR to clearly select between
  sector based or partition based lookup
---
 common/spl/Kconfig | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index c837f831212..a32c5fd11e6 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1660,13 +1660,53 @@ config SPL_UFS_RAW_U_BOOT_DEVNUM
 	  SCSI device number, which might differ from the UFS LUN if you have
 	  multiple SCSI devices attached and recognized by the SPL.
 
-config SPL_UFS_RAW_U_BOOT_SECTOR
-	hex "Address on the UFS to load U-Boot from"
+choice
+	prompt "Method for locating U-Boot on UFS"
 	depends on SPL_UFS
+	default SPL_UFS_RAW_U_BOOT_USE_SECTOR
+
+config SPL_UFS_RAW_U_BOOT_USE_SECTOR
+	bool "UFS raw mode: by sector"
+	help
+	  Use absolute sector number for specifying U-Boot location on UFS LUN.
+	  When selected, SPL_UFS_RAW_U_BOOT_SECTOR specifies the sector offset.
+
+config SPL_UFS_RAW_U_BOOT_USE_PARTITION
+	bool "UFS raw mode: by partition"
+	select SPL_LIBDISK_SUPPORT
+	help
+	  Use a partition for loading U-Boot when using UFS in raw mode.
+	  You can specify either a partition name or partition number.
+
+endchoice
+
+config SPL_UFS_RAW_U_BOOT_SECTOR
+	hex "Sector offset to load U-Boot from in UFS raw mode"
+	depends on SPL_UFS_RAW_U_BOOT_USE_SECTOR
 	default 0x800 if ARCH_ROCKCHIP
+	default 0x0
 	help
-	  Address on the block device to load U-Boot from.
+	  Absolute sector offset on the UFS LUN to load U-Boot from.
 	  Units: UFS sectors (1 sector = 4096 bytes).
+	  Note: Setting this to 0x0 will load from the start of the LUN.
+
+config SPL_UFS_RAW_U_BOOT_PARTITION_NAME
+	string "Partition name to load U-Boot from"
+	depends on SPL_UFS_RAW_U_BOOT_USE_PARTITION
+	help
+	  Name of the partition to load U-Boot from in UFS raw mode.
+	  This is tried before partition number lookup.
+	  Leave empty to skip name-based lookup.
+	  Example: "boot", "uefi", "dtb_a"
+
+config SPL_UFS_RAW_U_BOOT_PARTITION_NUM
+	int "Partition number to load U-Boot from"
+	depends on SPL_UFS_RAW_U_BOOT_USE_PARTITION
+	default 1
+	help
+	  Partition number to load U-Boot from when using UFS raw mode
+	  with partition support. This is used if partition name is not
+	  specified or not found.
 
 config SPL_WATCHDOG
 	bool "Support watchdog drivers"

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 7/9] part: introduce SPL_PARTITION_GET_INFO and select it from consumers
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
                   ` (5 preceding siblings ...)
  2026-10-19 10:49 ` [PATCH v4 6/9] spl: ufs: add Kconfig choice for U-Boot location method Balaji Selvanathan
@ 2026-10-19 10:49 ` Balaji Selvanathan
  2026-10-19 10:49 ` [PATCH v4 8/9] spl: add UFS boot mode defines to spl.h Balaji Selvanathan
  2026-10-19 10:49 ` [PATCH v4 9/9] spl: ufs: add partition-based U-Boot loading support Balaji Selvanathan
  8 siblings, 0 replies; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:49 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

part_get_info_ptr() in include/part.h resolves the .get_info partition
driver hook to a real function or NULL in SPL, depending on a list of
defined() checks for the SPL features that need partition lookups.

Add an SPL_PARTITION_GET_INFO bool symbol in disk/Kconfig and have each
consumer (EXT4, FAT, SquashFS, MMC raw-mode partition and partition
type, and UFS raw-mode partition) select it. Replace the list of checks
in part.h with a single check on CONFIG_SPL_PARTITION_GET_INFO, so a
new SPL boot method only needs to select the symbol to get partition
lookup support.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- Replace the ad-hoc part.h OR-chain check with a proper
  SPL_PARTITION_GET_INFO Kconfig symbol selected by consumers
- Drop Varadarajan's Reviewed-by as the approach changed
---
 common/spl/Kconfig | 6 ++++++
 disk/Kconfig       | 8 ++++++++
 include/part.h     | 4 +---
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index a32c5fd11e6..adeb2ccc7a7 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -575,12 +575,14 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
 config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
 	bool "MMC raw mode: by partition"
 	select SPL_LOAD_BLOCK
+	select SPL_PARTITION_GET_INFO
 	help
 	  Use a partition for loading U-Boot when using MMC/SD in raw mode.
 
 config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE
 	bool "MMC raw mode: by partition type"
 	select SPL_LOAD_BLOCK
+	select SPL_PARTITION_GET_INFO
 	depends on DOS_PARTITION
 	help
 	  Use partition type for specifying U-Boot partition on MMC/SD in
@@ -771,6 +773,7 @@ config SPL_ETH
 config SPL_FS_EXT4
 	bool "Support EXT filesystems"
 	select SPL_CRC16 if EXT4_WRITE
+	select SPL_PARTITION_GET_INFO
 	help
 	  Enable support for EXT2/3/4 filesystems with SPL. This permits
 	  U-Boot (or Linux in Falcon mode) to be loaded from an EXT
@@ -780,6 +783,7 @@ config SPL_FS_EXT4
 config SPL_FS_SQUASHFS
 	bool "Support SquashFS filesystems"
 	select FS_SQUASHFS
+	select SPL_PARTITION_GET_INFO
 	help
 	  Enable support for SquashFS filesystems with SPL. This permits
 	  U-Boot (or Linux in Falcon mode) to be loaded from a SquashFS
@@ -789,6 +793,7 @@ config SPL_FS_SQUASHFS
 config SPL_FS_FAT
 	bool "Support FAT filesystems"
 	select FS_FAT
+	select SPL_PARTITION_GET_INFO
 	help
 	  Enable support for FAT and VFAT filesystems with SPL. This
 	  permits U-Boot (or Linux in Falcon mode) to be loaded from a FAT
@@ -1674,6 +1679,7 @@ config SPL_UFS_RAW_U_BOOT_USE_SECTOR
 config SPL_UFS_RAW_U_BOOT_USE_PARTITION
 	bool "UFS raw mode: by partition"
 	select SPL_LIBDISK_SUPPORT
+	select SPL_PARTITION_GET_INFO
 	help
 	  Use a partition for loading U-Boot when using UFS in raw mode.
 	  You can specify either a partition name or partition number.
diff --git a/disk/Kconfig b/disk/Kconfig
index fc30c13cee2..7a02c48365c 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -26,6 +26,14 @@ config SPL_PARTITIONS
 	  partition table types shold be enabled separately. This adds a
 	  small amount of size to SPL, typically 500 bytes.
 
+config SPL_PARTITION_GET_INFO
+	bool
+	help
+	  Enable this when an SPL boot method needs to look up a partition
+	  by name or number (part_get_info_ptr() resolves to a real
+	  function rather than NULL). Selected by whichever loader needs
+	  partition lookups, rather than being tested for directly.
+
 config TPL_PARTITIONS
 	bool
 	select TPL_SPRINTF
diff --git a/include/part.h b/include/part.h
index 1dc510cb6b1..7c885928b62 100644
--- a/include/part.h
+++ b/include/part.h
@@ -463,9 +463,7 @@ ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
  */
 #ifdef CONFIG_XPL_BUILD
 # define part_print_ptr(x)	NULL
-# if defined(CONFIG_SPL_FS_EXT4) || defined(CONFIG_SPL_FS_FAT) || \
-	defined(CONFIG_SPL_FS_SQUASHFS) || \
-	defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_ANY_PARTITION)
+# if defined(CONFIG_SPL_PARTITION_GET_INFO)
 #  define part_get_info_ptr(x)	x
 # else
 #  define part_get_info_ptr(x)	NULL

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 8/9] spl: add UFS boot mode defines to spl.h
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
                   ` (6 preceding siblings ...)
  2026-10-19 10:49 ` [PATCH v4 7/9] part: introduce SPL_PARTITION_GET_INFO and select it from consumers Balaji Selvanathan
@ 2026-10-19 10:49 ` Balaji Selvanathan
  2026-10-20  8:57   ` Neil Armstrong
  2026-10-19 10:49 ` [PATCH v4 9/9] spl: ufs: add partition-based U-Boot loading support Balaji Selvanathan
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:49 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Add UFS_MODE_RAW and UFS_MODE_FS defines to include/spl.h,
mirroring the existing MMCSD_MODE_* constants. These are used
by spl_ufs_boot_mode() to select between raw sector and
filesystem boot paths in spl_ufs_load().

Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- No changes in v4

Changes in v3:
- No changes in v3
---
 include/spl.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/spl.h b/include/spl.h
index 390d18fd9d5..0b2527ee90d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -29,6 +29,10 @@ struct legacy_img_hdr;
 #define MMCSD_MODE_FS		2
 #define MMCSD_MODE_EMMCBOOT	3
 
+/* UFS boot modes */
+#define UFS_MODE_RAW		1
+#define UFS_MODE_FS		2
+
 struct blk_desc;
 struct legacy_img_hdr;
 struct spl_boot_device;

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 9/9] spl: ufs: add partition-based U-Boot loading support
  2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
                   ` (7 preceding siblings ...)
  2026-10-19 10:49 ` [PATCH v4 8/9] spl: add UFS boot mode defines to spl.h Balaji Selvanathan
@ 2026-10-19 10:49 ` Balaji Selvanathan
  2026-10-20  8:56   ` Neil Armstrong
  8 siblings, 1 reply; 17+ messages in thread
From: Balaji Selvanathan @ 2026-10-19 10:49 UTC (permalink / raw)
  To: u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis,
	Johan Jonker, Casey Connolly, Carlo Caione, Anshul Dalal,
	Petr Hodina, Michael Srba, Jonas Karlman, Quentin Schulz,
	Kever Yang, Varadarajan Narayanan, David Lechner,
	Heinrich Schuchardt, Alexey Charkov, Peng Fan, Daniel Golle,
	Balaji Selvanathan

Refactor spl_ufs.c to support loading U-Boot either from a raw
sector offset or from a named/numbered partition, controlled by
the Kconfig choice introduced in the previous commit.

The monolithic spl_ufs_load_image() is split into helper functions:
ufs_load_image_raw_sector() handles sector-based loading, and
ufs_load_image_raw_partition() resolves the target sector by looking
up a partition name first, falling back to partition number. A new
exported spl_ufs_load() function drives the boot-mode switch and
can be reused by other callers. A weak spl_ufs_boot_mode() hook
allows board code to override the default raw boot mode.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
---
Changes in v4:
- No changes

Changes in v3:
- Renamed h_spl_load_read to spl_ufs_load_read
- Simplified partition selection logic in ufs_load_image_raw_partition

Changes in v2:
- Refactored the codes in common/spl/spl_ufs.c to use helper functions
  to make the codes readable and clear
---
 common/spl/spl_ufs.c | 153 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 134 insertions(+), 19 deletions(-)

diff --git a/common/spl/spl_ufs.c b/common/spl/spl_ufs.c
index cef1843f40f..dc871d0f22f 100644
--- a/common/spl/spl_ufs.c
+++ b/common/spl/spl_ufs.c
@@ -3,15 +3,19 @@
  * (C) Copyright 2025 Alexey Charkov <alchark@gmail.com>
  */
 
+#include <dm.h>
+#include <log.h>
 #include <spl.h>
 #include <spl_load.h>
 #include <scsi.h>
-#include <errno.h>
-#include <image.h>
+#include <part.h>
+#include <blk.h>
 #include <linux/compiler.h>
-#include <log.h>
+#include <errno.h>
 
-static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off, ulong size, void *buf)
+/* Block read callback for spl_load framework */
+static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off,
+			       ulong size, void *buf)
 {
 	struct blk_desc *bd = load->priv;
 	lbaint_t sector = off >> bd->log2blksz;
@@ -20,30 +24,141 @@ static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off, ulong size
 	return blk_dread(bd, sector, count, buf) << bd->log2blksz;
 }
 
-static int spl_ufs_load_image(struct spl_image_info *spl_image,
-			      struct spl_boot_device *bootdev)
+/* Load image from raw sector */
+static int ufs_load_image_raw_sector(struct spl_image_info *spl_image,
+				     struct spl_boot_device *bootdev,
+				     struct blk_desc *bd,
+				     unsigned long sector)
 {
-	unsigned long sector = CONFIG_SPL_UFS_RAW_U_BOOT_SECTOR;
-	int devnum = CONFIG_SPL_UFS_RAW_U_BOOT_DEVNUM;
 	struct spl_load_info load;
+	int ret;
+
+	debug("spl: ufs: loading from sector 0x%lx\n", sector);
+
+	spl_load_init(&load, spl_ufs_load_read, bd, bd->blksz);
+	ret = spl_load(spl_image, bootdev, &load, 0, sector << bd->log2blksz);
+
+	if (ret) {
+		printf("%s: ufs block read error\n", __func__);
+		log_debug("(error=%d)\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+/* Find and load from partition */
+#ifdef CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION
+static int ufs_load_image_raw_partition(struct spl_image_info *spl_image,
+					struct spl_boot_device *bootdev,
+					struct blk_desc *bd)
+{
+	struct disk_partition part_info;
+	int ret = -ENOENT;
+
+	/* Try partition name first if configured */
+#ifdef CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME
+	if (strlen(CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME) > 0) {
+		debug("spl: ufs: trying partition name '%s'\n",
+		      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME);
+		ret = part_get_info_by_name(bd,
+					    CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME,
+					    &part_info);
+		if (ret >= 0)
+			debug("spl: ufs: found partition '%s' at 0x%lx\n",
+			      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME,
+			      (ulong)part_info.start);
+		else
+			debug("spl: ufs: partition name not found: %d\n", ret);
+	}
+#endif
+
+	/* Fall back to partition number if name lookup failed */
+	if (ret < 0 && IS_ENABLED(CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM)) {
+		debug("spl: ufs: trying partition number %d\n",
+		      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM);
+		ret = part_get_info(bd, CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM,
+				    &part_info);
+		if (ret >= 0)
+			debug("spl: ufs: found partition %d at 0x%lx\n",
+			      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM,
+			      (ulong)part_info.start);
+		else
+			debug("spl: ufs: partition number not found: %d\n", ret);
+	}
+
+	if (ret >= 0)
+		return ufs_load_image_raw_sector(spl_image, bootdev, bd,
+						 part_info.start);
+
+	puts("spl: ufs: partition error\n");
+	return ret;
+}
+#endif /* CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION */
+
+u32 __weak spl_ufs_boot_mode(const u32 boot_device)
+{
+	return UFS_MODE_RAW;
+}
+
+int spl_ufs_load(struct spl_image_info *spl_image,
+		 struct spl_boot_device *bootdev,
+		 const char *filename)
+{
+	u32 boot_mode;
+	int ret = 0;
+	int devnum = CONFIG_SPL_UFS_RAW_U_BOOT_DEVNUM;
 	struct blk_desc *bd;
-	int err;
 
-	/* try to recognize storage devices immediately */
-	scsi_scan(false);
+	log_debug("spl: ufs: devnum=%d\n", devnum);
+
+	ret = scsi_scan(false);
+	if (ret) {
+		printf("spl: ufs: scsi scan failed: %d\n", ret);
+		return ret;
+	}
+
 	bd = blk_get_devnum_by_uclass_id(UCLASS_SCSI, devnum);
-	if (!bd)
+	if (!bd) {
+		printf("spl: ufs: could not get device %d\n", devnum);
 		return -ENODEV;
+	}
 
-	spl_load_init(&load, spl_ufs_load_read, bd, bd->blksz);
-	err = spl_load(spl_image, bootdev, &load, 0, sector << bd->log2blksz);
-	if (err) {
-		puts("spl_ufs_load_image: ufs block read error\n");
-		log_debug("(error=%d)\n", err);
-		return err;
+	boot_mode = spl_ufs_boot_mode(bootdev->boot_device);
+	ret = -EINVAL;
+
+	switch (boot_mode) {
+	case UFS_MODE_RAW:
+		debug("spl: ufs: boot mode: raw\n");
+
+#ifdef CONFIG_SPL_UFS_RAW_U_BOOT_USE_SECTOR
+		ret = ufs_load_image_raw_sector(spl_image, bootdev, bd,
+						CONFIG_SPL_UFS_RAW_U_BOOT_SECTOR);
+		if (!ret)
+			return 0;
+#elif defined(CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION)
+		ret = ufs_load_image_raw_partition(spl_image, bootdev, bd);
+		if (!ret)
+			return 0;
+#endif
+		break;
+	default:
+		puts("spl: ufs: wrong boot mode\n");
 	}
 
-	return 0;
+	return ret;
+}
+
+/* SPL load image entry point */
+static int spl_ufs_load_image(struct spl_image_info *spl_image,
+			      struct spl_boot_device *bootdev)
+{
+	return spl_ufs_load(spl_image, bootdev,
+#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+			    CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+#else
+			    NULL);
+#endif
 }
 
 SPL_LOAD_IMAGE_METHOD("UFS", 0, BOOT_DEVICE_UFS, spl_ufs_load_image);

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/9] lib: update charset.o build rule to use SPL_UFS
  2026-10-19 10:48 ` [PATCH v4 2/9] lib: update charset.o build rule to use SPL_UFS Balaji Selvanathan
@ 2026-10-19 10:58   ` Alexey Charkov
  0 siblings, 0 replies; 17+ messages in thread
From: Alexey Charkov @ 2026-10-19 10:58 UTC (permalink / raw)
  To: Balaji Selvanathan
  Cc: u-boot, Simon Glass, Sumit Garg, u-boot-qcom, Tom Rini,
	Neil Armstrong, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Peng Fan, Daniel Golle

Hi Balaji,

On Mon, Oct 19, 2026 at 2:50 PM Balaji Selvanathan
<balaji.selvanathan@oss.qualcomm.com> wrote:
>
> Update lib/Makefile to reference CONFIG_$(PHASE_)UFS instead of
> CONFIG_$(PHASE_)UFS_SUPPORT for the charset.o build rule, following
> the rename of SPL_UFS_SUPPORT to SPL_UFS.
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - No code changes, order of this commit is changed
>
> Changes in v3:
> - No changes in v3
> ---
>  lib/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/Makefile b/lib/Makefile
> index 30092dd4a04..0901804323a 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -150,7 +150,7 @@ else
>  obj-$(CONFIG_$(PHASE_)SPRINTF) += vsprintf.o
>  endif
>  obj-$(CONFIG_$(PHASE_)STRTO) += strto.o
> -obj-$(CONFIG_$(PHASE_)UFS_SUPPORT) += charset.o
> +obj-$(CONFIG_$(PHASE_)UFS) += charset.o

This will probably break bisection - is there any downside to
squashing this patch with the one that drops the *UFS_SUPPORT symbol?
Existing board defconfigs will also change behavior across your three
patches until all are applied, which is probably a bisection problem,
too.

Alternatively you'd probably need to do it in two passes: e.g. first
add a new phase-aware UFS symbol, make UFS_SUPPORT default on it,
switch over the defconfigs, then drop UFS_SUPPORT (or something along
those lines).

Best regards,
Alexey

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 3/9] configs: rename SPL_UFS_SUPPORT to SPL_UFS
  2026-10-19 10:48 ` [PATCH v4 3/9] configs: rename SPL_UFS_SUPPORT to SPL_UFS Balaji Selvanathan
@ 2026-10-20  8:51   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2026-10-20  8:51 UTC (permalink / raw)
  To: Balaji Selvanathan, u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Alexey Charkov, Peng Fan, Daniel Golle

On 10/19/26 12:48, Balaji Selvanathan wrote:
> Update all board defconfigs to use the renamed SPL_UFS config
> symbol instead of SPL_UFS_SUPPORT.
> 
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - No changes
> 
> Changes in v3:
> - Added newly in v3
> ---
>   configs/nanopi-m5-rk3576_defconfig | 2 +-
>   configs/rock-4d-rk3576_defconfig   | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configs/nanopi-m5-rk3576_defconfig b/configs/nanopi-m5-rk3576_defconfig
> index 88b6d0f9e86..edb71b87a7b 100644
> --- a/configs/nanopi-m5-rk3576_defconfig
> +++ b/configs/nanopi-m5-rk3576_defconfig
> @@ -23,7 +23,7 @@ CONFIG_SPL_MAX_SIZE=0x40000
>   CONFIG_SPL_DM_RESET=y
>   CONFIG_SPL_SPI_LOAD=y
>   CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
> -CONFIG_SPL_UFS_SUPPORT=y
> +CONFIG_SPL_UFS=y
>   CONFIG_CMD_MEMINFO=y
>   CONFIG_CMD_MEMINFO_MAP=y
>   CONFIG_CMD_ADC=y
> diff --git a/configs/rock-4d-rk3576_defconfig b/configs/rock-4d-rk3576_defconfig
> index 93faf09962c..96527c3faa0 100644
> --- a/configs/rock-4d-rk3576_defconfig
> +++ b/configs/rock-4d-rk3576_defconfig
> @@ -23,7 +23,7 @@ CONFIG_SPL_MAX_SIZE=0x40000
>   CONFIG_SPL_DM_RESET=y
>   CONFIG_SPL_SPI_LOAD=y
>   CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
> -CONFIG_SPL_UFS_SUPPORT=y
> +CONFIG_SPL_UFS=y
>   CONFIG_CMD_MEMINFO=y
>   CONFIG_CMD_MEMINFO_MAP=y
>   CONFIG_CMD_ADC=y
> 

I think the 3 first patches should be squashed as one once we agree on the changes,

Neil

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 4/9] ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support
  2026-10-19 10:48 ` [PATCH v4 4/9] ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support Balaji Selvanathan
@ 2026-10-20  8:52   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2026-10-20  8:52 UTC (permalink / raw)
  To: Balaji Selvanathan, u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Alexey Charkov, Peng Fan, Daniel Golle

On 10/19/26 12:48, Balaji Selvanathan wrote:
> Add a new SPL_UFS_QCOM Kconfig option to allow the Qualcomm UFS
> host controller driver to be built for SPL on Snapdragon platforms.
> 
> Switch the ufs-qcom.o Makefile rule to use the $(PHASE_) prefix
> macro so that the correct config symbol (UFS_QCOM/SPL_UFS_QCOM) is
> selected automatically depending on whether SPL or U-Boot proper is
> being compiled.
> 
> Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - Keep only the ufs-qcom.o $(PHASE_) switch here; the ufs-uclass.o
>    switch moved to the first commit in the series
> - Drop the stray trailing blank line in drivers/ufs/Makefile
> 
> Changes in v3:
> - No changes in v3
> ---
>   drivers/ufs/Kconfig  | 8 ++++++++
>   drivers/ufs/Makefile | 2 +-
>   2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig
> index 8174a7acc5e..1d21dde250b 100644
> --- a/drivers/ufs/Kconfig
> +++ b/drivers/ufs/Kconfig
> @@ -55,6 +55,14 @@ config UFS_QCOM
>   	  This selects the platform driver for the UFS host
>   	  controller present on Qualcomm Snapdragon SoCs.
>   
> +config SPL_UFS_QCOM
> +	bool "Qualcomm Host Controller driver for UFS in SPL"
> +	depends on SPL_UFS && ARCH_SNAPDRAGON
> +	help
> +	  This selects the platform driver for the UFS host controller
> +	  present on Qualcomm Snapdragon SoCs for use in SPL. Enable this
> +	  to use UFS as a boot device in SPL on Qualcomm platforms.
> +
>   config UFS_RENESAS
>   	bool "Renesas R-Car S4 UFS Controller support"
>   	depends on UFS
> diff --git a/drivers/ufs/Makefile b/drivers/ufs/Makefile
> index 7c1db11be7b..3b927fc49a3 100644
> --- a/drivers/ufs/Makefile
> +++ b/drivers/ufs/Makefile
> @@ -8,7 +8,7 @@ obj-$(CONFIG_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
>   obj-$(CONFIG_UFS_CADENCE) += cdns-platform.o
>   obj-$(CONFIG_UFS_MEDIATEK) += ufs-mediatek.o
>   obj-$(CONFIG_UFS_PCI) += ufs-pci.o
> -obj-$(CONFIG_UFS_QCOM) += ufs-qcom.o
> +obj-$(CONFIG_$(PHASE_)UFS_QCOM) += ufs-qcom.o
>   obj-$(CONFIG_UFS_RENESAS) += ufs-renesas.o
>   obj-$(CONFIG_UFS_RENESAS_GEN5) += ufs-renesas-rcar-gen5.o
>   obj-$(CONFIG_UFS_ROCKCHIP) += ufs-rockchip.o
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 5/9] phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot
  2026-10-19 10:49 ` [PATCH v4 5/9] phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot Balaji Selvanathan
@ 2026-10-20  8:52   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2026-10-20  8:52 UTC (permalink / raw)
  To: Balaji Selvanathan, u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Alexey Charkov, Peng Fan, Daniel Golle, Sumit Garg

On 10/19/26 12:49, Balaji Selvanathan wrote:
> Add a new SPL_PHY_QCOM_QMP_UFS Kconfig option to enable the
> Qualcomm QMP UFS PHY driver in SPL on Snapdragon platforms.
> This is a prerequisite for UFS boot support in SPL.
> 
> Switch the phy-qcom-qmp-ufs.o Makefile rule to use the $(PHASE_)
> prefix so the correct config symbol is selected automatically
> for both SPL and U-Boot proper builds.
> 
> Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
> Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - No changes in v4
> 
> Changes in v3:
> - No changes in v3
> ---
>   drivers/phy/qcom/Kconfig  | 7 +++++++
>   drivers/phy/qcom/Makefile | 2 +-
>   2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/qcom/Kconfig b/drivers/phy/qcom/Kconfig
> index 1fdadaccb12..8890854f3f0 100644
> --- a/drivers/phy/qcom/Kconfig
> +++ b/drivers/phy/qcom/Kconfig
> @@ -32,6 +32,13 @@ config PHY_QCOM_QMP_UFS
>   	help
>   	  Enable this to support the UFS QMP PHY on various Qualcomm chipsets.
>   
> +config SPL_PHY_QCOM_QMP_UFS
> +	bool "Qualcomm QMP UFS PHY driver in SPL"
> +	depends on SPL_PHY && ARCH_SNAPDRAGON
> +	help
> +	  Enable this to support the UFS QMP PHY in SPL on various Qualcomm chipsets.
> +	  This is required for UFS boot support in SPL.
> +
>   config PHY_QCOM_QUSB2
>   	bool "Qualcomm USB QUSB2 PHY driver"
>   	depends on PHY && ARCH_SNAPDRAGON
> diff --git a/drivers/phy/qcom/Makefile b/drivers/phy/qcom/Makefile
> index 714013dc572..ec99fab4468 100644
> --- a/drivers/phy/qcom/Makefile
> +++ b/drivers/phy/qcom/Makefile
> @@ -2,7 +2,7 @@ obj-$(CONFIG_PHY_QCOM_IPQ4019_USB) += phy-qcom-ipq4019-usb.o
>   obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o
>   obj-$(CONFIG_PHY_QCOM_QMP_COMBO) += phy-qcom-qmp-combo.o
>   obj-$(CONFIG_PHY_QCOM_QMP_PCIE) += phy-qcom-qmp-pcie.o
> -obj-$(CONFIG_PHY_QCOM_QMP_UFS) += phy-qcom-qmp-ufs.o
> +obj-$(CONFIG_$(PHASE_)PHY_QCOM_QMP_UFS) += phy-qcom-qmp-ufs.o
>   obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o
>   obj-$(CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2) += phy-qcom-snps-femto-v2.o
>   obj-$(CONFIG_PHY_QCOM_SNPS_EUSB2) += phy-qcom-snps-eusb2.o
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 6/9] spl: ufs: add Kconfig choice for U-Boot location method
  2026-10-19 10:49 ` [PATCH v4 6/9] spl: ufs: add Kconfig choice for U-Boot location method Balaji Selvanathan
@ 2026-10-20  8:53   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2026-10-20  8:53 UTC (permalink / raw)
  To: Balaji Selvanathan, u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Alexey Charkov, Peng Fan, Daniel Golle

On 10/19/26 12:49, Balaji Selvanathan wrote:
> Replace the single SPL_UFS_RAW_U_BOOT_SECTOR config with a Kconfig
> choice that lets the user select how U-Boot is located on the UFS
> LUN: by absolute sector offset or by partition.
> 
> The sector-based path (SPL_UFS_RAW_U_BOOT_USE_SECTOR) retains the
> existing SPL_UFS_RAW_U_BOOT_SECTOR option with an explicit default
> of 0x0.
> 
> The partition-based path (SPL_UFS_RAW_U_BOOT_USE_PARTITION) adds
> SPL_UFS_RAW_U_BOOT_PARTITION_NAME and
> SPL_UFS_RAW_U_BOOT_PARTITION_NUM, allowing U-Boot to be loaded by
> partition name (tried first) or partition number as a fallback.
> SPL_LIBDISK_SUPPORT is automatically selected when this path is
> chosen.
> 
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - No changes
> 
> Changes in v3:
> - No changes
> 
> Changes in v2:
> - Introduce SPL_UFS_RAW_U_BOOT_USE_SECTOR to clearly select between
>    sector based or partition based lookup
> ---
>   common/spl/Kconfig | 46 +++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 43 insertions(+), 3 deletions(-)
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index c837f831212..a32c5fd11e6 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -1660,13 +1660,53 @@ config SPL_UFS_RAW_U_BOOT_DEVNUM
>   	  SCSI device number, which might differ from the UFS LUN if you have
>   	  multiple SCSI devices attached and recognized by the SPL.
>   
> -config SPL_UFS_RAW_U_BOOT_SECTOR
> -	hex "Address on the UFS to load U-Boot from"
> +choice
> +	prompt "Method for locating U-Boot on UFS"
>   	depends on SPL_UFS
> +	default SPL_UFS_RAW_U_BOOT_USE_SECTOR
> +
> +config SPL_UFS_RAW_U_BOOT_USE_SECTOR
> +	bool "UFS raw mode: by sector"
> +	help
> +	  Use absolute sector number for specifying U-Boot location on UFS LUN.
> +	  When selected, SPL_UFS_RAW_U_BOOT_SECTOR specifies the sector offset.
> +
> +config SPL_UFS_RAW_U_BOOT_USE_PARTITION
> +	bool "UFS raw mode: by partition"
> +	select SPL_LIBDISK_SUPPORT
> +	help
> +	  Use a partition for loading U-Boot when using UFS in raw mode.
> +	  You can specify either a partition name or partition number.
> +
> +endchoice
> +
> +config SPL_UFS_RAW_U_BOOT_SECTOR
> +	hex "Sector offset to load U-Boot from in UFS raw mode"
> +	depends on SPL_UFS_RAW_U_BOOT_USE_SECTOR
>   	default 0x800 if ARCH_ROCKCHIP
> +	default 0x0
>   	help
> -	  Address on the block device to load U-Boot from.
> +	  Absolute sector offset on the UFS LUN to load U-Boot from.
>   	  Units: UFS sectors (1 sector = 4096 bytes).
> +	  Note: Setting this to 0x0 will load from the start of the LUN.
> +
> +config SPL_UFS_RAW_U_BOOT_PARTITION_NAME
> +	string "Partition name to load U-Boot from"
> +	depends on SPL_UFS_RAW_U_BOOT_USE_PARTITION
> +	help
> +	  Name of the partition to load U-Boot from in UFS raw mode.
> +	  This is tried before partition number lookup.
> +	  Leave empty to skip name-based lookup.
> +	  Example: "boot", "uefi", "dtb_a"
> +
> +config SPL_UFS_RAW_U_BOOT_PARTITION_NUM
> +	int "Partition number to load U-Boot from"
> +	depends on SPL_UFS_RAW_U_BOOT_USE_PARTITION
> +	default 1
> +	help
> +	  Partition number to load U-Boot from when using UFS raw mode
> +	  with partition support. This is used if partition name is not
> +	  specified or not found.
>   
>   config SPL_WATCHDOG
>   	bool "Support watchdog drivers"
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 9/9] spl: ufs: add partition-based U-Boot loading support
  2026-10-19 10:49 ` [PATCH v4 9/9] spl: ufs: add partition-based U-Boot loading support Balaji Selvanathan
@ 2026-10-20  8:56   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2026-10-20  8:56 UTC (permalink / raw)
  To: Balaji Selvanathan, u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Alexey Charkov, Peng Fan, Daniel Golle

On 10/19/26 12:49, Balaji Selvanathan wrote:
> Refactor spl_ufs.c to support loading U-Boot either from a raw
> sector offset or from a named/numbered partition, controlled by
> the Kconfig choice introduced in the previous commit.
> 
> The monolithic spl_ufs_load_image() is split into helper functions:
> ufs_load_image_raw_sector() handles sector-based loading, and
> ufs_load_image_raw_partition() resolves the target sector by looking
> up a partition name first, falling back to partition number. A new
> exported spl_ufs_load() function drives the boot-mode switch and
> can be reused by other callers. A weak spl_ufs_boot_mode() hook
> allows board code to override the default raw boot mode.
> 
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - No changes
> 
> Changes in v3:
> - Renamed h_spl_load_read to spl_ufs_load_read
> - Simplified partition selection logic in ufs_load_image_raw_partition
> 
> Changes in v2:
> - Refactored the codes in common/spl/spl_ufs.c to use helper functions
>    to make the codes readable and clear
> ---
>   common/spl/spl_ufs.c | 153 ++++++++++++++++++++++++++++++++++++++++++++-------
>   1 file changed, 134 insertions(+), 19 deletions(-)
> 
> diff --git a/common/spl/spl_ufs.c b/common/spl/spl_ufs.c
> index cef1843f40f..dc871d0f22f 100644
> --- a/common/spl/spl_ufs.c
> +++ b/common/spl/spl_ufs.c
> @@ -3,15 +3,19 @@
>    * (C) Copyright 2025 Alexey Charkov <alchark@gmail.com>
>    */
>   
> +#include <dm.h>
> +#include <log.h>
>   #include <spl.h>
>   #include <spl_load.h>
>   #include <scsi.h>
> -#include <errno.h>
> -#include <image.h>
> +#include <part.h>
> +#include <blk.h>
>   #include <linux/compiler.h>
> -#include <log.h>
> +#include <errno.h>
>   
> -static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off, ulong size, void *buf)
> +/* Block read callback for spl_load framework */
> +static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off,
> +			       ulong size, void *buf)
>   {
>   	struct blk_desc *bd = load->priv;
>   	lbaint_t sector = off >> bd->log2blksz;
> @@ -20,30 +24,141 @@ static ulong spl_ufs_load_read(struct spl_load_info *load, ulong off, ulong size
>   	return blk_dread(bd, sector, count, buf) << bd->log2blksz;
>   }
>   
> -static int spl_ufs_load_image(struct spl_image_info *spl_image,
> -			      struct spl_boot_device *bootdev)
> +/* Load image from raw sector */
> +static int ufs_load_image_raw_sector(struct spl_image_info *spl_image,
> +				     struct spl_boot_device *bootdev,
> +				     struct blk_desc *bd,
> +				     unsigned long sector)
>   {
> -	unsigned long sector = CONFIG_SPL_UFS_RAW_U_BOOT_SECTOR;
> -	int devnum = CONFIG_SPL_UFS_RAW_U_BOOT_DEVNUM;
>   	struct spl_load_info load;
> +	int ret;
> +
> +	debug("spl: ufs: loading from sector 0x%lx\n", sector);
> +
> +	spl_load_init(&load, spl_ufs_load_read, bd, bd->blksz);
> +	ret = spl_load(spl_image, bootdev, &load, 0, sector << bd->log2blksz);
> +
> +	if (ret) {
> +		printf("%s: ufs block read error\n", __func__);
> +		log_debug("(error=%d)\n", ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +/* Find and load from partition */
> +#ifdef CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION
> +static int ufs_load_image_raw_partition(struct spl_image_info *spl_image,
> +					struct spl_boot_device *bootdev,
> +					struct blk_desc *bd)
> +{
> +	struct disk_partition part_info;
> +	int ret = -ENOENT;
> +
> +	/* Try partition name first if configured */
> +#ifdef CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME
> +	if (strlen(CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME) > 0) {
> +		debug("spl: ufs: trying partition name '%s'\n",
> +		      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME);
> +		ret = part_get_info_by_name(bd,
> +					    CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME,
> +					    &part_info);
> +		if (ret >= 0)
> +			debug("spl: ufs: found partition '%s' at 0x%lx\n",
> +			      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NAME,
> +			      (ulong)part_info.start);
> +		else
> +			debug("spl: ufs: partition name not found: %d\n", ret);
> +	}
> +#endif
> +
> +	/* Fall back to partition number if name lookup failed */
> +	if (ret < 0 && IS_ENABLED(CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM)) {
> +		debug("spl: ufs: trying partition number %d\n",
> +		      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM);
> +		ret = part_get_info(bd, CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM,
> +				    &part_info);
> +		if (ret >= 0)
> +			debug("spl: ufs: found partition %d at 0x%lx\n",
> +			      CONFIG_SPL_UFS_RAW_U_BOOT_PARTITION_NUM,
> +			      (ulong)part_info.start);
> +		else
> +			debug("spl: ufs: partition number not found: %d\n", ret);
> +	}
> +
> +	if (ret >= 0)
> +		return ufs_load_image_raw_sector(spl_image, bootdev, bd,
> +						 part_info.start);
> +
> +	puts("spl: ufs: partition error\n");
> +	return ret;
> +}
> +#endif /* CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION */
> +
> +u32 __weak spl_ufs_boot_mode(const u32 boot_device)
> +{
> +	return UFS_MODE_RAW;
> +}
> +
> +int spl_ufs_load(struct spl_image_info *spl_image,
> +		 struct spl_boot_device *bootdev,
> +		 const char *filename)
> +{
> +	u32 boot_mode;
> +	int ret = 0;
> +	int devnum = CONFIG_SPL_UFS_RAW_U_BOOT_DEVNUM;
>   	struct blk_desc *bd;
> -	int err;
>   
> -	/* try to recognize storage devices immediately */
> -	scsi_scan(false);
> +	log_debug("spl: ufs: devnum=%d\n", devnum);
> +
> +	ret = scsi_scan(false);
> +	if (ret) {
> +		printf("spl: ufs: scsi scan failed: %d\n", ret);
> +		return ret;
> +	}
> +
>   	bd = blk_get_devnum_by_uclass_id(UCLASS_SCSI, devnum);
> -	if (!bd)
> +	if (!bd) {
> +		printf("spl: ufs: could not get device %d\n", devnum);
>   		return -ENODEV;
> +	}
>   
> -	spl_load_init(&load, spl_ufs_load_read, bd, bd->blksz);
> -	err = spl_load(spl_image, bootdev, &load, 0, sector << bd->log2blksz);
> -	if (err) {
> -		puts("spl_ufs_load_image: ufs block read error\n");
> -		log_debug("(error=%d)\n", err);
> -		return err;
> +	boot_mode = spl_ufs_boot_mode(bootdev->boot_device);
> +	ret = -EINVAL;
> +
> +	switch (boot_mode) {
> +	case UFS_MODE_RAW:
> +		debug("spl: ufs: boot mode: raw\n");
> +
> +#ifdef CONFIG_SPL_UFS_RAW_U_BOOT_USE_SECTOR
> +		ret = ufs_load_image_raw_sector(spl_image, bootdev, bd,
> +						CONFIG_SPL_UFS_RAW_U_BOOT_SECTOR);
> +		if (!ret)
> +			return 0;
> +#elif defined(CONFIG_SPL_UFS_RAW_U_BOOT_USE_PARTITION)
> +		ret = ufs_load_image_raw_partition(spl_image, bootdev, bd);
> +		if (!ret)
> +			return 0;
> +#endif
> +		break;
> +	default:
> +		puts("spl: ufs: wrong boot mode\n");

What's the point of introducing the boot_mode logic with UFS_MODE_FS and not
implementing it ?

Just drop spl_ufs_boot_mode, the defines and just stick with the UFS_MODE_RAW
by default and add support for that in a separate patches when needed by
an implementation.

Neil

>   	}
>   
> -	return 0;
> +	return ret;
> +}
> +
> +/* SPL load image entry point */
> +static int spl_ufs_load_image(struct spl_image_info *spl_image,
> +			      struct spl_boot_device *bootdev)
> +{
> +	return spl_ufs_load(spl_image, bootdev,
> +#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
> +			    CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
> +#else
> +			    NULL);
> +#endif
>   }
>   
>   SPL_LOAD_IMAGE_METHOD("UFS", 0, BOOT_DEVICE_UFS, spl_ufs_load_image);
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 8/9] spl: add UFS boot mode defines to spl.h
  2026-10-19 10:49 ` [PATCH v4 8/9] spl: add UFS boot mode defines to spl.h Balaji Selvanathan
@ 2026-10-20  8:57   ` Neil Armstrong
  0 siblings, 0 replies; 17+ messages in thread
From: Neil Armstrong @ 2026-10-20  8:57 UTC (permalink / raw)
  To: Balaji Selvanathan, u-boot, Simon Glass, Sumit Garg, u-boot-qcom
  Cc: Tom Rini, Bhupesh Sharma, Neha Malcom Francis, Johan Jonker,
	Casey Connolly, Carlo Caione, Anshul Dalal, Petr Hodina,
	Michael Srba, Jonas Karlman, Quentin Schulz, Kever Yang,
	Varadarajan Narayanan, David Lechner, Heinrich Schuchardt,
	Alexey Charkov, Peng Fan, Daniel Golle

On 10/19/26 12:49, Balaji Selvanathan wrote:
> Add UFS_MODE_RAW and UFS_MODE_FS defines to include/spl.h,
> mirroring the existing MMCSD_MODE_* constants. These are used
> by spl_ufs_boot_mode() to select between raw sector and
> filesystem boot paths in spl_ufs_load().
> 
> Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
> ---
> Changes in v4:
> - No changes in v4
> 
> Changes in v3:
> - No changes in v3
> ---
>   include/spl.h | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/include/spl.h b/include/spl.h
> index 390d18fd9d5..0b2527ee90d 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -29,6 +29,10 @@ struct legacy_img_hdr;
>   #define MMCSD_MODE_FS		2
>   #define MMCSD_MODE_EMMCBOOT	3
>   
> +/* UFS boot modes */
> +#define UFS_MODE_RAW		1
> +#define UFS_MODE_FS		2
> +
>   struct blk_desc;
>   struct legacy_img_hdr;
>   struct spl_boot_device;
> 

Drop this patch and add them when needed

Neil

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-10-20  8:57 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 10:48 [PATCH v4 0/9] spl: ufs: add UFS boot support for Qualcomm Snapdragon in SPL Balaji Selvanathan
2026-10-19 10:48 ` [PATCH v4 1/9] spl: ufs: rename SPL_UFS_SUPPORT config to SPL_UFS Balaji Selvanathan
2026-10-19 10:48 ` [PATCH v4 2/9] lib: update charset.o build rule to use SPL_UFS Balaji Selvanathan
2026-10-19 10:58   ` Alexey Charkov
2026-10-19 10:48 ` [PATCH v4 3/9] configs: rename SPL_UFS_SUPPORT to SPL_UFS Balaji Selvanathan
2026-10-20  8:51   ` Neil Armstrong
2026-10-19 10:48 ` [PATCH v4 4/9] ufs: qcom: add SPL_UFS_QCOM Kconfig and SPL build support Balaji Selvanathan
2026-10-20  8:52   ` Neil Armstrong
2026-10-19 10:49 ` [PATCH v4 5/9] phy: qcom: add SPL_PHY_QCOM_QMP_UFS for SPL UFS boot Balaji Selvanathan
2026-10-20  8:52   ` Neil Armstrong
2026-10-19 10:49 ` [PATCH v4 6/9] spl: ufs: add Kconfig choice for U-Boot location method Balaji Selvanathan
2026-10-20  8:53   ` Neil Armstrong
2026-10-19 10:49 ` [PATCH v4 7/9] part: introduce SPL_PARTITION_GET_INFO and select it from consumers Balaji Selvanathan
2026-10-19 10:49 ` [PATCH v4 8/9] spl: add UFS boot mode defines to spl.h Balaji Selvanathan
2026-10-20  8:57   ` Neil Armstrong
2026-10-19 10:49 ` [PATCH v4 9/9] spl: ufs: add partition-based U-Boot loading support Balaji Selvanathan
2026-10-20  8:56   ` Neil Armstrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.