[PATCH] gpio: mxc_gpio: fix reading state of GPIO pins in output mode

Fabio Estevam festevam at gmail.com
Tue Aug 27 21:53:46 CEST 2024


Hi Tomas,

On Tue, Aug 27, 2024 at 4:41 PM Tomas Paukrt <tomaspaukrt at email.cz> wrote:

> 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.

This happens due to an incorrect devicetree description, i.e, the lack
of setting the SION bit.

> 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.

Adding Ye Li on Cc.

There were many attempts to fix this in both U-Boot and the kernel,
but the recommendation has always been: "Set the SION bit if you need
to read the output state".

Regards,

Fabio Estevam


More information about the U-Boot mailing list