Lines Matching +full:0 +full:us

35 static void pdump(struct us_data *us, void *ibuffer, int length);
39 #define ERR_STAT 0x01
40 #define DRQ_STAT 0x08
80 #define FCM_INT_STATUS 0x02 /* INDEX_STAT */
81 #define FCM_STATUS_BUSY 0x80
87 #define FCM_PACKET_ATAPI 0x21
88 #define FCM_PACKET_STATUS 0x20
94 #define FCM_PACKET_INPUT 0x81
97 #define FCM_PACKET_OUTPUT 0x01
103 #define FCM_PACKET_IDE_WRITE 0x40
104 #define FCM_PACKET_IDE_READ 0xC0
110 static int init_freecom(struct us_data *us);
152 freecom_readdata (struct scsi_cmnd *srb, struct us_data *us, in freecom_readdata() argument
156 (struct freecom_xfer_wrap *) us->iobuf; in freecom_readdata()
159 fxfr->Type = FCM_PACKET_INPUT | 0x00; in freecom_readdata()
160 fxfr->Timeout = 0; /* Short timeout for debugging. */ in freecom_readdata()
162 memset (fxfr->Pad, 0, sizeof (fxfr->Pad)); in freecom_readdata()
164 usb_stor_dbg(us, "Read data Freecom! (c=%d)\n", count); in freecom_readdata()
167 result = usb_stor_bulk_transfer_buf (us, opipe, fxfr, in freecom_readdata()
170 usb_stor_dbg(us, "Freecom readdata transport error\n"); in freecom_readdata()
175 usb_stor_dbg(us, "Start of read\n"); in freecom_readdata()
176 result = usb_stor_bulk_srb(us, ipipe, srb); in freecom_readdata()
177 usb_stor_dbg(us, "freecom_readdata done!\n"); in freecom_readdata()
185 freecom_writedata (struct scsi_cmnd *srb, struct us_data *us, in freecom_writedata() argument
189 (struct freecom_xfer_wrap *) us->iobuf; in freecom_writedata()
192 fxfr->Type = FCM_PACKET_OUTPUT | 0x00; in freecom_writedata()
193 fxfr->Timeout = 0; /* Short timeout for debugging. */ in freecom_writedata()
195 memset (fxfr->Pad, 0, sizeof (fxfr->Pad)); in freecom_writedata()
197 usb_stor_dbg(us, "Write data Freecom! (c=%d)\n", count); in freecom_writedata()
200 result = usb_stor_bulk_transfer_buf (us, opipe, fxfr, in freecom_writedata()
203 usb_stor_dbg(us, "Freecom writedata transport error\n"); in freecom_writedata()
208 usb_stor_dbg(us, "Start of write\n"); in freecom_writedata()
209 result = usb_stor_bulk_srb(us, opipe, srb); in freecom_writedata()
211 usb_stor_dbg(us, "freecom_writedata done!\n"); in freecom_writedata()
221 static int freecom_transport(struct scsi_cmnd *srb, struct us_data *us) in freecom_transport() argument
230 fcb = (struct freecom_cb_wrap *) us->iobuf; in freecom_transport()
231 fst = (struct freecom_status *) us->iobuf; in freecom_transport()
233 usb_stor_dbg(us, "Freecom TRANSPORT STARTED\n"); in freecom_transport()
236 opipe = us->send_bulk_pipe; in freecom_transport()
237 ipipe = us->recv_bulk_pipe; in freecom_transport()
240 fcb->Type = FCM_PACKET_ATAPI | 0x00; in freecom_transport()
241 fcb->Timeout = 0; in freecom_transport()
243 memset (fcb->Filler, 0, sizeof (fcb->Filler)); in freecom_transport()
245 US_DEBUG(pdump(us, srb->cmnd, 12)); in freecom_transport()
248 result = usb_stor_bulk_transfer_buf (us, opipe, fcb, in freecom_transport()
257 usb_stor_dbg(us, "freecom transport error\n"); in freecom_transport()
263 * doesn't hurt us to always do it now. in freecom_transport()
265 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, in freecom_transport()
267 usb_stor_dbg(us, "foo Status result %d %u\n", result, partial); in freecom_transport()
271 US_DEBUG(pdump(us, (void *)fst, partial)); in freecom_transport()
283 usb_stor_dbg(us, "20 second USB/ATAPI bridge TIMEOUT occurred!\n"); in freecom_transport()
284 usb_stor_dbg(us, "fst->Status is %x\n", fst->Status); in freecom_transport()
288 fcb->Timeout = 0; in freecom_transport()
289 memset (fcb->Atapi, 0, sizeof(fcb->Atapi)); in freecom_transport()
290 memset (fcb->Filler, 0, sizeof (fcb->Filler)); in freecom_transport()
293 result = usb_stor_bulk_transfer_buf (us, opipe, fcb, in freecom_transport()
302 usb_stor_dbg(us, "freecom transport error\n"); in freecom_transport()
307 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, in freecom_transport()
310 usb_stor_dbg(us, "bar Status result %d %u\n", result, partial); in freecom_transport()
314 US_DEBUG(pdump(us, (void *)fst, partial)); in freecom_transport()
319 if ((fst->Status & 1) != 0) { in freecom_transport()
320 usb_stor_dbg(us, "operation failed\n"); in freecom_transport()
329 usb_stor_dbg(us, "Device indicates that it has %d bytes available\n", in freecom_transport()
331 usb_stor_dbg(us, "SCSI requested %d\n", scsi_bufflen(srb)); in freecom_transport()
334 switch (srb->cmnd[0]) { in freecom_transport()
348 usb_stor_dbg(us, "Truncating request to match buffer length: %d\n", in freecom_transport()
357 switch (us->srb->sc_data_direction) { in freecom_transport()
359 /* catch bogus "read 0 length" case */ in freecom_transport()
366 if ((fst->Status & DRQ_STAT) == 0 || (fst->Reason & 3) != 2) { in freecom_transport()
367 usb_stor_dbg(us, "SCSI wants data, drive doesn't have any\n"); in freecom_transport()
370 result = freecom_readdata (srb, us, ipipe, opipe, length); in freecom_transport()
374 usb_stor_dbg(us, "Waiting for status\n"); in freecom_transport()
375 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, in freecom_transport()
377 US_DEBUG(pdump(us, (void *)fst, partial)); in freecom_transport()
381 if ((fst->Status & ERR_STAT) != 0) { in freecom_transport()
382 usb_stor_dbg(us, "operation failed\n"); in freecom_transport()
386 usb_stor_dbg(us, "Drive seems still hungry\n"); in freecom_transport()
389 usb_stor_dbg(us, "Transfer happy\n"); in freecom_transport()
393 /* catch bogus "write 0 length" case */ in freecom_transport()
398 * send us data. in freecom_transport()
401 result = freecom_writedata (srb, us, ipipe, opipe, length); in freecom_transport()
405 usb_stor_dbg(us, "Waiting for status\n"); in freecom_transport()
406 result = usb_stor_bulk_transfer_buf (us, ipipe, fst, in freecom_transport()
411 if ((fst->Status & ERR_STAT) != 0) { in freecom_transport()
412 usb_stor_dbg(us, "operation failed\n"); in freecom_transport()
416 usb_stor_dbg(us, "Drive seems still hungry\n"); in freecom_transport()
420 usb_stor_dbg(us, "Transfer happy\n"); in freecom_transport()
430 usb_stor_dbg(us, "freecom unimplemented direction: %d\n", in freecom_transport()
431 us->srb->sc_data_direction); in freecom_transport()
439 static int init_freecom(struct us_data *us) in init_freecom() argument
442 char *buffer = us->iobuf; in init_freecom()
449 result = usb_stor_control_msg(us, us->recv_ctrl_pipe, in init_freecom()
450 0x4c, 0xc0, 0x4346, 0x0, buffer, 0x20, 3*HZ); in init_freecom()
451 buffer[32] = '\0'; in init_freecom()
452 usb_stor_dbg(us, "String returned from FC init is: %s\n", buffer); in init_freecom()
462 result = usb_stor_control_msg(us, us->send_ctrl_pipe, in init_freecom()
463 0x4d, 0x40, 0x24d8, 0x0, NULL, 0x0, 3*HZ); in init_freecom()
464 usb_stor_dbg(us, "result from activate reset is %d\n", result); in init_freecom()
470 result = usb_stor_control_msg(us, us->send_ctrl_pipe, in init_freecom()
471 0x4d, 0x40, 0x24f8, 0x0, NULL, 0x0, 3*HZ); in init_freecom()
472 usb_stor_dbg(us, "result from clear reset is %d\n", result); in init_freecom()
480 static int usb_stor_freecom_reset(struct us_data *us) in usb_stor_freecom_reset() argument
489 static void pdump(struct us_data *us, void *ibuffer, int length) in pdump() argument
492 int offset = 0; in pdump()
497 offset = 0; in pdump()
498 for (i = 0; i < length; i++) { in pdump()
499 if ((i & 15) == 0) { in pdump()
500 if (i > 0) { in pdump()
508 line[offset] = 0; in pdump()
509 usb_stor_dbg(us, "%s\n", line); in pdump()
510 offset = 0; in pdump()
513 } else if ((i & 7) == 0) { in pdump()
516 offset += sprintf (line+offset, " %02x", buffer[i] & 0xff); in pdump()
529 for (i = 0; i <= from; i++) { in pdump()
535 line[offset] = 0; in pdump()
536 usb_stor_dbg(us, "%s\n", line); in pdump()
545 struct us_data *us; in freecom_probe() local
548 result = usb_stor_probe1(&us, intf, id, in freecom_probe()
554 us->transport_name = "Freecom"; in freecom_probe()
555 us->transport = freecom_transport; in freecom_probe()
556 us->transport_reset = usb_stor_freecom_reset; in freecom_probe()
557 us->max_lun = 0; in freecom_probe()
559 result = usb_stor_probe2(us); in freecom_probe()