]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spmi: msm: refine handling of multiple APID mappings
authorAswin Murugan <aswin.murugan@oss.qualcomm.com>
Wed, 7 Jan 2026 15:35:04 +0000 (21:05 +0530)
committerCasey Connolly <casey.connolly@linaro.org>
Wed, 14 Jan 2026 15:25:09 +0000 (16:25 +0100)
PMIC Arbiter may expose multiple owned and non-owned APIDs per SID/PID.
- Keep current mapping if it is OWNED and a NON-OWNED appears.
- Always update when a NEW OWNED APID appears (make writable).
- If current is NON-OWNED and a new NON-OWNED appears, update to it
  (remain read-only).

This avoids write-access violations when not using the newly discovered
owned channels.

Signed-off-by: Aswin Murugan <aswin.murugan@oss.qualcomm.com>
Link: https://patch.msgid.link/20260107153504.550450-1-aswin.murugan@oss.qualcomm.com
Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
drivers/spmi/spmi-msm.c

index faae54e9fef025466787541631ce5b5171444621..f3cd98c3db83d23f5d5bc9199c8ca5c9084f44a6 100644 (file)
@@ -274,10 +274,25 @@ static void msm_spmi_channel_map_v5(struct msm_spmi_priv *priv, unsigned int i,
                priv->channel_map[slave_id][pid] = i | SPMI_CHANNEL_VALID;
                if (owner != priv->owner)
                        priv->channel_map[slave_id][pid] |= SPMI_CHANNEL_READ_ONLY;
-       } else if ((owner == priv->owner) && prev_read_only) {
-               /* Read only and we found one we own, switch */
+
+       } else if (owner == priv->owner) {
+               /*
+                * Found a channel owned by our EE - ALWAYS switch to it!
+                * even if we already have a mapping, we must prefer the one
+                * owned by our EE to avoid hardware access violations.
+                */
                priv->channel_map[slave_id][pid] = i | SPMI_CHANNEL_VALID;
+               /* Clear READ_ONLY flag since we own this channel */
+
+       } else if (prev_read_only) {
+               /*
+                * Previous mapping was read-only and this one is also not ours.
+                * Update to this channel.
+                */
+               priv->channel_map[slave_id][pid] = i | SPMI_CHANNEL_VALID | SPMI_CHANNEL_READ_ONLY;
+
        }
+       /* else: Previous was writable and owned by us, this one isn't - keep previous */
 }
 
 static int msm_spmi_probe(struct udevice *dev)