GPIO issues on Apalis iMX6 boot2qt 5.12.4

Hi,

I’m trying to set pins 183 and 185 on Apalis iMX6Q V1.1C IT as GPIO but wihout luck.
Here are used commands from user space

echo 159 > /sys/class/gpio/export
echo 160 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio159/direction
echo "out" > /sys/class/gpio/gpio160/direction
echo 1 > /sys/class/gpio/gpio159/value
echo 1 > /sys/class/gpio/gpio160/value

And here are modification of imx6qdl-apalis.dtsi:

&iomuxc {
	/* pins used on module */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_reset_moci>;

	pinctrl_lvds_ov_cam_1_pwr: gpio5io31grp {
		fsl,pins = <
			MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13 PAD_CTRL_HYS_PD
		>;
	};

	pinctrl_lvds_ov_cam_2_pwr: gpio6io00grp {
		fsl,pins = <
			MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14 PAD_CTRL_HYS_PD
		>;
	};

	pinctrl_apalis_gpio1: gpio2io04grp {
		fsl,pins = <
			MX6QDL_PAD_NANDF_D4__GPIO2_IO04 PAD_CTRL_HYS_PD
...

Since max9526 is using these pins I’ve set its status to “disabled” under imx6qdl-apalis-eval.dtsi.
Also added it in iomuxc in imx6qdl-apalis-eval.dtsi

&iomuxc {
	/*
	 * Mux the Apalis GPIOs.
	 * Note:
	 * - GPIO7 is used for PCIe reset
	 * - GPIO5, 6 are used by optional capacitive touch controller
	 */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_lvds_ov_cam_1_pwr &pinctrl_lvds_ov_cam_2_pwr
			&pinctrl_apalis_gpio1 &pinctrl_apalis_gpio2
		    &pinctrl_apalis_gpio3 &pinctrl_apalis_gpio4
		    &pinctrl_apalis_gpio5 &pinctrl_apalis_gpio6
		    &pinctrl_apalis_gpio7 &pinctrl_apalis_gpio8>;
};
...

I already read couple of threads on the topis but don’t seems to have success with any of provided solutions.
With Boot2Qt 5.11.3 all worked without any of above modifications however on 5.12.4 I can’t make it work. Could you please provide some pointers on what I’m doing wrong.

Just to note that when setting PU instead of PD there is expected voltage on these pins and it seems like they are stuck in HIGH Z.

Thanks in advance and best regards,
Ivan

Hi @IvanKarezic

Could you provide the exact Software Version of you module ( uname -a )? Which carrier board are you using?

Could you share all changes to the device tree files and the dmesg log in a text file?

Just to note that when setting PU instead of PD there is expected voltage on these pins and it seems like they are stuck in HIGH Z.

What is the Pin connected to on your carrier board? Could you provide a sample schematic?

Thanks and best regards,
Jaski

Hi Jaski,

Here are requested details:

Could you provide the exact Software Version of you module ( uname -a )? Which carrier board are you using?

Version on which GPIO are working fine is 4.1.44-2.7.5+g18717e2 and distro is Boot2Qt 5.11.3 (pyro).
Version I’m having problems with is 4.9.87-2.8.3+g07d40f6f, distro Boot2Qt 5.12.4 (sumo).

Could you share all changes to the device tree files and the dmesg log in a text file?

link text
Relevant changes are stated in initial post i.e. there are no other differences between 5.12.4 and 5.11.3. These changes are introduced only to try and make pins 183 and 185 work as GPIO.

What is the Pin connected to on your carrier board? Could you provide a sample schematic?

Carrier board is our own custom design.
As mentioned in first post, pins are 183 and 185.
Those work with 4.1.44 kernel with same HW configuration so I’m sure it’s not HW issue.

If you need more details please let me know.

Thanks in advance and best regards,
Ivan

Edit:
I removed all patches applied to device tree and kernel but still can’t use these two pins as GPIO.
While at it I also tried to set pin 16 and 18 as GPIO. They stay at 3V3 even when their value is set to “0”. Used following commands to do so:

echo 111 > /sys/class/gpio/export                                                                                                                                                                                                                                          
echo "out" > /sys/class/gpio/gpio111/direction                                                                                                                                                                                                                             
echo 0 > /sys/class/gpio/gpio111/value                                                                                                                                                                                                                                     
echo 1 > /sys/class/gpio/gpio111/value                                                                                                                                                                                                                                     
echo 110 > /sys/class/gpio/export                                                                                                                                                                                                                                          
echo "out" > /sys/class/gpio/gpio110/direction                                                                                                                                                                                                                             
echo 0 > /sys/class/gpio/gpio110/value                                                                                                                                                                                                                                     
echo 1 > /sys/class/gpio/gpio110/value

Hi Jaski,

I just went through relevant parts of reference manual for iMX6 and managed to make pin working by directily writing to registers using devmem2. Here are commands and values:

devmem2 0x20e0290
- 0x00000000
devmem2 0x20e0290 w 0x5
- 0x00000005 - Set CSI0_DATA14 as GPIO
devmem2 0x20e0660
- 0x0000B0B1 - Default Pad control register value, seams OK
devmem2 0x20b0000
- 0x80010DA0 - Value of GPIO6_00 is 0
devmem2 0x20b0000 w 0x80010DA1
- 0x80010DA1 - Now is 1 (3V3)
devmem2 0x20b0004
- 0x00000020 - Direction is "in"
devmem2 0x20b0004 w 0x21
- 0x00000021 - Set it to "out"

After that i tried to export GPIO once more and control it as usual it worked.

echo 160 > /sys/class/gpio/export
echo 0 > /sys/class/gpio/gpio160 // Properly sets pin to 0V
echo 1 > /sys/class/gpio/gpio160 // Properly sets pin to 3V3

Hope this helps.

Regards,

Ivan

Hi @IvanKarezic

Thanks for your reply. Sorry I did not see this before. For setting the Pins to GPIO, you need to use this Pin Muxing and not change the existing definition of Pin Muxing.

MX6QDL_PAD_CSI0_DAT13__GPIO5_IO31
MX6QDL_PAD_CSI0_DAT14__GPIO6_IO00

Best regards,
Jaski

Hi Jaski,

Managed to make it work by modifying mux_mode in imx6q-pinfunc.h as follows:

//Original settings
#define MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13     0x28c 0x65c 0x000 0x0 0x0
#define MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14     0x290 0x660 0x000 0x0 0x0

//Modified settings:
#define MX6QDL_PAD_CSI0_DAT13__IPU1_CSI0_DATA13     0x28c 0x65c 0x000 0x5 0x0
#define MX6QDL_PAD_CSI0_DAT14__IPU1_CSI0_DATA14     0x290 0x660 0x000 0x5 0x0

Hope it’ll help someneone else.

Regards,

Ivan