* [PATCH 0/2] gpio: i.MX: make _get_value() able to read output pin state @ 2025-10-15 18:03 Maud Spierings via B4 Relay 2025-10-15 18:03 ` [PATCH 1/2] " Maud Spierings via B4 Relay 2025-10-15 18:03 ` [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file Maud Spierings via B4 Relay 0 siblings, 2 replies; 6+ messages in thread From: Maud Spierings via B4 Relay @ 2025-10-15 18:03 UTC (permalink / raw) To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings 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 new empty migration guide file. Signed-off-by: Maud Spierings <maud_spierings@hotmail.com> --- Maud Spierings (2): gpio: i.MX: make _get_value() able to read output pin state Documentation: migration-2025.11.0: add new empty file .../migration-guides/migration-2025.11.0.rst | 0 drivers/gpio/gpio-imx.c | 19 +++++++++++-------- 2 files changed, 11 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] 6+ messages in thread
* [PATCH 1/2] gpio: i.MX: make _get_value() able to read output pin state 2025-10-15 18:03 [PATCH 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay @ 2025-10-15 18:03 ` Maud Spierings via B4 Relay 2025-10-16 12:53 ` Ahmad Fatoum 2025-10-15 18:03 ` [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file Maud Spierings via B4 Relay 1 sibling, 1 reply; 6+ messages in thread From: Maud Spierings via B4 Relay @ 2025-10-15 18:03 UTC (permalink / raw) To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings 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. Signed-off-by: Maud Spierings <maud_spierings@hotmail.com> --- inspired by similar logic being used in u-boot and Linux --- 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.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] gpio: i.MX: make _get_value() able to read output pin state 2025-10-15 18:03 ` [PATCH 1/2] " Maud Spierings via B4 Relay @ 2025-10-16 12:53 ` Ahmad Fatoum 0 siblings, 0 replies; 6+ messages in thread From: Ahmad Fatoum @ 2025-10-16 12:53 UTC (permalink / raw) To: maud_spierings, Sascha Hauer, BAREBOX On 10/15/25 8:03 PM, Maud Spierings via B4 Relay wrote: > 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. > > Signed-off-by: Maud Spierings <maud_spierings@hotmail.com> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> > > --- > inspired by similar logic being used in u-boot and Linux That's useful info that should go into the commit message IMO, because it explains why we think regression should be limited. > --- > 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 = { > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file 2025-10-15 18:03 [PATCH 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay 2025-10-15 18:03 ` [PATCH 1/2] " Maud Spierings via B4 Relay @ 2025-10-15 18:03 ` Maud Spierings via B4 Relay 2025-10-16 12:58 ` Ahmad Fatoum 1 sibling, 1 reply; 6+ messages in thread From: Maud Spierings via B4 Relay @ 2025-10-15 18:03 UTC (permalink / raw) To: Sascha Hauer, BAREBOX; +Cc: Maud Spierings From: Maud Spierings <maud_spierings@hotmail.com> Add an empty file to hold any future migration notes. Signed-off-by: Maud Spierings <maud_spierings@hotmail.com> --- Documentation/migration-guides/migration-2025.11.0.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) 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..e69de29bb2 -- 2.51.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file 2025-10-15 18:03 ` [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file Maud Spierings via B4 Relay @ 2025-10-16 12:58 ` Ahmad Fatoum 2025-10-17 9:15 ` Maud Spierings 0 siblings, 1 reply; 6+ messages in thread From: Ahmad Fatoum @ 2025-10-16 12:58 UTC (permalink / raw) To: maud_spierings, Sascha Hauer, BAREBOX On 10/15/25 8:03 PM, Maud Spierings via B4 Relay wrote: > From: Maud Spierings <maud_spierings@hotmail.com> > > Add an empty file to hold any future migration notes. > > Signed-off-by: Maud Spierings <maud_spierings@hotmail.com> > --- > Documentation/migration-guides/migration-2025.11.0.rst | 0 > 1 file changed, 0 insertions(+), 0 deletions(-) > > diff --git a/Documentation/migration-guides/migration-2025.11.0.rst b/Documentation/migration-guides/migration-2025.11.0.rst Sorry, I should have been clearer; I am a bit wary of breaking scripts or board code that do SION shenanigans, so my suggestion to add a note. Something like: 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. > new file mode 100644 > index 0000000000..e69de29bb2 > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file 2025-10-16 12:58 ` Ahmad Fatoum @ 2025-10-17 9:15 ` Maud Spierings 0 siblings, 0 replies; 6+ messages in thread From: Maud Spierings @ 2025-10-17 9:15 UTC (permalink / raw) To: Ahmad Fatoum, Sascha Hauer, BAREBOX On 10/16/25 14:58, Ahmad Fatoum wrote: > > > On 10/15/25 8:03 PM, Maud Spierings via B4 Relay wrote: >> From: Maud Spierings <maud_spierings@hotmail.com> >> >> Add an empty file to hold any future migration notes. >> >> Signed-off-by: Maud Spierings <maud_spierings@hotmail.com> >> --- >> Documentation/migration-guides/migration-2025.11.0.rst | 0 >> 1 file changed, 0 insertions(+), 0 deletions(-) >> >> diff --git a/Documentation/migration-guides/migration-2025.11.0.rst b/Documentation/migration-guides/migration-2025.11.0.rst > > Sorry, I should have been clearer; I am a bit wary of breaking scripts > or board code that do SION shenanigans, so my suggestion to add a note. > > Something like: > > 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. > That makes a lot more sense, I'll send a V2 also fixing the commit on [1/2] this evening. Kind regards, Maud ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-17 9:17 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-10-15 18:03 [PATCH 0/2] gpio: i.MX: make _get_value() able to read output pin state Maud Spierings via B4 Relay 2025-10-15 18:03 ` [PATCH 1/2] " Maud Spierings via B4 Relay 2025-10-16 12:53 ` Ahmad Fatoum 2025-10-15 18:03 ` [PATCH 2/2] Documentation: migration-2025.11.0: add new empty file Maud Spierings via B4 Relay 2025-10-16 12:58 ` Ahmad Fatoum 2025-10-17 9:15 ` Maud Spierings
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox