[PATCH] mxc_gpio: on imx8m read the DR instead of the PSR

Angus Ainslie angus at akkea.ca
Sun Nov 28 15:51:43 CET 2021


On imx8m it is more correct to read the data register than the pad status
register.

In output mode the pad status register does not contain the value being
output so we must read the DR for the value.

In input mode the DR will contain the same value as the PSR when the pad
mode is GPIO.

If the pad mode is not GPIO and the pin is an input then 0 is always
returned.

Signed-off-by: Angus Ainslie <angus at akkea.ca>
---
 drivers/gpio/mxc_gpio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 03471db9e80..0d9f6f44042 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -211,6 +211,9 @@ static void mxc_gpio_bank_set_value(struct gpio_regs *regs, int offset,
 
 static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset)
 {
+if (IS_ENABLED(CONFIG_IMX8M))
+	return (readl(&regs->gpio_dr) >> offset) & 0x01;
+else
 	return (readl(&regs->gpio_psr) >> offset) & 0x01;
 }
 
-- 
2.25.1



More information about the U-Boot mailing list