Lines Matching +full:1 +full:- +full:9 +full:a +full:- +full:d
1 // SPDX-License-Identifier: GPL-2.0+
3 * Driver for SanDisk SDDR-09 SmartMedia reader
10 * The SanDisk SDDR-09 SmartMedia reader uses the Shuttle EUSB-01 chip.
11 * This chip is a programmable USB controller. In the SDDR-09, it has
12 * been programmed to obey a certain limited set of SCSI commands.
13 * This driver translates the "real" SCSI commands to the SDDR-09 SCSI
45 #define DRV_NAME "ums-sddr09"
47 MODULE_DESCRIPTION("Driver for SanDisk SDDR-09 SmartMedia reader");
109 int chipshift; /* 1<<cs bytes total capacity */
110 char pageshift; /* 1<<ps bytes in a page */
111 char blockshift; /* 1<<bs pages in an erase block */
112 char zoneshift; /* 1<<zs blocks in a zone */
114 char pageadrlen; /* length of an address in bytes - 1 */
142 * remaining data: SSFDC prescribes manufacturer-independent id codes.
144 * 256 MB NAND flash has a 5-byte ID with 2nd byte 0xaa, 0xba, 0xca or 0xda.
149 { 0x6e, 20, 8, 4, 8, 2}, /* 1 MB */
150 { 0xe8, 20, 8, 4, 8, 2}, /* 1 MB */
151 { 0xec, 20, 8, 4, 8, 2}, /* 1 MB */
152 { 0x64, 21, 8, 4, 9, 2}, /* 2 MB */
153 { 0xea, 21, 8, 4, 9, 2}, /* 2 MB */
154 { 0x6b, 22, 9, 4, 9, 2}, /* 4 MB */
155 { 0xe3, 22, 9, 4, 9, 2}, /* 4 MB */
156 { 0xe5, 22, 9, 4, 9, 2}, /* 4 MB */
157 { 0xe6, 23, 9, 4, 10, 2}, /* 8 MB */
158 { 0x73, 24, 9, 5, 10, 2}, /* 16 MB */
159 { 0x75, 25, 9, 5, 10, 2}, /* 32 MB */
160 { 0x76, 26, 9, 5, 10, 3}, /* 64 MB */
161 { 0x79, 27, 9, 5, 10, 3}, /* 128 MB */
164 { 0x5d, 21, 9, 4, 8, 2}, /* 2 MB */
165 { 0xd5, 22, 9, 4, 9, 2}, /* 4 MB */
166 { 0xd6, 23, 9, 4, 10, 2}, /* 8 MB */
167 { 0x57, 24, 9, 4, 11, 2}, /* 16 MB */
168 { 0x58, 25, 9, 4, 12, 2}, /* 32 MB */
189 int i, j, a; in nand_init_ecc() local
192 for (i = 1; i < 256; i++) in nand_init_ecc()
193 parity[i] = (parity[i&(i-1)] ^ 1); in nand_init_ecc()
196 a = 0; in nand_init_ecc()
198 if (i & (1<<j)) { in nand_init_ecc()
199 if ((j & 1) == 0) in nand_init_ecc()
200 a ^= 0x04; in nand_init_ecc()
202 a ^= 0x10; in nand_init_ecc()
204 a ^= 0x40; in nand_init_ecc()
207 ecc2[i] = ~(a ^ (a<<1) ^ (parity[i] ? 0xa8 : 0)); in nand_init_ecc()
211 /* compute 3-byte ecc on 256 bytes */
213 int i, j, a; in nand_compute_ecc() local
221 if ((i & (1<<j)) == 0) in nand_compute_ecc()
226 a = (bits[3] << 6) + (bits[2] << 4) + (bits[1] << 2) + bits[0]; in nand_compute_ecc()
227 ecc[0] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0)); in nand_compute_ecc()
229 a = (bits[7] << 6) + (bits[6] << 4) + (bits[5] << 2) + bits[4]; in nand_compute_ecc()
230 ecc[1] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0)); in nand_compute_ecc()
236 return (data[0] == ecc[0] && data[1] == ecc[1] && data[2] == ecc[2]); in nand_compare_ecc()
253 int blockmask; /* 2^blockshift - 1 */
258 #define SDDR09_WP 1 /* write protected */
265 * depend on the card. For now a constant.
270 * On my Combo CF/SM reader, the SM reader has LUN 1.
274 #define LUN 1
287 /* called for requests 0, 1, 8 */
301 pipe = us->recv_ctrl_pipe; in sddr09_send_command()
303 pipe = us->send_ctrl_pipe; in sddr09_send_command()
309 case USB_STOR_XFER_STALLED: return -EPIPE; in sddr09_send_command()
310 default: return -EIO; in sddr09_send_command()
328 unsigned char *command = us->iobuf;
332 command[1] = LUNBITS;
336 usb_stor_dbg(us, "sddr09_test_unit_ready returns %d\n", result);
349 unsigned char *command = us->iobuf; in sddr09_request_sense()
354 command[1] = LUNBITS; in sddr09_request_sense()
361 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in sddr09_request_sense()
363 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); in sddr09_request_sense()
369 * byte 1: last two bits: 00: read data, 01: read blockwise control,
371 * It turns out we need values 20, 21, 22, 23 here (LUN 1).
372 * bytes 2-5: address (interpretation depends on byte 1, see below)
373 * bytes 10-11: count (idem)
375 * A page has 512 data bytes and 64 control bytes (16 control and 48 junk).
376 * A read data command gets data in 512-byte pages.
377 * A read control command gets control in 64-byte chunks.
378 * A read both command gets data+control in 576-byte chunks.
382 * reading a group of 64 control bytes.
383 * [Here 512 = 1<<pageshift, 32 = 1<<blockshift, 64 is constant?]
385 * (1 MB and 2 MB cards are a bit different, but I have only a 16 MB card.)
393 unsigned char *command = us->iobuf; in sddr09_readX()
397 command[1] = LUNBITS | x; in sddr09_readX()
405 command[9] = 0; in sddr09_readX()
412 usb_stor_dbg(us, "Result for send_control in sddr09_read2%d %d\n", in sddr09_readX()
417 result = usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, in sddr09_readX()
421 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read2%d %d\n", in sddr09_readX()
423 return -EIO; in sddr09_readX()
435 * nr_of_pages counts pages of size (1 << pageshift).
454 * count counts control groups of size (1 << controlshift).
465 return sddr09_readX(us, 1, fromaddress, count, bulklen, in sddr09_read21()
476 * nr_of_pages counts pages of size (1 << pageshift) + (1 << controlshift).
483 usb_stor_dbg(us, "reading %d pages, %d bytes\n", nr_of_pages, bulklen); in sddr09_read22()
496 * count counts control groups of size (1 << controlshift).
515 * bytes 6-9: erase address (big-endian, counting shorts, sector aligned).
517 * Always precisely one block is erased; bytes 2-5 and 10-11 are ignored.
523 unsigned char *command = us->iobuf; in sddr09_erase()
530 command[1] = LUNBITS; in sddr09_erase()
534 command[9] = LSB_of(Eaddress & 0xFFFF); in sddr09_erase()
539 usb_stor_dbg(us, "Result for send_control in sddr09_erase %d\n", in sddr09_erase()
548 * bytes 2-5: write address in shorts
549 * bytes 10-11: sector count
562 * bytes 2-5: write address (big-endian, counting shorts, sector aligned).
563 * bytes 6-9: erase address (big-endian, counting shorts, sector aligned).
564 * bytes 10-11: sector count (big-endian, in 512-byte sectors).
575 unsigned char *command = us->iobuf; in sddr09_writeX()
579 command[1] = LUNBITS; in sddr09_writeX()
589 command[9] = LSB_of(Eaddress & 0xFFFF); in sddr09_writeX()
597 usb_stor_dbg(us, "Result for send_control in sddr09_writeX %d\n", in sddr09_writeX()
602 result = usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, in sddr09_writeX()
606 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_writeX %d\n", in sddr09_writeX()
608 return -EIO; in sddr09_writeX()
628 * bytes 4i-1,4i,4i+1: page address
630 * (i=1..n)
632 * This reads several pages from the card to a single memory buffer.
633 * The last two bits of byte 1 have the same meaning as for E8.
637 unsigned char *command = us->iobuf;
644 command[1] = LUNBITS;
646 address = 040000; ct = 1;
648 bulklen += (ct << 9);
650 command[4*nsg+1] = ((address >> 9) & 0xFF);
652 command[4*nsg-1] = ((address >> 25) & 0xFF);
654 address = 0340000; ct = 1;
656 bulklen += (ct << 9);
658 command[4*nsg+1] = ((address >> 9) & 0xFF);
660 command[4*nsg-1] = ((address >> 25) & 0xFF);
664 bulklen += (ct << 9);
666 command[4*nsg+1] = ((address >> 9) & 0xFF);
668 command[4*nsg-1] = ((address >> 25) & 0xFF);
675 usb_stor_dbg(us, "Result for send_control in sddr09_read_sg %d\n",
682 return -ENOMEM;
684 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
688 usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read_sg %d\n",
690 return -EIO;
702 * bit 0: 1: Error
703 * bit 5: 1: Suspended
704 * bit 6: 1: Ready
705 * bit 7: 1: Not write-protected
711 unsigned char *command = us->iobuf; in sddr09_read_status()
712 unsigned char *data = us->iobuf; in sddr09_read_status()
719 command[1] = LUNBITS; in sddr09_read_status()
725 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in sddr09_read_status()
728 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); in sddr09_read_status()
736 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_read_data()
745 lba = address >> info->blockshift; in sddr09_read_data()
746 page = (address & info->blockmask); in sddr09_read_data()
747 maxlba = info->capacity >> (info->pageshift + info->blockshift); in sddr09_read_data()
749 return -EIO; in sddr09_read_data()
751 // Since we only read in one block at a time, we have to create in sddr09_read_data()
752 // a bounce buffer and move the data a piece at a time between the in sddr09_read_data()
755 len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; in sddr09_read_data()
758 return -ENOMEM; in sddr09_read_data()
770 pages = min(sectors, info->blocksize - page); in sddr09_read_data()
771 len = pages << info->pageshift; in sddr09_read_data()
777 result = -EIO; in sddr09_read_data()
782 pba = info->lba_to_pba[lba]; in sddr09_read_data()
786 usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", in sddr09_read_data()
799 usb_stor_dbg(us, "Read %d pages, from PBA %d (LBA %d) page %d\n", in sddr09_read_data()
802 address = ((pba << info->blockshift) + page) << in sddr09_read_data()
803 info->pageshift; in sddr09_read_data()
805 result = sddr09_read20(us, address>>1, in sddr09_read_data()
806 pages, info->pageshift, buffer, 0); in sddr09_read_data()
812 usb_stor_access_xfer_buf(buffer, len, us->srb, in sddr09_read_data()
817 sectors -= pages; in sddr09_read_data()
826 static unsigned int lastpba = 1; in sddr09_find_unused_pba()
830 end = info->capacity >> (info->blockshift + info->pageshift); in sddr09_find_unused_pba()
831 end -= zonestart; in sddr09_find_unused_pba()
835 for (i = lastpba+1; i < end; i++) { in sddr09_find_unused_pba()
836 if (info->pba_to_lba[zonestart+i] == UNDEF) { in sddr09_find_unused_pba()
842 if (info->pba_to_lba[zonestart+i] == UNDEF) { in sddr09_find_unused_pba()
855 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_write_lba()
863 lbap = ((lba % 1000) << 1) | 0x1000; in sddr09_write_lba()
865 lbap ^= 1; in sddr09_write_lba()
866 pba = info->lba_to_pba[lba]; in sddr09_write_lba()
873 return -ENOSPC; in sddr09_write_lba()
875 info->pba_to_lba[pba] = lba; in sddr09_write_lba()
876 info->lba_to_pba[lba] = pba; in sddr09_write_lba()
879 if (pba == 1) { in sddr09_write_lba()
881 * Maybe it is impossible to write to PBA 1. in sddr09_write_lba()
884 printk(KERN_WARNING "sddr09: avoid writing to pba 1\n"); in sddr09_write_lba()
888 pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); in sddr09_write_lba()
891 address = (pba << (info->pageshift + info->blockshift)); in sddr09_write_lba()
892 result = sddr09_read22(us, address>>1, info->blocksize, in sddr09_write_lba()
893 info->pageshift, blockbuffer, 0); in sddr09_write_lba()
898 for (i = 0; i < info->blocksize; i++) { in sddr09_write_lba()
900 cptr = bptr + info->pagesize; in sddr09_write_lba()
903 usb_stor_dbg(us, "Warning: bad ecc in page %d- of pba %d\n", in sddr09_write_lba()
907 nand_compute_ecc(bptr+(info->pagesize / 2), ecc); in sddr09_write_lba()
909 usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n", in sddr09_write_lba()
921 cptr = bptr + info->pagesize; in sddr09_write_lba()
922 memcpy(bptr, xptr, info->pagesize); in sddr09_write_lba()
923 xptr += info->pagesize; in sddr09_write_lba()
926 nand_compute_ecc(bptr+(info->pagesize / 2), ecc); in sddr09_write_lba()
930 usb_stor_dbg(us, "Rewrite PBA %d (LBA %d)\n", pba, lba); in sddr09_write_lba()
932 result = sddr09_write_inplace(us, address>>1, info->blocksize, in sddr09_write_lba()
933 info->pageshift, blockbuffer, 0); in sddr09_write_lba()
935 usb_stor_dbg(us, "sddr09_write_inplace returns %d\n", result); in sddr09_write_lba()
962 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_write_data()
972 lba = address >> info->blockshift; in sddr09_write_data()
973 page = (address & info->blockmask); in sddr09_write_data()
974 maxlba = info->capacity >> (info->pageshift + info->blockshift); in sddr09_write_data()
976 return -EIO; in sddr09_write_data()
985 * add a bufferpointer to the info structure in sddr09_write_data()
988 pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); in sddr09_write_data()
989 blocklen = (pagelen << info->blockshift); in sddr09_write_data()
992 return -ENOMEM; in sddr09_write_data()
996 * we have to create a bounce buffer and move the data a piece in sddr09_write_data()
997 * at a time between the bounce buffer and the actual transfer buffer. in sddr09_write_data()
1000 len = min(sectors, (unsigned int) info->blocksize) * info->pagesize; in sddr09_write_data()
1004 return -ENOMEM; in sddr09_write_data()
1015 pages = min(sectors, info->blocksize - page); in sddr09_write_data()
1016 len = (pages << info->pageshift); in sddr09_write_data()
1022 result = -EIO; in sddr09_write_data()
1027 usb_stor_access_xfer_buf(buffer, len, us->srb, in sddr09_write_data()
1037 sectors -= pages; in sddr09_write_data()
1053 usb_stor_dbg(us, "Read control address %lu, blocks %d\n", in sddr09_read_control()
1066 * signifying that the secret command to read an 128-bit ID is available.
1068 * a second read ID cmd is available.
1072 unsigned char *command = us->iobuf; in sddr09_read_deviceID()
1073 unsigned char *content = us->iobuf; in sddr09_read_deviceID()
1078 command[1] = LUNBITS; in sddr09_read_deviceID()
1084 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in sddr09_read_deviceID()
1090 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); in sddr09_read_deviceID()
1105 info->flags |= SDDR09_WP; /* write protected */ in sddr09_get_wp()
1126 unsigned char *command = us->iobuf;
1130 command[1] = LUNBITS;
1148 usb_stor_dbg(us, "Result of read_deviceID is %d\n", result); in sddr09_get_cardinfo()
1160 /* Byte 1 is the device type */ in sddr09_get_cardinfo()
1161 cardinfo = nand_find_id(deviceID[1]); in sddr09_get_cardinfo()
1164 * MB or MiB? It is neither. A 16 MB card has in sddr09_get_cardinfo()
1169 ", %d MB", 1<<(cardinfo->chipshift - 20)); in sddr09_get_cardinfo()
1175 /* Byte 2 is code to signal availability of 128-bit ID */ in sddr09_get_cardinfo()
1178 ", 128-bit ID"); in sddr09_get_cardinfo()
1199 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; in sddr09_read_map()
1205 if (!info->capacity) in sddr09_read_map()
1206 return -1; in sddr09_read_map()
1209 * size of a block is 1 << (blockshift + pageshift) bytes in sddr09_read_map()
1213 numblocks = info->capacity >> (info->blockshift + info->pageshift); in sddr09_read_map()
1216 * read 64 bytes for every block (actually 1 << CONTROL_SHIFT) in sddr09_read_map()
1217 * but only use a 64 KB buffer in sddr09_read_map()
1218 * buffer size used must be a multiple of (1 << CONTROL_SHIFT) in sddr09_read_map()
1226 result = -1; in sddr09_read_map()
1233 kfree(info->lba_to_pba); in sddr09_read_map()
1234 kfree(info->pba_to_lba); in sddr09_read_map()
1235 info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO); in sddr09_read_map()
1236 info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO); in sddr09_read_map()
1238 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { in sddr09_read_map()
1240 result = -1; in sddr09_read_map()
1245 info->lba_to_pba[i] = info->pba_to_lba[i] = UNDEF; in sddr09_read_map()
1248 * Define lba-pba translation table in sddr09_read_map()
1253 ptr += (1 << CONTROL_SHIFT); in sddr09_read_map()
1257 address = i << (info->pageshift + info->blockshift); in sddr09_read_map()
1259 us, address>>1, in sddr09_read_map()
1260 min(alloc_blocks, numblocks - i), in sddr09_read_map()
1263 result = -1; in sddr09_read_map()
1269 if (i == 0 || i == 1) { in sddr09_read_map()
1270 info->pba_to_lba[i] = UNUSABLE; in sddr09_read_map()
1278 info->pba_to_lba[i] = UNUSABLE; in sddr09_read_map()
1279 printk(KERN_WARNING "sddr09: PBA %d has no logical mapping\n", in sddr09_read_map()
1294 "sddr09: PBA %d has no logical mapping: " in sddr09_read_map()
1297 i, ptr[0], ptr[1], ptr[2], ptr[3], in sddr09_read_map()
1299 info->pba_to_lba[i] = UNUSABLE; in sddr09_read_map()
1305 "sddr09: PBA %d has invalid address field " in sddr09_read_map()
1308 info->pba_to_lba[i] = UNUSABLE; in sddr09_read_map()
1315 "sddr09: Bad parity in LBA for block %d" in sddr09_read_map()
1317 info->pba_to_lba[i] = UNUSABLE; in sddr09_read_map()
1322 lba = (lba & 0x07FF) >> 1; in sddr09_read_map()
1326 * go back to zero, but are within a higher block of LBA's. in sddr09_read_map()
1327 * Also, there is a maximum of 1000 LBA's per zone. in sddr09_read_map()
1328 * In other words, in PBA 1024-2047 you will find LBA 0-999 in sddr09_read_map()
1329 * which are really LBA 1000-1999. This allows for 24 bad in sddr09_read_map()
1335 "sddr09: Bad low LBA %d for block %d\n", in sddr09_read_map()
1342 if (info->lba_to_pba[lba] != UNDEF) { in sddr09_read_map()
1344 "sddr09: LBA %d seen for PBA %d and %d\n", in sddr09_read_map()
1345 lba, info->lba_to_pba[lba], i); in sddr09_read_map()
1349 info->pba_to_lba[i] = lba; in sddr09_read_map()
1350 info->lba_to_pba[lba] = i; in sddr09_read_map()
1357 address = (i << (info->pageshift + info->blockshift)); in sddr09_read_map()
1358 sddr09_erase(us, address>>1); in sddr09_read_map()
1359 info->pba_to_lba[i] = UNDEF; in sddr09_read_map()
1361 info->pba_to_lba[i] = UNUSABLE; in sddr09_read_map()
1366 * since a zone with less than 1000 usable pages leads to in sddr09_read_map()
1375 if (info->pba_to_lba[i+j] != UNUSABLE) { in sddr09_read_map()
1377 info->pba_to_lba[i+j] = SPARE; in sddr09_read_map()
1384 info->lbact = lbact; in sddr09_read_map()
1385 usb_stor_dbg(us, "Found %d LBA's\n", lbact); in sddr09_read_map()
1390 kfree(info->lba_to_pba); in sddr09_read_map()
1391 kfree(info->pba_to_lba); in sddr09_read_map()
1392 info->lba_to_pba = NULL; in sddr09_read_map()
1393 info->pba_to_lba = NULL; in sddr09_read_map()
1406 kfree(info->lba_to_pba); in sddr09_card_info_destructor()
1407 kfree(info->pba_to_lba); in sddr09_card_info_destructor()
1414 /* set the configuration -- STALL is an acceptable response here */ in sddr09_common_init()
1415 if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { in sddr09_common_init()
1416 usb_stor_dbg(us, "active config #%d != 1 ??\n", in sddr09_common_init()
1417 us->pusb_dev->actconfig->desc.bConfigurationValue); in sddr09_common_init()
1418 return -EINVAL; in sddr09_common_init()
1421 result = usb_reset_configuration(us->pusb_dev); in sddr09_common_init()
1422 usb_stor_dbg(us, "Result of usb_reset_configuration is %d\n", result); in sddr09_common_init()
1423 if (result == -EPIPE) { in sddr09_common_init()
1424 usb_stor_dbg(us, "-- stall on control interface\n"); in sddr09_common_init()
1426 /* it's not a stall, but another error -- time to bail */ in sddr09_common_init()
1427 usb_stor_dbg(us, "-- Unknown error. Rejecting device\n"); in sddr09_common_init()
1428 return -EINVAL; in sddr09_common_init()
1431 us->extra = kzalloc(sizeof(struct sddr09_card_info), GFP_NOIO); in sddr09_common_init()
1432 if (!us->extra) in sddr09_common_init()
1433 return -ENOMEM; in sddr09_common_init()
1434 us->extra_destructor = sddr09_card_info_destructor; in sddr09_common_init()
1442 * This is needed at a very early stage. If this is not listed in the
1449 unsigned char *data = us->iobuf; in usb_stor_sddr09_dpcm_init()
1461 usb_stor_dbg(us, "%02X %02X\n", data[0], data[1]); in usb_stor_sddr09_dpcm_init()
1470 usb_stor_dbg(us, "%02X %02X\n", data[0], data[1]); in usb_stor_sddr09_dpcm_init()
1482 // additional transfer length * = sizeof(data) - 7 in usb_stor_sddr09_dpcm_init()
1494 * Transport for the Microtech DPCM-USB
1500 usb_stor_dbg(us, "LUN=%d\n", (u8)srb->device->lun); in dpcm_transport()
1502 switch (srb->device->lun) { in dpcm_transport()
1511 case 1: in dpcm_transport()
1514 * LUN 1 corresponds to the SmartMedia card reader. in dpcm_transport()
1520 srb->device->lun = 0; in dpcm_transport()
1522 srb->device->lun = 1; in dpcm_transport()
1526 usb_stor_dbg(us, "Invalid LUN %d\n", (u8)srb->device->lun); in dpcm_transport()
1535 * Transport for the Sandisk SDDR-09
1542 unsigned char *ptr = us->iobuf; in sddr09_transport()
1559 info = (struct sddr09_card_info *)us->extra; in sddr09_transport()
1561 if (srb->cmnd[0] == REQUEST_SENSE && havefakesense) { in sddr09_transport()
1562 /* for a faked command, we have to follow with a faked sense */ in sddr09_transport()
1573 havefakesense = 1; in sddr09_transport()
1576 * Dummy up a response for INQUIRY since SDDR09 doesn't in sddr09_transport()
1580 if (srb->cmnd[0] == INQUIRY) { in sddr09_transport()
1586 if (srb->cmnd[0] == READ_CAPACITY) { in sddr09_transport()
1591 cardinfo = sddr09_get_cardinfo(us, info->flags); in sddr09_transport()
1600 info->capacity = (1 << cardinfo->chipshift); in sddr09_transport()
1601 info->pageshift = cardinfo->pageshift; in sddr09_transport()
1602 info->pagesize = (1 << info->pageshift); in sddr09_transport()
1603 info->blockshift = cardinfo->blockshift; in sddr09_transport()
1604 info->blocksize = (1 << info->blockshift); in sddr09_transport()
1605 info->blockmask = info->blocksize - 1; in sddr09_transport()
1615 capacity = (info->lbact << info->blockshift) - 1; in sddr09_transport()
1621 ((__be32 *) ptr)[1] = cpu_to_be32(info->pagesize); in sddr09_transport()
1627 if (srb->cmnd[0] == MODE_SENSE_10) { in sddr09_transport()
1628 int modepage = (srb->cmnd[2] & 0x3F); in sddr09_transport()
1640 ((__be16*)ptr)[0] = cpu_to_be16(sizeof(mode_page_01) - 2); in sddr09_transport()
1641 ptr[3] = (info->flags & SDDR09_WP) ? 0x80 : 0; in sddr09_transport()
1651 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) in sddr09_transport()
1656 if (srb->cmnd[0] == READ_10) { in sddr09_transport()
1658 page = short_pack(srb->cmnd[3], srb->cmnd[2]); in sddr09_transport()
1660 page |= short_pack(srb->cmnd[5], srb->cmnd[4]); in sddr09_transport()
1661 pages = short_pack(srb->cmnd[8], srb->cmnd[7]); in sddr09_transport()
1663 usb_stor_dbg(us, "READ_10: read page %d pagect %d\n", in sddr09_transport()
1671 if (srb->cmnd[0] == WRITE_10) { in sddr09_transport()
1673 page = short_pack(srb->cmnd[3], srb->cmnd[2]); in sddr09_transport()
1675 page |= short_pack(srb->cmnd[5], srb->cmnd[4]); in sddr09_transport()
1676 pages = short_pack(srb->cmnd[8], srb->cmnd[7]); in sddr09_transport()
1678 usb_stor_dbg(us, "WRITE_10: write page %d pagect %d\n", in sddr09_transport()
1687 * catch-all for all other commands, except in sddr09_transport()
1690 if (srb->cmnd[0] != TEST_UNIT_READY && in sddr09_transport()
1691 srb->cmnd[0] != REQUEST_SENSE) { in sddr09_transport()
1694 havefakesense = 1; in sddr09_transport()
1698 for (; srb->cmd_len<12; srb->cmd_len++) in sddr09_transport()
1699 srb->cmnd[srb->cmd_len] = 0; in sddr09_transport()
1701 srb->cmnd[1] = LUNBITS; in sddr09_transport()
1705 sprintf(ptr+strlen(ptr), "%02X ", srb->cmnd[i]); in sddr09_transport()
1709 result = sddr09_send_scsi_command(us, srb->cmnd, 12); in sddr09_transport()
1711 usb_stor_dbg(us, "sddr09_send_scsi_command returns %d\n", in sddr09_transport()
1719 if (srb->sc_data_direction == DMA_TO_DEVICE || in sddr09_transport()
1720 srb->sc_data_direction == DMA_FROM_DEVICE) { in sddr09_transport()
1721 unsigned int pipe = (srb->sc_data_direction == DMA_TO_DEVICE) in sddr09_transport()
1722 ? us->send_bulk_pipe : us->recv_bulk_pipe; in sddr09_transport()
1724 usb_stor_dbg(us, "%s %d bytes\n", in sddr09_transport()
1725 (srb->sc_data_direction == DMA_TO_DEVICE) ? in sddr09_transport()
1755 (id - sddr09_usb_ids) + sddr09_unusual_dev_list, in sddr09_probe()
1760 if (us->protocol == USB_PR_DPCM_USB) { in sddr09_probe()
1761 us->transport_name = "Control/Bulk-EUSB/SDDR09"; in sddr09_probe()
1762 us->transport = dpcm_transport; in sddr09_probe()
1763 us->transport_reset = usb_stor_CB_reset; in sddr09_probe()
1764 us->max_lun = 1; in sddr09_probe()
1766 us->transport_name = "EUSB/SDDR09"; in sddr09_probe()
1767 us->transport = sddr09_transport; in sddr09_probe()
1768 us->transport_reset = usb_stor_CB_reset; in sddr09_probe()
1769 us->max_lun = 0; in sddr09_probe()
1786 .soft_unbind = 1,
1787 .no_dynamic_id = 1,