The Dragonwing IQ8-EVK contains one low-speed connector (JLS1) that provides access to various GPIOs, CAN, QUPs, and other interfaces.
Pinout
The figure below shows the default functions of the IQ-8275 EVK 40-pin LS connector.
GPIOs
The following commands require root privileges. Use sudo su to switch to the root user.
Identify GPIO Subsystem Numbers
Identify the base GPIO number by running the following command and looking for platform/f000000.pinctrl (gpiochip4).
mount -t debugfs none /sys/kernel/debug/
cat /sys/kernel/debug/gpio
| LS1 Connector GPIO |
|---|
| GPIO | Odd | Even | GPIO |
|---|
| GND | 1 | 2 | GND |
| 52 | 3 | 4 | CAN_H |
| 54 | 5 | 6 | CAN_L |
| 55 | 7 | 8 | 32 |
| 53 | 9 | 10 | 33 |
| 44 | 11 | 12 | 34 |
| 45 | 13 | 14 | 35 |
| 96 | 15 | 16 | 107 |
| 95 | 17 | 18 | 106 |
| 100 | 19 | 20 | 109 |
| 99 | 21 | 22 | 108 |
| 40 | 23 | 24 | 105 |
| 41 | 25 | 26 | 43 |
| 42 | 27 | 28 | SAIL59 |
| PME 11 | 29 | 30 | SAIL42 |
| 140 | 31 | 32 | SAIL46 |
| IO EXP3 7 | 33 | 34 | SAIL50 |
| 3.3V | 35 | 36 | SYS PWR |
| 5V | 37 | 38 | SYS PWR |
| GND | 39 | 40 | GND |
Configure GPIOs from User Space
Use the libgpiod library from user space to control the GPIOs for better performance.
Install the Arm64 toolchain
sudo apt install gcc-aarch64-linux-gnu
sudo apt install binutils-aarch64-linux-gnu
Download and extract libgpiod
wget https://www.kernel.org/pub/software/libs/libgpiod/libgpiod-1.6.4.tar.xz
tar xvf libgpiod-1.6.4.tar.xz
cd libgpiod-1.6.4
Configure the sources for static linking
./configure --enable-tools=yes --build x86_64-pc-linux-gnu --host aarch64-linux-gnu CFLAGS="-static -static-libgcc -Wl,-static,--start-group,/usr/lib/gcc-cross/aarch64-linux-gnu/7.5.0/libgcc.a,/usr/lib/gcc-cross/aarch64-linux-gnu/7.5.0/libgcc_eh.a,/usr/aarch64-linux-gnu/lib/libc.a,--end-group"
Compile the library
Compiling creates linked binaries.
Build the statically linked binaries
aarch64-linux-gnu-gcc -static -o tools/gpiodetect tools/gpiodetect.o tools/tools-common.o -Wl,-L<ABSOLUTE_PATH_TO_LIBGPIOD>/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
aarch64-linux-gnu-gcc -static -o tools/gpioget tools/gpioget.o tools/tools-common.o -Wl,-L<ABSOLUTE_PATH_TO_LIBGPIOD>/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
aarch64-linux-gnu-gcc -static -o tools/gpioset tools/gpioset.o tools/tools-common.o -Wl,-L<ABSOLUTE_PATH_TO_LIBGPIOD>/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
aarch64-linux-gnu-gcc -static -o tools/gpiofind tools/gpiofind.o tools/tools-common.o -Wl,-L<ABSOLUTE_PATH_TO_LIBGPIOD>/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
aarch64-linux-gnu-gcc -static -o tools/gpioinfo tools/gpioinfo.o tools/tools-common.o -Wl,-L<ABSOLUTE_PATH_TO_LIBGPIOD>/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
aarch64-linux-gnu-gcc -static -o tools/gpiomon tools/gpiomon.o tools/tools-common.o -Wl,-L<ABSOLUTE_PATH_TO_LIBGPIOD>/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
Push the binaries to the device
scp gpiodetect gpioget gpioset gpiofind gpioinfo root@<IP_address>:/path/to/directory/on/device
List GPIO chips on the device
Run gpiodetect to list the GPIO chips.Example output:gpiochip0 [c440000.spmi:pmic@8:pinctrl@c00] (12 lines)
gpiochip1 [c440000.spmi:pmic@1:gpio@8800] (10 lines)
gpiochip2 [c440000.spmi:pmic@2:gpio@8800] (9 lines)
gpiochip3 [c440000.spmi:pmic@0:gpio@b000] (4 lines)
gpiochip4 [f100000.pinctrl] (176 lines)
gpiochip5 [33c0000.pinctrl] (15 lines)
Display GPIO line information
Run gpioinfo to view the lines for a specific chip.Example output:gpiochip4 - 151 lines:
line 0: unnamed "?" input active-high [used]
line 1: unnamed unused input active-high
line 2: unnamed "perst" output active-low [used]
line 3: unnamed unused input active-high
line 4: unnamed "perst" output active-low [used]
line 5: unnamed "?" input active-high [used]
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
line 8: unnamed unused input active-high
line 9: unnamed unused input active-high
line 10: unnamed unused input active-high
line 11: unnamed unused input active-high
line 12: unnamed unused input active-high
line 13: unnamed unused input active-high
line 14: unnamed unused input active-high
line 15: unnamed unused input active-high
......
.....
Set a GPIO value
To set GPIO line 54 on gpiochip4, run:./gpioset gpiochip4 54=1
./gpioinfo gpiochip4 | grep 54
Example output:gpiochip4 - 176 lines:
line 54: unnamed unused output active-high
Read a GPIO value
To read GPIO line 0 on gpiochip4, run:Example output:After reading the value, gpioinfo shows the line returned to input mode.Example output:gpiochip4 - 176 lines:
line 0: unnamed unused input active-high
line 1: unnamed unused input active-high
UART
Pins 5 and 7 are configured for UART by default (GPIO lines 54 and 55, mapping to uart12 = qup1_se5 (0xa98000)).
Follow the Modify serial engine node procedure to enable the UART interface. After enabling, the device node appears at /dev/ttyHS3.
Connect pins
Short pin 5 and pin 7 with a Dupont wire.
Do not short power and ground pins.
Configure UART
stty -F /dev/ttyHS3 ispeed 115200 ospeed 115200
stty -F /dev/ttyHS3 115200 -echo -icanon -isig -iexten -icrnl -ixon -opost
Open two SSH terminals
Terminal 1 (RX): cat /dev/ttyHS3Terminal 2 (TX): echo "hello world!" > /dev/ttyHS3
I2C
Pins 8 and 10 are configured for I2C by default (GPIO lines 32 and 33, mapping to i2c4 = qup0_se4 (0x990000)).
Follow the Modify serial engine node procedure to enable the I2C interface.
ls /dev/i2c*
scp i2cdetect root@<IP address>:/usr
i2cdetect -l
i2cdetect -a -y -r 20
SPI
Pins 11 and 13 are configured for SPI by default (GPIO lines 44 and 45, mapping to spi10 = qup1_se3 (0xa8c000)).
Follow the Modify serial engine node procedure to enable the SPI interface.