i.MX6: Using GPIO1_IO19

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

i.MX6: Using GPIO1_IO19

跳至解决方案
3,159 次查看
lynix
Contributor II

My intent is to configure the WDOG1 pin on the i.MX6 as GPIO output (to trigger a custom power-off circuit). The i.MX6 Reference Manual states that this is achievable by setting the Pad Mux Register (IOMUXC_SW_MUX_CTL_PAD_SD1_DATA2) MUX_MODE to ALT5, which selects the signal GPIO1_IO19.

In order to implement this, I have added the following lines to the iomuxc-block in the Linux Kernel device tree:

gpio19 {

    pinctrl_gpio19_1: gpio19grp-1 {

        fsl,pins = <

            MX6QDL_PAD_SD1_DAT2__GPIO1_IO19 0x80000000

        >;

    }; 

};

From userspace I am now able to configure and use the GPIO like this:

$ echo 19 > /sys/class/gpio/export

$ echo out > /sys/class/gpio/gpio19/direction

$ echo 1 > /sys/class/gpio/gpio19/active_low

$ echo 1 > /sys/class/gpio/gpio19/value

(unfortunately I don't have a scope so I can't verify that the output value actually changes)

My question now is how to do this initialization in the device tree, so that I have the GPIO properly set up on system boot without using userland scripts?

My understanding is that I'd have to create a "gpio19" device in the tree that makes use of the pinctrl block I have defined, but I don't know how to declare such a device. This document describes properties for such a device that I don't know which values I'd have to assign to, e.g. the interrupt number.

I'm using a TQMa6S board with the latest BSP 0105.

Thanks in advance for any feedback! :smileyhappy:

标签 (2)
标记 (3)
0 项奖励
回复
1 解答
2,205 次查看
frankba
Contributor III

Hi Alexander,

not sure if I got your question right. A common trick is to use the GPIO as a LED. In the device tree, insert a block like:

/ {

...

    leds {

        compatible = "gpio-leds";

        my_led {

            gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;

        };
    };
...

which will automatically create a LED that can be switched on and off:

echo 1 >  /sys/class/leds/my_led/brightness

echo 0 >  /sys/class/leds/my_led/brightness

Frank

在原帖中查看解决方案

0 项奖励
回复
5 回复数
2,204 次查看
BiyongSUN
NXP Employee
NXP Employee

Please check the base and lable to indetify the number of gpio in linux.

GPIO1_19 should be the GPIO1 base + 19.

for example:

root@imx6qdlsolo:~# cat /sys/class/gpio/gpiochip32/base

32

root@imx6qdlsolo:~# cat /sys/class/gpio/gpiochip32/label

20a0000.gpio

0 项奖励
回复
2,205 次查看
lynix
Contributor II

Thank you for the hint; I was naive and assumed it to be 19.

Check according your hint confirmed that:

  root@MBa6x:~ cat /sys/class/gpio/gpiochip0/base

0

(There is no /sys/class/gpio/gpiochip1, I think they are just indexed by 0)

0 项奖励
回复
2,205 次查看
BiyongSUN
NXP Employee
NXP Employee

what is the lable?

It is the value to indentify the gpio, which is in the device tree.

In that way, you can figure out which is the base for.

0 项奖励
回复
2,206 次查看
frankba
Contributor III

Hi Alexander,

not sure if I got your question right. A common trick is to use the GPIO as a LED. In the device tree, insert a block like:

/ {

...

    leds {

        compatible = "gpio-leds";

        my_led {

            gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;

        };
    };
...

which will automatically create a LED that can be switched on and off:

echo 1 >  /sys/class/leds/my_led/brightness

echo 0 >  /sys/class/leds/my_led/brightness

Frank

0 项奖励
回复
2,205 次查看
lynix
Contributor II

Exactly what I was looking for, thanks! :smileyhappy:

0 项奖励
回复