Lines Matching +full:10 +full:us

116 #define MEDIA_PORT(us) us->srb->device->lun  argument
117 #define MEDIA_INFO(us) ((struct alauda_info *)us->extra)->port[MEDIA_PORT(us)] argument
123 static int init_alauda(struct us_data *us);
187 { 0xe6, 23, 9, 4, 10}, /* 8 MB */
188 { 0x73, 24, 9, 5, 10}, /* 16 MB */
189 { 0x75, 25, 9, 5, 10}, /* 32 MB */
190 { 0x76, 26, 9, 5, 10}, /* 64 MB */
191 { 0x79, 27, 9, 5, 10}, /* 128 MB */
192 { 0x71, 28, 9, 5, 10}, /* 256 MB */
197 { 0xd6, 23, 9, 4, 10}, /* 8 MB */
310 static int alauda_get_media_status(struct us_data *us, unsigned char *data) in alauda_get_media_status() argument
315 if (MEDIA_PORT(us) == ALAUDA_PORT_XD) in alauda_get_media_status()
320 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, in alauda_get_media_status()
324 usb_stor_dbg(us, "Media status %02X %02X\n", data[0], data[1]); in alauda_get_media_status()
333 static int alauda_ack_media(struct us_data *us) in alauda_ack_media() argument
337 if (MEDIA_PORT(us) == ALAUDA_PORT_XD) in alauda_ack_media()
342 return usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, in alauda_ack_media()
350 static int alauda_get_media_signature(struct us_data *us, unsigned char *data) in alauda_get_media_signature() argument
354 if (MEDIA_PORT(us) == ALAUDA_PORT_XD) in alauda_get_media_signature()
359 return usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, in alauda_get_media_signature()
366 static int alauda_reset_media(struct us_data *us) in alauda_reset_media() argument
368 unsigned char *command = us->iobuf; in alauda_reset_media()
373 command[8] = MEDIA_PORT(us); in alauda_reset_media()
375 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in alauda_reset_media()
382 static int alauda_init_media(struct us_data *us) in alauda_init_media() argument
384 unsigned char *data = us->iobuf; in alauda_init_media()
392 if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD) in alauda_init_media()
399 usb_stor_dbg(us, "We are ready for action!\n"); in alauda_init_media()
401 if (alauda_ack_media(us) != USB_STOR_XFER_GOOD) in alauda_init_media()
404 msleep(10); in alauda_init_media()
406 if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD) in alauda_init_media()
410 usb_stor_dbg(us, "Media not ready after ack\n"); in alauda_init_media()
414 if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD) in alauda_init_media()
417 usb_stor_dbg(us, "Media signature: %4ph\n", data); in alauda_init_media()
425 MEDIA_INFO(us).capacity = 1 << media_info->chipshift; in alauda_init_media()
426 usb_stor_dbg(us, "Found media with capacity: %ldMB\n", in alauda_init_media()
427 MEDIA_INFO(us).capacity >> 20); in alauda_init_media()
429 MEDIA_INFO(us).pageshift = media_info->pageshift; in alauda_init_media()
430 MEDIA_INFO(us).blockshift = media_info->blockshift; in alauda_init_media()
431 MEDIA_INFO(us).zoneshift = media_info->zoneshift; in alauda_init_media()
433 MEDIA_INFO(us).pagesize = 1 << media_info->pageshift; in alauda_init_media()
434 MEDIA_INFO(us).blocksize = 1 << media_info->blockshift; in alauda_init_media()
435 MEDIA_INFO(us).zonesize = 1 << media_info->zoneshift; in alauda_init_media()
437 MEDIA_INFO(us).uzonesize = ((1 << media_info->zoneshift) / 128) * 125; in alauda_init_media()
438 MEDIA_INFO(us).blockmask = MEDIA_INFO(us).blocksize - 1; in alauda_init_media()
440 num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift in alauda_init_media()
441 + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift); in alauda_init_media()
442 MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); in alauda_init_media()
443 MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); in alauda_init_media()
444 if (MEDIA_INFO(us).pba_to_lba == NULL || MEDIA_INFO(us).lba_to_pba == NULL) in alauda_init_media()
447 if (alauda_reset_media(us) != USB_STOR_XFER_GOOD) in alauda_init_media()
457 static int alauda_check_media(struct us_data *us) in alauda_check_media() argument
459 struct alauda_info *info = (struct alauda_info *) us->extra; in alauda_check_media()
460 unsigned char *status = us->iobuf; in alauda_check_media()
463 rc = alauda_get_media_status(us, status); in alauda_check_media()
472 usb_stor_dbg(us, "No media, or door open\n"); in alauda_check_media()
473 alauda_free_maps(&MEDIA_INFO(us)); in alauda_check_media()
482 usb_stor_dbg(us, "Media change detected\n"); in alauda_check_media()
483 alauda_free_maps(&MEDIA_INFO(us)); in alauda_check_media()
484 rc = alauda_init_media(us); in alauda_check_media()
500 static int alauda_check_status2(struct us_data *us) in alauda_check_status2() argument
505 0, 0, 0, 0, 3, 0, MEDIA_PORT(us) in alauda_check_status2()
509 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in alauda_check_status2()
514 rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in alauda_check_status2()
519 usb_stor_dbg(us, "%3ph\n", data); in alauda_check_status2()
530 static int alauda_get_redu_data(struct us_data *us, u16 pba, unsigned char *data) in alauda_get_redu_data() argument
535 PBA_HI(pba), PBA_ZONE(pba), 0, PBA_LO(pba), 0, 0, MEDIA_PORT(us) in alauda_get_redu_data()
538 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in alauda_get_redu_data()
543 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in alauda_get_redu_data()
568 static int alauda_read_map(struct us_data *us, unsigned int zone) in alauda_read_map() argument
570 unsigned char *data = us->iobuf; in alauda_read_map()
573 unsigned int zonesize = MEDIA_INFO(us).zonesize; in alauda_read_map()
574 unsigned int uzonesize = MEDIA_INFO(us).uzonesize; in alauda_read_map()
585 usb_stor_dbg(us, "Mapping blocks for zone %d\n", zone); in alauda_read_map()
594 result = alauda_get_redu_data(us, blocknum, data); in alauda_read_map()
605 usb_stor_dbg(us, "PBA %d has no logical mapping\n", blocknum); in alauda_read_map()
618 …usb_stor_dbg(us, "PBA %d has no logical mapping: reserved area = %02X%02X%02X%02X data status %02X… in alauda_read_map()
627 usb_stor_dbg(us, "PBA %d has invalid address field %02X%02X/%02X%02X\n", in alauda_read_map()
676 MEDIA_INFO(us).lba_to_pba[zone] = lba_to_pba; in alauda_read_map()
677 MEDIA_INFO(us).pba_to_lba[zone] = pba_to_lba; in alauda_read_map()
692 static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone) in alauda_ensure_map_for_zone() argument
694 if (MEDIA_INFO(us).lba_to_pba[zone] == NULL in alauda_ensure_map_for_zone()
695 || MEDIA_INFO(us).pba_to_lba[zone] == NULL) in alauda_ensure_map_for_zone()
696 alauda_read_map(us, zone); in alauda_ensure_map_for_zone()
702 static int alauda_erase_block(struct us_data *us, u16 pba) in alauda_erase_block() argument
707 PBA_ZONE(pba), 0, PBA_LO(pba), 0x02, 0, MEDIA_PORT(us) in alauda_erase_block()
711 usb_stor_dbg(us, "Erasing PBA %d\n", pba); in alauda_erase_block()
713 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in alauda_erase_block()
718 rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in alauda_erase_block()
723 usb_stor_dbg(us, "Erase result: %02X %02X\n", buf[0], buf[1]); in alauda_erase_block()
731 static int alauda_read_block_raw(struct us_data *us, u16 pba, in alauda_read_block_raw() argument
737 PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us) in alauda_read_block_raw()
740 usb_stor_dbg(us, "pba %d page %d count %d\n", pba, page, pages); in alauda_read_block_raw()
742 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in alauda_read_block_raw()
747 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in alauda_read_block_raw()
748 data, (MEDIA_INFO(us).pagesize + 64) * pages, NULL); in alauda_read_block_raw()
757 static int alauda_read_block(struct us_data *us, u16 pba, in alauda_read_block() argument
761 unsigned int pagesize = MEDIA_INFO(us).pagesize; in alauda_read_block()
763 rc = alauda_read_block_raw(us, pba, page, pages, data); in alauda_read_block()
782 static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data) in alauda_write_block() argument
785 struct alauda_info *info = (struct alauda_info *) us->extra; in alauda_write_block()
788 PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us) in alauda_write_block()
791 usb_stor_dbg(us, "pba %d\n", pba); in alauda_write_block()
793 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in alauda_write_block()
798 rc = usb_stor_bulk_transfer_buf(us, info->wr_ep, data, in alauda_write_block()
799 (MEDIA_INFO(us).pagesize + 64) * MEDIA_INFO(us).blocksize, in alauda_write_block()
804 return alauda_check_status2(us); in alauda_write_block()
810 static int alauda_write_lba(struct us_data *us, u16 lba, in alauda_write_lba() argument
818 unsigned int uzonesize = MEDIA_INFO(us).uzonesize; in alauda_write_lba()
819 unsigned int zonesize = MEDIA_INFO(us).zonesize; in alauda_write_lba()
820 unsigned int pagesize = MEDIA_INFO(us).pagesize; in alauda_write_lba()
821 unsigned int blocksize = MEDIA_INFO(us).blocksize; in alauda_write_lba()
826 alauda_ensure_map_for_zone(us, zone); in alauda_write_lba()
828 pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; in alauda_write_lba()
839 new_pba = alauda_find_unused_pba(&MEDIA_INFO(us), zone); in alauda_write_lba()
848 result = alauda_read_block_raw(us, pba, 0, in alauda_write_lba()
866 usb_stor_dbg(us, "Warning: bad ecc in page %d- of pba %d\n", in alauda_write_lba()
872 usb_stor_dbg(us, "Warning: bad ecc in page %d+ of pba %d\n", in alauda_write_lba()
893 result = alauda_write_block(us, new_pba, blockbuffer); in alauda_write_lba()
898 MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba; in alauda_write_lba()
899 MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba; in alauda_write_lba()
900 usb_stor_dbg(us, "Remapped LBA %d to PBA %d\n", lba, new_pba); in alauda_write_lba()
904 result = alauda_erase_block(us, pba); in alauda_write_lba()
907 MEDIA_INFO(us).pba_to_lba[zone][pba_offset] = UNDEF; in alauda_write_lba()
916 static int alauda_read_data(struct us_data *us, unsigned long address, in alauda_read_data() argument
922 unsigned int blockshift = MEDIA_INFO(us).blockshift; in alauda_read_data()
923 unsigned int pageshift = MEDIA_INFO(us).pageshift; in alauda_read_data()
924 unsigned int blocksize = MEDIA_INFO(us).blocksize; in alauda_read_data()
925 unsigned int pagesize = MEDIA_INFO(us).pagesize; in alauda_read_data()
926 unsigned int uzonesize = MEDIA_INFO(us).uzonesize; in alauda_read_data()
945 page = (address & MEDIA_INFO(us).blockmask); in alauda_read_data()
946 max_lba = MEDIA_INFO(us).capacity >> (blockshift + pageshift); in alauda_read_data()
957 alauda_ensure_map_for_zone(us, zone); in alauda_read_data()
961 usb_stor_dbg(us, "Error: Requested lba %u exceeds maximum %u\n", in alauda_read_data()
972 pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; in alauda_read_data()
975 usb_stor_dbg(us, "Read %d zero pages (LBA %d) page %d\n", in alauda_read_data()
987 usb_stor_dbg(us, "Read %d pages, from PBA %d (LBA %d) page %d\n", in alauda_read_data()
990 result = alauda_read_block(us, pba, page, pages, buffer); in alauda_read_data()
996 usb_stor_access_xfer_buf(buffer, len, us->srb, in alauda_read_data()
1011 static int alauda_write_data(struct us_data *us, unsigned long address, in alauda_write_data() argument
1016 unsigned int blockshift = MEDIA_INFO(us).blockshift; in alauda_write_data()
1017 unsigned int pageshift = MEDIA_INFO(us).pageshift; in alauda_write_data()
1018 unsigned int blocksize = MEDIA_INFO(us).blocksize; in alauda_write_data()
1019 unsigned int pagesize = MEDIA_INFO(us).pagesize; in alauda_write_data()
1047 page = (address & MEDIA_INFO(us).blockmask); in alauda_write_data()
1048 max_lba = MEDIA_INFO(us).capacity >> (pageshift + blockshift); in alauda_write_data()
1061 usb_stor_dbg(us, "Requested lba %u exceeds maximum %u\n", in alauda_write_data()
1068 usb_stor_access_xfer_buf(buffer, len, us->srb, in alauda_write_data()
1071 result = alauda_write_lba(us, lba, page, pages, buffer, in alauda_write_data()
1110 static int init_alauda(struct us_data *us) in init_alauda() argument
1113 struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; in init_alauda()
1116 us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO); in init_alauda()
1117 if (!us->extra) in init_alauda()
1120 info = (struct alauda_info *) us->extra; in init_alauda()
1121 us->extra_destructor = alauda_info_destructor; in init_alauda()
1123 info->wr_ep = usb_sndbulkpipe(us->pusb_dev, in init_alauda()
1130 static int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) in alauda_transport() argument
1133 struct alauda_info *info = (struct alauda_info *) us->extra; in alauda_transport()
1134 unsigned char *ptr = us->iobuf; in alauda_transport()
1140 usb_stor_dbg(us, "INQUIRY - Returning bogus response\n"); in alauda_transport()
1142 fill_inquiry_response(us, ptr, 36); in alauda_transport()
1147 usb_stor_dbg(us, "TEST_UNIT_READY\n"); in alauda_transport()
1148 return alauda_check_media(us); in alauda_transport()
1155 rc = alauda_check_media(us); in alauda_transport()
1159 num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift in alauda_transport()
1160 + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift); in alauda_transport()
1162 capacity = num_zones * MEDIA_INFO(us).uzonesize in alauda_transport()
1163 * MEDIA_INFO(us).blocksize; in alauda_transport()
1176 rc = alauda_check_media(us); in alauda_transport()
1185 usb_stor_dbg(us, "READ_10: page %d pagect %d\n", page, pages); in alauda_transport()
1187 return alauda_read_data(us, page, pages); in alauda_transport()
1193 rc = alauda_check_media(us); in alauda_transport()
1202 usb_stor_dbg(us, "WRITE_10: page %d pagect %d\n", page, pages); in alauda_transport()
1204 return alauda_write_data(us, page, pages); in alauda_transport()
1208 usb_stor_dbg(us, "REQUEST_SENSE\n"); in alauda_transport()
1229 usb_stor_dbg(us, "Gah! Unknown command: %d (0x%x)\n", in alauda_transport()
1242 struct us_data *us; in alauda_probe() local
1245 result = usb_stor_probe1(&us, intf, id, in alauda_probe()
1251 us->transport_name = "Alauda Control/Bulk"; in alauda_probe()
1252 us->transport = alauda_transport; in alauda_probe()
1253 us->transport_reset = usb_stor_Bulk_reset; in alauda_probe()
1254 us->max_lun = 1; in alauda_probe()
1256 result = usb_stor_probe2(us); in alauda_probe()