aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-07-03 05:35:17 -0400
committerPaul Mackerras <paulus@samba.org>2006-07-03 05:55:24 -0400
commitcc9fd71c62f542233c412b5fabc1bbe0c4d5ad08 (patch)
tree67af54159a57029057765c7ce94b00081844a6c8 /include/asm-powerpc
parentb9e5b4e6a991a5a6d521f2e20a65835404b4169f (diff)
[POWERPC] New device-tree interrupt parsing code
Adds new routines to prom_parse to walk the device-tree for interrupt information. This includes both direct mapping of interrupts and low level parsing functions for use with partial trees. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'include/asm-powerpc')
-rw-r--r--include/asm-powerpc/prom.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index b0768f474809..48bef401bc19 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -204,6 +204,15 @@ extern int release_OF_resource(struct device_node* node, int index);
204 */ 204 */
205 205
206 206
207/* Helper to read a big number */
208static inline u64 of_read_number(u32 *cell, int size)
209{
210 u64 r = 0;
211 while (size--)
212 r = (r << 32) | *(cell++);
213 return r;
214}
215
207/* Translate an OF address block into a CPU physical address 216/* Translate an OF address block into a CPU physical address
208 */ 217 */
209#define OF_BAD_ADDR ((u64)-1) 218#define OF_BAD_ADDR ((u64)-1)
@@ -240,5 +249,83 @@ extern void kdump_move_device_tree(void);
240/* CPU OF node matching */ 249/* CPU OF node matching */
241struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); 250struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
242 251
252
253/*
254 * OF interrupt mapping
255 */
256
257/* This structure is returned when an interrupt is mapped. The controller
258 * field needs to be put() after use
259 */
260
261#define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
262
263struct of_irq {
264 struct device_node *controller; /* Interrupt controller node */
265 u32 size; /* Specifier size */
266 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
267};
268
269/***
270 * of_irq_map_init - Initialize the irq remapper
271 * @flags: flags defining workarounds to enable
272 *
273 * Some machines have bugs in the device-tree which require certain workarounds
274 * to be applied. Call this before any interrupt mapping attempts to enable
275 * those workarounds.
276 */
277#define OF_IMAP_OLDWORLD_MAC 0x00000001
278#define OF_IMAP_NO_PHANDLE 0x00000002
279
280extern void of_irq_map_init(unsigned int flags);
281
282/***
283 * of_irq_map_raw - Low level interrupt tree parsing
284 * @parent: the device interrupt parent
285 * @intspec: interrupt specifier ("interrupts" property of the device)
286 * @addr: address specifier (start of "reg" property of the device)
287 * @out_irq: structure of_irq filled by this function
288 *
289 * Returns 0 on success and a negative number on error
290 *
291 * This function is a low-level interrupt tree walking function. It
292 * can be used to do a partial walk with synthetized reg and interrupts
293 * properties, for example when resolving PCI interrupts when no device
294 * node exist for the parent.
295 *
296 */
297
298extern int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 *addr,
299 struct of_irq *out_irq);
300
301
302/***
303 * of_irq_map_one - Resolve an interrupt for a device
304 * @device: the device whose interrupt is to be resolved
305 * @index: index of the interrupt to resolve
306 * @out_irq: structure of_irq filled by this function
307 *
308 * This function resolves an interrupt, walking the tree, for a given
309 * device-tree node. It's the high level pendant to of_irq_map_raw().
310 * It also implements the workarounds for OldWolrd Macs.
311 */
312extern int of_irq_map_one(struct device_node *device, int index,
313 struct of_irq *out_irq);
314
315/***
316 * of_irq_map_pci - Resolve the interrupt for a PCI device
317 * @pdev: the device whose interrupt is to be resolved
318 * @out_irq: structure of_irq filled by this function
319 *
320 * This function resolves the PCI interrupt for a given PCI device. If a
321 * device-node exists for a given pci_dev, it will use normal OF tree
322 * walking. If not, it will implement standard swizzling and walk up the
323 * PCI tree until an device-node is found, at which point it will finish
324 * resolving using the OF tree walking.
325 */
326struct pci_dev;
327extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
328
329
243#endif /* __KERNEL__ */ 330#endif /* __KERNEL__ */
244#endif /* _POWERPC_PROM_H */ 331#endif /* _POWERPC_PROM_H */