imx8m plus evk with gpio (high - low)

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

imx8m plus evk with gpio (high - low)

1,695 Views
ylmzhsn_
Contributor III

Hi NXP,

1- imx-yocto-bsp/build/tmp/work-shared/imx8mpevk/kernel-source/arch/arm64/boot/dts/freescale$ ls
2- nano imx8mp-evk.dts
&iomuxc {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_hog>;

        pinctrl_hog: hoggrp {
                fsl,pins = <
                   MX8MP_IOMUXC_HDMI_DDC_SCL__HDMIMIX_HDMI_SCL     0x40000000
                   MX8MP_IOMUXC_HDMI_DDC_SDA__HDMIMIX_HDMI_SDA     0x40000000
                   MX8MP_IOMUXC_HDMI_HPD__HDMIMIX_HDMI_HPD         0x40000000
                   MX8MP_IOMUXC_HDMI_CEC__HDMIMIX_HDMI_CEC         0x40000000
                   MX8MP_IOMUXC_SAI5_RXD0__GPIO3_IO21              0x00000106
                   MX8MP_IOMUXC_SAI5_RXD1__GPIO3_IO22              0x00000106
                   MX8MP_IOMUXC_SAI5_RXD2__GPIO3_IO23              0x00000106
                   MX8MP_IOMUXC_SAI5_RXD3__GPIO3_IO24              0x00000106
                >;
        };
3- bitbake imx-image-full
4- 
gpio3_io22= (3-1)*32+22=86

a ->  echo 86 > /sys/class/gpio/export

b ->  echo "out" > /sys/class/gpio/gpio86/direction 

c ->  echo 1 > /sys/class/gpio/gpio86/value  
      echo 0 > /sys/class/gpio/gpio86/value 

But when I measure the pin I can't see 0-1. (There is no change in the pins.)

Do you know the solution for this error?

gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:
 gpio-10  (                    |reset               ) out hi ACTIVE LOW
 gpio-14  (                    |regulator-usb1-vbus ) out hi 

gpiochip1: GPIOs 32-63, parent: platform/30210000.gpio, 30210000.gpio:
 gpio-38  (                    |PCIe DIS            ) out hi 
 gpio-39  (                    |PCIe reset          ) out hi 
 gpio-44  (                    |cd                  ) in  lo IRQ ACTIVE LOW
 gpio-51  (                    |regulator-usdhc2    ) out hi 

gpiochip2: GPIOs 64-95, parent: platform/30220000.gpio, 30220000.gpio:
 gpio-80  (                    |status              ) out hi 

gpiochip3: GPIOs 96-127, parent: platform/30230000.gpio, 30230000.gpio:
 gpio-116 (                    |switch              ) out lo ACTIVE LOW
 gpio-123 (                    |regulator-can2-stby ) out lo 
 gpio-124 (                    |headphone detect    ) in  lo IRQ 
 gpio-125 (                    |regulator-audio-pwr ) out hi 

gpiochip4: GPIOs 128-159, parent: platform/30240000.gpio, 30240000.gpio:
 gpio-133 (                    |regulator-can1-stby ) out lo 
 gpio-141 (                    |spi_imx             ) out hi 

gpiochip5: GPIOs 496-511, parent: i2c/2-0020, 2-0020, can sleep:

 

0 Kudos
3 Replies

1,674 Views
edwardtyrrell
Senior Contributor I

Hi @ylmzhsn_ 

The /sys/class/gpio method has been deprecated on later kernels in favour of the gpio driver. The advice is to go with the new; it's also easy to use in C as it uses a proper driver..

gpiodetect List all gpiochips present on the system, their names, labels and number of GPIO lines
gpioinfo List all lines of specified gpiochips, their names, consumers, direction, active state and additional flags
gpioget Read values of specified GPIO lines
gpioset Set values of specified GPIO lines, potentially keep the lines exported and wait until timeout, user input or signal
gpiofind Find the gpiochip name and line offset given the line name
gpiomon Wait for events on GPIO lines, specify which events to watch, how many events to process before exiting or if the events should be reported to the console

To use these GPIO methods you will need to add them into your device tree unlike the /sys/class/gpio method.

Here's a link to an old answer of mine, there's also a bit of information on how to check the 'actual' registers of the iMx to see if your bits are getting changed. Warning - to use the gpioset method the you need to decrease the bank by 1 (explained in the link) as the GPIO methods start at bank 0

https://community.nxp.com/t5/i-MX-Processors/How-to-initial-GPIO-as-input-or-output-PINS/m-p/1561780 

.

Hope it helps!

 

0 Kudos

1,655 Views
ylmzhsn_
Contributor III

Hi @edwardtyrrell ,

imx-yocto-bsp/build/tmp/work-shared/imx8mpevk/kernel-source/arch/arm64/boot/dts/freescale

imx8mp-evk.dts:

&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog>;

pinctrl_og: hoggrp {
fsl,pins = <
MX8MP_IOMUXC_HDMI_DDC_SCL__HDMIMIX_HDMI_SCL 0x400001c3
MX8MP_IOMUXC_HDMI_DDC_SDA__HDMIMIX_HDMI_SDA 0x400001c3
MX8MP_IOMUXC_HDMI_HPD__HDMIMIX_HDMI_HPD 0x40000019
MX8MP_IOMUXC_HDMI_CEC__HDMIMIX_HDMI_CEC 0x40000019
MX8MP_IOMUXC_SAI5_RXD0__GPIO3_IO21 0x19
MX8MP_IOMUXC_SAI5_RXD1__GPIO3_IO22 0x19
MX8MP_IOMUXC_SAI5_RXD2__GPIO3_IO23 0x19
MX8MP_IOMUXC_SAI5_RXD3__GPIO3_IO24 0x19

>;
};

Am I editing this imx8mp-evk.dts file correctly?

Or do we edit it in imx8mp.dtsi?

I need to set the pin status to out.

When I did, there was still no change in the pin.

Set GPIO3_21 high:  // As above
gpioset gpiochip2 21=1

Set GPIO3_21 low:  // As above
gpioset gpiochip2 21=0

 

Best Regards,

Hasan Yılmaz

 

0 Kudos

1,614 Views
edwardtyrrell
Senior Contributor I

Hi @ylmzhsn_,

Looks alright, and using imx8mp-evk.dts is correct. The proper procedure would be to patch this file in your Yocto source otherwise you will lose all you changes if you edit the file in the build directly. Check the file after building for your changes. Also make sure you are actually pulling in your changes when building. That can be 'tested' by adding a bit of junk text in the file and making sure the build fails at that point.. 

Another thing to do is make sure those pins aren't being used elsewhere in the device tree. Check you boot log carefully to see if there's any errors or the pins are allocated to another driver.  Check if your sai5 node is using them too. Do a search using the string 'MX8MP_IOMUXC_SAI5_RXD1__GPIO3' (forget the last bit of the search string) and see if those pins in question are used in any other place. 

Cheers.

0 Kudos