linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category
@ 2025-07-02  8:45 Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 1/5] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02  8:45 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

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>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH RFC 1/5] pinctrl: allow to mark pin functions as requestable GPIOs
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
@ 2025-07-02  8:45 ` Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 2/5] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs Bartosz Golaszewski
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02  8:45 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The name of the pin function has no real meaning to pinctrl core and is
there only for human readability of device properties. Some pins are
muxed as GPIOs but for "strict" pinmuxers it's impossible to request
them as GPIOs if they're bound to a devide - even if their function name
explicitly says "gpio". Add a new field to struct pinfunction that
allows to pass additional flags to pinctrl core. While we could go with
a boolean "is_gpio" field, a flags field is more future-proof.

If the PINFUNCTION_FLAG_GPIO is set for a given function, the pin muxed
to it can be requested as GPIO even on strict pin controllers. Add a new
callback to struct pinmux_ops - function_is_gpio() - that allows pinmux
core to inspect a function and see if it's a GPIO one.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/pinmux.c        | 17 +++++++++++++++--
 include/linux/pinctrl/pinctrl.h | 14 ++++++++++++++
 include/linux/pinctrl/pinmux.h  |  2 ++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 0743190da59e819d1c72c1ed1ece72f206d60d65..49855e6c49616d70bf9c805fc7c11ef41284dc52 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -89,13 +89,19 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned int pin)
 {
 	struct pin_desc *desc = pin_desc_get(pctldev, pin);
 	const struct pinmux_ops *ops = pctldev->desc->pmxops;
+	const struct pinctrl_setting_mux *mux_setting = desc->mux_setting;
+	bool func_is_gpio = false;
 
 	/* Can't inspect pin, assume it can be used */
 	if (!desc || !ops)
 		return true;
 
 	guard(mutex)(&desc->mux_lock);
-	if (ops->strict && desc->mux_usecount)
+	if (ops->function_is_gpio && mux_setting)
+		func_is_gpio = ops->function_is_gpio(pctldev,
+						     mux_setting->func);
+
+	if (ops->strict && desc->mux_usecount && !func_is_gpio)
 		return false;
 
 	return !(ops->strict && !!desc->gpio_owner);
@@ -116,7 +122,9 @@ static int pin_request(struct pinctrl_dev *pctldev,
 {
 	struct pin_desc *desc;
 	const struct pinmux_ops *ops = pctldev->desc->pmxops;
+	const struct pinctrl_setting_mux *mux_setting;
 	int status = -EINVAL;
+	bool func_is_gpio = false;
 
 	desc = pin_desc_get(pctldev, pin);
 	if (desc == NULL) {
@@ -126,11 +134,16 @@ static int pin_request(struct pinctrl_dev *pctldev,
 		goto out;
 	}
 
+	mux_setting = desc->mux_setting;
+
 	dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
 		pin, desc->name, owner);
 
 	scoped_guard(mutex, &desc->mux_lock) {
-		if ((!gpio_range || ops->strict) &&
+		if (ops->function_is_gpio && mux_setting)
+			func_is_gpio = ops->function_is_gpio(pctldev,
+							     mux_setting->func);
+		if ((!gpio_range || ops->strict) && !func_is_gpio &&
 		    desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
 			dev_err(pctldev->dev,
 				"pin %s already requested by %s; cannot claim for %s\n",
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index d138e18156452e008f24ca06358fcab45135632f..1a8084e2940537f8f0862761d3e47c56c8783193 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -11,6 +11,7 @@
 #ifndef __LINUX_PINCTRL_PINCTRL_H
 #define __LINUX_PINCTRL_PINCTRL_H
 
+#include <linux/bits.h>
 #include <linux/types.h>
 
 struct device;
@@ -206,16 +207,20 @@ extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
 				  const char *pin_group, const unsigned int **pins,
 				  unsigned int *num_pins);
 
+#define PINFUNCTION_FLAG_GPIO	BIT(0)
+
 /**
  * struct pinfunction - Description about a function
  * @name: Name of the function
  * @groups: An array of groups for this function
  * @ngroups: Number of groups in @groups
+ * @flags: Additional pin function flags
  */
 struct pinfunction {
 	const char *name;
 	const char * const *groups;
 	size_t ngroups;
+	unsigned long flags;
 };
 
 /* Convenience macro to define a single named pinfunction */
@@ -226,6 +231,15 @@ struct pinfunction {
 		.ngroups = (_ngroups),			\
 	}
 
+/* Same as PINCTRL_PINFUNCTION() but for the GPIO category of functions */
+#define PINCTRL_GPIO_PINFUNCTION(_name, _groups, _ngroups)	\
+(struct pinfunction) {						\
+		.name = (_name),				\
+		.groups = (_groups),				\
+		.ngroups = (_ngroups),				\
+		.flags = PINFUNCTION_FLAG_GPIO,			\
+	}
+
 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PINCTRL)
 extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np);
 #else
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h
index d6f7b58d6ad0cce421aad80463529c9ccc65d68e..6db6c3e1ccc2249d4b4204e6fc19bf7b4397cc81 100644
--- a/include/linux/pinctrl/pinmux.h
+++ b/include/linux/pinctrl/pinmux.h
@@ -66,6 +66,8 @@ struct pinmux_ops {
 				    unsigned int selector,
 				    const char * const **groups,
 				    unsigned int *num_groups);
+	bool (*function_is_gpio) (struct pinctrl_dev *pctldev,
+				  unsigned int selector);
 	int (*set_mux) (struct pinctrl_dev *pctldev, unsigned int func_selector,
 			unsigned int group_selector);
 	int (*gpio_request_enable) (struct pinctrl_dev *pctldev,

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 2/5] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 1/5] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
@ 2025-07-02  8:45 ` Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function Bartosz Golaszewski
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02  8:45 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Add a helper macro that wraps PINCTRL_GPIO_PINFUNCTION() for pinctrl-msm
pin functions and implement the .function_is_gpio() callback.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 9 +++++++++
 drivers/pinctrl/qcom/pinctrl-msm.h | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index f713c80d7f3eda06de027cd539e8decd4412876a..bb1e5aca058fc28c3cc823876c8fe7880d66b6fa 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -286,10 +286,19 @@ static int msm_pinmux_request_gpio(struct pinctrl_dev *pctldev,
 	return msm_pinmux_set_mux(pctldev, g->funcs[pctrl->soc->gpio_func], offset);
 }
 
