1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * SWARM-specific commands File: ui_lausanne.c
6 * A temporary sandbox for misc test routines and commands.
8 * Author: Mitch Lichtenberg (mpl@broadcom.com)
10 *********************************************************************
12 * Copyright 2000,2001,2002,2003
13 * Broadcom Corporation. All rights reserved.
15 * This software is furnished under license and may be used and
16 * copied only in accordance with the following terms and
17 * conditions. Subject to these conditions, you may download,
18 * copy, install, use, modify and distribute modified or unmodified
19 * copies of this software in source and/or binary form. No title
20 * or ownership is transferred hereby.
22 * 1) Any source code used, modified or distributed must reproduce
23 * and retain this copyright notice and list of conditions
24 * as they appear in the source file.
26 * 2) No right is granted to use any trade name, trademark, or
27 * logo of Broadcom Corporation. The "Broadcom Corporation"
28 * name may not be used to endorse or promote products derived
29 * from this software without the prior written permission of
30 * Broadcom Corporation.
32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
44 * THE POSSIBILITY OF SUCH DAMAGE.
45 ********************************************************************* */
48 #include "lib_types.h"
49 #include "lib_string.h"
50 #include "lib_queue.h"
51 #include "lib_malloc.h"
52 #include "lib_printf.h"
54 #include "cfe_timer.h"
56 #include "cfe_device.h"
57 #include "cfe_ioctl.h"
58 #include "cfe_devfuncs.h"
59 #include "cfe_error.h"
60 #include "cfe_console.h"
62 #include "ui_command.h"
65 #include "bsp_config.h"
68 #include "sb1250_regs.h"
69 #include "sb1250_scd.h"
71 #include "sb1250_genbus.h"
73 #include "sb1250_pass2.h"
74 #include "dev_flash.h"
77 /* *********************************************************************
79 ********************************************************************* */
81 /* *********************************************************************
83 ********************************************************************* */
85 int ui_init_swarmcmds(void);
87 int ui_init_cpldcmds(void);
88 static int ui_cmd_writecpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
89 static int ui_cmd_readcpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
90 static int ui_cmd_burstwcpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
91 static int ui_cmd_burstrcpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
92 static int ui_cmd_config_flash(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
96 static int ui_cmd_vgadump(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
97 static int ui_cmd_vgainit(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
98 extern int vga_biosinit(void);
99 extern void vgaraw_dump(char *tail
);
104 /* *********************************************************************
106 ********************************************************************* */
109 /* *********************************************************************
110 * ui_init_swarmcmds()
112 * Add SWARM-specific commands to the command table
119 ********************************************************************* */
122 int ui_init_swarmcmds(void)
125 cmd_addcmd("vga init",
128 "Initialize the VGA adapter.",
132 cmd_addcmd("vga dumpbios",
135 "Dump the VGA BIOS to the console",
151 static int ui_cmd_vgainit(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
155 res
= vga_biosinit();
157 xprintf("vgaraw_init returns %d\n",res
);
162 static int ui_cmd_vgadump(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
166 x
= cmd_getarg(cmd
,0);
176 int ui_init_cpldcmds(void)
179 cmd_addcmd("write cpld",
182 "Write bytes to the cpld",
186 cmd_addcmd("read cpld",
189 "Read bytes from the cpld",
193 cmd_addcmd("burstw cpld",
196 "Write to the cpld in 8-bit BURST MODE",
200 cmd_addcmd("burstr cpld",
203 "Read from the cpld in 8-bit BURST MODE",
207 cmd_addcmd("config flash",
210 "Configure the flash (flash1) while NOT booting from flash.",
211 "config flash [-n|-w] [-b|-o]",
212 "-n;switch flash1 to 8-bit mode|"
213 "-w;switch flash1 to 16-bit mode|"
220 /* NORMAL WRITE to the cpld
221 * Write 8'b01010101 to address 8'b00000001 of the cpld
223 static int ui_cmd_writecpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
225 // make sure burst mode is DISABLED
226 *((volatile uint64_t *)PHYS_TO_K1(A_IO_EXT_CS_BASE(CPLD_CS
))) = CPLD_CONFIG
;
228 xprintf ("writing 0x55 to cpld address 0x01\n");
229 *((volatile uint8_t *) PHYS_TO_K1(0x100B0001)) = (uint8_t) (0x55);
230 xprintf("Done.\n\n");
235 /* NORMAL READ to the cpld
236 * The cpld is programmed to output the current cpld SUM if address 0x00 is
237 * read. However, if any other address is read, then the cpld will output
238 * 5'b00000 concatenated with the lowest three address bits.
240 * reading address 0xFF will return 0x07.
241 * reading address 0x4A will return 0x02.
242 * reading address 0x09 will return 0x01.
244 static int ui_cmd_readcpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
249 // make sure burst mode is DISABLED
250 *((volatile uint64_t *)PHYS_TO_K1(A_IO_EXT_CS_BASE(CPLD_CS
))) = CPLD_CONFIG
;
252 data
= *((volatile uint8_t *) PHYS_TO_K1(0x100B00FC));
253 xprintf ("CPLD address 0xFC contains 0x%2X\n", data
);
254 xprintf ("This value should be 0x04\n\n");
255 data
= *((volatile uint8_t *) PHYS_TO_K1(0x100B0000));
256 xprintf ("CPLD address 0x00 contains 0x%2X\n\n", data
);
262 /* BURST WRITE to the cpld
263 * Maximum burst size (without doing a UAC store) to cpld is 8 bytes.
272 * To do the burst, write the 64-bit value 0x8040201008040201 to the cpld.
273 * At the end of the burst, the cpld SUM register should contain 0xFF.
275 static int ui_cmd_burstwcpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
278 *((volatile uint64_t *)PHYS_TO_K1(A_IO_EXT_CS_BASE(CPLD_CS
))) = CPLD_CONFIG
| M_IO_BURST_EN
;
280 xprintf("burst writing 8 bytes (0x8040201008040201) to cpld address 0x00\n");
281 *((volatile uint64_t *) PHYS_TO_K1(0x100B0000)) = (uint64_t) (0x8040201008040201);
282 xprintf("Done.\n\n");
288 /* BURST READ to the cpld
289 * Burst reading the cpld at address 0x00 should return
290 * 0x07060504030201 concatenated with the cpld SUM[7:0]
292 static int ui_cmd_burstrcpld(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
297 *((volatile uint64_t *)PHYS_TO_K1(A_IO_EXT_CS_BASE(CPLD_CS
))) = CPLD_CONFIG
| M_IO_BURST_EN
;
299 data
= *((volatile uint64_t *) PHYS_TO_K1(0x100B0000));
300 xprintf ("Address 0x00 of cpld contains (by burst reading) 0x%16X\n", data
);
301 xprintf ("This value should be 0x07060504030201FF if a burst write was just exectued\n\n");
306 static int ui_cmd_config_flash(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
312 fh
= cfe_open("flash1");
314 xprintf("Could not open device flash1\n");
315 return CFE_ERR_DEVNOTFOUND
;
318 if (cmd_sw_isset(cmd
,"-w")) {
320 /*switch to 16-bit mode*/
321 flash_mode
= INTEL_FLASH_16BIT
;
323 else if (cmd_sw_isset(cmd
,"-n")) {
324 /*switch to 8-bit mode*/
325 flash_mode
= INTEL_FLASH_8BIT
;
327 cfe_ioctl(fh
,IOCTL_FLASH_DATA_WIDTH_MODE
,(uint8_t *) &flash_mode
, sizeof(flash_mode
),NULL
,0);
329 if (cmd_sw_isset(cmd
,"-b")) {
332 else if (cmd_sw_isset(cmd
,"-o")) {
335 cfe_ioctl(fh
,IOCTL_FLASH_BURST_MODE
,(uint8_t *) &burst_on
, sizeof(burst_on
),NULL
,0);