From: Conor Dooley <conor@kernel.org>
To: Linus Walleij <linusw@kernel.org>
Cc: conor@kernel.org, Conor Dooley <conor.dooley@microchip.com>,
Yixun Lan <dlan@kernel.org>,
Troy Mitchell <troy.mitchell@linux.spacemit.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev
Subject: [RFC v1 4/4] pinctrl: spacemit: move over to generic pinmux dt_node_to_map implementation
Date: Wed, 6 May 2026 10:57:42 +0100 [thread overview]
Message-ID: <20260506-womb-bonus-68a236490084@spud> (raw)
In-Reply-To: <20260506-energize-dramatize-051909e54256@spud>
From: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pinctrl/spacemit/pinctrl-k1.c | 33 ++++++++++-----------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/drivers/pinctrl/spacemit/pinctrl-k1.c b/drivers/pinctrl/spacemit/pinctrl-k1.c
index 41d8a34bc386b..c90b6ccfce2ea 100644
--- a/drivers/pinctrl/spacemit/pinctrl-k1.c
+++ b/drivers/pinctrl/spacemit/pinctrl-k1.c
@@ -114,11 +114,6 @@ struct spacemit_pinctrl_data {
const struct spacemit_pinctrl_dconf *dconf;
};
-struct spacemit_pin_mux_config {
- const struct spacemit_pin *pin;
- u32 config;
-};
-
/* map pin id to pinctrl register offset, refer MFPR definition */
static unsigned int spacemit_k1_pin_to_offset(unsigned int pin)
{
@@ -474,7 +469,6 @@ static int spacemit_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
ngroups = 0;
guard(mutex)(&pctrl->mutex);
for_each_available_child_of_node_scoped(np, child) {
- struct spacemit_pin_mux_config *pinmuxs;
unsigned int config, *pins;
int i, npins;
@@ -497,10 +491,6 @@ static int spacemit_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
if (!pins)
return -ENOMEM;
- pinmuxs = devm_kcalloc(dev, npins, sizeof(*pinmuxs), GFP_KERNEL);
- if (!pinmuxs)
- return -ENOMEM;
-
for (i = 0; i < npins; i++) {
ret = of_property_read_u32_index(child, "pinmux",
i, &config);
@@ -509,11 +499,6 @@ static int spacemit_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
return -EINVAL;
pins[i] = spacemit_dt_get_pin(config);
- pinmuxs[i].config = config;
- pinmuxs[i].pin = spacemit_get_pin(pctrl, pins[i]);
-
- if (!pinmuxs[i].pin)
- return dev_err_probe(dev, -ENODEV, "failed to get pin %d\n", pins[i]);
}
map[nmaps].type = PIN_MAP_TYPE_MUX_GROUP;
@@ -522,7 +507,7 @@ static int spacemit_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
nmaps += 1;
ret = pinctrl_generic_add_group(pctldev, grpname,
- pins, npins, pinmuxs);
+ pins, npins, &config);
if (ret < 0)
return dev_err_probe(dev, ret, "failed to add group %s: %d\n", grpname, ret);
@@ -559,7 +544,7 @@ static const struct pinctrl_ops spacemit_pctrl_ops = {
.get_group_name = pinctrl_generic_get_group_name,
.get_group_pins = pinctrl_generic_get_group_pins,
.pin_dbg_show = spacemit_pctrl_dbg_show,
- .dt_node_to_map = spacemit_pctrl_dt_node_to_map,
+ .dt_node_to_map = pinctrl_generic_pinmux_dt_node_to_map,
.dt_free_map = pinctrl_utils_free_map,
};
@@ -568,8 +553,8 @@ static int spacemit_pmx_set_mux(struct pinctrl_dev *pctldev,
{
struct spacemit_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
const struct group_desc *group;
- const struct spacemit_pin_mux_config *configs;
unsigned int i, mux;
+ unsigned int *configs;
void __iomem *reg;
group = pinctrl_generic_get_group(pctldev, gsel);
@@ -579,11 +564,17 @@ static int spacemit_pmx_set_mux(struct pinctrl_dev *pctldev,
configs = group->data;
for (i = 0; i < group->grp.npins; i++) {
- const struct spacemit_pin *spin = configs[i].pin;
- u32 value = configs[i].config;
+ const struct spacemit_pin *spin;
+ u32 value = configs[i];
+
+ spin = spacemit_get_pin(pctrl, group->grp.pins[i]);
+ if (!spin) {
+ dev_err(pctrl->dev, "Invalid pin %u\n", group->grp.pins[i]);
+ return -EINVAL;
+ }
reg = spacemit_pin_to_reg(pctrl, spin->pin);
- mux = spacemit_dt_get_pin_mux(value);
+ mux = value;
guard(raw_spinlock_irqsave)(&pctrl->lock);
value = readl_relaxed(reg) & ~PAD_MUX;
--
2.53.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
prev parent reply other threads:[~2026-05-06 9:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 9:57 [RFC v1 0/4] generic pinmux dt_node_to_map implementation Conor Dooley
2026-05-06 9:57 ` [RFC v1 1/4] pinctrl: generic: change signature of pinctrl_generic_to_map() to pass void data Conor Dooley
2026-05-06 9:57 ` [RFC v1 2/4] pinctrl: add new generic groups/function creation function for pinmux Conor Dooley
2026-05-06 9:57 ` [RFC v1 3/4] pinctrl: spacemit: delete check_power() Conor Dooley
2026-05-06 9:57 ` Conor Dooley [this message]
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=20260506-womb-bonus-68a236490084@spud \
--to=conor@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=dlan@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=spacemit@lists.linux.dev \
--cc=troy.mitchell@linux.spacemit.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