SetGPIOAltFn(

How to set Alternate function on the GPIO pin in embeded linux.
i have the windows version of setting GPIO pins using the available libs “gpiolib.lib”
Void initPins()
{
SetGPIOAltFn(TEGRA_GPIONUM(‘k’, 4), 1 , DIROUT);
SetGPIOAltFn(TEGRA_GPIONUM(‘w’, 0), -1 , DIRIN);
SetGPIOAltFn(TEGRA_GPIONUM(‘i’, 1), 2 , DIROUT);
SetGPIOAltFn(TEGRA_GPIONUM(‘u’, 1), 3 , DIROUT);

}

How do i achieve above in Embeded linux?
what i understand from the page “How to use GPIO library
is
i need to create files under pin_name_folder
@ “/sys/class/gpio/gpio14/value”
“/sys/class/gpio/gpio14/direction”
and set the desired value and direction for the PIN , however i dont know how to set the alternate function vlaue ?
hope i am clear. Please advice.

Thanks.

Unfortunately /sys/class/gpio can only be used for GPIO functionality. For other alternate functions you have to revert to the platform data here.

Thanks Marcel for reply. platform data ?
you mean change the value here …
#else /* COLIBRI_T30_V10 */
DEFAULT_PINMUX(GMI_AD0, GMI, NORMAL, NORMAL, INPUT),
and compile the linux kernel is the only way ?
Also , just now , i checked the tool GPIO Config , if i right click on the PIN number it gives option to change either GPIO or alternate in the Description column. ?

Thanks.

Yes, in the pre device tree times that was the only way to go. The GPIO Tool (formerly GPIOConfig) is only useful for experimenting with pins for evaluation purpose really.

Thanks Marcel,
I am going to check-out the kernel code and build the kernel with modified default PINMUX.
i see many indexed in the GIT repository,which one i should use to checkout the linuxkernelv2.6 (Colibri T30)?

Thanks.

Thanks Marcel,

You are very welcome.

I am going to check-out the kernel code and build the kernel with modified default PINMUX.

Yes, please note that such modifications are generally only required if using pins as anything else then GPIOs as for using pins as GPIOs one can simply export them via sysfs as explained in the following article on our developer website.

I see many indexed in the GIT repository,which one i should use to checkout the linuxkernelv2.6 (Colibri T30)?

I’m not exactly sure what you mean by indexed but the following article explains in detail how to do what you are up for. As for the exact kernel version of our BSP V2.6 you would be looking for the following git hash.

Thanks Marcel,
Do i need to build “openembedded” (core) as well before building the kernel ?

Thanks.

Thanks Marcel,

You are very welcome.

Do I need to build “openembedded” (core) as well before building the kernel?

No, this is only recommended if you intend to customise your image in any other way.

Hi Marcel,
One more query :slight_smile:
Do i need to deploy linux mudules again or new uImage installation is enough for changes done only in platformdata ?

Thanks.

Deploying kernel modules matching the actual kernel to be run is very much recommended.