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.
This commit is contained in:
Ian Lepore 2017-06-28 20:28:47 +00:00
parent e5426b9f65
commit c592231080

View File

@ -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);
}