Re: [PATCH] gpio: mxc_gpio: fix reading state of GPIO pins in output mode
Tomas Paukrt
tomaspaukrt at email.cz
Tue Aug 27 21:41:29 CEST 2024
>> The PSR register works correctly for GPIO pins in input mode,
>> but always returns 0 for GPIO pins in output mode.
>> The DR register works correctly in both modes.
>
> The current code is correct as is.
> You should set the SION bit to read the value of the output pin.
Hi Fabio,
you are correct that the existing code will work if the SION bit is set, but this is not always possible or desirable. For example, if you use the command "gpio set" to set the state of a pin that is not configured in DTS then you will get the error message "Warning: value of pin is still 0". Also the command "gpio status -a" shows wrong states of some output pins without this patch.
Please see the chapters "GPIO data register (GPIOx_DR)" and "GPIO pad status register (GPIOx_PSR)" in the document IMX6ULLRM.pdf which show that it is possible to use the DR register instead of the PSR register in this case.
I also found the exactly same modification in NXP version of U-Boot (https://github.com/nxp-imx/uboot-imx/commit/4afc3f90943c6b117f79b66d2cd04e64f437b0c2) made by an NXP employee.
Best regards
Tomas
More information about the U-Boot
mailing list