Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

The legacy GPIO and IRQ chip

  1. The first step is to allocate a struct irq_domain to our gpiochip that will store the mapping between hwirq and virq. The linear mapping is suitable for us. We will do that in the probe function. That domain will hold the number of IRQs that our drivers wish to provide. For example, for an I/O expander, the number of IRQs could be the number of GPIOs the expander provides:
my_gpiochip->irq_domain = irq_domain_add_linear( client->dev.of_node, 
             my_gpiochip->chip.ngpio, &mcp23016_irq_domain_ops, NULL); 

The host_data parameter is NULL. Therefore, you can parse whatever data structure you need. Prior to allocating the domain, our domain ops structure should be defined, as follows:

static struct irq_domain_ops mcp23016_irq_domain_ops ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content