Merge branch 'kbuild/clean' into kbuild/kbuild
[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/proc_fs.h>
22 #include <linux/platform_device.h>
23 #include <asm/irq.h>
24 #include <asm/atomic.h>
25
26 #define HAVE_ARCH_DEVTREE_FIXUPS
27
28 #ifdef CONFIG_PPC32
29 /*
30 * PCI <-> OF matching functions
31 * (XXX should these be here?)
32 */
33 struct pci_bus;
34 struct pci_dev;
35 extern int pci_device_from_OF_node(struct device_node *node,
36 u8* bus, u8* devfn);
37 extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
38 extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
39 extern void pci_create_OF_bus_map(void);
40 #endif
41
42 /*
43 * OF address retreival & translation
44 */
45
46 /* Translate an OF address block into a CPU physical address
47 */
48 extern u64 of_translate_address(struct device_node *np, const u32 *addr);
49
50 /* Translate a DMA address from device space to CPU space */
51 extern u64 of_translate_dma_address(struct device_node *dev,
52 const u32 *in_addr);
53
54 /* Extract an address from a device, returns the region size and
55 * the address space flags too. The PCI version uses a BAR number
56 * instead of an absolute index
57 */
58 extern const u32 *of_get_address(struct device_node *dev, int index,
59 u64 *size, unsigned int *flags);
60 #ifdef CONFIG_PCI
61 extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
62 u64 *size, unsigned int *flags);
63 #else
64 static inline const u32 *of_get_pci_address(struct device_node *dev,
65 int bar_no, u64 *size, unsigned int *flags)
66 {
67 return NULL;
68 }
69 #endif /* CONFIG_PCI */
70
71 /* Get an address as a resource. Note that if your address is
72 * a PIO address, the conversion will fail if the physical address
73 * can't be internally converted to an IO token with
74 * pci_address_to_pio(), that is because it's either called to early
75 * or it can't be matched to any host bridge IO space
76 */
77 extern int of_address_to_resource(struct device_node *dev, int index,
78 struct resource *r);
79 #ifdef CONFIG_PCI
80 extern int of_pci_address_to_resource(struct device_node *dev, int bar,
81 struct resource *r);
82 #else
83 static inline int of_pci_address_to_resource(struct device_node *dev, int bar,
84 struct resource *r)
85 {
86 return -ENOSYS;
87 }
88 #endif /* CONFIG_PCI */
89
90 /* Parse the ibm,dma-window property of an OF node into the busno, phys and
91 * size parameters.
92 */
93 void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
94 unsigned long *busno, unsigned long *phys, unsigned long *size);
95
96 extern void kdump_move_device_tree(void);
97
98 /* CPU OF node matching */
99 struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
100
101 /* cache lookup */
102 struct device_node *of_find_next_cache_node(struct device_node *np);
103
104 /* Get the MAC address */
105 extern const void *of_get_mac_address(struct device_node *np);
106
107 /*
108 * OF interrupt mapping
109 */
110
111 /* This structure is returned when an interrupt is mapped. The controller
112 * field needs to be put() after use
113 */
114
115 #define OF_MAX_IRQ_SPEC 4 /* We handle specifiers of at most 4 cells */
116
117 struct of_irq {
118 struct device_node *controller; /* Interrupt controller node */
119 u32 size; /* Specifier size */
120 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
121 };
122
123 /**
124 * of_irq_map_init - Initialize the irq remapper
125 * @flags: flags defining workarounds to enable
126 *
127 * Some machines have bugs in the device-tree which require certain workarounds
128 * to be applied. Call this before any interrupt mapping attempts to enable
129 * those workarounds.
130 */
131 #define OF_IMAP_OLDWORLD_MAC 0x00000001
132 #define OF_IMAP_NO_PHANDLE 0x00000002
133
134 extern void of_irq_map_init(unsigned int flags);
135
136 /**
137 * of_irq_map_raw - Low level interrupt tree parsing
138 * @parent: the device interrupt parent
139 * @intspec: interrupt specifier ("interrupts" property of the device)
140 * @ointsize: size of the passed in interrupt specifier
141 * @addr: address specifier (start of "reg" property of the device)
142 * @out_irq: structure of_irq filled by this function
143 *
144 * Returns 0 on success and a negative number on error
145 *
146 * This function is a low-level interrupt tree walking function. It
147 * can be used to do a partial walk with synthetized reg and interrupts
148 * properties, for example when resolving PCI interrupts when no device
149 * node exist for the parent.
150 *
151 */
152
153 extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
154 u32 ointsize, const u32 *addr,
155 struct of_irq *out_irq);
156
157
158 /**
159 * of_irq_map_one - Resolve an interrupt for a device
160 * @device: the device whose interrupt is to be resolved
161 * @index: index of the interrupt to resolve
162 * @out_irq: structure of_irq filled by this function
163 *
164 * This function resolves an interrupt, walking the tree, for a given
165 * device-tree node. It's the high level pendant to of_irq_map_raw().
166 * It also implements the workarounds for OldWolrd Macs.
167 */
168 extern int of_irq_map_one(struct device_node *device, int index,
169 struct of_irq *out_irq);
170
171 /**
172 * of_irq_map_pci - Resolve the interrupt for a PCI device
173 * @pdev: the device whose interrupt is to be resolved
174 * @out_irq: structure of_irq filled by this function
175 *
176 * This function resolves the PCI interrupt for a given PCI device. If a
177 * device-node exists for a given pci_dev, it will use normal OF tree
178 * walking. If not, it will implement standard swizzling and walk up the
179 * PCI tree until an device-node is found, at which point it will finish
180 * resolving using the OF tree walking.
181 */
182 struct pci_dev;
183 extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
184
185 extern int of_irq_to_resource(struct device_node *dev, int index,
186 struct resource *r);
187
188 /**
189 * of_iomap - Maps the memory mapped IO for a given device_node
190 * @device: the device whose io range will be mapped
191 * @index: index of the io range
192 *
193 * Returns a pointer to the mapped memory
194 */
195 extern void __iomem *of_iomap(struct device_node *device, int index);
196
197 #endif /* __KERNEL__ */
198 #endif /* _POWERPC_PROM_H */
This page took 0.041517 seconds and 6 git commands to generate.