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:
已解决! 转到解答。
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
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
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)
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