aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/prom.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-powerpc/prom.h')
-rw-r--r--include/asm-powerpc/prom.h98
1 files changed, 89 insertions, 9 deletions
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 010d186d095b..b095a285c84b 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -64,11 +64,6 @@ struct boot_param_header
64typedef u32 phandle; 64typedef u32 phandle;
65typedef u32 ihandle; 65typedef u32 ihandle;
66 66
67struct interrupt_info {
68 int line;
69 int sense; /* +ve/-ve logic, edge or level, etc. */
70};
71
72struct property { 67struct property {
73 char *name; 68 char *name;
74 int length; 69 int length;
@@ -81,8 +76,6 @@ struct device_node {
81 char *type; 76 char *type;
82 phandle node; 77 phandle node;
83 phandle linux_phandle; 78 phandle linux_phandle;
84 int n_intrs;
85 struct interrupt_info *intrs;
86 char *full_name; 79 char *full_name;
87 80
88 struct property *properties; 81 struct property *properties;
@@ -167,8 +160,8 @@ extern void unflatten_device_tree(void);
167extern void early_init_devtree(void *); 160extern void early_init_devtree(void *);
168extern int device_is_compatible(struct device_node *device, const char *); 161extern int device_is_compatible(struct device_node *device, const char *);
169extern int machine_is_compatible(const char *compat); 162extern int machine_is_compatible(const char *compat);
170extern unsigned char *get_property(struct device_node *node, const char *name, 163extern void *get_property(struct device_node *node, const char *name,
171 int *lenp); 164 int *lenp);
172extern void print_properties(struct device_node *node); 165extern void print_properties(struct device_node *node);
173extern int prom_n_addr_cells(struct device_node* np); 166extern int prom_n_addr_cells(struct device_node* np);
174extern int prom_n_size_cells(struct device_node* np); 167extern int prom_n_size_cells(struct device_node* np);
@@ -204,6 +197,15 @@ extern int release_OF_resource(struct device_node* node, int index);
204 */ 197 */
205 198
206 199
200/* Helper to read a big number */
201static inline u64 of_read_number(u32 *cell, int size)
202{
203 u64 r = 0;
204 while (size--)
205 r = (r << 32) | *(cell++);
206 return r;
207}
208
207/* Translate an OF address block into a CPU physical address 209/* Translate an OF address block into a CPU physical address
208 */ 210 */
209#define OF_BAD_ADDR ((u64)-1) 211#define OF_BAD_ADDR ((u64)-1)
@@ -240,5 +242,83 @@ extern void kdump_move_device_tree(void);
240/* CPU OF node matching */ 242/* CPU OF node matching */
241struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); 243struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
242 244
245
246/*
247 * OF interrupt mapping
248 */
249
250/* This structure is returned when an interrupt is mapped. The controller
251 * field needs to be put() after use
252 */
253
254#define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
255
256struct of_irq {
257 struct device_node *controller; /* Interrupt controller node */
258 u32 size; /* Specifier size */
259 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
260};
261
262/***
263 * of_irq_map_init - Initialize the irq remapper
264 * @flags: flags defining workarounds to enable
265 *
266 * Some machines have bugs in the device-tree which require certain workarounds
267 * to be applied. Call this before any interrupt mapping attempts to enable
268 * those workarounds.
269 */
270#define OF_IMAP_OLDWORLD_MAC 0x00000001
271#define OF_IMAP_NO_PHANDLE 0x00000002
272
273extern void of_irq_map_init(unsigned int flags);
274
275/***
276 * of_irq_map_raw - Low level interrupt tree parsing
277 * @parent: the device interrupt parent
278 * @intspec: interrupt specifier ("interrupts" property of the device)
279 * @addr: address specifier (start of "reg" property of the device)
280 * @out_irq: structure of_irq filled by this function
281 *
282 * Returns 0 on success and a negative number on error
283 *
284 * This function is a low-level interrupt tree walking function. It
285 * can be used to do a partial walk with synthetized reg and interrupts
286 * properties, for example when resolving PCI interrupts when no device
287 * node exist for the parent.
288 *
289 */
290
291extern int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
292 struct of_irq *out_irq);
293
294
295/***
296 * of_irq_map_one - Resolve an interrupt for a device
297 * @device: the device whose interrupt is to be resolved
298 * @index: index of the interrupt to resolve
299 * @out_irq: structure of_irq filled by this function
300 *
301 * This function resolves an interrupt, walking the tree, for a given
302 * device-tree node. It's the high level pendant to of_irq_map_raw().
303 * It also implements the workarounds for OldWolrd Macs.
304 */
305extern int of_irq_map_one(struct device_node *device, int index,
306 struct of_irq *out_irq);
307
308/***
309 * of_irq_map_pci - Resolve the interrupt for a PCI device
310 * @pdev: the device whose interrupt is to be resolved
311 * @out_irq: structure of_irq filled by this function
312 *
313 * This function resolves the PCI interrupt for a given PCI device. If a
314 * device-node exists for a given pci_dev, it will use normal OF tree
315 * walking. If not, it will implement standard swizzling and walk up the
316 * PCI tree until an device-node is found, at which point it will finish
317 * resolving using the OF tree walking.
318 */
319struct pci_dev;
320extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
321
322
243#endif /* __KERNEL__ */ 323#endif /* __KERNEL__ */
244#endif /* _POWERPC_PROM_H */ 324#endif /* _POWERPC_PROM_H */