From 8ae054d03ee2afbb1bd2d174a4f399859f3d90ca Mon Sep 17 00:00:00 2001 From: Aswin Murugan Date: Sun, 8 Mar 2026 23:00:09 +0530 Subject: [PATCH] spmi: msm: Allow writes to SDAM02 reboot mode peripheral Add an exception to bypass the read-only check for the SDAM02 reboot mode peripheral (slave_id=0, pid=0x71) in the SPMI write function. This peripheral needs to be writable to store reboot reason information, even when the channel is marked as read-only due to ownership by a different execution environment. The change adds: - SDAM02_REBOOT_MODE_PID definition (0x71) - Runtime check in msm_spmi_write() to skip read-only enforcement for this specific peripheral This allows the reboot mode to be written successfully while maintaining read-only protection for all other peripherals. Signed-off-by: Aswin Murugan --- drivers/spmi/spmi-msm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index b89dd0b406ba..da399685f7b2 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -59,6 +59,8 @@ #define SPMI_MAX_SLAVES 16 #define SPMI_MAX_PERIPH 256 +#define SDAM02_REBOOT_MODE_PID 0x71 + #define SPMI_CHANNEL_READ_ONLY BIT(31) #define SPMI_CHANNEL_VALID BIT(30) #define SPMI_CHANNEL_MASK 0xffff @@ -117,8 +119,11 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, return -EIO; if (!(priv->channel_map[usid][pid] & SPMI_CHANNEL_VALID)) return -EINVAL; - if (priv->channel_map[usid][pid] & SPMI_CHANNEL_READ_ONLY) - return -EPERM; + /* Skip readonly check for SDAM02 reboot reason pid */ + if (priv->channel_map[usid][pid] & SPMI_CHANNEL_READ_ONLY) { + if (!(usid == 0 && pid == SDAM02_REBOOT_MODE_PID)) + return -EPERM; + } channel = priv->channel_map[usid][pid] & SPMI_CHANNEL_MASK;