1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef _LINUX_IRQDOMAIN_H
33#define _LINUX_IRQDOMAIN_H
34
35#include <linux/types.h>
36#include <linux/radix-tree.h>
37
38struct device_node;
39struct irq_domain;
40struct of_device_id;
41
42
43#define NUM_ISA_INTERRUPTS 16
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60struct irq_domain_ops {
61 int (*match)(struct irq_domain *d, struct device_node *node);
62 int (*map)(struct irq_domain *d, unsigned int virq, irq_hw_number_t hw);
63 void (*unmap)(struct irq_domain *d, unsigned int virq);
64 int (*xlate)(struct irq_domain *d, struct device_node *node,
65 const u32 *intspec, unsigned int intsize,
66 unsigned long *out_hwirq, unsigned int *out_type);
67};
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86struct irq_domain {
87 struct list_head link;
88
89
90 unsigned int revmap_type;
91 union {
92 struct {
93 unsigned int size;
94 unsigned int first_irq;
95 irq_hw_number_t first_hwirq;
96 } legacy;
97 struct {
98 unsigned int size;
99 unsigned int *revmap;
100 } linear;
101 struct {
102 unsigned int max_irq;
103 } nomap;
104 struct radix_tree_root tree;
105 } revmap_data;
106 const struct irq_domain_ops *ops;
107 void *host_data;
108 irq_hw_number_t inval_irq;
109
110
111 struct device_node *of_node;
112};
113
114#ifdef CONFIG_IRQ_DOMAIN
115struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
116 unsigned int size,
117 unsigned int first_irq,
118 irq_hw_number_t first_hwirq,
119 const struct irq_domain_ops *ops,
120 void *host_data);
121struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
122 unsigned int size,
123 const struct irq_domain_ops *ops,
124 void *host_data);
125struct irq_domain *irq_domain_add_nomap(struct device_node *of_node,
126 unsigned int max_irq,
127 const struct irq_domain_ops *ops,
128 void *host_data);
129struct irq_domain *irq_domain_add_tree(struct device_node *of_node,
130 const struct irq_domain_ops *ops,
131 void *host_data);
132
133extern struct irq_domain *irq_find_host(struct device_node *node);
134extern void irq_set_default_host(struct irq_domain *host);
135
136static inline struct irq_domain *irq_domain_add_legacy_isa(
137 struct device_node *of_node,
138 const struct irq_domain_ops *ops,
139 void *host_data)
140{
141 return irq_domain_add_legacy(of_node, NUM_ISA_INTERRUPTS, 0, 0, ops,
142 host_data);
143}
144
145extern void irq_domain_remove(struct irq_domain *host);
146
147extern unsigned int irq_create_mapping(struct irq_domain *host,
148 irq_hw_number_t hwirq);
149extern void irq_dispose_mapping(unsigned int virq);
150extern unsigned int irq_find_mapping(struct irq_domain *host,
151 irq_hw_number_t hwirq);
152extern unsigned int irq_create_direct_mapping(struct irq_domain *host);
153extern void irq_radix_revmap_insert(struct irq_domain *host, unsigned int virq,
154 irq_hw_number_t hwirq);
155extern unsigned int irq_radix_revmap_lookup(struct irq_domain *host,
156 irq_hw_number_t hwirq);
157extern unsigned int irq_linear_revmap(struct irq_domain *host,
158 irq_hw_number_t hwirq);
159
160extern const struct irq_domain_ops irq_domain_simple_ops;
161
162
163int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr,
164 const u32 *intspec, unsigned int intsize,
165 irq_hw_number_t *out_hwirq, unsigned int *out_type);
166int irq_domain_xlate_twocell(struct irq_domain *d, struct device_node *ctrlr,
167 const u32 *intspec, unsigned int intsize,
168 irq_hw_number_t *out_hwirq, unsigned int *out_type);
169int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
170 const u32 *intspec, unsigned int intsize,
171 irq_hw_number_t *out_hwirq, unsigned int *out_type);
172
173#if defined(CONFIG_OF_IRQ)
174extern void irq_domain_generate_simple(const struct of_device_id *match,
175 u64 phys_base, unsigned int irq_start);
176#else
177static inline void irq_domain_generate_simple(const struct of_device_id *match,
178 u64 phys_base, unsigned int irq_start) { }
179#endif
180
181#else
182static inline void irq_dispose_mapping(unsigned int virq) { }
183#endif
184
185#endif
186