[PATCH 3/5] gpio/omap: Add DT support to GPIO driver

From
Linus Walleij <hidden>
Date
2013-02-27 23:41:06
Also in
linux-devicetree, linux-omap
Reply to
Benoit Cousson, 2012-02-15
On Wed, Feb 15, 2012 at 5:04 PM, Benoit Cousson [off-list ref] wrote:
quoted hunk ↗ jump to hunk
@@ -52,7 +55,8 @@ struct gpio_bank {
        struct list_head node;
        void __iomem *base;
        u16 irq;
-       u16 virtual_irq_start;
+       int irq_base;
+       struct irq_domain *domain;
This seems wrong. IRQ domains are used to avoid keeping track of
irq base offsets. I would even say it's the whole point of irq domains.
quoted hunk ↗ jump to hunk
@@ -669,7 +673,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
                if (!isr)
                        break;

-               gpio_irq = bank->virtual_irq_start;
+               gpio_irq = bank->irq_base;
                for (; isr != 0; isr >>= 1, gpio_irq++) {
                        gpio_index = GPIO_INDEX(bank, irq_to_gpio(gpio_irq));
Use irq_find_mapping(irqdomain, hwirq) in this function.

quoted hunk ↗ jump to hunk
@@ -915,7 +919,7 @@ static int gpio_2irq(struct gpio_chip *chip, unsigned offset)
        struct gpio_bank *bank;

        bank = container_of(chip, struct gpio_bank, chip);
-       return bank->virtual_irq_start + offset;
+       return bank->irq_base + offset;
Use irq_create_mapping() in this function.
quoted hunk ↗ jump to hunk
+       bank->irq_base = irq_alloc_descs(-1, 0, bank->width, 0);
+       if (bank->irq_base < 0) {
+               dev_err(dev, "Couldn't allocate IRQ numbers\n");
+               return -ENODEV;
+       }
+
+       bank->domain = irq_domain_add_legacy(node, bank->width, bank->irq_base,
+                                            0, &irq_domain_simple_ops, NULL);
Use irq_domain_add_simple() and the descs will be allocated for
you as part of the domain creation, when using a pre-fixed base.

If you fix this I suspect the device tree discussion also will fix
itself :-)

Documentation/IRQ-domain.txt

Yours,
Linus Walleij
Thread (43 messages) 43 messages, 10 authors, last reply 2013-03-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help