1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * BCM1250CPCI USB commands File: ui_usb_scanlogic.c
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"
55 #include "cfe_error.h"
57 #include "ui_command.h"
60 #include "bsp_config.h"
64 #include "sb1250_regs.h"
65 #include "sb1250_smbus.h"
67 #include "bcm1250cpci.h"
71 /* *********************************************************************
73 ********************************************************************* */
75 /* *********************************************************************
77 ********************************************************************* */
79 /* *********************************************************************
81 ********************************************************************* */
83 int ui_init_usbcmds(void);
84 static int ui_cmd_usbread(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
85 static int ui_cmd_usbwrite(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
86 static int ui_cmd_usbreset(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
87 static int ui_cmd_usbmemtest(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
88 static int ui_cmd_usbfinddevice(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
91 /* *********************************************************************
93 ********************************************************************* */
96 /* *********************************************************************
99 * Add USB commands to the command table
106 ********************************************************************* */
109 int ui_init_usbcmds(void)
111 cmd_addcmd("usb read",
114 "Read register from SL11H USB chip",
118 cmd_addcmd("usb write",
121 "Write register from SL11H USB chip",
122 "usb write <reg> <data>",
125 cmd_addcmd("usb reset",
128 "Resets the SL11H USB chip",
132 cmd_addcmd("usb memtest",
135 "Tests all of the onboard memory on the SL11H USB chip",
139 cmd_addcmd("usb finddevice",
140 ui_cmd_usbfinddevice
,
142 "Scans for peripherals.",
150 /* *********************************************************************
151 * User interface commands
152 ********************************************************************* */
154 static int ui_cmd_usbread(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
160 if ((line
= cmd_getarg(cmd
,0)) == NULL
) {
161 return ui_showusage(cmd
);
164 /* parse and check command-line args */
168 if (p
) address
= xtoi(p
);
170 if ((address
< 0) || (address
> 0xfF)) {
171 printf("Invalid Address Range on USB read");
175 printf("USB read at address %02X = %02X\n",address
,SL11Read(address
));
180 static int ui_cmd_usbwrite(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
187 return ui_showusage(cmd
);
190 if ((line
= cmd_getarg(cmd
,0)) == NULL
) {
191 return ui_showusage(cmd
);
195 /* parse and check command-line args */
199 address
= xtoi(argv
[0]);
200 data
= xtoi(argv
[1]);
202 // p = gettoken(&line);
203 // if (p) address = xtoi(p);
205 // p = gettoken(&line);
206 // if (p) data = xtoi(p);
209 printf ("%X,%X\n",address
,data
);
211 if ((address
< 0) || (address
> 0xfF)) {
212 printf("Invalid Address Range on USB write\n");
216 if ((data
< 0) || (data
> 0xfF)) {
217 printf("Invalid DATA Range on USB write\n");
221 SL11Write(address
,data
);
223 printf("Data written\n");
230 static int ui_cmd_usbreset(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
233 printf("Reseting USB device\n");
235 printf("USB reset complete\n");
241 static int ui_cmd_usbmemtest(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
245 printf("Performing memory test...\n");
246 errors
= SL11HMemTest();
247 printf("Error Count = %d\n",errors
);
248 printf("Memory Test complete.\n");
259 static int ui_cmd_usbfinddevice(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
263 status
= uFindUsbDev(0x0);