Skip to content

[qcom-next] Add memory node device tree fixup infrastructure#53

Open
aswinm94 wants to merge 35 commits into
qualcomm-linux:qcom-nextfrom
aswinm94:ddr-mem
Open

[qcom-next] Add memory node device tree fixup infrastructure#53
aswinm94 wants to merge 35 commits into
qualcomm-linux:qcom-nextfrom
aswinm94:ddr-mem

Conversation

@aswinm94
Copy link
Copy Markdown

of_live: dts: Add runtime memory node fixup from SMEM

Implement a minimal OF_LIVE fixup to populate the memory node
reg property at runtime using memory ranges obtained from SMEM.

On Qualcomm Snapdragon platforms, the usable physical memory
layout cannot be fully described in the kernel DTS, as it depends
on firmware carve‑outs and platform configuration determined at
runtime. This fixup ensures the kernel receives an accurate
memory map during boot.

upstream-link: https://lore.kernel.org/all/20260113115404.1448759-1-aswin.murugan@oss.qualcomm.com/#t

This PR drops the Add cached SMEM socinfo accessor api patch & SMEM cache infra from the series, these were added as part of FIT DTB Change

aswinm94 and others added 30 commits April 28, 2026 09:40
Add initial support for the lemans EVK platform based on lemans SoC.
Define memory layout statically.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Signed-off-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Add clock support for SDCC1 (eMMC) and SDCC2 (SD card) controllers
on QCS615 platform. This enables proper clock configuration for both
storage interfaces.

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>
The block device removable flag should reflect whether the MMC
device is physically removable (SD card) or soldered (eMMC). This
information is specified in the device tree via the "non-removable"
property and stored in the MMC_CAP_NONREMOVABLE capability flag.

Update the removable flag in the block device descriptor during
controller probe to properly reflect the device's removable status.
This allows the block layer and upper layers (particularly EFI boot
manager) to distinguish between eMMC and SD cards for appropriate
handling.

The default removable=1 is set in mmc_bind(), and this change
overrides it only for non-removable devices after mmc_of_parse()
has set the MMC_CAP_NONREMOVABLE capability from the device tree.

Reviewed-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
…r timeout

Set CONFIG_SYS_MMC_MAX_BLK_COUNT to 16384 blocks to limit the
maximum transfer size per operation. This prevents controller timeouts.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
NVMEM cells currently only support byte-level access. Many hardware
registers pack multiple fields into single bytes, requiring bit-level
granularity. For example, Qualcomm PMIC PON registers store a 7-bit
reboot reason field within a single byte, with bit 0 reserved for other
purposes.

Add support for the optional 'bits' property in NVMEM cell device tree
bindings. This property specifies <bit_offset num_bits> to define a bit
field within the cell's register space.

Implement bit‑field handling in the driver to max u32 size

Example device tree usage:
        reboot-reason@48 {
                reg = <0x48 0x01>;
                bits = <0x01 0x07>;  /* 7 bits starting at bit 1 */
        };

This reads bits [7:1] from the byte at offset 0x48, leaving bit 0
untouched during write operations.

Cells without the 'bits' property continue to work unchanged, ensuring
backward compatibility with existing device trees.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Qualcomm PMICs include SDAM (Shared Direct Access Memory) regions which
are used to store persistent data like reboot reasons that must survive
across reboots.

Without this driver, U-Boot cannot access PMIC storage, preventing
reboot-to-bootloader functionality and other features that rely on
persistent state.

Add qcom-spmi-sdam driver that:
- Probes SDAM regions from device tree compatible "qcom,spmi-sdam"
- Implements NVMEM provider interface for standard cell-based access
- Uses SPMI register read/write operations for data access

This enables reboot-mode and other subsystems to access PMIC storage
through standard NVMEM APIs.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Add REBOOT_MODE_ENV_UPDATE Kconfig option and implement
automatic reboot-mode env variable update at last stage init.

When enabled, the reboot-mode uclass registers an
EVT_LAST_STAGE_INIT event handler that probes the first
reboot-mode device and calls dm_reboot_mode_update() to set
the reboot-mode environment variable.

EVT_LAST_STAGE_INIT fires after the environment is fully
initialized.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Update preboot to check the reboot-mode environment variable
and automatically enter fastboot mode when the reboot reason
is "bootloader". This enables 'adb reboot bootloader'
functionality on Qualcomm platforms.

The reboot-mode variable is set by the reboot-mode uclass
via EVT_LAST_STAGE_INIT before preboot runs.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Enable reboot-mode functionality for all Qualcomm platforms that define
reboot-mode device tree nodes. The drivers gracefully handle platforms
without reboot-mode configuration, making it safe to enable globally.

