SODIMM #45 as GPIO on Colibri iMX6

we’re trying to use SODIMM pin 45 as GPIO, but attempt to export it ends up returning

echo 54 > /sys/class/gpio/export

-sh: echo: write error: Device or resource busy

note that we’re converting the GPIO #45 to numeral 54 as specified in http://developer.toradex.com/knowledge-base/gpio-alphanumeric-to-gpio-numeric-assignment

it does work for all other gpios. Some search returned #45 being used as a wake up, but no info about how to use it as sysfs gpio

it does work for all other gpios. Some search returned #45 being used as a wake up, but no info about how to use it as sysfs gpio

Yes. By default SODIMM_45 is configured as standard wake up source and cannot be used via sysfs GPIO. Have a look at this.

You will need to alter the device tree and use any other free GPIO as wakeup source to use SODIMM_45 as GPIO via GPIO sysfs. Refer modules data sheet for the list of possible free GPIOs which can be used as wake up source. Also note that as per Colibri standard only SODIMM_43 and SODIMM_45 are standard GPIO wake up sources.

A few questions:

  1. Is it possible not to have any wakeup source? That is, can I just delete the block relating to the wakeup in the device tree?
  2. if not, let’s say I want to use only the SODIMM_43 and leave the 45 for GPIO - I’m assuming this is the line I should change: gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>; but the question is: what should I change it to? That is, how to address the SODIMM_43 here
  3. once the device tree change is done in the said file, do I only need to bitbake the angstrom ( bitbake -k angstrom-lxde-image ) or I somehow need to enable/load this file first?

-1. Is it possible not to have any wakeup source? That is, can I just delete the block relating to the wakeup in the device tree?

Yes. If you do not need to wake up from suspend by a GPIO signal that you can delete the node gpio-keys with all its properties and subnodes.

-2. if not, let’s say I want to use only the SODIMM_43 and leave the 45 for GPIO - I’m assuming this is the line I should change: gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>; but the question is: what should I change it to? That is, how to address the SODIMM_43 here

To use SODIMM_43 (GPIO2_IO05) as a wakeup source you would have to remove it from its currently assigned function as the card detect pin for the MMC interface (e.g. here and here and you would want to mark the MMC to have no card detect so it uses polling)

Then you could set the pinmuxing of SODIMM_43 to GPIO here
‘MX6QDL_PAD_NANDF_D5__GPIO2_IO05 PAD_CTRL_HYS_PD’
and assign it as the wakeup source here.
gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;

-3. once the device tree change is done in the said file, do I only need to bitbake the angstrom ( bitbake -k angstrom-lxde-image ) or I somehow need to enable/load this file first?

We recommend doing kernel development outside of an OE build. For your case you would change the device-tree sources, build the device tree and then you could deploy it to a module by replacing the current one from the running Linux on the module in /media/mmcblk0p1.
Once you are happy with the results you would create a patch of your changes, add the patch to the openembedded recipe to get a deployable image of your changes.
This article might be of interest.

Max

Got it. One last question: if I’m removing the entire gpio-keys node (as in I don’t need the wake up functionality), do I need to separately re-enable SODIMM_45 for GPIO usage via sysfs, or it will be available for use as soon as I stop using it for wakeup?

The pin must be muxed to be GPIO. i.e. a reference to a pinctrl node containing the pin must be added to an active pinctrl-0 property.

e.g. add &pinctrl_gpio_keys to this list.

@max.tx you’re the man, thanks for the step by step explanation this worked well for the IMX7 I work with !

Perfect that it works. Thanks for the feedback.