From: "Clément Le Goffic" <clement.legoffic@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>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
devicetree@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
"Clément Le Goffic" <clement.legoffic@foss.st.com>
Subject: [PATCH v4 1/9] gpio: mmio: add BGPIOF_NO_INPUT flag for GPO gpiochip
Date: Wed, 28 May 2025 15:30:54 +0200 [thread overview]
Message-ID: <20250528-hdp-upstream-v4-1-7e9b3ad2036d@foss.st.com> (raw)
In-Reply-To: <20250528-hdp-upstream-v4-0-7e9b3ad2036d@foss.st.com>
When using bgpio_init with a gpiochip acting as a GPO (output only), the
gpiochip ops `direction_input` was set to `bgpio_simple_dir_in` by
default but we have no input ability.
Adding this flag allows to set a valid ops for the `direction_output`
ops without setting a valid ops for `direction_input` by default.
Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com>
---
drivers/gpio/gpio-mmio.c | 11 ++++++++++-
include/linux/gpio/driver.h | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index 4841e4ebe7a6..09b9e1275e7e 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -335,6 +335,11 @@ static int bgpio_dir_return(struct gpio_chip *gc, unsigned int gpio, bool dir_ou
return pinctrl_gpio_direction_input(gc, gpio);
}
+static int bgpio_dir_in_err(struct gpio_chip *gc, unsigned int gpio)
+{
+ return -EINVAL;
+}
+
static int bgpio_simple_dir_in(struct gpio_chip *gc, unsigned int gpio)
{
return bgpio_dir_return(gc, gpio, false);
@@ -566,7 +571,11 @@ static int bgpio_setup_direction(struct gpio_chip *gc,
gc->direction_output = bgpio_dir_out_err;
else
gc->direction_output = bgpio_simple_dir_out;
- gc->direction_input = bgpio_simple_dir_in;
+
+ if (flags & BGPIOF_NO_INPUT)
+ gc->direction_input = bgpio_dir_in_err;
+ else
+ gc->direction_input = bgpio_simple_dir_in;
}
return 0;
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 4c0294a9104d..42890db9b10e 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -749,6 +749,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
#define BGPIOF_NO_OUTPUT BIT(5) /* only input */
#define BGPIOF_NO_SET_ON_INPUT BIT(6)
#define BGPIOF_PINCTRL_BACKEND BIT(7) /* Call pinctrl direction setters */
+#define BGPIOF_NO_INPUT BIT(8) /* only output */
#ifdef CONFIG_GPIOLIB_IRQCHIP
int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
--
2.43.0
next prev parent reply other threads:[~2025-05-28 13:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 13:30 [PATCH v4 0/9] Introduce HDP support for STM32MP platforms Clément Le Goffic
2025-05-28 13:30 ` Clément Le Goffic [this message]
2025-06-05 12:59 ` [PATCH v4 1/9] gpio: mmio: add BGPIOF_NO_INPUT flag for GPO gpiochip Linus Walleij
2025-05-28 13:30 ` [PATCH v4 2/9] dt-bindings: pinctrl: stm32: Introduce HDP Clément Le Goffic
2025-05-28 14:29 ` Rob Herring (Arm)
2025-05-29 9:14 ` Krzysztof Kozlowski
2025-06-10 12:10 ` Clement LE GOFFIC
2025-05-28 13:30 ` [PATCH v4 3/9] pinctrl: stm32: Introduce HDP driver Clément Le Goffic
2025-06-05 13:02 ` Linus Walleij
2025-05-28 13:30 ` [PATCH v4 4/9] MAINTAINERS: add Clément Le Goffic as STM32 HDP maintainer Clément Le Goffic
2025-05-28 15:36 ` kernel test robot
2025-05-28 13:30 ` [PATCH v4 5/9] ARM: dts: stm32: add Hardware debug port (HDP) on stm32mp13 Clément Le Goffic
2025-05-29 9:13 ` Krzysztof Kozlowski
2025-06-10 12:11 ` Clement LE GOFFIC
2025-05-28 13:30 ` [PATCH v4 6/9] ARM: dts: stm32: add Hardware debug port (HDP) on stm32mp15 Clément Le Goffic
2025-05-29 9:13 ` Krzysztof Kozlowski
2025-05-28 13:31 ` [PATCH v4 7/9] ARM: dts: stm32: add Hardware debug port (HDP) on stm32mp25 Clément Le Goffic
2025-05-28 13:31 ` [PATCH v4 8/9] ARM: dts: stm32: add alternate pinmux for HDP pin and add HDP pinctrl node Clément Le Goffic
2025-05-28 13:31 ` [PATCH v4 9/9] ARM: dts: stm32: add Hardware debug port (HDP) on stm32mp157c-dk2 board Clément Le Goffic
2025-06-05 13:03 ` [PATCH v4 0/9] Introduce HDP support for STM32MP platforms Linus Walleij
2025-06-05 13:16 ` Bartosz Golaszewski
2025-06-10 12:20 ` Clement LE GOFFIC
2025-06-10 12:37 ` Krzysztof Kozlowski
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=20250528-hdp-upstream-v4-1-7e9b3ad2036d@foss.st.com \
--to=clement.legoffic@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--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 \
/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).