Difference between revisions of "DESK-MX6UL-L/Peripherals/GPIOs"

From DAVE Developer's Wiki
Jump to: navigation, search
(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...")
 
m (U0007 moved page DESK-MX6UL-L/Pheripherals/GPIOs to DESK-MX6UL-L/Peripherals/GPIOs without leaving a redirect)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<section begin=History/>
+
<section begin="History" />
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
+
! 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"|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:#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" |{{oldid|14249|2021/07/20}}
|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-MX6UL-L release
|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
+
|-
 
+
| 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" |{{oldid|16315|2022/03/16}}
 +
| 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" |DESK-MX6UL-L 3.0.0 release
 +
|-
 +
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |2023/05/04
 +
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX6UL-L 4.0.0 release
 
|}
 
|}
<section end=History/>
+
<section end="History" />
<section begin=Body/>
+
<section begin="Body" />
  
 
==Peripheral GPIOs ==
 
==Peripheral GPIOs ==
Line 19: Line 22:
 
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  
 
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.  
 
to read its value, change its direction or change output value directly from the shell.  
 +
 +
{{ImportantMessage|text=There aren't GIO already configured in the [[AXEL_ULite_SOM/AXEL_ULite_Evaluation_Kit | AXEL ULite EVK]].<br>Here below an example of GPIOs usage in the i.MX6UL standard product [[SBC_Lynx_SBC | SBCLynx]]}}
  
 
=== Device tree configuration ===
 
=== 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]]:
+
Here below an example of device tree configuration for using the RS-485 GPIOs used on standard DAVE's product [[SBC_Lynx_SBC | SBCLynx]]:
  
 
From <code>imx6ul-lynx-som0013.dtsi</code>:
 
From <code>imx6ul-lynx-som0013.dtsi</code>:
Line 73: Line 78:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# ls -la /sys/class/leds/
+
root@desk-mx6ul-lynx:~# ls -la /sys/class/leds/
 
total 0
 
total 0
drwxr-xr-x  2 root root 0 Apr 21 09:37 .
+
drwxr-xr-x  2 root root 0 Apr 3 15:19 .
drwxr-xr-x 50 root root 0 Apr 21 09:37 ..
+
drwxr-xr-x 54 root root 0 Apr 3 15:19 ..
lrwxrwxrwx  1 root root 0 Apr 21 09:37 gpio113 -> ../../devices/soc0/uart8_rs232/leds/gpio113
+
lrwxrwxrwx  1 root root 0 Apr 3 15:19 gpio113 -> ../../devices/platform/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 3 15:19 gpio114 -> ../../devices/platform/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 3 15:19 gpio136 -> ../../devices/platform/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 3 15:19 gpio137 -> ../../devices/platform/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 3 15:19 mmc0:: -> ../../devices/platform/soc/2100000.bus/2190000.mmc/leds/mmc0::
lrwxrwxrwx  1 root root 0 Apr 21 09:37 mmc1:: -> ../../devices/soc0/soc/2100000.aips-bus/2194000.usdhc/leds/mmc1::
+
lrwxrwxrwx  1 root root 0 Apr 3 15:19 mmc1:: -> ../../devices/platform/soc/2100000.bus/2194000.mmc/leds/mmc1::
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
Line 92: Line 96:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# echo 1 > /sys/class/gpio/export
+
root@desk-mx6ul-lynx:~# echo 1 > /sys/class/gpio/export
root@desk-mx6ul-axelulite:~# echo out > /sys/class/gpio/gpio1/direction
+
root@desk-mx6ul-lynx:~# echo out > /sys/class/gpio/gpio1/direction
root@desk-mx6ul-axelulite:~# echo 1 > /sys/class/gpio/gpio1/value
+
root@desk-mx6ul-lynx:~# echo 1 > /sys/class/gpio/gpio1/value
root@desk-mx6ul-axelulite:~#
+
root@desk-mx6ul-lynx:~#
 
</pre>
 
</pre>
  
