Work with GPIO i.MX 8M Mini

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

Work with GPIO i.MX 8M Mini

2,442 Views
SYakubson
Contributor II

Hello! Where can i find schematics to work with GPIO. I found this site (https://variwiki.com/index.php?title=MX8M_GPIO), but I could not find a diagram that describes which pin on gpio and its number.

Labels (1)
0 Kudos
Reply
11 Replies

2,433 Views
SYakubson
Contributor II

@weidong_sun You can give a link to the manul? I could not find it anywhere.
And I have one more question, how can I control the pins from the GPIO comb (EXP CN, ​​J1003)? I tried to do as described here: 

https://community.nxp.com/t5/i-MX-Processors/Configuration-of-GPIO-of-expansion-connector-of-IMX8mm/...
But I get this:
root @ imx8mmevk: / # echo 505> / sys / class / gpio / export
[13964.387316] export_store: invalid GPIO 505
-sh: echo: write error: Invalid argument

 

0 Kudos
Reply

2,421 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello @SYakubson ,

Download the reference manual on the web link, please!

https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-proces...

An example for you:

if you are using GPIO5_IO08, it's number in linux : (5-1)x32 + 8 = 136

you can get all GPIO list from reference manual.

 

Hope above is helpful to you.

Have a good day!

regards,

weidong

0 Kudos
Reply

2,416 Views
SYakubson
Contributor II

@weidong_sun 
Ok, but what GPIO number will EXP_IO13 (and other EXP_IOs) have?
Screenshot from 2021-11-15 10-25-46.png

 

0 Kudos
Reply

2,376 Views
BiyongSUN
NXP Employee
NXP Employee

It is linux knowledge, technically, not a question for i.mx processors community strictly. 

You should read the linux document. and document tells you everything.

linux/Documentation/driver-api/gpio/legacy.rst

GPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the
controller implementing GPIOs starting at #42) and have the following
read-only attributes:

/sys/class/gpio/gpiochipN/

"base" ... same as N, the first GPIO managed by this chip

"label" ... provided for diagnostics (not always unique)

"ngpio" ... how many GPIOs this manges (N to N + ngpio - 1)

 


for i in /sys/class/gpio/gpiochip* ; do echo $i ;echo label:$(cat $i/label);echo base: $(cat $i/base); echo ngpio $(cat $i/ngpio);done

 

 

Untitledx.png

confirmed by debugfs

cat /sys/kernel/debug/gpio

Untitledyyy.png

0 Kudos
Reply

2,371 Views
SYakubson
Contributor II

Screenshot from 2021-11-18 11-07-51.png

I am assuming that the dts file you are showing needs to be added to the yocto build, right? Because I don't have gpiochip5.

This is it, right?
https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.d...

0 Kudos
Reply

2,362 Views
BiyongSUN
NXP Employee
NXP Employee

You don't have because the i.MX8MM EVK hardware is rohm bd71847 pmic. 

but the BSP software is pca pmic. you change it to rohm pmic as previous. 

will see the gpio, I have shown you. 

You can see the current dts is using pca pmic not rohm pmic.

hardware is rohm pimc, bsp is pca pmic, so it has an error. 

and the PCA6416APW is supplied by rohm,  bd71847 buck 6 and buck7. 

change is to rohm, you will see the PCA6416APW.

you can do backports the rohm pmic from L5.4.24. 

It is very easy, just copy & paste.

root@imx8mmevk:~# dmesg|grep pca
[ 2.112946] nxp-pca9450 0-0025: Read device id error

 

 

 

&i2c1 {
	clock-frequency = <400000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c1>;
	status = "okay";

	pmic_nxp: pca9450@25 {
		compatible = "nxp,pca9450a";
		reg = <0x25>;
		pinctrl-0 = <&pinctrl_pmic>;

 

0 Kudos
Reply

2,354 Views
SYakubson
Contributor II

Okay so I have to change the PCA6416APW to bd71847 in dts file in the yocto build directory?

Or i can do this under build Linux image? 

Screenshot from 2021-11-18 15-40-45.png

0 Kudos
Reply

2,335 Views
BiyongSUN
NXP Employee
NXP Employee

I already told you everything. If you cannot modify the device tree as backposts from L5.4.24.

You can download L5.4.24 binary demo image to try. 

0 Kudos
Reply

2,402 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi @SYakubson ,

 

the driver of I2C IO expander is gpio-pca953x.c

open the file, you can find 'chip->gpio_start' in probe function, add prink() to print it's value, you will know the first GPIO number.

 

Regards,

weidong

0 Kudos
Reply

2,386 Views
SYakubson
Contributor II

@weidong_sun 
Where i can find this file in Yocto build dir?
Or in builded Linux Files system?

0 Kudos
Reply

2,437 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hi, 

All Pins multiplexing are listed in  8.1.1.1 Muxing Options of reference manual

weidong_sun_0-1636610933314.png

check it , please!

Regards,

weidong

0 Kudos
Reply