---
# System prepended metadata

title: Untitled

---

AR8MXMQ GPIO Test Guide
---
### 1. AR8MXMQ GPIO Pin Definition
![](https://engineering.bcmcom.com/customerdl/ar8mxmq/pic/ar8mxmq_gpio.png)

| Pin Name | iMX8 Pin Name | GPIO Pin# |
| ---- | --- | --- |
| DIO0 | NAND_nRE | GP3_15 |
| DIO1 | NAND_nREADY | GP3_16 |
| DIO2 | NAND_nWE | GP3_17 |
| DIO3 | NAND_nWP | GP3_18 |
| DIO4 | NAND_DATA4 | GP3_10 |
| DIO5 | NAND_DATA5 | GP3_11 |
| DIO6 | NAND_DATA6 | GP3_12 |
| DIO7 | NAND_DATA7 | GP3_13 |

### 2. Linux DTS
```c=
                /* DIO CONN */
                MX8MQ_IOMUXC_NAND_RE_B_GPIO3_IO15          0x00000016
                MX8MQ_IOMUXC_NAND_READY_B_GPIO3_IO16       0x00000016
                MX8MQ_IOMUXC_NAND_WE_B_GPIO3_IO17          0x00000016
                MX8MQ_IOMUXC_NAND_WP_B_GPIO3_IO18          0x00000016
                MX8MQ_IOMUXC_NAND_DATA04_GPIO3_IO10        0x00000016
                MX8MQ_IOMUXC_NAND_DATA05_GPIO3_IO11        0x00000016
                MX8MQ_IOMUXC_NAND_DATA06_GPIO3_IO12        0x00000016
                MX8MQ_IOMUXC_NAND_DATA07_GPIO3_IO13        0x00000016

```


### 3. Access via Linux sysfs
#### Calculate the GPIO number
```
GPIO# = (PORT# - 1) * 32 + Pin#
```
#### Expand Pin Definition Table
| Pin Name | iMX8 Pin Name | GPIO Pin# | GPIO# |
| ---- | --- | --- | --- |
| DIO0 | NAND_nRE | GP3_15 | 79 |
| DIO1 | NAND_nREADY | GP3_16 | 80 |
| DIO2 | NAND_nWE | GP3_17 | 81 |
| DIO3 | NAND_nWP | GP3_18 | 82|
| DIO4 | NAND_DATA4 | GP3_10 | 74 |
| DIO5 | NAND_DATA5 | GP3_11 | 75 |
| DIO6 | NAND_DATA6 | GP3_12 | 76 |
| DIO7 | NAND_DATA7 | GP3_13 | 77 |

#### Export GPIO79 for DIO0
`# echo 79 > /sys/class/gpio/export`
#### GPIO folder structure
```
# tree /sys/class/gpio/gpio79/
/sys/class/gpio/gpio79/
├── active_low
├── device -> ../../../gpiochip2
├── direction
├── edge
├── power
│   ├── autosuspend_delay_ms
│   ├── control
│   ├── runtime_active_time
│   ├── runtime_status
│   └── runtime_suspended_time
├── subsystem -> ../../../../../../class/gpio
├── uevent
└── value

3 directories, 10 files
```

#### Check GPIO configured as Input/Output
```
cat /sys/class/gpio/gpio79/direction
in
```
#### Set GPIO79 to Output
`# echo out > /sys/class/gpio/gpio79/direction`
#### Drive GPIO79 high
`# echo 1 > /sys/class/gpio/gpio79/value`
#### Drive GPIO79 high
`# echo 0 > /sys/class/gpio/gpio79/value`
#### Unexport GPIO79 when done
`# echo 79 > /sys/class/gpio/unexport`