Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2017 SiFive |
| 4 | * Copyright (C) 2018 Christoph Hellwig |
| 5 | */ |
| 6 | #define pr_fmt(fmt) "plic: " fmt |
Atish Patra | ccbe80b | 2020-03-02 15:11:45 -0800 | [diff] [blame^] | 7 | #include <linux/cpu.h> |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 8 | #include <linux/interrupt.h> |
| 9 | #include <linux/io.h> |
| 10 | #include <linux/irq.h> |
| 11 | #include <linux/irqchip.h> |
| 12 | #include <linux/irqdomain.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/of.h> |
| 15 | #include <linux/of_address.h> |
| 16 | #include <linux/of_irq.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/spinlock.h> |
Atish Patra | f99fb60 | 2018-10-02 12:15:05 -0700 | [diff] [blame] | 19 | #include <asm/smp.h> |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 20 | |
| 21 | /* |
| 22 | * This driver implements a version of the RISC-V PLIC with the actual layout |
| 23 | * specified in chapter 8 of the SiFive U5 Coreplex Series Manual: |
| 24 | * |
| 25 | * https://static.dev.sifive.com/U54-MC-RVCoreIP.pdf |
| 26 | * |
| 27 | * The largest number supported by devices marked as 'sifive,plic-1.0.0', is |
| 28 | * 1024, of which device 0 is defined as non-existent by the RISC-V Privileged |
| 29 | * Spec. |
| 30 | */ |
| 31 | |
| 32 | #define MAX_DEVICES 1024 |
| 33 | #define MAX_CONTEXTS 15872 |
| 34 | |
| 35 | /* |
| 36 | * Each interrupt source has a priority register associated with it. |
| 37 | * We always hardwire it to one in Linux. |
| 38 | */ |
| 39 | #define PRIORITY_BASE 0 |
| 40 | #define PRIORITY_PER_ID 4 |
| 41 | |
| 42 | /* |
| 43 | * Each hart context has a vector of interrupt enable bits associated with it. |
| 44 | * There's one bit for each interrupt source. |
| 45 | */ |
| 46 | #define ENABLE_BASE 0x2000 |
| 47 | #define ENABLE_PER_HART 0x80 |
| 48 | |
| 49 | /* |
| 50 | * Each hart context has a set of control registers associated with it. Right |
| 51 | * now there's only two: a source priority threshold over which the hart will |
| 52 | * take an interrupt, and a register to claim interrupts. |
| 53 | */ |
| 54 | #define CONTEXT_BASE 0x200000 |
| 55 | #define CONTEXT_PER_HART 0x1000 |
| 56 | #define CONTEXT_THRESHOLD 0x00 |
| 57 | #define CONTEXT_CLAIM 0x04 |
| 58 | |
Atish Patra | ccbe80b | 2020-03-02 15:11:45 -0800 | [diff] [blame^] | 59 | #define PLIC_DISABLE_THRESHOLD 0xf |
| 60 | #define PLIC_ENABLE_THRESHOLD 0 |
| 61 | |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 62 | static void __iomem *plic_regs; |
| 63 | |
| 64 | struct plic_handler { |
| 65 | bool present; |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 66 | void __iomem *hart_base; |
| 67 | /* |
| 68 | * Protect mask operations on the registers given that we can't |
| 69 | * assume atomic memory operations work on them. |
| 70 | */ |
| 71 | raw_spinlock_t enable_lock; |
| 72 | void __iomem *enable_base; |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 73 | }; |
| 74 | static DEFINE_PER_CPU(struct plic_handler, plic_handlers); |
| 75 | |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 76 | static inline void plic_toggle(struct plic_handler *handler, |
| 77 | int hwirq, int enable) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 78 | { |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 79 | u32 __iomem *reg = handler->enable_base + (hwirq / 32) * sizeof(u32); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 80 | u32 hwirq_mask = 1 << (hwirq % 32); |
| 81 | |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 82 | raw_spin_lock(&handler->enable_lock); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 83 | if (enable) |
| 84 | writel(readl(reg) | hwirq_mask, reg); |
| 85 | else |
| 86 | writel(readl(reg) & ~hwirq_mask, reg); |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 87 | raw_spin_unlock(&handler->enable_lock); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 88 | } |
| 89 | |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 90 | static inline void plic_irq_toggle(const struct cpumask *mask, |
| 91 | int hwirq, int enable) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 92 | { |
| 93 | int cpu; |
| 94 | |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 95 | writel(enable, plic_regs + PRIORITY_BASE + hwirq * PRIORITY_PER_ID); |
| 96 | for_each_cpu(cpu, mask) { |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 97 | struct plic_handler *handler = per_cpu_ptr(&plic_handlers, cpu); |
| 98 | |
| 99 | if (handler->present) |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 100 | plic_toggle(handler, hwirq, enable); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | |
Marc Zyngier | bb0fed1 | 2019-09-15 15:17:45 +0100 | [diff] [blame] | 104 | static void plic_irq_unmask(struct irq_data *d) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 105 | { |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 106 | unsigned int cpu = cpumask_any_and(irq_data_get_affinity_mask(d), |
| 107 | cpu_online_mask); |
| 108 | if (WARN_ON_ONCE(cpu >= nr_cpu_ids)) |
| 109 | return; |
| 110 | plic_irq_toggle(cpumask_of(cpu), d->hwirq, 1); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 111 | } |
| 112 | |
Marc Zyngier | bb0fed1 | 2019-09-15 15:17:45 +0100 | [diff] [blame] | 113 | static void plic_irq_mask(struct irq_data *d) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 114 | { |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 115 | plic_irq_toggle(cpu_possible_mask, d->hwirq, 0); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 116 | } |
| 117 | |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 118 | #ifdef CONFIG_SMP |
| 119 | static int plic_set_affinity(struct irq_data *d, |
| 120 | const struct cpumask *mask_val, bool force) |
| 121 | { |
| 122 | unsigned int cpu; |
| 123 | |
| 124 | if (force) |
| 125 | cpu = cpumask_first(mask_val); |
| 126 | else |
| 127 | cpu = cpumask_any_and(mask_val, cpu_online_mask); |
| 128 | |
| 129 | if (cpu >= nr_cpu_ids) |
| 130 | return -EINVAL; |
| 131 | |
Marc Zyngier | bb0fed1 | 2019-09-15 15:17:45 +0100 | [diff] [blame] | 132 | plic_irq_toggle(cpu_possible_mask, d->hwirq, 0); |
| 133 | plic_irq_toggle(cpumask_of(cpu), d->hwirq, 1); |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 134 | |
| 135 | irq_data_update_effective_affinity(d, cpumask_of(cpu)); |
| 136 | |
| 137 | return IRQ_SET_MASK_OK_DONE; |
| 138 | } |
| 139 | #endif |
| 140 | |
Marc Zyngier | bb0fed1 | 2019-09-15 15:17:45 +0100 | [diff] [blame] | 141 | static void plic_irq_eoi(struct irq_data *d) |
| 142 | { |
| 143 | struct plic_handler *handler = this_cpu_ptr(&plic_handlers); |
| 144 | |
| 145 | writel(d->hwirq, handler->hart_base + CONTEXT_CLAIM); |
| 146 | } |
| 147 | |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 148 | static struct irq_chip plic_chip = { |
| 149 | .name = "SiFive PLIC", |
Marc Zyngier | bb0fed1 | 2019-09-15 15:17:45 +0100 | [diff] [blame] | 150 | .irq_mask = plic_irq_mask, |
| 151 | .irq_unmask = plic_irq_unmask, |
| 152 | .irq_eoi = plic_irq_eoi, |
Anup Patel | cc9f04f | 2019-02-12 18:22:46 +0530 | [diff] [blame] | 153 | #ifdef CONFIG_SMP |
| 154 | .irq_set_affinity = plic_set_affinity, |
| 155 | #endif |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | static int plic_irqdomain_map(struct irq_domain *d, unsigned int irq, |
| 159 | irq_hw_number_t hwirq) |
| 160 | { |
Yash Shah | 466008f | 2019-12-10 16:41:11 +0530 | [diff] [blame] | 161 | irq_domain_set_info(d, irq, hwirq, &plic_chip, d->host_data, |
| 162 | handle_fasteoi_irq, NULL, NULL); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 163 | irq_set_noprobe(irq); |
| 164 | return 0; |
| 165 | } |
| 166 | |
Yash Shah | 466008f | 2019-12-10 16:41:11 +0530 | [diff] [blame] | 167 | static int plic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, |
| 168 | unsigned int nr_irqs, void *arg) |
| 169 | { |
| 170 | int i, ret; |
| 171 | irq_hw_number_t hwirq; |
| 172 | unsigned int type; |
| 173 | struct irq_fwspec *fwspec = arg; |
| 174 | |
| 175 | ret = irq_domain_translate_onecell(domain, fwspec, &hwirq, &type); |
| 176 | if (ret) |
| 177 | return ret; |
| 178 | |
| 179 | for (i = 0; i < nr_irqs; i++) { |
| 180 | ret = plic_irqdomain_map(domain, virq + i, hwirq + i); |
| 181 | if (ret) |
| 182 | return ret; |
| 183 | } |
| 184 | |
| 185 | return 0; |
| 186 | } |
| 187 | |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 188 | static const struct irq_domain_ops plic_irqdomain_ops = { |
Yash Shah | 466008f | 2019-12-10 16:41:11 +0530 | [diff] [blame] | 189 | .translate = irq_domain_translate_onecell, |
| 190 | .alloc = plic_irq_domain_alloc, |
| 191 | .free = irq_domain_free_irqs_top, |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | static struct irq_domain *plic_irqdomain; |
| 195 | |
| 196 | /* |
| 197 | * Handling an interrupt is a two-step process: first you claim the interrupt |
| 198 | * by reading the claim register, then you complete the interrupt by writing |
| 199 | * that source ID back to the same claim register. This automatically enables |
| 200 | * and disables the interrupt, so there's nothing else to do. |
| 201 | */ |
| 202 | static void plic_handle_irq(struct pt_regs *regs) |
| 203 | { |
| 204 | struct plic_handler *handler = this_cpu_ptr(&plic_handlers); |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 205 | void __iomem *claim = handler->hart_base + CONTEXT_CLAIM; |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 206 | irq_hw_number_t hwirq; |
| 207 | |
| 208 | WARN_ON_ONCE(!handler->present); |
| 209 | |
Christoph Hellwig | a4c3733 | 2019-10-28 13:10:32 +0100 | [diff] [blame] | 210 | csr_clear(CSR_IE, IE_EIE); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 211 | while ((hwirq = readl(claim))) { |
| 212 | int irq = irq_find_mapping(plic_irqdomain, hwirq); |
| 213 | |
| 214 | if (unlikely(irq <= 0)) |
| 215 | pr_warn_ratelimited("can't find mapping for hwirq %lu\n", |
| 216 | hwirq); |
| 217 | else |
| 218 | generic_handle_irq(irq); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 219 | } |
Christoph Hellwig | a4c3733 | 2019-10-28 13:10:32 +0100 | [diff] [blame] | 220 | csr_set(CSR_IE, IE_EIE); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | /* |
| 224 | * Walk up the DT tree until we find an active RISC-V core (HART) node and |
| 225 | * extract the cpuid from it. |
| 226 | */ |
| 227 | static int plic_find_hart_id(struct device_node *node) |
| 228 | { |
| 229 | for (; node; node = node->parent) { |
| 230 | if (of_device_is_compatible(node, "riscv")) |
Palmer Dabbelt | b2f8cfa7 | 2018-10-02 12:15:00 -0700 | [diff] [blame] | 231 | return riscv_of_processor_hartid(node); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | return -1; |
| 235 | } |
| 236 | |
Atish Patra | ccbe80b | 2020-03-02 15:11:45 -0800 | [diff] [blame^] | 237 | static void plic_set_threshold(struct plic_handler *handler, u32 threshold) |
| 238 | { |
| 239 | /* priority must be > threshold to trigger an interrupt */ |
| 240 | writel(threshold, handler->hart_base + CONTEXT_THRESHOLD); |
| 241 | } |
| 242 | |
| 243 | static int plic_dying_cpu(unsigned int cpu) |
| 244 | { |
| 245 | struct plic_handler *handler = this_cpu_ptr(&plic_handlers); |
| 246 | |
| 247 | csr_clear(CSR_IE, IE_EIE); |
| 248 | plic_set_threshold(handler, PLIC_DISABLE_THRESHOLD); |
| 249 | |
| 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | static int plic_starting_cpu(unsigned int cpu) |
| 254 | { |
| 255 | struct plic_handler *handler = this_cpu_ptr(&plic_handlers); |
| 256 | |
| 257 | csr_set(CSR_IE, IE_EIE); |
| 258 | plic_set_threshold(handler, PLIC_ENABLE_THRESHOLD); |
| 259 | |
| 260 | return 0; |
| 261 | } |
| 262 | |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 263 | static int __init plic_init(struct device_node *node, |
| 264 | struct device_node *parent) |
| 265 | { |
Anup Patel | 6adfe8d | 2019-02-12 18:22:45 +0530 | [diff] [blame] | 266 | int error = 0, nr_contexts, nr_handlers = 0, i; |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 267 | u32 nr_irqs; |
| 268 | |
| 269 | if (plic_regs) { |
| 270 | pr_warn("PLIC already present.\n"); |
| 271 | return -ENXIO; |
| 272 | } |
| 273 | |
| 274 | plic_regs = of_iomap(node, 0); |
| 275 | if (WARN_ON(!plic_regs)) |
| 276 | return -EIO; |
| 277 | |
| 278 | error = -EINVAL; |
| 279 | of_property_read_u32(node, "riscv,ndev", &nr_irqs); |
| 280 | if (WARN_ON(!nr_irqs)) |
| 281 | goto out_iounmap; |
| 282 | |
Anup Patel | 6adfe8d | 2019-02-12 18:22:45 +0530 | [diff] [blame] | 283 | nr_contexts = of_irq_count(node); |
| 284 | if (WARN_ON(!nr_contexts)) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 285 | goto out_iounmap; |
Anup Patel | 6adfe8d | 2019-02-12 18:22:45 +0530 | [diff] [blame] | 286 | if (WARN_ON(nr_contexts < num_possible_cpus())) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 287 | goto out_iounmap; |
| 288 | |
| 289 | error = -ENOMEM; |
| 290 | plic_irqdomain = irq_domain_add_linear(node, nr_irqs + 1, |
| 291 | &plic_irqdomain_ops, NULL); |
| 292 | if (WARN_ON(!plic_irqdomain)) |
| 293 | goto out_iounmap; |
| 294 | |
Anup Patel | 6adfe8d | 2019-02-12 18:22:45 +0530 | [diff] [blame] | 295 | for (i = 0; i < nr_contexts; i++) { |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 296 | struct of_phandle_args parent; |
| 297 | struct plic_handler *handler; |
| 298 | irq_hw_number_t hwirq; |
Atish Patra | f99fb60 | 2018-10-02 12:15:05 -0700 | [diff] [blame] | 299 | int cpu, hartid; |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 300 | |
| 301 | if (of_irq_parse_one(node, i, &parent)) { |
| 302 | pr_err("failed to parse parent for context %d.\n", i); |
| 303 | continue; |
| 304 | } |
| 305 | |
Christoph Hellwig | a4c3733 | 2019-10-28 13:10:32 +0100 | [diff] [blame] | 306 | /* |
| 307 | * Skip contexts other than external interrupts for our |
| 308 | * privilege level. |
| 309 | */ |
Paul Walmsley | 2f3035d | 2019-12-20 03:09:49 -0800 | [diff] [blame] | 310 | if (parent.args[0] != RV_IRQ_EXT) |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 311 | continue; |
| 312 | |
Atish Patra | f99fb60 | 2018-10-02 12:15:05 -0700 | [diff] [blame] | 313 | hartid = plic_find_hart_id(parent.np); |
| 314 | if (hartid < 0) { |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 315 | pr_warn("failed to parse hart ID for context %d.\n", i); |
| 316 | continue; |
| 317 | } |
| 318 | |
Atish Patra | f99fb60 | 2018-10-02 12:15:05 -0700 | [diff] [blame] | 319 | cpu = riscv_hartid_to_cpuid(hartid); |
Atish Patra | fc03aca | 2019-02-12 03:10:11 -0800 | [diff] [blame] | 320 | if (cpu < 0) { |
| 321 | pr_warn("Invalid cpuid for context %d\n", i); |
| 322 | continue; |
| 323 | } |
| 324 | |
Christoph Hellwig | 9ce0649 | 2019-09-03 11:32:20 +0200 | [diff] [blame] | 325 | /* |
| 326 | * When running in M-mode we need to ignore the S-mode handler. |
| 327 | * Here we assume it always comes later, but that might be a |
| 328 | * little fragile. |
| 329 | */ |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 330 | handler = per_cpu_ptr(&plic_handlers, cpu); |
Anup Patel | 3fecb5a | 2019-02-12 18:22:44 +0530 | [diff] [blame] | 331 | if (handler->present) { |
| 332 | pr_warn("handler already present for context %d.\n", i); |
Atish Patra | ccbe80b | 2020-03-02 15:11:45 -0800 | [diff] [blame^] | 333 | plic_set_threshold(handler, PLIC_DISABLE_THRESHOLD); |
Christoph Hellwig | 9ce0649 | 2019-09-03 11:32:20 +0200 | [diff] [blame] | 334 | goto done; |
Anup Patel | 3fecb5a | 2019-02-12 18:22:44 +0530 | [diff] [blame] | 335 | } |
| 336 | |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 337 | handler->present = true; |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 338 | handler->hart_base = |
| 339 | plic_regs + CONTEXT_BASE + i * CONTEXT_PER_HART; |
| 340 | raw_spin_lock_init(&handler->enable_lock); |
| 341 | handler->enable_base = |
| 342 | plic_regs + ENABLE_BASE + i * ENABLE_PER_HART; |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 343 | |
Christoph Hellwig | 9ce0649 | 2019-09-03 11:32:20 +0200 | [diff] [blame] | 344 | done: |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 345 | for (hwirq = 1; hwirq <= nr_irqs; hwirq++) |
Anup Patel | 86c7cbf | 2019-02-12 18:22:43 +0530 | [diff] [blame] | 346 | plic_toggle(handler, hwirq, 0); |
Anup Patel | 6adfe8d | 2019-02-12 18:22:45 +0530 | [diff] [blame] | 347 | nr_handlers++; |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 348 | } |
| 349 | |
Atish Patra | ccbe80b | 2020-03-02 15:11:45 -0800 | [diff] [blame^] | 350 | cpuhp_setup_state(CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, |
| 351 | "irqchip/sifive/plic:starting", |
| 352 | plic_starting_cpu, plic_dying_cpu); |
Anup Patel | 6adfe8d | 2019-02-12 18:22:45 +0530 | [diff] [blame] | 353 | pr_info("mapped %d interrupts with %d handlers for %d contexts.\n", |
| 354 | nr_irqs, nr_handlers, nr_contexts); |
Christoph Hellwig | 8237f8b | 2018-07-26 16:27:00 +0200 | [diff] [blame] | 355 | set_handle_irq(plic_handle_irq); |
| 356 | return 0; |
| 357 | |
| 358 | out_iounmap: |
| 359 | iounmap(plic_regs); |
| 360 | return error; |
| 361 | } |
| 362 | |
| 363 | IRQCHIP_DECLARE(sifive_plic, "sifive,plic-1.0.0", plic_init); |
| 364 | IRQCHIP_DECLARE(riscv_plic0, "riscv,plic0", plic_init); /* for legacy systems */ |