Configuration of GPIO of expansion connector of IMX8mm

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Configuration of GPIO of expansion connector of IMX8mm

5,700 Views
ebecam
Contributor II

Hello,

I'm working with the IMX8M Mini EVK and generate image with Yocto using the core-image-base.

I would like to use the GPIO of the expansion connector.

According to the schematics, 7 GPIOs are available on the expansion connector through the PCA6416 driver.

pastedImage_1.png

GPIO from this driver are available under sysfs:

root@imx8mmevk:~# cat /sys/class/gpio/gpiochip496/label
tca6416

root@imx8mmevk:~# cat /sys/class/gpio/gpiochip496/ngpio
16
root@imx8mmevk:~# cat /sys/class/gpio/gpiochip496/base  
496

I first try to use GPIO 9 of the expansion connector as as input GPIO:

root@imx8mmevk:~# echo 505 > /sys/class/gpio/export                                                                                           
root@imx8mmevk:~# echo in > /sys/class/gpio/gpio505/direction

Then I connect pin 13 of the expansion connector to 3.3V and read value:

root@imx8mmevk:~# cat /sys/class/gpio/gpio505/value
0

Value of GPIO stays to 0.

Moreover, when configuring GPIO as output, and measuring voltage of the GPIO, I always measure 0V even when value in set to 1.

I have checked that pca6416 driver is recognized on the i2c bus (bus #3, @ 0x20)

root@imx8mmevk:~# i2cdetect 2
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-2.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: UU UU UU UU -- -- -- -- -- -- -- -- -- -- -- --
20: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Could you please help me configuring those GPIO ? Is there more checking I should make to assure everything is alright ? Am I missing some configurations to enable those GPIO ?

Thanks in advance

Labels (1)
4 Replies

4,681 Views
ebecam
Contributor II

Thanks for the links Jimmy.

I finally manage to control GPIO of the expansion connector by using the following commands:

For GPIO 9 of the expansion connector as as input GPIO:

root@imx8mmevk:~# echo 507 > /sys/class/gpio/export                                                                                           
root@imx8mmevk:~# echo in > /sys/class/gpio/gpio507/direction

Then when connecting pin 13 of the expansion connector to 3.3V and reading value:

root@imx8mmevk:~# cat /sys/class/gpio/gpio507/value
1

4,681 Views
sasa_pavlovic
Contributor I

Hi and thank you for posting your solution.

However, I would like to know why it is 507 instead of 505 like in your first attempt? The base is 496 and you want the 9th gpio of the i/o expansion chip so 496 + 9 = 505? Why is there an offset of 2?

Thank you

0 Kudos

4,681 Views
charles_pacey
Contributor I

Hi Sasa,

     The gpio pins here are driven through and i2c i/o expander chip.  If you look on sheet 6 of the schematic, you will see that the GPIO_IOxx pins are connected to the expander outputs such that P0_0 is connected to EXP_IO14 and EXP_IO0 starts sequentially at P0_2.   You can confirm this behavior with the below commands to toggle the pins gpio496 and gpio511 to confirm:

Pin 31 = EXP_IO14 = gpio496

Pin 33 = EXP_IO13 = gpio496+15 = gpio511

1) export both gpio for userspace. 

root@imx8mmevk:~# echo 496 > /sys/class/gpio/export

root@imx8mmevk:~# echo 511 > /sys/class/gpio/export

2) set them as outputs

root@imx8mmevk:~# echo out > /sys/class/gpio/gpio496/direction

root@imx8mmevk:~# echo out > /sys/class/gpio/gpio511/direction

3) Set the values of them to 1 and 0 and confirm 3.3V and 0V accordingly 

    to confirm:

Pin 31 = EXP_IO14 = gpio496

Pin 33 = EXP_IO13 = gpio511

 

root@imx8mmevk:~# echo 1 > /sys/class/gpio/gpio496/value

root@imx8mmevk:~# echo 0 > /sys/class/gpio/gpio496/value

 

pastedImage_1.png

4,681 Views
jimmychan
NXP TechSupport
NXP TechSupport
0 Kudos