EasyManua.ls Logo

Phytec i.MX 93 - Gpios

Default Icon
85 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
i.MX 93 BSP Manual PD24.1.1 Documentation Rev.: imx8mp-pd22.1.2-51-ga548be7d
7.5 GPIOs
The phyBOARD-Segin/Nash i.MX 93 doesn’t have a set of pins especially dedicated for user I/Os since all
GPIOs are used by kernel device drivers or used for a specic purpose. The processor has organized its
GPIOs into ve banks of 32 GPIOs each (GPIO1 GPIO4) GPIOs. gpiochip0, gpiochip32, gpiochip64 and
gpiochip96 are the sysfs representation of these internal i.MX 93 GPIO banks GPIO1 GPIO4.
The GPIOs are identied as GPIO<X>_<Y> (e.g. GPIO4_07). <X> identies the GPIO bank and
counts from 1 to 4, while <Y> stands for the GPIO within the bank. <Y> is being counted from 0 to 31
(32 GPIOs on each bank).
By contrast, the Linux kernel uses a single integer to enumerate all available GPIOs in the system. The
formula to calculate the right number is:
Linux GPIO number: <N> = (<X> - 1) * 32 + <Y>
Accessing GPIOs from userspace will be done using the libgpiod. It provides a library and tools for interacting
with the Linux GPIO character device. Examples of some usages of various tools:
Detecting the gpiochips on the chip:
target:~$ gpiodetect
gpiochip0 [43810080.gpio] (32 lines)
gpiochip1 [43820080.gpio] (32 lines)
gpiochip2 [43830080.gpio] (32 lines)
gpiochip3 [47400080.gpio] (32 lines)
Note
Order of GPIOchips in i.MX 93 Application Processor Reference Manual and in Linux kernel dier!
GPIOchip address Linux Reference Manual
0x43810080 gpiochip0 gpiochip2
0x43820080 gpiochip1 gpiochip3
0x43830080 gpiochip2 gpiochip4
0x47400080 gpiochip3 gpiochip1
Show detailed information about the gpiochips. Like their names, consumers, direction, active state,
and additional ags:
target:~$ gpioinfo gpiochip0
Read the value of a GPIO (e.g GPIO 3 from chip0):
target:~$ gpioget gpiochip0 3
Set the value of GPIO 3 on chip0 to 0 and exit tool:
target:~$ gpioset --mode=exit gpiochip0 3=0
Help text of gpioset shows possible options:
target:~$ gpioset --help
Usage: gpioset [OPTIONS] <chip name/number> <offset1>=<value1> <offset2>=<value2> ...
(continues on next page)
Accessing Peripherals 57