spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / arch / sparc / prom / misc_32.c
blob677b6a10fbde3e2e4c6728027d67ae5b24ed9eeb
1 /*
2 * misc.c: Miscellaneous prom functions that don't belong
3 * anywhere else.
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/module.h>
13 #include <asm/openprom.h>
14 #include <asm/oplib.h>
15 #include <asm/auxio.h>
16 #include <asm/system.h>
18 extern void restore_current(void);
20 DEFINE_SPINLOCK(prom_lock);
22 /* Reset and reboot the machine with the command 'bcommand'. */
23 void
24 prom_reboot(char *bcommand)
26 unsigned long flags;
27 spin_lock_irqsave(&prom_lock, flags);
28 (*(romvec->pv_reboot))(bcommand);
29 /* Never get here. */
30 restore_current();
31 spin_unlock_irqrestore(&prom_lock, flags);
34 /* Forth evaluate the expression contained in 'fstring'. */
35 void
36 prom_feval(char *fstring)
38 unsigned long flags;
39 if(!fstring || fstring[0] == 0)
40 return;
41 spin_lock_irqsave(&prom_lock, flags);
42 if(prom_vers == PROM_V0)
43 (*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
44 else
45 (*(romvec->pv_fortheval.v2_eval))(fstring);
46 restore_current();
47 spin_unlock_irqrestore(&prom_lock, flags);
49 EXPORT_SYMBOL(prom_feval);
51 /* Drop into the prom, with the chance to continue with the 'go'
52 * prom command.
54 void
55 prom_cmdline(void)
57 unsigned long flags;
59 spin_lock_irqsave(&prom_lock, flags);
60 (*(romvec->pv_abort))();
61 restore_current();
62 spin_unlock_irqrestore(&prom_lock, flags);
63 set_auxio(AUXIO_LED, 0);
66 /* Drop into the prom, but completely terminate the program.
67 * No chance of continuing.
69 void __noreturn
70 prom_halt(void)
72 unsigned long flags;
73 again:
74 spin_lock_irqsave(&prom_lock, flags);
75 (*(romvec->pv_halt))();
76 /* Never get here. */
77 restore_current();
78 spin_unlock_irqrestore(&prom_lock, flags);
79 goto again; /* PROM is out to get me -DaveM */
82 typedef void (*sfunc_t)(void);
84 /* Set prom sync handler to call function 'funcp'. */
85 void
86 prom_setsync(sfunc_t funcp)
88 if(!funcp) return;
89 *romvec->pv_synchook = funcp;
92 /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
93 * format type. 'num_bytes' is the number of bytes that your idbuf
94 * has space for. Returns 0xff on error.
96 unsigned char
97 prom_get_idprom(char *idbuf, int num_bytes)
99 int len;
101 len = prom_getproplen(prom_root_node, "idprom");
102 if((len>num_bytes) || (len==-1)) return 0xff;
103 if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
104 return idbuf[0];
106 return 0xff;
109 /* Get the major prom version number. */
111 prom_version(void)
113 return romvec->pv_romvers;
116 /* Get the prom plugin-revision. */
118 prom_getrev(void)
120 return prom_rev;
123 /* Get the prom firmware print revision. */
125 prom_getprev(void)
127 return prom_prev;