I’m trying to figure out how to set the default state of a GPIO line in our carrier board specific device tree that we’ve created. This is GPIO6 IO12. According to the GPIO line mapping this is GPIO line 172, SODIMM line 169.
This GPIO line is normally low, but there is a period of time, usually between 2.5 and 3 seconds, on embedded Linux bootup where the line will go high and then back to low again where it will remain low until we export that GPIO line, set the direction to “out”, and then set the value to 1. Setting and clearing the value works great after embedded Linux is fully booted, but the initial setting of the GPIO line to high on OS bootup is creating a problem for us in our application of the i.MX7D Colibri board. We cannot have this happening.
After research I’ve found information that suggests this can be handled in the device tree, but I haven’t found anything that supplies instructions on how to do this.
I’ve verified that the pinmux for this GPIO line is set only to GPIO. There is no other node in the device tree that is claiming this line for use by a device driver.
How would I define something in the device tree that tells embedded Linux NOT to set this line high during bootup, or at any other time, until we are ready to set it high ourselves?
I believe that in our 4.1 downstream kernel the device tree does not allow to set an initial output state for a GPIO.
I guess the pulse you see is from U-Boot which muxes that pin to NAND_CE1.
Try to stop in U-Boot and see if the pin is set to ‘1’.
Thanks for your response.
Alex at Toradex provided information to set and clear GPIO lines from U-boot, as well as adding a script to bootcmd that allows the GPIO line change to occur every time the device is rebooted by doing the following:
# setenv set-io 'gpio set <gpio-number> ; gpio clear <gpio-number>'
# setenv bootcmd 'run set-io; <copy existing bootcmd here>'
I tried this, but it didn’t work. We are still seeing the GPIO line toggling for 2.5 to 3 seconds as before.
His other suggestion was to modify a source file that is built as part of U-boot. The file to modify is:
board/toradex/colibri_imx7/colibri_imx7.c. I added the following two lines to the end of the board_init() function:
gpio_request( 172, "SODIMM_PIN_169" );
gpio_direction_output( 172, 0 );
But this, still, is not working. We still see GPIO line go high for 2.5 to 3 seconds.
Using the following document: GPIO Alphanumeric to GPIO Numeric Assignment it appears that the line we want to set is
GPIO 172 = GPIO6 IO12 = SODIMM 169.
Is there a reason why this is not working?
Am I calling the
gpio_direction_output() function properly? I cannot find documentation that describe how these two functions work.
- Did you stop U-Boot by pressing a character on the serial console?
- Did then the pin have the output signal ‘1’ and stays there?
- If you then enter ‘boot’ to start Linux does the signal change to ‘0’?
If and only if the answer to the three questions is yes we found the culprit.
Then, and only then, remove the line I reference above to not touch the pinmuxing of said pin and I expect that the pulse goes away.
Thank you so much! This solved our problem! What is that pinmux used for in U-boot? Is that for NAND flash that’s available on one of your carrier boards?
Thanks again for your help with this!
The module is prepared for different NAND chips which might need that signal.
Cool. Thanks again max. Your response solved our problem. :).