wiki:ventana/DigitalIO

Ventana Digital IO

The intent of this page is to provide information about Ventana single board computers general purpose off-board digital IO signals including GPIO, I2C, and PWM

DIO and pin function Mapping

Ventana baseboards provide 4 digital IO signals to a connector. The IMX6 has 7 GPIO blocks having 32 GPIO's each which typically get mapped to gpio0 - through gpio 223 in the Linux kernel. Note that this mapping is not gaurunteed to stay the same across kernel versions - you can look at the debugfs /sys/kernel/debug/gpio file to see where the IMX6 GPIO controller is mapped.

The various ventana product hardware manuals contain a table of what pins on the Digital IO connector routes to what IMX6 GPIO. In some cases these signals can be pinmux'd internally to one of four IMX6 PWM's or in other cases to an I2C controller.

Operating manual "Specifications", "Electrical" section for information on DIO max and min driving strength.

Ventana GPIO Mapping:

Board DIO(1) Connector(2) IMX6_PAD(3) IMX6 GPIO(4) linux sysfsgpio(5) linux PWM(6) I2C(7)
GW51xx DIO0 J11.5 PAD_SD1_DATA0 GPIO1_IO16 gpio-16 - -
GW51xx DIO1 J11.7 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 -
GW51xx DIO2 J11.6 PAD_SD1_DATA1 GPIO1_IO17 gpio-17 PWM3 -
GW51xx DIO3 J11.8 PAD_SD1_CMD GPIO1_IO18 gpio-18 PWM4 -
GW52xx DIO0 J4.1 PAD_SD1_DATA0 GPIO1_IO16 gpio-16 - i2c-2 SDA (9)
GW52xx DIO1 J4.2 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 i2c-2 SCL (9)
GW52xx DIO2 J4.3 PAD_SD1_DATA1 GPIO1_IO17 gpio-17 PWM3 -
GW52xx DIO3 J4.4 PAD_SD1_CLK GPIO1_IO20 gpio-20 - -
GW53xx DIO0 J4.1 PAD_SD1_DATA0 GPIO1_IO16 gpio-16 - i2c-2 SDA
GW53xx DIO1 J4.2 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 i2c-2 SCL
GW53xx DIO2 J4.3 PAD_SD1_DATA1 GPIO1_IO17 gpio-17 PWM3 -
GW53xx DIO3 J4.4 PAD_SD1_CLK GPIO1_IO20 gpio-20 - -
GW54xx DIO0 J16.1 PAD_GPIO_9 GPIO1_IO09 gpio-9 PWM1 i2c-2 SDA
GW54xx DIO1 J16.2 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 i2c-2 SCL
GW54xx DIO2 J16.3 PAD_SD4_DATA1 GPIO2_IO09 gpio-41 PWM3 -
GW54xx DIO3(10) J16.4 PAD_SD4_DATA2 GPIO2_IO10 gpio-42 PWM4 -
GW551x DIO1 J3.19 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 -
GW551x DIO2 J3.20 PAD_SD1_DATA1 GPIO2_IO17 gpio-17 PWM3 -
GW551x J3.7 I2C SDA
GW551x J3.8 I2C SCL
GW552x DIO0 J8.9 PAD_SD1_DATA0 GPIO1_IO16 gpio-16 - -
GW552x DIO1 J8.11 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 -
GW552x DIO2 J8.10 PAD_SD1_DATA1 GPIO1_IO17 gpio-17 PWM3 -
GW552x DIO3 J8.12 PAD_SD1_CLK GPIO1_IO20 gpio-20 - -
GW552x DIO4 J8.15 PAD_CSI0_PIXCLK GPIO5_IO18 gpio-146 - -
GW552x DIO5 J8.17 PAD_CSI0_DATA_EN GPIO5_IO20 gpio-148 - -
GW552x DIO6 J8.16 PAD_CSI0_VSYNC GPIO5_IO21 gpio-149 - -
GW552x DIO7 J8.18 PAD_CSI0_DAT4 GPIO5_IO22 gpio-150 - -
GW552x DIO8 J8.1 PAD_CSI0_DAT5 GPIO5_IO23 gpio-151 - -
GW552x DIO9 J8.2 PAD_CSI0_DAT7 GPIO5_IO25 gpio-153 - -
GW553x DIO0 J10.5 PAD_SD1_DATA0 GPIO1_IO16 gpio-16 - -
GW553x DIO1 J10.7 PAD_SD1_DATA2 GPIO1_IO19 gpio-19 PWM2 -
GW553x DIO2 J10.6 PAD_SD1_DATA1 GPIO1_IO17 gpio-17 PWM3 -
GW553x DIO3 J10.8 PAD_SD1_CMD GPIO1_IO18 gpio-18 PWM4 -
GW16111(8) P0.0 J12.1 (IO0) - - gpio-224 - -
GW16111(8) P0.1 J12.2 (IO1) - - gpio-225 - -
GW16111(8) P0.2 J12.3 (IO2) - - gpio-226 - -
GW16111(8) P0.3 J12.4 (IO3) - - gpio-227 - -
GW16111(8) P0.4 J13.1 (IO4) - - gpio-228 - -
GW16111(8) P0.5 J13.2 (IO5) - - gpio-229 - -
GW16111(8) P0.6 J13.3 (IO6) - - gpio-230 - -
GW16111(8) P0.7 J13.4 (IO7) - - gpio-231 - -
GW16111(8) P1.0 J14.1 (IO8) - - gpio-232 - -
GW16111(8) P1.1 J14.2 (IO9) - - gpio-233 - -
GW16111(8) P1.2 J14.3 (IO10) - - gpio-234 - -
GW16111(8) P1.3 J14.4 (IO11) - - gpio-235 - -
GW16111(8) P1.4 J15.1 (IO12) - - gpio-236 - -
GW16111(8) P1.5 J15.2 (IO13) - - gpio-237 - -
GW16111(8) P1.6 J15.3 (IO14) - - gpio-238 - -
GW16111(8) P1.7 J15.4 (IO15) - - gpio-239 - -
  1. This is the signal name from the Ventana hardware manuals
  2. This is the connector pinout. The 5th pin on 5-pin connectors is GND
  3. Consult the IMX6 Reference manuals for PAD info: ​IMX6DQRM IMX6SDLRM
  4. This is the GPIO block and IO the PAD is pinmux'd to when hwconfig is configured for GPIO
  5. This is the gpio mapped in the linux sysfsgpio API accessible via /sys/class/gpio. Note that the pinmux and IO configuration are done by the bootloader, but you will need to manually export the GPIO to use it (see here for details)
  6. This is the PWM that the PAD is pinmux'd to by the bootloader with hwconfig is conifgured for PWM. u-boot hwconfig to configure DIO pinmux/config
  7. GW54xx and GW53xx (revision B and above) can extend the 2nd CPU I2C bus (I2C3 available as /dev/i2c-2) out the DIO connector if gpio-101 is driven high. see below
  8. The GW16111 is an expansion board for the GW551x family. It has a (PCA9555) digital io expansion chip that gives it 16 GPIO's. There are 2 8 bit ports for 16 bits total (P0 & P1). Each IO has a series current limiting resistor of 332 Ohms.
  9. GW52xx does not have an i2c buffer for protection
  10. The GW5400 PWM4 can be routed to two different pads/connectors. By default the Ventana kernel device-tree's map PWM4 to the J6.5 backlight connector. If you want to use PWM4 as DIO3 on J16.4 you need to change the kernel device-tree and should contact ​support@… for details.

