diff options
Diffstat (limited to 'drivers/mfd/twl4030-irq.c')
-rw-r--r-- | drivers/mfd/twl4030-irq.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index b31f920feb51..a3dc1d929070 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c | |||
@@ -28,10 +28,13 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/export.h> | ||
31 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
32 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
33 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
34 | 35 | ||
36 | #include <linux/of.h> | ||
37 | #include <linux/irqdomain.h> | ||
35 | #include <linux/i2c/twl.h> | 38 | #include <linux/i2c/twl.h> |
36 | 39 | ||
37 | #include "twl-core.h" | 40 | #include "twl-core.h" |
@@ -53,6 +56,8 @@ | |||
53 | * base + 8 .. base + 15 SIH for PWR_INT | 56 | * base + 8 .. base + 15 SIH for PWR_INT |
54 | * base + 16 .. base + 33 SIH for GPIO | 57 | * base + 16 .. base + 33 SIH for GPIO |
55 | */ | 58 | */ |
59 | #define TWL4030_CORE_NR_IRQS 8 | ||
60 | #define TWL4030_PWR_NR_IRQS 8 | ||
56 | 61 | ||
57 | /* PIH register offsets */ | 62 | /* PIH register offsets */ |
58 | #define REG_PIH_ISR_P1 0x01 | 63 | #define REG_PIH_ISR_P1 0x01 |
@@ -695,14 +700,34 @@ int twl4030_sih_setup(int module) | |||
695 | /* FIXME pass in which interrupt line we'll use ... */ | 700 | /* FIXME pass in which interrupt line we'll use ... */ |
696 | #define twl_irq_line 0 | 701 | #define twl_irq_line 0 |
697 | 702 | ||
698 | int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) | 703 | int twl4030_init_irq(struct device *dev, int irq_num) |
699 | { | 704 | { |
700 | static struct irq_chip twl4030_irq_chip; | 705 | static struct irq_chip twl4030_irq_chip; |
706 | int irq_base, irq_end, nr_irqs; | ||
707 | struct device_node *node = dev->of_node; | ||
701 | 708 | ||
702 | int status; | 709 | int status; |
703 | int i; | 710 | int i; |
704 | 711 | ||
705 | /* | 712 | /* |
713 | * TWL core and pwr interrupts must be contiguous because | ||
714 | * the hwirqs numbers are defined contiguously from 1 to 15. | ||
715 | * Create only one domain for both. | ||
716 | */ | ||
717 | nr_irqs = TWL4030_PWR_NR_IRQS + TWL4030_CORE_NR_IRQS; | ||
718 | |||
719 | irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); | ||
720 | if (IS_ERR_VALUE(irq_base)) { | ||
721 | dev_err(dev, "Fail to allocate IRQ descs\n"); | ||
722 | return irq_base; | ||
723 | } | ||
724 | |||
725 | irq_domain_add_legacy(node, nr_irqs, irq_base, 0, | ||
726 | &irq_domain_simple_ops, NULL); | ||
727 | |||
728 | irq_end = irq_base + TWL4030_CORE_NR_IRQS; | ||
729 | |||
730 | /* | ||
706 | * Mask and clear all TWL4030 interrupts since initially we do | 731 | * Mask and clear all TWL4030 interrupts since initially we do |
707 | * not have any TWL4030 module interrupt handlers present | 732 | * not have any TWL4030 module interrupt handlers present |
708 | */ | 733 | */ |
@@ -747,7 +772,7 @@ int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) | |||
747 | goto fail_rqirq; | 772 | goto fail_rqirq; |
748 | } | 773 | } |
749 | 774 | ||
750 | return status; | 775 | return irq_base; |
751 | fail_rqirq: | 776 | fail_rqirq: |
752 | /* clean up twl4030_sih_setup */ | 777 | /* clean up twl4030_sih_setup */ |
753 | fail: | 778 | fail: |