diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/sh/intc | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'drivers/sh/intc')
| -rw-r--r-- | drivers/sh/intc/dynamic.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/sh/intc/dynamic.c b/drivers/sh/intc/dynamic.c new file mode 100644 index 00000000000..a3677c9dfe3 --- /dev/null +++ b/drivers/sh/intc/dynamic.c | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | /* | ||
| 2 | * Dynamic IRQ management | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Paul Mundt | ||
| 5 | * | ||
| 6 | * Modelled after arch/x86/kernel/apic/io_apic.c | ||
| 7 | * | ||
| 8 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 9 | * License. See the file "COPYING" in the main directory of this archive | ||
| 10 | * for more details. | ||
| 11 | */ | ||
| 12 | #define pr_fmt(fmt) "intc: " fmt | ||
| 13 | |||
| 14 | #include <linux/irq.h> | ||
| 15 | #include <linux/bitmap.h> | ||
| 16 | #include <linux/spinlock.h> | ||
| 17 | #include "internals.h" /* only for activate_irq() damage.. */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * The IRQ bitmap provides a global map of bound IRQ vectors for a | ||
| 21 | * given platform. Allocation of IRQs are either static through the CPU | ||
| 22 | * vector map, or dynamic in the case of board mux vectors or MSI. | ||
| 23 | * | ||
| 24 | * As this is a central point for all IRQ controllers on the system, | ||
| 25 | * each of the available sources are mapped out here. This combined with | ||
| 26 | * sparseirq makes it quite trivial to keep the vector map tightly packed | ||
| 27 | * when dynamically creating IRQs, as well as tying in to otherwise | ||
| 28 | * unused irq_desc positions in the sparse array. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /* | ||
| 32 | * Dynamic IRQ allocation and deallocation | ||
| 33 | */ | ||
| 34 | unsigned int create_irq_nr(unsigned int irq_want, int node) | ||
| 35 | { | ||
| 36 | int irq = irq_alloc_desc_at(irq_want, node); | ||
| 37 | if (irq < 0) | ||
| 38 | return 0; | ||
| 39 | |||
| 40 | activate_irq(irq); | ||
| 41 | return irq; | ||
| 42 | } | ||
| 43 | |||
| 44 | int create_irq(void) | ||
| 45 | { | ||
| 46 | int irq = irq_alloc_desc(numa_node_id()); | ||
| 47 | if (irq >= 0) | ||
| 48 | activate_irq(irq); | ||
| 49 | |||
| 50 | return irq; | ||
| 51 | } | ||
| 52 | |||
| 53 | void destroy_irq(unsigned int irq) | ||
| 54 | { | ||
| 55 | irq_free_desc(irq); | ||
| 56 | } | ||
| 57 | |||
| 58 | void reserve_intc_vectors(struct intc_vect *vectors, unsigned int nr_vecs) | ||
| 59 | { | ||
| 60 | int i; | ||
| 61 | |||
| 62 | for (i = 0; i < nr_vecs; i++) | ||
| 63 | irq_reserve_irq(evt2irq(vectors[i].vect)); | ||
| 64 | } | ||