The pinmux and IO configuration is done by the bootloader depending on the hwconfig env variable. For information on how to configure that see hwconfig

Software GPIO Configuration

Please visit this link to find out more information about using GPIO's in Linux

Configuring GPIO Hardware

Typically not needed as defaults should work Please visit this link to find out how to configure the pin function and IO driver details (pull-up, drive str, etc) of the Digital IO pins:

Configuring PWM Hardware

See linux/pwm

External or off-board I2C support

Please consult the ​Hardware Manuals for pint output and support

Model external I2C Support Notes
GW551x Yes Does not have I2C buffer
GW51xx No Can add via GW16113
GW52xx Yes (Requires resistor loading) Does not have I2C buffer
GW53xx-B+ Yes Has software controlled I2C buffer
GW54xx-B+ Yes Has software controlled I2C buffer
GW552x No Can add via GW16113

Ventana boards rely heavily on the I2C bus for on-board devices. The IMX6 supports 4 i2c controllers and Ventana uses the first three as:

I2C Bus Linux Device Description
1 /dev/i2c-0 GSC
2 /dev/i2c-1 PMIC, System items
3 /dev/i2c-2 Multimedia, HDMI, LVDS, Audio, User bus

Accessing I2C on the board

Note that depending on the board model, there may be some i2c device addresses already in use. Please refer to this table:

