This patch series introduces bit-level granularity to NVMEM cells and adds complete reboot-mode support for Qualcomm platforms that store reboot reasons in PMIC registers.
Qualcomm SoCs rely on PMIC-backed reboot reason storage to implement features like "reboot bootloader" for entering fastboot mode. However, these PMIC registers often pack multiple fields into a single byte, requiring fine-grained bit access that the current NVMEM subsystem does not support. This version adds automated reboot‑mode environment updates via the REBOOT_MODE_ENV_UPDATE option, ensuring the reboot-mode variable is set during last-stage initialization once the environment is ready. Signed-off-by: Aswin Murugan <[email protected]> --- Changes in v5: 1. Added REBOOT_MODE_ENV_UPDATE option to automatically update the reboot-mode environment variable during last-stage initialization. 2. Registers an EVT_LAST_STAGE_INIT handler to probe the reboot-mode device and trigger the update once the environment is ready. Link to v4: https://lore.kernel.org/u-boot/[email protected]/ Changes in v4: 1. NVMEM Core (drivers/misc/nvmem.c, include/nvmem.h): - Explicitly interpret hardware bytes as little-endian for bitfield operations to ensure consistent behavior across architectures - Removed const pointer write violation in nvmem_cell_write() - Replaced unsafe bit shift expressions with GENMASK() macro to avoid undefined behavior when nbits == 32 - Consolidated size validation logic for clarity - Enhanced documentation with explicit @cell parameters (offset, size, nbits, bit_offset) - Changed magic number 4 to sizeof(u32) for consistency 2. QCOM SPMI SDAM Driver (drivers/misc/qcom-spmi-sdam.c): - Fixed address type mismatch using local fdt_addr_t variable to prevent silent comparison failure on 64-bit platforms - Removed non-standard qcom,sdam-size property and hardcoded SDAM size to 0x100 bytes per hardware specification - Changed dev_info() to dev_dbg() to reduce boot log verbosity 3. Board Integration (arch/arm/mach-snapdragon/board.c): - Simplified conditional compilation with runtime check instead of #ifdef wrapper - Adopted logging subsystem (log_info/log_warning) consistent with rest of file - Added error handling for fastboot command failures 4. Device Tree (arch/arm/dts/qcs615-ride-u-boot.dtsi): - Changed bits property to decimal format (bits = <1 7>) for consistency with upstream conventions 5. Test Coverage (test/dm/nvmem.c): - Created separate test file for NVMEM bitfield tests - Fixed test to use correct I2C EEPROM functions - Corrected test expectation bug for 4-byte cell with 12-bit field spanning byte boundary - Added comprehensive error validation tests Link to v3: https://lore.kernel.org/u-boot/[email protected]/ Changes in v3: 1. Simplified bit field handling to maximum u32 size (32 bits). 2. Enforced strict size matching (size == cell->size) when nbits == 0. 3. Enhanced test function for NVMEM read & write 4. Updated NVMEM API documentation Link to v2: https://lore.kernel.org/all/[email protected]/ Changes in v2: 1. Replaced custom reboot reason handling with the standard U-Boot reboot-mode subsystem, per review feedback. 2. Added bit-field support to the NVMEM core using the new "bits" property. 3. Introduced the Qualcomm SPMI SDAM driver for unified PMIC storage access. 4. Updated the reboot-mode driver to support variable-sized NVMEM cells. 5. Added device tree configuration for the QCS615 RIDE board. 6. Enabled reboot-mode in qcom_defconfig. 7. Integrated reboot-mode detection into Snapdragon board initialization: - Added qcom_handle_reboot_mode() in board_late_init() to enable automatic fastboot entry on "reboot bootloader". Link to v1: https://lore.kernel.org/all/[email protected]/ --- Aswin Murugan (7): misc: Add support for bit fields in NVMEM cells misc: qcom: Add Qualcomm SPMI SDAM NVMEM driver reboot-mode: add REBOOT_MODE_ENV_UPDATE option mach-snapdragon: enter fastboot on bootloader reboot reason qcom_defconfig: Enable reboot-mode support in qcom_defconfig test: dm: add comprehensive tests for NVMEM bit field operations misc: update API documentation for bit field support in NVMEM arch/sandbox/dts/test.dts | 12 ++ board/qualcomm/default.env | 2 +- configs/qcom_defconfig | 4 + drivers/misc/Kconfig | 8 + drivers/misc/Makefile | 1 + drivers/misc/nvmem.c | 166 ++++++++++++++++--- drivers/misc/qcom-spmi-sdam.c | 202 +++++++++++++++++++++++ drivers/reboot-mode/Kconfig | 8 + drivers/reboot-mode/reboot-mode-uclass.c | 29 +++- include/nvmem.h | 40 ++++- test/dm/Makefile | 1 + test/dm/nvmem.c | 160 ++++++++++++++++++ 12 files changed, 604 insertions(+), 29 deletions(-) create mode 100644 drivers/misc/qcom-spmi-sdam.c create mode 100644 test/dm/nvmem.c -- 2.34.1

