tommessum
tommessum

Reputation: 95

GPIO pin Interrupt handlers in linux (arm)

Can somebody point me at some sample code for enabling and handling user pin IO interrupts (C language) for an ARM9 in linux?

I am aware that a low level driver may be needed, I just want to get some ideas on how to initialise it, then handle the messaging at the user level etc.

I am familiar with ARM interrupts, and device drivers (in Windows) but I am new to linux programming.

thanks

Upvotes: 3

Views: 4962

Answers (1)

Igor Skochinsky
Igor Skochinsky

Reputation: 25318

It really depends on the actual BSP you're using. AFAIK there's no "generic ARM9 gpio interrupt" in Linux, it's pretty much board-specific. E.g. here's an example for a PCA100 board:

static int pca100_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
                void *data)
{
        int ret;

        ret = request_irq(IRQ_GPIOC(29), detect_irq,
                          IRQF_DISABLED | IRQF_TRIGGER_FALLING,
                          "imx-mmc-detect", data);
        if (ret)
                printk(KERN_ERR
                        "pca100: Failed to reuest irq for sd/mmc detection\n");

        return ret;
}

static void pca100_sdhc2_exit(struct device *dev, void *data)
{
        free_irq(IRQ_GPIOC(29), data);
}

Upvotes: 4

Related Questions