Enabling GPIO Without Recompiling Kernel

Recently I needed to access a GPIO signal on the CM-FX6.


After searching, to convert from the iMX6 multifunction signal to the gpioXX number in Linux userspace, you have to do the following :

linux gpio number = (gpio_bank – 1) * 32 + gpio_bit

For GPIO2_25,

XX = (2 – 1) * 32 + 25  = 57

However, doing this

# echo 57 > /sys/class/gpio/export

# echo out > /sys/class/gpio/gpio57/direction

# echo 1 > /sys/class/gpio/gpio57/value

still didn’t work. Reading, I realised you need to ensure that the multiplexer on the card itself is set to use GPIO2_25. Search for GPIO2_25 in  http://compulab.co.il/wp-content/uploads/2014/07/CM-FX6-reference-guide.pdf The corresponding iMX6 Mux Pad value is EIM_OE Look up EIM_OE in iMX6 Reference Manual http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf?fasp=1&WT_TYPE=Reference%20Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation&fileExt=.pdf You will realise that you need to set IOMUXC_SW_MUX_CTL_PAD_EIM_OE_B at physical memory 20E_0100h So that means you have to add the corresponding code and recompile the kernel, right? But you may not want to do so, for various reasons. What you can do is this : Make use of the “devmem2” application. Make sure that you are root.

1) Download it:

# wget http://utilite-computer.com/download/utilite/tools/devmem2

2) Make it executable:

# chmod +x devmem2

3) Read the IOMUXC_SW_MUX_CTL_PAD_EIM_OE value # ./devmem2 0x20E0100

4) Set the IOMUXC_SW_MUX_CTL_PAD_EIM_OE value # ./devmem2 0x20E0100 w 5

Check it :

# echo 57 > /sys/class/gpio/export

# echo out > /sys/class/gpio/gpio57/direction

# echo 1 > /sys/class/gpio/gpio57/value

Measure the voltage from this pin on your baseboard, it should give ~3.3v. You need to set the multiplexer values in /etc/rc.local as it is not persistent. References: http://www.kosagi.com/w/index.php?title=Definitive_GPIO_guide


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s