| Message ID | 20260517171405.3697469-1-paulk@sys-base.io (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-23434-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id CD2681C021A for <noreply@patchwork.local>; Sun, 17 May 2026 19:23:48 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-23434-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-23434-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 9D2A13002308 for <noreply@patchwork.local>; Sun, 17 May 2026 17:23:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FE113C65E0; Sun, 17 May 2026 17:23:45 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EA203C5DD4 for <linux-sunxi@lists.linux.dev>; Sun, 17 May 2026 17:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779038625; cv=none; b=aY8RukDLyci0OfKrbOLcbBLIgKl+Hc2M4fgJ1zT5f33qGrGha8gDNRPcXw0fGQYYMpC0n0f6D12Z1S5+u7pMcYHlgrSP1Pr28wUcX+pBlR70bzUlOYqZKa34TJzkhEq1Ee3oeZWv9QIVqMzVJvX5lQyJEHz0a5/hYEb0DGZaapE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779038625; c=relaxed/simple; bh=w5oEMeftLT6dpjH4N6NKR2mi8NlY8HlAmFv9o+3dyb0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GlK6qP9A44vTSMxO3nABidH39ZRUpZnFVMhb5iupA7S74aNhF9/WT9I6njWiyUCtPZ0tjkfGDdxW6gLRy9JOcItCDd39qqsFizYPIKPzjZacJqSVWtdq7RPW36tV/yHY/ndUAFgOKB4VMDevvo5QtIHzNW3fHX+luQSxroiAtuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 82C481F8004A for <linux-sunxi@lists.linux.dev>; Sun, 17 May 2026 17:14:25 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id A1F09B407A2; Sun, 17 May 2026 17:14:24 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id CB7A8B4079C; Sun, 17 May 2026 17:14:06 +0000 (UTC) From: Paul Kocialkowski <paulk@sys-base.io> To: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Andre Przywara <andre.przywara@arm.com>, Linus Walleij <linusw@kernel.org>, Chen-Yu Tsai <wens@kernel.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Paul Kocialkowski <paulk@sys-base.io> Subject: [PATCH] pinctrl: sunxi: Implement function_is_gpio Date: Sun, 17 May 2026 19:14:05 +0200 Message-ID: <20260517171405.3697469-1-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[99.99%]; RBL_SENDERSCORE(2.00)[172.232.135.74:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[arm.com,kernel.org,gmail.com,sholland.org,sys-base.io]; DMARC_NA(0.00)[sys-base.io]; FUZZY_BLOCKED(0.00)[rspamd.com]; TAGGED_RCPT(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[sys-base.io:email]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; RCPT_COUNT_SEVEN(0.00)[10]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.232.135.74]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.232.128.0/19, country:SG]; R_DKIM_NA(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; TAGGED_FROM(0.00)[bounces-23434-noreply=patchwork.local]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: CD2681C021A X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
pinctrl: sunxi: Implement function_is_gpio
|
|
Commit Message
Paul Kocialkowski
May 17, 2026, 5:14 p.m. UTC
The function_is_gpio pinmux op allows the core to find out whether a
GPIO can be safely requested from a pinctrl property and requested as a
GPIO at the same time.
This is especially useful to request a GPIO with a particular drive
strength, which would otherwise not be possible.
Signed-off-by: Paul Kocialkowski <paulk@sys-base.io>
---
drivers/pinctrl/sunxi/pinctrl-sunxi.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
Comments
On Sun, 17 May 2026 19:14:05 +0200 Paul Kocialkowski <paulk@sys-base.io> wrote: Hi Paul, > The function_is_gpio pinmux op allows the core to find out whether a > GPIO can be safely requested from a pinctrl property and requested as a > GPIO at the same time. > > This is especially useful to request a GPIO with a particular drive > strength, which would otherwise not be possible. That looks a easy enough solution, but: > Signed-off-by: Paul Kocialkowski <paulk@sys-base.io> > --- > drivers/pinctrl/sunxi/pinctrl-sunxi.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > index d3042e0c9712..6162f2d86723 100644 > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > @@ -821,6 +821,17 @@ static int sunxi_pmx_get_func_groups(struct pinctrl_dev *pctldev, > return 0; > } > > +static bool sunxi_pmx_function_is_gpio(struct pinctrl_dev *pctldev, > + unsigned function) > +{ > + struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); > + > + if (!strncmp(pctl->functions[function].name, "gpio", 4)) I wonder if this condition is a bit too relaxed? There could be some (theoretical) function just starting with gpio, but not being mux 0 or 1. So should we check for gpio_in or gpio_out, explicitly? Or at least use (strcmp(name, "gpio_", 5)? Or maybe even better for the mux value directly? Is "function" an indicator of this, or does this rely on the two GPIO functions being always listed first, at least so far? And what about the IRQ function? Isn't that some GPIO as well, or does that not count for the purpose of the function_is_gpio() callback? Cheers, Andre > + return true; > + > + return false; > +} > + > static void sunxi_pmx_set(struct pinctrl_dev *pctldev, > unsigned pin, > u8 config) > @@ -952,6 +963,7 @@ static const struct pinmux_ops sunxi_pmx_ops = { > .get_functions_count = sunxi_pmx_get_funcs_cnt, > .get_function_name = sunxi_pmx_get_func_name, > .get_function_groups = sunxi_pmx_get_func_groups, > + .function_is_gpio = sunxi_pmx_function_is_gpio, > .set_mux = sunxi_pmx_set_mux, > .gpio_set_direction = sunxi_pmx_gpio_set_direction, > .request = sunxi_pmx_request,
On Mon, May 25, 2026 at 11:39 PM Andre Przywara <andre.przywara@arm.com> wrote: > And what about the IRQ function? Isn't that some GPIO as well, or does > that not count for the purpose of the function_is_gpio() callback? The purpose of the function is to tell the GPIO subsystem if a pin is muxed into GPIO mode, and by that we mean a driver using struct gpio_chip, so we can approve a request of gpiod_get*(). The struct irq_chip is often orthogonal and I think it would usually "just work", and a struct irq_chip unrelated to a struct gpio_chip (i.e. there is no way to actually drive or listen to the lines) is something completely separate from struct gpio_chip. Yours, Linus Walleij
Hi Andrew, On Mon 25 May 26, 23:38, Andre Przywara wrote: > On Sun, 17 May 2026 19:14:05 +0200 > Paul Kocialkowski <paulk@sys-base.io> wrote: > > Hi Paul, > > > The function_is_gpio pinmux op allows the core to find out whether a > > GPIO can be safely requested from a pinctrl property and requested as a > > GPIO at the same time. > > > > This is especially useful to request a GPIO with a particular drive > > strength, which would otherwise not be possible. > > That looks a easy enough solution, but: > > > Signed-off-by: Paul Kocialkowski <paulk@sys-base.io> > > --- > > drivers/pinctrl/sunxi/pinctrl-sunxi.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > > index d3042e0c9712..6162f2d86723 100644 > > --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c > > +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c > > @@ -821,6 +821,17 @@ static int sunxi_pmx_get_func_groups(struct pinctrl_dev *pctldev, > > return 0; > > } > > > > +static bool sunxi_pmx_function_is_gpio(struct pinctrl_dev *pctldev, > > + unsigned function) > > +{ > > + struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); > > + > > + if (!strncmp(pctl->functions[function].name, "gpio", 4)) > > I wonder if this condition is a bit too relaxed? There could be > some (theoretical) function just starting with gpio, but not being mux > 0 or 1. Yes maybe this is a bit too relaxed. > So should we check for gpio_in or gpio_out, explicitly? Or at > least use (strcmp(name, "gpio_", 5)? Or maybe even better for the mux > value directly? Is "function" an indicator of this, or does this rely > on the two GPIO functions being always listed first, at least so far? I considered mathcing the function to the mux index, but we can't really rely on Allwinner keeping GPIO to mux 0/1 either so I think the string comparison is still the best approach. But I am totally fine with having an explicit check against "gpio_in" || "gpio_out". And to answer your question it's not safe to use the function as mux value, even though the values are the same in practice. The muxval field of struct sunxi_desc_function should be used instead and that can be looked up by sunxi_pinctrl_desc_find_function_by_name. All the best, Paul > And what about the IRQ function? Isn't that some GPIO as well, or does > that not count for the purpose of the function_is_gpio() callback? > > Cheers, > Andre > > > + return true; > > + > > + return false; > > +} > > + > > static void sunxi_pmx_set(struct pinctrl_dev *pctldev, > > unsigned pin, > > u8 config) > > @@ -952,6 +963,7 @@ static const struct pinmux_ops sunxi_pmx_ops = { > > .get_functions_count = sunxi_pmx_get_funcs_cnt, > > .get_function_name = sunxi_pmx_get_func_name, > > .get_function_groups = sunxi_pmx_get_func_groups, > > + .function_is_gpio = sunxi_pmx_function_is_gpio, > > .set_mux = sunxi_pmx_set_mux, > > .gpio_set_direction = sunxi_pmx_gpio_set_direction, > > .request = sunxi_pmx_request, >
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index d3042e0c9712..6162f2d86723 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -821,6 +821,17 @@ static int sunxi_pmx_get_func_groups(struct pinctrl_dev *pctldev, return 0; } +static bool sunxi_pmx_function_is_gpio(struct pinctrl_dev *pctldev, + unsigned function) +{ + struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); + + if (!strncmp(pctl->functions[function].name, "gpio", 4)) + return true; + + return false; +} + static void sunxi_pmx_set(struct pinctrl_dev *pctldev, unsigned pin, u8 config) @@ -952,6 +963,7 @@ static const struct pinmux_ops sunxi_pmx_ops = { .get_functions_count = sunxi_pmx_get_funcs_cnt, .get_function_name = sunxi_pmx_get_func_name, .get_function_groups = sunxi_pmx_get_func_groups, + .function_is_gpio = sunxi_pmx_function_is_gpio, .set_mux = sunxi_pmx_set_mux, .gpio_set_direction = sunxi_pmx_gpio_set_direction, .request = sunxi_pmx_request,