Why won't my GPIO read anything other than 0?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Why won't my GPIO read anything other than 0?

跳至解决方案
1,560 次查看
joshbarnheiser
Contributor I

Hi,

I have a custom iMX6 board with multiple GPIO pins on it being used. All of the GPIOs that I am using as outputs work and all but one of my inputs work. The input that is not working has the same voltage divider and filtering capacitors as the other inputs, so the circuitry is the same. For some reason GPIO7_IO01 always reads 0 regardless of whether the input pin is at 0V or 3.3V. I use the below commands to read the input:

echo 193 >> /sys/class/gpio/export

echo in >> /sys/class/gpio/gpio193/direction

cat /sys/class/gpio/gpio193/value

In my device tree, I have tried with the pin not specified as anything and throwing in pinctrl_hog set as below:

 MX6QDL_PAD_SD3_DAT4__GPIO7_IO01            0x0001B0B0

In both cases, 0 is always read. The SD3 pins are not being used for an SDIO interface. I am using four of the SD3 pins for my two CAN interfaces (CMD, CLK, DAT0 and DAT1). Some of the other pins are being used for GPIO (DAT6, DAT7 and RST) and they work. The other GPIO are not specified in the device tree.

I am really at a loss for this one, any ideas?

Thanks,

Josh

标签 (2)
标记 (1)
0 项奖励
回复
1 解答
1,331 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Josh

one can check if that pad was used in uboot. Seems most

simple way to attach jtag debugger (or add printfs) and look at

GPIO registers described in Chapter 28 General Purpose Input/Output (GPIO)

i.MX6DQ Reference Manual
https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,332 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Josh

one can check if that pad was used in uboot. Seems most

simple way to attach jtag debugger (or add printfs) and look at

GPIO registers described in Chapter 28 General Purpose Input/Output (GPIO)

i.MX6DQ Reference Manual
https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,331 次查看
joshbarnheiser
Contributor I

Thanks Igor,

You were correct, uboot was setting it as an SDIO pin, which affected it in some way. I removed that part from my uboot and it reads correctly now. 

As a more detailed explaination of what I had to do, in the .c file for my board I commented out the lines setting the gpio pins as SDIO and one other line setting another SD3 pin to an output. They are the below lines.

/*MX6_PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_NANDF_D0__GPIO2_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL),*/ /* CD */

.....

//gpio_direction_input(USDHC3_CD_GPIO);

I'm not using SD3 on my board so this worked for me.

Josh

0 项奖励
回复
1,331 次查看
fabio_estevam
NXP Employee
NXP Employee

Hi Josh,

In order to set SION bit in your device tree:

 MX6QDL_PAD_SD3_DAT4__GPIO7_IO01            0x4001B0B0

(Need to set bit 30)

Hope this helps.

0 项奖励
回复