This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Initialisation of GPIO in kernel for OMAPL137EVM

Other Parts Discussed in Thread: OMAP-L137, OMAP3530

Hi all,

I am using the OMAPL137 EVM and trying the simple led driver.  I am not getting any response.

The data sheet says the GPIO are initalized by default. If so how should i come to know?

I tried at the u-boot level the led is working fine. I want to know how to initalize GPIO in the kernel..

If some can tell me the link or help me out, it will be of great help....

The kernel i am using is 2.6.18

Thanks in advance...

 

Regards,

Lokesh

  • In kernel enable Gpio support.

    drivers ->GPIO Suport

    and sys interface also.

    [* ]   /sys/class/gpio/... (sysfs interface).

    After this load the new kernel.

    Now the gpio required should be exported

    echo "gpio_no"> /sys/class/gpio/export

    Make the direction as output.

    echo "out" >/sys/class/gpio/gpio$gpio_no/direction

    To make it high

    echo "1" >/sys/class/gpio/gpio$gpio_no/value

    Hope this helps

    Nikhil Varghese

  • Hi all/Nikhil,

     

    Thanks for that suggestion.... but

    I am unable to see

    drivers ->GPIO Support    In Kernel driver Support.

    as i told i am using kernel version 2.6.18, the other kernel versions(2.6.37.1 / 2.6.27.57) shows this and i tried, it stucks at

    Uncompressing Linux...

    So, if some one can tell me the solution for Initializing or Enabling the GPIO in kernel version 2.6.18, for OMAPL137 EVM.

    If there is any patch for GPIO initalization in kernel 2.6.18, that also will help....

    or what i am making mistake in compilation so that all the kernel version are stopping at Uncompressing Linux...

    Thanks in advance....

     

    Regards,

    Lokesh

     

     

  • Hi lokesh

     

    Use latest kernel.

     

    Thanks and regards

    Nikhil

  • Hi Nikhil,

     

    I used the latest kernel 2.6.37.2 from kernel.org website.  It is having the GPIO support in menuconfig , it compiles as well, but it stops at Uncompressing linux....

    I am having kernel version 2.6.18 with me which does not show GPIO support in menuconfig....

    Please if you can  help me for this problem....

    mean while i will be trying with the other kernel versions also...

     

    Regards,

    Lokesh

  • Hi Lokesh,

    The initial PG versions of OMAP-L137 have an errata because of which cache does not work in write-back mode. So, you need to configure the cache in write-through mode (in kernel configuration) and also apply this patch:

    http://git.kernel.org/?p=linux/kernel/git/khilman/linux-davinci.git;a=commit;h=bc2b2f75fa8ae4e8e90ee1c84b7bb471c1b6a219

    Thanks,

    Sekhar

  • Hi lokesh

    Try  the following command on the kernel,

     

    #devmem <gpio direction adress>

    if its direction is correct

    #devmem <gpio out_data reg address> 32 <HEX val>

     

     

  • Hi All / Shadakshari KP,

     

    Thanks for that post but, when i use devmem it says

    "bash command not found"

    if you can tell me how to solve the problem of devmem in the board may it helps... I am now using kernel version 03.20.00.14.

    Thanks,

    Lokesh

  • Hi Sekar Nori,

     

    Thanks for the post...

    it helped me but still i am unable to get the GPIO pin toggling...

    I am getting /sys/class/gpio/ .....

    Plz tell me what i am doing wrong.......

     

    Thanks

    Lokesh

  • Hi all,

    I am using the same in omap3530 cortex A8 (Angstrom),  it is working in output device (led).  Sample code for LED is

    #include <stdio.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/ipc.h>
    #include <sys/ioctl.h>
    #include <fcntl.h>

    #define LED0 "/sys/class/leds/led0/brightness"
    #define LED1 "/sys/class/leds/led1/brightness"
    #define LED2 "/sys/class/leds/led2/brightness"

    int main(int argc, char *argv[])
    {
            int f_led0, f_led1, f_led2;
            unsigned char i = 0;
            unsigned char dat0, dat1, dat2;

            if((f_led0 = open(LED0, O_RDWR)) < 0)
            {
                printf("error in open %s",LED0);
                return -1;
            }
            if((f_led1 = open(LED1, O_RDWR)) < 0)
            {
                printf("error in open %s",LED1);
                return -1;
            }
            if((f_led2 = open(LED2, O_RDWR)) < 0)
            {
                printf("error in open %s",LED2);
                return -1;
            }
            printf("led location %d  %d  %d",f_led0,f_led1,f_led2);


            for(;;)
            {
                i++;
                dat0 = i&0x1 ? '1':'0';
                dat1 = (i&0x2)>>1 ? '1':'0';
                dat2 = (i&0x4)>>2 ? '1':'0';

                printf("data=%d  %d  %d",dat0,dat1,dat2);


                write(f_led0, &dat0, sizeof(dat0));
                write(f_led1, &dat1, sizeof(dat1));
                write(f_led2, &dat2, sizeof(dat2));
                usleep(300000);
            }
    }

     

    For the same above, i need for Keypad. I am using GPIO158 and GPIO156, 2 pins are connected to keypad,

     

    I used echo command, but it is not working, how read key value from GPIO158 and GPIO156 also.

    Anyone having code send me the code, it is urgent for me.

    My email id is sasi2103@gmail.com.

    Advance

    Thanks

    Sasikumar. M