* [PATCH v4 1/7] pinctrl: introduce pinctrl_gpio_get_config()
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
@ 2026-03-17 14:40 ` Dan Carpenter
2026-03-17 15:40 ` Andy Shevchenko
2026-03-17 14:40 ` [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:40 UTC (permalink / raw)
To: Linus Walleij, AKASHI Takahiro
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Andy Shevchenko,
Linus Walleij, Bartosz Golaszewski, arm-scmi, Vincent Guittot,
Khaled Ali Ahmed, Michal Simek
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
This is a counterpart of pinctrl_gpio_set_config(), which will be used
to implement the ->get() interface in a GPIO driver for SCMI.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
v4: Fix kernel-doc (Andy)
drivers/pinctrl/core.c | 31 +++++++++++++++++++++++++++++++
include/linux/pinctrl/consumer.h | 9 +++++++++
2 files changed, 40 insertions(+)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 2edc9bdad183..c471f3fbd035 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -30,6 +30,7 @@
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/devinfo.h>
#include <linux/pinctrl/machine.h>
+#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinctrl.h>
#include "core.h"
@@ -938,6 +939,36 @@ int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
}
EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config);
+/**
+ * pinctrl_gpio_get_config() - Get the config for a given GPIO pin
+ * @gc: GPIO chip structure from the GPIO subsystem
+ * @offset: hardware offset of the GPIO relative to the controller
+ * @config: the configuration to query. On success it holds the result
+ * Return: 0 on success, negative errno otherwise
+ */
+int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset, unsigned long *config)
+{
+ struct pinctrl_gpio_range *range;
+ struct pinctrl_dev *pctldev;
+ int ret, pin;
+
+ ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
+ if (ret)
+ return ret;
+
+ mutex_lock(&pctldev->mutex);
+ pin = gpio_to_pin(range, gc, offset);
+ ret = pin_config_get_for_pin(pctldev, pin, config);
+ mutex_unlock(&pctldev->mutex);
+
+ if (ret)
+ return ret;
+
+ *config = pinconf_to_config_argument(*config);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pinctrl_gpio_get_config);
+
static struct pinctrl_state *find_state(struct pinctrl *p,
const char *name)
{
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 63ce16191eb9..11b8f0b8da0c 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -35,6 +35,8 @@ int pinctrl_gpio_direction_output(struct gpio_chip *gc,
unsigned int offset);
int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
unsigned long config);
+int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset,
+ unsigned long *config);
struct pinctrl * __must_check pinctrl_get(struct device *dev);
void pinctrl_put(struct pinctrl *p);
@@ -101,6 +103,13 @@ pinctrl_gpio_direction_output(struct gpio_chip *gc, unsigned int offset)
return 0;
}
+static inline int
+pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset,
+ unsigned long *config)
+{
+ return 0;
+}
+
static inline int
pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
unsigned long config)
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v4 1/7] pinctrl: introduce pinctrl_gpio_get_config()
2026-03-17 14:40 ` [PATCH v4 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
@ 2026-03-17 15:40 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-03-17 15:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Linus Walleij, AKASHI Takahiro, Bartosz Golaszewski, linux-gpio,
linux-kernel, Bartosz Golaszewski, arm-scmi, Vincent Guittot,
Khaled Ali Ahmed, Michal Simek
On Tue, Mar 17, 2026 at 05:40:20PM +0300, Dan Carpenter wrote:
> This is a counterpart of pinctrl_gpio_set_config(), which will be used
> to implement the ->get() interface in a GPIO driver for SCMI.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
@ 2026-03-17 14:40 ` Dan Carpenter
2026-03-17 15:38 ` Andy Shevchenko
2026-03-17 14:40 ` [PATCH v4 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:40 UTC (permalink / raw)
To: Sudeep Holla, AKASHI Takahiro
Cc: Cristian Marussi, Linus Walleij, arm-scmi, linux-arm-kernel,
linux-gpio, linux-kernel, Andy Shevchenko, Bartosz Golaszewski,
Vincent Guittot, Khaled Ali Ahmed, Michal Simek
The PIN_CONFIG_LEVEL parameter represents the value of the pin, whether
reading or writing to the pin. In SCMI, the parameter is represented by
two different values SCMI_PIN_OUTPUT_VALUE for writing to a pin and
SCMI_PIN_INPUT_VALUE for reading. The current code translates
PIN_CONFIG_LEVEL as SCMI_PIN_OUTPUT_VALUE (writing).
Add a function to translate it to either INPUT or OUTPUT depending on
whether it is called from a _get or _set() operation.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Acked-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/pinctrl/pinctrl-scmi.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index f4f296e07be5..5d347e6b2e4c 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -251,9 +251,6 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
case PIN_CONFIG_MODE_LOW_POWER:
*type = SCMI_PIN_LOW_POWER_MODE;
break;
- case PIN_CONFIG_LEVEL:
- *type = SCMI_PIN_OUTPUT_VALUE;
- break;
case PIN_CONFIG_OUTPUT_ENABLE:
*type = SCMI_PIN_OUTPUT_MODE;
break;
@@ -276,6 +273,28 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
return 0;
}
+static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
+ enum scmi_pinctrl_conf_type *type)
+{
+ if (param == PIN_CONFIG_LEVEL) {
+ *type = SCMI_PIN_INPUT_VALUE;
+ return 0;
+ }
+
+ return pinctrl_scmi_map_pinconf_type(param, type);
+}
+
+static int pinctrl_scmi_map_pinconf_type_set(enum pin_config_param param,
+ enum scmi_pinctrl_conf_type *type)
+{
+ if (param == PIN_CONFIG_LEVEL) {
+ *type = SCMI_PIN_OUTPUT_VALUE;
+ return 0;
+ }
+
+ return pinctrl_scmi_map_pinconf_type(param, type);
+}
+
static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev,
unsigned int pin, unsigned long *config)
{
@@ -290,7 +309,7 @@ static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev,
config_type = pinconf_to_config_param(*config);
- ret = pinctrl_scmi_map_pinconf_type(config_type, &type);
+ ret = pinctrl_scmi_map_pinconf_type_get(config_type, &type);
if (ret)
return ret;
@@ -363,7 +382,7 @@ static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev,
for (i = 0; i < num_configs; i++) {
param = pinconf_to_config_param(configs[i]);
- ret = pinctrl_scmi_map_pinconf_type(param, &p_config_type[i]);
+ ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[i]);
if (ret) {
dev_err(pmx->dev, "Error map pinconf_type %d\n", ret);
goto free_config;
@@ -405,7 +424,7 @@ static int pinctrl_scmi_pinconf_group_set(struct pinctrl_dev *pctldev,
for (i = 0; i < num_configs; i++) {
param = pinconf_to_config_param(configs[i]);
- ret = pinctrl_scmi_map_pinconf_type(param, &p_config_type[i]);
+ ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[i]);
if (ret) {
dev_err(pmx->dev, "Error map pinconf_type %d\n", ret);
goto free_config;
@@ -440,7 +459,7 @@ static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev,
return -EINVAL;
config_type = pinconf_to_config_param(*config);
- ret = pinctrl_scmi_map_pinconf_type(config_type, &type);
+ ret = pinctrl_scmi_map_pinconf_type_get(config_type, &type);
if (ret) {
dev_err(pmx->dev, "Error map pinconf_type %d\n", ret);
return ret;
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
2026-03-17 14:40 ` [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
@ 2026-03-17 15:38 ` Andy Shevchenko
2026-03-18 7:19 ` Dan Carpenter
0 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2026-03-17 15:38 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sudeep Holla, AKASHI Takahiro, Cristian Marussi, Linus Walleij,
arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Bartosz Golaszewski, Vincent Guittot, Khaled Ali Ahmed,
Michal Simek
On Tue, Mar 17, 2026 at 05:40:27PM +0300, Dan Carpenter wrote:
> The PIN_CONFIG_LEVEL parameter represents the value of the pin, whether
> reading or writing to the pin. In SCMI, the parameter is represented by
> two different values SCMI_PIN_OUTPUT_VALUE for writing to a pin and
> SCMI_PIN_INPUT_VALUE for reading. The current code translates
> PIN_CONFIG_LEVEL as SCMI_PIN_OUTPUT_VALUE (writing).
>
> Add a function to translate it to either INPUT or OUTPUT depending on
> whether it is called from a _get or _set() operation.
In three consecutive patches against the same file you have three (!) different
prefixes. Please, align with what is being used most in the driver and/or subsystem
(the driver seems has no consensus with itself, so subsystem then, something like
"pinctrl: scmi: ").
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
2026-03-17 15:38 ` Andy Shevchenko
@ 2026-03-18 7:19 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2026-03-18 7:19 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Sudeep Holla, AKASHI Takahiro, Cristian Marussi, Linus Walleij,
arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Bartosz Golaszewski, Vincent Guittot, Khaled Ali Ahmed,
Michal Simek
On Tue, Mar 17, 2026 at 05:38:36PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 17, 2026 at 05:40:27PM +0300, Dan Carpenter wrote:
> > The PIN_CONFIG_LEVEL parameter represents the value of the pin, whether
> > reading or writing to the pin. In SCMI, the parameter is represented by
> > two different values SCMI_PIN_OUTPUT_VALUE for writing to a pin and
> > SCMI_PIN_INPUT_VALUE for reading. The current code translates
> > PIN_CONFIG_LEVEL as SCMI_PIN_OUTPUT_VALUE (writing).
> >
> > Add a function to translate it to either INPUT or OUTPUT depending on
> > whether it is called from a _get or _set() operation.
>
> In three consecutive patches against the same file you have three (!) different
> prefixes. Please, align with what is being used most in the driver and/or subsystem
> (the driver seems has no consensus with itself, so subsystem then, something like
> "pinctrl: scmi: ").
Oops. Crud. You're right.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
@ 2026-03-17 14:40 ` Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:40 UTC (permalink / raw)
To: Sudeep Holla, AKASHI Takahiro
Cc: Cristian Marussi, Linus Walleij, arm-scmi, linux-arm-kernel,
linux-gpio, linux-kernel, Andy Shevchenko, Bartosz Golaszewski,
Vincent Guittot, Khaled Ali Ahmed, Michal Simek
The argument for PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS is supposed to
be expressed in terms of ohms. But the pinctrl-scmi driver was
implementing it the same as PIN_CONFIG_OUTPUT and writing either a
zero or one to the pin.
The SCMI protocol doesn't have an support configuration type so just
delete this code instead of replacing it.
Cc: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
drivers/pinctrl/pinctrl-scmi.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 5d347e6b2e4c..de8c113bc61d 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -254,9 +254,6 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
case PIN_CONFIG_OUTPUT_ENABLE:
*type = SCMI_PIN_OUTPUT_MODE;
break;
- case PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS:
- *type = SCMI_PIN_OUTPUT_VALUE;
- break;
case PIN_CONFIG_POWER_SOURCE:
*type = SCMI_PIN_POWER_SOURCE;
break;
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v4 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
` (2 preceding siblings ...)
2026-03-17 14:40 ` [PATCH v4 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
@ 2026-03-17 14:40 ` Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:40 UTC (permalink / raw)
To: Sudeep Holla, AKASHI Takahiro
Cc: Cristian Marussi, Linus Walleij, arm-scmi, linux-arm-kernel,
linux-gpio, linux-kernel, Andy Shevchenko, Bartosz Golaszewski,
Vincent Guittot, Khaled Ali Ahmed, Michal Simek
The PIN_CONFIG_PERSIST_STATE setting ensures that the pin state persists
across a sleep or controller reset. The SCMI spec does not have an
equivalent command to this so just ignore it.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
drivers/pinctrl/pinctrl-scmi.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index de8c113bc61d..f22be6b7b82a 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -361,7 +361,7 @@ static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev,
unsigned long *configs,
unsigned int num_configs)
{
- int i, ret;
+ int i, cnt, ret;
struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
enum scmi_pinctrl_conf_type config_type[SCMI_NUM_CONFIGS];
u32 config_value[SCMI_NUM_CONFIGS];
@@ -377,17 +377,21 @@ static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev,
if (ret)
return ret;
+ cnt = 0;
for (i = 0; i < num_configs; i++) {
param = pinconf_to_config_param(configs[i]);
- ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[i]);
+ if (param == PIN_CONFIG_PERSIST_STATE)
+ continue;
+ ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[cnt]);
if (ret) {
dev_err(pmx->dev, "Error map pinconf_type %d\n", ret);
goto free_config;
}
- p_config_value[i] = pinconf_to_config_argument(configs[i]);
+ p_config_value[cnt] = pinconf_to_config_argument(configs[i]);
+ cnt++;
}
- ret = pinctrl_ops->settings_conf(pmx->ph, pin, PIN_TYPE, num_configs,
+ ret = pinctrl_ops->settings_conf(pmx->ph, pin, PIN_TYPE, cnt,
p_config_type, p_config_value);
if (ret)
dev_err(pmx->dev, "Error parsing config %d\n", ret);
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v4 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
` (3 preceding siblings ...)
2026-03-17 14:40 ` [PATCH v4 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
@ 2026-03-17 14:40 ` Dan Carpenter
2026-03-18 11:07 ` Cristian Marussi
2026-03-17 14:40 ` [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
2026-03-17 14:41 ` [PATCH v4 7/7] gpio: add " Dan Carpenter
6 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:40 UTC (permalink / raw)
To: Sudeep Holla, AKASHI Takahiro
Cc: Cristian Marussi, arm-scmi, linux-arm-kernel, linux-kernel,
Andy Shevchenko, Linus Walleij, Bartosz Golaszewski, linux-gpio,
Vincent Guittot, Khaled Ali Ahmed, Michal Simek
The SCMI protocol specification says that the PINCTRL_REQUEST and
PINCTRL_RELEASE commands are optional. So if the SCMI server returns
-EOPNOTSUPP, then treat that as success and continue.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/firmware/arm_scmi/pinctrl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scmi/pinctrl.c
index a020e23d7c49..42cb1aef1fe1 100644
--- a/drivers/firmware/arm_scmi/pinctrl.c
+++ b/drivers/firmware/arm_scmi/pinctrl.c
@@ -578,6 +578,8 @@ static int scmi_pinctrl_request_free(const struct scmi_protocol_handle *ph,
tx->flags = cpu_to_le32(type);
ret = ph->xops->do_xfer(ph, t);
+ if (ret == -EOPNOTSUPP)
+ ret = 0;
ph->xops->xfer_put(ph, t);
return ret;
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v4 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP
2026-03-17 14:40 ` [PATCH v4 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
@ 2026-03-18 11:07 ` Cristian Marussi
0 siblings, 0 replies; 14+ messages in thread
From: Cristian Marussi @ 2026-03-18 11:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sudeep Holla, AKASHI Takahiro, Cristian Marussi, arm-scmi,
linux-arm-kernel, linux-kernel, Andy Shevchenko, Linus Walleij,
Bartosz Golaszewski, linux-gpio, Vincent Guittot,
Khaled Ali Ahmed, Michal Simek
On Tue, Mar 17, 2026 at 05:40:50PM +0300, Dan Carpenter wrote:
> The SCMI protocol specification says that the PINCTRL_REQUEST and
> PINCTRL_RELEASE commands are optional. So if the SCMI server returns
> -EOPNOTSUPP, then treat that as success and continue.
Hi
a nitpick, this should be
firmware: arm_scmi: Allow PINCTRL_REQUEST to return EOPNOTSUPP
Thanks,
Cristian
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
> ---
> drivers/firmware/arm_scmi/pinctrl.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scmi/pinctrl.c
> index a020e23d7c49..42cb1aef1fe1 100644
> --- a/drivers/firmware/arm_scmi/pinctrl.c
> +++ b/drivers/firmware/arm_scmi/pinctrl.c
> @@ -578,6 +578,8 @@ static int scmi_pinctrl_request_free(const struct scmi_protocol_handle *ph,
> tx->flags = cpu_to_le32(type);
>
> ret = ph->xops->do_xfer(ph, t);
> + if (ret == -EOPNOTSUPP)
> + ret = 0;
> ph->xops->xfer_put(ph, t);
>
> return ret;
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
` (4 preceding siblings ...)
2026-03-17 14:40 ` [PATCH v4 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
@ 2026-03-17 14:40 ` Dan Carpenter
2026-03-18 7:14 ` Krzysztof Kozlowski
2026-03-17 14:41 ` [PATCH v4 7/7] gpio: add " Dan Carpenter
6 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:40 UTC (permalink / raw)
To: Linus Walleij, AKASHI Takahiro
Cc: Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Dan Carpenter, linux-gpio, devicetree, linux-kernel,
Andy Shevchenko, Linus Walleij, Bartosz Golaszewski, arm-scmi,
Vincent Guittot, Khaled Ali Ahmed, Michal Simek
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
Add a dt binding for the gpio-by-pinctrl driver. The driver is used
for doing GPIO over the SCMI pinctrl protocol. There are a few
mandatory properties such as gpio-ranges and ngpios, but it's not
mandatory to specify the pin-mux.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
---
v4: Changed additionalProperties: true to false.
My concern here was that there might be a lot of gpio properties
which I wasn't familiar with. To check I did:
grep :$ Documentation/devicetree/bindings/gpio/* | \
cut -d : -f 2- | perl -ne 's/[\ ]*//g; print "$_\n"' | \
sort | uniq -c
The only property that I decided to add was gpio-line-names.
Deleted the extra bonus example.
.../bindings/gpio/pin-control-gpio.yaml | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
diff --git a/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
new file mode 100644
index 000000000000..ebc3fdd039fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/pin-control-gpio.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Pin control based generic GPIO controller
+
+description:
+ The pin control-based GPIO will facilitate a pin controller's ability
+ to drive electric lines high/low and other generic properties of a
+ pin controller to perform general-purpose one-bit binary I/O.
+
+maintainers:
+ - Dan Carpenter <dan.carpenter@linaro.og>
+
+properties:
+ compatible:
+ const: scmi-pinctrl-gpio
+
+ gpio-controller: true
+
+ "#gpio-cells":
+ const: 2
+
+ gpio-line-names: true
+
+ gpio-ranges: true
+
+ ngpios: true
+
+patternProperties:
+ "^.+-hog(-[0-9]+)?$":
+ type: object
+
+ required:
+ - gpio-hog
+
+required:
+ - compatible
+ - gpio-controller
+ - "#gpio-cells"
+ - gpio-ranges
+ - ngpios
+
+additionalProperties: false
+
+examples:
+ - |
+ gpio {
+ compatible = "scmi-pinctrl-gpio";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <3>;
+ gpio-line-names = "gpio_5_17", "gpio_5_20", "gpio_5_22", "gpio_2_1";
+ gpio-ranges = <&scmi_pinctrl 0 30 4>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&keys_pins>;
+ };
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
2026-03-17 14:40 ` [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
@ 2026-03-18 7:14 ` Krzysztof Kozlowski
0 siblings, 0 replies; 14+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-18 7:14 UTC (permalink / raw)
To: Dan Carpenter
Cc: Linus Walleij, AKASHI Takahiro, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Dan Carpenter, linux-gpio,
devicetree, linux-kernel, Andy Shevchenko, Bartosz Golaszewski,
arm-scmi, Vincent Guittot, Khaled Ali Ahmed, Michal Simek
On Tue, Mar 17, 2026 at 05:40:57PM +0300, Dan Carpenter wrote:
> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
>
> Add a dt binding for the gpio-by-pinctrl driver. The driver is used
Drop all references to the driver. Describe the
device/hardware/firmware/interface, not driver. Same for subject.
> for doing GPIO over the SCMI pinctrl protocol. There are a few
> mandatory properties such as gpio-ranges and ngpios, but it's not
> mandatory to specify the pin-mux.
There is no such thing there as pin-mux, so I don't understand above
sentence.
Describe the hardware/firmware/interface, not the patch, because we
easily see which properties are mandatory. Schema tells that.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
A nit, subject: drop second/last, redundant "bindings for". The
"dt-bindings" prefix is already stating that these are bindings.
See also:
https://elixir.bootlin.com/linux/v6.17-rc3/source/Documentation/devicetree/bindings/submitting-patches.rst#L18
> ---
> v4: Changed additionalProperties: true to false.
>
> My concern here was that there might be a lot of gpio properties
> which I wasn't familiar with. To check I did:
> grep :$ Documentation/devicetree/bindings/gpio/* | \
> cut -d : -f 2- | perl -ne 's/[\ ]*//g; print "$_\n"' | \
> sort | uniq -c
> The only property that I decided to add was gpio-line-names.
>
> Deleted the extra bonus example.
>
> .../bindings/gpio/pin-control-gpio.yaml | 59 +++++++++++++++++++
> 1 file changed, 59 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
>
> diff --git a/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
> new file mode 100644
> index 000000000000..ebc3fdd039fd
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
> @@ -0,0 +1,59 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/gpio/pin-control-gpio.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Pin control based generic GPIO controller
> +
> +description:
> + The pin control-based GPIO will facilitate a pin controller's ability
> + to drive electric lines high/low and other generic properties of a
> + pin controller to perform general-purpose one-bit binary I/O.
> +
> +maintainers:
> + - Dan Carpenter <dan.carpenter@linaro.og>
> +
> +properties:
> + compatible:
> + const: scmi-pinctrl-gpio
> +
> + gpio-controller: true
> +
> + "#gpio-cells":
> + const: 2
> +
> + gpio-line-names: true
> +
> + gpio-ranges: true
> +
> + ngpios: true
> +
> +patternProperties:
> + "^.+-hog(-[0-9]+)?$":
> + type: object
> +
> + required:
> + - gpio-hog
> +
> +required:
> + - compatible
> + - gpio-controller
> + - "#gpio-cells"
> + - gpio-ranges
> + - ngpios
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + gpio {
> + compatible = "scmi-pinctrl-gpio";
> + gpio-controller;
> + #gpio-cells = <2>;
> + ngpios = <3>;
Three pins here
> + gpio-line-names = "gpio_5_17", "gpio_5_20", "gpio_5_22", "gpio_2_1";
... four here
> + gpio-ranges = <&scmi_pinctrl 0 30 4>;
... and four here, so it feels inconsistent. I guess ngpios = 4?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 7/7] gpio: add pinctrl based generic gpio driver
2026-03-17 14:40 [PATCH v4 0/7] gpio: add pinctrl based generic gpio driver Dan Carpenter
` (5 preceding siblings ...)
2026-03-17 14:40 ` [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
@ 2026-03-17 14:41 ` Dan Carpenter
2026-03-17 15:52 ` Andy Shevchenko
6 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2026-03-17 14:41 UTC (permalink / raw)
To: Linus Walleij, AKASHI Takahiro
Cc: Bartosz Golaszewski, linux-kernel, linux-gpio, Andy Shevchenko,
Linus Walleij, Bartosz Golaszewski, arm-scmi, Vincent Guittot,
Khaled Ali Ahmed, Michal Simek
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
The ARM SCMI pinctrl protocol allows GPIO access. Instead of creating
a new SCMI gpio driver, this driver is a generic GPIO driver that uses
standard pinctrl interfaces.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/Kconfig | 7 ++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-by-pinctrl.c | 124 +++++++++++++++++++++++++++++++++
3 files changed, 132 insertions(+)
create mode 100644 drivers/gpio/gpio-by-pinctrl.c
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index b45fb799e36c..4c8d2589c412 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -246,6 +246,13 @@ config GPIO_BRCMSTB
help
Say yes here to enable GPIO support for Broadcom STB (BCM7XXX) SoCs.
+config GPIO_BY_PINCTRL
+ tristate "GPIO support based on a pure pin control backend"
+ depends on GPIOLIB
+ help
+ Select this option to support GPIO devices based solely on pin
+ control. This is used to do GPIO over the ARM SCMI protocol.
+
config GPIO_CADENCE
tristate "Cadence GPIO support"
depends on OF_GPIO
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index c05f7d795c43..20d4a57afdaa 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o
obj-$(CONFIG_GPIO_BLZP1600) += gpio-blzp1600.o
obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o
obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o
+obj-$(CONFIG_GPIO_BY_PINCTRL) += gpio-by-pinctrl.o
obj-$(CONFIG_GPIO_CADENCE) += gpio-cadence.o
obj-$(CONFIG_GPIO_CGBC) += gpio-cgbc.o
obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o
diff --git a/drivers/gpio/gpio-by-pinctrl.c b/drivers/gpio/gpio-by-pinctrl.c
new file mode 100644
index 000000000000..51d99723d3ca
--- /dev/null
+++ b/drivers/gpio/gpio-by-pinctrl.c
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (C) 2023 Linaro Inc.
+// Author: AKASHI takahiro <takahiro.akashi@linaro.org>
+
+#include <linux/gpio/driver.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+#include "gpiolib.h"
+
+struct pin_control_gpio_priv {
+ struct gpio_chip chip;
+};
+
+static int pin_control_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
+{
+ unsigned long config;
+ bool in, out;
+ int ret;
+
+ config = PIN_CONFIG_INPUT_ENABLE;
+ ret = pinctrl_gpio_get_config(gc, offset, &config);
+ if (ret)
+ return ret;
+ in = config;
+
+ config = PIN_CONFIG_OUTPUT_ENABLE;
+ ret = pinctrl_gpio_get_config(gc, offset, &config);
+ if (ret)
+ return ret;
+ out = config;
+
+ /* Consistency check - in theory both can be enabled! */
+ if (in && !out)
+ return GPIO_LINE_DIRECTION_IN;
+ if (!in && out)
+ return GPIO_LINE_DIRECTION_OUT;
+
+ return -EINVAL;
+}
+
+static int pin_control_gpio_direction_output(struct gpio_chip *chip,
+ unsigned int offset, int val)
+{
+ return pinctrl_gpio_direction_output(chip, offset);
+}
+
+static int pin_control_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+ unsigned long config;
+ int ret;
+
+ config = PIN_CONFIG_LEVEL;
+ ret = pinctrl_gpio_get_config(chip, offset, &config);
+ if (ret)
+ return ret;
+
+ return !!config;
+}
+
+static int pin_control_gpio_set(struct gpio_chip *chip, unsigned int offset,
+ int val)
+{
+ unsigned long config;
+
+ config = PIN_CONF_PACKED(PIN_CONFIG_LEVEL, val);
+ return pinctrl_gpio_set_config(chip, offset, config);
+}
+
+static int pin_control_gpio_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct pin_control_gpio_priv *priv;
+ struct gpio_chip *chip;
+ int ret;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ chip = &priv->chip;
+ chip->label = dev_name(dev);
+ chip->parent = dev;
+ chip->base = -1;
+
+ chip->request = gpiochip_generic_request;
+ chip->free = gpiochip_generic_free;
+ chip->get_direction = pin_control_gpio_get_direction;
+ chip->direction_input = pinctrl_gpio_direction_input;
+ chip->direction_output = pin_control_gpio_direction_output;
+ chip->get = pin_control_gpio_get;
+ chip->set = pin_control_gpio_set;
+ chip->set_config = gpiochip_generic_config;
+
+ ret = devm_gpiochip_add_data(dev, chip, priv);
+ if (ret)
+ return ret;
+
+ platform_set_drvdata(pdev, priv);
+
+ return 0;
+}
+
+static const struct of_device_id pin_control_gpio_match[] = {
+ { .compatible = "scmi-pinctrl-gpio" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, pin_control_gpio_match);
+
+static struct platform_driver pin_control_gpio_driver = {
+ .probe = pin_control_gpio_probe,
+ .driver = {
+ .name = "pin-control-gpio",
+ .of_match_table = pin_control_gpio_match,
+ },
+};
+module_platform_driver(pin_control_gpio_driver);
+
+MODULE_AUTHOR("AKASHI Takahiro <takahiro.akashi@linaro.org>");
+MODULE_DESCRIPTION("Pinctrl based GPIO driver");
+MODULE_LICENSE("GPL");
--
2.51.0
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v4 7/7] gpio: add pinctrl based generic gpio driver
2026-03-17 14:41 ` [PATCH v4 7/7] gpio: add " Dan Carpenter
@ 2026-03-17 15:52 ` Andy Shevchenko
0 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2026-03-17 15:52 UTC (permalink / raw)
To: Dan Carpenter
Cc: Linus Walleij, AKASHI Takahiro, Bartosz Golaszewski, linux-kernel,
linux-gpio, Bartosz Golaszewski, arm-scmi, Vincent Guittot,
Khaled Ali Ahmed, Michal Simek
On Tue, Mar 17, 2026 at 05:41:02PM +0300, Dan Carpenter wrote:
> The ARM SCMI pinctrl protocol allows GPIO access. Instead of creating
> a new SCMI gpio driver, this driver is a generic GPIO driver that uses
GPIO
> standard pinctrl interfaces.
...
> +config GPIO_BY_PINCTRL
> + tristate "GPIO support based on a pure pin control backend"
> + depends on GPIOLIB
> + help
> + Select this option to support GPIO devices based solely on pin
> + control. This is used to do GPIO over the ARM SCMI protocol.
This is not enough to understand (as discussion in previous round showed).
Can we have added a Documentation/driver-api/gpio/... (to the existing one
or a new one)?
...
> +// Copyright (C) 2023 Linaro Inc.
2026 (as well)?
...
+ errno.h // -ENOMEM, et cetera
> +#include <linux/gpio/driver.h>
> +#include <linux/list.h>
?! Cargo cult?
+ mod_devicetable.h // of_device_id
> +#include <linux/module.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/platform_device.h>
> +#include <linux/types.h>
+ blank line.
> +#include "gpiolib.h"
...
> +struct pin_control_gpio_priv {
> + struct gpio_chip chip;
> +};
Unneeded, you can use struct gpio_chip directly. No?
...
> +static int pin_control_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
> +{
> + unsigned long config;
> + bool in, out;
> + int ret;
> +
> + config = PIN_CONFIG_INPUT_ENABLE;
> + ret = pinctrl_gpio_get_config(gc, offset, &config);
> + if (ret)
> + return ret;
> + in = config;
> +
> + config = PIN_CONFIG_OUTPUT_ENABLE;
> + ret = pinctrl_gpio_get_config(gc, offset, &config);
> + if (ret)
> + return ret;
> + out = config;
> + /* Consistency check - in theory both can be enabled! */
> + if (in && !out)
> + return GPIO_LINE_DIRECTION_IN;
> + if (!in && out)
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return -EINVAL;
When both are enabled it's out direction, so the entire piece
can be simplified to
if (out)
return GPIO_LINE_DIRECTION_OUT;
if (in)
return GPIO_LINE_DIRECTION_IN;
return ...something...; ideally it should be HiZ.
So, even more simplified will be just
if (out)
return GPIO_LINE_DIRECTION_OUT;
else
return GPIO_LINE_DIRECTION_IN;
> +}
...
> + ret = devm_gpiochip_add_data(dev, chip, priv);
> + if (ret)
> + return ret;
> +
> + platform_set_drvdata(pdev, priv);
Not used.
> + return 0;
Hence, the entire piece is just
return devm_gpiochip_add_data(dev, chip, priv);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread