> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 40 Pin Low Speed Connector

The Dragonwing IQ9-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-9075 EVK 40-pin LS connector.

<img src="https://mintcdn.com/qualcomm-prod/T1k4QQ7G3l_dE-rX/Linux/images/peripheral-interfaces/40-pin-LS-details.png?fit=max&auto=format&n=T1k4QQ7G3l_dE-rX&q=85&s=f805093457abc7799690fc98280a9173" width="1639" height="1050" data-path="Linux/images/peripheral-interfaces/40-pin-LS-details.png" />

<img src="https://mintcdn.com/qualcomm-prod/Bh7DlgudKfjY_3Wf/Linux/images/peripheral-interfaces/LS-connector-functional_details.png?fit=max&auto=format&n=Bh7DlgudKfjY_3Wf&q=85&s=ca86cb7a63e3f4428b2cef50c39e46a8" width="1449" height="834" data-path="Linux/images/peripheral-interfaces/LS-connector-functional_details.png" />

## GPIOs

<Note>
  The following commands require root privileges. Use `sudo su` to switch to the root user.
</Note>

### Identify GPIO Subsystem Numbers

Identify the base GPIO number by running the following command and looking for `platform/f000000.pinctrl` (gpiochip4).

```text theme={null}
mount -t debugfs none /sys/kernel/debug/
cat /sys/kernel/debug/gpio
```

<table border="1">
  <thead>
    <tr>
      <th colspan="4">LS1 Connector GPIO</th>
    </tr>

    <tr>
      <th>GPIO</th>
      <th>Odd</th>
      <th>Even</th>
      <th>GPIO</th>
    </tr>
  </thead>

  <tbody>
    <tr><td>GND</td><td>1</td><td>2</td><td>GND</td></tr>
    <tr><td>52</td><td>3</td><td>4</td><td>CAN\_H</td></tr>
    <tr><td>54</td><td>5</td><td>6</td><td>CAN\_L</td></tr>
    <tr><td>55</td><td>7</td><td>8</td><td>32</td></tr>
    <tr><td>53</td><td>9</td><td>10</td><td>33</td></tr>
    <tr><td>44</td><td>11</td><td>12</td><td>34</td></tr>
    <tr><td>45</td><td>13</td><td>14</td><td>35</td></tr>
    <tr><td>96</td><td>15</td><td>16</td><td>107</td></tr>
    <tr><td>95</td><td>17</td><td>18</td><td>106</td></tr>
    <tr><td>100</td><td>19</td><td>20</td><td>109</td></tr>
    <tr><td>99</td><td>21</td><td>22</td><td>108</td></tr>
    <tr><td>40</td><td>23</td><td>24</td><td>105</td></tr>
    <tr><td>41</td><td>25</td><td>26</td><td>43</td></tr>
    <tr><td>42</td><td>27</td><td>28</td><td>SAIL59</td></tr>
    <tr><td>PME 11</td><td>29</td><td>30</td><td>SAIL42</td></tr>
    <tr><td>140</td><td>31</td><td>32</td><td>SAIL46</td></tr>
    <tr><td>IO EXP3 7</td><td>33</td><td>34</td><td>SAIL50</td></tr>
    <tr><td>3.3V</td><td>35</td><td>36</td><td>SYS PWR</td></tr>
    <tr><td>5V</td><td>37</td><td>38</td><td>SYS PWR</td></tr>
    <tr><td>GND</td><td>39</td><td>40</td><td>GND</td></tr>
  </tbody>
</table>

# Configure GPIOs from User Space

Use the `libgpiod` library from user space to control the GPIOs for better performance.

<Steps>
  <Step title="Install the Arm64 toolchain">
    ```bash theme={null}
    sudo apt install gcc-aarch64-linux-gnu
    sudo apt install binutils-aarch64-linux-gnu
    ```
  </Step>

  <Step title="Download and extract libgpiod">
    ```bash theme={null}
    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
    ```
  </Step>

  <Step title="Configure the sources for static linking">
    ```bash theme={null}
    ./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"
    ```
  </Step>

  <Step title="Compile the library">
    ```bash theme={null}
    make
    ```

    <Note>
      Compiling creates linked binaries.
    </Note>
  </Step>

  <Step title="Build the statically linked binaries">
    ```bash theme={null}
    aarch64-linux-gnu-gcc -static -o tools/gpiodetect tools/gpiodetect.o tools/tools-common.o -Wl,-L&lt;ABSOLUTE_PATH_TO_LIBGPIOD&gt;/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&lt;ABSOLUTE_PATH_TO_LIBGPIOD&gt;/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&lt;ABSOLUTE_PATH_TO_LIBGPIOD&gt;/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&lt;ABSOLUTE_PATH_TO_LIBGPIOD&gt;/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&lt;ABSOLUTE_PATH_TO_LIBGPIOD&gt;/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&lt;ABSOLUTE_PATH_TO_LIBGPIOD&gt;/libgpiod-1.6.4/lib/.libs,-lgpiod,-lpthread,-static
    ```
  </Step>

  <Step title="Push the binaries to the device">
    ```bash theme={null}
    scp gpiodetect gpioget gpioset gpiofind gpioinfo root@<IP_address>:/path/to/directory/on/device
    ```
  </Step>

  <Step title="List GPIO chips on the device">
    Run `gpiodetect` to list the GPIO chips.

    ```bash theme={null}
    ./gpiodetect
    ```

    Example output:

    ```text theme={null}
    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)
    ```
  </Step>

  <Step title="Display GPIO line information">
    Run `gpioinfo` to view the lines for a specific chip.

    ```text theme={null}
    ./gpioinfo gpiochip4
    ```

    Example output:

    ```text theme={null}
    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
    ......
    .....
    ```
  </Step>

  <Step title="Set a GPIO value">
    To set GPIO line `54` on `gpiochip4`, run:

    ```text theme={null}
    ./gpioset gpiochip4 54=1
    ./gpioinfo gpiochip4 | grep 54
    ```

    Example output:

    ```text theme={null}
    gpiochip4 - 176 lines:
       line    54:      unnamed       unused   output  active-high
    ```
  </Step>

  <Step title="Read a GPIO value">
    To read GPIO line `0` on `gpiochip4`, run:

    ```text theme={null}
    ./gpioget gpiochip4 0
    ```

    Example output:

    ```text theme={null}
    1
    ```

    After reading the value, `gpioinfo` shows the line returned to input mode.

    ```text theme={null}
    ./gpioinfo gpiochip4
    ```

    Example output:

    ```text theme={null}
    gpiochip4 - 176 lines:
             line    0:      unnamed       unused   input   active-high
             line    1:      unnamed       unused   input   active-high
    ```
  </Step>
</Steps>

## 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](./peripheral_interface_overview#modify-serial-engine-node) procedure to enable the UART interface. After enabling, the device node appears at `/dev/ttyHS3`.

```bash theme={null}
#ls -al /dev/ttyHS3
crw-rw---- 1 root dialout 236, 2 Nov 25 18:16 ttyHS3
```

<Tabs>
  <Tab title="Shell">
    <Steps>
      <Step title="Connect pins">
        Short pin 5 and pin 7 with a Dupont wire.

        <img src="https://mintcdn.com/qualcomm-prod/Bh7DlgudKfjY_3Wf/Linux/images/peripheral-interfaces/IQ9075_short_pin5_7_gpio_test.png?fit=max&auto=format&n=Bh7DlgudKfjY_3Wf&q=85&s=c715e089081886bf3fc77b3bab9bf5eb" width="520" height="584" data-path="Linux/images/peripheral-interfaces/IQ9075_short_pin5_7_gpio_test.png" />

        <Warning>
          Pay attention to pin order. Do not short power and ground pins — this may damage the board.
        </Warning>
      </Step>

      <Step title="Configure UART">
        ```bash theme={null}
        stty -F /dev/ttyHS3 ispeed 115200 ospeed 115200
        stty -F /dev/ttyHS3 115200 -echo -icanon -isig -iexten -icrnl -ixon -opost
        ```
      </Step>

      <Step title="Open two SSH terminals">
        **Terminal 1 (RX):**

        ```bash theme={null}
        cat /dev/ttyHS3
        ```

        **Terminal 2 (TX):**

        ```bash theme={null}
        su
        echo "hello world!" > /dev/ttyHS3
        ```

        <img src="https://mintcdn.com/qualcomm-prod/Bh7DlgudKfjY_3Wf/Linux/images/peripheral-interfaces/UART_loopback.png?fit=max&auto=format&n=Bh7DlgudKfjY_3Wf&q=85&s=e92dbb6c7f8bc77bbfb00416d3b8c700" width="1428" height="311" data-path="Linux/images/peripheral-interfaces/UART_loopback.png" />
      </Step>
    </Steps>
  </Tab>
</Tabs>

## I2C

I2C (Inter-Integrated Circuit) is a bidirectional 2-wire bus for inter-IC control. Every device on the bus has a unique address. The I2C core supports multi-controller mode, 10-bit target addressing, and 10-bit extendable addressing.

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](./peripheral_interface_overview#modify-serial-engine-node) procedure to enable the I2C interface. After enabling, verify the device nodes:

```bash theme={null}
ls /dev/i2c*
# Expected: /dev/i2c-18  /dev/i2c-19  /dev/i2c-20  /dev/i2c-21  /dev/i2c-22  /dev/i2c-23  /dev/i2c-24  /dev/i2c-25
```

<Tabs>
  <Tab title="Shell">
    <Steps>
      <Step title="push i2c-tools">
        ```bash theme={null}
        scp i2cdetect root@<IP address>:/usr
        ```
      </Step>

      <Step title="List I2C adapters">
        ```bash theme={null}
        i2cdetect -l
        ```
      </Step>

      <Step title="Map adapters to device tree nodes">
        ```bash theme={null}
        ls -l /sys/class/i2c-adapter/i2c-*
        ```
      </Step>

      <Step title="Scan for devices on bus 20">
        ```bash theme={null}
        i2cdetect -a -y -r 20
        ```
      </Step>

      <Step title="Read/write device registers">
        ```bash theme={null}
        # Read all registers of device at address 0x38
        i2cdump -f -y 1 0x38

        # Write 0xaa to register 0x01
        i2cset -f -y 1 0x38 0x01 0xaa

        # Read register 0x01
        i2cget -f -y 1 0x38 0x01
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

## SPI

SPI (Serial Peripheral Interface) is a synchronous full-duplex 4-wire serial bus.

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](./peripheral_interface_overview#modify-serial-engine-node) procedure to enable the SPI interface.
