October 2017
Intermediate to advanced
586 pages
14h 8m
English
Input GPIOs can often be used as IRQ signals. Such IRQs can be edge-triggered or level-triggered. The configuration depends on your needs. The GPIO controller is responsible for providing the mapping between the GPIO and its IRQ. You can use gpio_to_irq() to map a given GPIO number to its IRQ number:
int gpio_to_irq(unsigned gpio);
The return value is the IRQ number, on which you can call request_irq() (or the threaded version request_threaded_irq()) in order to register a handler for this IRQ:
static irqreturn_t my_interrupt_handler(int irq, void *dev_id) { [...] return IRQ_HANDLED; } [...] int gpio_int = of_get_gpio(np, 0); int irq_num = gpio_to_irq(gpio_int); int error = devm_request_threaded_irq(&client->dev, irq_num, ...Read now
Unlock full access