Add config options:
  CONFIG_DM_REBOOT_MODE=y       - Core reboot-mode framework
  CONFIG_REBOOT_MODE_NVMEM=y    - NVMEM-based storage backend
  CONFIG_QCOM_SPMI_SDAM=y       - Qualcomm PMIC SDAM/PON access
  CONFIG_REBOOT_MODE_ENV_UPDATE=y - Auto-update reboot-mode env

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Add a mock I2C EEPROM device (nvmem-test@50) to the sandbox device tree
to support NVMEM bit field operation testing.

Add test coverage for NVMEM bit field read and write operations to
validate the new bit field support in the NVMEM subsystem.

Test cases include:
- 1-byte cell with 7-bit field (Qualcomm SDAM reboot reason use case)
- 2-byte cell with 12-bit field spanning a byte boundary
- 4-byte cell without a bit field (legacy byte-level access)
- 4-byte cell with a 16-bit field in the upper 2 bytes

Error validation tests cover:
- Bit field exceeding the cell size
- Bit field exceeding the 32-bit maximum
- Invalid bit_offset and nbits combinations
- Buffer size mismatch in non-bit-field mode

The tests verify:
- Correct bit extraction during read operations
- Read-modify-write behavior preserving unrelated bits
- Proper error handling for invalid configurations

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Update the nvmem_cell_read() and nvmem_cell_write() documentation to
describe the new bit field operation mode.

The documentation now clearly explains:

For bit field mode (nbits > 0):
- Read: extracts the bit field from raw hardware bytes
- Write: performs read-modify-write to preserve other bits
- Requirements: buffer size must be sizeof(u32), cell size <= 4 bytes

For non-bit-field mode (nbits == 0):
- Read/Write: direct byte-level access
- Requirements: buffer size must equal the cell size

This helps developers understand when to use each mode and the
associated buffer size requirements.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
The PM8150 PMIC on this platform uses the older PON (Power On) register
architecture rather than dedicated SDAM regions found in newer PMIC
generations. To enable reboot-mode functionality with the unified
NVMEM-based approach, add a compatibility wrapper that exposes PON
registers through the SDAM NVMEM interface.

Add device tree configuration:
- NVMEM node with compatible "qcom,spmi-sdam" wrapping PON registers
- Uses 'ranges' property to map the PON register block at offset 0x800
- NVMEM cell at offset 0x8F (PON_SOFT_RB_SPARE register)
- 7-bit field (bits [7:1]) for reboot reason, preserving bit 0
- Mode mappings: bootloader=0x02, recovery=0x01

This wrapper allows the SDAM NVMEM driver to access PON registers
transparently, providing a unified interface for both PON-based (older)
and SDAM-based (newer) PMIC generations.

The PON_SOFT_RB_SPARE register persists across warm resets and is
automatically cleared on power cycle.

This will be maintained in uboot untill it is upstreamed in kernel dts

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Reorder compatible strings in stub_clk_ids to maintain alphabetical
order for easier maintenance.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add RPMH clock compatible strings for QCS615 and SA8775P
SoCs to enable clock framework support on these platforms.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add UFS clock support for SA8775P including register definitions,
rate configuration, and gate clocks.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add UFS clock support for qcs615 including register definitions,
rate configuration, and gate clocks.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add UFS clock support for sc7280 including register definitions,
rate configuration, and gate clocks.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Move UFS clock initialization and enabling before hardware setup
to ensure clocks are running when accessing UFS registers.

Previously, U-Boot depended on earlier bootloader stages to
initialize UFS clocks. When these bootloaders failed to do so,
UFS registers became inaccessible, causing initialization to fail.
This change makes U-Boot initialize and enable UFS clocks early
in the init sequence, removing the dependency on previous
bootloaders.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
The ufs_qcom_init() function was calling ufs_qcom_setup_clocks() with
POST_CHANGE twice. The first call after setting PA_TXHSADAPTTYPE
correctly enables the device reference clock. The second call after
ufs_qcom_advertise_quirks() is redundant as the clock is already
enabled.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Implement device selection syntax allowing users to specify the
target block device using "N:partition" format, where N is the
device number. When no device is specified, the default from
CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID is used.

Modify fastboot_block_get_part_info() to use the new parsing
function, enabling operations like "fastboot flash 0:boot boot.img"
to write to specific devices while maintaining backward compatibility
with the existing "fastboot flash boot boot.img" syntax.

