* [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state
@ 2025-10-18 9:59 Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 1/2] " Maud Spierings via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Maud Spierings via B4 Relay @ 2025-10-18 9:59 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings, Ahmad Fatoum
Make _get_value() read back the dr register instead of the psr register
when the direction is set to output. Now _get_value() can actually read
the state of an output gpio instead of being always low.
Also add a note in the migration guide file.
Signed-off-by: Maud Spierings <maud_spierings@hotmail.com>
---
Changes in v2:
- Move the extra commit comment into the commit [1/2]
- Actually add a note to the migration file [2/2]
- Link to v1: https://lore.kernel.org/r/20251015-imx_gpio-v1-0-e57925f906bb@hotmail.com
---
Maud Spierings (2):
gpio: i.MX: make _get_value() able to read output pin state
Documentation: migration-2025.11.0: add note about new gpio behaviour
.../migration-guides/migration-2025.11.0.rst | 7 +++++++
drivers/gpio/gpio-imx.c | 19 +++++++++++--------
2 files changed, 18 insertions(+), 8 deletions(-)
---
base-commit: 8defba1d0ab1aef9dd5d57710e18d0d02e2c48e2
change-id: 20251015-imx_gpio-46efe1e7abd3
Best regards,
--
Maud Spierings <maud_spierings@hotmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] gpio: i.MX: make _get_value() able to read output pin state
2025-10-18 9:59 [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay
@ 2025-10-18 9:59 ` Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 2/2] Documentation: migration-2025.11.0: add note about new gpio behaviour Maud Spierings via B4 Relay
2025-10-20 8:21 ` [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Maud Spierings via B4 Relay @ 2025-10-18 9:59 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings, Ahmad Fatoum
From: Maud Spierings <maud_spierings@hotmail.com>
Make _get_value() read back the dr register instead of the psr register
when the direction is set to output. Now _get_value() can actually read
the state of an output gpio instead of being always low.
This aproach is also used by u-boot and Linux.
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Maud Spierings <maud_spierings@hotmail.com>
---
drivers/gpio/gpio-imx.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-imx.c b/drivers/gpio/gpio-imx.c
index d9499c66cd..bb14c56399 100644
--- a/drivers/gpio/gpio-imx.c
+++ b/drivers/gpio/gpio-imx.c
@@ -89,24 +89,27 @@ static int imx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int
return 0;
}
-static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+static int imx_get_direction(struct gpio_chip *chip, unsigned offset)
{
struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
void __iomem *base = imxgpio->base;
- u32 val;
-
- val = readl(base + imxgpio->regs->psr);
+ u32 val = readl(base + imxgpio->regs->gdir);
- return val & (1 << gpio) ? 1 : 0;
+ return (val & (1 << offset)) ? GPIOF_DIR_OUT : GPIOF_DIR_IN;
}
-static int imx_get_direction(struct gpio_chip *chip, unsigned offset)
+static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
{
struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
void __iomem *base = imxgpio->base;
- u32 val = readl(base + imxgpio->regs->gdir);
+ u32 val;
- return (val & (1 << offset)) ? GPIOF_DIR_OUT : GPIOF_DIR_IN;
+ if (imx_get_direction(chip, gpio) == GPIOF_DIR_IN)
+ val = readl(base + imxgpio->regs->psr);
+ else
+ val = readl(base + imxgpio->regs->dr);
+
+ return val & (1 << gpio) ? 1 : 0;
}
static struct gpio_ops imx_gpio_ops = {
--
2.51.1.dirty
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] Documentation: migration-2025.11.0: add note about new gpio behaviour
2025-10-18 9:59 [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 1/2] " Maud Spierings via B4 Relay
@ 2025-10-18 9:59 ` Maud Spierings via B4 Relay
2025-10-20 8:21 ` [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Maud Spierings via B4 Relay @ 2025-10-18 9:59 UTC (permalink / raw)
To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings
From: Maud Spierings <maud_spierings@hotmail.com>
The previous change, changes the behaviour of reading gpio values, make
a note of it in the migration guide.
Signed-off-by: Maud Spierings <maud_spierings@hotmail.com>
---
Documentation/migration-guides/migration-2025.11.0.rst | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/migration-guides/migration-2025.11.0.rst b/Documentation/migration-guides/migration-2025.11.0.rst
new file mode 100644
index 0000000000..9cbc46acc3
--- /dev/null
+++ b/Documentation/migration-guides/migration-2025.11.0.rst
@@ -0,0 +1,7 @@
+i.MX GPIOs
+----------
+
+Reading output GPIOs now returns the configured output level instead
+of reading back the input register. This aligns us with what Linux
+is doing, but may falsify readings of single-ended GPIOs that have
+the SION bit configured.
--
2.51.1.dirty
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state
2025-10-18 9:59 [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 1/2] " Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 2/2] Documentation: migration-2025.11.0: add note about new gpio behaviour Maud Spierings via B4 Relay
@ 2025-10-20 8:21 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2025-10-20 8:21 UTC (permalink / raw)
To: BAREBOX, Maud Spierings via B4 Relay; +Cc: Maud Spierings, Ahmad Fatoum
On Sat, 18 Oct 2025 11:59:46 +0200, Maud Spierings via B4 Relay wrote:
> Make _get_value() read back the dr register instead of the psr register
> when the direction is set to output. Now _get_value() can actually read
> the state of an output gpio instead of being always low.
>
> Also add a note in the migration guide file.
>
>
> [...]
Applied, thanks!
[1/2] gpio: i.MX: make _get_value() able to read output pin state
https://git.pengutronix.de/cgit/barebox/commit/?id=9749d5bb4cfd (link may not be stable)
[2/2] Documentation: migration-2025.11.0: add note about new gpio behaviour
https://git.pengutronix.de/cgit/barebox/commit/?id=5e531faed8b2 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-20 12:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-18 9:59 [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 1/2] " Maud Spierings via B4 Relay
2025-10-18 9:59 ` [PATCH v2 2/2] Documentation: migration-2025.11.0: add note about new gpio behaviour Maud Spierings via B4 Relay
2025-10-20 8:21 ` [PATCH v2 0/2] gpio: i.MX: make _get_value() able to read output pin state Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox