diff options
Diffstat (limited to 'arch/microblaze/kernel/intc.c')
| -rw-r--r-- | arch/microblaze/kernel/intc.c | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c index 44b177e2ab12..ad120672cee5 100644 --- a/arch/microblaze/kernel/intc.c +++ b/arch/microblaze/kernel/intc.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
| 12 | #include <linux/irqdomain.h> | ||
| 12 | #include <linux/irq.h> | 13 | #include <linux/irq.h> |
| 13 | #include <asm/page.h> | 14 | #include <asm/page.h> |
| 14 | #include <linux/io.h> | 15 | #include <linux/io.h> |
| @@ -25,8 +26,6 @@ static unsigned int intc_baseaddr; | |||
| 25 | #define INTC_BASE intc_baseaddr | 26 | #define INTC_BASE intc_baseaddr |
| 26 | #endif | 27 | #endif |
| 27 | 28 | ||
| 28 | unsigned int nr_irq; | ||
| 29 | |||
| 30 | /* No one else should require these constants, so define them locally here. */ | 29 | /* No one else should require these constants, so define them locally here. */ |
| 31 | #define ISR 0x00 /* Interrupt Status Register */ | 30 | #define ISR 0x00 /* Interrupt Status Register */ |
| 32 | #define IPR 0x04 /* Interrupt Pending Register */ | 31 | #define IPR 0x04 /* Interrupt Pending Register */ |
| @@ -84,24 +83,45 @@ static struct irq_chip intc_dev = { | |||
| 84 | .irq_mask_ack = intc_mask_ack, | 83 | .irq_mask_ack = intc_mask_ack, |
| 85 | }; | 84 | }; |
| 86 | 85 | ||
| 87 | unsigned int get_irq(struct pt_regs *regs) | 86 | static struct irq_domain *root_domain; |
| 87 | |||
| 88 | unsigned int get_irq(void) | ||
| 88 | { | 89 | { |
| 89 | int irq; | 90 | unsigned int hwirq, irq = -1; |
| 90 | 91 | ||
| 91 | /* | 92 | hwirq = in_be32(INTC_BASE + IVR); |
| 92 | * NOTE: This function is the one that needs to be improved in | 93 | if (hwirq != -1U) |
| 93 | * order to handle multiple interrupt controllers. It currently | 94 | irq = irq_find_mapping(root_domain, hwirq); |
| 94 | * is hardcoded to check for interrupts only on the first INTC. | 95 | |
| 95 | */ | 96 | pr_debug("get_irq: hwirq=%d, irq=%d\n", hwirq, irq); |
| 96 | irq = in_be32(INTC_BASE + IVR) + NO_IRQ_OFFSET; | ||
| 97 | pr_debug("get_irq: %d\n", irq); | ||
| 98 | 97 | ||
| 99 | return irq; | 98 | return irq; |
| 100 | } | 99 | } |
| 101 | 100 | ||
| 101 | int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) | ||
| 102 | { | ||
| 103 | u32 intr_mask = (u32)d->host_data; | ||
| 104 | |||
| 105 | if (intr_mask & (1 << hw)) { | ||
| 106 | irq_set_chip_and_handler_name(irq, &intc_dev, | ||
| 107 | handle_edge_irq, "edge"); | ||
| 108 | irq_clear_status_flags(irq, IRQ_LEVEL); | ||
| 109 | } else { | ||
| 110 | irq_set_chip_and_handler_name(irq, &intc_dev, | ||
| 111 | handle_level_irq, "level"); | ||
| 112 | irq_set_status_flags(irq, IRQ_LEVEL); | ||
| 113 | } | ||
| 114 | return 0; | ||
| 115 | } | ||
| 116 | |||
| 117 | static const struct irq_domain_ops xintc_irq_domain_ops = { | ||
| 118 | .xlate = irq_domain_xlate_onetwocell, | ||
| 119 | .map = xintc_map, | ||
| 120 | }; | ||
| 121 | |||
| 102 | void __init init_IRQ(void) | 122 | void __init init_IRQ(void) |
| 103 | { | 123 | { |
| 104 | u32 i, intr_mask; | 124 | u32 nr_irq, intr_mask; |
| 105 | struct device_node *intc = NULL; | 125 | struct device_node *intc = NULL; |
| 106 | #ifdef CONFIG_SELFMOD_INTC | 126 | #ifdef CONFIG_SELFMOD_INTC |
| 107 | unsigned int intc_baseaddr = 0; | 127 | unsigned int intc_baseaddr = 0; |
| @@ -146,16 +166,9 @@ void __init init_IRQ(void) | |||
| 146 | /* Turn on the Master Enable. */ | 166 | /* Turn on the Master Enable. */ |
| 147 | out_be32(intc_baseaddr + MER, MER_HIE | MER_ME); | 167 | out_be32(intc_baseaddr + MER, MER_HIE | MER_ME); |
| 148 | 168 | ||
| 149 | for (i = IRQ_OFFSET; i < (nr_irq + IRQ_OFFSET); ++i) { | 169 | /* Yeah, okay, casting the intr_mask to a void* is butt-ugly, but I'm |
| 150 | if (intr_mask & (0x00000001 << (i - IRQ_OFFSET))) { | 170 | * lazy and Michal can clean it up to something nicer when he tests |
| 151 | irq_set_chip_and_handler_name(i, &intc_dev, | 171 | * and commits this patch. ~~gcl */ |
| 152 | handle_edge_irq, "edge"); | 172 | root_domain = irq_domain_add_linear(intc, nr_irq, &xintc_irq_domain_ops, |
| 153 | irq_clear_status_flags(i, IRQ_LEVEL); | 173 | (void *)intr_mask); |
| 154 | } else { | ||
| 155 | irq_set_chip_and_handler_name(i, &intc_dev, | ||
| 156 | handle_level_irq, "level"); | ||
| 157 | irq_set_status_flags(i, IRQ_LEVEL); | ||
| 158 | } | ||
| 159 | irq_get_irq_data(i)->hwirq = i - IRQ_OFFSET; | ||
| 160 | } | ||
| 161 | } | 174 | } |
