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 Access using sysfs

Other Parts Discussed in Thread: AM1808, DA8XX

Hi,

I am using LogicPD's Zoom AM1808 eXperimenter Kit with ti-sdk-am180x-evm-4.0.1.0 having linux-2.6.33-rc4-psp03.20.00.14.sdk & tisdk-rootfs-am180x-evm arago file system. I want to access GPIO from user space in linux.

I followed the procedure mentioned here  for GPIO 33, 34 & 81. I am able to change the direction of these pins but I am not able to change the value. They remain the same despite echoing 0 or 1.

What's going wrong?

  • Hi,

    I'm working on my customed am1808 board, linux-2.6.37 from linux-davinci branch of http://arago-project.org.

    I came across the same problem as yours.

    I followed http://processors.wiki.ti.com/index.php/Sitara_GPIO_Driver_User_Guide#Sysfs_control, but I can't change the value, and the gpios won't change.

    I'm sure the hardware is ok and the gpios have not been taked yet.

    Any clues?

    TIA & Best Regards!

  • Sorry, No response from TI...

  • did you make sure that those GPIOs you are trying to control are configured as GPIOs and not its alternate function?

    You can check out how this is done by searching for the function: "da8xx_pinmux_setup" and the macro "MUX_CFG".

    Hope that helps.

  • I suggest to enable PINMUX debug in kernel configuration, to be sure that required pins are configured as desired gpios.

    Please note that what Linux calls gpio-33 has GPIO PIN Number 34 in TRM, therefore it is GP2[1], aka register PINMUX6 offset 24.

    In this case you must have something like this:

        MUX_CFG(DA850, GPIO2_1,       6,    24,    15,    8,    false)

    and like that:

        davinci_cfg_reg(DA850_GPIO2_1);

    But be sure no other configurations conflict, eg a call to davinci_cfg_reg(DA850_EMA_WAIT_1), because it addresses the same pin:

        MUX_CFG(DA850, EMA_WAIT_1,    6,    24,    15,    1,    false)

    Hope this helps. I had no issue to configure and drive GPIOs on my AM1808 custom board.

    Regards, Max



  • Hi,

     We had also followed the same process before posting this question here. But we fail to toggle the gpio value using sysfs on our LogicPD's Zoom eXperimenter board.

    Any solution from TI guys ?

    Regards,

    Jitendra

  • The pinmux config is very likely the problem. The default kernel does not bring those GPIOs out to pins. GrantHatamosa and Qmax have given the answers you need to configure the pinmux.

    The TRM numbers GPIOs from 1. Linux numbers from 0. When you say that you are toggling GPIOs 33, 34 and 81, it is not clear which numbering system you are using. So TRM GPIO number 33,34,35,81,82 map to Linux 32,33,34,80,81. When using sysfs, you must use the Linux numbers.

    Usually you must change the kernel to change the pinmux. You might be able to do this from within a loadable module. Configuring the pinmux from userspace is not possible due to privilege problems. Below are some example changes. Note that some GPIOS might be used by other modules. GPIO2_1 is the same pin as EMA_WAIT_1. GPIO5_1 is the same pin as NUART0_RTS and MII_RXD_0. Remove configuration of the pins that conflict or you do not use.

    ----------------------------
    File: arch/arm/mach-davinci/da850.c
    ...
    static const struct mux_config da850_pins[] = {
    ...
        MUX_CFG(DA850, ECAP2_APWM2,    1,    0,    15,    4,    false)
        MUX_CFG(DA850, GPIO2_0,    6,    28,    15,    8,    false) //<--Add--
        MUX_CFG(DA850, GPIO2_1,    6,    24,    15,    8,    false) //<--Add--
        MUX_CFG(DA850, GPIO2_2,    6,    20,    15,    8,    false) //<--Add--
        MUX_CFG(DA850, GPIO5_0,    19,    28,    15,    8,    false) //<--Add--
        MUX_CFG(DA850, GPIO5_1,    3,    28,    15,    4,    false) //<--Add--
    #endif
    };
    ...

    ----------------------------
    File: arch/arm/mach-davinci/include/mach/mux.h
    ...
    enum davinci_da850_index {
    ...
        DA850_ECAP2_APWM2,

        DA850_GPIO2_0, //<--Add--
        DA850_GPIO2_1, //<--Add--
        DA850_GPIO2_2, //<--Add--
        DA850_GPIO5_0, //<--Add--
        DA850_GPIO5_1, //<--Add--
    };
    ...

    ----------------------------
    File: arch/arm/mach-davinci/board-da850-evm.c
    ...
    // Add these if you intend on using gpio_request(), etc. in
    // this file. Not required if you are using GPIO sysfs.
    // These are use 0 based numbering. Do no confuse with
    // the 1 based numbering in the TRM
    #define GPIO32_PIN        GPIO_TO_PIN(2, 0) //<--Add--
    #define GPIO33_PIN        GPIO_TO_PIN(2, 1) //<--Add--
    #define GPIO34_PIN        GPIO_TO_PIN(2, 2) //<--Add--
    #define GPIO80_PIN        GPIO_TO_PIN(5, 0) //<--Add--
    #define GPIO81_PIN        GPIO_TO_PIN(5, 0) //<--Add--
    ...
    static const short da850_my_gpio_pins[] = { //<--Add--
        DA850_GPIO2_0, //<--Add--
        DA850_GPIO2_1, //<--Add--
        DA850_GPIO2_2, //<--Add--
        DA850_GPIO5_0, //<--Add--
        DA850_GPIO5_1, //<--Add--
        -1 //<--Add--
    }; //<--Add--
    ...
    static __init void da850_evm_init(void)
    {
    ...
        ret = davinci_cfg_reg_list(da850_my_gpio_pins); //<--Add--
        if (ret) //<--Add--
            pr_warning("da850_evm_init: my gpio mux setup failed: %d\n", ret); //<--Add--

        /* initilaize usb module */
        da850_evm_usb_init();
    }
    ...