Home/Support/Support Forum/How to properly configure GPIO in dts for ccimx6ul6bc?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How to properly configure GPIO in dts for ccimx6ul6bc?

0 votes
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>;
};
asked Mar 9, 2017 in Linux by cgamboni New to the Community (8 points)

Please log in or register to answer this question.

1 Answer

+1 vote
 
Best answer
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:
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.
answered Mar 10, 2017 by LeonidM Veteran of the Digi Community (2,755 points)
selected Mar 10, 2017 by cgamboni
...