GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / board / bcm1250cpci / src / ui_usb_scanlogic.c
blob403cf94b531c42fe840c887468283de34237a750
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * BCM1250CPCI USB commands File: ui_usb_scanlogic.c
5 *
6 * USB test utilities
7 *
8 * Author: Paul Burrell
9 *
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"
58 #include "cfe.h"
60 #include "bsp_config.h"
62 #include "sl11h.h"
63 #include "sbmips.h"
64 #include "sb1250_regs.h"
65 #include "sb1250_smbus.h"
67 #include "bcm1250cpci.h"
71 /* *********************************************************************
72 * Constants
73 ********************************************************************* */
75 /* *********************************************************************
76 * Configuration
77 ********************************************************************* */
79 /* *********************************************************************
80 * prototypes
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 /* *********************************************************************
92 * Data
93 ********************************************************************* */
96 /* *********************************************************************
97 * ui_init_usbcmds()
99 * Add USB commands to the command table
101 * Input parameters:
102 * nothing
104 * Return value:
106 ********************************************************************* */
109 int ui_init_usbcmds(void)
111 cmd_addcmd("usb read",
112 ui_cmd_usbread,
113 NULL,
114 "Read register from SL11H USB chip",
115 "usb read <reg>",
116 "");
118 cmd_addcmd("usb write",
119 ui_cmd_usbwrite,
120 NULL,
121 "Write register from SL11H USB chip",
122 "usb write <reg> <data>",
123 "");
125 cmd_addcmd("usb reset",
126 ui_cmd_usbreset,
127 NULL,
128 "Resets the SL11H USB chip",
129 "usb reset",
130 "");
132 cmd_addcmd("usb memtest",
133 ui_cmd_usbmemtest,
134 NULL,
135 "Tests all of the onboard memory on the SL11H USB chip",
136 "usb memtest",
137 "");
139 cmd_addcmd("usb finddevice",
140 ui_cmd_usbfinddevice,
141 NULL,
142 "Scans for peripherals.",
143 "usb find device",
144 "");
146 return 0;
150 /* *********************************************************************
151 * User interface commands
152 ********************************************************************* */
154 static int ui_cmd_usbread(ui_cmdline_t *cmd,int argc,char *argv[])
156 char *line;
157 char *p;
158 int address;
160 if ((line = cmd_getarg(cmd,0)) == NULL) {
161 return ui_showusage(cmd);
164 /* parse and check command-line args */
165 address = -1;
167 p = gettoken(&line);
168 if (p) address = xtoi(p);
170 if ((address < 0) || (address > 0xfF)) {
171 printf("Invalid Address Range on USB read");
172 return(-1);
175 printf("USB read at address %02X = %02X\n",address,SL11Read(address));
177 return 0;
180 static int ui_cmd_usbwrite(ui_cmdline_t *cmd,int argc,char *argv[])
182 char *line;
183 // char *p;
184 int address,data;
186 if (argc != 2) {
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 */
196 address = -1;
197 data = -1;
199 address = xtoi(argv[0]);
200 data = xtoi(argv[1]);
202 // p = gettoken(&line);
203 // if (p) address = xtoi(p);
204 // printf("%s\n",p);
205 // p = gettoken(&line);
206 // if (p) data = xtoi(p);
207 // printf("%s\n",p);
209 printf ("%X,%X\n",address,data);
211 if ((address < 0) || (address > 0xfF)) {
212 printf("Invalid Address Range on USB write\n");
213 return(-1);
216 if ((data < 0) || (data > 0xfF)) {
217 printf("Invalid DATA Range on USB write\n");
218 return(-1);
221 SL11Write(address,data);
223 printf("Data written\n");
225 return(0);
230 static int ui_cmd_usbreset(ui_cmdline_t *cmd,int argc,char *argv[])
233 printf("Reseting USB device\n");
234 USBReset();
235 printf("USB reset complete\n");
237 return 0;
241 static int ui_cmd_usbmemtest(ui_cmdline_t *cmd,int argc,char *argv[])
243 int errors;
245 printf("Performing memory test...\n");
246 errors = SL11HMemTest();
247 printf("Error Count = %d\n",errors);
248 printf("Memory Test complete.\n");
250 if (errors) {
251 return(-1);
252 } else {
253 return(0);
259 static int ui_cmd_usbfinddevice(ui_cmdline_t *cmd,int argc,char *argv[])
261 int status;
263 status = uFindUsbDev(0x0);
265 return(status);