From: Richard GENOUD <richard.genoud@bootlin.com>
To: Jisheng Zhang <jszhang@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Andi Shyti <andi.shyti@kernel.org>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Frank Li <Frank.Li@nxp.com>, Lee Jones <lee@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-i3c@lists.infradead.org, mfd@lists.linux.dev,
linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 12/20] pinctrl: berlin: add optional pinconf support
Date: Wed, 28 Oct 2026 15:32:18 +0100 [thread overview]
Message-ID: <880e67e2-3f29-4dfd-84ee-09006dc86574@bootlin.com> (raw)
In-Reply-To: <20260929061417.20733-13-jszhang@kernel.org>
Le 29/09/2026 à 08:14, Jisheng Zhang a écrit :
> Add pinconf support for newer Synaptics SoCs.
>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> ---
> drivers/pinctrl/berlin/berlin.c | 232 +++++++++++++++++++++++++++++++-
> 1 file changed, 228 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
> index 0c2179b98629..06c67f00c527 100644
> --- a/drivers/pinctrl/berlin/berlin.c
> +++ b/drivers/pinctrl/berlin/berlin.c
> @@ -13,6 +13,8 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_device.h>
> +#include <linux/pinctrl/pinconf-generic.h>
> +#include <linux/pinctrl/pinconf.h>
> #include <linux/pinctrl/pinctrl.h>
> #include <linux/pinctrl/pinmux.h>
> #include <linux/platform_device.h>
> @@ -20,9 +22,24 @@
> #include <linux/slab.h>
>
> #include "../core.h"
> +#include "../pinconf.h"
> #include "../pinctrl-utils.h"
> #include "berlin.h"
>
> +#define PINCFG_DS_10BIT GENMASK(3, 0)
> +#define PINCFG_IE_10BIT BIT(4)
> +#define PINCFG_PE_10BIT BIT(5)
> +#define PINCFG_PS_10BIT BIT(6)
> +#define PINCFG_SL_10BIT BIT(7)
> +#define PINCFG_SPU_10BIT BIT(8)
> +#define PINCFG_ST_10BIT BIT(9)
> +#define PINCFG_DS_8BIT GENMASK(2, 0)
> +#define PINCFG_IE_8BIT BIT(3)
> +#define PINCFG_PD_8BIT BIT(4)
> +#define PINCFG_PU_8BIT BIT(5)
> +#define PINCFG_SL_8BIT BIT(6)
> +#define PINCFG_ST_8BIT BIT(7)
> +
> struct berlin_pinctrl {
> struct regmap *regmap;
> struct device *dev;
> @@ -56,6 +73,8 @@ static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
> struct property *prop;
> const char *function_name, *group_name;
> unsigned reserved_maps = 0;
> + unsigned long *configs = NULL;
> + unsigned int num_configs = 0;
> int ret, ngroups;
>
> *map = NULL;
> @@ -75,11 +94,19 @@ static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
> return -EINVAL;
> }
>
> + ret = pinconf_generic_parse_dt_config(node, pctrl_dev, &configs,
> + &num_configs);
> + if (ret < 0) {
> + dev_err(pctrl->dev, "%s: could not parse node property\n",
> + node->name);
> + return ret;
> + }
> +
> ret = pinctrl_utils_reserve_map(pctrl_dev, map, &reserved_maps,
> - num_maps, ngroups);
> + num_maps, ngroups * (num_configs + 1));
> if (ret) {
> dev_err(pctrl->dev, "can't reserve map: %d\n", ret);
> - return ret;
> + goto exit;
> }
>
> of_property_for_each_string(node, "groups", prop, group_name) {
> @@ -88,11 +115,22 @@ static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
> function_name);
> if (ret) {
> dev_err(pctrl->dev, "can't add map: %d\n", ret);
> - return ret;
> + goto exit;
> + }
> +
> + if (num_configs) {
> + ret = pinctrl_utils_add_map_configs(pctrl_dev, map,
> + &reserved_maps, num_maps, group_name,
> + configs, num_configs,
> + PIN_MAP_TYPE_CONFIGS_GROUP);
> + if (ret < 0)
> + goto exit;
> }
> }
>
> - return 0;
> +exit:
> + kfree(configs);
> + return ret;
> }
>
> static const struct pinctrl_ops berlin_pinctrl_ops = {
> @@ -177,6 +215,191 @@ static const struct pinmux_ops berlin_pinmux_ops = {
> .set_mux = &berlin_pinmux_set,
> };
>
> +static int berlin_pinconf_group_get(struct pinctrl_dev *pctrl_dev,
> + unsigned int group, unsigned long *configs)
> +{
> + enum pin_config_param param = pinconf_to_config_param(*configs);
> + struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
> + const struct berlin_desc_group *group_desc = pctrl->desc->groups + group;
> + bool enabled;
> + u32 val;
> + int ret;
> + u8 conf_bits = group_desc->conf_bits;
> +
> + if (!conf_bits)
> + return -EOPNOTSUPP;
> +
> + ret = regmap_read(pctrl->regmap, group_desc->conf_offset, &val);
> + if (ret)
> + return ret;
> +
> + switch (param) {
> + case PIN_CONFIG_BIAS_DISABLE:
> + if (conf_bits == 10)
> + enabled = !(val & PINCFG_PE_10BIT);
> + else
> + enabled = !(val & (PINCFG_PD_8BIT | PINCFG_PU_8BIT));
> + val = 0;
> + break;
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> + if (conf_bits == 10)
> + enabled = (val & (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) == PINCFG_PE_10BIT;
> + else
> + enabled = val & PINCFG_PD_8BIT;
> + val = enabled ? 1 : 0;
> + break;
> + case PIN_CONFIG_BIAS_PULL_UP:
> + if (conf_bits == 10) {
> + if ((val & (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) == (PINCFG_PE_10BIT | PINCFG_PS_10BIT)) {
> + enabled = true;
> + if (val & PINCFG_SPU_10BIT)
> + val = 2;
> + else
> + val = 1;
> + } else {
> + enabled = false;
> + val = 0;
> + }
> + } else {
> + enabled = val & PINCFG_PU_8BIT;
> + val = enabled ? 1 : 0;
> + }
> + break;
> + case PIN_CONFIG_DRIVE_STRENGTH:
> + enabled = true;
> + if (conf_bits == 10)
> + val = FIELD_GET(PINCFG_DS_10BIT, val);
> + else
> + val = FIELD_GET(PINCFG_DS_8BIT, val);
> + break;
> + case PIN_CONFIG_INPUT_ENABLE:
> + if (conf_bits == 10)
> + enabled = val & PINCFG_IE_10BIT;
> + else
> + enabled = val & PINCFG_IE_8BIT;
> + val = enabled ? 1 : 0;
> + break;
> + case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
> + if (conf_bits == 10)
> + enabled = val & PINCFG_ST_10BIT;
> + else
> + enabled = val & PINCFG_ST_8BIT;
> + val = enabled ? 1 : 0;
> + break;
> + case PIN_CONFIG_SLEW_RATE:
> + if (conf_bits == 10)
> + enabled = val & PINCFG_SL_10BIT;
> + else
> + enabled = val & PINCFG_SL_8BIT;
> + val = enabled ? 1 : 0;
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
> + *configs = pinconf_to_config_packed(param, val);
> + return enabled ? 0 : -EINVAL;
> +}
> +
> +static int berlin_pinconf_group_set(struct pinctrl_dev *pctrl_dev,
> + unsigned int group, unsigned long *configs,
> + unsigned int nconfigs)
> +{
> + struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
> + const struct berlin_desc_group *group_desc = pctrl->desc->groups + group;
> + u8 conf_bits = group_desc->conf_bits;
> + u32 mask = 0, val = 0;
> + int i;
> +
> + if (!conf_bits)
> + return -EOPNOTSUPP;
> +
> + for (i = 0; i < nconfigs; i++) {
> + enum pin_config_param param =
> + pinconf_to_config_param(configs[i]);
> + u32 arg = pinconf_to_config_argument(configs[i]);
> +
> + switch (param) {
> + case PIN_CONFIG_BIAS_DISABLE:
> + if (conf_bits == 10)
> + mask |= (PINCFG_PE_10BIT | PINCFG_PS_10BIT | PINCFG_SPU_10BIT);
> + else
> + mask |= (PINCFG_PU_8BIT | PINCFG_PD_8BIT);
> + break;
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> + if (conf_bits == 10) {
> + mask |= (PINCFG_PE_10BIT | PINCFG_PS_10BIT | PINCFG_SPU_10BIT);
> + val |= PINCFG_PE_10BIT;
> + } else {
> + mask |= (PINCFG_PU_8BIT | PINCFG_PD_8BIT);
> + val |= PINCFG_PD_8BIT;
> + }
> + break;
> + case PIN_CONFIG_BIAS_PULL_UP:
> + if (conf_bits == 10) {
> + mask |= (PINCFG_PE_10BIT | PINCFG_PS_10BIT | PINCFG_SPU_10BIT);
> + val |= (PINCFG_PE_10BIT | PINCFG_PS_10BIT);
> + if (arg == 2)
> + val |= PINCFG_SPU_10BIT;
The value 2 Ohms is hijacked to be used as strong pull up.
The more I look at that, the more it feels hacky.
> + } else {
> + mask |= (PINCFG_PU_8BIT | PINCFG_PD_8BIT);
> + val |= PINCFG_PU_8BIT;
> + }
> + break;
> + case PIN_CONFIG_DRIVE_STRENGTH:
> + if (conf_bits == 10)
> + mask |= PINCFG_DS_10BIT;
> + else
> + mask |= PINCFG_DS_8BIT;
> + val |= arg;
The drive strength is assumed to be lsb (which is the case), but maybe
something like:
if (arg > FIELD_MAX(mask))
return -EINVAL;
val |= FIELD_PREP(mask, arg);
would be more generic.
> + break;
> + case PIN_CONFIG_INPUT_ENABLE:
> + if (conf_bits == 10) {
> + mask |= PINCFG_IE_10BIT;
> + if (arg)
> + val |= PINCFG_IE_10BIT;
> + } else {
> + mask |= PINCFG_IE_8BIT;
> + if (arg)
> + val |= PINCFG_IE_8BIT;
> + }
> + break;
> + case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
> + if (conf_bits == 10) {
> + mask |= PINCFG_ST_10BIT;
> + if (arg)
> + val |= PINCFG_ST_10BIT;
> + } else {
> + mask |= PINCFG_ST_8BIT;
> + if (arg)
> + val |= PINCFG_ST_8BIT;
> + }
> + break;
> + case PIN_CONFIG_SLEW_RATE:
> + if (conf_bits == 10) {
> + mask |= PINCFG_SL_10BIT;
> + if (arg)
> + val |= PINCFG_SL_10BIT;
> + } else {
> + mask |= PINCFG_SL_8BIT;
> + if (arg)
> + val |= PINCFG_SL_8BIT;
> + }
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> + }
> +
> + return regmap_update_bits(pctrl->regmap, group_desc->conf_offset, mask, val);
> +}
> +
> +static const struct pinconf_ops berlin_confops = {
> + .is_generic = true,
> + .pin_config_group_get = berlin_pinconf_group_get,
> + .pin_config_group_set = berlin_pinconf_group_set,
> +};
> +
> static int berlin_pinctrl_add_function(struct berlin_pinctrl *pctrl,
> const char *name)
> {
> @@ -287,6 +510,7 @@ static const struct pinctrl_desc berlin_pctrl_desc = {
> .name = "berlin-pinctrl",
> .pctlops = &berlin_pinctrl_ops,
> .pmxops = &berlin_pinmux_ops,
> + .confops = &berlin_confops,
> .owner = THIS_MODULE,
> };
>
Regards,
Richard
next prev parent reply other threads:[~2026-10-28 14:32 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 6:13 [PATCH 00/20] arm64: add Synaptics SL261X SoCs and RDK boards Jisheng Zhang
2026-09-29 6:13 ` [PATCH 01/20] dt-bindings: serial: snps-dw-apb-uart: Add Synaptics sl261x uart Jisheng Zhang
2026-09-29 6:13 ` [PATCH 02/20] dt-bindings: i2c: dw: Add Synaptics sl261x i2c Jisheng Zhang
2026-09-29 20:57 ` Andi Shyti
2026-09-29 6:14 ` [PATCH 03/20] spi: dt-bindings: snps,dw-apb-ssi: Add Synaptics sl261x spi Jisheng Zhang
2026-09-29 6:14 ` [PATCH 04/20] dt-bindings: i3c: dw: support up to two reset lines Jisheng Zhang
2026-09-29 19:40 ` Conor Dooley
2026-10-19 12:55 ` Philipp Zabel
2026-10-20 1:08 ` Jisheng Zhang
2026-10-20 17:47 ` Conor Dooley
2026-09-29 6:14 ` [PATCH 05/20] i3c: dw: switch to array-based exclusive reset control Jisheng Zhang
2026-09-29 15:01 ` Frank Li
2026-10-19 12:55 ` Philipp Zabel
2026-10-20 1:01 ` Jisheng Zhang
2026-09-29 6:14 ` [PATCH 06/20] dt-bindings: i3c: Add Synaptics sl261x i3c Jisheng Zhang
2026-09-29 6:14 ` [PATCH 07/20] arm64: kconfig: let ARCH_BERLIN cover Synaptics arm64 SoCs Jisheng Zhang
2026-09-29 6:14 ` [PATCH 08/20] dt-bindings: reset: add Synaptics SL261X SoCs Jisheng Zhang
2026-09-29 19:44 ` Conor Dooley
2026-09-30 15:15 ` Jisheng Zhang
2026-09-30 16:49 ` Conor Dooley
2026-10-02 15:35 ` Jisheng Zhang
2026-10-05 10:50 ` Conor Dooley
2026-09-29 6:14 ` [PATCH 09/20] reset: add Synaptics SL261x reset support Jisheng Zhang
2026-09-29 6:14 ` [PATCH 10/20] pinctrl: berlin: use u16 instead of u8 for the offset Jisheng Zhang
2026-09-29 6:14 ` [PATCH 11/20] pinctrl: berlin: enable module build support Jisheng Zhang
2026-09-29 6:14 ` [PATCH 12/20] pinctrl: berlin: add optional pinconf support Jisheng Zhang
2026-10-28 14:32 ` Richard GENOUD [this message]
2026-09-29 6:14 ` [PATCH 13/20] dt-bindings: pinctrl: berlin: Support Synaptics SL261X SoCs Jisheng Zhang
2026-10-27 9:11 ` Richard GENOUD
2026-09-29 6:14 ` [PATCH 14/20] pinctrl: berlin: support " Jisheng Zhang
2026-09-29 15:34 ` Uwe Kleine-König
2026-09-29 6:14 ` [PATCH 15/20] dt-bindings: clock: add Synaptics SL261X clock Jisheng Zhang
2026-09-29 19:46 ` Conor Dooley
2026-09-29 20:49 ` Rob Herring (Arm)
2026-09-30 14:18 ` Jisheng Zhang
2026-09-29 6:14 ` [PATCH 16/20] clk: berlin: add Synaptics SL261X SoC clocks and plls Jisheng Zhang
2026-09-29 6:14 ` [PATCH 17/20] dt-bindings: mfd: Add Synaptics SL261x global block binding Jisheng Zhang
2026-09-29 19:55 ` Conor Dooley
2026-09-29 6:14 ` [PATCH 18/20] regulator: dt-bindings: sy8827n: support standard properties Jisheng Zhang
2026-09-29 19:40 ` Conor Dooley
2026-09-29 6:14 ` [PATCH 19/20] dt-bindings: arm: berlin: Add Synaptics SL261X SoC and RDK board Jisheng Zhang
2026-10-26 21:50 ` Rob Herring (Arm)
2026-09-29 6:14 ` [PATCH 20/20] arm64: dts: synaptics: " Jisheng Zhang
2026-09-29 19:38 ` [PATCH 00/20] arm64: add Synaptics SL261X SoCs and RDK boards Conor Dooley
2026-09-30 14:15 ` Jisheng Zhang
2026-09-30 14:32 ` Jisheng Zhang
2026-09-30 16:35 ` Conor Dooley
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=880e67e2-3f29-4dfd-84ee-09006dc86574@bootlin.com \
--to=richard.genoud@bootlin.com \
--cc=Frank.Li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andi.shyti@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jbrunet+clk@baylibre.com \
--cc=jirislaby@kernel.org \
--cc=jszhang@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=sebastian.hesselbarth@gmail.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