From: Nickolay Goppen <setotau@mainlining.org>
To: Bjorn Andersson <andersson@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Nickolay Goppen <setotau@mainlining.org>
Cc: linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht, linux@mainlining.org,
Nickolay Goppen <setotau@yandex.ru>
Subject: [PATCH v5 1/3] pinctrl: qcom: lpass-lpi: Add ability to use custom pin offsets
Date: Wed, 03 Sep 2025 16:39:01 +0300 [thread overview]
Message-ID: <20250903-sdm660-lpass-lpi-v5-1-fe171098b6a1@mainlining.org> (raw)
In-Reply-To: <20250903-sdm660-lpass-lpi-v5-0-fe171098b6a1@mainlining.org>
By default pin_offset is calculated by formula: LPI_TLMM_REG_OFFSET * pin_id.
However not all platforms are using this pin_offset formula (e.g. SDM660 LPASS
LPI uses a predefined array of offsets [1]), so extend lpi_pingroup struct
with pin_offset field, introduce extended LPI_PINGROUP_OFFSET macro with
pin_offet field and introduce LPI_FLAG_USE_PREDEFINED_PIN_OFFSET flag.
This adds an ability to use predefined offset for pin if it exists.
[1] https://git.codelinaro.org/clo/la/kernel/msm-4.4/-/blob/LA.UM.7.2.c27-07400-sdm660.0/drivers/pinctrl/qcom/pinctrl-lpi.c#L107
Signed-off-by: Nickolay Goppen <setotau@mainlining.org>
---
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c | 18 ++++++++++++++++--
drivers/pinctrl/qcom/pinctrl-lpass-lpi.h | 18 ++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
index 54c77e0b96e91de8d96ff3cbd0ca88fadc6d55f6..d6c1ba109b958296acd8f129a781da1a08e8e438 100644
--- a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
+++ b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
@@ -41,13 +41,27 @@ struct lpi_pinctrl {
static int lpi_gpio_read(struct lpi_pinctrl *state, unsigned int pin,
unsigned int addr)
{
- return ioread32(state->tlmm_base + LPI_TLMM_REG_OFFSET * pin + addr);
+ u32 pin_offset;
+
+ if (state->data->flags & LPI_FLAG_USE_PREDEFINED_PIN_OFFSET)
+ pin_offset = state->data->groups[pin].pin_offset;
+ else
+ pin_offset = LPI_TLMM_REG_OFFSET * pin;
+
+ return ioread32(state->tlmm_base + pin_offset + addr);
}
static int lpi_gpio_write(struct lpi_pinctrl *state, unsigned int pin,
unsigned int addr, unsigned int val)
{
- iowrite32(val, state->tlmm_base + LPI_TLMM_REG_OFFSET * pin + addr);
+ u32 pin_offset;
+
+ if (state->data->flags & LPI_FLAG_USE_PREDEFINED_PIN_OFFSET)
+ pin_offset = state->data->groups[pin].pin_offset;
+ else
+ pin_offset = LPI_TLMM_REG_OFFSET * pin;
+
+ iowrite32(val, state->tlmm_base + pin_offset + addr);
return 0;
}
diff --git a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.h b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.h
index a9b2f65c1ebe0f8fb5d7814f8ef8b723c617c85b..f48368492861348519ea19b5291ac7df13050eef 100644
--- a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.h
+++ b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.h
@@ -55,6 +55,22 @@ struct pinctrl_pin_desc;
LPI_MUX_##f4, \
}, \
.nfuncs = 5, \
+ .pin_offset = 0, \
+ }
+
+#define LPI_PINGROUP_OFFSET(id, soff, f1, f2, f3, f4, poff) \
+ { \
+ .pin = id, \
+ .slew_offset = soff, \
+ .funcs = (int[]){ \
+ LPI_MUX_gpio, \
+ LPI_MUX_##f1, \
+ LPI_MUX_##f2, \
+ LPI_MUX_##f3, \
+ LPI_MUX_##f4, \
+ }, \
+ .nfuncs = 5, \
+ .pin_offset = poff, \
}
/*
@@ -62,6 +78,7 @@ struct pinctrl_pin_desc;
* pin configuration.
*/
#define LPI_FLAG_SLEW_RATE_SAME_REG BIT(0)
+#define LPI_FLAG_USE_PREDEFINED_PIN_OFFSET BIT(1)
struct lpi_pingroup {
unsigned int pin;
@@ -69,6 +86,7 @@ struct lpi_pingroup {
int slew_offset;
unsigned int *funcs;
unsigned int nfuncs;
+ unsigned int pin_offset;
};
struct lpi_function {
--
2.51.0
next prev parent reply other threads:[~2025-09-03 13:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 13:39 [PATCH v5 0/3] Add SDM660 LPASS LPI TLMM Nickolay Goppen
2025-09-03 13:39 ` Nickolay Goppen [this message]
2025-09-03 13:39 ` [PATCH v5 2/3] dt-bindings: pinctrl: qcom: Add SDM660 LPI pinctrl Nickolay Goppen
2025-09-03 14:14 ` Krzysztof Kozlowski
2025-09-03 13:39 ` [PATCH v5 3/3] pinctrl: qcom: Add SDM660 LPASS LPI TLMM Nickolay Goppen
2025-09-03 21:23 ` Richard Acayan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250903-sdm660-lpass-lpi-v5-1-fe171098b6a1@mainlining.org \
--to=setotau@mainlining.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@mainlining.org \
--cc=robh@kernel.org \
--cc=setotau@yandex.ru \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).