Open main menu

DAVE Developer's Wiki β

DESK-MX6UL-L/Peripherals/GPIOs

< DESK-MX6UL-L
Revision as of 10:13, 21 April 2021 by U0007 (talk | contribs) (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...")

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
History
Version Issue Date Notes
1.0.0 Apr 2021 First DESK release


Contents

Peripheral GPIOsEdit

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 configurationEdit

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 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 peripheralEdit

Linux messages at boot timeEdit

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-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:~#

Usage with sysfsEdit

  • 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-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:~#
  • 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-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:~#

Additional informationEdit

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


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

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