blob: 50eb239aaf6cd964dc9b8d7f52e7c9382dc15ade [file] [log] [blame]
wdenke887afc2002-08-27 09:44:07 +00001/*
2 * (C) Copyright 2001
3 * Denis Peter, MPL AG Switzerland
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 *
24 *
25 */
26
27/*
28 * SCSI support.
29 */
wdenke887afc2002-08-27 09:44:07 +000030#include <common.h>
31#include <command.h>
wdenke887afc2002-08-27 09:44:07 +000032#include <asm/processor.h>
33#include <scsi.h>
34#include <image.h>
wdenke887afc2002-08-27 09:44:07 +000035#include <pci.h>
36
Vadim Bendebury3e9fa302012-10-29 05:23:45 +000037#ifdef CONFIG_SCSI_DEV_LIST
38#define SCSI_DEV_LIST CONFIG_SCSI_DEV_LIST
39#else
wdenke887afc2002-08-27 09:44:07 +000040#ifdef CONFIG_SCSI_SYM53C8XX
41#define SCSI_VEND_ID 0x1000
42#ifndef CONFIG_SCSI_DEV_ID
43#define SCSI_DEV_ID 0x0001
44#else
45#define SCSI_DEV_ID CONFIG_SCSI_DEV_ID
46#endif
Jin Zhengxiongae180dc2006-08-23 19:10:44 +080047#elif defined CONFIG_SATA_ULI5288
48
49#define SCSI_VEND_ID 0x10b9
50#define SCSI_DEV_ID 0x5288
51
Rob Herringc2829ff2011-07-06 16:13:36 +000052#elif !defined(CONFIG_SCSI_AHCI_PLAT)
Jin Zhengxiongae180dc2006-08-23 19:10:44 +080053#error no scsi device defined
wdenke887afc2002-08-27 09:44:07 +000054#endif
Vadim Bendebury3e9fa302012-10-29 05:23:45 +000055#define SCSI_DEV_LIST {SCSI_VEND_ID, SCSI_DEV_ID}
56#endif
wdenke887afc2002-08-27 09:44:07 +000057
Vadim Bendebury3e9fa302012-10-29 05:23:45 +000058#ifdef CONFIG_PCI
59const struct pci_device_id scsi_device_list[] = { SCSI_DEV_LIST };
60#endif
wdenke887afc2002-08-27 09:44:07 +000061static ccb tempccb; /* temporary scsi command buffer */
62
63static unsigned char tempbuff[512]; /* temporary data buffer */
64
65static int scsi_max_devs; /* number of highest available scsi device */
66
67static int scsi_curr_dev; /* current device */
68
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020069static block_dev_desc_t scsi_dev_desc[CONFIG_SYS_SCSI_MAX_DEVICE];
wdenke887afc2002-08-27 09:44:07 +000070
71/********************************************************************************
72 * forward declerations of some Setup Routines
73 */
74void scsi_setup_test_unit_ready(ccb * pccb);
75void scsi_setup_read_capacity(ccb * pccb);
76void scsi_setup_read6(ccb * pccb, unsigned long start, unsigned short blocks);
77void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks);
78void scsi_setup_inquiry(ccb * pccb);
79void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
80
81
Grant Likely2089cab2007-02-20 09:05:45 +010082ulong scsi_read(int device, ulong blknr, ulong blkcnt, void *buffer);
wdenke887afc2002-08-27 09:44:07 +000083
84
85/*********************************************************************************
86 * (re)-scan the scsi bus and reports scsi device info
87 * to the user if mode = 1
88 */
89void scsi_scan(int mode)
90{
91 unsigned char i,perq,modi,lun;
92 unsigned long capacity,blksz;
93 ccb* pccb=(ccb *)&tempccb;
94
95 if(mode==1) {
96 printf("scanning bus for devices...\n");
97 }
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020098 for(i=0;i<CONFIG_SYS_SCSI_MAX_DEVICE;i++) {
wdenke887afc2002-08-27 09:44:07 +000099 scsi_dev_desc[i].target=0xff;
100 scsi_dev_desc[i].lun=0xff;
101 scsi_dev_desc[i].lba=0;
102 scsi_dev_desc[i].blksz=0;
103 scsi_dev_desc[i].type=DEV_TYPE_UNKNOWN;
104 scsi_dev_desc[i].vendor[0]=0;
105 scsi_dev_desc[i].product[0]=0;
106 scsi_dev_desc[i].revision[0]=0;
107 scsi_dev_desc[i].removable=FALSE;
108 scsi_dev_desc[i].if_type=IF_TYPE_SCSI;
109 scsi_dev_desc[i].dev=i;
110 scsi_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
111 scsi_dev_desc[i].block_read=scsi_read;
112 }
113 scsi_max_devs=0;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200114 for(i=0;i<CONFIG_SYS_SCSI_MAX_SCSI_ID;i++) {
wdenke887afc2002-08-27 09:44:07 +0000115 pccb->target=i;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200116 for(lun=0;lun<CONFIG_SYS_SCSI_MAX_LUN;lun++) {
wdenke887afc2002-08-27 09:44:07 +0000117 pccb->lun=lun;
118 pccb->pdata=(unsigned char *)&tempbuff;
119 pccb->datalen=512;
120 scsi_setup_inquiry(pccb);
121 if(scsi_exec(pccb)!=TRUE) {
122 if(pccb->contr_stat==SCSI_SEL_TIME_OUT) {
wdenkf1276d42005-02-03 23:00:49 +0000123 debug ("Selection timeout ID %d\n",pccb->target);
wdenke887afc2002-08-27 09:44:07 +0000124 continue; /* selection timeout => assuming no device present */
125 }
126 scsi_print_error(pccb);
127 continue;
128 }
129 perq=tempbuff[0];
130 modi=tempbuff[1];
131 if((perq & 0x1f)==0x1f) {
132 continue; /* skip unknown devices */
133 }
134 if((modi&0x80)==0x80) /* drive is removable */
135 scsi_dev_desc[scsi_max_devs].removable=TRUE;
136 /* get info for this device */
Stefan Roese4404c162007-11-17 07:58:25 +0100137 scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].vendor[0],
138 &tempbuff[8], 8);
139 scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].product[0],
140 &tempbuff[16], 16);
141 scsi_ident_cpy((unsigned char *)&scsi_dev_desc[scsi_max_devs].revision[0],
142 &tempbuff[32], 4);
wdenke887afc2002-08-27 09:44:07 +0000143 scsi_dev_desc[scsi_max_devs].target=pccb->target;
144 scsi_dev_desc[scsi_max_devs].lun=pccb->lun;
145
146 pccb->datalen=0;
147 scsi_setup_test_unit_ready(pccb);
148 if(scsi_exec(pccb)!=TRUE) {
149 if(scsi_dev_desc[scsi_max_devs].removable==TRUE) {
150 scsi_dev_desc[scsi_max_devs].type=perq;
151 goto removable;
152 }
153 scsi_print_error(pccb);
154 continue;
155 }
156 pccb->datalen=8;
157 scsi_setup_read_capacity(pccb);
158 if(scsi_exec(pccb)!=TRUE) {
159 scsi_print_error(pccb);
160 continue;
161 }
162 capacity=((unsigned long)tempbuff[0]<<24)|((unsigned long)tempbuff[1]<<16)|
163 ((unsigned long)tempbuff[2]<<8)|((unsigned long)tempbuff[3]);
164 blksz=((unsigned long)tempbuff[4]<<24)|((unsigned long)tempbuff[5]<<16)|
165 ((unsigned long)tempbuff[6]<<8)|((unsigned long)tempbuff[7]);
166 scsi_dev_desc[scsi_max_devs].lba=capacity;
167 scsi_dev_desc[scsi_max_devs].blksz=blksz;
168 scsi_dev_desc[scsi_max_devs].type=perq;
169 init_part(&scsi_dev_desc[scsi_max_devs]);
170removable:
171 if(mode==1) {
172 printf (" Device %d: ", scsi_max_devs);
173 dev_print(&scsi_dev_desc[scsi_max_devs]);
174 } /* if mode */
175 scsi_max_devs++;
176 } /* next LUN */
177 }
178 if(scsi_max_devs>0)
179 scsi_curr_dev=0;
180 else
Wolfgang Denkdc770c72008-07-14 15:19:07 +0200181 scsi_curr_dev = -1;
wdenke887afc2002-08-27 09:44:07 +0000182}
183
Rob Herringc2829ff2011-07-06 16:13:36 +0000184#ifdef CONFIG_PCI
wdenke887afc2002-08-27 09:44:07 +0000185void scsi_init(void)
186{
187 int busdevfunc;
Vadim Bendebury3e9fa302012-10-29 05:23:45 +0000188 int i;
189 /*
190 * Find a device from the list, this driver will support a single
191 * controller.
192 */
193 for (i = 0; i < ARRAY_SIZE(scsi_device_list); i++) {
194 /* get PCI Device ID */
195 busdevfunc = pci_find_device(scsi_device_list[i].vendor,
196 scsi_device_list[i].device,
197 0);
198 if (busdevfunc != -1)
199 break;
200 }
wdenke887afc2002-08-27 09:44:07 +0000201
Vadim Bendebury3e9fa302012-10-29 05:23:45 +0000202 if (busdevfunc == -1) {
203 printf("Error: SCSI Controller(s) ");
204 for (i = 0; i < ARRAY_SIZE(scsi_device_list); i++) {
205 printf("%04X:%04X ",
206 scsi_device_list[i].vendor,
207 scsi_device_list[i].device);
208 }
209 printf("not found\n");
wdenke887afc2002-08-27 09:44:07 +0000210 return;
211 }
212#ifdef DEBUG
213 else {
Vadim Bendebury3e9fa302012-10-29 05:23:45 +0000214 printf("SCSI Controller (%04X,%04X) found (%d:%d:%d)\n",
215 scsi_device_list[i].vendor,
216 scsi_device_list[i].device,
217 (busdevfunc >> 16) & 0xFF,
218 (busdevfunc >> 11) & 0x1F,
219 (busdevfunc >> 8) & 0x7);
wdenke887afc2002-08-27 09:44:07 +0000220 }
221#endif
222 scsi_low_level_init(busdevfunc);
223 scsi_scan(1);
224}
Rob Herringc2829ff2011-07-06 16:13:36 +0000225#endif
wdenke887afc2002-08-27 09:44:07 +0000226
Matthew McClintock6252b4f2011-05-24 05:31:19 +0000227#ifdef CONFIG_PARTITIONS
wdenke887afc2002-08-27 09:44:07 +0000228block_dev_desc_t * scsi_get_dev(int dev)
229{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200230 return (dev < CONFIG_SYS_SCSI_MAX_DEVICE) ? &scsi_dev_desc[dev] : NULL;
wdenke887afc2002-08-27 09:44:07 +0000231}
Matthew McClintock6252b4f2011-05-24 05:31:19 +0000232#endif
wdenke887afc2002-08-27 09:44:07 +0000233
wdenke887afc2002-08-27 09:44:07 +0000234/******************************************************************************
235 * scsi boot command intepreter. Derived from diskboot
236 */
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200237int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenke887afc2002-08-27 09:44:07 +0000238{
Rob Herringa20cbf92012-09-21 04:02:30 +0000239 return common_diskboot(cmdtp, "scsi", argc, argv);
wdenke887afc2002-08-27 09:44:07 +0000240}
241
242/*********************************************************************************
243 * scsi command intepreter
244 */
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200245int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenke887afc2002-08-27 09:44:07 +0000246{
247 switch (argc) {
Simon Glassa06dfc72011-12-10 08:44:01 +0000248 case 0:
249 case 1:
250 return CMD_RET_USAGE;
Wolfgang Denk3b683112010-07-17 01:06:04 +0200251
Simon Glassa06dfc72011-12-10 08:44:01 +0000252 case 2:
wdenke887afc2002-08-27 09:44:07 +0000253 if (strncmp(argv[1],"res",3) == 0) {
254 printf("\nReset SCSI\n");
255 scsi_bus_reset();
256 scsi_scan(1);
257 return 0;
258 }
259 if (strncmp(argv[1],"inf",3) == 0) {
260 int i;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200261 for (i=0; i<CONFIG_SYS_SCSI_MAX_DEVICE; ++i) {
wdenke887afc2002-08-27 09:44:07 +0000262 if(scsi_dev_desc[i].type==DEV_TYPE_UNKNOWN)
263 continue; /* list only known devices */
264 printf ("SCSI dev. %d: ", i);
265 dev_print(&scsi_dev_desc[i]);
266 }
267 return 0;
268 }
269 if (strncmp(argv[1],"dev",3) == 0) {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200270 if ((scsi_curr_dev < 0) || (scsi_curr_dev >= CONFIG_SYS_SCSI_MAX_DEVICE)) {
wdenke887afc2002-08-27 09:44:07 +0000271 printf("\nno SCSI devices available\n");
272 return 1;
273 }
274 printf ("\n Device %d: ", scsi_curr_dev);
275 dev_print(&scsi_dev_desc[scsi_curr_dev]);
276 return 0;
277 }
278 if (strncmp(argv[1],"scan",4) == 0) {
279 scsi_scan(1);
280 return 0;
281 }
282 if (strncmp(argv[1],"part",4) == 0) {
283 int dev, ok;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200284 for (ok=0, dev=0; dev<CONFIG_SYS_SCSI_MAX_DEVICE; ++dev) {
wdenke887afc2002-08-27 09:44:07 +0000285 if (scsi_dev_desc[dev].type!=DEV_TYPE_UNKNOWN) {
286 ok++;
287 if (dev)
288 printf("\n");
wdenkf1276d42005-02-03 23:00:49 +0000289 debug ("print_part of %x\n",dev);
wdenke887afc2002-08-27 09:44:07 +0000290 print_part(&scsi_dev_desc[dev]);
291 }
292 }
293 if (!ok)
294 printf("\nno SCSI devices available\n");
295 return 1;
296 }
Simon Glassa06dfc72011-12-10 08:44:01 +0000297 return CMD_RET_USAGE;
Wolfgang Denka1be4762008-05-20 16:00:29 +0200298 case 3:
wdenke887afc2002-08-27 09:44:07 +0000299 if (strncmp(argv[1],"dev",3) == 0) {
300 int dev = (int)simple_strtoul(argv[2], NULL, 10);
301 printf ("\nSCSI device %d: ", dev);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200302 if (dev >= CONFIG_SYS_SCSI_MAX_DEVICE) {
wdenke887afc2002-08-27 09:44:07 +0000303 printf("unknown device\n");
304 return 1;
305 }
306 printf ("\n Device %d: ", dev);
307 dev_print(&scsi_dev_desc[dev]);
308 if(scsi_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
309 return 1;
310 }
311 scsi_curr_dev = dev;
312 printf("... is now current device\n");
313 return 0;
314 }
315 if (strncmp(argv[1],"part",4) == 0) {
316 int dev = (int)simple_strtoul(argv[2], NULL, 10);
317 if(scsi_dev_desc[dev].type != DEV_TYPE_UNKNOWN) {
318 print_part(&scsi_dev_desc[dev]);
319 }
320 else {
321 printf ("\nSCSI device %d not available\n", dev);
322 }
323 return 1;
324 }
Simon Glassa06dfc72011-12-10 08:44:01 +0000325 return CMD_RET_USAGE;
wdenke887afc2002-08-27 09:44:07 +0000326 default:
327 /* at least 4 args */
328 if (strcmp(argv[1],"read") == 0) {
329 ulong addr = simple_strtoul(argv[2], NULL, 16);
330 ulong blk = simple_strtoul(argv[3], NULL, 16);
331 ulong cnt = simple_strtoul(argv[4], NULL, 16);
332 ulong n;
333 printf ("\nSCSI read: device %d block # %ld, count %ld ... ",
334 scsi_curr_dev, blk, cnt);
335 n = scsi_read(scsi_curr_dev, blk, cnt, (ulong *)addr);
336 printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR");
337 return 0;
338 }
339 } /* switch */
Simon Glassa06dfc72011-12-10 08:44:01 +0000340 return CMD_RET_USAGE;
wdenke887afc2002-08-27 09:44:07 +0000341}
342
343/****************************************************************************************
344 * scsi_read
345 */
346
347#define SCSI_MAX_READ_BLK 0xFFFF /* almost the maximum amount of the scsi_ext command.. */
348
Grant Likely2089cab2007-02-20 09:05:45 +0100349ulong scsi_read(int device, ulong blknr, ulong blkcnt, void *buffer)
wdenke887afc2002-08-27 09:44:07 +0000350{
351 ulong start,blks, buf_addr;
352 unsigned short smallblks;
353 ccb* pccb=(ccb *)&tempccb;
354 device&=0xff;
355 /* Setup device
356 */
357 pccb->target=scsi_dev_desc[device].target;
358 pccb->lun=scsi_dev_desc[device].lun;
359 buf_addr=(unsigned long)buffer;
360 start=blknr;
361 blks=blkcnt;
wdenkf1276d42005-02-03 23:00:49 +0000362 debug ("\nscsi_read: dev %d startblk %lx, blccnt %lx buffer %lx\n",device,start,blks,(unsigned long)buffer);
wdenke887afc2002-08-27 09:44:07 +0000363 do {
364 pccb->pdata=(unsigned char *)buf_addr;
365 if(blks>SCSI_MAX_READ_BLK) {
366 pccb->datalen=scsi_dev_desc[device].blksz * SCSI_MAX_READ_BLK;
367 smallblks=SCSI_MAX_READ_BLK;
368 scsi_setup_read_ext(pccb,start,smallblks);
369 start+=SCSI_MAX_READ_BLK;
370 blks-=SCSI_MAX_READ_BLK;
371 }
372 else {
373 pccb->datalen=scsi_dev_desc[device].blksz * blks;
374 smallblks=(unsigned short) blks;
375 scsi_setup_read_ext(pccb,start,smallblks);
376 start+=blks;
377 blks=0;
378 }
wdenkf1276d42005-02-03 23:00:49 +0000379 debug ("scsi_read_ext: startblk %lx, blccnt %x buffer %lx\n",start,smallblks,buf_addr);
wdenke887afc2002-08-27 09:44:07 +0000380 if(scsi_exec(pccb)!=TRUE) {
381 scsi_print_error(pccb);
382 blkcnt-=blks;
383 break;
384 }
385 buf_addr+=pccb->datalen;
386 } while(blks!=0);
wdenkf1276d42005-02-03 23:00:49 +0000387 debug ("scsi_read_ext: end startblk %lx, blccnt %x buffer %lx\n",start,smallblks,buf_addr);
wdenke887afc2002-08-27 09:44:07 +0000388 return(blkcnt);
389}
390
391/* copy src to dest, skipping leading and trailing blanks
392 * and null terminate the string
393 */
394void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len)
395{
396 int start,end;
397
398 start=0;
399 while(start<len) {
400 if(src[start]!=' ')
401 break;
402 start++;
403 }
404 end=len-1;
405 while(end>start) {
406 if(src[end]!=' ')
407 break;
408 end--;
409 }
410 for( ; start<=end; start++) {
411 *dest++=src[start];
412 }
413 *dest='\0';
414}
415
416
wdenke887afc2002-08-27 09:44:07 +0000417/* Trim trailing blanks, and NUL-terminate string
418 */
419void scsi_trim_trail (unsigned char *str, unsigned int len)
420{
421 unsigned char *p = str + len - 1;
422
423 while (len-- > 0) {
424 *p-- = '\0';
425 if (*p != ' ') {
426 return;
427 }
428 }
429}
430
431
432/************************************************************************************
433 * Some setup (fill-in) routines
434 */
435void scsi_setup_test_unit_ready(ccb * pccb)
436{
437 pccb->cmd[0]=SCSI_TST_U_RDY;
438 pccb->cmd[1]=pccb->lun<<5;
439 pccb->cmd[2]=0;
440 pccb->cmd[3]=0;
441 pccb->cmd[4]=0;
442 pccb->cmd[5]=0;
443 pccb->cmdlen=6;
444 pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
445}
446
447void scsi_setup_read_capacity(ccb * pccb)
448{
449 pccb->cmd[0]=SCSI_RD_CAPAC;
450 pccb->cmd[1]=pccb->lun<<5;
451 pccb->cmd[2]=0;
452 pccb->cmd[3]=0;
453 pccb->cmd[4]=0;
454 pccb->cmd[5]=0;
455 pccb->cmd[6]=0;
456 pccb->cmd[7]=0;
457 pccb->cmd[8]=0;
458 pccb->cmd[9]=0;
459 pccb->cmdlen=10;
460 pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
461
462}
463
464void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks)
465{
466 pccb->cmd[0]=SCSI_READ10;
467 pccb->cmd[1]=pccb->lun<<5;
468 pccb->cmd[2]=((unsigned char) (start>>24))&0xff;
469 pccb->cmd[3]=((unsigned char) (start>>16))&0xff;
470 pccb->cmd[4]=((unsigned char) (start>>8))&0xff;
471 pccb->cmd[5]=((unsigned char) (start))&0xff;
472 pccb->cmd[6]=0;
473 pccb->cmd[7]=((unsigned char) (blocks>>8))&0xff;
474 pccb->cmd[8]=(unsigned char) blocks & 0xff;
475 pccb->cmd[6]=0;
476 pccb->cmdlen=10;
477 pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
wdenkf1276d42005-02-03 23:00:49 +0000478 debug ("scsi_setup_read_ext: cmd: %02X %02X startblk %02X%02X%02X%02X blccnt %02X%02X\n",
wdenke887afc2002-08-27 09:44:07 +0000479 pccb->cmd[0],pccb->cmd[1],
480 pccb->cmd[2],pccb->cmd[3],pccb->cmd[4],pccb->cmd[5],
481 pccb->cmd[7],pccb->cmd[8]);
482}
483
484void scsi_setup_read6(ccb * pccb, unsigned long start, unsigned short blocks)
485{
486 pccb->cmd[0]=SCSI_READ6;
487 pccb->cmd[1]=pccb->lun<<5 | (((unsigned char)(start>>16))&0x1f);
488 pccb->cmd[2]=((unsigned char) (start>>8))&0xff;
489 pccb->cmd[3]=((unsigned char) (start))&0xff;
490 pccb->cmd[4]=(unsigned char) blocks & 0xff;
491 pccb->cmd[5]=0;
492 pccb->cmdlen=6;
493 pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
wdenkf1276d42005-02-03 23:00:49 +0000494 debug ("scsi_setup_read6: cmd: %02X %02X startblk %02X%02X blccnt %02X\n",
wdenke887afc2002-08-27 09:44:07 +0000495 pccb->cmd[0],pccb->cmd[1],
496 pccb->cmd[2],pccb->cmd[3],pccb->cmd[4]);
497}
498
499
500void scsi_setup_inquiry(ccb * pccb)
501{
502 pccb->cmd[0]=SCSI_INQUIRY;
503 pccb->cmd[1]=pccb->lun<<5;
504 pccb->cmd[2]=0;
505 pccb->cmd[3]=0;
506 if(pccb->datalen>255)
507 pccb->cmd[4]=255;
508 else
509 pccb->cmd[4]=(unsigned char)pccb->datalen;
510 pccb->cmd[5]=0;
511 pccb->cmdlen=6;
512 pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
513}
514
Wolfgang Denk6a3d6b02005-08-04 01:14:12 +0200515
516U_BOOT_CMD(
517 scsi, 5, 1, do_scsi,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600518 "SCSI sub-system",
Wolfgang Denk6a3d6b02005-08-04 01:14:12 +0200519 "reset - reset SCSI controller\n"
520 "scsi info - show available SCSI devices\n"
521 "scsi scan - (re-)scan SCSI bus\n"
522 "scsi device [dev] - show or set current device\n"
523 "scsi part [dev] - print partition table of one or all SCSI devices\n"
524 "scsi read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200525 " to memory address `addr'"
Wolfgang Denk6a3d6b02005-08-04 01:14:12 +0200526);
527
528U_BOOT_CMD(
529 scsiboot, 3, 1, do_scsiboot,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600530 "boot from SCSI device",
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200531 "loadAddr dev:part"
Wolfgang Denk6a3d6b02005-08-04 01:14:12 +0200532);