]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
spmi: msm: factor out channel mapping for v5 & v7
authorNeil Armstrong <neil.armstrong@linaro.org>
Fri, 28 Mar 2025 08:53:22 +0000 (09:53 +0100)
committerCaleb Connolly <caleb.connolly@linaro.org>
Thu, 10 Apr 2025 13:43:10 +0000 (15:43 +0200)
The handling of the table mapping for V5 & V7 needs more work
to handle the duplicate read-only & read-write mappings,
so to make code cleaner add a switch/case and move the
v5 & v7 mapping handler in a separate function.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: caleb.connolly@linaro.org # sdm845
Link: https://lore.kernel.org/r/20250328-topic-sm8x50-spmi-fix-v1-2-a7548d3aef0d@linaro.org
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
drivers/spmi/spmi-msm.c

index 08be4517df189f320302e97334a371d370b36440..9b2be1c1b9e381985b621297774500dd97844963 100644 (file)
@@ -249,6 +249,18 @@ static struct dm_spmi_ops msm_spmi_ops = {
        .write = msm_spmi_write,
 };
 
+static void msm_spmi_channel_map_v5(struct msm_spmi_priv *priv, unsigned int i,
+                                   uint8_t slave_id, uint8_t pid)
+{
+       /* Mark channels read-only when from different owner */
+       uint32_t cnfg = readl(priv->spmi_cnfg + ARB_CHANNEL_OFFSET(i));
+       uint8_t owner = SPMI_OWNERSHIP_PERIPH2OWNER(cnfg);
+
+       priv->channel_map[slave_id][pid] = i;
+       if (owner != priv->owner)
+               priv->channel_map[slave_id][pid] |= SPMI_CHANNEL_READ_ONLY;
+}
+
 static int msm_spmi_probe(struct udevice *dev)
 {
        struct msm_spmi_priv *priv = dev_get_priv(dev);
@@ -304,15 +316,16 @@ static int msm_spmi_probe(struct udevice *dev)
                uint8_t slave_id = (periph & 0xf0000) >> 16;
                uint8_t pid = (periph & 0xff00) >> 8;
 
-               priv->channel_map[slave_id][pid] = i;
-
-               /* Mark channels read-only when from different owner */
-               if (priv->arb_ver == V5 || priv->arb_ver == V7) {
-                       uint32_t cnfg = readl(priv->spmi_cnfg + ARB_CHANNEL_OFFSET(i));
-                       uint8_t owner = SPMI_OWNERSHIP_PERIPH2OWNER(cnfg);
+               switch (priv->arb_ver) {
+               case V2:
+               case V3:
+                       priv->channel_map[slave_id][pid] = i;
+                       break;
 
-                       if (owner != priv->owner)
-                               priv->channel_map[slave_id][pid] |= SPMI_CHANNEL_READ_ONLY;
+               case V5:
+               case V7:
+                       msm_spmi_channel_map_v5(priv, i, slave_id, pid);
+                       break;
                }
        }
        return 0;