Lines Matching +full:0 +full:us
74 #define LSB_of(s) ((s)&0xFF)
83 } while (0)
104 #define NOT_ALLOCATED 0xffffffff
105 #define BAD_BLOCK 0xffff
106 #define CIS_BLOCK 0x400
107 #define UNUSED_BLOCK 0x3ff
110 sddr55_bulk_transport(struct us_data *us, int direction, in sddr55_bulk_transport() argument
112 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; in sddr55_bulk_transport()
114 us->recv_bulk_pipe : us->send_bulk_pipe; in sddr55_bulk_transport()
119 return usb_stor_bulk_transfer_buf(us, pipe, data, len, NULL); in sddr55_bulk_transport()
127 static int sddr55_status(struct us_data *us) in sddr55_status() argument
130 unsigned char *command = us->iobuf; in sddr55_status()
131 unsigned char *status = us->iobuf; in sddr55_status()
132 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; in sddr55_status()
135 memset(command, 0, 8); in sddr55_status()
136 command[5] = 0xB0; in sddr55_status()
137 command[7] = 0x80; in sddr55_status()
138 result = sddr55_bulk_transport(us, in sddr55_status()
141 usb_stor_dbg(us, "Result for send_command in status %d\n", result); in sddr55_status()
144 set_sense_info (4, 0, 0); /* hardware error */ in sddr55_status()
148 result = sddr55_bulk_transport(us, in sddr55_status()
159 info->fatal_error = 0; in sddr55_status()
160 info->force_read_only = 0; in sddr55_status()
162 set_sense_info (2, 0x3a, 0); /* not ready, medium not present */ in sddr55_status()
167 set_sense_info (4, 0, 0); /* hardware error */ in sddr55_status()
172 info->read_only = (status[0] & 0x20); in sddr55_status()
175 result = sddr55_bulk_transport(us, in sddr55_status()
179 set_sense_info (4, 0, 0); /* hardware error */ in sddr55_status()
187 static int sddr55_read_data(struct us_data *us, in sddr55_read_data() argument
193 unsigned char *command = us->iobuf; in sddr55_read_data()
194 unsigned char *status = us->iobuf; in sddr55_read_data()
195 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; in sddr55_read_data()
214 offset = 0; in sddr55_read_data()
217 while (sectors>0) { in sddr55_read_data()
231 usb_stor_dbg(us, "Read %02X pages, from PBA %04X (LBA %04X) page %02X\n", in sddr55_read_data()
236 memset (buffer, 0, len); in sddr55_read_data()
241 command[0] = 0; in sddr55_read_data()
246 command[4] = 0; in sddr55_read_data()
247 command[5] = 0xB0; in sddr55_read_data()
249 command[7] = 0x85; in sddr55_read_data()
252 result = sddr55_bulk_transport(us, in sddr55_read_data()
255 usb_stor_dbg(us, "Result for send_command in read_data %d\n", in sddr55_read_data()
264 result = sddr55_bulk_transport(us, in sddr55_read_data()
273 result = sddr55_bulk_transport(us, in sddr55_read_data()
282 if (status[0] == 0xff && status[1] == 0x4) { in sddr55_read_data()
283 set_sense_info (3, 0x11, 0); in sddr55_read_data()
290 usb_stor_access_xfer_buf(buffer, len, us->srb, in sddr55_read_data()
293 page = 0; in sddr55_read_data()
306 static int sddr55_write_data(struct us_data *us, in sddr55_write_data() argument
312 unsigned char *command = us->iobuf; in sddr55_write_data()
313 unsigned char *status = us->iobuf; in sddr55_write_data()
314 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; in sddr55_write_data()
328 set_sense_info (7, 0x27, 0); /* read only */ in sddr55_write_data()
341 offset = 0; in sddr55_write_data()
344 while (sectors > 0) { in sddr55_write_data()
359 usb_stor_access_xfer_buf(buffer, len, us->srb, in sddr55_write_data()
362 usb_stor_dbg(us, "Write %02X pages, to PBA %04X (LBA %04X) page %02X\n", in sddr55_write_data()
365 command[4] = 0; in sddr55_write_data()
371 int found_count = 0; in sddr55_write_data()
377 usb_stor_dbg(us, "No PBA for LBA %04X\n", lba); in sddr55_write_data()
388 for (i = 0; i < max_pba; i++, pba++) { in sddr55_write_data()
400 usb_stor_dbg(us, "Couldn't find unallocated block\n"); in sddr55_write_data()
402 set_sense_info (3, 0x31, 0); /* medium error */ in sddr55_write_data()
407 usb_stor_dbg(us, "Allocating PBA %04X for LBA %04X\n", in sddr55_write_data()
411 command[4] = 0x40; in sddr55_write_data()
421 command[0] = LSB_of(lba % 1000); in sddr55_write_data()
425 command[5] = 0xB0; in sddr55_write_data()
426 command[7] = 0x86; in sddr55_write_data()
429 result = sddr55_bulk_transport(us, in sddr55_write_data()
433 usb_stor_dbg(us, "Result for send_command in write_data %d\n", in sddr55_write_data()
437 set_sense_info (3, 0x3, 0);/* peripheral write error */ in sddr55_write_data()
443 result = sddr55_bulk_transport(us, in sddr55_write_data()
447 usb_stor_dbg(us, "Result for send_data in write_data %d\n", in sddr55_write_data()
451 set_sense_info (3, 0x3, 0);/* peripheral write error */ in sddr55_write_data()
457 result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, status, 6); in sddr55_write_data()
460 usb_stor_dbg(us, "Result for get_status in write_data %d\n", in sddr55_write_data()
464 set_sense_info (3, 0x3, 0);/* peripheral write error */ in sddr55_write_data()
473 if (status[0] == 0xff && status[1] == 0x4) { in sddr55_write_data()
476 set_sense_info (3, 0x0c, 0); in sddr55_write_data()
481 usb_stor_dbg(us, "Updating maps for LBA %04X: old PBA %04X, new PBA %04X\n", in sddr55_write_data()
493 set_sense_info (3, 0x31, 0); in sddr55_write_data()
501 page = 0; in sddr55_write_data()
512 static int sddr55_read_deviceID(struct us_data *us, in sddr55_read_deviceID() argument
517 unsigned char *command = us->iobuf; in sddr55_read_deviceID()
518 unsigned char *content = us->iobuf; in sddr55_read_deviceID()
520 memset(command, 0, 8); in sddr55_read_deviceID()
521 command[5] = 0xB0; in sddr55_read_deviceID()
522 command[7] = 0x84; in sddr55_read_deviceID()
523 result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8); in sddr55_read_deviceID()
525 usb_stor_dbg(us, "Result of send_control for device ID is %d\n", in sddr55_read_deviceID()
531 result = sddr55_bulk_transport(us, in sddr55_read_deviceID()
537 *manufacturerID = content[0]; in sddr55_read_deviceID()
540 if (content[0] != 0xff) { in sddr55_read_deviceID()
541 result = sddr55_bulk_transport(us, in sddr55_read_deviceID()
549 static int sddr55_reset(struct us_data *us) in sddr55_reset() argument
551 return 0; in sddr55_reset()
555 static unsigned long sddr55_get_capacity(struct us_data *us) { in sddr55_get_capacity() argument
560 struct sddr55_card_info *info = (struct sddr55_card_info *)us->extra; in sddr55_get_capacity()
562 usb_stor_dbg(us, "Reading capacity...\n"); in sddr55_get_capacity()
564 result = sddr55_read_deviceID(us, in sddr55_get_capacity()
568 usb_stor_dbg(us, "Result of read_deviceID is %d\n", result); in sddr55_get_capacity()
571 return 0; in sddr55_get_capacity()
573 usb_stor_dbg(us, "Device ID = %02X\n", deviceID); in sddr55_get_capacity()
574 usb_stor_dbg(us, "Manuf ID = %02X\n", manufacturerID); in sddr55_get_capacity()
577 info->smallpageshift = 0; in sddr55_get_capacity()
584 case 0x6e: // 1MB in sddr55_get_capacity()
585 case 0xe8: in sddr55_get_capacity()
586 case 0xec: in sddr55_get_capacity()
589 return 0x00100000; in sddr55_get_capacity()
591 case 0xea: // 2MB in sddr55_get_capacity()
592 case 0x64: in sddr55_get_capacity()
596 case 0x5d: // 5d is a ROM card with pagesize 512. in sddr55_get_capacity()
597 return 0x00200000; in sddr55_get_capacity()
599 case 0xe3: // 4MB in sddr55_get_capacity()
600 case 0xe5: in sddr55_get_capacity()
601 case 0x6b: in sddr55_get_capacity()
602 case 0xd5: in sddr55_get_capacity()
603 return 0x00400000; in sddr55_get_capacity()
605 case 0xe6: // 8MB in sddr55_get_capacity()
606 case 0xd6: in sddr55_get_capacity()
607 return 0x00800000; in sddr55_get_capacity()
609 case 0x73: // 16MB in sddr55_get_capacity()
613 return 0x01000000; in sddr55_get_capacity()
615 case 0x75: // 32MB in sddr55_get_capacity()
619 return 0x02000000; in sddr55_get_capacity()
621 case 0x76: // 64MB in sddr55_get_capacity()
625 return 0x04000000; in sddr55_get_capacity()
627 case 0x79: // 128MB in sddr55_get_capacity()
631 return 0x08000000; in sddr55_get_capacity()
634 return 0; in sddr55_get_capacity()
639 static int sddr55_read_map(struct us_data *us) { in sddr55_read_map() argument
641 struct sddr55_card_info *info = (struct sddr55_card_info *)(us->extra); in sddr55_read_map()
644 unsigned char *command = us->iobuf; in sddr55_read_map()
660 memset(command, 0, 8); in sddr55_read_map()
661 command[5] = 0xB0; in sddr55_read_map()
663 command[7] = 0x8A; in sddr55_read_map()
665 result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8); in sddr55_read_map()
672 result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, buffer, numblocks * 2); in sddr55_read_map()
679 result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, command, 2); in sddr55_read_map()
700 memset(info->lba_to_pba, 0xff, numblocks*sizeof(int)); in sddr55_read_map()
701 memset(info->pba_to_lba, 0xff, numblocks*sizeof(int)); in sddr55_read_map()
713 for (i=0; i<numblocks; i++) { in sddr55_read_map()
723 * 1024-2047 you will find LBA 0-999 which are in sddr55_read_map()
731 * SDDR55 returns 0xffff for a bad block, and 0x400 for the in sddr55_read_map()
750 if (lba<0x10 || (lba>=0x3E0 && lba<0x3EF)) in sddr55_read_map()
751 usb_stor_dbg(us, "LBA %04X <-> PBA %04X\n", lba, i); in sddr55_read_map()
757 return 0; in sddr55_read_map()
775 static int sddr55_transport(struct scsi_cmnd *srb, struct us_data *us) in sddr55_transport() argument
779 0x00, 0x80, 0x00, 0x02, 0x1F, 0x00, 0x00, 0x00 in sddr55_transport()
783 0x0, 0x12, 0x00, 0x80, 0x0, 0x0, 0x0, 0x0, in sddr55_transport()
784 0x01, 0x0A, in sddr55_transport()
785 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 in sddr55_transport()
787 unsigned char *ptr = us->iobuf; in sddr55_transport()
795 if (!us->extra) { in sddr55_transport()
796 us->extra = kzalloc( in sddr55_transport()
798 if (!us->extra) in sddr55_transport()
800 us->extra_destructor = sddr55_card_info_destructor; in sddr55_transport()
803 info = (struct sddr55_card_info *)(us->extra); in sddr55_transport()
805 if (srb->cmnd[0] == REQUEST_SENSE) { in sddr55_transport()
806 usb_stor_dbg(us, "request sense %02x/%02x/%02x\n", in sddr55_transport()
812 ptr[0] = 0x70; in sddr55_transport()
815 memset (info->sense_data, 0, sizeof info->sense_data); in sddr55_transport()
820 memset (info->sense_data, 0, sizeof info->sense_data); in sddr55_transport()
827 if (srb->cmnd[0] == INQUIRY) { in sddr55_transport()
829 fill_inquiry_response(us, ptr, 36); in sddr55_transport()
840 result = sddr55_status (us); in sddr55_transport()
842 result = sddr55_status (us); in sddr55_transport()
844 set_sense_info (6, 0x28, 0); /* new media, set unit attention, not ready to ready */ in sddr55_transport()
856 set_sense_info (3, 0x31, 0); in sddr55_transport()
860 if (srb->cmnd[0] == READ_CAPACITY) { in sddr55_transport()
862 capacity = sddr55_get_capacity(us); in sddr55_transport()
865 set_sense_info (3, 0x30, 0); /* incompatible medium */ in sddr55_transport()
886 ((__be32 *) ptr)[0] = cpu_to_be32(capacity); in sddr55_transport()
890 sddr55_read_map(us); in sddr55_transport()
895 if (srb->cmnd[0] == MODE_SENSE_10) { in sddr55_transport()
898 ptr[3] = (info->read_only || info->force_read_only) ? 0x80 : 0; in sddr55_transport()
901 if ( (srb->cmnd[2] & 0x3F) == 0x01 ) { in sddr55_transport()
902 usb_stor_dbg(us, "Dummy up request for mode page 1\n"); in sddr55_transport()
905 } else if ( (srb->cmnd[2] & 0x3F) == 0x3F ) { in sddr55_transport()
906 usb_stor_dbg(us, "Dummy up request for all mode pages\n"); in sddr55_transport()
910 set_sense_info (5, 0x24, 0); /* invalid field in command */ in sddr55_transport()
914 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { in sddr55_transport()
916 usb_stor_dbg(us, "%s medium removal. Not that I can do anything about it...\n", in sddr55_transport()
917 (srb->cmnd[4]&0x03) ? "Prevent" : "Allow"); in sddr55_transport()
923 if (srb->cmnd[0] == READ_10 || srb->cmnd[0] == WRITE_10) { in sddr55_transport()
941 usb_stor_dbg(us, "Error: Requested LBA %04X exceeds maximum block %04X\n", in sddr55_transport()
944 set_sense_info (5, 0x24, 0); /* invalid field in command */ in sddr55_transport()
951 if (srb->cmnd[0] == WRITE_10) { in sddr55_transport()
952 usb_stor_dbg(us, "WRITE_10: write block %04X (LBA %04X) page %01X pages %d\n", in sddr55_transport()
955 return sddr55_write_data(us, lba, page, pages); in sddr55_transport()
957 usb_stor_dbg(us, "READ_10: read block %04X (LBA %04X) page %01X pages %d\n", in sddr55_transport()
960 return sddr55_read_data(us, lba, page, pages); in sddr55_transport()
965 if (srb->cmnd[0] == TEST_UNIT_READY) { in sddr55_transport()
969 if (srb->cmnd[0] == START_STOP) { in sddr55_transport()
973 set_sense_info (5, 0x20, 0); /* illegal command */ in sddr55_transport()
983 struct us_data *us; in sddr55_probe() local
986 result = usb_stor_probe1(&us, intf, id, in sddr55_probe()
992 us->transport_name = "SDDR55"; in sddr55_probe()
993 us->transport = sddr55_transport; in sddr55_probe()
994 us->transport_reset = sddr55_reset; in sddr55_probe()
995 us->max_lun = 0; in sddr55_probe()
997 result = usb_stor_probe2(us); in sddr55_probe()