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 driver for am1808 experimenters kit.

Other Parts Discussed in Thread: AM1808

Hi

I am using am1808 experimenters kit.I would like to write a GPIO driver as a loadable module. here i am giving the piece of code which i have implimented in IOCTL.

                       #define DA850_GPR_5P11 GPIO_TO_PIN(5,11)

      The configuration of GPIO is given here.

                        gpio_request(DA850_GPR_5P11,"dipswitch");
                        gpio_direction_output(DA850_GPR_5P11,1);
                        gpio_set_value(DA850_GPR_5P11,0x00);
                        gpio_free(DA850_GPR_5P11);

with this configuration i was unable to touggle the gpio pin. can u suggest me the proper way to touggle the GPIO pin. and proper gpio configurations to be done for tougling.
         

Regards

Vasu       

  • Hi Vasu,

    It is not clear if you have setup the pinmux correctly. You need to use the API davinci_cfg_reg() for that. Please see examples in arch/arm/mach-davinci/board-da850-evm.c.

    Also, you are writing a 1 and a 0 to the pin back to back. Please introduce a delay between these operations to see the pin toggle.

    Thanks,

    Sekhar

  • Just went through detailing the code changes for GPIO pinmux in another thread. Easy enough to repeat the changes here.

    The TRM numbers GPIOs from 1. Linux numbers from 0. Toggling GP5[11] means GPIO 92 in the TRM but 91 in Linux. Use 91 if you are using the user space GPIO sysfs instead of your own loadable module.

    Usually you must change the kernel to change the pinmux. Configuring the pinmux from userspace is not possible due to privilege problems. You might be able to do this from within a loadable module. Probably not as the pinmux functions and structures are not exported from the kernel. Note that some GPIOS might be used by other modules. GPIO5_11 is the same pin as EMA_A_11.

    You might be able to modify the pinmux registers directly. Tricky stuff with virtual address, privilege, lock registers and such.

    ----------------------------
    File: arch/arm/mach-davinci/da850.c
    ...
    static const struct mux_config da850_pins[] = {
    ...
        MUX_CFG(DA850, GPIO5_11,    11,    16,    15,    8,    false) //<--Add--
    #endif
    };
    ...

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

        DA850_GPIO5_11, //<--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 GPIO91_PIN        GPIO_TO_PIN(5, 11) //<--Add--
    ...
    static const short da850_my_gpio_pins[] = { //<--Add--
        DA850_GPIO5_11, //<--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();
    }
    ...

  • hello 

    i am also trying to use gpio of am1808

    can anybody give me the steps or any example code to use the gpio as input and output

    i have pinmux the gpio

    but i am not able to compile the code with my kernel header files and my arm compiler

    thanks