Some Qualcomm platforms use a dedicated subsystem to own and manage SPI-NOR during normal operation. Consequently, the SPI controller and SPI-NOR nodes are disabled in the application processor device tree.
In Snagboot recovery mode, the application processor requires direct access to SPI-NOR for provisioning and recovery purposes. Enable the SPI-NOR node referenced by the "spi0" alias, together with its parent SPI controller, when CONFIG_QCOM_SNAGBOOT_SPI_NOR_FIXUP is enabled. This exposes SPI-NOR only during recovery mode and avoids affecting the normal runtime ownership of the device. Signed-off-by: Vandhiadevan Karunamoorthy <[email protected]> --- arch/arm/mach-snapdragon/Kconfig | 10 ++++++++++ arch/arm/mach-snapdragon/board.c | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/arm/mach-snapdragon/Kconfig b/arch/arm/mach-snapdragon/Kconfig index 3cfac19188c..6e318733fe3 100644 --- a/arch/arm/mach-snapdragon/Kconfig +++ b/arch/arm/mach-snapdragon/Kconfig @@ -78,4 +78,14 @@ config QCOM_SNAGBOOT_MODE Build U-Boot to be loaded in Snagboot mode on Qualcomm platforms for device/factory provisioning using fastboot. +config QCOM_SNAGBOOT_SPI_NOR_FIXUP + bool "Enable spi0-aliased SPI-NOR node for Snagboot mode" + depends on QCOM_SNAGBOOT_MODE + select OF_BOARD_FIXUP + help + Enable the SPI-NOR flash node referenced by the "spi0" alias (and + its parent bus node) when booting in Snagboot mode. Boards that + use a different medium for Snagboot provisioning should leave + this disabled. + endif diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c index 6a66f5e3096..8f841888466 100644 --- a/arch/arm/mach-snapdragon/board.c +++ b/arch/arm/mach-snapdragon/board.c @@ -760,3 +760,24 @@ void enable_caches(void) } dcache_enable(); } + +int board_fix_fdt(void *rw_fdt_blob) +{ + if (IS_ENABLED(CONFIG_QCOM_SNAGBOOT_SPI_NOR_FIXUP)) { + const char *alias; + int spi_off, parent_off; + + alias = fdt_get_alias(rw_fdt_blob, "spi0"); + spi_off = fdt_path_offset(rw_fdt_blob, alias); + if (spi_off >= 0) { + parent_off = fdt_parent_offset(rw_fdt_blob, spi_off); + + fdt_status_okay(rw_fdt_blob, spi_off); + + if (parent_off >= 0) + fdt_status_okay(rw_fdt_blob, parent_off); + } + } + + return 0; +} --- base-commit: 911260be07649563b2f98555f56779a76a99c534 change-id: 20261005-review-lemans-spinor-fix-7c063cbfafb0 Best regards, -- Vandhiadevan Karunamoorthy <[email protected]>
