Skip to content

Commit 1eb41f7

Browse files
FournierMxjonaswood01
authored andcommitted
docs(GPIO): Updated Kernel driver doc with examples
Replaced Debian links with lgpiod links and cleaned a lengthy URL. Signed-off-by: Jonas Wood <[email protected]>
1 parent 09fa28c commit 1eb41f7

File tree

6 files changed

+177
-25
lines changed

6 files changed

+177
-25
lines changed

source/android/Foundational_Components_Bootloaders.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Fetch the code using ``repo``:
3131
.. code-block:: console
3232
3333
$ mkdir ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
34-
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Bootloader.xml
34+
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_01_Bootloader.xml
3535
$ repo sync
3636
3737
For more information about ``repo``, visit `Android's official

source/android/Foundational_Components_Kernel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Fetch the code using ``repo``:
2323
.. code-block:: console
2424
2525
$ mkdir ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
26-
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml
26+
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_01_Kernel.xml
2727
$ repo sync
2828
2929
.. tip::
@@ -32,7 +32,7 @@ Fetch the code using ``repo``:
3232

3333
.. code-block:: console
3434
35-
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml --depth=1
35+
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_01_Kernel.xml --depth=1
3636
3737
.. _android-build-kernel:
3838

source/android/Overview_Building_the_SDK.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Fetch the code using ``repo``:
4040
.. code-block:: console
4141
4242
$ mkdir ${YOUR_PATH}/ti-aosp-15 && cd $_
43-
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01.xml
43+
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_01.xml
4444
$ repo sync
4545
4646
.. tip::
1.2 MB
Loading

source/images/sk-am62b-p1-top.png

1.2 MB
Loading

source/linux/Foundational_Components/Kernel/Kernel_Drivers/GPIO.rst

Lines changed: 173 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
.. http://processors.wiki.ti.com/index.php/Processor_SDK_Linux_GPIO_Driver_Overview
2-
31
.. please note that there is no GPIO user guide from LCPD
42
3+
----
54
GPIO
6-
---------------------------------
5+
----
76

87
.. rubric:: GPIO Driver Overview
98
:name: gpio-driver-overview
@@ -48,33 +47,186 @@ and interrupt generation.
4847
.. rubric:: User Layer
4948
:name: user-layer
5049

51-
The GPIO driver can be used via user space or by
52-
other drivers that may need to access pins as either input/outputs or
53-
interrupts. More information about this driver and GPIO usage in Linux
54-
can be found in the kernel documentation:
55-
56-
- GPIO Interface:
57-
Under Kernel directory Documentation/gpio/gpio.txt
58-
- GPIO Driver:
59-
Under Kernel directory Documentation/gpio/driver.txt
60-
50+
The GPIO driver can be used in user space via Linux CLI. This section provides examples, command-line-tools, and guidance for using GPIOs in user space.
6151

6252
.. note ::
63-
Since linux 4.8 the GPIO sysfs interface is deprecated. User space should use
53+
Since linux 4.8, the GPIO sysfs interface is deprecated. User space should use
6454
the character device instead.
6555
56+
# Example: Using GPIOs with the *libgpiod* library in user space to toggle a GPIO pin, which is connected to an LED on the SK-AM62B-P1 board:
57+
58+
#. Locate *Table 2-23* under **2.6.16.3 User Test LEDs** in the *AM62x Starter Kit User's Guide (Rev. C)*: https://www.ti.com/lit/pdf/spruj40.
59+
60+
- This example uses LED "LD11", AKA the **IO_EXP_TEST_LED**. It is connected to GPIO *U70.24(P27)*, AKA pin 27 of the *GPIO Port Expander* on the SK-AM62B-P1 board:
61+
62+
.. Image:: /images/sk-am62b-p1-top.png
63+
64+
#. Detect every available **gpiochip**:
65+
66+
.. code-block:: console
67+
68+
$ gpiodetect
69+
gpiochip0 [600000.gpio] (92 lines)
70+
gpiochip1 [601000.gpio] (52 lines)
71+
gpiochip2 [1-0022] (24 lines)
72+
73+
- This shows 92+52+24=168 total GPIO lines available across 3 GPIO chips: 0, 1, and 2.
74+
75+
#. Read info for every available **gpiochip**:
76+
77+
.. code-block:: console
78+
79+
$ gpioinfo
80+
gpiochip0 - 92 lines:
81+
line 0: unnamed input
82+
line 1: unnamed input
83+
{...}
84+
line 91: unnamed input
85+
gpiochip1 - 52 lines:
86+
line 0: unnamed input
87+
line 1: unnamed input
88+
{...}
89+
line 51: unnamed input
90+
gpiochip2 - 24 lines:
91+
line 0: "GPIO_CPSW2_RST" input
92+
line 1: "GPIO_CPSW1_RST" input
93+
{...}
94+
line 23: "IO_EXP_TEST_LED" input
95+
96+
- This should result in a large output, 168+ lines in this case. It outputs all GPIO lines available on every GPIO chip, as well as their names and input/output directions. The above output is truncated.
97+
98+
- For more info on *gpioinfo*, see its man page: https://libgpiod.readthedocs.io/en/latest/gpioinfo.html.
99+
100+
- To see info for a specific GPIO chip, use the '-c' option and the GPIO chip number.
101+
102+
#. Read info for **gpiochip2** (for this example):
103+
104+
.. code-block:: console
105+
106+
$ gpioinfo -c 2
107+
gpiochip2 - 24 lines:
108+
line 0: "GPIO_CPSW2_RST" input
109+
line 1: "GPIO_CPSW1_RST" input
110+
line 2: "PRU_DETECT" input
111+
line 3: "MMC1_SD_EN" output consumer="regulator-3"
112+
line 4: "VPP_LDO_EN" input
113+
line 5: "EXP_PS_3V3_En" input
114+
line 6: "EXP_PS_5V0_En" input
115+
line 7: "EXP_HAT_DETECT" input
116+
line 8: "GPIO_AUD_RSTn" input
117+
line 9: "GPIO_eMMC_RSTn" input
118+
line 10: "UART1_FET_BUF_EN" input
119+
line 11: "WL_LT_EN" input
120+
line 12: "GPIO_HDMI_RSTn" input
121+
line 13: "CSI_GPIO1" input
122+
line 14: "CSI_GPIO2" input
123+
line 15: "PRU_3V3_EN" input
124+
line 16: "HDMI_INTn" input consumer="interrupt"
125+
line 17: "PD_I2C_IRQ" input
126+
line 18: "MCASP1_FET_EN" input
127+
line 19: "MCASP1_BUF_BT_EN" input
128+
line 20: "MCASP1_FET_SEL" input
129+
line 21: "UART1_FET_SEL" input
130+
line 22: "TSINT#" input
131+
line 23: "IO_EXP_TEST_LED" output
132+
133+
- We see that **IO_EXP_TEST_LED** is connected to *GPIO2_23* on the SK-AM62B-P1 board.
134+
135+
#. Read the value of the GPIO pin:
136+
137+
.. code-block:: console
138+
139+
$ gpioget --numeric -c 2 23
140+
0
141+
142+
- Use variations of *gpioget* to read the value of the GPIO pin:
143+
144+
.. code-block:: console
145+
146+
$ gpioget -c 2 23
147+
"23"=inactive
148+
$ gpioget IO_EXP_TEST_LED
149+
"IO_EXP_TEST_LED"=inactive
150+
$ gpioget --numeric IO_EXP_TEST_LED
151+
0
152+
153+
- For more info on *gpioget*, see its man page: https://libgpiod.readthedocs.io/en/latest/gpioget.html.
154+
155+
#. Set the GPIO pin to turn on the LED
156+
157+
.. code-block:: console
158+
159+
$ gpioset -c 2 23=1
160+
^C
161+
$ gpioset -c 2 23=0
162+
^C
163+
164+
- *Note: '^C' (Ctrl + C) interrupts the command, else the command would not terminate on its own. Use '^C' (Ctrl + C) to stop the command, and the new GPIO value will still remain.*
165+
166+
- This should have turned the active-high LED "LD11" on the SK-AM62B-P1 on and off.
167+
168+
- Use variations of *gpioset* to set the value of the GPIO pin:
169+
170+
.. code-block:: console
171+
172+
$ gpioset IO_EXP_TEST_LED=1
173+
^C
174+
$ gpioset IO_EXP_TEST_LED=0
175+
^C
176+
177+
- This should have also turned the active-high LED "LD11" on the SK-AM62B-P1 on and off.
178+
179+
- Example: Toggle *GPIO2_23* (blink "LD11") at 10Hz, then turn it off:
180+
181+
.. code-block:: console
182+
183+
$ gpioset --toggle 50ms IO_EXP_TEST_LED=1
184+
^C
185+
$ gpioset IO_EXP_TEST_LED=0
186+
^C
187+
188+
- For more info on *gpioset*, see its man page: https://libgpiod.readthedocs.io/en/latest/gpioset.html.
189+
190+
For more command-line tools, refer to the *libgpiod* documentation: https://libgpiod.readthedocs.io/en/latest/gpio_tools.html.
191+
192+
# Example: Using GPIOs on the Raspberry Pi Compatible 40-pin Header on the SK-AM62B-P1 board:
193+
194+
.. Image:: /images/sk-am62b-p1-top-2.png
195+
196+
#. Locate *Table 2-25* under **2.6.17.2 User Expansion Connector** in the *AM62x Starter Kit User's Guide (Rev. C)*: https://www.ti.com/lit/pdf/spruj40.
197+
198+
#. Identify the desired GPIO pin number and pin multiplexed signal. For example, *GPIO1_25* corresponds to physical pin 8 on the 40-pin header.
199+
200+
#. Use *libgpiod* mentioned in the previous example to control the GPIO pin, ensuring that the GPIO pin is not being used already.
201+
202+
# Additional Resources
203+
204+
- For more information about GPIO usage in Linux and U-Boot, refer to these resources:
205+
206+
- SDK:
207+
208+
- Kernel: ti-processor-sdk-linux-am62xx-evm-<sdk version>/board-support/ti-linux-kernel-<kernel version>+git-ti/Documentation/devicetree/bindings/gpio/gpio.txt
209+
- U-Boot: ti-processor-sdk-linux-am62xx-evm-<sdk version>/board-support/ti-u-boot-<u-boot version>+git/doc/device-tree-bindings/gpio/gpio.txt
210+
211+
- Online:
212+
213+
- Linux: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1494485/faq-processor-sdk-getting-started-with-gpios-in-linux-using-the-am62-and-am64-family-processors
214+
- U-Boot: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1398803/faq-processor-sdk-am62x-how-to-toggle-gpios-and-leds-from-u-boot-command-prompt
215+
- GPIO on Sitara: https://www.ti.com/lit/ab/spradk0/spradk0.pdf
216+
- https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1398198/faq-am62x-how-to-allocate-use-gpios-from-different-device-domains
217+
- https://support.criticallink.com/redmine/projects/mitysom_am62x/wiki/Example\_-_User_level_GPIO_Access
218+
- https://software-dl.ti.com/processor-sdk-linux/esd/AM64X/10_01_10_04/exports/docs/linux/How_to_Guides/FAQ/How_to_Check_Device_Tree_Info.html
219+
- https://docs.kernel.org/devicetree/usage-model.html
220+
- (*Note: AM62P-specific, but similar to AM62x*): https://software-dl.ti.com/processor-sdk-linux/esd/AM62PX/09_02_01_09/exports/docs/linux/Foundational_Components/Tools/GPIO_Tools.html
221+
66222
.. rubric:: Consuming Drivers
67223
:name: consuming-drivers
68224

69-
The GPIO Driver can also be easily leveraged by other drivers to
70-
"consume" a GPIO.
225+
The GPIO Driver can also be easily leveraged by other drivers to "consume" a GPIO.
71226

72-
- GPIO Consumer:
73-
Under Kernel directory Documentation/gpio/consumer.txt
227+
- For an example of a driver using a GPIO pin, examine this entry in a dts file for how the MMC/SD interface could use a GPIO as a card detect pin:
74228

75-
For an example of a driver using a GPIO pin, examine this entry in a dts
76-
file for how the MMC/SD interface could use a GPIO as a card detect pin
77-
Under Kernel directory arch/arm/boot/dts/am335x-bone-common.dtsi line 401
229+
- ti-processor-sdk-linux-am62xx-evm-<sdk version>/board-support/ti-linux-kernel-<kernel version>+git-ti/arch/arm/boot/dts/ti/omap/am335x-bone-common.dtsi.
78230

79231
|
80232

0 commit comments

Comments
 (0)