Line 102: Line 106:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# echo 2 > /sys/class/gpio/export
+
root@desk-mx6ul-lynx:~# echo 2 > /sys/class/gpio/export
root@desk-mx6ul-axelulite:~# echo in > /sys/class/gpio/gpio2/direction
+
root@desk-mx6ul-lynx:~# echo in > /sys/class/gpio/gpio2/direction
root@desk-mx6ul-axelulite:~# cat /sys/class/gpio/gpio2/value
+
root@desk-mx6ul-lynx:~# cat /sys/class/gpio/gpio2/value
1
+
0
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
Line 116: Line 119:
 
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]  
 
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/>
+
<section end="Body" />
  
 
----
 
----
  
 
[[Category:AXEL ULite]]
 
[[Category:AXEL ULite]]

Latest revision as of 18:04, 11 January 2024

History
Issue Date Notes

2021/07/20

First DESK-MX6UL-L release

2022/03/16

DESK-MX6UL-L 3.0.0 release
2023/05/04 DESK-MX6UL-L 4.0.0 release


Peripheral GPIOs[edit | edit source]

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.


200px-Emblem-important.svg.png

There aren't GIO already configured in the AXEL ULite EVK.
Here below an example of GPIOs usage in the i.MX6UL standard product SBCLynx

Device tree configuration[edit | edit source]

Here below an example of device tree configuration for using the RS-485 GPIOs used on standard DAVE's product SBCLynx:

From imx6ul-lynx-som0013.dtsi:

        /* 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 */
                        >;
                };

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

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

root@desk-mx6ul-lynx:~# ls -la /sys/class/leds/
total 0
drwxr-xr-x  2 root root 0 Apr  3 15:19 .
drwxr-xr-x 54 root root 0 Apr  3 15:19 ..
lrwxrwxrwx  1 root root 0 Apr  3 15:19 gpio113 -> ../../devices/platform/uart8_rs232/leds/gpio113
lrwxrwxrwx  1 root root 0 Apr  3 15:19 gpio114 -> ../../devices/platform/uart3_rs485/leds/gpio114
lrwxrwxrwx  1 root root 0 Apr  3 15:19 gpio136 -> ../../devices/platform/uart8_rs232/leds/gpio136
lrwxrwxrwx  1 root root 0 Apr  3 15:19 gpio137 -> ../../devices/platform/uart8_rs232/leds/gpio137
lrwxrwxrwx  1 root root 0 Apr  3 15:19 mmc0:: -> ../../devices/platform/soc/2100000.bus/2190000.mmc/leds/mmc0::
lrwxrwxrwx  1 root root 0 Apr  3 15:19 mmc1:: -> ../../devices/platform/soc/2100000.bus/2194000.mmc/leds/mmc1::

Usage with sysfs[edit | edit source]

  • set GPIO1_IO01 (MX6UL_PAD_GPIO1_IO01__GPIO1_IO01) as output GPIO
    • GPIO1_IO01 => (n-1)*32 + IO = (1-1)*32+1 = 1
root@desk-mx6ul-lynx:~# echo 1 > /sys/class/gpio/export
root@desk-mx6ul-lynx:~# echo out > /sys/class/gpio/gpio1/direction
root@desk-mx6ul-lynx:~# echo 1 > /sys/class/gpio/gpio1/value
root@desk-mx6ul-lynx:~#
  • set GPIO1_IO02 (echo 1 > /sys/class/gpio/gpio1/value) as input GPIO
    • GPIO1_IO02 => (n-1)*32 + IO = (1-1)*32+1 = 2
root@desk-mx6ul-lynx:~# echo 2 > /sys/class/gpio/export
root@desk-mx6ul-lynx:~# echo in > /sys/class/gpio/gpio2/direction
root@desk-mx6ul-lynx:~# cat /sys/class/gpio/gpio2/value
0

Additional information[edit | edit source]

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


Warning-icon.png sysfs GPIO ABI has been deprecated. See more inofrmation here about it. A character device access has to be used, more information here Warning-icon.png

Information about GPIOs library libgpiod - C library and tools - can be found on git.kernel.org