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.

Timer Interrupt in Linux OMAP L138

Other Parts Discussed in Thread: OMAPL138

Hi

Iam new to the linux related devolpments in TI OMAP,Davinci... But i have good experience in the Firmware devolpment using the CCS IDE.. In my application, Linux runs in OMAP L138.. Every 5 us my application sw should perform SOC for the ADC.. I know using timer interrupt we can manage this.. But iam confused whether is it possible when using linux.. Is 5 us timer is possible.. i read somewhere it is 200Hz timer is safe while using Linux.. Kindly advise me on this

 

Regards

Vijayabharathi C

 

  •  

     

    Is it possible use same like in firmware with timer interrupt ie mapping to ISR , handling it using handler .. using traditional Interrupt API's like

    int request_irq(unsigned int irq,irqreturn_t (*handler)(int, void *, struct pt_regs *),unsigned long flags,const char *dev_name,void *dev_id);

    Kindly advise me or give me any example.. I found example GPIO interrupt program OMAP SDK.. i have some doubts over it

     

    /*
     * Copyright (C) 2009 Texas Instruments Inc
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
     * (at your option)any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     */

    #include <linux/module.h>
    #include <linux/version.h>
    #include <linux/delay.h>
    #include <linux/irq.h>
    #include <linux/interrupt.h>
    #include <linux/completion.h>
    #include <mach/cputype.h>
    #include <mach/hardware.h>
    #include <mach/mux.h>
    #include <asm/gpio.h>


    static int gpio_num;
    static int gpio_pin;

    DECLARE_COMPLETION(work);

    static irqreturn_t handler (int irq, void * dev)
    {
        complete_all(&work);
        return IRQ_HANDLED;
    }


    int init_module()
    {
        int status;

        init_completion(&work);

        if(cpu_is_davinci_da830()) {
            gpio_num = 87;    /* gpio_num = (bank_num * 16) + pin_num */
            gpio_pin = DA830_GPIO5_7;
        } else {
            gpio_num = 116;
            gpio_pin = DA850_GPIO7_4;
        }

        if (cpu_is_davinci_da830())   
            printk("\nTesting gpio %d (connected to boot pin S2-7)\n",
                gpio_num);
        else
            printk("\nTesting gpio %d (connected to boot pin S7-8)\n",
                gpio_num);

        /* init/set pinmux */
        status = davinci_cfg_reg(gpio_pin);
        if (status < 0) {
            printk("pin could not be muxed for GPIO functionality %d\n",
                                    gpio_num);
            return status;
        }
       
        status = gpio_request(gpio_num, "gpio_test\n");
        if (status < 0) {
            printk("ERROR can not open GPIO %d\n", gpio_num);
            return status;
        }

        gpio_direction_input(gpio_num);

        if (cpu_is_davinci_da830())
            printk("The current state of S2-7 pin is ");
        else
            printk("The current state of S7-8 pin is ");
        if(gpio_get_value(gpio_num) == 0)
            printk("OFF. \n\tWaiting for the pin to be on..\n");
        else
            printk("ON. \n\tWaiting for the pin to be off..\n");

        status = request_irq(gpio_to_irq(gpio_num), handler, 0, "gpio_test", NULL);
        if(status < 0) {
            printk(KERN_ERR "error %d requesting GPIO IRQ %d\n", status, gpio_num);
            return status;
        }

        set_irq_type(gpio_to_irq(gpio_num), IRQ_TYPE_EDGE_RISING);

        wait_for_completion_interruptible(&work);

        printk(".. done\n");

        return 0;
    }

    void cleanup_module(void) {
       
        gpio_free(gpio_num);

        free_irq(gpio_to_irq(gpio_num), NULL);
    }

    MODULE_LICENSE("GPL");

     

    Is wait_for_completion_interruptible(&work); is a general linux API?

    Where is the  " complete_all(&work);" Is complete_all API too general API?

     

    Regards

    VIjayabharathi C

  • hi vijayabharathi

    I am using omapl138 with linux and i want to install an interrupt handler with the signature to be able to read the interrupt flags

    irqreturn_t (*handler)(int, void *, struct pt_regs *)


    but the signature of the interrupt handler that i have in <linux/interrupt.h> is like

    irqreturn_t (*handler)(int, void *)

    the linux communites always refer to the the first version of the function

    Could  you tell me how can i use this version: irqreturn_t (*handler)(int, void *, struct pt_regs *) or how can i get the interrupt flags in the interrupt handler?

    Another question

    Is it possible to install two different interrupt handlers on the same interrupt line each having different flags?

    Thanks a lot