public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI
@ 2026-03-11 19:37 Dan Carpenter
  2026-03-11 19:38 ` [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
                   ` (6 more replies)
  0 siblings, 7 replies; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:37 UTC (permalink / raw)
  To: Linus Walleij, AKASHI Takahiro
  Cc: arm-scmi, Bartosz Golaszewski, Conor Dooley, Cristian Marussi,
	Dan Carpenter, devicetree, Krzysztof Kozlowski, linux-arm-kernel,
	linux-gpio, linux-kernel, Rob Herring, Sudeep Holla,
	Andy Shevchenko, Linus Walleij, Bartosz Golaszewski, Michal Simek

This basically abandons my earlier attempts and goes back to Takahiro
Akashi's driver.  Here is the link to Takahiro's patchset:

https://lore.kernel.org/all/20231005025843.508689-1-takahiro.akashi@linaro.org/

In the review comments, to that patchset we had discussed putting the
gpio section inside the pinctrl section.  The ordering problems are a
bit tricky because you want the pinctrl driver to finish probing before
you start probing the gpio driver.  To me it seems nicer to put the
pinctrl things such as pinmuxing in the pinctrl block and the gpio things
in the gpio block.

I updated Takahiro's patch to work on current kernels.  I've had added a
few other patches to make things work on current kernels.  The most
noteworthy change is that instead of calculating the ngpios, I changed
it so you have to specify the ngpios in the device tree.

I updated the device tree spec file to address review comments.  I
changed the compatible to scmi-pinctrl-gpio.  I also updated the
examples to show how pinmuxing works.  I didn't know how to include all
the potential GPIO configuration options so I set
"additionalProperties: true".  Hopefully, that's okay.

AKASHI Takahiro (3):
  pinctrl: introduce pinctrl_gpio_get_config()
  dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
  gpio: add pinctrl based generic gpio driver

Dan Carpenter (4):
  pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
  pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support
  pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE
  arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP

 .../bindings/gpio/pin-control-gpio.yaml       |  70 ++++++++++
 drivers/firmware/arm_scmi/pinctrl.c           |   2 +
 drivers/gpio/Kconfig                          |   7 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/gpio-by-pinctrl.c                | 124 ++++++++++++++++++
 drivers/pinctrl/core.c                        |  30 +++++
 drivers/pinctrl/pinctrl-scmi.c                |  46 +++++--
 include/linux/pinctrl/consumer.h              |   9 ++
 8 files changed, 276 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
 create mode 100644 drivers/gpio/gpio-by-pinctrl.c

-- 
2.51.0


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

