RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / cfe / cfe / arch / mips / board / p6064 / src / p6064_commands.c
blob1a4884d93a80d367ae1962ecf5dc89f86525fe26
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * P5064-specific commands File: P5064_COMMANDS.C
5 *
6 * This module contains special command extensions for the
7 * Algorithmics P5064 port of CFE.
9 * NOTE: Some of the routines in this module were borrowed
10 * from PMON.
12 * Author: Mitch Lichtenberg (mpl@broadcom.com)
14 *********************************************************************
16 * Copyright 2000,2001,2002,2003
17 * Broadcom Corporation. All rights reserved.
19 * This software is furnished under license and may be used and
20 * copied only in accordance with the following terms and
21 * conditions. Subject to these conditions, you may download,
22 * copy, install, use, modify and distribute modified or unmodified
23 * copies of this software in source and/or binary form. No title
24 * or ownership is transferred hereby.
26 * 1) Any source code used, modified or distributed must reproduce
27 * and retain this copyright notice and list of conditions
28 * as they appear in the source file.
30 * 2) No right is granted to use any trade name, trademark, or
31 * logo of Broadcom Corporation. The "Broadcom Corporation"
32 * name may not be used to endorse or promote products derived
33 * from this software without the prior written permission of
34 * Broadcom Corporation.
36 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
37 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
38 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
40 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
41 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
42 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
44 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
45 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
46 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
47 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
48 * THE POSSIBILITY OF SUCH DAMAGE.
49 ********************************************************************* */
52 #include "sbmips.h"
53 #include "lib_types.h"
54 #include "lib_string.h"
55 #include "lib_queue.h"
56 #include "lib_malloc.h"
57 #include "lib_printf.h"
59 #include "cfe_iocb.h"
60 #include "cfe_device.h"
61 #include "cfe_console.h"
62 #include "cfe_devfuncs.h"
63 #include "cfe_timer.h"
65 #include "cfe_error.h"
66 #include "env_subr.h"
67 #include "ui_command.h"
68 #include "cfe.h"
70 #include "sbd.h"
71 #include "rtc.h"
73 #include "pcivar.h"
77 #if !defined(__MIPSEB) && !defined(__MIPSEL)
78 #error "You must define either __MIPSEB or __MIPSEL"
79 #endif
81 /* #define POWEROFF */
84 int ui_init_p6064cmds(void);
86 #ifdef POWEROFF
87 static int ui_cmd_poweroff(ui_cmdline_t *cmd,int argc,char *argv[]);
88 #endif
90 #if CFG_VGACONSOLE
91 static int ui_cmd_vgadump(ui_cmdline_t *cmd,int argc,char *argv[]);
92 static int ui_cmd_vgainit(ui_cmdline_t *cmd,int argc,char *argv[]);
93 extern int vga_biosinit(void);
94 extern void vgaraw_dump(char *tail);
95 #endif
97 #define INB(x) inb(x)
98 #define INW(x) inw(x)
99 #define INL(x) inl(x)
101 #define OUTB(x,y) outb(x,y)
102 #define OUTW(x,y) outw(x,y)
103 #define OUTL(x,y) outl(x,y)
106 int ui_init_p6064cmds(void)
109 #ifdef POWEROFF
110 cmd_addcmd("power off",
111 ui_cmd_poweroff,
112 NULL,
113 "Power off the system.",
114 "power off\n\n"
115 "This command turns off the power for systems that support it.",
116 "");
117 #endif
119 #if CFG_VGACONSOLE
120 cmd_addcmd("vga init",
121 ui_cmd_vgainit,
122 NULL,
123 "Initialize the VGA adapter.",
124 "vgainit",
125 "");
127 cmd_addcmd("vga dumpbios",
128 ui_cmd_vgadump,
129 NULL,
130 "Dump the VGA BIOS to the console",
131 "vga dumpbios",
132 "");
133 #endif
135 return 0;
139 #ifdef POWEROFF
140 unsigned int apc_bis (int reg, unsigned int val);
142 unsigned int
143 apc_bis (int reg, unsigned int val)
145 unsigned int rtcsa, o, n;
147 if (BOARD_REVISION < 'C')
148 return ~0;
150 OUTB(RTC_ADDR_PORT, RTC_STATUSA);
151 rtcsa = INB(RTC_DATA_PORT);
152 if ((rtcsa & RTCSA_DVMASK) != RTC_DV2_OSC_ON)
153 OUTB(RTC_DATA_PORT, (rtcsa & ~RTCSA_DVMASK) | RTC_DV2_OSC_ON);
155 OUTB(RTC_ADDR_PORT, reg);
156 o = INB(RTC_DATA_PORT);
157 n = o | val;
158 if (o != n) {
159 OUTB(RTC_DATA_PORT, n);
162 /* paranoia - switch back to bank 0 */
163 OUTB(RTC_ADDR_PORT, RTC_STATUSA);
164 OUTB(RTC_DATA_PORT, (rtcsa & ~RTCSA_DVMASK) | RTC_DV0_OSC_ON);
166 return (o);
169 #endif
171 #if CFG_VGACONSOLE
172 static int ui_cmd_vgainit(ui_cmdline_t *cmd,int argc,char *argv[])
174 int res;
176 res = vga_biosinit();
178 xprintf("vgaraw_init returns %d\n",res);
180 return 0;
183 static int ui_cmd_vgadump(ui_cmdline_t *cmd,int argc,char *argv[])
185 char *x;
187 x = cmd_getarg(cmd,0);
188 if (!x) x = "";
190 vgaraw_dump(x);
192 return 0;
194 #endif
197 #ifdef POWEROFF
198 static int ui_cmd_poweroff(ui_cmdline_t *cmd,int argc,char *argv[])
200 xprintf("Power off.\n");
201 apc_bis(RTC_BANK2_APCR1, APCR1_SOC);
202 for (;;) ;
203 return 0;
206 #endif