diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-08-01 04:13:46 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-08-01 04:13:46 -0400 |
commit | 1d6a21b0a672fb29b01ccf397d478e0541e17716 (patch) | |
tree | cc4527286de39a1b70e0af1de16f8a664bea0118 /drivers/sh/intc/irqdomain.c | |
parent | 2d534926205db9ffce4bbbde67cb9b2cee4b835c (diff) |
sh: intc: initial irqdomain support.
Trivial support for irq domains, using either a linear map or radix tree
depending on the vector layout.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/sh/intc/irqdomain.c')
-rw-r--r-- | drivers/sh/intc/irqdomain.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/drivers/sh/intc/irqdomain.c b/drivers/sh/intc/irqdomain.c new file mode 100644 index 000000000000..3968f1c3c5c3 --- /dev/null +++ b/drivers/sh/intc/irqdomain.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * IRQ domain support for SH INTC subsystem | ||
3 | * | ||
4 | * Copyright (C) 2012 Paul Mundt | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #define pr_fmt(fmt) "intc: " fmt | ||
11 | |||
12 | #include <linux/irqdomain.h> | ||
13 | #include <linux/sh_intc.h> | ||
14 | #include <linux/export.h> | ||
15 | #include "internals.h" | ||
16 | |||
17 | /** | ||
18 | * intc_irq_domain_evt_xlate() - Generic xlate for vectored IRQs. | ||
19 | * | ||
20 | * This takes care of exception vector to hwirq translation through | ||
21 | * by way of evt2irq() translation. | ||
22 | * | ||
23 | * Note: For platforms that use a flat vector space without INTEVT this | ||
24 | * basically just mimics irq_domain_xlate_onecell() by way of a nopped | ||
25 | * out evt2irq() implementation. | ||
26 | */ | ||
27 | static int intc_evt_xlate(struct irq_domain *d, struct device_node *ctrlr, | ||
28 | const u32 *intspec, unsigned int intsize, | ||
29 | unsigned long *out_hwirq, unsigned int *out_type) | ||
30 | { | ||
31 | if (WARN_ON(intsize < 1)) | ||
32 | return -EINVAL; | ||
33 | |||
34 | *out_hwirq = evt2irq(intspec[0]); | ||
35 | *out_type = IRQ_TYPE_NONE; | ||
36 | |||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | static const struct irq_domain_ops intc_evt_ops = { | ||
41 | .xlate = intc_evt_xlate, | ||
42 | }; | ||
43 | |||
44 | void __init intc_irq_domain_init(struct intc_desc_int *d, | ||
45 | struct intc_hw_desc *hw) | ||
46 | { | ||
47 | unsigned int irq_base, irq_end; | ||
48 | |||
49 | /* | ||
50 | * Quick linear revmap check | ||
51 | */ | ||
52 | irq_base = evt2irq(hw->vectors[0].vect); | ||
53 | irq_end = evt2irq(hw->vectors[hw->nr_vectors - 1].vect); | ||
54 | |||
55 | /* | ||
56 | * Linear domains have a hard-wired assertion that IRQs start at | ||
57 | * 0 in order to make some performance optimizations. Lamely | ||
58 | * restrict the linear case to these conditions here, taking the | ||
59 | * tree penalty for linear cases with non-zero hwirq bases. | ||
60 | */ | ||
61 | if (irq_base == 0 && irq_end == (irq_base + hw->nr_vectors - 1)) | ||
62 | d->domain = irq_domain_add_linear(NULL, hw->nr_vectors, | ||
63 | &intc_evt_ops, NULL); | ||
64 | else | ||
65 | d->domain = irq_domain_add_tree(NULL, &intc_evt_ops, NULL); | ||
66 | |||
67 | BUG_ON(!d->domain); | ||
68 | } | ||