From patchwork Fri Apr 5 08:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 786193 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp52684wrw; Fri, 5 Apr 2024 01:22:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWmwl8ijUmLDItMgsm2rtSWRmBqvUplHNNbRa8NQ6JlUf0WxWjn0epBqr57QMlmRTcYjwjMrcfYQdE1hM1Zeflm X-Google-Smtp-Source: AGHT+IGivruPKM5g5JRetVlO00Swd/X8xKhK0bkhFDfArt7EsAx19UuLJZ7qVFrBfQOpemAu8T1q X-Received: by 2002:a2e:9887:0:b0:2d8:5af9:90c5 with SMTP id b7-20020a2e9887000000b002d85af990c5mr868104ljj.39.1712305333449; Fri, 05 Apr 2024 01:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712305333; cv=none; d=google.com; s=arc-20160816; b=QFEhcetrYFG96SyZBQDy6YQHU1p6uUJWCaHqKPtH0ktIw4PCy4QfN0U19xDKwa2Vj8 RJxl/qPRKyeub1eKnIcFe2Njn0iLbRASrp3JNvokFEg0GXsrK77G0FxGwHIXTjQXAo/R cWTBJXqyBz0uiBwPslEYDOihSDkBOQqpj9iK5upfkTXT6Q+mhCLoJjaTtws81HXvHwhV 1NAP4BlU7IQ4MjQ0b1uOrUkHh4z7LnVRIV9c9xVYEYB4KBL2Nb+06lBxQwVUyBgq8wjw 7Rxej5CpOn0iUZsh3WkYnZwrm3AH6Sr9DEEltaeAjjU1dCOIwJHcPlHnCWrsufkSYQim pX3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=6dKpRGmyPkdUIGV+k5unKfus8cERlzrz7D8lFITEH4k=; fh=CysUfdz8TMhrnL3XEYYwPXjcX61bp1VQIWrXNtJSfKA=; b=lrtG6h2+FhtULz8B09Ki0ghW7tlvWeHmWjN6lpWvGjzciWyjMc63m6UBqOdQAES2FE /TjCKWSeo4f1/9XINECcpuqhj+4CTdrE8bMne+ebae89Uj5g4IixEHkDfMaNIOgt40wB VEkjSafHcjrWia8lylVS4f/cymwvUqV5hJ6c6NOc0SUE9k4oLjxTZcZXDVU9aL9t9KHZ 1uTx2FBh0wbJLBgjoxK7IPykfAXlr80lLEzj2AtgbXk5DhfztRhxlJ50bNTshLsewQZN 0XY9+uo4VH+tiXDMpr0gN8v4RjraqtYsQib0ujDI+RaMQ4/wz7L3My+h3A9cp48vne+Y pvHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JAF7MU5K; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ov32-20020a170906fc2000b00a4a3c6d2c7bsi470551ejb.967.2024.04.05.01.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:22:13 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JAF7MU5K; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 580AC884A6; Fri, 5 Apr 2024 10:22:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="JAF7MU5K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 87A0C88498; Fri, 5 Apr 2024 10:22:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A4ED98849D for ; Fri, 5 Apr 2024 10:21:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-343e70dd405so288922f8f.3 for ; Fri, 05 Apr 2024 01:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712305319; x=1712910119; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6dKpRGmyPkdUIGV+k5unKfus8cERlzrz7D8lFITEH4k=; b=JAF7MU5Kq/r+gMttnW1/XoITQZhf6Sk5Df8uhyB9LnfcIFqGt0JvmMkul6SJnLi+Ah rIgqM0nEPt0803TSY4agsYwpzSLFg3LquJ+9BMHQUxL6L37YuRv7P9Rh7hwQd7BVW2+I cPK+Y05tvq3Eo+8a/iSXspJ9L24CRlv7Mkm5kmXv2nFNzp4LmjTwabfxpEb45dRvtnAq Gm7IzaQhlz+BJWhQIZBxfnEUYEq9rxj4F4gxSS2vcwGyea3GJk7EiQc6UUTC+lG7nYGB vy10ky5v+RWez9s69E0ktLc3sakdFIWv5CWh4DFFW9K0bLScXS0sLYk7ozB/9E9/AHAw aUbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712305319; x=1712910119; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6dKpRGmyPkdUIGV+k5unKfus8cERlzrz7D8lFITEH4k=; b=whnr/5ML+YL+o31sm8RHztN/oCbyzh+m6F7fKTHgI7KaiL3yLqXa6D/SQoyK62pSzS RmgbOcQhVUtJQOJfgbRY7TikAn8XpibUXgg5iBGuFFEaZAz79aTJuxPC+sjLMh3FuJYS Trl5riquK7FnnOucZHk+M/e3boqHOKDUBl56GUTuYmbKhzxZT1J0tN+glihV0B452IZv hqi75iTqBm47ZNHGmNxtij6Hzmw0S3unS6WlS/v5KF4dFmuB/HaYIieTJoi9qEUk1o4A RvPRKPT3OH4m1nNJENmQaJ/o/FqemmyRCQ77AZ4aweMQQ9GXVEqa1r/LsgQvbfHx8FV6 gIkg== X-Gm-Message-State: AOJu0YwUKIUF19R4XyoS8vO+KOyBvxkuv7iUZZYX96laaiEiQB8lQlEV jZooagjR80u0HLUkFZHlz/pyihQn8G+PwzxV5CK7k4j6KzHsEWNxXbm7KNFjSx8= X-Received: by 2002:adf:f9cc:0:b0:343:7653:ad14 with SMTP id w12-20020adff9cc000000b003437653ad14mr767204wrr.30.1712305318937; Fri, 05 Apr 2024 01:21:58 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id j27-20020adfb31b000000b00341d84f641asm1452326wrd.8.2024.04.05.01.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:21:58 -0700 (PDT) From: Neil Armstrong Date: Fri, 05 Apr 2024 10:21:53 +0200 Subject: [PATCH 1/4] spmi: msm: fix version 5 support MIME-Version: 1.0 Message-Id: <20240405-topic-sm8x50-spmi-fixes-v1-1-031a9e5efab4@linaro.org> References: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> In-Reply-To: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> To: Caleb Connolly , Sumit Garg , Mateusz Kulikowski , Tom Rini , Dzmitry Sankouski Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1894; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=LaXl9zWgypJuMb/3QiSIxEc5AI6hOk7WqkoxmZNe4lw=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmD7SjIqVUicjlR9KwI334QwwllUSzQacDLhtU2ySw JrkOcc2JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZg+0owAKCRB33NvayMhJ0YRlD/ 42OLZUM0UUQUUsHaMoE2jWOBEptTx3+jhp5wift7QSh838oo/GH9Jkz/1p+yFzOm0lBtc1vpMuatpg ybAtB9fJ5p5zdivBF30uXimBd6J4B7Drh4qUiyPzBOncRtMCQcZdDF37Q7BLU96ijJDE3Xgs9b7CvZ 52qc0IPO6JHmMGOOpqV4U+O4aazNk6SdQsZmeK6Vux+RsoSqnH6WCuzKbZVklVoeIlB1vDsWkR8kAD OvkqZYGmvLJFCr1uK2AEsdbhR0BBQJ/o55A3mTCVh8Qj8CFIVdPGCw8pAp9hciSqsD8l8Id8x79Sf4 pU/9oGYUIkMOgg6oCT1UTBqs15PuCbaaLmM4flnqtTsBTUg8H8cmig/uAwbC+xabjP4AA/v4XKXu9C xhq0r4iJwbS8QBNm5V0QzSuFGgfaUeHNpGGrOMlL/HSYj+0OJDNEn4PLL1bedTUGEaTSc2F8qBIZ1N smddUytRSUAIj5UtkYmkXr4uIdOi15PUo97dsXJc1WkYBlvClgCzUA7VHCcrxyLqjl47a9lj7JpD5v LwA+jEfqARTtKhoMl9DHZFDBQi6kGz8bOpy0goZvHCFfYFbjPtpEGhFqZNbxIHWc9A82YMPG7yenJa WDmR8bSjet/NvXzAsKZ02u4C4vdLkciAS75X+XnriLzssbODdcuC87IYeYAA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Properly use ch_offset in msm_spmi_write() reg access. Fixes: f5a2d6b4b03 ("spmi: msm: add arbiter version 5 support") Signed-off-by: Neil Armstrong --- drivers/spmi/spmi-msm.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 5fe8a70abca..97383d8c7b8 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -93,12 +93,16 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, channel = priv->channel_map[usid][pid]; + if (priv->arb_ver == V5) + ch_offset = SPMI_V5_RW_CH_OFFSET(channel); + else + ch_offset = SPMI_CH_OFFSET(channel); + /* Disable IRQ mode for the current channel*/ - writel(0x0, - priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_CONFIG); + writel(0x0, priv->spmi_chnls + ch_offset + SPMI_REG_CONFIG); /* Write single byte */ - writel(val, priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_WDATA); + writel(val, priv->spmi_chnls + ch_offset + SPMI_REG_WDATA); /* Prepare write command */ reg |= SPMI_CMD_EXT_REG_WRITE_LONG << SPMI_CMD_OPCODE_SHIFT; @@ -107,18 +111,13 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, reg |= (off << SPMI_CMD_ADDR_OFFSET_SHIFT); reg |= 1; /* byte count */ - if (priv->arb_ver == V5) - ch_offset = SPMI_V5_RW_CH_OFFSET(channel); - else - ch_offset = SPMI_CH_OFFSET(channel); - /* Send write command */ - writel(reg, priv->spmi_chnls + SPMI_CH_OFFSET(channel) + SPMI_REG_CMD0); + writel(reg, priv->spmi_chnls + ch_offset + SPMI_REG_CMD0); /* Wait till CMD DONE status */ reg = 0; while (!reg) { - reg = readl(priv->spmi_chnls + SPMI_CH_OFFSET(channel) + + reg = readl(priv->spmi_chnls + ch_offset + SPMI_REG_STATUS); } From patchwork Fri Apr 5 08:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 786194 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp52742wrw; Fri, 5 Apr 2024 01:22:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOqN+K+C/9EoUSrikIAw1H1oAPhwMy5F/JxMpg0Ic6HEEZF2WflugoyDh4PHtWVobtPEy79IA8jZ1wX621zrDf X-Google-Smtp-Source: AGHT+IEqvW5b4401jfooygh7qXrdrJ6pd5vNTcLm0+z3r6gHslk1xem65SokdoKlesRGqu9uzJP5 X-Received: by 2002:a50:c2c2:0:b0:56d:b7d6:d64b with SMTP id u2-20020a50c2c2000000b0056db7d6d64bmr571488edf.29.1712305342544; Fri, 05 Apr 2024 01:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712305342; cv=none; d=google.com; s=arc-20160816; b=njVsSsOykFp1DwN5ZQw+KJzpCWPsPyxTrhjTCFyBLSC8rPpVOzeakDSo3gAjDvpu2e VvLKiaybKqtSm1wa13urP+u8A3Xxsh2HogxIGTvXaDKtjKd8Lafbl9q7uA5dP2eupjSq JDFDddJ3ELZsUsK+ecYjFaMW7r2gRnc0ghhVkJ+NG/cSRzAIKoHdaF3vYb6D3lfC7RX0 d9PdaQOONsk8z514InZOhgj5rRmgFE9UNBE19VIZKFzio3zBshYnmZUnQWz5Qp8nJ/Xi dIGEAeU87+3GY+R+f6+jtrakPuIrP2entmP3rQVbNbYyYuvxrxwUL951SQIe2hEIb3KE iJJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=YVOcC+aJP/zP5nYNTwZP7yZVupvu+P2kFrJ8Oh6HoF4=; fh=CysUfdz8TMhrnL3XEYYwPXjcX61bp1VQIWrXNtJSfKA=; b=RqKaG86du7GJZZrS1caxexNNd+iEGRfDYSOh9jrDCCFoTHHfdXUorba5QdOy6Q+sCm zKljBFoVgvW5XgshHkl5lsp7qnh7xj08j/jYlKz7jWkb/3Y+5flJVnPqNBFco/C1+uIs Bu0a8J4cTQ190+YdoBgbXxaH5X5aWWgskPIZaJt47se0CkvOhNMyvOmEU7Bp7M6p9JIn oR+N8grhDQ7z2gzGijXR4mZOkCE3ZZ8D5rs+/DLVFLI5rpaIhMjL8rU18V3xLkgHCCqz 9KmXiUZy9S5nKDXpbteqvDAsPBwNL/FGPycKUL/UVMYpVFLW+dm2jJUxB5/t/+4ef/XF LfYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rco2PrCG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id fd3-20020a056402388300b0056e2a14f4adsi484591edb.626.2024.04.05.01.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rco2PrCG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DEFCE8849D; Fri, 5 Apr 2024 10:22:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rco2PrCG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15866884A5; Fri, 5 Apr 2024 10:22:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 634F18849F for ; Fri, 5 Apr 2024 10:22:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4162c2107d3so8016245e9.0 for ; Fri, 05 Apr 2024 01:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712305320; x=1712910120; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=YVOcC+aJP/zP5nYNTwZP7yZVupvu+P2kFrJ8Oh6HoF4=; b=rco2PrCGKB8inuuQBvnzxug5R6C+QxIYo4TCB9gf182m5f2ZXJefgN+9U+ceIexJIr CIAYkHY8qddFoQUOAaIN8ftD0Wnjd0C661/HjfloLgZ+X2Ao0cHP9yURcrKZH76i52RO Kw3rc++A5w2IVwfYKSHysnLCKVaMTz8yxz3A2TmAKIlyq8dONnMG3rnfa/U1JpgIh45W Yt2LWGJcpgOXGTZGCOK8iovbUQGzi092UQRPOR8+Zdx/LC2aUJHZRdE8X/9IKZ/8vVPe 1frpASu5EP3oY6UGjXKz39PaJUXf2/YOdM3ORk4svPUl5XxBR3H55scH1JBjo1IY0x3I bHYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712305320; x=1712910120; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YVOcC+aJP/zP5nYNTwZP7yZVupvu+P2kFrJ8Oh6HoF4=; b=isKqfZ4H9MbOSDInwNiP3zrBeRoAlr+MRxaxru2YraKDY/SNL5K2HINgbBD0ijgxK/ +IBwpFuHQLEtvV5gj3eFQK01mgAFEtPbdXcdbPs25jR4t9SBzAwv1x4Z3lC8CFB4LK7s j/8dB31Mh2/7e+qjXsOEucE1G4c809fQ5TghHoYWmFh3BnNjAaQfR4jRJYHBAVvnEcDC PNiobln6HI/qJTHwq5MERQVOeXiejmtgFx6VIoyOADMtsfhlbiKO2fG9aC/A3q5al8lI CBKJMWrOw6Z9/CSKxhbO75CkO9UJNB9j/g7qgaGqbxywSRnOKR9WAaLgQq0ceY81Bj4p Sc8g== X-Gm-Message-State: AOJu0YwnYkMiCE/6O6CZ95wHRn0xDY7tNyI0WdLGxTKviO5aR4BCyY3B 3DeWB9zbqEWpphcJTGPLa3AyvbQNjeua/gGOdEyeVKfbMi7nlx0BREtIwifyeoA= X-Received: by 2002:a5d:5146:0:b0:33e:6366:5f2a with SMTP id u6-20020a5d5146000000b0033e63665f2amr648184wrt.5.1712305319633; Fri, 05 Apr 2024 01:21:59 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id j27-20020adfb31b000000b00341d84f641asm1452326wrd.8.2024.04.05.01.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:21:59 -0700 (PDT) From: Neil Armstrong Date: Fri, 05 Apr 2024 10:21:54 +0200 Subject: [PATCH 2/4] spmi: msm: properly format command MIME-Version: 1.0 Message-Id: <20240405-topic-sm8x50-spmi-fixes-v1-2-031a9e5efab4@linaro.org> References: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> In-Reply-To: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> To: Caleb Connolly , Sumit Garg , Mateusz Kulikowski , Tom Rini , Dzmitry Sankouski Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3605; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=L7dT0VNmPI3dYsmh0xmaANK0mnY7T76P4RWPgWp44w8=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmD7SkhdfKS6R+LA5YCAeJ68mm04B/mMBSeVGzZ5Ho XhpKCLWJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZg+0pAAKCRB33NvayMhJ0f/oD/ 9w0YQxl7GiqzKQ9/qpwhsDqAhP29yxXq4bas6rAoPJf70u/WZB8UKLKxX/+kb2l8+ObXFv+iyjTfbV pjlrZrV/7wgEom2cgQG5amM6tt/EXsX/duZvs/j5L76Oa9RqTApsSIh7774Bo5CRPVyF2l2YIoV5Kl sUc8yV8IEe7ZXyC3FFWjJHN/32uaps/7/aeOIqgzcDfyOubW0lhSXzNGB26BAI46xxLpOQhVaYhXkj npLyyVpV6yXCjTqmroNPgy0tDbq22s73pM6G9jk2PtckrIIPR2h9eISNpU24sUHGcUWQXUtSxz7vsq I13JpX1HhLC7+dEnJHmvcax3FHhwGWwufI095oEa0TGGQbKn+H/it5MWpvxcnHsYApX9tuiT6m2LVX YLQRzWXljkQZ2yBmLGNIEgzMp9dbs+fyVHC/ZKByHIuU5wkTtflxmUamGURHgZODn8rTP3fD5Ydhhp 8a+kbKKGBO/vaP6IdkVaba+76eCnGtQnSgQpnYGObjp+k5Es2ON4X7F4vBR/xXSRiZKsQaJuSXcGRV 7D5KQf/5pbBUl2WXb+9ODdcWDiWKBYC2prhPPCdix90qnbAYlvvh7CU9A1NQ/1NWKKhqJa7M+AviLc +m2/qfMj+TB+HFKTMpdjPwQH4HLaHSuXodKg5ztTkFKOzcEmJyqgkwD2nHkw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Since version 2, the cmd format has changed, takes helpers from Linux driver and use a switch/case to handle all versions in msm_spmi_write/read() command. Signed-off-by: Neil Armstrong --- drivers/spmi/spmi-msm.c | 75 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 97383d8c7b8..68bb8a38c3c 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -78,6 +78,16 @@ struct msm_spmi_priv { u32 arb_ver; }; +static u32 pmic_arb_fmt_cmd_v1(u8 opc, u8 sid, u8 pid, u8 off) +{ + return (opc << 27) | (sid << 20) | (pid << 12) | (off << 4) | 1; +} + +static u32 pmic_arb_fmt_cmd_v2(u8 opc, u8 off) +{ + return (opc << 27) | (off << 4) | 1; +} + static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, uint8_t val) { @@ -93,24 +103,35 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, channel = priv->channel_map[usid][pid]; - if (priv->arb_ver == V5) - ch_offset = SPMI_V5_RW_CH_OFFSET(channel); - else + dev_dbg(dev, "[%d:%d] %s: channel %d\n", usid, pid, __func__, channel); + + switch (priv->arb_ver) { + case V1: + ch_offset = SPMI_CH_OFFSET(channel); + + reg = pmic_arb_fmt_cmd_v1(SPMI_CMD_EXT_REG_WRITE_LONG, + usid, pid, off); + break; + + case V2: ch_offset = SPMI_CH_OFFSET(channel); + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_WRITE_LONG, off); + break; + + case V5: + ch_offset = SPMI_V5_RW_CH_OFFSET(channel); + + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_WRITE_LONG, off); + break; + } + /* Disable IRQ mode for the current channel*/ writel(0x0, priv->spmi_chnls + ch_offset + SPMI_REG_CONFIG); /* Write single byte */ writel(val, priv->spmi_chnls + ch_offset + SPMI_REG_WDATA); - /* Prepare write command */ - reg |= SPMI_CMD_EXT_REG_WRITE_LONG << SPMI_CMD_OPCODE_SHIFT; - reg |= (usid << SPMI_CMD_SLAVE_ID_SHIFT); - reg |= (pid << SPMI_CMD_ADDR_SHIFT); - reg |= (off << SPMI_CMD_ADDR_OFFSET_SHIFT); - reg |= 1; /* byte count */ - /* Send write command */ writel(reg, priv->spmi_chnls + ch_offset + SPMI_REG_CMD0); @@ -143,21 +164,35 @@ static int msm_spmi_read(struct udevice *dev, int usid, int pid, int off) channel = priv->channel_map[usid][pid]; - if (priv->arb_ver == V5) - ch_offset = SPMI_V5_OBS_CH_OFFSET(channel); - else + dev_dbg(dev, "[%d:%d] %s: channel %d\n", usid, pid, __func__, channel); + + switch (priv->arb_ver) { + case V1: + ch_offset = SPMI_CH_OFFSET(channel); + + /* Prepare read command */ + reg = pmic_arb_fmt_cmd_v1(SPMI_CMD_EXT_REG_READ_LONG, + usid, pid, off); + break; + + case V2: ch_offset = SPMI_CH_OFFSET(channel); + /* Prepare read command */ + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_READ_LONG, off); + break; + + case V5: + ch_offset = SPMI_V5_OBS_CH_OFFSET(channel); + + /* Prepare read command */ + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_READ_LONG, off); + break; + } + /* Disable IRQ mode for the current channel*/ writel(0x0, priv->spmi_obs + ch_offset + SPMI_REG_CONFIG); - /* Prepare read command */ - reg |= SPMI_CMD_EXT_REG_READ_LONG << SPMI_CMD_OPCODE_SHIFT; - reg |= (usid << SPMI_CMD_SLAVE_ID_SHIFT); - reg |= (pid << SPMI_CMD_ADDR_SHIFT); - reg |= (off << SPMI_CMD_ADDR_OFFSET_SHIFT); - reg |= 1; /* byte count */ - /* Request read */ writel(reg, priv->spmi_obs + ch_offset + SPMI_REG_CMD0); From patchwork Fri Apr 5 08:21:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 786195 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp52810wrw; Fri, 5 Apr 2024 01:22:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrlHsOcuRTNJUQGSvEN3wqtA1Yn9zKlbV3XI/Ct9IU1Pok4dQZu/5M4XBiueVdr7Qmu83ej/UoUwTcizcc2fWf X-Google-Smtp-Source: AGHT+IHLLKrl3xVl5GCxV7Pu9lb4gUjM2SJwNo0XD2j38qiD4MCtiGgA+U923IjMyY8UdsPpie89 X-Received: by 2002:a17:906:80d7:b0:a4e:8f4f:2f09 with SMTP id a23-20020a17090680d700b00a4e8f4f2f09mr563629ejx.15.1712305352045; Fri, 05 Apr 2024 01:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712305352; cv=none; d=google.com; s=arc-20160816; b=ulzDPE+3JWlhbDW+dqkZCJmiMCec+7Jvk8Hn7354aCtGV6rqK8btwMHqRRmGeCzKv9 BermqtEPR1yo6cB9uLhq0mUn/NPImj4k488rXPVgiM0AYjXfDfrIEvum+9WvznDarG9u czk3NKRjCstWoo9lEF+7pR0898qO25MIzKl54IXk3o2+fbEGFZe3wTOiwKzoPzRxDaFt uBe3s4oPfdarSj3HcV30Ep13sE1ufApyP7G9konfjRILi/BhCLcqs4tM1Eec8okM5mNt XZ3jEKj5ik5vifJi/tC8byMKvhqj08ycDEyKqxsENHg9EUW0ItpEAtTWvZS8AO6dZ5/j 5mkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=2VXhmTPTkrGz79CaY+8KabcI4NMo90SgGYVaGgHBzEU=; fh=CysUfdz8TMhrnL3XEYYwPXjcX61bp1VQIWrXNtJSfKA=; b=CXuWTGMUZufUtAiUQUSn4murOP2ebuow/dmIBXhg2nJkSzmXLfqIIhw9OeyP+14Bky jahfTaqqCVCKaFf32g3oQQjLdrWQjvn3ts0GjUvx624hTp40KlNuzdL2calJ1+9XGtdj ZaJ/jgfyXw/Be1bp7SSM/SVqpw0qYIdEDztqMBlmjsi+mZowYi24hiSmbNv0QAQxU/Hh h1/Moq8E9hUsTpqC1zXTU+XWeCafetOuWqw/AEsQEaa4IqyyAsCFfkXEE9xb3d1HhTHD frh46e14B70WqNBzTSo8l4Ij4I+8fzfLqCyK9N9tuvrI2jwdFDcTVJE/oK47XCRGn44W DXow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XOarGDgO; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id g10-20020a17090613ca00b00a4dfad59b39si480800ejc.830.2024.04.05.01.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XOarGDgO; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 677E2884AB; Fri, 5 Apr 2024 10:22:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XOarGDgO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F2CC884A8; Fri, 5 Apr 2024 10:22:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 912B888499 for ; Fri, 5 Apr 2024 10:22:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-343e46ec237so270006f8f.2 for ; Fri, 05 Apr 2024 01:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712305321; x=1712910121; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2VXhmTPTkrGz79CaY+8KabcI4NMo90SgGYVaGgHBzEU=; b=XOarGDgOad38R1+b/hFTMGiMyroJiCSrYvn+Ge1zY+IL+u6ubdUMo4nvole9m/aWDI RuxWTFAWOHeCTTP8zz9FJWTkfprCSfhzUat/MDfA+QgGErvdQ1Pmz7h3l7TiCqWTnEom Vb9K7ntEWutHxbD03DSMa/ZYRW2gJNU/O2yfEyDMUuMl2sk+swauJqIGsxdbtOTOWkqS 7EKgKISeL3LuLvrmSiEVBiI59gMlyhoQ2+A6DrLaHc6Ux5fyUQHZnhFlpqjPrGvARivY Brr9Qjc9OxU4CEV/wRPW5skBgU5tEju/t14Bj+nKqlxcCiovRSVAaApuYBtiF4hMhMOP Wm5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712305321; x=1712910121; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2VXhmTPTkrGz79CaY+8KabcI4NMo90SgGYVaGgHBzEU=; b=F3UNRAmFwanJ7pjnBlqsWjCfqiMtQoIuA8DuI2JAd4q7RGQ7fyXdXnBhl5mnlF0fQL biSZmSK4yjhXiLrhdDfweqUuq/Mi63ZnvEXI/35SNrkGlaZA9+a3fD3s8vEHcXDyrTUQ sTbxV1zEGEGb6eLGHm8dFtHQ1ggxk4Idw/vtdhu0im9gmYpoADFR0qm55tACQwJN28Pl 9hxMyjeekuC28s7XB5hU1kF6QiADrDVIAXxABmb39blrS2ASc+VeJOMl3DiPgZQA2wvD wfduNYJd0qeVOqKgrkMuM94+pp5sboCFkfjmZfjqlRDDv5uK+c80Wuw7lPEW11h45Y8D yrkw== X-Gm-Message-State: AOJu0YxlchcAKDZRnC+BzVNfzSkTYeFAQhrPExicQjRGubVw2ooMxFFY YduACvATEZ22Ipv+MtkPizBffTUxNYr3TC9asFH9sGVwaHbvTz4dcPoQLE5tQf4= X-Received: by 2002:adf:f40d:0:b0:343:878d:d691 with SMTP id g13-20020adff40d000000b00343878dd691mr604569wro.47.1712305320894; Fri, 05 Apr 2024 01:22:00 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id j27-20020adfb31b000000b00341d84f641asm1452326wrd.8.2024.04.05.01.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:22:00 -0700 (PDT) From: Neil Armstrong Date: Fri, 05 Apr 2024 10:21:55 +0200 Subject: [PATCH 3/4] spmi: msm: handle peripheral ownership MIME-Version: 1.0 Message-Id: <20240405-topic-sm8x50-spmi-fixes-v1-3-031a9e5efab4@linaro.org> References: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> In-Reply-To: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> To: Caleb Connolly , Sumit Garg , Mateusz Kulikowski , Tom Rini , Dzmitry Sankouski Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4513; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=mM6+B/F0qZuOIU4XA5qgwXI4s/DfVycw26pJr7R+bMI=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmD7SkzZMSrNj1G2jeUU0ZFxzpqu26sx7LaICTC9Ll T2NaHnGJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZg+0pAAKCRB33NvayMhJ0XIWD/ 9q8RtSkI+OJF/67VuMZaXKfgjgNimNEypSCd4soZmPi3W/nd9y8XFXNHIyyASKj16rPLLT9ocSatZ5 3qTSOFslYWks16LMxDb5Jb3iNJC3EaZJJbQEIw/ELegi9+hyG19zEBgs9SAnWOIx7N8MFapOP89eCZ rH0sBz3RBgtNX7ZH8RzKEEtG6yZK3GXSGv+EJ/558GcMtWo/Xeh+PyB7p93A/lgUlQ/qaHjNVVAHCR 2V1jduXjJGVNVJZqU/reinR0EaMhE1xIman2JKrMQtPlggHelg9klykIIlfYrWDL2CHIqxeiZCVHkP QRt4l4qDBOa8dNUfD/WkIruVY+2Ph+aq6Je/nPZVgTrlIE5vLVAJxXgfjaeGnwSXgdDaTsUgVAa9Wt 2isYWUBb/imTRkHN5IVkDLofLaIgtG8ij6dQce7fLp0hIX+R20QuVZGlkAqlQv5r5Bjq8NEvSvlXYd zeDNPDjYJ1XZKxgy+DfIizAevbuQ8fCCEmR/FPVrGK8geJYJRmqZMJmWFcpyUAW7/YHRNKTjGthJW7 RmcaJcZgmKd+041CLkG0wd5Riv/8Zkrj4I3zYugt3E8hA9pkYc/Qlx0KlF7lRGbbI0Tz8zk7gjvZJQ on4sBPr5DOa834WRsgFHnPFDJPPZO38PJVsSrEICEYa6DzBUWK7/m44F/OBw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The cnfg registers provides the owner id for each peripheral, so we can use this id to check if we're allowed to write register to each peripherals. Since the v5 can handle more peripherals, add the max_channels to scan more starting from version 5, make the channel_map store 32bit values and introduce the SPMI_CHANNEL_READ_ONLY flag to mark a peripheral as read-only. Signed-off-by: Neil Armstrong --- drivers/spmi/spmi-msm.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 68bb8a38c3c..46e2e09dc26 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -31,6 +31,8 @@ DECLARE_GLOBAL_DATA_PTR; #define SPMI_V5_OBS_CH_OFFSET(chnl) ((chnl) * 0x80) #define SPMI_V5_RW_CH_OFFSET(chnl) ((chnl) * 0x10000) +#define SPMI_OWNERSHIP_PERIPH2OWNER(x) ((x) & 0x7) + #define SPMI_REG_CMD0 0x0 #define SPMI_REG_CONFIG 0x4 #define SPMI_REG_STATUS 0x8 @@ -49,9 +51,13 @@ DECLARE_GLOBAL_DATA_PTR; #define SPMI_STATUS_DONE 0x1 #define SPMI_MAX_CHANNELS 128 +#define SPMI_MAX_CHANNELS_V5 512 #define SPMI_MAX_SLAVES 16 #define SPMI_MAX_PERIPH 256 +#define SPMI_CHANNEL_READ_ONLY BIT(31) +#define SPMI_CHANNEL_MASK 0xffff + enum arb_ver { V1 = 1, V2, @@ -72,8 +78,11 @@ struct msm_spmi_priv { phys_addr_t arb_chnl; /* ARB channel mapping base */ phys_addr_t spmi_chnls; /* SPMI channels */ phys_addr_t spmi_obs; /* SPMI observer */ + phys_addr_t spmi_cnfg; /* SPMI config */ + u32 owner; /* Current owner */ + unsigned int max_channels; /* Max channels */ /* SPMI channel map */ - uint8_t channel_map[SPMI_MAX_SLAVES][SPMI_MAX_PERIPH]; + uint32_t channel_map[SPMI_MAX_SLAVES][SPMI_MAX_PERIPH]; /* SPMI bus arbiter version */ u32 arb_ver; }; @@ -100,8 +109,10 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, return -EIO; if (pid >= SPMI_MAX_PERIPH) return -EIO; + if (priv->channel_map[usid][pid] & SPMI_CHANNEL_READ_ONLY) + return -EPERM; - channel = priv->channel_map[usid][pid]; + channel = priv->channel_map[usid][pid] & SPMI_CHANNEL_MASK; dev_dbg(dev, "[%d:%d] %s: channel %d\n", usid, pid, __func__, channel); @@ -162,7 +173,7 @@ static int msm_spmi_read(struct udevice *dev, int usid, int pid, int off) if (pid >= SPMI_MAX_PERIPH) return -EIO; - channel = priv->channel_map[usid][pid]; + channel = priv->channel_map[usid][pid] & SPMI_CHANNEL_MASK; dev_dbg(dev, "[%d:%d] %s: channel %d\n", usid, pid, __func__, channel); @@ -227,18 +238,23 @@ static int msm_spmi_probe(struct udevice *dev) core_addr = dev_read_addr_name(dev, "core"); priv->spmi_chnls = dev_read_addr_name(dev, "chnls"); priv->spmi_obs = dev_read_addr_name(dev, "obsrvr"); + dev_read_u32(dev, "qcom,ee", &priv->owner); hw_ver = readl(core_addr + PMIC_ARB_VERSION); if (hw_ver < PMIC_ARB_VERSION_V3_MIN) { priv->arb_ver = V2; priv->arb_chnl = core_addr + APID_MAP_OFFSET_V1_V2_V3; + priv->max_channels = SPMI_MAX_CHANNELS; } else if (hw_ver < PMIC_ARB_VERSION_V5_MIN) { priv->arb_ver = V3; priv->arb_chnl = core_addr + APID_MAP_OFFSET_V1_V2_V3; + priv->max_channels = SPMI_MAX_CHANNELS; } else { priv->arb_ver = V5; priv->arb_chnl = core_addr + APID_MAP_OFFSET_V5; + priv->max_channels = SPMI_MAX_CHANNELS_V5; + priv->spmi_cnfg = dev_read_addr_name(dev, "cnfg"); } dev_dbg(dev, "PMIC Arb Version-%d (%#x)\n", hw_ver >> 28, hw_ver); @@ -252,12 +268,21 @@ static int msm_spmi_probe(struct udevice *dev) dev_dbg(dev, "priv->spmi_chnls address (%#08llx)\n", priv->spmi_chnls); dev_dbg(dev, "priv->spmi_obs address (%#08llx)\n", priv->spmi_obs); /* Scan peripherals connected to each SPMI channel */ - for (i = 0; i < SPMI_MAX_PERIPH; i++) { + for (i = 0; i < priv->max_channels; i++) { uint32_t periph = readl(priv->arb_chnl + ARB_CHANNEL_OFFSET(i)); 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) { + uint32_t cnfg = readl(priv->spmi_cnfg + ARB_CHANNEL_OFFSET(i)); + uint8_t owner = SPMI_OWNERSHIP_PERIPH2OWNER(cnfg); + + if (owner != priv->owner) + priv->channel_map[slave_id][pid] |= SPMI_CHANNEL_READ_ONLY; + } } return 0; } From patchwork Fri Apr 5 08:21:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 786196 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1101:b0:343:f27d:c44e with SMTP id z1csp52880wrw; Fri, 5 Apr 2024 01:22:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4UHSKAFOtrzTPY+lohex2FFD9eDPmHdw2L8KLB5KJu5g1tbnb18yVkhhVDbVClNfRsIemKoP1WQx8Z2HSJ91x X-Google-Smtp-Source: AGHT+IEdDFJn3J1ZxwPH8adJq3ghr4JxLaizTEZIBphn33XKzDYDdPsVwz+H2ovTkENxEpxHXkfi X-Received: by 2002:a05:6512:b8e:b0:513:cc18:d4c6 with SMTP id b14-20020a0565120b8e00b00513cc18d4c6mr795671lfv.41.1712305362232; Fri, 05 Apr 2024 01:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712305362; cv=none; d=google.com; s=arc-20160816; b=yt8KDzO6jmKq01YyOYtBPjlz1mwzeYPM+yq7YAiL0pBWYkuk93wGixIairv8yhoLWW RrVuqWuD1FQPstnl3wLUuHayDdzrGlMJBeoVdaRCAgpcN9E2gmfebY/nMMa7tVrOj0zj mflvxQedD6RMTaUC0DenHLerZhQEQ2taZcaghS1K6ZnKcxkiAg5bxDFi0kHyjrKcXsQe 8mavWf4zIYA7PWRmCa6v7KHCArZVWe7MfmWP+08WxICxH3UJiERwNJ4gkidKq+GEwMwR n/kSpjRXv09cXzf6L4pvjLC6XKzvS2NzoNmRifgX33gvo3FBKBKkpiYwN3oS/IKcphPB x4iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Dk21LyGHImJBYNFvztEgUb33gmCnQ5zbMfQ4IK8Cb8A=; fh=CysUfdz8TMhrnL3XEYYwPXjcX61bp1VQIWrXNtJSfKA=; b=XWOJdn/Hmak2tvC4yI0yuoJTp5/l15v3qMb29d9S8tGhy/3sXL+sF25SDmXfisGvEP pUhy4FuvE8xxloIuGkEGw+uNE71LdtWAa4HY9jHcHTl58KT4XPKuIDRQmZGN//0+24sx VMWgbej9z034Iin4WVgK1w3vGpsgqfjdMvhMzodiuDGlhVlzcz8oa0EMx8rSF43ZBKj7 1OJ63NCvoJ9Y1PY6/lMYb8QFH7N5abdv0wjZ+HtOYkEbGyBmIMgN9KNyPlAeg/XDJeP1 EQLcbzu83YcqRTdbRyImwEcYimIzrErIYHGjt4MhmvSff8yufnYDUPzAtjSFBXqY2z8z sgRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uVi1XCVp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id qc18-20020a170906d8b200b00a474da2177esi467842ejb.532.2024.04.05.01.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:22:42 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uVi1XCVp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D8E62884B0; Fri, 5 Apr 2024 10:22:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uVi1XCVp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FA6388499; Fri, 5 Apr 2024 10:22:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9C3288849D for ; Fri, 5 Apr 2024 10:22:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-343e70dd405so288951f8f.3 for ; Fri, 05 Apr 2024 01:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712305322; x=1712910122; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Dk21LyGHImJBYNFvztEgUb33gmCnQ5zbMfQ4IK8Cb8A=; b=uVi1XCVpRxStAp2dE53Z/yoe00hAMFeTcKj4Tpp4s5v+eUgd7Ft6cQ4WEYc8763uO+ LnFWF3bNjXhNHM+ln+jJnrWnjZyBZumn2i2ZaA8IVJ49bhjCSwqX7/EFDyz1F9a5JYvu 9bil3ho9f+dBveZImjnazCKXV7wRnGS/sKw4/lCorYSG1qgESJO53EOh8Txz+cb/k1GI dgkLDDK8R5+CW4VlmlJspcvTFZLQ5WqzJlwuMQDuWPkedBNOEEkKiSl7GH2yZb9UpNmI z26twxbMc8v2870g6x3PV79oxR6IR4H/lsf770ZoESLsb/E7il6C7KaFhJUdAFvrGNkG F3lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712305322; x=1712910122; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dk21LyGHImJBYNFvztEgUb33gmCnQ5zbMfQ4IK8Cb8A=; b=GrW1Ey994iNC8NWBfMqX8gH3w+EKImtDEqpWtLdvtQX15H5pCxwnzPkz8zKn5IZJAU oqgKCFmsi7tbaZEmVmD9CRvI19ju3qceFK/kKyTZDjKjDBsd2/WRseD+KRS2jf+pynMO WGb/fgApLWffqdG6L/wGJYkheLgo09Pa/G/zIvXLmp42mj5PJpjnCAk4GjHWO7PnE2J3 rWaa8FMMEGvJB7sAckK1jJ16MAMzpSv1vQDlg33YZmnxCEfo1lvRkf+EbgujJJNdhSE9 rk0n0yhAIcvzMCELiDWHHWCjMSAcqb+zkz4+JrsE314S9zLsTWXpSIN7fCvb8BIaPs+z dDTA== X-Gm-Message-State: AOJu0YynQqYEZmNV3Y3UXM+w5Mv9bzQZ5YTBEx09uVsywdZI40YNqwP3 zilu1QVaHc+pzUUJZx0zcNgMNSAPwJWQijzGuiAzaBBjqFQq9tmMYfYbi/lJGFc= X-Received: by 2002:a5d:44cc:0:b0:341:c673:f1e8 with SMTP id z12-20020a5d44cc000000b00341c673f1e8mr764388wrr.9.1712305321686; Fri, 05 Apr 2024 01:22:01 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id j27-20020adfb31b000000b00341d84f641asm1452326wrd.8.2024.04.05.01.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:22:01 -0700 (PDT) From: Neil Armstrong Date: Fri, 05 Apr 2024 10:21:56 +0200 Subject: [PATCH 4/4] spmi: msm: support controller version 7 MIME-Version: 1.0 Message-Id: <20240405-topic-sm8x50-spmi-fixes-v1-4-031a9e5efab4@linaro.org> References: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> In-Reply-To: <20240405-topic-sm8x50-spmi-fixes-v1-0-031a9e5efab4@linaro.org> To: Caleb Connolly , Sumit Garg , Mateusz Kulikowski , Tom Rini , Dzmitry Sankouski Cc: u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3483; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=Of+sSRftRSuNrLL/g86jacc8masXQy+VXZvuP0XsLXk=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBmD7SlqG9NPSk1Uk5UfTjb64cR5ZP1gD6rz4hjHRri 6C6RZb+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZg+0pQAKCRB33NvayMhJ0Um0EA DCF5lLzcm7kH4xwmMOoXsI93QuGerqSfeQxof/D4bSdKCmaLguwcCrZYIBG1hHONbjvX1StpHOTaQu fXslTYYr6tnOibF/2VcokpMvIvr4mJX+0JEDYDvfD1aw02jZJl1vBj/C5Tx6nDfxinn5V+FZ9TrYkc RB7sqHRKqUY2eDHlhKNccHsiBUIsaY8a9oeIEFhC0P6tDswSOHeV9mqnQQfMNN49KOGNZBUP2zCFAl 1e7AukNIDmDyLXsjX1CC3EQhz7GxbUeiqSYT61VxxZpC0/eEEjeUd5IM40EBONsNmAnAaSeK9f7g2D ikBk+FpPj1Vf6ML6TlDva7OmWMsYKMCuzK91mZHSjzuw27dWUWs38tsUyQd15RxmkEfsbn9ovGfV3r UdNR7kKQWFRIxo+fbKyFXL7gV8vBtU6Iewx/HouqfpKlVEw5TQ0DhUS2UpaGly8lrNqrayo4n6MUA/ ViDensG+H3r6uW7vUVI708vTMGHf3h5+6vxL+31/aBlFg5lhu5vnbOyxZ0Wt2lD7SA4jFHqBAoFdCz Yk3C1QF4kzPq9FpAsc99f+32x9oLw6OLp+HuKYZIGpUtdLQI/XibLDxD2tHd92SMXl5t1S6IZCd+cR uOa0CGQ+T/rWjR77iDqpMc0NLaDyJwXmVAhfczHRZL6S8oH8RGoK6v0HbOTA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add the defines and support for SPMI arbiters version 7, which can handle up to 1024 peripherals, and can also drive a secondary bus which is not implemented yet. Signed-off-by: Neil Armstrong --- drivers/spmi/spmi-msm.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/spmi/spmi-msm.c b/drivers/spmi/spmi-msm.c index 46e2e09dc26..244de69b359 100644 --- a/drivers/spmi/spmi-msm.c +++ b/drivers/spmi/spmi-msm.c @@ -23,13 +23,17 @@ DECLARE_GLOBAL_DATA_PTR; #define PMIC_ARB_VERSION_V2_MIN 0x20010000 #define PMIC_ARB_VERSION_V3_MIN 0x30000000 #define PMIC_ARB_VERSION_V5_MIN 0x50000000 +#define PMIC_ARB_VERSION_V7_MIN 0x70000000 #define APID_MAP_OFFSET_V1_V2_V3 (0x800) #define APID_MAP_OFFSET_V5 (0x900) +#define APID_MAP_OFFSET_V7 (0x2000) #define ARB_CHANNEL_OFFSET(n) (0x4 * (n)) #define SPMI_CH_OFFSET(chnl) ((chnl) * 0x8000) #define SPMI_V5_OBS_CH_OFFSET(chnl) ((chnl) * 0x80) +#define SPMI_V7_OBS_CH_OFFSET(chnl) ((chnl) * 0x20) #define SPMI_V5_RW_CH_OFFSET(chnl) ((chnl) * 0x10000) +#define SPMI_V7_RW_CH_OFFSET(chnl) ((chnl) * 0x1000) #define SPMI_OWNERSHIP_PERIPH2OWNER(x) ((x) & 0x7) @@ -52,6 +56,7 @@ DECLARE_GLOBAL_DATA_PTR; #define SPMI_MAX_CHANNELS 128 #define SPMI_MAX_CHANNELS_V5 512 +#define SPMI_MAX_CHANNELS_V7 1024 #define SPMI_MAX_SLAVES 16 #define SPMI_MAX_PERIPH 256 @@ -62,7 +67,8 @@ enum arb_ver { V1 = 1, V2, V3, - V5 = 5 + V5 = 5, + V7 = 7 }; /* @@ -133,6 +139,12 @@ static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off, case V5: ch_offset = SPMI_V5_RW_CH_OFFSET(channel); + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_WRITE_LONG, off); + break; + + case V7: + ch_offset = SPMI_V7_RW_CH_OFFSET(channel); + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_WRITE_LONG, off); break; } @@ -196,6 +208,13 @@ static int msm_spmi_read(struct udevice *dev, int usid, int pid, int off) case V5: ch_offset = SPMI_V5_OBS_CH_OFFSET(channel); + /* Prepare read command */ + reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_READ_LONG, off); + break; + + case V7: + ch_offset = SPMI_V7_OBS_CH_OFFSET(channel); + /* Prepare read command */ reg = pmic_arb_fmt_cmd_v2(SPMI_CMD_EXT_REG_READ_LONG, off); break; @@ -250,10 +269,16 @@ static int msm_spmi_probe(struct udevice *dev) priv->arb_ver = V3; priv->arb_chnl = core_addr + APID_MAP_OFFSET_V1_V2_V3; priv->max_channels = SPMI_MAX_CHANNELS; - } else { + } else if (hw_ver < PMIC_ARB_VERSION_V7_MIN) { priv->arb_ver = V5; priv->arb_chnl = core_addr + APID_MAP_OFFSET_V5; - priv->max_channels = SPMI_MAX_CHANNELS_V5; + priv->max_channels = SPMI_MAX_CHANNELS; + priv->spmi_cnfg = dev_read_addr_name(dev, "cnfg"); + } else { + /* TOFIX: handle second bus */ + priv->arb_ver = V7; + priv->arb_chnl = core_addr + APID_MAP_OFFSET_V7; + priv->max_channels = SPMI_MAX_CHANNELS_V7; priv->spmi_cnfg = dev_read_addr_name(dev, "cnfg"); } @@ -276,7 +301,7 @@ static int msm_spmi_probe(struct udevice *dev) priv->channel_map[slave_id][pid] = i; /* Mark channels read-only when from different owner */ - if (priv->arb_ver == V5) { + 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);