转载地址:http://blog.chinaunix.net/uid-22670933-id-5761825.html
内核版本:linux-3.14.38
以GPIO1_IO13为例:
1. 在arch/arm/boot/dts/imx6ul-14x14-evk.dts中:
pinctrl_hog_1: hoggrp-1 {
fsl,pins = <
MX6UL_PAD_LCD_RESET__WDOG1_WDOG_ANY 0x30b0
MX6UL_PAD_UART1_RTS_B__GPIO1_IO19 0x17059
MX6UL_PAD_GPIO1_IO05__USDHC1_VSELECT 0x17059
MX6UL_PAD_GPIO1_IO09__GPIO1_IO09 0x17059
MX6UL_PAD_JTAG_TDI__GPIO1_IO13 0xC0000000
>;
};
MX6UL_PAD_JTAG_TDI__GPIO1_IO13:宏定义引脚JTAG_TDI功能复用为GPIO13;
0xC0000000:
- 0x80000000 is special and means "I don't know and don't change from the default"
- Bit 30 set to 1 means: software input on (SION) whcih means that the logical value of an output can be read back
2. 在用户空间可控制gpio13:
echo 13 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio2/direction
echo 1 > /sys/class/gpio/gpio2/value
echo 0 > /sys/class/gpio/gpio2/value
参考链接:
https://github.com/FrankBau/meta-marsboard-bsp/wiki/iMX6-Pad-Mux-and-Pad-Control
http://cache.freescale.com/files/32bit/doc/app_note/AN5078.pdf
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/295260
http://www.kosagi.com/w/index.php?title=Definitive_GPIO_guide#Linux_Device_Tree_Naming_Convention