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.

GPIO accessing in User Space

Other Parts Discussed in Thread: OMAP3530

Hi,

     We are using OMAP3530 based custom support board. In that board we are provided GPIO's 12,13,14,15,16,17,18,19,20,21,22, and 140,141,149,150 .  Using the following commands i can able to toggle gpio 150,140,141 but rest of gpio's  mentioned above.

Commands :

In linux prompt : echo N > /sys/class/gpio/export

echo out > /sys/class/gpio/gpioN/direction

echo 1 > /sys/class/gpio/gpioN/value

Where N is GPIO number.

For all gpio's it is creating corresponding gpioN . We are using linux kernel in this bundle  AM35x-OMAP35x-Linux-PSP-04.02.00.07 .

Please help on this. 

Thanks

bhimesh

  • Check that the non-working GPIOs are pinmuxed to the GPIO function.

  • Hi,

         In board-omap3beagle.c file mux padding also did correctly.

    OMAP3_MUX(ETK_CLK, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_CTL,OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D0,OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D1,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D2,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D3,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D4,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D5,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(ETK_D6,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(MCBSP3_DX,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(MCBSP3_DR,OMAP_MUX_MODE4| OMAP_PIN_OUTPUT),

    OMAP3_MUX(UART1_TX,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    OMAP3_MUX(UART1_CTS,OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),

    OMAP3_MUX(UART1_RTS,OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),

    I think muxing also properly set. Observe above details

    Thanks

    bhimesh

  • I am guessing that after your mux initializations are being overwritten by other modules. My guess would be that the driver for either sdmmc3 or hsusb1 is starting up.

  • Hi,

        In u-boot level  MUX seetings also done for none working GPIO's in USERSPACE.  In kernel level  i can able to toggle the  GPIO'S from  12 to 21 .

    Thanks

    bhimesh 

  • Not quite understanding. To review:

    U-Boot - MUX is configured for 12-22,140,141,149,150.
    Kernel - MUX is configured for 12-22,140,141,149,150

    140,141,150 - Good. Can toggle using sysfs in userspace.
    12-22,149 - Good. Can toggle in kernel code.
    12-22,149 - Bad. Cannot toggle using sysfs in userspace.

    I think you are missing configs lines for 21 and 22:

    OMAP3_MUX(ETK_D7,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),
    OMAP3_MUX(ETK_D8,OMAP_MUX_MODE4|OMAP_PIN_OUTPUT),

    When you say you can toggle the gpio pins from the kernel, where in the kernel code did you do this?

    Not quite understanding.
  • Hi bhimesh,

    1. You can check the GPIO values which are used in the kernel by using debugfs.

    a. $ mount -t debugfs debugfs /sys/kernel/debug

    b. $ cat /sys/kernel/debug/gpio

    2. By using mux entries we can identify which pins are used for which purpose, by using debugfs

    follow this posts http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/716/t/168911.aspx

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Hi all:

    I 've done this before!

    which gpio pin you want to toggle,

    just do muxing in u-boot as gpio mode then, in kernel you just request that pin, set as output / input then,

    toggle it by set and clear function!!!!!!!!!!!

    It will work!

    Regards,

    santosh vastrad

  • Hi Anilkumar,

                         Thanks for the support . The GPIO's which are unable to toggle in user space set into MODE3 inspite of the mux initialization in kernel into MODE4. So, some other drivers are changing these GPIO's into mode3 . So in __init omap3_beagle_init function again i called the mux intialization function omap3_mux_init().

    So that all the gpio's are set in the mode4 not in mode3

    Thanks

    bhimesh

  • You probably should disable or remove the driver using mode3 rather than overwriting the drivers mux config. The driver might use the pins during the brief period that it has them. You might get unexpected activity on the pins. Or the driver may behave erratically if not connected to the pins. Worst case you might get a kernel panic. Mode3 looks to be the hsusb1 used in usb-ehci.c. Changes

    1) Unconfig the USB module from the kernel. The define is CONFIG_USB_EHCI_HCD.

    Device Drivers
    ->USB Support
    --->USB HOst Controller
    ----->EHCI HCD (YSB 2.0) Support

    2) Optionally, comment out the call to usb_ehci_init() in board-omap3beagle.c.

  • Hi , 

          I  want to  export my gpio pin uart0_rtsn gpio1_9 to user space. How to convert the gpio number to generic number like 

     echo N > /sys/class/gpio/export. I'm using am335xevm board.
    
    
    Please reply.
    thanks,
    shrisha