of/irq: Move irq_of_parse_and_map() to common code
[deliverable/linux.git] / arch / powerpc / include / asm / prom.h
1 #include <linux/of.h> /* linux/of.h gets to determine #include ordering */
2 #ifndef _POWERPC_PROM_H
3 #define _POWERPC_PROM_H
4 #ifdef __KERNEL__
5
6 /*
7 * Definitions for talking to the Open Firmware PROM on
8 * Power Macintosh computers.
9 *
10 * Copyright (C) 1996-2005 Paul Mackerras.
11 *
12 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19 #include <linux/types.h>
20 #include <linux/of_fdt.h>
21 #include <linux/of_irq.h>
22 #include <linux/proc_fs.h>
23 #include <linux/platform_device.h>
24 #include <asm/irq.h>
25 #include <asm/atomic.h>
26
27 #define HAVE_ARCH_DEVTREE_FIXUPS
28
29 #ifdef CONFIG_PPC32
30 /*
31 * PCI <-> OF matching functions
32 * (XXX should these be here?)
33 */
34 struct pci_bus;
35 struct pci_dev;
36 extern int pci_device_from_OF_node(struct device_node *node,
37 u8* bus, u8* devfn);
38 extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
39 extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
40 extern void pci_create_OF_bus_map(void);
41 #endif
42
43 /*
44 * OF address retreival & translation
45 */
46
47 /* Translate an OF address block into a CPU physical address
48 */
49 extern u64 of_translate_address(struct device_node *np, const u32 *addr);
50
51 /* Translate a DMA address from device space to CPU space */
52 extern u64 of_translate_dma_address(struct device_node *dev,
53 const u32 *in_addr);
54
55 /* Extract an address from a device, returns the region size and
56 * the address space flags too. The PCI version uses a BAR number
57 * instead of an absolute index
58 */
59 extern const u32 *of_get_address(struct device_node *dev, int index,
60 u64 *size, unsigned int *flags);
61 #ifdef CONFIG_PCI
62 extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
63 u64 *size, unsigned int *flags);
64 #else
65 static inline const u32 *of_get_pci_address(struct device_node *dev,
66 int bar_no, u64 *size, unsigned int *flags)
67 {
68 return NULL;
69 }
70 #endif /* CONFIG_PCI */
71
72 /* Get an address as a resource. Note that if your address is
73 * a PIO address, the conversion will fail if the physical address
74 * can't be internally converted to an IO token with
75 * pci_address_to_pio(), that is because it's either called to early
76 * or it can't be matched to any host bridge IO space
77 */
78 extern int of_address_to_resource(struct device_node *dev, int index,
79 struct resource *r);
80 #ifdef CONFIG_PCI
81 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
82 struct resource *r);
83 #else
84 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
85 struct resource *r)
86 {
87 return -ENOSYS;
88 }
89 #endif /* CONFIG_PCI */
90
91 /* Parse the ibm,dma-window property of an OF node into the busno, phys and
92 * size parameters.
93 */
94 void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
95 unsigned long *busno, unsigned long *phys, unsigned long *size);
96
97 extern void kdump_move_device_tree(void);
98
99 /* CPU OF node matching */
100 struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
101
102 /* cache lookup */
103 struct device_node *of_find_next_cache_node(struct device_node *np);
104
105 /* Get the MAC address */
106 extern const void *of_get_mac_address(struct device_node *np);
107
108 /*
109 * OF interrupt mapping
110 */
111
112 /**
113 * of_irq_map_init - Initialize the irq remapper
114 * @flags: flags defining workarounds to enable
115 *
116 * Some machines have bugs in the device-tree which require certain workarounds
117 * to be applied. Call this before any interrupt mapping attempts to enable
118 * those workarounds.
119 */
120 #define OF_IMAP_OLDWORLD_MAC 0x00000001
121 #define OF_IMAP_NO_PHANDLE 0x00000002
122
123 extern void of_irq_map_init(unsigned int flags);
124
125 /**
126 * of_irq_map_raw - Low level interrupt tree parsing
127 * @parent: the device interrupt parent
128 * @intspec: interrupt specifier ("interrupts" property of the device)
129 * @ointsize: size of the passed in interrupt specifier
130 * @addr: address specifier (start of "reg" property of the device)
131 * @out_irq: structure of_irq filled by this function
132 *
133 * Returns 0 on success and a negative number on error
134 *
135 * This function is a low-level interrupt tree walking function. It
136 * can be used to do a partial walk with synthetized reg and interrupts
137 * properties, for example when resolving PCI interrupts when no device
138 * node exist for the parent.
139 *
140 */
141
142 extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
143 u32 ointsize, const u32 *addr,
144 struct of_irq *out_irq);
145
146 /**
147 * of_irq_map_pci - Resolve the interrupt for a PCI device
148 * @pdev: the device whose interrupt is to be resolved
149 * @out_irq: structure of_irq filled by this function
150 *
151 * This function resolves the PCI interrupt for a given PCI device. If a
152 * device-node exists for a given pci_dev, it will use normal OF tree
153 * walking. If not, it will implement standard swizzling and walk up the
154 * PCI tree until an device-node is found, at which point it will finish
155 * resolving using the OF tree walking.
156 */
157 struct pci_dev;
158 extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
159
160 extern int of_irq_to_resource(struct device_node *dev, int index,
161 struct resource *r);
162
163 /**
164 * of_iomap - Maps the memory mapped IO for a given device_node
165 * @device: the device whose io range will be mapped
166 * @index: index of the io range
167 *
168 * Returns a pointer to the mapped memory
169 */
170 extern void __iomem *of_iomap(struct device_node *device, int index);
171
172 #endif /* __KERNEL__ */
173 #endif /* _POWERPC_PROM_H */
This page took 0.033867 seconds and 5 git commands to generate.