Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / sparc / prom / misc_32.c
CommitLineData
88278ca2 1/*
1da177e4
LT
2 * misc.c: Miscellaneous prom functions that don't belong
3 * anywhere else.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7
1da177e4
LT
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <asm/openprom.h>
12#include <asm/oplib.h>
13#include <asm/auxio.h>
14#include <asm/system.h>
15
16extern void restore_current(void);
17
18DEFINE_SPINLOCK(prom_lock);
19
20/* Reset and reboot the machine with the command 'bcommand'. */
21void
22prom_reboot(char *bcommand)
23{
24 unsigned long flags;
25 spin_lock_irqsave(&prom_lock, flags);
26 (*(romvec->pv_reboot))(bcommand);
27 /* Never get here. */
28 restore_current();
29 spin_unlock_irqrestore(&prom_lock, flags);
30}
31
32/* Forth evaluate the expression contained in 'fstring'. */
33void
34prom_feval(char *fstring)
35{
36 unsigned long flags;
37 if(!fstring || fstring[0] == 0)
38 return;
39 spin_lock_irqsave(&prom_lock, flags);
40 if(prom_vers == PROM_V0)
41 (*(romvec->pv_fortheval.v0_eval))(strlen(fstring), fstring);
42 else
43 (*(romvec->pv_fortheval.v2_eval))(fstring);
44 restore_current();
45 spin_unlock_irqrestore(&prom_lock, flags);
46}
47
1da177e4
LT
48/* Drop into the prom, with the chance to continue with the 'go'
49 * prom command.
50 */
51void
52prom_cmdline(void)
53{
54 extern void install_obp_ticker(void);
55 extern void install_linux_ticker(void);
56 unsigned long flags;
57
1da177e4
LT
58 spin_lock_irqsave(&prom_lock, flags);
59 install_obp_ticker();
60 (*(romvec->pv_abort))();
61 restore_current();
62 install_linux_ticker();
63 spin_unlock_irqrestore(&prom_lock, flags);
1da177e4 64 set_auxio(AUXIO_LED, 0);
1da177e4
LT
65}
66
67/* Drop into the prom, but completely terminate the program.
68 * No chance of continuing.
69 */
70void
71prom_halt(void)
72{
73 unsigned long flags;
74again:
75 spin_lock_irqsave(&prom_lock, flags);
76 (*(romvec->pv_halt))();
77 /* Never get here. */
78 restore_current();
79 spin_unlock_irqrestore(&prom_lock, flags);
80 goto again; /* PROM is out to get me -DaveM */
81}
82
83typedef void (*sfunc_t)(void);
84
85/* Set prom sync handler to call function 'funcp'. */
86void
87prom_setsync(sfunc_t funcp)
88{
89 if(!funcp) return;
90 *romvec->pv_synchook = funcp;
91}
92
93/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
94 * format type. 'num_bytes' is the number of bytes that your idbuf
95 * has space for. Returns 0xff on error.
96 */
97unsigned char
98prom_get_idprom(char *idbuf, int num_bytes)
99{
100 int len;
101
102 len = prom_getproplen(prom_root_node, "idprom");
103 if((len>num_bytes) || (len==-1)) return 0xff;
104 if(!prom_getproperty(prom_root_node, "idprom", idbuf, num_bytes))
105 return idbuf[0];
106
107 return 0xff;
108}
109
110/* Get the major prom version number. */
111int
112prom_version(void)
113{
114 return romvec->pv_romvers;
115}
116
117/* Get the prom plugin-revision. */
118int
119prom_getrev(void)
120{
121 return prom_rev;
122}
123
124/* Get the prom firmware print revision. */
125int
126prom_getprev(void)
127{
128 return prom_prev;
129}