+static bool msm_pinmux_function_is_gpio(struct pinctrl_dev *pctldev,
+					unsigned int selector)
+{
+	struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
+
+	return (pctrl->soc->functions[selector].flags & PINFUNCTION_FLAG_GPIO);
+}
+
 static const struct pinmux_ops msm_pinmux_ops = {
 	.request		= msm_pinmux_request,
 	.get_functions_count	= msm_get_functions_count,
 	.get_function_name	= msm_get_function_name,
+	.function_is_gpio	= msm_pinmux_function_is_gpio,
 	.get_function_groups	= msm_get_function_groups,
 	.gpio_request_enable	= msm_pinmux_request_gpio,
 	.set_mux		= msm_pinmux_set_mux,
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
index d7dc0947bb161868c8f433dc2536719b8afc8bd8..4625fa5320a95a4d24e3a0c98a249e4f163dd4c7 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.h
+++ b/drivers/pinctrl/qcom/pinctrl-msm.h
@@ -29,6 +29,11 @@ struct pinctrl_pin_desc;
 					fname##_groups,		\
 					ARRAY_SIZE(fname##_groups))
 
+#define MSM_GPIO_PIN_FUNCTION(fname)				\
+	[msm_mux_##fname] = PINCTRL_GPIO_PINFUNCTION(#fname,	\
+					fname##_groups,		\
+					ARRAY_SIZE(fname##_groups))
+
 #define QCA_PIN_FUNCTION(fname)					\
 	[qca_mux_##fname] = PINCTRL_PINFUNCTION(#fname,		\
 					fname##_groups,		\

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 1/5] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 2/5] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs Bartosz Golaszewski
@ 2025-07-02  8:45 ` Bartosz Golaszewski
  2025-07-02 10:55   ` Konrad Dybcio
  2025-07-02 22:50   ` Dmitry Baryshkov
  2025-07-02  8:45 ` [PATCH RFC 4/5] pinctrl: qcom: sc8280xp: " Bartosz Golaszewski
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02  8:45 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Allow pins muxed to the "gpio" function to be requested as GPIOs even if
pinmux_ops say the controller should be strict.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/qcom/pinctrl-sm8650.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-sm8650.c b/drivers/pinctrl/qcom/pinctrl-sm8650.c
index 449a0077f4b10666ecd9dfaae8e0057a91e181a6..4ab0e75079cd5dec1d86835dae30c9a09455c7f3 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8650.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8650.c
@@ -1328,7 +1328,7 @@ static const char *const vsense_trigger_mirnat_groups[] = {
 };
 
 static const struct pinfunction sm8650_functions[] = {
-	MSM_PIN_FUNCTION(gpio),
+	MSM_GPIO_PIN_FUNCTION(gpio),
 	MSM_PIN_FUNCTION(aoss_cti),
 	MSM_PIN_FUNCTION(atest_char),
 	MSM_PIN_FUNCTION(atest_usb),

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 4/5] pinctrl: qcom: sc8280xp: mark the `gpio` pin function as a non-strict function
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2025-07-02  8:45 ` [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function Bartosz Golaszewski
@ 2025-07-02  8:45 ` Bartosz Golaszewski
  2025-07-02  8:45 ` [PATCH RFC 5/5] pinctrl: qcom: make the pinmuxing strict Bartosz Golaszewski
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02  8:45 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Allow pins muxed to the "gpio" function to be requested as GPIOs even if
pinmux_ops say the controller should be strict.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/qcom/pinctrl-sc8280xp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-sc8280xp.c b/drivers/pinctrl/qcom/pinctrl-sc8280xp.c
index 6ccd7e5648d420072f7ce467d92ef0764a6d7764..352cb08bdc12cabed8a0c3b2b9616a56578c6a58 100644
--- a/drivers/pinctrl/qcom/pinctrl-sc8280xp.c
+++ b/drivers/pinctrl/qcom/pinctrl-sc8280xp.c
@@ -1527,7 +1527,7 @@ static const struct pinfunction sc8280xp_functions[] = {
 	MSM_PIN_FUNCTION(gcc_gp3),
 	MSM_PIN_FUNCTION(gcc_gp4),
 	MSM_PIN_FUNCTION(gcc_gp5),
-	MSM_PIN_FUNCTION(gpio),
+	MSM_GPIO_PIN_FUNCTION(gpio),
 	MSM_PIN_FUNCTION(hs1_mi2s),
 	MSM_PIN_FUNCTION(hs2_mi2s),
 	MSM_PIN_FUNCTION(hs3_mi2s),

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH RFC 5/5] pinctrl: qcom: make the pinmuxing strict
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2025-07-02  8:45 ` [PATCH RFC 4/5] pinctrl: qcom: sc8280xp: " Bartosz Golaszewski
@ 2025-07-02  8:45 ` Bartosz Golaszewski
  2025-07-02 11:03 ` [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Konrad Dybcio
  2025-07-03 22:39 ` Linus Walleij
  6 siblings, 0 replies; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02  8:45 UTC (permalink / raw)
  To: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The strict flag in struct pinmux_ops disallows the usage of the same pin
as a GPIO and for another function. Without it, a rouge user-space
process with enough privileges (or even a buggy driver) can request a
used pin as GPIO and drive it, potentially confusing devices or even
crashing the system. Set it globally for all pinctrl-msm users.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index bb1e5aca058fc28c3cc823876c8fe7880d66b6fa..8727b8f394a5a2669c0dc8ffe5f1b83d5db526e8 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -302,6 +302,7 @@ static const struct pinmux_ops msm_pinmux_ops = {
 	.get_function_groups	= msm_get_function_groups,
 	.gpio_request_enable	= msm_pinmux_request_gpio,
 	.set_mux		= msm_pinmux_set_mux,
+	.strict			= true,
 };
 
 static int msm_config_reg(struct msm_pinctrl *pctrl,

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function
  2025-07-02  8:45 ` [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function Bartosz Golaszewski
@ 2025-07-02 10:55   ` Konrad Dybcio
  2025-07-02 22:50   ` Dmitry Baryshkov
  1 sibling, 0 replies; 12+ messages in thread
From: Konrad Dybcio @ 2025-07-02 10:55 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Bjorn Andersson,
	Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

On 7/2/25 10:45 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Allow pins muxed to the "gpio" function to be requested as GPIOs even if
> pinmux_ops say the controller should be strict.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---

fwiw this simple change could be a single 'run sed on all files' if
we decide to go with this approach

Konrad

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2025-07-02  8:45 ` [PATCH RFC 5/5] pinctrl: qcom: make the pinmuxing strict Bartosz Golaszewski
@ 2025-07-02 11:03 ` Konrad Dybcio
  2025-07-03 22:39 ` Linus Walleij
  6 siblings, 0 replies; 12+ messages in thread
From: Konrad Dybcio @ 2025-07-02 11:03 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Bjorn Andersson,
	Konrad Dybcio, Alexey Klimov
  Cc: linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function
  2025-07-02  8:45 ` [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function Bartosz Golaszewski
  2025-07-02 10:55   ` Konrad Dybcio
@ 2025-07-02 22:50   ` Dmitry Baryshkov
  2025-07-03  8:17     ` Bartosz Golaszewski
  1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Baryshkov @ 2025-07-02 22:50 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov,
	linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

On Wed, Jul 02, 2025 at 10:45:33AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Allow pins muxed to the "gpio" function to be requested as GPIOs even if
> pinmux_ops say the controller should be strict.

This is a strange commit message, shouldn't "gpio" function behave
exactly like that - mark the pin as a GPIO?

> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/pinctrl/qcom/pinctrl-sm8650.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/qcom/pinctrl-sm8650.c b/drivers/pinctrl/qcom/pinctrl-sm8650.c
> index 449a0077f4b10666ecd9dfaae8e0057a91e181a6..4ab0e75079cd5dec1d86835dae30c9a09455c7f3 100644
> --- a/drivers/pinctrl/qcom/pinctrl-sm8650.c
> +++ b/drivers/pinctrl/qcom/pinctrl-sm8650.c
> @@ -1328,7 +1328,7 @@ static const char *const vsense_trigger_mirnat_groups[] = {
>  };
>  
>  static const struct pinfunction sm8650_functions[] = {
> -	MSM_PIN_FUNCTION(gpio),
> +	MSM_GPIO_PIN_FUNCTION(gpio),
>  	MSM_PIN_FUNCTION(aoss_cti),
>  	MSM_PIN_FUNCTION(atest_char),
>  	MSM_PIN_FUNCTION(atest_usb),
> 
> -- 
> 2.48.1
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function
  2025-07-02 22:50   ` Dmitry Baryshkov
@ 2025-07-03  8:17     ` Bartosz Golaszewski
  2025-07-04 16:50       ` Dmitry Baryshkov
  0 siblings, 1 reply; 12+ messages in thread
From: Bartosz Golaszewski @ 2025-07-03  8:17 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov,
	linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

On Thu, Jul 3, 2025 at 12:50 AM Dmitry Baryshkov
<dmitry.baryshkov@oss.qualcomm.com> wrote:
>
> On Wed, Jul 02, 2025 at 10:45:33AM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Allow pins muxed to the "gpio" function to be requested as GPIOs even if
> > pinmux_ops say the controller should be strict.
>
> This is a strange commit message, shouldn't "gpio" function behave
> exactly like that - mark the pin as a GPIO?
>

They should but they don't. I should maybe rework the commit message
to say: "muxed to the function called `gpio`...". The "gpio" here is
just a name, it could as well be saying "dmitry" or "123456", the
pinctrl core doesn't interpret it in any special way. What I'm doing
here, is marking the associated struct pinfunction object as one that
should allow pinmux core to export this pin as a GPIOLIB GPIO.

Bart

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category
  2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2025-07-02 11:03 ` [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Konrad Dybcio
@ 2025-07-03 22:39 ` Linus Walleij
  6 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2025-07-03 22:39 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Bjorn Andersson, Konrad Dybcio, Alexey Klimov, linux-gpio,
	linux-kernel, linux-arm-msm, Bartosz Golaszewski

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function
  2025-07-03  8:17     ` Bartosz Golaszewski
@ 2025-07-04 16:50       ` Dmitry Baryshkov
  0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Baryshkov @ 2025-07-04 16:50 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Bjorn Andersson, Konrad Dybcio, Alexey Klimov,
	linux-gpio, linux-kernel, linux-arm-msm, Bartosz Golaszewski

On Thu, Jul 03, 2025 at 10:17:43AM +0200, Bartosz Golaszewski wrote:
> On Thu, Jul 3, 2025 at 12:50 AM Dmitry Baryshkov
> <dmitry.baryshkov@oss.qualcomm.com> wrote:
> >
> > On Wed, Jul 02, 2025 at 10:45:33AM +0200, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > Allow pins muxed to the "gpio" function to be requested as GPIOs even if
> > > pinmux_ops say the controller should be strict.
> >
> > This is a strange commit message, shouldn't "gpio" function behave
> > exactly like that - mark the pin as a GPIO?
> >
> 
> They should but they don't. I should maybe rework the commit message
> to say: "muxed to the function called `gpio`...". The "gpio" here is
> just a name, it could as well be saying "dmitry" or "123456", the
> pinctrl core doesn't interpret it in any special way. What I'm doing
> here, is marking the associated struct pinfunction object as one that
> should allow pinmux core to export this pin as a GPIOLIB GPIO.

Ack

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-07-04 16:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-02  8:45 [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
2025-07-02  8:45 ` [PATCH RFC 1/5] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
2025-07-02  8:45 ` [PATCH RFC 2/5] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs Bartosz Golaszewski
2025-07-02  8:45 ` [PATCH RFC 3/5] pinctrl: qcom: sm8650: mark the `gpio` pin function as a non-strict function Bartosz Golaszewski
2025-07-02 10:55   ` Konrad Dybcio
2025-07-02 22:50   ` Dmitry Baryshkov
2025-07-03  8:17     ` Bartosz Golaszewski
2025-07-04 16:50       ` Dmitry Baryshkov
2025-07-02  8:45 ` [PATCH RFC 4/5] pinctrl: qcom: sc8280xp: " Bartosz Golaszewski
2025-07-02  8:45 ` [PATCH RFC 5/5] pinctrl: qcom: make the pinmuxing strict Bartosz Golaszewski
2025-07-02 11:03 ` [PATCH RFC 0/5] pinctrl: introduce the concept of a GPIO pin function category Konrad Dybcio
2025-07-03 22:39 ` Linus Walleij

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).