First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / sparc / include / asm / oplib_32.h
blob33e31ce6b31f56c4952083096fb9bc5c58928cd9
1 /*
2 * oplib.h: Describes the interface and available routines in the
3 * Linux Prom library.
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
8 #ifndef __SPARC_OPLIB_H
9 #define __SPARC_OPLIB_H
11 #include <asm/openprom.h>
12 #include <linux/spinlock.h>
13 #include <linux/compiler.h>
15 /* The master romvec pointer... */
16 extern struct linux_romvec *romvec;
18 /* Enumeration to describe the prom major version we have detected. */
19 enum prom_major_version {
20 PROM_V0, /* Original sun4c V0 prom */
21 PROM_V2, /* sun4c and early sun4m V2 prom */
22 PROM_V3, /* sun4m and later, up to sun4d/sun4e machines V3 */
23 PROM_P1275, /* IEEE compliant ISA based Sun PROM, only sun4u */
26 extern enum prom_major_version prom_vers;
27 /* Revision, and firmware revision. */
28 extern unsigned int prom_rev, prom_prev;
30 /* Root node of the prom device tree, this stays constant after
31 * initialization is complete.
33 extern int prom_root_node;
35 /* Pointer to prom structure containing the device tree traversal
36 * and usage utility functions. Only prom-lib should use these,
37 * users use the interface defined by the library only!
39 extern struct linux_nodeops *prom_nodeops;
41 /* The functions... */
43 /* You must call prom_init() before using any of the library services,
44 * preferably as early as possible. Pass it the romvec pointer.
46 extern void prom_init(struct linux_romvec *rom_ptr);
48 /* Boot argument acquisition, returns the boot command line string. */
49 extern char *prom_getbootargs(void);
51 /* Device utilities. */
53 /* Map and unmap devices in IO space at virtual addresses. Note that the
54 * virtual address you pass is a request and the prom may put your mappings
55 * somewhere else, so check your return value as that is where your new
56 * mappings really are!
58 * Another note, these are only available on V2 or higher proms!
60 extern char *prom_mapio(char *virt_hint, int io_space, unsigned int phys_addr, unsigned int num_bytes);
61 extern void prom_unmapio(char *virt_addr, unsigned int num_bytes);
63 /* Device operations. */
65 /* Open the device described by the passed string. Note, that the format
66 * of the string is different on V0 vs. V2->higher proms. The caller must
67 * know what he/she is doing! Returns the device descriptor, an int.
69 extern int prom_devopen(char *device_string);
71 /* Close a previously opened device described by the passed integer
72 * descriptor.
74 extern int prom_devclose(int device_handle);
76 /* Do a seek operation on the device described by the passed integer
77 * descriptor.
79 extern void prom_seek(int device_handle, unsigned int seek_hival,
80 unsigned int seek_lowval);
82 /* Miscellaneous routines, don't really fit in any category per se. */
84 /* Reboot the machine with the command line passed. */
85 extern void prom_reboot(char *boot_command);
87 /* Evaluate the forth string passed. */
88 extern void prom_feval(char *forth_string);
90 /* Enter the prom, with possibility of continuation with the 'go'
91 * command in newer proms.
93 extern void prom_cmdline(void);
95 /* Enter the prom, with no chance of continuation for the stand-alone
96 * which calls this.
98 extern void prom_halt(void) __attribute__ ((noreturn));
100 /* Set the PROM 'sync' callback function to the passed function pointer.
101 * When the user gives the 'sync' command at the prom prompt while the
102 * kernel is still active, the prom will call this routine.
104 * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
106 typedef void (*sync_func_t)(void);
107 extern void prom_setsync(sync_func_t func_ptr);
109 /* Acquire the IDPROM of the root node in the prom device tree. This
110 * gets passed a buffer where you would like it stuffed. The return value
111 * is the format type of this idprom or 0xff on error.
113 extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
115 /* Get the prom major version. */
116 extern int prom_version(void);
118 /* Get the prom plugin revision. */
119 extern int prom_getrev(void);
121 /* Get the prom firmware revision. */
122 extern int prom_getprev(void);
124 /* Character operations to/from the console.... */
126 /* Non-blocking get character from console. */
127 extern int prom_nbgetchar(void);
129 /* Non-blocking put character to console. */
130 extern int prom_nbputchar(char character);
132 /* Blocking get character from console. */
133 extern char prom_getchar(void);
135 /* Blocking put character to console. */
136 extern void prom_putchar(char character);
138 /* Prom's internal routines, don't use in kernel/boot code. */
139 extern void prom_printf(const char *fmt, ...);
140 extern void prom_write(const char *buf, unsigned int len);
142 /* Multiprocessor operations... */
144 /* Start the CPU with the given device tree node, context table, and context
145 * at the passed program counter.
147 extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
148 int context, char *program_counter);
150 /* Stop the CPU with the passed device tree node. */
151 extern int prom_stopcpu(int cpunode);
153 /* Idle the CPU with the passed device tree node. */
154 extern int prom_idlecpu(int cpunode);
156 /* Re-Start the CPU with the passed device tree node. */
157 extern int prom_restartcpu(int cpunode);
159 /* PROM memory allocation facilities... */
161 /* Allocated at possibly the given virtual address a chunk of the
162 * indicated size.
164 extern char *prom_alloc(char *virt_hint, unsigned int size);
166 /* Free a previously allocated chunk. */
167 extern void prom_free(char *virt_addr, unsigned int size);
169 /* Sun4/sun4c specific memory-management startup hook. */
171 /* Map the passed segment in the given context at the passed
172 * virtual address.
174 extern void prom_putsegment(int context, unsigned long virt_addr,
175 int physical_segment);
178 /* PROM device tree traversal functions... */
180 /* Get the child node of the given node, or zero if no child exists. */
181 extern int prom_getchild(int parent_node);
183 /* Get the next sibling node of the given node, or zero if no further
184 * siblings exist.
186 extern int prom_getsibling(int node);
188 /* Get the length, at the passed node, of the given property type.
189 * Returns -1 on error (ie. no such property at this node).
191 extern int prom_getproplen(int thisnode, const char *property);
193 /* Fetch the requested property using the given buffer. Returns
194 * the number of bytes the prom put into your buffer or -1 on error.
196 extern int __must_check prom_getproperty(int thisnode, const char *property,
197 char *prop_buffer, int propbuf_size);
199 /* Acquire an integer property. */
200 extern int prom_getint(int node, char *property);
202 /* Acquire an integer property, with a default value. */
203 extern int prom_getintdefault(int node, char *property, int defval);
205 /* Acquire a boolean property, 0=FALSE 1=TRUE. */
206 extern int prom_getbool(int node, char *prop);
208 /* Acquire a string property, null string on error. */
209 extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
211 /* Does the passed node have the given "name"? YES=1 NO=0 */
212 extern int prom_nodematch(int thisnode, char *name);
214 /* Search all siblings starting at the passed node for "name" matching
215 * the given string. Returns the node on success, zero on failure.
217 extern int prom_searchsiblings(int node_start, char *name);
219 /* Return the first property type, as a string, for the given node.
220 * Returns a null string on error.
222 extern char *prom_firstprop(int node, char *buffer);
224 /* Returns the next property after the passed property for the given
225 * node. Returns null string on failure.
227 extern char *prom_nextprop(int node, char *prev_property, char *buffer);
229 /* Returns phandle of the path specified */
230 extern int prom_finddevice(char *name);
232 /* Returns 1 if the specified node has given property. */
233 extern int prom_node_has_property(int node, char *property);
235 /* Set the indicated property at the given node with the passed value.
236 * Returns the number of bytes of your value that the prom took.
238 extern int prom_setprop(int node, const char *prop_name, char *prop_value,
239 int value_size);
241 extern int prom_pathtoinode(char *path);
242 extern int prom_inst2pkg(int);
244 /* Dorking with Bus ranges... */
246 /* Apply promlib probes OBIO ranges to registers. */
247 extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
249 /* Apply ranges of any prom node (and optionally parent node as well) to registers. */
250 extern void prom_apply_generic_ranges(int node, int parent,
251 struct linux_prom_registers *sbusregs, int nregs);
253 /* CPU probing helpers. */
254 int cpu_find_by_instance(int instance, int *prom_node, int *mid);
255 int cpu_find_by_mid(int mid, int *prom_node);
256 int cpu_get_hwmid(int prom_node);
258 extern spinlock_t prom_lock;
260 #endif /* !(__SPARC_OPLIB_H) */