Changes

Jump to: navigation, search

DESK-MX6UL-L/Peripherals/GPIOs

5,732 bytes added, 10:13, 21 April 2021
Created page with "<section begin=History/> {| style="border-collapse:collapse; " !colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History |- !style="border-le..."
<section begin=History/>
{| style="border-collapse:collapse; "
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
|-
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Version
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|1.0.0
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Apr 2021
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|First DESK release

|}
<section end=History/>
<section begin=Body/>

==Peripheral GPIOs ==

i.MX6UL can handle external pins in many different ways and most of them can be configured as GPIOs. When a pin is set as a GPIO, it is possible
to read its value, change its direction or change output value directly from the shell.

=== Device tree configuration ===
Here below an example of device tree configuration for using the RS-485 GPIOs used on standard DAVE's kit for the [[AXEL ULite SOM]]:

From <code>imx6ul-lynx-som0013.dtsi</code>:

<pre>
/* configure uart8/ttymxc7 as rs232 */
uart8_rs232_config: uart8_rs232 {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart8_config>;

status = "disabled";

gpio113 {
gpios = <&gpio4 17 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
gpio136 {
gpios = <&gpio5 8 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
gpio137 {
gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
};
};

&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog_gpios>;

imx6ul-lynx {

...
...
pinctrl_uart8_config: uart8grp-config {
fsl,pins = <
MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08 0x80000000 /* MPUART0_DEN */
MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09 0x80000000 /* MPUART0_RXEN */
MX6UL_PAD_CSI_MCLK__GPIO4_IO17 0x80000000 /* MPUART0_ON */
>;
};

</pre>

===Accessing the peripheral===
====Linux messages at boot time====

With the previous <code>leds</code> configuration for the GPIOs, it is possible to find them on <code>sysfs</code> under ''/sys/class/leds'' sub-directory:

<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# ls -la /sys/class/leds/
total 0
drwxr-xr-x 2 root root 0 Apr 21 09:37 .
drwxr-xr-x 50 root root 0 Apr 21 09:37 ..
lrwxrwxrwx 1 root root 0 Apr 21 09:37 gpio113 -> ../../devices/soc0/uart8_rs232/leds/gpio113
lrwxrwxrwx 1 root root 0 Apr 21 09:37 gpio114 -> ../../devices/soc0/uart3_rs485/leds/gpio114
lrwxrwxrwx 1 root root 0 Apr 21 09:37 gpio136 -> ../../devices/soc0/uart8_rs232/leds/gpio136
lrwxrwxrwx 1 root root 0 Apr 21 09:37 gpio137 -> ../../devices/soc0/uart8_rs232/leds/gpio137
lrwxrwxrwx 1 root root 0 Apr 21 09:37 mmc0:: -> ../../devices/soc0/soc/2100000.aips-bus/2190000.usdhc/leds/mmc0::
lrwxrwxrwx 1 root root 0 Apr 21 09:37 mmc1:: -> ../../devices/soc0/soc/2100000.aips-bus/2194000.usdhc/leds/mmc1::
root@desk-mx6ul-axelulite:~#
</pre>

==== Usage with [https://www.kernel.org/doc/Documentation/gpio/sysfs.txt sysfs] ====

* set GPIO1_IO01 (MX6UL_PAD_GPIO1_IO01__GPIO1_IO01) as output GPIO
** GPIO1_IO01 => (n-1)*32 + IO = (1-1)*32+1 = 1

<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# echo 1 > /sys/class/gpio/export
root@desk-mx6ul-axelulite:~# echo out > /sys/class/gpio/gpio1/direction
root@desk-mx6ul-axelulite:~# echo 1 > /sys/class/gpio/gpio1/value
root@desk-mx6ul-axelulite:~#
</pre>

* set GPIO1_IO02 (echo 1 > /sys/class/gpio/gpio1/value) as input GPIO
** GPIO1_IO02 => (n-1)*32 + IO = (1-1)*32+1 = 2

<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# echo 2 > /sys/class/gpio/export
root@desk-mx6ul-axelulite:~# echo in > /sys/class/gpio/gpio2/direction
root@desk-mx6ul-axelulite:~# cat /sys/class/gpio/gpio2/value
1
root@desk-mx6ul-axelulite:~#
</pre>

=== Additional information ===
Information about GPIOs usage under sysfs directory ''https://www.kernel.org/doc/Documentation/gpio/sysfs.txt''

{{WarningMessage|text=''sysfs'' GPIO ABI has been deprecated. See more inofrmation [https://www.kernel.org/doc/Documentation/gpio/sysfs.rst here] about it. A character device access has to be used, more information [https://embeddedbits.org/new-linux-kernel-gpio-user-space-interface/ here]}}

Information about GPIOs library '''libgpiod''' - C library and tools - can be found on [https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ git.kernel.org]

<section end=Body/>

----

[[Category:AXEL ULite]]
8,226
edits

Navigation menu