From c59223108014093a38206f52937e468bf6dca778 Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Wed, 28 Jun 2017 20:28:47 +0000 Subject: [PATCH] Implement gpio input by reading the pad state register, not the data register. When a pin is set for input the value in the DR will be the same as the PSR. When a pin is set for output the value in the DR is the value output to the pad, and the value in the PSR is the actual electrical level sensed on the pad, and they can be different if the pad is configured for open-drain mode and some other entity on the board is driving the line low. --- sys/arm/freescale/imx/imx_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/freescale/imx/imx_gpio.c b/sys/arm/freescale/imx/imx_gpio.c index f7b417252dc8..fe4955c856b7 100644 --- a/sys/arm/freescale/imx/imx_gpio.c +++ b/sys/arm/freescale/imx/imx_gpio.c @@ -644,7 +644,7 @@ imx51_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val) if (pin >= sc->gpio_npins) return (EINVAL); - *val = (READ4(sc, IMX_GPIO_DR_REG) >> pin) & 1; + *val = (READ4(sc, IMX_GPIO_PSR_REG) >> pin) & 1; return (0); }