Example usage:
  fastboot flash 0:boot boot.img      # Flash to device 0
  fastboot flash 1:system system.img  # Flash to device 1
  fastboot flash boot boot.img        # Use default device

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add fastboot_flash_gpt_partition_table() and
fastboot_flash_mbr_partition_table() helper functions that handle
flashing of GPT and MBR partition tables to block devices.

The MMC backend now uses these helper functions for GPT and MBR
operations, simplifying the code while maintaining the same
functionality.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add support for flashing GPT and MBR partition tables to the
fastboot block backend. This enables operations like "fastboot flash
gpt gpt.img" and "fastboot flash mbr mbr.img" for block devices.

The implementation validates partition table names and rejects
invalid input formats such as ":gpt" or ":mbr" where the device
prefix is missing. Valid formats include "gpt", "mbr", "0:gpt",
and "1:mbr".

Update Kconfig dependencies to allow FASTBOOT_GPT_NAME and
FASTBOOT_MBR_NAME to work with both MMC and block backends.`

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add documentation for the device selection syntax in fastboot
block device operations. Users can now specify target devices
using "N:partition" format where N is the device number.

Document usage examples for regular partition operations like
"fastboot flash 0:boot boot.img" and partition table operations
like "fastboot flash 1:gpt gpt.img". When no device number is
specified, the default from CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID
is used.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Rename qcom_qcs9100_defconfig to qcom_lemans_defconfig
and update the defconfig to select lemans-evk DTS instead
of qcs9100-ride-r3.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Replace MMC-specific fastboot flash configuration with generic
block device support for Qualcomm platforms. This change switches
from MMC device 0 to SCSI interface with device ID 4, enabling
fastboot operations on UFS storage instead of eMMC.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Introduce part_get_info_by_type_guid() function to enable partition
lookup using partition type GUID. This complements the existing UUID
lookup functionality and provides more flexible partition discovery
mechanisms.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Introduce scsi_get_blk_by_type_guid() function to enable SCSI
partition discovery using partition type GUID. This function scans
all available SCSI devices and searches for a partition matching the
specified type GUID.

Reviewed-by: Simon Glass <simon.glass@canonical.com>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Compute blk_find_max_devnum(UCLASS_SCSI) only once instead of
on every loop iteration for better performance.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Change the default value from integer 0 to string "0" to match
the string type of the configuration option.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add support for locating SCSI environment partition using GPT type
GUID.

Introduce a Kconfig choice statement to select between three
mutually exclusive partition lookup methods: UUID-based (default),
type GUID-based, and hardware partition number.

Reorganize existing configs to depend on their respective choice
options. Update ENV_IS_IN_SCSI help text to document the
new configuration structure.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
balajiselvanathan and others added 5 commits April 29, 2026 06:07
Update env/scsi.c to support the new partition selection methods
introduced in the Kconfig. Replace runtime string checks with
compile-time preprocessor conditionals.

Implement support for all three partition selection methods:
- TYPE_GUID: Uses scsi_get_blk_by_type_guid()
- UUID: Uses scsi_get_blk_by_uuid()
- HW: Uses blk_get_device_part_str()

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Enable CONFIG_PARTITION_TYPE_GUID and configure SCSI environment
partition type GUID for QCS9100, QCM6490 and QCS615 configurations.
This allows these platforms to locate the environment partition
using GPT type GUID instead of UUID.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add a unit test for the partition type GUID lookup functionality. The
test verifies that partitions can be correctly identified by their type
GUID, specifically testing the ChromeOS kernel partition lookup.

Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
Add device tree DDR configuration fixup handler
infrastructure to support runtime dts modifications.

DDR info fixup (qcom_fixup_ddrinfo.c)
   - Adds DDR configuration information like DDR size.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Integrate the device tree fixup handlers into ft_board_setup() to
enable runtime device tree modifications for Qualcomm Snapdragon
platforms.

This patch adds:

1. ft_board_setup() implementation
   - Calls all registered fixup handlers
   - Provides central point for device tree modifications
   - Executes before passing DT to kernel

2. fixup_dt_node() utility function
   - Generic device tree node manipulation helper
   - Supports multiple operation types:
     * APPEND_PROP_U32/U64: Append 32/64-bit properties
     * SET_PROP_U32/U64/STRING: Set property values
     * ADD_SUBNODE: Add new device tree nodes
   - Automatically adjusts FDT size as needed

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
@b49020
Copy link
Copy Markdown
Member

b49020 commented May 5, 2026

#56 should be able to provide the required functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants