# How to properly configure GPIO in dts for ccimx6ul6bc?

**URL:** <https://forums.digi.com/t/how-to-properly-configure-gpio-in-dts-for-ccimx6ul6bc/18132>\
**Category:** Linux\
**Tags:** linux, gpio, ccimx6ulsbc, mca, yocto\
**Created:** [March 9, 2017, 3:58pm UTC](https://forums.digi.com/t/how-to-properly-configure-gpio-in-dts-for-ccimx6ul6bc/18132 "2017-03-09T15:58:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgamboni](https://avatars.discourse-cdn.com/v4/letter/c/919ad9/32.png) [@cgamboni](https://forums.digi.com/u/cgamboni)\
**Post date:** [March 9, 2017, 3:58pm UTC](https://forums.digi.com/t/how-to-properly-configure-gpio-in-dts-for-ccimx6ul6bc/18132/1 "2017-03-09T15:58:49Z")

</div>

As I currently understand it the ioexpander on the ccimx6ulsbc is not yet supported in 2.0-r5. I do however want to start working with the available GPIOs.

I believe I am able to use MCA\_IO2 as a gpio so I look to Documentation/devicetree/bindings/gpio/gpio-mca-cc6ul.txt. I see the entry

mca: mca-ccul@7e {  
gpio{  
compatible = “digi,mca-cc6ul-gpio”;  
gpio-controller;  
#gpio-cells = \<2\>;  
};  
};

What else am I missing to add this to imx6ul-ccimx6ulsbc-id135.dts? As it stands it would obviously cause a syntax error.

Also I want to get control of nets EXP\_GPIO\_3, EXP\_GPIO\_2, and EXP\_GPIO1 which are connected to GPIO1\_2, GPIO1\_3 and GPIO1\_5 respectively. As far as enabling these ports in the dts, do I look towards Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt? Also how do I map port and channel in the example provided?

gpio0: gpio@73f84000 {  
compatible = “fsl,imx51-gpio”, “fsl,imx35-gpio”;  
reg = \<0x73f84000 0x4000\>;  
interrupts = \<50 51\>;  
gpio-controller;  
#gpio-cells = \<2\>;  
interrupt-controller;  
#interrupt-cells = \<2\>;  
};

---

<div class="post-metadata">

**Author:** ![LeonidM](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@LeonidM](https://forums.digi.com/u/LeonidM)\
**Post date:** [March 10, 2017, 11:20am UTC](https://forums.digi.com/t/how-to-properly-configure-gpio-in-dts-for-ccimx6ul6bc/18132/2 "2017-03-10T11:20:52Z")

</div>

The formula to calculate the GPIO number in software is:  
32 \*(GPIO\_BANK-1)+GPIO\_Number = Software GPIO Number  
•example:  
GPIO3\_IO11  
32 \*(3–1)+11 = 75  
gpio75

MCA GPIOs are not supported yet, I believe, but you should be able to use i.mx6ul processor GPIOs

take a look here:

> **[Definitive GPIO guide - Studio Kousagi Wiki](https://www.kosagi.com/w/index.php?title=Definitive_GPIO_guide)**

also I do not think you need to modify device tree to use GPIO is it’s not defined there for something else. You can do it from user space:

Output GPIO (LED):  
A device node for GPIO75 is not set in our system, we have to create it using the console (GTKTerm):

# cd /sys/class/gpio

# ls

# echo 75 \> export

# echo out \> gpio75/direction

• To read and write GPIO values on the command line, use:

# cat gpio75/value

# echo 1 \> gpio75/value

# echo 0 \> gpio75/value

Input GPIO (button):  
A device node for GPIO67 is not set in our system, we have to create it using the console (GTKTerm):

# cd /sys/class/gpio

# ls

# echo 67 \> export

# echo in \> gpio67/direction

• To read GPIO value on the command line, use:

# cat gpio75/value

you can also do it from C code. Let me know if you need an example.
