i.MX6: Using GPIO1_IO19

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

i.MX6: Using GPIO1_IO19

ソリューションへジャンプ
4,303件の閲覧回数
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 解決策
3,349件の閲覧回数
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 返答(返信)
3,348件の閲覧回数
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 件の賞賛
返信
3,349件の閲覧回数
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 件の賞賛
返信
3,349件の閲覧回数
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 件の賞賛
返信
3,350件の閲覧回数
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 件の賞賛
返信
3,349件の閲覧回数
lynix
Contributor II

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

0 件の賞賛
返信