2 * Definitions for talking to the Open Firmware PROM on
3 * Power Macintosh computers.
5 * Copyright (C) 1996 Paul Mackerras.
11 #include <linux/config.h>
12 #include <linux/types.h>
17 struct address_range
{
23 struct interrupt_info
{
25 int sense
; /* +ve/-ve logic, edge or level, etc. */
37 struct property
*next
;
41 * Note: don't change this structure for now or you'll break BootX !
48 struct address_range
*addrs
;
50 struct interrupt_info
*intrs
;
52 struct property
*properties
;
53 struct device_node
*parent
;
54 struct device_node
*child
;
55 struct device_node
*sibling
;
56 struct device_node
*next
; /* next device of same type */
57 struct device_node
*allnext
; /* next in list of all nodes */
61 typedef void (*prom_entry
)(struct prom_args
*);
63 /* OBSOLETE: Old style node lookup */
64 extern struct device_node
*find_devices(const char *name
);
65 extern struct device_node
*find_type_devices(const char *type
);
66 extern struct device_node
*find_path_device(const char *path
);
67 extern struct device_node
*find_compatible_devices(const char *type
,
69 extern struct device_node
*find_all_nodes(void);
71 /* New style node lookup */
72 extern struct device_node
*of_find_node_by_name(struct device_node
*from
,
74 extern struct device_node
*of_find_node_by_type(struct device_node
*from
,
76 extern struct device_node
*of_find_compatible_node(struct device_node
*from
,
77 const char *type
, const char *compat
);
78 extern struct device_node
*of_find_node_by_path(const char *path
);
79 extern struct device_node
*of_find_all_nodes(struct device_node
*prev
);
80 extern struct device_node
*of_get_parent(const struct device_node
*node
);
81 extern struct device_node
*of_get_next_child(const struct device_node
*node
,
82 struct device_node
*prev
);
83 extern struct device_node
*of_node_get(struct device_node
*node
);
84 extern void of_node_put(struct device_node
*node
);
86 /* Other Prototypes */
87 extern void abort(void);
88 extern unsigned long prom_init(int, int, prom_entry
);
89 extern void prom_print(const char *msg
);
90 extern void relocate_nodes(void);
91 extern void finish_device_tree(void);
92 extern int device_is_compatible(struct device_node
*device
, const char *);
93 extern int machine_is_compatible(const char *compat
);
94 extern unsigned char *get_property(struct device_node
*node
, const char *name
,
96 extern int prom_add_property(struct device_node
* np
, struct property
* prop
);
97 extern void prom_get_irq_senses(unsigned char *, int, int);
98 extern int prom_n_addr_cells(struct device_node
* np
);
99 extern int prom_n_size_cells(struct device_node
* np
);
101 extern struct resource
*
102 request_OF_resource(struct device_node
* node
, int index
, const char* name_postfix
);
103 extern int release_OF_resource(struct device_node
* node
, int index
);
105 extern void print_properties(struct device_node
*node
);
106 extern int call_rtas(const char *service
, int nargs
, int nret
,
107 unsigned long *outputs
, ...);
110 * PCI <-> OF matching functions
114 extern int pci_device_from_OF_node(struct device_node
*node
,
116 extern struct device_node
* pci_busdev_to_OF_node(struct pci_bus
*, int);
117 extern struct device_node
* pci_device_to_OF_node(struct pci_dev
*);
118 extern void pci_create_OF_bus_map(void);
121 * When we call back to the Open Firmware client interface, we usually
122 * have to do that before the kernel is relocated to its final location
123 * (this is because we can't use OF after we have overwritten the
124 * exception vectors with our exception handlers). These macros assist
125 * in performing the address calculations that we need to do to access
126 * data when the kernel is running at an address that is different from
127 * the address that the kernel is linked at. The reloc_offset() function
128 * returns the difference between these two addresses and the macros
129 * simplify the process of adding or subtracting this offset to/from
130 * pointer values. See arch/ppc/kernel/prom.c for how these are used.
132 extern unsigned long reloc_offset(void);
133 extern unsigned long add_reloc_offset(unsigned long);
134 extern unsigned long sub_reloc_offset(unsigned long);
136 #define PTRRELOC(x) ((typeof(x))add_reloc_offset((unsigned long)(x)))
137 #define PTRUNRELOC(x) ((typeof(x))sub_reloc_offset((unsigned long)(x)))
141 * OF address retreival & translation
145 /* Translate an OF address block into a CPU physical address
147 #define OF_BAD_ADDR ((u64)-1)
148 extern u64
of_translate_address(struct device_node
*np
, u32
*addr
);
150 /* Extract an address from a device, returns the region size and
151 * the address space flags too. The PCI version uses a BAR number
152 * instead of an absolute index
154 extern u32
*of_get_address(struct device_node
*dev
, int index
,
155 u64
*size
, unsigned int *flags
);
156 extern u32
*of_get_pci_address(struct device_node
*dev
, int bar_no
,
157 u64
*size
, unsigned int *flags
);
159 /* Get an address as a resource. Note that if your address is
160 * a PIO address, the conversion will fail if the physical address
161 * can't be internally converted to an IO token with
162 * pci_address_to_pio(), that is because it's either called to early
163 * or it can't be matched to any host bridge IO space
165 extern int of_address_to_resource(struct device_node
*dev
, int index
,
167 extern int of_pci_address_to_resource(struct device_node
*dev
, int bar
,
170 #ifndef CONFIG_PPC_OF
172 * Fallback definitions for builds where we don't have prom.c included.
174 #define machine_is_compatible(x) 0
175 #define of_find_compatible_node(f, t, c) NULL
176 #define get_property(p, n, l) NULL
179 #endif /* _PPC_PROM_H */
180 #endif /* __KERNEL__ */