GPIO Mapping

Hi,

I want to use some GPIO pins of Viola board as output pins, pin 8 / SODIMM135 and pin 9 / SODIMM 98 to be exact. Where can I find a document showing the relationship between the SODIMM pin or Viola board pin and the GPIO driver number? I’m trying to test executing the example showed on GPIO (Linux)

$ echo XXX > /sys/class/gpio/export
$ echo “out” > /sys/class/gpio/gpioXXX/direction
$ echo 1 > /sys/class/gpio/gpioXXX/value

Thanks

I try to use GPIO 89 GPIO Alphanumeric to GPIO Numeric Assignment and the commands:

$ echo 89 > /sys/class/gpio/export

$ echo “out” > /sys/class/gpio/gpio89/direction

$ echo 1 > /sys/class/gpio/gpio89/value

but with no success.

After a reboot I can use the instructions of the GPIO Alphanumeric to GPIO Numeric Assignment with success…

To obtain information of actual GPIO number available at SODIMM pins one need to refer
the modules datasheet list functions section and GPIO Alphanumeric to GPIO Numeric Assignment article

e.g.
SODIMM_pin: 135 | Vybrid_pad_name: PAD_89 | GPIO_number: 89

NOTE:
All free pins can be accessed via Linux standard GPIO sysfs inerface from userspace
and the free pins get pinmuxed to GPIO when exported through the GPIO sysfs.
To use any non standard pins as GPIOs one need to alter the device tree accordingly,
for more information regarding device tree customization refer the device tree
customization article

Thanks for reply

Hi,

there was any specific formula for the GPIO Mapping with SODIMM Pin.so I can easily calculate it and export gpio according to that. because of I am using Vf50 colibri module and it was difficult to find which gpio assign to which pin of SODIMM.

Hardware: Iris Carrier board V1.1A, Colibri module VF50
Thanks,
Best Regards,
Kanji Viroja.

Unfortunately there is no such formula available. May be you could use GPIO Config tool which has the information about GPIO mapping with SODIMM pins.

yes, you are right that tool available GPIOConfig. but I want to change pin control by program at runtime then How to jump one functionality to another. I had seen there was used multiplexing on gpio(IOMUXC_x Register) and it has 0-7 functionality each gpio.

could you share one of the example?which is helpful to me.

Many thanks
Regards
Kanji.

I think that is not possible since user space programs could not write on registers. The function of a pin can be customized on device tree.

@danieloak, @kanjiviroja
One cannot change the alternate function of SoC pads at runtime from user-space.
There is no interface provided for that even from kernel space at runtime. Ideally one need to configure the pin functions in device tree before hand.
GPIOConfig Tool is meant only for debugging. The way GPIO Config tool works is to mmap the GPIO, pin-mux registers and use the pins without the kernel knowing what it does, which may cause unknown behaviour. We recommend not to directly manipulate GPIO or pin-mux from user-space.

Thank you both of you :slight_smile:

@kanjiviroja, controlling the functionality of the pins and which driver is owning it is clearly something which the operating system should handle. And as @bhuvanchandra.dv says, there is no kernel interface to influence this directly.

However, you can influence it indirectly. The kernel muxes a pin automatically when its driver gets loaded, or when a GPIO get exported. Only one device can actively control a pin, you can see the current controlling device driver in

/sys/kernel/debug/pinctrl/40048000.iomuxc/pinmux-pins

If you plan to use a pin for two things (e.g. GPIO and UART), just make sure the pinmux for the two options are part of your device tree, and use the bind/unbind option to unbind the serial driver:

echo 40028000.serial > /sys/bus/platform/drivers/fsl-lpuart/unbind

After that, you will be able to use it as GPIO

echo 26 > /sys/class/gpio/export

You can also do the opposite, unexport the GPIO and (re)bind the UART driver.

What functionality are you trying to switch between? What is your exact use case?