GPIO output not working on Colibri imx6

Hello,
we would like to use gpios 9 14 15 36 40 41 42 43 52 53 82 90 91 113 117 118 121 122 127 165 175 on Colibri imx6 for input/output, but none of these work for output when tested.

# cd /sys/class/gpio
# echo 9 >export
# echo out >gpio9/direction
# echo 1 >gpio9/value
# cat gpio9/value
0
#

We are using the default kernel Linux colibri-imx6 3.10.17. We have also tried to remove PWM support from the kernel, but the result is the same - when trying to set gpio value to 1, none of these gpio ports change the actual value.

You need to disable any interfaces currently using these pins in the device tree. Since the bootloader may have initialized some pins as something besides GPIO, you’ll want to ensure that the pins are reconfigured for GPIO in the kernel by defining them as such in the device tree.

A similar question/answer is provided here: https://www.toradex.com/community/questions/1788/disable-lcd-for-gpio.html

Please refer to our developer website regarding Device Tree Customization.

You may also find our GPIOConfig tool useful for testing & verification.

Furthermore, I see you’re using a bit of a older kernel. Although this shouldn’t impact this particular issue, you might consider upgrading to the latest Linux image for Colibri iMX6.

I have found that SION bit needs to be set for us to be able to read back value of an output GPIO.
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/295260

I tried to add this to our &iomuxc in device tree, but this doesn’t work :frowning:

&iomuxc {
    ...

    ngrt {
        pinctrl_additionalgpio: additionalgpios {
            fsl,pins = <
                0x240 0x610 0x000 0x15 0x0 PAD_CTRL_HYS_PU
                ...
            >;
        };
    };
};

The values are grepped from imx6dl-pinfunc.h for the gpios we want - the first line is from macro MX6QDL_PAD_GPIO_9__GPIO1_IO09, which expands to 0x240 0x610 0x000 0x5 0x0. I have changed the 4th value to 0x15 to enable the SION bit, as is in http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/273209.html
but it doesn’t work. Any ideas someone?

Does the control of the output actually work? e.g. when you toggle the output with
echo 1 >gpio9/value
echo 0 >gpio9/value
do you see the change on the actual pin?


Note that the pinmux driver evaluates bit 30 of the CONFIG byte to set the SION bit.

So in the device tree you could write the above also like this:

fsl,pins = <
    MX6QDL_PAD_GPIO_9__GPIO1_IO09 ((1<<30) | PAD_CTRL_HYS_PU)
                 ...
             >;