viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 1 | /* |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 2 | * SPEAr platform shared irq layer source file |
| 3 | * |
Viresh Kumar | df1590d | 2012-11-12 22:56:03 +0530 | [diff] [blame] | 4 | * Copyright (C) 2009-2012 ST Microelectronics |
Viresh Kumar | 10d8935 | 2012-06-20 12:53:02 -0700 | [diff] [blame] | 5 | * Viresh Kumar <viresh.linux@gmail.com> |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 6 | * |
Viresh Kumar | df1590d | 2012-11-12 22:56:03 +0530 | [diff] [blame] | 7 | * Copyright (C) 2012 ST Microelectronics |
Viresh Kumar | 9cc2368 | 2014-04-18 15:07:16 -0700 | [diff] [blame] | 8 | * Shiraz Hashim <shiraz.linux.kernel@gmail.com> |
Viresh Kumar | df1590d | 2012-11-12 22:56:03 +0530 | [diff] [blame] | 9 | * |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 10 | * This file is licensed under the terms of the GNU General Public |
| 11 | * License version 2. This program is licensed "as is" without any |
| 12 | * warranty of any kind, whether express or implied. |
| 13 | */ |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 15 | |
| 16 | #include <linux/err.h> |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 17 | #include <linux/export.h> |
| 18 | #include <linux/interrupt.h> |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 19 | #include <linux/io.h> |
| 20 | #include <linux/irq.h> |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 21 | #include <linux/irqdomain.h> |
| 22 | #include <linux/of.h> |
| 23 | #include <linux/of_address.h> |
| 24 | #include <linux/of_irq.h> |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 25 | #include <linux/spinlock.h> |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 26 | |
Rob Herring | e9c5155 | 2013-01-02 09:37:56 -0600 | [diff] [blame] | 27 | #include "irqchip.h" |
| 28 | |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 29 | /* |
| 30 | * struct shirq_regs: shared irq register configuration |
| 31 | * |
| 32 | * enb_reg: enable register offset |
| 33 | * reset_to_enb: val 1 indicates, we need to clear bit for enabling interrupt |
| 34 | * status_reg: status register offset |
| 35 | * status_reg_mask: status register valid mask |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 36 | */ |
| 37 | struct shirq_regs { |
| 38 | u32 enb_reg; |
| 39 | u32 reset_to_enb; |
| 40 | u32 status_reg; |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /* |
| 44 | * struct spear_shirq: shared irq structure |
| 45 | * |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 46 | * base: Base register address |
| 47 | * regs: Register configuration for shared irq block |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 48 | * mask: Mask to apply to the status register |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 49 | * virq_base: Base virtual interrupt number |
| 50 | * nr_irqs: Number of interrupts handled by this block |
| 51 | * offset: Bit offset of the first interrupt |
| 52 | * disabled: Group is disabled, but accounted |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 53 | */ |
| 54 | struct spear_shirq { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 55 | void __iomem *base; |
| 56 | struct shirq_regs regs; |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 57 | u32 mask; |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 58 | u32 virq_base; |
| 59 | u32 nr_irqs; |
| 60 | u32 offset; |
| 61 | bool disabled; |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 64 | static DEFINE_SPINLOCK(lock); |
| 65 | |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 66 | /* spear300 shared irq registers offsets and masks */ |
| 67 | #define SPEAR300_INT_ENB_MASK_REG 0x54 |
| 68 | #define SPEAR300_INT_STS_MASK_REG 0x58 |
| 69 | |
| 70 | static struct spear_shirq spear300_shirq_ras1 = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 71 | .offset = 0, |
| 72 | .nr_irqs = 9, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 73 | .mask = ((0x1 << 9) - 1) << 0, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 74 | .regs = { |
| 75 | .enb_reg = SPEAR300_INT_ENB_MASK_REG, |
| 76 | .status_reg = SPEAR300_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 77 | }, |
| 78 | }; |
| 79 | |
| 80 | static struct spear_shirq *spear300_shirq_blocks[] = { |
| 81 | &spear300_shirq_ras1, |
| 82 | }; |
| 83 | |
| 84 | /* spear310 shared irq registers offsets and masks */ |
| 85 | #define SPEAR310_INT_STS_MASK_REG 0x04 |
| 86 | |
| 87 | static struct spear_shirq spear310_shirq_ras1 = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 88 | .offset = 0, |
| 89 | .nr_irqs = 8, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 90 | .mask = ((0x1 << 8) - 1) << 0, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 91 | .regs = { |
| 92 | .enb_reg = -1, |
| 93 | .status_reg = SPEAR310_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct spear_shirq spear310_shirq_ras2 = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 98 | .offset = 8, |
| 99 | .nr_irqs = 5, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 100 | .mask = ((0x1 << 5) - 1) << 8, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 101 | .regs = { |
| 102 | .enb_reg = -1, |
| 103 | .status_reg = SPEAR310_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 104 | }, |
| 105 | }; |
| 106 | |
| 107 | static struct spear_shirq spear310_shirq_ras3 = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 108 | .offset = 13, |
| 109 | .nr_irqs = 1, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 110 | .mask = ((0x1 << 1) - 1) << 13, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 111 | .regs = { |
| 112 | .enb_reg = -1, |
| 113 | .status_reg = SPEAR310_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 114 | }, |
| 115 | }; |
| 116 | |
| 117 | static struct spear_shirq spear310_shirq_intrcomm_ras = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 118 | .offset = 14, |
| 119 | .nr_irqs = 3, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 120 | .mask = ((0x1 << 3) - 1) << 14, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 121 | .regs = { |
| 122 | .enb_reg = -1, |
| 123 | .status_reg = SPEAR310_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 124 | }, |
| 125 | }; |
| 126 | |
| 127 | static struct spear_shirq *spear310_shirq_blocks[] = { |
| 128 | &spear310_shirq_ras1, |
| 129 | &spear310_shirq_ras2, |
| 130 | &spear310_shirq_ras3, |
| 131 | &spear310_shirq_intrcomm_ras, |
| 132 | }; |
| 133 | |
| 134 | /* spear320 shared irq registers offsets and masks */ |
| 135 | #define SPEAR320_INT_STS_MASK_REG 0x04 |
| 136 | #define SPEAR320_INT_CLR_MASK_REG 0x04 |
| 137 | #define SPEAR320_INT_ENB_MASK_REG 0x08 |
| 138 | |
Thomas Gleixner | 03319a1 | 2014-06-19 21:34:40 +0000 | [diff] [blame] | 139 | static struct spear_shirq spear320_shirq_ras3 = { |
| 140 | .offset = 0, |
| 141 | .nr_irqs = 7, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 142 | .mask = ((0x1 << 7) - 1) << 0, |
Thomas Gleixner | 03319a1 | 2014-06-19 21:34:40 +0000 | [diff] [blame] | 143 | .disabled = 1, |
Thomas Gleixner | 03319a1 | 2014-06-19 21:34:40 +0000 | [diff] [blame] | 144 | }; |
| 145 | |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 146 | static struct spear_shirq spear320_shirq_ras1 = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 147 | .offset = 7, |
| 148 | .nr_irqs = 3, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 149 | .mask = ((0x1 << 3) - 1) << 7, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 150 | .regs = { |
| 151 | .enb_reg = -1, |
| 152 | .status_reg = SPEAR320_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 153 | }, |
| 154 | }; |
| 155 | |
| 156 | static struct spear_shirq spear320_shirq_ras2 = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 157 | .offset = 10, |
| 158 | .nr_irqs = 1, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 159 | .mask = ((0x1 << 1) - 1) << 10, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 160 | .regs = { |
| 161 | .enb_reg = -1, |
| 162 | .status_reg = SPEAR320_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 163 | }, |
| 164 | }; |
| 165 | |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 166 | static struct spear_shirq spear320_shirq_intrcomm_ras = { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 167 | .offset = 11, |
| 168 | .nr_irqs = 11, |
Thomas Gleixner | 4ecc832 | 2014-06-19 21:34:41 +0000 | [diff] [blame] | 169 | .mask = ((0x1 << 11) - 1) << 11, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 170 | .regs = { |
| 171 | .enb_reg = -1, |
| 172 | .status_reg = SPEAR320_INT_STS_MASK_REG, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 173 | }, |
| 174 | }; |
| 175 | |
| 176 | static struct spear_shirq *spear320_shirq_blocks[] = { |
| 177 | &spear320_shirq_ras3, |
| 178 | &spear320_shirq_ras1, |
| 179 | &spear320_shirq_ras2, |
| 180 | &spear320_shirq_intrcomm_ras, |
| 181 | }; |
| 182 | |
| 183 | static void shirq_irq_mask_unmask(struct irq_data *d, bool mask) |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 184 | { |
Lennert Buytenhek | 0e60e11 | 2010-11-29 11:22:33 +0100 | [diff] [blame] | 185 | struct spear_shirq *shirq = irq_data_get_irq_chip_data(d); |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 186 | u32 val, offset = d->irq - shirq->virq_base; |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 187 | unsigned long flags; |
| 188 | |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 189 | if (shirq->regs.enb_reg == -1) |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 190 | return; |
| 191 | |
| 192 | spin_lock_irqsave(&lock, flags); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 193 | val = readl(shirq->base + shirq->regs.enb_reg); |
| 194 | |
| 195 | if (mask ^ shirq->regs.reset_to_enb) |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 196 | val &= ~(0x1 << shirq->offset << offset); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 197 | else |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 198 | val |= 0x1 << shirq->offset << offset; |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 199 | |
| 200 | writel(val, shirq->base + shirq->regs.enb_reg); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 201 | spin_unlock_irqrestore(&lock, flags); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 202 | |
| 203 | } |
| 204 | |
| 205 | static void shirq_irq_mask(struct irq_data *d) |
| 206 | { |
| 207 | shirq_irq_mask_unmask(d, 1); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 208 | } |
| 209 | |
Lennert Buytenhek | 0e60e11 | 2010-11-29 11:22:33 +0100 | [diff] [blame] | 210 | static void shirq_irq_unmask(struct irq_data *d) |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 211 | { |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 212 | shirq_irq_mask_unmask(d, 0); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | static struct irq_chip shirq_chip = { |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 216 | .name = "spear-shirq", |
Lennert Buytenhek | 0e60e11 | 2010-11-29 11:22:33 +0100 | [diff] [blame] | 217 | .irq_ack = shirq_irq_mask, |
| 218 | .irq_mask = shirq_irq_mask, |
| 219 | .irq_unmask = shirq_irq_unmask, |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | static void shirq_handler(unsigned irq, struct irq_desc *desc) |
| 223 | { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 224 | struct spear_shirq *shirq = irq_get_handler_data(irq); |
Thomas Gleixner | e3c871a | 2014-06-19 21:34:40 +0000 | [diff] [blame] | 225 | struct irq_data *idata = irq_desc_get_irq_data(desc); |
| 226 | struct irq_chip *chip = irq_data_get_irq_chip(idata); |
Thomas Gleixner | 25dc49e | 2014-06-19 21:34:42 +0000 | [diff] [blame^] | 227 | u32 pend; |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 228 | |
Thomas Gleixner | e3c871a | 2014-06-19 21:34:40 +0000 | [diff] [blame] | 229 | chip->irq_ack(idata); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 230 | |
Thomas Gleixner | 25dc49e | 2014-06-19 21:34:42 +0000 | [diff] [blame^] | 231 | pend = readl(shirq->base + shirq->regs.status_reg) & shirq->mask; |
| 232 | pend >>= shirq->offset; |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 233 | |
Thomas Gleixner | 25dc49e | 2014-06-19 21:34:42 +0000 | [diff] [blame^] | 234 | while (pend) { |
| 235 | int irq = __ffs(pend); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 236 | |
Thomas Gleixner | 25dc49e | 2014-06-19 21:34:42 +0000 | [diff] [blame^] | 237 | pend &= ~(0x1 << irq); |
| 238 | generic_handle_irq(shirq->virq_base + irq); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 239 | } |
Thomas Gleixner | 25dc49e | 2014-06-19 21:34:42 +0000 | [diff] [blame^] | 240 | |
Thomas Gleixner | e3c871a | 2014-06-19 21:34:40 +0000 | [diff] [blame] | 241 | chip->irq_unmask(idata); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 242 | } |
| 243 | |
Thomas Gleixner | f37ecbc | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 244 | static void __init spear_shirq_register(struct spear_shirq *shirq, |
| 245 | int parent_irq) |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 246 | { |
| 247 | int i; |
| 248 | |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 249 | if (shirq->disabled) |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 250 | return; |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 251 | |
Thomas Gleixner | f37ecbc | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 252 | irq_set_chained_handler(parent_irq, shirq_handler); |
| 253 | irq_set_handler_data(parent_irq, shirq); |
| 254 | |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 255 | for (i = 0; i < shirq->nr_irqs; i++) { |
| 256 | irq_set_chip_and_handler(shirq->virq_base + i, |
Thomas Gleixner | f38c02f | 2011-03-24 13:35:09 +0100 | [diff] [blame] | 257 | &shirq_chip, handle_simple_irq); |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 258 | set_irq_flags(shirq->virq_base + i, IRQF_VALID); |
| 259 | irq_set_chip_data(shirq->virq_base + i, shirq); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 260 | } |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | static int __init shirq_init(struct spear_shirq **shirq_blocks, int block_nr, |
| 264 | struct device_node *np) |
| 265 | { |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 266 | int i, parent_irq, virq_base, hwirq = 0, nr_irqs = 0; |
Thomas Gleixner | a26c06f | 2014-06-19 21:34:37 +0000 | [diff] [blame] | 267 | struct irq_domain *shirq_domain; |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 268 | void __iomem *base; |
| 269 | |
| 270 | base = of_iomap(np, 0); |
| 271 | if (!base) { |
| 272 | pr_err("%s: failed to map shirq registers\n", __func__); |
| 273 | return -ENXIO; |
| 274 | } |
| 275 | |
| 276 | for (i = 0; i < block_nr; i++) |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 277 | nr_irqs += shirq_blocks[i]->nr_irqs; |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 278 | |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 279 | virq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); |
| 280 | if (IS_ERR_VALUE(virq_base)) { |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 281 | pr_err("%s: irq desc alloc failed\n", __func__); |
| 282 | goto err_unmap; |
| 283 | } |
| 284 | |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 285 | shirq_domain = irq_domain_add_legacy(np, nr_irqs, virq_base, 0, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 286 | &irq_domain_simple_ops, NULL); |
| 287 | if (WARN_ON(!shirq_domain)) { |
| 288 | pr_warn("%s: irq domain init failed\n", __func__); |
| 289 | goto err_free_desc; |
| 290 | } |
| 291 | |
| 292 | for (i = 0; i < block_nr; i++) { |
| 293 | shirq_blocks[i]->base = base; |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 294 | shirq_blocks[i]->virq_base = irq_find_mapping(shirq_domain, |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 295 | hwirq); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 296 | |
Thomas Gleixner | f37ecbc | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 297 | parent_irq = irq_of_parse_and_map(np, i); |
| 298 | spear_shirq_register(shirq_blocks[i], parent_irq); |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 299 | hwirq += shirq_blocks[i]->nr_irqs; |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 300 | } |
| 301 | |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 302 | return 0; |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 303 | |
| 304 | err_free_desc: |
Thomas Gleixner | c5d1d85 | 2014-06-19 21:34:39 +0000 | [diff] [blame] | 305 | irq_free_descs(virq_base, nr_irqs); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 306 | err_unmap: |
| 307 | iounmap(base); |
| 308 | return -ENXIO; |
| 309 | } |
| 310 | |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 311 | static int __init spear300_shirq_of_init(struct device_node *np, |
| 312 | struct device_node *parent) |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 313 | { |
| 314 | return shirq_init(spear300_shirq_blocks, |
| 315 | ARRAY_SIZE(spear300_shirq_blocks), np); |
| 316 | } |
Rob Herring | e9c5155 | 2013-01-02 09:37:56 -0600 | [diff] [blame] | 317 | IRQCHIP_DECLARE(spear300_shirq, "st,spear300-shirq", spear300_shirq_of_init); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 318 | |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 319 | static int __init spear310_shirq_of_init(struct device_node *np, |
| 320 | struct device_node *parent) |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 321 | { |
| 322 | return shirq_init(spear310_shirq_blocks, |
| 323 | ARRAY_SIZE(spear310_shirq_blocks), np); |
| 324 | } |
Rob Herring | e9c5155 | 2013-01-02 09:37:56 -0600 | [diff] [blame] | 325 | IRQCHIP_DECLARE(spear310_shirq, "st,spear310-shirq", spear310_shirq_of_init); |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 326 | |
Thomas Gleixner | 078bc00 | 2014-06-19 21:34:38 +0000 | [diff] [blame] | 327 | static int __init spear320_shirq_of_init(struct device_node *np, |
| 328 | struct device_node *parent) |
Shiraz Hashim | 80515a5a | 2012-08-03 15:33:10 +0530 | [diff] [blame] | 329 | { |
| 330 | return shirq_init(spear320_shirq_blocks, |
| 331 | ARRAY_SIZE(spear320_shirq_blocks), np); |
viresh kumar | 4c18e77 | 2010-05-03 09:24:30 +0100 | [diff] [blame] | 332 | } |
Rob Herring | e9c5155 | 2013-01-02 09:37:56 -0600 | [diff] [blame] | 333 | IRQCHIP_DECLARE(spear320_shirq, "st,spear320-shirq", spear320_shirq_of_init); |