* [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support
@ 2026-11-13 11:05 Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
` (10 more replies)
0 siblings, 11 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic, Bartosz Golaszewski
Five fixes: the drive strength went out in milliamperes, the schmitt
trigger enable was mapped to the input buffer, the settings Linux
carries without argument went out as disabled, a setting the platform
reports off read as set, and the protocol layer read past a
PINCTRL_LIST_ASSOCIATIONS reply larger than its receive buffer.
Then GPIO function support: report the pin-only and GPIO attributes of
a function, give pin-only functions no groups, mark the GPIO functions,
and select the GPIO function of a pin on a GPIO request.
Tested on R-Car X5H with a v6.18 backport that needed adapting, all but
the schmitt and enable settings, which the platform does not implement.
An LLM was used to review the patches and to set up the tests.
---
Changes in v2:
- patch 4: keep the enables value on get (Sashiko)
- patch 5: error out on a truncated reply (Cristian)
- patch 11: unsigned counts, loop variables in the for (Andy, Cristian)
- patch 11: dev_dbg when no GPIO function is found (Cristian)
- join the lines that fit in 100 columns (Andy)
- collect Reviewed-by tags
- rebase on next-20261112
- Link to v1: https://patch.msgid.link/20261030-clegoffic-pinctrl-scmi-gpio-v1-0-52d92843ad97@baylibre.com
---
Clément Le Goffic (11):
pinctrl: scmi: send the drive strength in microamperes
pinctrl: scmi: map the schmitt trigger enable to its SCMI type
pinctrl: scmi: send the settings without argument as enabled
pinctrl: scmi: report an off setting as not set
firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies
firmware: arm_scmi: report the pin-only and GPIO flags of functions
pinctrl: scmi: give no groups to pin-only functions
pinctrl: scmi: mark the GPIO functions
pinctrl: scmi: report whether a function is GPIO
firmware: arm_scmi: add an operation to set the function of a single pin
pinctrl: scmi: select the GPIO function on GPIO requests
drivers/firmware/arm/scmi/pinctrl.c | 51 ++++++++++--
drivers/pinctrl/pinctrl-scmi.c | 161 +++++++++++++++++++++++++++++++++---
include/linux/scmi_protocol.h | 8 +-
3 files changed, 201 insertions(+), 19 deletions(-)
---
base-commit: 6d582d78fad9d828e575ca0cdcff8ea47a77220b
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
change-id: 20261030-clegoffic-pinctrl-scmi-gpio-48cfe014bb11
Best regards,
--
Clément Le Goffic <clegoffic@baylibre.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-17 14:35 ` Geert Uytterhoeven
2026-11-13 11:05 ` [PATCH v2 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type Clément Le Goffic
` (9 subsequent siblings)
10 siblings, 1 reply; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
SCMI gives the drive strength in microamperes, but
PIN_CONFIG_DRIVE_STRENGTH is in milliamperes and was sent unchanged.
Convert it on set and on get. It is the only unit that differs: the
debounce is in microseconds and the pull resistances in ohms on both
sides, and every other value is a flag or implementation defined.
Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 43d5f3d54a8a..af33ddd4056b 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -14,6 +14,7 @@
#include <linux/scmi_protocol.h>
#include <linux/slab.h>
#include <linux/types.h>
+#include <linux/units.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinconf.h>
@@ -155,6 +156,14 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
return 0;
}
+static u32 pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 value)
+{
+ if (param == PIN_CONFIG_DRIVE_STRENGTH)
+ return value / MILLI;
+
+ return value;
+}
+
static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
enum scmi_pinctrl_conf_type *type)
{
@@ -167,13 +176,17 @@ static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
}
static int pinctrl_scmi_map_pinconf_type_set(enum pin_config_param param,
- enum scmi_pinctrl_conf_type *type)
+ enum scmi_pinctrl_conf_type *type,
+ u32 *arg)
{
if (param == PIN_CONFIG_LEVEL) {
*type = SCMI_PIN_OUTPUT_VALUE;
return 0;
}
+ if (param == PIN_CONFIG_DRIVE_STRENGTH)
+ *arg *= MILLI;
+
return pinctrl_scmi_map_pinconf_type(param, type);
}
@@ -203,6 +216,7 @@ static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev,
if (ret)
return ret;
+ config_value = pinctrl_scmi_map_pinconf_arg_get(config_type, config_value);
*config = pinconf_to_config_packed(config_type, config_value);
return 0;
@@ -267,12 +281,13 @@ static int pinctrl_scmi_pinconf_set(struct pinctrl_dev *pctldev,
param = pinconf_to_config_param(configs[i]);
if (param == PIN_CONFIG_PERSIST_STATE)
continue;
- ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[cnt]);
+ p_config_value[cnt] = pinconf_to_config_argument(configs[i]);
+ ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[cnt],
+ &p_config_value[cnt]);
if (ret) {
dev_err(pmx->dev, "Error map pinconf_type %d\n", ret);
goto free_config;
}
- p_config_value[cnt] = pinconf_to_config_argument(configs[i]);
cnt++;
}
@@ -310,13 +325,13 @@ 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_set(param, &p_config_type[i]);
+ p_config_value[i] = pinconf_to_config_argument(configs[i]);
+ ret = pinctrl_scmi_map_pinconf_type_set(param, &p_config_type[i],
+ &p_config_value[i]);
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]);
}
ret = pinctrl_ops->settings_conf(pmx->ph, group, GROUP_TYPE,
@@ -359,6 +374,7 @@ static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev,
if (ret)
return ret;
+ config_value = pinctrl_scmi_map_pinconf_arg_get(config_type, config_value);
*config = pinconf_to_config_packed(config_type, config_value);
return 0;
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 03/11] pinctrl: scmi: send the settings without argument as enabled Clément Le Goffic
` (8 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
PIN_CONFIG_INPUT_SCHMITT_ENABLE was sent as INPUT_MODE, which drives
the input buffer, and PIN_CONFIG_INPUT_SCHMITT, a threshold, as
INPUT_SCHMITT, which only takes 0 or 1. Send the enable as
INPUT_SCHMITT and refuse the threshold, the protocol has no type for
it.
Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index af33ddd4056b..cbe4f3b6368f 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -128,11 +128,8 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
case PIN_CONFIG_INPUT_ENABLE:
*type = SCMI_PIN_INPUT_MODE;
break;
- case PIN_CONFIG_INPUT_SCHMITT:
- *type = SCMI_PIN_INPUT_SCHMITT;
- break;
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
- *type = SCMI_PIN_INPUT_MODE;
+ *type = SCMI_PIN_INPUT_SCHMITT;
break;
case PIN_CONFIG_MODE_LOW_POWER:
*type = SCMI_PIN_LOW_POWER_MODE;
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 03/11] pinctrl: scmi: send the settings without argument as enabled
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 04/11] pinctrl: scmi: report an off setting as not set Clément Le Goffic
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
bias-bus-hold, bias-disable, bias-high-impedance, drive-open-drain,
drive-open-source and drive-push-pull take no argument in Linux, so
they were sent with the value 0, which the protocol reads as disabled.
Send 1.
Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index cbe4f3b6368f..221dd8d30009 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -172,6 +172,21 @@ static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
return pinctrl_scmi_map_pinconf_type(param, type);
}
+static bool pinctrl_scmi_pinconf_arg_ignored(enum pin_config_param param)
+{
+ switch (param) {
+ case PIN_CONFIG_BIAS_BUS_HOLD:
+ case PIN_CONFIG_BIAS_DISABLE:
+ case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+ case PIN_CONFIG_DRIVE_OPEN_DRAIN:
+ case PIN_CONFIG_DRIVE_OPEN_SOURCE:
+ case PIN_CONFIG_DRIVE_PUSH_PULL:
+ return true;
+ default:
+ return false;
+ }
+}
+
static int pinctrl_scmi_map_pinconf_type_set(enum pin_config_param param,
enum scmi_pinctrl_conf_type *type,
u32 *arg)
@@ -181,6 +196,9 @@ static int pinctrl_scmi_map_pinconf_type_set(enum pin_config_param param,
return 0;
}
+ if (pinctrl_scmi_pinconf_arg_ignored(param))
+ *arg = 1;
+
if (param == PIN_CONFIG_DRIVE_STRENGTH)
*arg *= MILLI;
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 04/11] pinctrl: scmi: report an off setting as not set
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (2 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 03/11] pinctrl: scmi: send the settings without argument as enabled Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies Clément Le Goffic
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
A get of a setting that is on or off, the flags and the pulls, returned
0 as a value, so every one of them showed as set on every pin. Return
-EINVAL when the platform answers 0, which is how pinconf reports a
setting that is not active.
The input, output and schmitt enables keep their value: 0 means disabled
for them, and the pinctrl based GPIO driver reads the output enable to
tell the direction of a line.
Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 221dd8d30009..b088a24e4ec0 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -153,12 +153,36 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
return 0;
}
-static u32 pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 value)
+static bool pinctrl_scmi_pinconf_inactive_flag(enum pin_config_param param, u32 value)
{
- if (param == PIN_CONFIG_DRIVE_STRENGTH)
- return value / MILLI;
+ if (value)
+ return false;
- return value;
+ switch (param) {
+ case PIN_CONFIG_BIAS_BUS_HOLD:
+ case PIN_CONFIG_BIAS_DISABLE:
+ case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
+ case PIN_CONFIG_BIAS_PULL_DOWN:
+ case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
+ case PIN_CONFIG_BIAS_PULL_UP:
+ case PIN_CONFIG_DRIVE_OPEN_DRAIN:
+ case PIN_CONFIG_DRIVE_OPEN_SOURCE:
+ case PIN_CONFIG_DRIVE_PUSH_PULL:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static int pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 *value)
+{
+ if (pinctrl_scmi_pinconf_inactive_flag(param, *value))
+ return -EINVAL;
+
+ if (param == PIN_CONFIG_DRIVE_STRENGTH)
+ *value /= MILLI;
+
+ return 0;
}
static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
@@ -231,7 +255,10 @@ static int pinctrl_scmi_pinconf_get(struct pinctrl_dev *pctldev,
if (ret)
return ret;
- config_value = pinctrl_scmi_map_pinconf_arg_get(config_type, config_value);
+ ret = pinctrl_scmi_map_pinconf_arg_get(config_type, &config_value);
+ if (ret)
+ return ret;
+
*config = pinconf_to_config_packed(config_type, config_value);
return 0;
@@ -389,7 +416,10 @@ static int pinctrl_scmi_pinconf_group_get(struct pinctrl_dev *pctldev,
if (ret)
return ret;
- config_value = pinctrl_scmi_map_pinconf_arg_get(config_type, config_value);
+ ret = pinctrl_scmi_map_pinconf_arg_get(config_type, &config_value);
+ if (ret)
+ return ret;
+
*config = pinconf_to_config_packed(config_type, config_value);
return 0;
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (3 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 04/11] pinctrl: scmi: report an off setting as not set Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions Clément Le Goffic
` (5 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
The transport cuts a reply larger than the receive buffer, but the iterator
still reads every identifier the reply announces. Return an error instead.
Fixes: 2145af01b9cb ("firmware: arm_scmi: Add basic support for SCMI v3.2 pincontrol protocol")
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/firmware/arm/scmi/pinctrl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/firmware/arm/scmi/pinctrl.c b/drivers/firmware/arm/scmi/pinctrl.c
index 18761ffbf893..b071d31b5c33 100644
--- a/drivers/firmware/arm/scmi/pinctrl.c
+++ b/drivers/firmware/arm/scmi/pinctrl.c
@@ -265,6 +265,9 @@ static int iter_pinctrl_assoc_update_state(struct scmi_iterator_state *st,
st->num_returned = RETURNED(r->flags);
st->num_remaining = REMAINING(r->flags);
+ if (st->rx_len < sizeof(*r) + sizeof(r->array[0]) * st->num_returned)
+ return -EINVAL;
+
return 0;
}
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (4 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 07/11] pinctrl: scmi: give no groups to pin-only functions Clément Le Goffic
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
Keep the pin-only and GPIO flags that PINCTRL_ATTRIBUTES returns for a
function, and add a function_flags_get operation to read them.
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/firmware/arm/scmi/pinctrl.c | 42 ++++++++++++++++++++++++++++++++-----
include/linux/scmi_protocol.h | 6 +++++-
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/arm/scmi/pinctrl.c b/drivers/firmware/arm/scmi/pinctrl.c
index b071d31b5c33..1bc4bca4c48f 100644
--- a/drivers/firmware/arm/scmi/pinctrl.c
+++ b/drivers/firmware/arm/scmi/pinctrl.c
@@ -27,6 +27,8 @@
#define GET_FUNCTIONS_NR(x) le32_get_bits((x), GENMASK(15, 0))
#define EXT_NAME_FLAG(x) le32_get_bits((x), BIT(31))
+#define GPIO_FUNC(x) le32_get_bits((x), BIT(17))
+#define PIN_ONLY_FUNC(x) le32_get_bits((x), BIT(16))
#define NUM_ELEMS(x) le32_get_bits((x), GENMASK(15, 0))
#define REMAINING(x) le32_get_bits((x), GENMASK(31, 16))
@@ -107,6 +109,8 @@ struct scmi_group_info {
struct scmi_function_info {
char name[SCMI_MAX_STR_SIZE];
bool present;
+ bool pin_only;
+ bool gpio;
u32 *groups;
u32 nr_groups;
};
@@ -188,8 +192,8 @@ static int scmi_pinctrl_validate_id(const struct scmi_protocol_handle *ph,
static int scmi_pinctrl_attributes(const struct scmi_protocol_handle *ph,
enum scmi_pinctrl_selector_type type,
- u32 selector, char *name,
- u32 *n_elems)
+ u32 selector, char *name, u32 *n_elems,
+ bool *pin_only, bool *gpio)
{
int ret;
struct scmi_xfer *t;
@@ -219,6 +223,12 @@ static int scmi_pinctrl_attributes(const struct scmi_protocol_handle *ph,
if (n_elems)
*n_elems = NUM_ELEMS(rx->attributes);
+ if (pin_only)
+ *pin_only = PIN_ONLY_FUNC(rx->attributes);
+
+ if (gpio)
+ *gpio = GPIO_FUNC(rx->attributes);
+
strscpy(name, rx->name, SCMI_SHORT_NAME_MAX_SIZE);
ext_name_flag = !!EXT_NAME_FLAG(rx->attributes);
@@ -614,7 +624,7 @@ static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *ph,
return 0;
ret = scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, group->name,
- &group->nr_pins);
+ &group->nr_pins, NULL, NULL);
if (ret)
return ret;
@@ -691,7 +701,8 @@ static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handle *ph,
return 0;
ret = scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, func->name,
- &func->nr_groups);
+ &func->nr_groups, &func->pin_only,
+ &func->gpio);
if (ret)
return ret;
@@ -753,6 +764,26 @@ scmi_pinctrl_function_groups_get(const struct scmi_protocol_handle *ph,
return 0;
}
+static int
+scmi_pinctrl_function_flags_get(const struct scmi_protocol_handle *ph,
+ u32 selector, bool *pin_only, bool *gpio)
+{
+ struct scmi_pinctrl_info *pi = ph->get_priv(ph);
+ int ret;
+
+ if (!pin_only || !gpio)
+ return -EINVAL;
+
+ ret = scmi_pinctrl_get_function_info(ph, selector);
+ if (ret)
+ return ret;
+
+ *pin_only = pi->functions[selector].pin_only;
+ *gpio = pi->functions[selector].gpio;
+
+ return 0;
+}
+
static int scmi_pinctrl_mux_set(const struct scmi_protocol_handle *ph,
u32 selector, u32 group)
{
@@ -773,7 +804,7 @@ static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph,
if (pin->present)
return 0;
- ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL);
+ ret = scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL, NULL, NULL);
if (ret)
return ret;
@@ -821,6 +852,7 @@ static const struct scmi_pinctrl_proto_ops pinctrl_proto_ops = {
.name_get = scmi_pinctrl_name_get,
.group_pins_get = scmi_pinctrl_group_pins_get,
.function_groups_get = scmi_pinctrl_function_groups_get,
+ .function_flags_get = scmi_pinctrl_function_flags_get,
.mux_set = scmi_pinctrl_mux_set,
.settings_get_one = scmi_pinctrl_settings_get_one,
.settings_get_all = scmi_pinctrl_settings_get_all,
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 3f7cc35eb861..072190e89064 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -785,7 +785,9 @@ enum scmi_pinctrl_conf_type {
* @name_get: returns name by index of given type
* @group_pins_get: returns the set of pins, assigned to the specified group
* @function_groups_get: returns the set of groups, assigned to the specified
- * function
+ * function, or the set of pins for a pin-only function
+ * @function_flags_get: tells whether the specified function is pin-only and
+ * whether it is a GPIO function
* @mux_set: set muxing function for groups of pins
* @settings_get_one: returns one configuration parameter for pin or group
* specified by config_type
@@ -806,6 +808,8 @@ struct scmi_pinctrl_proto_ops {
int (*function_groups_get)(const struct scmi_protocol_handle *ph,
u32 selector, unsigned int *nr_groups,
const unsigned int **groups);
+ int (*function_flags_get)(const struct scmi_protocol_handle *ph,
+ u32 selector, bool *pin_only, bool *gpio);
int (*mux_set)(const struct scmi_protocol_handle *ph, u32 selector,
u32 group);
int (*settings_get_one)(const struct scmi_protocol_handle *ph,
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 07/11] pinctrl: scmi: give no groups to pin-only functions
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (5 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 08/11] pinctrl: scmi: mark the GPIO functions Clément Le Goffic
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
For a pin-only function PINCTRL_LIST_ASSOCIATIONS returns pins, but the
driver registered them as groups. Register pin-only functions without
groups.
Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index b088a24e4ec0..af9c9575d4f0 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -438,6 +438,7 @@ static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
{
unsigned int nr_funcs, nr_groups, i, j;
const unsigned int *group_ids;
+ bool pin_only, gpio;
const char *fname;
const char **gnames;
int ret;
@@ -450,13 +451,19 @@ static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
if (ret)
return ret;
+ ret = pinctrl_ops->function_flags_get(pmx->ph, i, &pin_only, &gpio);
+ if (ret)
+ return ret;
+
ret = pinctrl_ops->function_groups_get(pmx->ph, i,
&nr_groups,
&group_ids);
if (ret)
return ret;
- if (!nr_groups)
+ if (pin_only)
+ nr_groups = 0;
+ else if (!nr_groups)
dev_warn(pmx->dev,
"Function %s contains no groups\n",
fname);
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 08/11] pinctrl: scmi: mark the GPIO functions
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (6 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 07/11] pinctrl: scmi: give no groups to pin-only functions Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 09/11] pinctrl: scmi: report whether a function is GPIO Clément Le Goffic
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Bartosz Golaszewski, Clément Le Goffic
Register the functions flagged as GPIO with PINFUNCTION_FLAG_GPIO.
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index af9c9575d4f0..43b9d67eb9e5 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -438,6 +438,7 @@ static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
{
unsigned int nr_funcs, nr_groups, i, j;
const unsigned int *group_ids;
+ struct pinfunction func;
bool pin_only, gpio;
const char *fname;
const char **gnames;
@@ -479,8 +480,12 @@ static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
return ret;
}
- ret = pinmux_generic_add_function(pmx->pctldev, fname, gnames,
- nr_groups, NULL);
+ if (gpio)
+ func = PINCTRL_GPIO_PINFUNCTION(fname, gnames, nr_groups);
+ else
+ func = PINCTRL_PINFUNCTION(fname, gnames, nr_groups);
+
+ ret = pinmux_generic_add_pinfunction(pmx->pctldev, &func, NULL);
if (ret < 0)
return ret;
if (ret != i) {
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 09/11] pinctrl: scmi: report whether a function is GPIO
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (7 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 08/11] pinctrl: scmi: mark the GPIO functions Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 10/11] firmware: arm_scmi: add an operation to set the function of a single pin Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 11/11] pinctrl: scmi: select the GPIO function on GPIO requests Clément Le Goffic
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Bartosz Golaszewski, Clément Le Goffic
Use pinmux_generic_function_is_gpio() for the function_is_gpio
operation.
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 43b9d67eb9e5..6d51025013ec 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -80,6 +80,7 @@ static const struct pinmux_ops pinctrl_scmi_pinmux_ops = {
.get_functions_count = pinmux_generic_get_function_count,
.get_function_name = pinmux_generic_get_function_name,
.get_function_groups = pinmux_generic_get_function_groups,
+ .function_is_gpio = pinmux_generic_function_is_gpio,
.set_mux = pinctrl_scmi_func_set_mux,
};
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 10/11] firmware: arm_scmi: add an operation to set the function of a single pin
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (8 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 09/11] pinctrl: scmi: report whether a function is GPIO Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 11/11] pinctrl: scmi: select the GPIO function on GPIO requests Clément Le Goffic
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
Add pin_mux_set, which selects a function on a single pin. mux_set only
works on groups.
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/firmware/arm/scmi/pinctrl.c | 6 ++++++
include/linux/scmi_protocol.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/drivers/firmware/arm/scmi/pinctrl.c b/drivers/firmware/arm/scmi/pinctrl.c
index 1bc4bca4c48f..4e3968fbc5ec 100644
--- a/drivers/firmware/arm/scmi/pinctrl.c
+++ b/drivers/firmware/arm/scmi/pinctrl.c
@@ -790,6 +790,11 @@ static int scmi_pinctrl_mux_set(const struct scmi_protocol_handle *ph,
return scmi_pinctrl_function_select(ph, group, GROUP_TYPE, selector);
}
+static int scmi_pinctrl_pin_mux_set(const struct scmi_protocol_handle *ph, u32 selector, u32 pin)
+{
+ return scmi_pinctrl_function_select(ph, pin, PIN_TYPE, selector);
+}
+
static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph,
u32 selector)
{
@@ -854,6 +859,7 @@ static const struct scmi_pinctrl_proto_ops pinctrl_proto_ops = {
.function_groups_get = scmi_pinctrl_function_groups_get,
.function_flags_get = scmi_pinctrl_function_flags_get,
.mux_set = scmi_pinctrl_mux_set,
+ .pin_mux_set = scmi_pinctrl_pin_mux_set,
.settings_get_one = scmi_pinctrl_settings_get_one,
.settings_get_all = scmi_pinctrl_settings_get_all,
.settings_conf = scmi_pinctrl_settings_conf,
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 072190e89064..5cea4ee14a3e 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -789,6 +789,7 @@ enum scmi_pinctrl_conf_type {
* @function_flags_get: tells whether the specified function is pin-only and
* whether it is a GPIO function
* @mux_set: set muxing function for groups of pins
+ * @pin_mux_set: set muxing function for a single pin
* @settings_get_one: returns one configuration parameter for pin or group
* specified by config_type
* @settings_get_all: returns all configuration parameters for pin or group
@@ -812,6 +813,7 @@ struct scmi_pinctrl_proto_ops {
u32 selector, bool *pin_only, bool *gpio);
int (*mux_set)(const struct scmi_protocol_handle *ph, u32 selector,
u32 group);
+ int (*pin_mux_set)(const struct scmi_protocol_handle *ph, u32 selector, u32 pin);
int (*settings_get_one)(const struct scmi_protocol_handle *ph,
u32 selector,
enum scmi_pinctrl_selector_type type,
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 11/11] pinctrl: scmi: select the GPIO function on GPIO requests
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
` (9 preceding siblings ...)
2026-11-13 11:05 ` [PATCH v2 10/11] firmware: arm_scmi: add an operation to set the function of a single pin Clément Le Goffic
@ 2026-11-13 11:05 ` Clément Le Goffic
10 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-13 11:05 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski
Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel,
Clément Le Goffic
On a GPIO request, select the GPIO function of the pin, on the pin for a
pin-only function or on its single-pin group. Without a GPIO function the
mux is left as it is.
Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
---
drivers/pinctrl/pinctrl-scmi.c | 61 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 6d51025013ec..89be533354c0 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -74,6 +74,66 @@ static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset)
return pinctrl_ops->pin_free(pmx->ph, offset);
}
+static int pinctrl_scmi_gpio_mux_set(struct scmi_pinctrl *pmx, unsigned int pin)
+{
+ unsigned int nr_functions, nr_elems, nr_pins;
+ const unsigned int *elems, *pins;
+ bool pin_only, gpio;
+ int ret;
+
+ nr_functions = pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
+ for (unsigned int func = 0; func < nr_functions; func++) {
+ ret = pinctrl_ops->function_flags_get(pmx->ph, func, &pin_only, &gpio);
+ if (ret)
+ return ret;
+
+ if (!gpio)
+ continue;
+
+ ret = pinctrl_ops->function_groups_get(pmx->ph, func, &nr_elems, &elems);
+ if (ret)
+ return ret;
+
+ for (unsigned int i = 0; i < nr_elems; i++) {
+ if (pin_only) {
+ if (elems[i] != pin)
+ continue;
+
+ return pinctrl_ops->pin_mux_set(pmx->ph, func, pin);
+ }
+
+ ret = pinctrl_ops->group_pins_get(pmx->ph, elems[i], &pins, &nr_pins);
+ if (ret)
+ return ret;
+
+ if (nr_pins == 1 && pins[0] == pin)
+ return pinctrl_ops->mux_set(pmx->ph, func, elems[i]);
+ }
+ }
+
+ dev_dbg(pmx->dev, "No GPIO function for pin %u, mux left unchanged\n", pin);
+
+ return 0;
+}
+
+static int pinctrl_scmi_gpio_request_enable(struct pinctrl_dev *pctldev,
+ struct pinctrl_gpio_range *range,
+ unsigned int offset)
+{
+ struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
+ int ret;
+
+ ret = pinctrl_ops->pin_request(pmx->ph, offset);
+ if (ret)
+ return ret;
+
+ ret = pinctrl_scmi_gpio_mux_set(pmx, offset);
+ if (ret)
+ pinctrl_ops->pin_free(pmx->ph, offset);
+
+ return ret;
+}
+
static const struct pinmux_ops pinctrl_scmi_pinmux_ops = {
.request = pinctrl_scmi_request,
.free = pinctrl_scmi_free,
@@ -82,6 +142,7 @@ static const struct pinmux_ops pinctrl_scmi_pinmux_ops = {
.get_function_groups = pinmux_generic_get_function_groups,
.function_is_gpio = pinmux_generic_function_is_gpio,
.set_mux = pinctrl_scmi_func_set_mux,
+ .gpio_request_enable = pinctrl_scmi_gpio_request_enable,
};
static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
--
2.56.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes
2026-11-13 11:05 ` [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
@ 2026-11-17 14:35 ` Geert Uytterhoeven
2026-11-18 14:56 ` Clément Le Goffic
0 siblings, 1 reply; 14+ messages in thread
From: Geert Uytterhoeven @ 2026-11-17 14:35 UTC (permalink / raw)
To: Clément Le Goffic
Cc: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski, arm-scmi, linux-arm-kernel, linux-gpio,
linux-kernel
Hi Clément,
On Fri, 13 Nov 2026 at 16:02, Clément Le Goffic <clegoffic@baylibre.com> wrote:
> SCMI gives the drive strength in microamperes, but
> PIN_CONFIG_DRIVE_STRENGTH is in milliamperes and was sent unchanged.
> Convert it on set and on get. It is the only unit that differs: the
> debounce is in microseconds and the pull resistances in ohms on both
> sides, and every other value is a flag or implementation defined.
>
> Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
> Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
Thanks for your patch, which is now commit cc2f90768e971bcc ("pinctrl:
scmi: send the drive strength in microamperes") in pinctrl/for-next.
> --- a/drivers/pinctrl/pinctrl-scmi.c
> +++ b/drivers/pinctrl/pinctrl-scmi.c
> @@ -14,6 +14,7 @@
> #include <linux/scmi_protocol.h>
> #include <linux/slab.h>
> #include <linux/types.h>
> +#include <linux/units.h>
>
> #include <linux/pinctrl/machine.h>
> #include <linux/pinctrl/pinconf.h>
> @@ -155,6 +156,14 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_config_param param,
> return 0;
> }
>
> +static u32 pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 value)
> +{
> + if (param == PIN_CONFIG_DRIVE_STRENGTH)
> + return value / MILLI;
Does this need rounding?
While MILLI = 1000UL is correct from a numerical point of view,
it is not correct from a semantical point of view.
<linux/units.h> has:
#define MICROWATT_PER_MILLIWATT 1000UL
In the absence of a generic conversion value, "(MICRO / MILLI)" might
be better.
> +
> + return value;
> +}
> +
> static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
> enum scmi_pinctrl_conf_type *type)
> {
> @@ -167,13 +176,17 @@ static int pinctrl_scmi_map_pinconf_type_get(enum pin_config_param param,
> }
>
> static int pinctrl_scmi_map_pinconf_type_set(enum pin_config_param param,
> - enum scmi_pinctrl_conf_type *type)
> + enum scmi_pinctrl_conf_type *type,
> + u32 *arg)
> {
> if (param == PIN_CONFIG_LEVEL) {
> *type = SCMI_PIN_OUTPUT_VALUE;
> return 0;
> }
>
> + if (param == PIN_CONFIG_DRIVE_STRENGTH)
> + *arg *= MILLI;
What happens if the result differs from the original value in µA,
due to truncation or rounding?
Likewise about the use of MILLI.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes
2026-11-17 14:35 ` Geert Uytterhoeven
@ 2026-11-18 14:56 ` Clément Le Goffic
0 siblings, 0 replies; 14+ messages in thread
From: Clément Le Goffic @ 2026-11-18 14:56 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Sudeep Holla, Cristian Marussi, Linus Walleij, Peng Fan,
Oleksii Moisieiev, Andy Shevchenko, Dhruva Gole,
Bartosz Golaszewski, arm-scmi, linux-arm-kernel, linux-gpio,
linux-kernel
Hi Geert,
On 11/17/26 3:35 PM, Geert Uytterhoeven wrote:
> Hi Clément,
>
> On Fri, 13 Nov 2026 at 16:02, Clément Le Goffic <clegoffic@baylibre.com> wrote:
>> SCMI gives the drive strength in microamperes, but
>> PIN_CONFIG_DRIVE_STRENGTH is in milliamperes and was sent unchanged.
>> Convert it on set and on get. It is the only unit that differs: the
>> debounce is in microseconds and the pull resistances in ohms on both
>> sides, and every other value is a flag or implementation defined.
>>
>> Fixes: eb524cb651b7 ("pinctrl: Implementation of the generic scmi-pinctrl driver")
>> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
>> Signed-off-by: Clément Le Goffic <clegoffic@baylibre.com>
>
> Thanks for your patch, which is now commit cc2f90768e971bcc ("pinctrl:
> scmi: send the drive strength in microamperes") in pinctrl/for-next.
Yes, Linus took it 1h before my v2 and I didn't see it.
[...]
>> +static u32 pinctrl_scmi_map_pinconf_arg_get(enum pin_config_param param, u32 value)
>> +{
>> + if (param == PIN_CONFIG_DRIVE_STRENGTH)
>> + return value / MILLI;
>
> Does this need rounding?
Rounding does not help I think: SCMI only talks µA, and 10800 µA has no exact mA form.
I will send a fix that returns -EINVAL on get when the value is not a whole mA.
PIN_CONFIG_DRIVE_STRENGTH_UA still gives the exact value.
> While MILLI = 1000UL is correct from a numerical point of view,
> it is not correct from a semantical point of view.
>
> <linux/units.h> has:
>
> #define MICROWATT_PER_MILLIWATT 1000UL
>
> In the absence of a generic conversion value, "(MICRO / MILLI)" might
> be better.
Agreed, I will send a follow-up once Linus answers my question on v1 patch 7 about where to base v3 [1].
[...]
>> + *arg *= MILLI;
>
> What happens if the result differs from the original value in µA,
> due to truncation or rounding?
>
> Likewise about the use of MILLI.
Multiplying a whole mA by 1000 gives an exact µA value, so it never differs, unless it overflows the u32.
The same fix will return -EINVAL for that case.
The platform refuses a value it does not support and the set fails with -EINVAL.
[1] https://lore.kernel.org/all/ce463c97-8fde-44b3-b3bd-c21a69ee61b9@baylibre.com/
Best regards,
Clément
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-18 14:56 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 11:05 [PATCH v2 00/11] pinctrl: scmi: fixes and GPIO function support Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 01/11] pinctrl: scmi: send the drive strength in microamperes Clément Le Goffic
2026-11-17 14:35 ` Geert Uytterhoeven
2026-11-18 14:56 ` Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 02/11] pinctrl: scmi: map the schmitt trigger enable to its SCMI type Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 03/11] pinctrl: scmi: send the settings without argument as enabled Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 04/11] pinctrl: scmi: report an off setting as not set Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 05/11] firmware: arm_scmi: stop reading past PINCTRL_LIST_ASSOCIATIONS replies Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 06/11] firmware: arm_scmi: report the pin-only and GPIO flags of functions Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 07/11] pinctrl: scmi: give no groups to pin-only functions Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 08/11] pinctrl: scmi: mark the GPIO functions Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 09/11] pinctrl: scmi: report whether a function is GPIO Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 10/11] firmware: arm_scmi: add an operation to set the function of a single pin Clément Le Goffic
2026-11-13 11:05 ` [PATCH v2 11/11] pinctrl: scmi: select the GPIO function on GPIO requests Clément Le Goffic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®