* [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config()
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
@ 2026-03-11 19:38 ` Dan Carpenter
  2026-03-11 20:30   ` Andy Shevchenko
  2026-03-11 21:47   ` Linus Walleij
  2026-03-11 19:38 ` [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:38 UTC (permalink / raw)
  To: Linus Walleij, AKASHI Takahiro
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Andy Shevchenko,
	Linus Walleij, Bartosz Golaszewski, arm-scmi

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>
---
 drivers/pinctrl/core.c           | 30 ++++++++++++++++++++++++++++++
 include/linux/pinctrl/consumer.h |  9 +++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index b5e97689589f..732ca6785c67 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,35 @@ 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
+ */
+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] 24+ messages in thread

* [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
  2026-03-11 19:38 ` [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
@ 2026-03-11 19:38 ` Dan Carpenter
  2026-03-11 21:46   ` Linus Walleij
  2026-03-12 15:27   ` Sudeep Holla
  2026-03-11 19:38 ` [PATCH v3 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:38 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

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>
---
 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] 24+ messages in thread

* [PATCH v3 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
  2026-03-11 19:38 ` [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
  2026-03-11 19:38 ` [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
@ 2026-03-11 19:38 ` Dan Carpenter
  2026-03-11 21:48   ` Linus Walleij
  2026-03-11 19:38 ` [PATCH v3 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:38 UTC (permalink / raw)
  To: Sudeep Holla, Peng Fan, AKASHI Takahiro
  Cc: Cristian Marussi, Linus Walleij, arm-scmi, linux-arm-kernel,
	linux-gpio, linux-kernel, Andy Shevchenko, Bartosz Golaszewski

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>
---
Hi Peng, could you Ack this patch?  I could drop it, since obviously
it doesn't affect my stuff at all but it's the right thing to do.

 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] 24+ messages in thread

* [PATCH v3 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
                   ` (2 preceding siblings ...)
  2026-03-11 19:38 ` [PATCH v3 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
@ 2026-03-11 19:38 ` Dan Carpenter
  2026-03-11 21:49   ` Linus Walleij
  2026-03-11 19:39 ` [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:38 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

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>
---
 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] 24+ messages in thread

* [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
                   ` (3 preceding siblings ...)
  2026-03-11 19:38 ` [PATCH v3 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
@ 2026-03-11 19:39 ` Dan Carpenter
  2026-03-11 21:50   ` Linus Walleij
  2026-03-12 15:25   ` Sudeep Holla
  2026-03-11 19:39 ` [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
  2026-03-11 19:39 ` [PATCH v3 7/7] gpio: add " Dan Carpenter
  6 siblings, 2 replies; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:39 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

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>
---
 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] 24+ messages in thread

* [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
                   ` (4 preceding siblings ...)
  2026-03-11 19:39 ` [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
@ 2026-03-11 19:39 ` Dan Carpenter
  2026-03-11 21:53   ` Linus Walleij
  2026-03-14  0:12   ` Rob Herring
  2026-03-11 19:39 ` [PATCH v3 7/7] gpio: add " Dan Carpenter
  6 siblings, 2 replies; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:39 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

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>
---
 .../bindings/gpio/pin-control-gpio.yaml       | 70 +++++++++++++++++++
 1 file changed, 70 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..81c68579df6e
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
@@ -0,0 +1,70 @@
+# 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-ranges: true
+
+  ngpios: true
+
+patternProperties:
+  "^.+-hog(-[0-9]+)?$":
+    type: object
+
+    required:
+      - gpio-hog
+
+required:
+  - compatible
+  - gpio-controller
+  - "#gpio-cells"
+  - gpio-ranges
+  - ngpios
+
+additionalProperties: true
+
+examples:
+  - |
+    gpio1 {
+        compatible = "scmi-pinctrl-gpio";
+        gpio-controller;
+        #gpio-cells = <2>;
+        ngpios = <10>;
+        gpio-ranges = <&scmi_pinctrl 0 8 4>,
+                      <&scmi_pinctrl 4 12 1>,
+                      <&scmi_pinctrl 5 15 1>,
+                      <&scmi_pinctrl 6 17 4>;
+        pinctrl-names = "default";
+        pinctrl-0 = <&i2c2_pins>;
+    };
+
+    gpio2 {
+        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] 24+ messages in thread

* [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
                   ` (5 preceding siblings ...)
  2026-03-11 19:39 ` [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
@ 2026-03-11 19:39 ` Dan Carpenter
  2026-03-11 20:34   ` Andy Shevchenko
                     ` (2 more replies)
  6 siblings, 3 replies; 24+ messages in thread
From: Dan Carpenter @ 2026-03-11 19:39 UTC (permalink / raw)
  To: Linus Walleij, AKASHI Takahiro
  Cc: Bartosz Golaszewski, linux-kernel, linux-gpio, Andy Shevchenko,
	Linus Walleij, Bartosz Golaszewski, arm-scmi

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>
---
 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..c1fed14c9d01
--- /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] 24+ messages in thread

* Re: [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config()
  2026-03-11 19:38 ` [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
@ 2026-03-11 20:30   ` Andy Shevchenko
  2026-03-11 21:47   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2026-03-11 20:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linus Walleij, AKASHI Takahiro, Bartosz Golaszewski, linux-gpio,
	linux-kernel, Bartosz Golaszewski, arm-scmi

On Wed, Mar 11, 2026 at 10:38:07PM +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.

...

> +/**
> + * 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

kernel-doc is not happy: return section is missing.
Always run it with -Wall to see that.

> + */

...

I'm also wondering if this needs to be used in / already part of UP board pin
control and GPIO driver. There they used a proxy based on gpio-aggregator code.
With this it might be (I haven't checked at all) that the code can be simplified.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-11 19:39 ` [PATCH v3 7/7] gpio: add " Dan Carpenter
@ 2026-03-11 20:34   ` Andy Shevchenko
  2026-03-11 22:00     ` Linus Walleij
  2026-03-11 21:55   ` Linus Walleij
  2026-03-16  9:16   ` Bartosz Golaszewski
  2 siblings, 1 reply; 24+ messages in thread
From: Andy Shevchenko @ 2026-03-11 20:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linus Walleij, AKASHI Takahiro, Bartosz Golaszewski, linux-kernel,
	linux-gpio, Bartosz Golaszewski, arm-scmi

On Wed, Mar 11, 2026 at 10:39:24PM +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
> standard pinctrl interfaces.

Similar wondering here... Can't this code be integrated with one of
the existing generic things, like gpio-aggregator?

I really don't want to see yet another generic code in this folder.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
  2026-03-11 19:38 ` [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
@ 2026-03-11 21:46   ` Linus Walleij
  2026-03-12 15:27   ` Sudeep Holla
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudeep Holla, AKASHI Takahiro, Cristian Marussi, arm-scmi,
	linux-arm-kernel, linux-gpio, linux-kernel, Andy Shevchenko,
	Bartosz Golaszewski

On Wed, Mar 11, 2026 at 8:38 PM Dan Carpenter <dan.carpenter@linaro.org> 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.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

I think you nailed it :)
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config()
  2026-03-11 19:38 ` [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
  2026-03-11 20:30   ` Andy Shevchenko
@ 2026-03-11 21:47   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: AKASHI Takahiro, Bartosz Golaszewski, linux-gpio, linux-kernel,
	Andy Shevchenko, Bartosz Golaszewski, arm-scmi

On Wed, Mar 11, 2026 at 8:38 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:

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

If you fix the kerneldoc as pointed out by Andy:
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support
  2026-03-11 19:38 ` [PATCH v3 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
@ 2026-03-11 21:48   ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:48 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudeep Holla, Peng Fan, AKASHI Takahiro, Cristian Marussi,
	arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
	Andy Shevchenko, Bartosz Golaszewski

On Wed, Mar 11, 2026 at 8:38 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:

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

Yours,
Linus Walleij

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

* Re: [PATCH v3 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE
  2026-03-11 19:38 ` [PATCH v3 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
@ 2026-03-11 21:49   ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudeep Holla, AKASHI Takahiro, Cristian Marussi, arm-scmi,
	linux-arm-kernel, linux-gpio, linux-kernel, Andy Shevchenko,
	Bartosz Golaszewski

On Wed, Mar 11, 2026 at 8:39 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:

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

The SCMI implementation by definition lives in some always-on
universe I think? It never sleeps or resets. Nevertheless:
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP
  2026-03-11 19:39 ` [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
@ 2026-03-11 21:50   ` Linus Walleij
  2026-03-12 15:25   ` Sudeep Holla
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sudeep Holla, AKASHI Takahiro, Cristian Marussi, arm-scmi,
	linux-arm-kernel, linux-kernel, Andy Shevchenko,
	Bartosz Golaszewski, linux-gpio

On Wed, Mar 11, 2026 at 8:39 PM Dan Carpenter <dan.carpenter@linaro.org> 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.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
  2026-03-11 19:39 ` [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
@ 2026-03-11 21:53   ` Linus Walleij
  2026-03-14  0:12   ` Rob Herring
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:53 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: AKASHI Takahiro, Bartosz Golaszewski, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Dan Carpenter, linux-gpio,
	devicetree, linux-kernel, Andy Shevchenko, Bartosz Golaszewski,
	arm-scmi

On Wed, Mar 11, 2026 at 8:39 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:

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

I think Takashi's original idea is sound now that we clarified
the level read/set semantics!
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-11 19:39 ` [PATCH v3 7/7] gpio: add " Dan Carpenter
  2026-03-11 20:34   ` Andy Shevchenko
@ 2026-03-11 21:55   ` Linus Walleij
  2026-03-16  9:16   ` Bartosz Golaszewski
  2 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 21:55 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: AKASHI Takahiro, Bartosz Golaszewski, linux-kernel, linux-gpio,
	Andy Shevchenko, Bartosz Golaszewski, arm-scmi

On Wed, Mar 11, 2026 at 8:39 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:

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

To me this is as pure as a GPIO-on-pinctrl can get.
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-11 20:34   ` Andy Shevchenko
@ 2026-03-11 22:00     ` Linus Walleij
  2026-03-12 10:41       ` Andy Shevchenko
  0 siblings, 1 reply; 24+ messages in thread
From: Linus Walleij @ 2026-03-11 22:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dan Carpenter, AKASHI Takahiro, Bartosz Golaszewski, linux-kernel,
	linux-gpio, Bartosz Golaszewski, arm-scmi

On Wed, Mar 11, 2026 at 9:34 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> On Wed, Mar 11, 2026 at 10:39:24PM +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
> > standard pinctrl interfaces.
>
> Similar wondering here... Can't this code be integrated with one of
> the existing generic things, like gpio-aggregator?

The aggregator is very different, it takes existing GPIOs and
creates a new GPIOchip from them.

What this does is essentially take the gpio-ranges, find the
backing pins on the pin controller, and creates a GPIOchip
from them.

I don't see anything that can be shared by the other generic
business sadly, but I think maybe another back-end using just
pin control can re-use this. In this case it is SCMI but any other
firmware API just exposing pin control and no explicit GPIO
could use this. (Not that I can think of any.)

Yours,
Linus Walleij

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

* Re: [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-11 22:00     ` Linus Walleij
@ 2026-03-12 10:41       ` Andy Shevchenko
  2026-03-16 21:08         ` Linus Walleij
  0 siblings, 1 reply; 24+ messages in thread
From: Andy Shevchenko @ 2026-03-12 10:41 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Dan Carpenter, AKASHI Takahiro, Bartosz Golaszewski, linux-kernel,
	linux-gpio, Bartosz Golaszewski, arm-scmi

On Wed, Mar 11, 2026 at 11:00:02PM +0100, Linus Walleij wrote:
> On Wed, Mar 11, 2026 at 9:34 PM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Wed, Mar 11, 2026 at 10:39:24PM +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
> > > standard pinctrl interfaces.
> >
> > Similar wondering here... Can't this code be integrated with one of
> > the existing generic things, like gpio-aggregator?
> 
> The aggregator is very different, it takes existing GPIOs and
> creates a new GPIOchip from them.
> 
> What this does is essentially take the gpio-ranges, find the
> backing pins on the pin controller, and creates a GPIOchip
> from them.

Thanks for elaboration! But why is it done this way? It doesn't sound
like a usual (generic) problem to solve.

> I don't see anything that can be shared by the other generic
> business sadly, but I think maybe another back-end using just
> pin control can re-use this. In this case it is SCMI but any other
> firmware API just exposing pin control and no explicit GPIO
> could use this. (Not that I can think of any.)

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP
  2026-03-11 19:39 ` [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
  2026-03-11 21:50   ` Linus Walleij
@ 2026-03-12 15:25   ` Sudeep Holla
  1 sibling, 0 replies; 24+ messages in thread
From: Sudeep Holla @ 2026-03-12 15:25 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: AKASHI Takahiro, Cristian Marussi, arm-scmi, linux-arm-kernel,
	Sudeep Holla, linux-kernel, Andy Shevchenko, Linus Walleij,
	Bartosz Golaszewski, linux-gpio

On Wed, Mar 11, 2026 at 10:39:03PM +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.
> 

Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>

I see Linus W has provided review tags too. Though I am assuming it will
go via some other tree as SCMI core change is tiny, just wanted to check
it explicitly so that there is no wrong assumption on my side.

-- 
Regards,
Sudeep

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

* Re: [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE
  2026-03-11 19:38 ` [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
  2026-03-11 21:46   ` Linus Walleij
@ 2026-03-12 15:27   ` Sudeep Holla
  1 sibling, 0 replies; 24+ messages in thread
From: Sudeep Holla @ 2026-03-12 15:27 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: AKASHI Takahiro, Sudeep Holla, Cristian Marussi, Linus Walleij,
	arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
	Andy Shevchenko, Bartosz Golaszewski

On Wed, Mar 11, 2026 at 10:38:16PM +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.
> 

Acked-by: Sudeep Holla <sudeep.holla@kernel.org>

-- 
Regards,
Sudeep

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

* Re: [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver
  2026-03-11 19:39 ` [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
  2026-03-11 21:53   ` Linus Walleij
@ 2026-03-14  0:12   ` Rob Herring
  1 sibling, 0 replies; 24+ messages in thread
From: Rob Herring @ 2026-03-14  0:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linus Walleij, AKASHI Takahiro, Bartosz Golaszewski,
	Krzysztof Kozlowski, Conor Dooley, Dan Carpenter, linux-gpio,
	devicetree, linux-kernel, Andy Shevchenko, Bartosz Golaszewski,
	arm-scmi

On Wed, Mar 11, 2026 at 10:39:17PM +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
> 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>
> ---
>  .../bindings/gpio/pin-control-gpio.yaml       | 70 +++++++++++++++++++
>  1 file changed, 70 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..81c68579df6e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/gpio/pin-control-gpio.yaml
> @@ -0,0 +1,70 @@
> +# 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-ranges: true
> +
> +  ngpios: true
> +
> +patternProperties:
> +  "^.+-hog(-[0-9]+)?$":
> +    type: object
> +
> +    required:
> +      - gpio-hog
> +
> +required:
> +  - compatible
> +  - gpio-controller
> +  - "#gpio-cells"
> +  - gpio-ranges
> +  - ngpios
> +
> +additionalProperties: true

That's only valid for common (incomplete) schemas. It must be false.

> +
> +examples:
> +  - |
> +    gpio1 {
> +        compatible = "scmi-pinctrl-gpio";
> +        gpio-controller;
> +        #gpio-cells = <2>;
> +        ngpios = <10>;
> +        gpio-ranges = <&scmi_pinctrl 0 8 4>,
> +                      <&scmi_pinctrl 4 12 1>,
> +                      <&scmi_pinctrl 5 15 1>,
> +                      <&scmi_pinctrl 6 17 4>;
> +        pinctrl-names = "default";
> +        pinctrl-0 = <&i2c2_pins>;
> +    };
> +
> +    gpio2 {
> +        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>;
> +    };

I think 1 example is enough.

> -- 
> 2.51.0
> 

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

* Re: [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-11 19:39 ` [PATCH v3 7/7] gpio: add " Dan Carpenter
  2026-03-11 20:34   ` Andy Shevchenko
  2026-03-11 21:55   ` Linus Walleij
@ 2026-03-16  9:16   ` Bartosz Golaszewski
  2 siblings, 0 replies; 24+ messages in thread
From: Bartosz Golaszewski @ 2026-03-16  9:16 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Bartosz Golaszewski, linux-kernel, linux-gpio, Andy Shevchenko,
	Linus Walleij, Bartosz Golaszewski, arm-scmi, AKASHI Takahiro

On Wed, 11 Mar 2026 20:39:24 +0100, Dan Carpenter
<dan.carpenter@linaro.org> said:
> 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>
> ---

That is actually pretty neat.

Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

* Re: [PATCH v3 7/7] gpio: add pinctrl based generic gpio driver
  2026-03-12 10:41       ` Andy Shevchenko
@ 2026-03-16 21:08         ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2026-03-16 21:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dan Carpenter, AKASHI Takahiro, Bartosz Golaszewski, linux-kernel,
	linux-gpio, Bartosz Golaszewski, arm-scmi

On Thu, Mar 12, 2026 at 11:41 AM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
> On Wed, Mar 11, 2026 at 11:00:02PM +0100, Linus Walleij wrote:

> > What this does is essentially take the gpio-ranges, find the
> > backing pins on the pin controller, and creates a GPIOchip
> > from them.
>
> Thanks for elaboration! But why is it done this way? It doesn't sound
> like a usual (generic) problem to solve.

The experts can confirm, but I think this was done to simplify
the SCMI firmware, both the specification and the implementation.

It was identified that it was necessary to have a pin control
SCMI specification and implementation, but no separate GPIO
specification and implementation was defined, leading to just
one spec, and one single firmware service to
implement that will support both pin control and GPIO.

These days, if we were re-specifying ACPI we could do the
same there, but alas it already has legacy GPIO-only interfaces.
SCMI has the upside of being able to start from scratch
and upend a few traditions.

Yours,
Linus Walleij

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

end of thread, other threads:[~2026-03-16 21:08 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 19:37 [PATCH v3 0/7] gpio: introduce a gpio driver for SCMI Dan Carpenter
2026-03-11 19:38 ` [PATCH v3 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
2026-03-11 20:30   ` Andy Shevchenko
2026-03-11 21:47   ` Linus Walleij
2026-03-11 19:38 ` [PATCH v3 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
2026-03-11 21:46   ` Linus Walleij
2026-03-12 15:27   ` Sudeep Holla
2026-03-11 19:38 ` [PATCH v3 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
2026-03-11 21:48   ` Linus Walleij
2026-03-11 19:38 ` [PATCH v3 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
2026-03-11 21:49   ` Linus Walleij
2026-03-11 19:39 ` [PATCH v3 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
2026-03-11 21:50   ` Linus Walleij
2026-03-12 15:25   ` Sudeep Holla
2026-03-11 19:39 ` [PATCH v3 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
2026-03-11 21:53   ` Linus Walleij
2026-03-14  0:12   ` Rob Herring
2026-03-11 19:39 ` [PATCH v3 7/7] gpio: add " Dan Carpenter
2026-03-11 20:34   ` Andy Shevchenko
2026-03-11 22:00     ` Linus Walleij
2026-03-12 10:41       ` Andy Shevchenko
2026-03-16 21:08         ` Linus Walleij
2026-03-11 21:55   ` Linus Walleij
2026-03-16  9:16   ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox