Freescale-iMX6 Development Board-GPIO Read and Write Configuration Document_V1.0《1》[Copy link]
This document mainly introduces the read and write configuration of the gpio pins of the iMX6 board. For information about device registration in platform files, please refer to
Refer to the "iTOP-iMX6-Platform File Register Device" document. The registered device name is "gpio_ctl".
The "arch/arm/plat-mxc/include/mach/iomux-mx6q.h" file is all the IOs of IMX6 and its
The definition set of all functions of each IO. Users can query the definition of a certain IO function through this file.
The "arch/arm/mach-mx6/board-mx6q_topeet.h" file is used to define the initialization of IMX6 corresponding to the needs
The function of the IO port used. Initialize the gpio in this file.
The "arch/arm/mach-mx6/board-mx6q_topeet.c" file is the board-level initialization file of IMX6.
This file can set the gpio pins.
1.2 Hardware Introduction
1.2.1 Bottom plate
Check the iMX6 baseboard schematics v_2.2. We take the following 5 pins as an example and perform the following operations.
The picture below is the schematic diagram of the baseboard of version v_2.1.
Search for each network label "EIM_D17", "EIM_D18", "EIM_D20",
"KEY_ROW5", "EIM_D19". You can see that they are all connected to the board-to-board connector. That is, they are all connected to the core
Next, look at the core board schematic.
1.2.2 Core board part
Search the network number above to see where it is connected to the core board, as shown below.
As can be seen from the figure above, the five pins are connected to the core's "EIM_D17", "EIM_D18", "EIM_D20",
"GPIO_1", "EIM_D19" pins. Next, in "arch/arm/plat-mxc/include/mach/iomux-
mx6q.h" to view the function definition of each IO port.
1.3 Software Configuration
1.3.1 iomux-mx6q.h file
The main function of the iomux-mx6q.h file is to query the definition of a certain IO function.
Enter the iMX6 kernel source directory and use "vi arch/arm/plat-mxc/include/mach/iomux-
mx6q.h" command to open the iomux-mx6q.h file. As shown below.
Search for the five pin names seen above.
Take pin 1 as an example. Use "/EIM_D17" to search for the following information. See the figure below.
From the above figure, we can see that the expansion bus "EIM_D17" is defined as 8 functions.
Note that no matter initialization or definition of functions, there should be no conflicts to avoid the functions you are using being occupied by other functions.
When EIM_D17 is configured as a GPIO function, the definition used is: _MX6Q_PAD_EIM_D17__GPIO_3_17.
The IOMUX_PAD macro has 6 parameters, each of which means:
The definitions of pins 2, 3, and 12 are similar to those of pin 1. I will not go into detail here. Search for the definition of pin 10.
"/GPIO_1" command, and the following information is displayed. (Note that GPIO is the GPIO after MX6Q_PAD)
As can be seen from the figure above, the definition used when GPIO_1 is configured as a GPIO function is:
_MX6Q_PAD_GPIO_1__GPIO_1_1.
Now we can temporarily summarize the information we have obtained. As shown in the figure below.
1.3.2 board-mx6q_topeet.h file
The board-mx6q_topeet.h file is used to define the functions of the IO ports that need to be used to initialize IMX6.
In the board-mx6q_topeet.h file, search for the used IO to see if it is not defined as other functions. If so,
You need to comment it out and then add your own initialization definition.
Enter the command "vi arch/arm/mach-mx6/board-mx6q_topeet.h" in the kernel source directory to open
board-mx6q_topeet.h file. As shown below.
Let’s take the configuration of EIM_D17 as an example. Use “/MX6Q_PAD_EIM_D17” to search for the initialization signal.
Check the information and find that the function has been initialized. Comment out the initialization, as shown in the figure below.
Searching again did not find other related definitions. Other pins are similar. Make sure they are not defined by other functions.
(Definition in the iomux-mx6q.h file). There is one more place that needs to be commented out, as shown below.
Now add initialization to the above pins. See the figure below.
Note that it is added to mx6q_topeet_pads[].
1.3.3 board-mx6q_topeet.c file
The board-mx6q_topeet.c file can set the gpio pins.
In the board-mx6q_topeet.c file, the gpio pins we are going to use may be occupied by other functions.
We are asked to comment out other functions or set them to NULL.
In the iMX6 kernel source directory, use the command "vi arch/arm/mach-mx6/board-mx6q_topeet.c"
Open the board-mx6q_topeet.c file, as shown below.
Use the command "/IMX_GPIO_NR(3, 17)" to find the configuration corresponding to EIM_D17. (Note that 17 and the previous
There is a space between the commas in the text box, otherwise it will not be searched). Change the searched configuration to NULL. As shown below.
The other pins are similar. All modifications are as shown below.
At this point, our configuration is complete. Note: There are two IMX_GPIO_NR(1, 1).
Compile the kernel according to the kernel compilation steps in the "iTOP-i.MX6 Development Board Full Version User Manual".
Burn it to the development board and proceed to the next step of testing.
This content is originally created by EEWORLD forum user Shawu's joke . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source