Device 7bit Address Present On Notes
FXOS8700 0x1E GW5400/GW5410/GW5300/GW5310 Accelerometer / Magnetometer, Bus 3
SGTL5000 0x0A GW5400/GW5300 Analog Audio Codec
ADV7180 0x20 GW5400/GW5300 Analog Video Decoder Bus 3
ADV7393 0x2A GW5400 Analog Video Encoder
TDF19771 0x34 GW5400 HDMI Receiver
TDF19771 0x48 GW5400 HDMI Receiver CEC
HDMI EDID 0x50 GW5xxx HDMI Monitor EDID device (If HDMI monitor plugged in)
  • Also note that this i2c bus goes to the LVDS Display connector which if used, may have i2c devices there as well (such as touchscreen controllers)
  • The models listed are catalog parts only - components on Gateworks specials may vary (contact Sales for more info)

Many Ventana boards provide the I2C3 (/dev/i2c-2) bus via an off-board connection:

  • used for HDMI DDC channel to support EDID for boards supporting HDMI output
  • routed to DIO connector via softwtare configuration on most Ventana models.

I2C at the DIO connector

Several Ventana boards can optionally configure the CPU I2C3 bus (/dev/i2c-2) SDA/SCL to route out to the Digital IO connector pins 1 (DIO0) and 2 (DIO1) respectively (see above)

Note that on these boards that have i2c-2 off-board via DIO0/DIO1 capability, there are 4.7kohm pull-up's to 3.3V on DIO0/DIO1 (SCL/SDA).

For those boards that have a software controlled I2C buffer, the buffer is disabled by default and to enable it you must:

  1. Confirm in the bootloader that DIO0 and DIO1 are set to GPIO in the hwconfig variable. These is the default configuration, so most likely no changes are needed:
    Ventana > print hwconfig
    hwconfig=rs232;dio0:mode=gpio;dio1:mode=gpio;dio2:mode=gpio;dio3:mode=gpio
    
    • Note above how dio0 and dio1 are set to gpio mode and not pwm mode
  2. Set the I2C_EN signal (gpio-101) high to enable the I2C buffer by appending gpio set 101 to the bootloader bootcmd:
    Ventana > setenv bootcmd "gpio set 101; ${bootcmd}"
    Ventana > saveenv
    
    • We do this in the bootloader so that the i2c buffer is enabled by the time i2c kernel drivers are probing the bus.
    • This is not necessary on the GW52xx as it does not have an i2c buffer for protection.
  3. Ensure you are not 'exporting' DIO0 and DIO1 gpios in Linux userspace as they will conflict with SDA/SCL if made to be outputs.

You can test by using a oscilloscope and probing the lines and issuing a command like shown below. You will see activity.

Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]

Example shown is on bus 3 (0 based, thus 2 is shown, address 0x20 and Data Address of 0)

Please adjust below example for actual bus and I2C address.

i2cget -f -y 2 0x20 0

A quick script to do the above commands for a GW5400:

#!/bin/sh

# make DIO0 and DIO1 inputs to not conflict with I2C-2 SCL/SDA
echo 9 > /sys/class/gpio/export
echo 19 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio9/direction
echo in > /sys/class/gpio/gpio19/direction

# enable I2C_EN
echo 101 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio101/direction
echo 1 > /sys/class/gpio/gpio101/value

Note that on these boards that have i2c-2 off-board via DIO0/DIO1 capability, there are 4.7kohm pull-up's to 3.3V on DIO0/DIO1.

Troubleshooting:

It's a best practice to only use output for troubleshooting DIO.

In this example a GW5304 is being used with leads attached to pin 1 and 5 or J4, probing with volt meter.

root@OpenWrt:/# echo 16 > /sys/class/gpio/export
root@OpenWrt:/# echo out > /sys/class/gpio/gpio16/direction
root@OpenWrt:/# echo 1 > /sys/class/gpio/gpio16/value # V out is high 3.3V
root@OpenWrt:/# echo 0 > /sys/class/gpio/gpio16/value # V out is low 0.2V

I2C on HDMI output

All boards that have HDMI output, route I2C3 to the HDMI connector. For pinout details see the HDMI specification for the specific connector type. Note that Type-A (standard HDMI) and Type-D (micro HDMI) have different pinouts.

References:

Accessing I2C From C Code

The best reference is looking at the source code for the standard I2C tools available on the Linux command line.

See links below:

Useful links

Last modified 5 years ago Last modified on 09/12/2019 11:58:43 PM
Note: See TracWiki for help on using the wiki.