[PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category

Bartosz Golaszewski posted 5 patches 3 months, 1 week ago
There is a newer version of this series
drivers/pinctrl/pinmux.c                | 17 +++++++++++++++--
drivers/pinctrl/qcom/pinctrl-msm.c      | 10 ++++++++++
drivers/pinctrl/qcom/pinctrl-msm.h      |  5 +++++
drivers/pinctrl/qcom/pinctrl-sc8280xp.c |  2 +-
drivers/pinctrl/qcom/pinctrl-sm8650.c   |  2 +-
include/linux/pinctrl/pinctrl.h         | 14 ++++++++++++++
include/linux/pinctrl/pinmux.h          |  2 ++
7 files changed, 48 insertions(+), 4 deletions(-)
[PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category
Posted by Bartosz Golaszewski 3 months, 1 week ago
Note: this really is an RFC. Please don't spend too much time revieweing
the code in detail. I'd like to figure out if that's a good approach at
all first. Also: while I tested it on sm8650-qrd and sc8280xp-crd, the
last patch cannot be applied until all Qualcomm platforms are converted.

Problem: when pinctrl core binds pins to a consumer device and the
pinmux ops of the underlying driver are marked as strict, the pin in
question can no longer be requested as a GPIO using the GPIO descriptor
API. It will result in the following error:

[    5.095688] sc8280xp-tlmm f100000.pinctrl: pin GPIO_25 already requested by regulator-edp-3p3; cannot claim for f100000.pinctrl:570
[    5.107822] sc8280xp-tlmm f100000.pinctrl: error -EINVAL: pin-25 (f100000.pinctrl:570)

This typically makes sense except when the pins are muxed to a function
that actually says "GPIO". Of course, the function name is just a string
so it has no meaning to the pinctrl subsystem.

We have many Qualcomm SoCs (and I can imagine it's a common pattern in
other platforms as well) where we mux a pin to "gpio" function using the
`pinctrl-X` property in order to configure bias or drive-strength and
then access it using the gpiod API. This makes it impossible to mark the
pin controller module as "strict".

This series proposes to introduce a concept of a sub-category of
pinfunctions: GPIO functions where the above is not true and the pin
muxed as a GPIO can still be accessed via the GPIO consumer API even for
strict pinmuxers.

The first patch implements this functionality in pinctrl core, the
second adds local infrastructure to pinctrl-msm, next we convert two
Qualcomm platforms as examples and then finally enable the strict flag
in pinctrl-msm.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (5):
      pinctrl: allow to mark pin functions as requestable GPIOs
      pinctrl: qcom: add infrastructure for marking pin functions as GPIOs
      pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function
      pinctrl: qcom: sc8280xp: mark the `gpio` pin function as a non-strict function
      pinctrl: qcom: make the pinmuxing strict

 drivers/pinctrl/pinmux.c                | 17 +++++++++++++++--
 drivers/pinctrl/qcom/pinctrl-msm.c      | 10 ++++++++++
 drivers/pinctrl/qcom/pinctrl-msm.h      |  5 +++++
 drivers/pinctrl/qcom/pinctrl-sc8280xp.c |  2 +-
 drivers/pinctrl/qcom/pinctrl-sm8650.c   |  2 +-
 include/linux/pinctrl/pinctrl.h         | 14 ++++++++++++++
 include/linux/pinctrl/pinmux.h          |  2 ++
 7 files changed, 48 insertions(+), 4 deletions(-)
---
base-commit: 1343433ed38923a21425c602e92120a1f1db5f7a
change-id: 20250701-pinctrl-gpio-pinfuncs-de82bd9aac43

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Re: [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category
Posted by Linus Walleij 3 months ago
On Wed, Jul 2, 2025 at 10:45 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> Note: this really is an RFC. Please don't spend too much time revieweing
> the code in detail. I'd like to figure out if that's a good approach at
> all first.

I like what I see.

Go ahead with this patch series!

I can use this to strictify other pin controllers as well.

Yours,
Linus Walleij
Re: [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category
Posted by Konrad Dybcio 3 months, 1 week ago
On 7/2/25 10:45 AM, Bartosz Golaszewski wrote:
> Note: this really is an RFC. Please don't spend too much time revieweing
> the code in detail. I'd like to figure out if that's a good approach at
> all first. Also: while I tested it on sm8650-qrd and sc8280xp-crd, the
> last patch cannot be applied until all Qualcomm platforms are converted.
> 
> Problem: when pinctrl core binds pins to a consumer device and the
> pinmux ops of the underlying driver are marked as strict, the pin in
> question can no longer be requested as a GPIO using the GPIO descriptor
> API. It will result in the following error:
> 
> [    5.095688] sc8280xp-tlmm f100000.pinctrl: pin GPIO_25 already requested by regulator-edp-3p3; cannot claim for f100000.pinctrl:570
> [    5.107822] sc8280xp-tlmm f100000.pinctrl: error -EINVAL: pin-25 (f100000.pinctrl:570)

I can confirm the above no longer appears on the same SC8280XP CRD with
this series applied

Konrad