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)
28 typedef void *ihandle;
29 typedef u32 phandle32;
30 typedef u32 ihandle32;
32 extern char *prom_display_paths[];
33 extern unsigned int prom_num_displays;
35 struct address_range {
37 unsigned long address;
41 struct interrupt_info {
43 int sense; /* +ve/-ve logic, edge or level, etc. */
58 struct isa_address isa_addr;
59 struct pci_address pci_addr;
64 struct pci_address child_addr;
65 unsigned int parent_addr;
70 struct pci_address child_addr;
71 unsigned long parent_addr;
77 struct pci_address addr;
82 struct pci_address addr;
95 extern struct of_tce_table of_tce_table[];
98 unsigned long address;
102 struct reg_property32 {
103 unsigned int address;
107 struct reg_property64 {
108 unsigned long address;
112 struct reg_property_pmac {
113 unsigned int address_hi;
114 unsigned int address_lo;
118 struct translation_property {
128 unsigned char *value;
129 struct property *next;
132 /* NOTE: the device_node contains PCI specific info for pci devices.
133 * This perhaps could be hung off the device_node with another struct,
134 * but for now it is directly in the node. The phb ptr is a good
135 * indication of a real PCI node. Other nodes leave these fields zeroed.
137 struct pci_controller;
143 phandle linux_phandle;
145 struct address_range *addrs;
147 struct interrupt_info *intrs;
150 /* PCI stuff probably doesn't belong here */
151 int busno; /* for pci devices */
152 int bussubno; /* for pci devices */
153 int devfn; /* for pci devices */
154 #define DN_STATUS_BIST_FAILED (1<<0)
155 int status; /* Current device status (non-zero is bad) */
156 int eeh_mode; /* See eeh.h for possible EEH_MODEs */
158 struct pci_controller *phb; /* for pci devices */
159 struct iommu_table *iommu_table; /* for phb's or bridges */
161 struct property *properties;
162 struct device_node *parent;
163 struct device_node *child;
164 struct device_node *sibling;
165 struct device_node *next; /* next device of same type */
166 struct device_node *allnext; /* next in list of all nodes */
167 struct proc_dir_entry *pde; /* this node's proc directory */
168 struct proc_dir_entry *name_link; /* name symlink */
169 struct proc_dir_entry *addr_link; /* addr symlink */
170 atomic_t _users; /* reference count */
171 unsigned long _flags;
174 /* flag descriptions */
175 #define OF_STALE 0 /* node is slated for deletion */
176 #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
178 #define OF_IS_STALE(x) test_bit(OF_STALE, &x->_flags)
179 #define OF_MARK_STALE(x) set_bit(OF_STALE, &x->_flags)
180 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
181 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
184 * Until 32-bit ppc can add proc_dir_entries to its device_node
185 * definition, we cannot refer to pde, name_link, and addr_link
186 * in arch-independent code.
188 #define HAVE_ARCH_DEVTREE_FIXUPS
190 static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
195 static void inline set_node_name_link(struct device_node *dn, struct proc_dir_entry *de)
200 static void inline set_node_addr_link(struct device_node *dn, struct proc_dir_entry *de)
205 typedef u32 prom_arg_t;
212 prom_arg_t *rets; /* Pointer to return values in args[16]. */
222 struct prom_args args;
223 unsigned long version;
224 unsigned long encode_phys_size;
225 struct bi_record *bi_recs;
228 extern struct prom_t prom;
229 extern char *of_stdout_device;
231 extern int boot_cpuid;
233 /* OBSOLETE: Old stlye node lookup */
234 extern struct device_node *find_devices(const char *name);
235 extern struct device_node *find_type_devices(const char *type);
236 extern struct device_node *find_path_device(const char *path);
237 extern struct device_node *find_compatible_devices(const char *type,
239 extern struct device_node *find_all_nodes(void);
241 /* New style node lookup */
242 extern struct device_node *of_find_node_by_name(struct device_node *from,
244 extern struct device_node *of_find_node_by_type(struct device_node *from,
246 extern struct device_node *of_find_compatible_node(struct device_node *from,
247 const char *type, const char *compat);
248 extern struct device_node *of_find_node_by_path(const char *path);
249 extern struct device_node *of_find_all_nodes(struct device_node *prev);
250 extern struct device_node *of_get_parent(const struct device_node *node);
251 extern struct device_node *of_get_next_child(const struct device_node *node,
252 struct device_node *prev);
253 extern struct device_node *of_node_get(struct device_node *node);
254 extern void of_node_put(struct device_node *node);
256 /* For updating the device tree at runtime */
257 extern int of_add_node(const char *path, struct property *proplist);
258 extern int of_remove_node(struct device_node *np);
260 /* Other Prototypes */
261 extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
262 unsigned long, unsigned long);
263 extern void relocate_nodes(void);
264 extern void finish_device_tree(void);
265 extern int device_is_compatible(struct device_node *device, const char *);
266 extern int machine_is_compatible(const char *compat);
267 extern unsigned char *get_property(struct device_node *node, const char *name,
269 extern void print_properties(struct device_node *node);
270 extern int prom_n_addr_cells(struct device_node* np);
271 extern int prom_n_size_cells(struct device_node* np);
272 extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
273 extern void prom_add_property(struct device_node* np, struct property* prop);
275 #endif /* _PPC64_PROM_H */