/
i.MX 8X GPIOs

i.MX 8X GPIOs

Each GPIO should be mapped on the device tree as:

XX_YY_ZZ_LSIO_GPIO#_IO#

<details>
<summary>Click here</summary>

imx8qxp-qx8x { pinctrl_hog: hoggrp { fsl,pins = < SC_P_SPI2_SDO_LSIO_GPIO1_IO01 0x00000021 /* GPIO 0 (449) */ SC_P_SPI2_CS0_LSIO_GPIO1_IO00 0x00000021 /* GPIO 1 (448) */ SC_P_SPI2_SDI_LSIO_GPIO1_IO02 0x00000021 /* GPIO 2 (450) */ SC_P_SPI2_SCK_LSIO_GPIO1_IO03 0x00000021 /* GPIO 3 (451)*/ SC_P_SPI0_CS0_LSIO_GPIO1_IO08 0x00000021 /* GPIO 4 (456) */ SC_P_FLEXCAN2_RX_LSIO_GPIO1_IO19 0x00000021 /* GPIO 5 (467) */ SC_P_SPI0_SDI_LSIO_GPIO1_IO05 0x00000021 /* GPIO 6 (453) */ SC_P_FLEXCAN2_TX_LSIO_GPIO1_IO20 0x00000021 /* GPIO 7 (468) */ SC_P_MIPI_DSI0_GPIO0_01_LSIO_GPIO1_IO28 0x00000021 /* LVDS0_PPEN (476) */ SC_P_MIPI_DSI1_GPIO0_01_LSIO_GPIO2_IO00 0x00000021 /* LVDS0_BLEN (416) */ >; };

</details>

the GPIO# matches the gpiochip

the IO# is the specific GPIO number into the chip

To calculate the number where the GPIO is mapped into the userspace this are the correspondence:

GPIO

#user space

GPIO

#user space

--

--

0

480

1

448

2

416

3

384

4

352

5

320

6

288

7

256

Then add the specific number of the IO to the gpiochip and this will be the GPIO number into the userspace

e.g: SC_P_M40_GPIO0_01_LSIO_GPIO0_IO09

 

GPIO chip 0 → 480

 

IO number → 9

 

gpio number → 480+9 = 489

To have access to it do the following

cd /sys/class/gpio echo 489 > export cd gpio489 echo out > direction echo 1 > value echo 0 > value echo in > direction