From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Bartosz Golaszewski <brgl@bgdev.pl>, <linux-gpio@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>
Cc: Antonio Borneo <antonio.borneo@foss.st.com>,
Christophe Roullier <christophe.roullier@foss.st.com>,
Fabien Dessenne <fabien.dessenne@foss.st.com>,
Valentin Caron <valentin.caron@foss.st.com>
Subject: [PATCH v4 02/12] pinctrl: pinconf-generic: Handle string values for generic properties
Date: Thu, 23 Oct 2025 15:26:50 +0200 [thread overview]
Message-ID: <20251023132700.1199871-3-antonio.borneo@foss.st.com> (raw)
In-Reply-To: <20251023132700.1199871-1-antonio.borneo@foss.st.com>
Allow a generic pinconf property to specify its argument as one of
the strings in a match list.
Convert the matching string to an integer value using the index in
the list, then keep using this value in the generic pinconf code.
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
---
drivers/pinctrl/pinconf-generic.c | 57 ++++++++++++++++++-------
include/linux/pinctrl/pinconf-generic.h | 11 ++++-
2 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index e3d10bbcdaebc..72906d71ae1a2 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -65,11 +65,12 @@ static void pinconf_generic_dump_one(struct pinctrl_dev *pctldev,
int i;
for (i = 0; i < nitems; i++) {
+ const struct pin_config_item *item = &items[i];
unsigned long config;
int ret;
/* We want to check out this parameter */
- config = pinconf_to_config_packed(items[i].param, 0);
+ config = pinconf_to_config_packed(item->param, 0);
if (gname)
ret = pin_config_group_get(dev_name(pctldev->dev),
gname, &config);
@@ -86,15 +87,22 @@ static void pinconf_generic_dump_one(struct pinctrl_dev *pctldev,
if (*print_sep)
seq_puts(s, ", ");
*print_sep = 1;
- seq_puts(s, items[i].display);
+ seq_puts(s, item->display);
/* Print unit if available */
- if (items[i].has_arg) {
+ if (item->has_arg) {
u32 val = pinconf_to_config_argument(config);
- if (items[i].format)
- seq_printf(s, " (%u %s)", val, items[i].format);
+ if (item->format)
+ seq_printf(s, " (%u %s)", val, item->format);
else
seq_printf(s, " (0x%x)", val);
+
+ if (item->values && item->num_values) {
+ if (val < item->num_values)
+ seq_printf(s, " \"%s\"", item->values[val]);
+ else
+ seq_puts(s, " \"(unknown)\"");
+ }
}
}
}
@@ -205,10 +213,10 @@ static const struct pinconf_generic_params dt_params[] = {
* @ncfg. @ncfg is updated to reflect the number of entries after parsing. @cfg
* needs to have enough memory allocated to hold all possible entries.
*/
-static void parse_dt_cfg(struct device_node *np,
- const struct pinconf_generic_params *params,
- unsigned int count, unsigned long *cfg,
- unsigned int *ncfg)
+static int parse_dt_cfg(struct device_node *np,
+ const struct pinconf_generic_params *params,
+ unsigned int count, unsigned long *cfg,
+ unsigned int *ncfg)
{
int i;
@@ -217,7 +225,19 @@ static void parse_dt_cfg(struct device_node *np,
int ret;
const struct pinconf_generic_params *par = ¶ms[i];
- ret = of_property_read_u32(np, par->property, &val);
+ if (par->values && par->num_values) {
+ ret = fwnode_property_match_property_string(of_fwnode_handle(np),
+ par->property,
+ par->values, par->num_values);
+ if (ret == -ENOENT)
+ return ret;
+ if (ret >= 0) {
+ val = ret;
+ ret = 0;
+ }
+ } else {
+ ret = of_property_read_u32(np, par->property, &val);
+ }
/* property not found */
if (ret == -EINVAL)
@@ -231,6 +251,8 @@ static void parse_dt_cfg(struct device_node *np,
cfg[*ncfg] = pinconf_to_config_packed(par->param, val);
(*ncfg)++;
}
+
+ return 0;
}
/**
@@ -323,13 +345,16 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
if (!cfg)
return -ENOMEM;
- parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
+ ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
+ if (ret)
+ return ret;
if (pctldev && pctldev->desc->num_custom_params &&
- pctldev->desc->custom_params)
- parse_dt_cfg(np, pctldev->desc->custom_params,
- pctldev->desc->num_custom_params, cfg, &ncfg);
-
- ret = 0;
+ pctldev->desc->custom_params) {
+ ret = parse_dt_cfg(np, pctldev->desc->custom_params,
+ pctldev->desc->num_custom_params, cfg, &ncfg);
+ if (ret)
+ return ret;
+ }
/* no configs found at all */
if (ncfg == 0) {
diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h
index d9245ecec71dc..f82add5d3302d 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -181,21 +181,28 @@ static inline unsigned long pinconf_to_config_packed(enum pin_config_param param
return PIN_CONF_PACKED(param, argument);
}
-#define PCONFDUMP(a, b, c, d) { \
- .param = a, .display = b, .format = c, .has_arg = d \
+#define PCONFDUMP_WITH_VALUES(a, b, c, d, e, f) { \
+ .param = a, .display = b, .format = c, .has_arg = d, \
+ .values = e, .num_values = f \
}
+#define PCONFDUMP(a, b, c, d) PCONFDUMP_WITH_VALUES(a, b, c, d, NULL, 0)
+
struct pin_config_item {
const enum pin_config_param param;
const char * const display;
const char * const format;
bool has_arg;
+ const char * const *values;
+ size_t num_values;
};
struct pinconf_generic_params {
const char * const property;
enum pin_config_param param;
u32 default_value;
+ const char * const *values;
+ size_t num_values;
};
int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
--
2.34.1
next prev parent reply other threads:[~2025-10-23 13:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 13:26 [PATCH v4 00/12] pinctrl: stm32: Support I/O synchronization Antonio Borneo
2025-10-23 13:26 ` [PATCH v4 01/12] pinctrl: pinconf-generic: Fix minor typos in comments Antonio Borneo
2025-10-27 22:04 ` Linus Walleij
2025-10-23 13:26 ` Antonio Borneo [this message]
2025-10-27 22:10 ` [PATCH v4 02/12] pinctrl: pinconf-generic: Handle string values for generic properties Linus Walleij
2025-10-23 13:26 ` [PATCH v4 03/12] pinctrl: pinconf-generic: Add properties 'skew-delay-{in,out}put-ps' Antonio Borneo
2025-10-27 22:10 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 04/12] dt-bindings: pincfg-node: " Antonio Borneo
2025-10-23 18:51 ` Conor Dooley
2025-10-27 22:11 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 05/12] pinctrl: stm32: Rework stm32_pconf_parse_conf() Antonio Borneo
2025-10-27 22:12 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 06/12] pinctrl: stm32: Simplify handling of backup pin status Antonio Borneo
2025-10-27 22:12 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 07/12] pinctrl: stm32: Drop useless spinlock save and restore Antonio Borneo
2025-10-27 22:13 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 08/12] pinctrl: stm32: Avoid keeping a bool value in a u32 variable Antonio Borneo
2025-10-27 22:13 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 09/12] pinctrl: stm32: Support I/O synchronization parameters Antonio Borneo
2025-10-27 22:14 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 10/12] dt-bindings: pinctrl: stm32: Use properties from pincfg-node.yaml Antonio Borneo
2025-10-23 18:42 ` Conor Dooley
2025-10-27 22:15 ` Linus Walleij
2025-10-23 13:26 ` [PATCH v4 11/12] dt-bindings: pinctrl: stm32: Support I/O synchronization parameters Antonio Borneo
2025-10-23 18:50 ` Conor Dooley
2025-10-27 22:16 ` Linus Walleij
2025-10-23 13:27 ` [PATCH v4 12/12] arm64: dts: st: Add I/O sync to eth pinctrl in stm32mp25-pinctrl.dtsi Antonio Borneo
2025-10-27 22:17 ` Linus Walleij
2025-11-14 8:35 ` Alexandre TORGUE
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251023132700.1199871-3-antonio.borneo@foss.st.com \
--to=antonio.borneo@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=brgl@bgdev.pl \
--cc=christophe.roullier@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabien.dessenne@foss.st.com \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh@kernel.org \
--cc=valentin.caron@foss.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).