initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / asm-ppc64 / prom.h
blob482f9f60db60b95b019f4e64d250a47ea0311ed9
1 #ifndef _PPC64_PROM_H
2 #define _PPC64_PROM_H
4 /*
5 * Definitions for talking to the Open Firmware PROM on
6 * Power Macintosh computers.
8 * Copyright (C) 1996 Paul Mackerras.
10 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
17 #include <linux/proc_fs.h>
18 #include <asm/atomic.h>
20 #define PTRRELOC(x) ((typeof(x))((unsigned long)(x) - offset))
21 #define PTRUNRELOC(x) ((typeof(x))((unsigned long)(x) + offset))
22 #define RELOC(x) (*PTRRELOC(&(x)))
24 #define LONG_LSW(X) (((unsigned long)X) & 0xffffffff)
25 #define LONG_MSW(X) (((unsigned long)X) >> 32)
27 /* Definitions used by the flattened device tree */
28 #define OF_DT_HEADER 0xd00dfeed /* 4: version, 4: total size */
29 #define OF_DT_BEGIN_NODE 0x1 /* Start node: full name */
30 #define OF_DT_END_NODE 0x2 /* End node */
31 #define OF_DT_PROP 0x3 /* Property: name off, size, content */
32 #define OF_DT_END 0x9
34 #define OF_DT_VERSION 1
37 * This is what gets passed to the kernel by prom_init or kexec
39 * The dt struct contains the device tree structure, full pathes and
40 * property contents. The dt strings contain a separate block with just
41 * the strings for the property names, and is fully page aligned and
42 * self contained in a page, so that it can be kept around by the kernel,
43 * each property name appears only once in this page (cheap compression)
45 * the mem_rsvmap contains a map of reserved ranges of physical memory,
46 * passing it here instead of in the device-tree itself greatly simplifies
47 * the job of everybody. It's just a list of u64 pairs (base/size) that
48 * ends when size is 0
50 struct boot_param_header
52 u32 magic; /* magic word OF_DT_HEADER */
53 u32 totalsize; /* total size of DT block */
54 u32 off_dt_struct; /* offset to structure */
55 u32 off_dt_strings; /* offset to strings */
56 u32 off_mem_rsvmap; /* offset to memory reserve map */
57 u32 version; /* format version */
58 u32 last_comp_version; /* last compatible version */
63 typedef u32 phandle;
64 typedef u32 ihandle;
65 typedef u32 phandle32;
66 typedef u32 ihandle32;
68 struct address_range {
69 unsigned long space;
70 unsigned long address;
71 unsigned long size;
74 struct interrupt_info {
75 int line;
76 int sense; /* +ve/-ve logic, edge or level, etc. */
79 struct pci_address {
80 u32 a_hi;
81 u32 a_mid;
82 u32 a_lo;
85 struct isa_address {
86 u32 a_hi;
87 u32 a_lo;
90 struct isa_range {
91 struct isa_address isa_addr;
92 struct pci_address pci_addr;
93 unsigned int size;
96 struct pci_range32 {
97 struct pci_address child_addr;
98 unsigned int parent_addr;
99 unsigned long size;
102 struct pci_range64 {
103 struct pci_address child_addr;
104 unsigned long parent_addr;
105 unsigned long size;
108 union pci_range {
109 struct {
110 struct pci_address addr;
111 u32 phys;
112 u32 size_hi;
113 } pci32;
114 struct {
115 struct pci_address addr;
116 u32 phys_hi;
117 u32 phys_lo;
118 u32 size_hi;
119 u32 size_lo;
120 } pci64;
123 struct of_tce_table {
124 phandle node;
125 unsigned long base;
126 unsigned long size;
128 extern struct of_tce_table of_tce_table[];
130 struct reg_property {
131 unsigned long address;
132 unsigned long size;
135 struct reg_property32 {
136 unsigned int address;
137 unsigned int size;
140 struct reg_property64 {
141 unsigned long address;
142 unsigned long size;
145 struct reg_property_pmac {
146 unsigned int address_hi;
147 unsigned int address_lo;
148 unsigned int size;
151 struct translation_property {
152 unsigned long virt;
153 unsigned long size;
154 unsigned long phys;
155 unsigned int flags;
158 struct property {
159 char *name;
160 int length;
161 unsigned char *value;
162 struct property *next;
165 /* NOTE: the device_node contains PCI specific info for pci devices.
166 * This perhaps could be hung off the device_node with another struct,
167 * but for now it is directly in the node. The phb ptr is a good
168 * indication of a real PCI node. Other nodes leave these fields zeroed.
170 struct pci_controller;
171 struct iommu_table;
173 struct device_node {
174 char *name;
175 char *type;
176 phandle node;
177 phandle linux_phandle;
178 int n_addrs;
179 struct address_range *addrs;
180 int n_intrs;
181 struct interrupt_info *intrs;
182 char *full_name;
184 /* PCI stuff probably doesn't belong here */
185 int busno; /* for pci devices */
186 int bussubno; /* for pci devices */
187 int devfn; /* for pci devices */
188 #define DN_STATUS_BIST_FAILED (1<<0)
189 int status; /* Current device status (non-zero is bad) */
190 int eeh_mode; /* See eeh.h for possible EEH_MODEs */
191 int eeh_config_addr;
192 struct pci_controller *phb; /* for pci devices */
193 struct iommu_table *iommu_table; /* for phb's or bridges */
195 struct property *properties;
196 struct device_node *parent;
197 struct device_node *child;
198 struct device_node *sibling;
199 struct device_node *next; /* next device of same type */
200 struct device_node *allnext; /* next in list of all nodes */
201 struct proc_dir_entry *pde; /* this node's proc directory */
202 struct proc_dir_entry *name_link; /* name symlink */
203 struct proc_dir_entry *addr_link; /* addr symlink */
204 atomic_t _users; /* reference count */
205 unsigned long _flags;
208 extern struct device_node *of_chosen;
210 /* flag descriptions */
211 #define OF_STALE 0 /* node is slated for deletion */
212 #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
214 #define OF_IS_STALE(x) test_bit(OF_STALE, &x->_flags)
215 #define OF_MARK_STALE(x) set_bit(OF_STALE, &x->_flags)
216 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
217 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
220 * Until 32-bit ppc can add proc_dir_entries to its device_node
221 * definition, we cannot refer to pde, name_link, and addr_link
222 * in arch-independent code.
224 #define HAVE_ARCH_DEVTREE_FIXUPS
226 static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
228 dn->pde = de;
231 static void inline set_node_name_link(struct device_node *dn, struct proc_dir_entry *de)
233 dn->name_link = de;
236 static void inline set_node_addr_link(struct device_node *dn, struct proc_dir_entry *de)
238 dn->addr_link = de;
241 /* OBSOLETE: Old stlye node lookup */
242 extern struct device_node *find_devices(const char *name);
243 extern struct device_node *find_type_devices(const char *type);
244 extern struct device_node *find_path_device(const char *path);
245 extern struct device_node *find_compatible_devices(const char *type,
246 const char *compat);
247 extern struct device_node *find_all_nodes(void);
249 /* New style node lookup */
250 extern struct device_node *of_find_node_by_name(struct device_node *from,
251 const char *name);
252 extern struct device_node *of_find_node_by_type(struct device_node *from,
253 const char *type);
254 extern struct device_node *of_find_compatible_node(struct device_node *from,
255 const char *type, const char *compat);
256 extern struct device_node *of_find_node_by_path(const char *path);
257 extern struct device_node *of_find_node_by_phandle(phandle handle);
258 extern struct device_node *of_find_all_nodes(struct device_node *prev);
259 extern struct device_node *of_get_parent(const struct device_node *node);
260 extern struct device_node *of_get_next_child(const struct device_node *node,
261 struct device_node *prev);
262 extern struct device_node *of_node_get(struct device_node *node);
263 extern void of_node_put(struct device_node *node);
265 /* For updating the device tree at runtime */
266 extern int of_add_node(const char *path, struct property *proplist);
267 extern int of_remove_node(struct device_node *np);
269 /* Other Prototypes */
270 extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
271 unsigned long, unsigned long);
272 extern void relocate_nodes(void);
273 extern void finish_device_tree(void);
274 extern int device_is_compatible(struct device_node *device, const char *);
275 extern int machine_is_compatible(const char *compat);
276 extern unsigned char *get_property(struct device_node *node, const char *name,
277 int *lenp);
278 extern void print_properties(struct device_node *node);
279 extern int prom_n_addr_cells(struct device_node* np);
280 extern int prom_n_size_cells(struct device_node* np);
281 extern int prom_n_intr_cells(struct device_node* np);
282 extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
283 extern void prom_add_property(struct device_node* np, struct property* prop);
285 #endif /* _PPC64_PROM_H */