ARM knowledge sharing, i.MX6Q GPIO multiplexing modification method
platform: OKMX6Q-S2
System: Linux
Core version: Linux-3.0.35
I.MX6Q GPIO multiplexing modification method, the verification platform is the Forlinx embedded OKMX6Q-S2 development board, based on the ARM Corte-A9 architecture, i.MX6Q quad-core processor, and other platforms can be used as a reference. This modification releases part of the pins occupied by the original SD card function and reuses them as GPIO. For the specific GPIO number, please refer to Chapter 4 of the i.MX6 CPU manual (IMX6DQRM.pdf), Chapter 4 External Signals and Pin Multiplexing.
i.MX6 CPU manual path: Forlinx Embedded OKMX6Q-S2,OKMX6DL-S2 User Information (A)/Hardware/Datasheet/i.MX6/IMX6DQRM.pdf
1. Modification process
Modify the file arch/arm/mach-mx6/board-mx6q_sabresd.h and add the following definitions in it:
/*GPIO*/
MX6Q_PAD_SD3_CLK__GPIO_7_3,
MX6Q_PAD_SD3_CMD__GPIO_7_2,
MX6Q_PAD_SD3_DAT2__GPIO_7_6,
MX6Q_PAD_SD3_DAT3__GPIO_7_7,
MX6Q_PAD_SD3_DAT4__GPIO_7_1,
MX6Q_PAD_SD3_DAT5__GPIO_7_0,
MX6Q_PAD_SD3_DAT6__GPIO_6_18,
MX6Q_PAD_SD3_DAT7__GPIO_6_17,
MX6Q_PAD_NANDF_D1__GPIO_2_1,
MX6Q_PAD_NANDF_D0__GPIO_2_0,
Comment out the original SD card function
/* USDHC3 */
/* MX6Q_PAD_SD3_CLK__USDHC3_CLK_50MHZ,
MX6Q_PAD_SD3_CMD__USDHC3_CMD_50MHZ,
MX6Q_PAD_SD3_DAT0__USDHC3_DAT0_50MHZ,
MX6Q_PAD_SD3_DAT1__USDHC3_DAT1_50MHZ,
MX6Q_PAD_SD3_DAT2__USDHC3_DAT2_50MHZ,
MX6Q_PAD_SD3_DAT3__USDHC3_DAT3_50MHZ,
MX6Q_PAD_SD3_DAT4__USDHC3_DAT4_50MHZ,
MX6Q_PAD_SD3_DAT5__USDHC3_DAT5_50MHZ,
MX6Q_PAD_SD3_DAT6__USDHC3_DAT6_50MHZ,
MX6Q_PAD_SD3_DAT7__USDHC3_DAT7_50MHZ,
MX6Q_PAD_NANDF_D0__GPIO_2_0,
MX6Q_PAD_NANDF_D1__GPIO_2_1, */
Note: The Linux-3.0.35version of the kernel defines the pin function in the arch/arm/plat-mxc/include/mach/iomux-mx6q.h file, which defines all the multiplexing functions of each pin, and you can take a look if you are interested.
2. Test
GPIO
Ball number definition GPIO
89 MX6Q_PAD_SD3_CLK__GPIO_7_3 195
91 MX6Q_PAD_SD3_CMD__GPIO_7_2 194
94 MX6Q_PAD_SD3_DAT2__GPIO_7_6 198
93 MX6Q_PAD_SD3_DAT3__GPIO_7_7 199
92 MX6Q_PAD_SD3_DAT4__GPIO_7_1 193
90 MX6Q_PAD_SD3_DAT5__GPIO_7_0 192
88 MX6Q_PAD_SD3_DAT6__GPIO_6_18 178
87 MX6Q_PAD_SD3_DAT7__GPIO_6_17 177
83 MX6Q_PAD_NANDF_D1__GPIO_2_1 33
84 MX6Q_PAD_NANDF_D0__GPIO_2_0 32
GPIO_M_N GPIOX,GPIOX=(M-1)*32+N,For example GPIO_4_28=(4-1)*32+28=124
Test command
echo 33 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio33/direction
echo 1 > /sys/class/gpio/gpio33/value
cat /sys/class/gpio/gpio33/value