Lines Matching full:us

58 static int isd200_Initialization(struct us_data *us);
399 static void isd200_build_sense(struct us_data *us, struct scsi_cmnd *srb) in isd200_build_sense() argument
401 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_build_sense()
477 static int isd200_action( struct us_data *us, int action, in isd200_action() argument
483 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_action()
497 usb_stor_dbg(us, " isd200_action(READ_STATUS)\n"); in isd200_action()
506 usb_stor_dbg(us, " isd200_action(ENUM,0x%02x)\n", value); in isd200_action()
516 usb_stor_dbg(us, " isd200_action(RESET)\n"); in isd200_action()
525 usb_stor_dbg(us, " isd200_action(REENABLE)\n"); in isd200_action()
534 usb_stor_dbg(us, " isd200_action(SOFT_RESET)\n"); in isd200_action()
543 usb_stor_dbg(us, " isd200_action(IDENTIFY)\n"); in isd200_action()
551 usb_stor_dbg(us, "Error: Undefined action %d\n", action); in isd200_action()
557 status = usb_stor_Bulk_transport(srb, us); in isd200_action()
561 usb_stor_dbg(us, " isd200_action(0x%02x) error: %d\n", in isd200_action()
578 static int isd200_read_regs( struct us_data *us ) in isd200_read_regs() argument
580 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_read_regs()
584 usb_stor_dbg(us, "Entering isd200_IssueATAReadRegs\n"); in isd200_read_regs()
586 transferStatus = isd200_action( us, ACTION_READ_STATUS, in isd200_read_regs()
589 usb_stor_dbg(us, " Error reading ATA registers\n"); in isd200_read_regs()
593 usb_stor_dbg(us, " Got ATA Register[ATA_REG_ERROR_OFFSET] = 0x%x\n", in isd200_read_regs()
607 static void isd200_invoke_transport( struct us_data *us, in isd200_invoke_transport() argument
618 transferStatus = usb_stor_Bulk_transport(srb, us); in isd200_invoke_transport()
624 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { in isd200_invoke_transport()
625 usb_stor_dbg(us, "-- command was aborted\n"); in isd200_invoke_transport()
637 usb_stor_dbg(us, "-- transport indicates protocol failure\n"); in isd200_invoke_transport()
642 usb_stor_dbg(us, "-- transport indicates command failure\n"); in isd200_invoke_transport()
647 usb_stor_dbg(us, "-- transport indicates transport error\n"); in isd200_invoke_transport()
653 usb_stor_dbg(us, "-- transport indicates unknown error\n"); in isd200_invoke_transport()
665 usb_stor_dbg(us, "-- unexpectedly short transfer\n"); in isd200_invoke_transport()
670 result = isd200_read_regs(us); in isd200_invoke_transport()
671 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { in isd200_invoke_transport()
672 usb_stor_dbg(us, "-- auto-sense aborted\n"); in isd200_invoke_transport()
676 isd200_build_sense(us, srb); in isd200_invoke_transport()
704 clear_bit(US_FLIDX_ABORTING, &us->dflags); in isd200_invoke_transport()
709 static void isd200_log_config(struct us_data *us, struct isd200_info *info) in isd200_log_config() argument
711 usb_stor_dbg(us, " Event Notification: 0x%x\n", in isd200_log_config()
713 usb_stor_dbg(us, " External Clock: 0x%x\n", in isd200_log_config()
715 usb_stor_dbg(us, " ATA Init Timeout: 0x%x\n", in isd200_log_config()
717 usb_stor_dbg(us, " ATAPI Command Block Size: 0x%x\n", in isd200_log_config()
719 usb_stor_dbg(us, " Master/Slave Selection: 0x%x\n", in isd200_log_config()
721 usb_stor_dbg(us, " ATAPI Reset: 0x%x\n", in isd200_log_config()
723 usb_stor_dbg(us, " ATA Timing: 0x%x\n", in isd200_log_config()
725 usb_stor_dbg(us, " ATA Major Command: 0x%x\n", in isd200_log_config()
727 usb_stor_dbg(us, " ATA Minor Command: 0x%x\n", in isd200_log_config()
729 usb_stor_dbg(us, " Init Status: 0x%x\n", in isd200_log_config()
731 usb_stor_dbg(us, " Config Descriptor 2: 0x%x\n", in isd200_log_config()
733 usb_stor_dbg(us, " Skip Device Boot: 0x%x\n", in isd200_log_config()
735 usb_stor_dbg(us, " ATA 3 State Suspend: 0x%x\n", in isd200_log_config()
737 usb_stor_dbg(us, " Descriptor Override: 0x%x\n", in isd200_log_config()
739 usb_stor_dbg(us, " Last LUN Identifier: 0x%x\n", in isd200_log_config()
741 usb_stor_dbg(us, " SRST Enable: 0x%x\n", in isd200_log_config()
754 static int isd200_write_config( struct us_data *us ) in isd200_write_config() argument
756 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_write_config()
761 usb_stor_dbg(us, "Entering isd200_write_config\n"); in isd200_write_config()
762 usb_stor_dbg(us, " Writing the following ISD200 Config Data:\n"); in isd200_write_config()
763 isd200_log_config(us, info); in isd200_write_config()
768 us, in isd200_write_config()
769 us->send_ctrl_pipe, in isd200_write_config()
778 usb_stor_dbg(us, " ISD200 Config Data was written successfully\n"); in isd200_write_config()
780 usb_stor_dbg(us, " Request to write ISD200 Config Data failed!\n"); in isd200_write_config()
784 usb_stor_dbg(us, "Leaving isd200_write_config %08X\n", retStatus); in isd200_write_config()
797 static int isd200_read_config( struct us_data *us ) in isd200_read_config() argument
799 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_read_config()
803 usb_stor_dbg(us, "Entering isd200_read_config\n"); in isd200_read_config()
809 us, in isd200_read_config()
810 us->recv_ctrl_pipe, in isd200_read_config()
820 usb_stor_dbg(us, " Retrieved the following ISD200 Config Data:\n"); in isd200_read_config()
822 isd200_log_config(us, info); in isd200_read_config()
825 usb_stor_dbg(us, " Request to get ISD200 Config Data failed!\n"); in isd200_read_config()
829 usb_stor_dbg(us, "Leaving isd200_read_config %08X\n", retStatus); in isd200_read_config()
842 static int isd200_atapi_soft_reset( struct us_data *us ) in isd200_atapi_soft_reset() argument
847 usb_stor_dbg(us, "Entering isd200_atapi_soft_reset\n"); in isd200_atapi_soft_reset()
849 transferStatus = isd200_action( us, ACTION_SOFT_RESET, NULL, 0 ); in isd200_atapi_soft_reset()
851 usb_stor_dbg(us, " Error issuing Atapi Soft Reset\n"); in isd200_atapi_soft_reset()
855 usb_stor_dbg(us, "Leaving isd200_atapi_soft_reset %08X\n", retStatus); in isd200_atapi_soft_reset()
868 static int isd200_srst( struct us_data *us ) in isd200_srst() argument
873 usb_stor_dbg(us, "Entering isd200_SRST\n"); in isd200_srst()
875 transferStatus = isd200_action( us, ACTION_RESET, NULL, 0 ); in isd200_srst()
879 usb_stor_dbg(us, " Error issuing SRST\n"); in isd200_srst()
885 transferStatus = isd200_action( us, ACTION_REENABLE, NULL, 0 ); in isd200_srst()
887 usb_stor_dbg(us, " Error taking drive out of reset\n"); in isd200_srst()
895 usb_stor_dbg(us, "Leaving isd200_srst %08X\n", retStatus); in isd200_srst()
909 static int isd200_try_enum(struct us_data *us, unsigned char master_slave, in isd200_try_enum() argument
914 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_try_enum()
926 status = isd200_action( us, ACTION_ENUM, NULL, master_slave ); in isd200_try_enum()
930 status = isd200_action( us, ACTION_READ_STATUS, in isd200_try_enum()
937 usb_stor_dbg(us, " %s status is still BSY, try again...\n", in isd200_try_enum()
941 usb_stor_dbg(us, " %s status !BSY, continue with next operation\n", in isd200_try_enum()
952 usb_stor_dbg(us, " Status indicates it is not ready, try again...\n"); in isd200_try_enum()
956 usb_stor_dbg(us, " Identified ATA device\n"); in isd200_try_enum()
979 usb_stor_dbg(us, " Identified ATAPI device as slave. Rechecking again as master\n"); in isd200_try_enum()
983 usb_stor_dbg(us, " Identified ATAPI device\n"); in isd200_try_enum()
986 status = isd200_atapi_soft_reset(us); in isd200_try_enum()
990 usb_stor_dbg(us, " Not ATA, not ATAPI - Weird\n"); in isd200_try_enum()
997 usb_stor_dbg(us, " BSY check timeout, just continue with next operation...\n"); in isd200_try_enum()
999 usb_stor_dbg(us, " Device detect timeout!\n"); in isd200_try_enum()
1016 static int isd200_manual_enum(struct us_data *us) in isd200_manual_enum() argument
1018 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_manual_enum()
1021 usb_stor_dbg(us, "Entering isd200_manual_enum\n"); in isd200_manual_enum()
1023 retStatus = isd200_read_config(us); in isd200_manual_enum()
1027 retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, 0); in isd200_manual_enum()
1029 retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_SLAVE, 0); in isd200_manual_enum()
1032 retStatus = isd200_srst(us); in isd200_manual_enum()
1035 retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, 1); in isd200_manual_enum()
1040 usb_stor_dbg(us, " Setting Master/Slave selection to %d\n", in isd200_manual_enum()
1044 retStatus = isd200_write_config(us); in isd200_manual_enum()
1048 usb_stor_dbg(us, "Leaving isd200_manual_enum %08X\n", retStatus); in isd200_manual_enum()
1066 static void isd200_dump_driveid(struct us_data *us, u16 *id) in isd200_dump_driveid() argument
1068 usb_stor_dbg(us, " Identify Data Structure:\n"); in isd200_dump_driveid()
1069 usb_stor_dbg(us, " config = 0x%x\n", id[ATA_ID_CONFIG]); in isd200_dump_driveid()
1070 usb_stor_dbg(us, " cyls = 0x%x\n", id[ATA_ID_CYLS]); in isd200_dump_driveid()
1071 usb_stor_dbg(us, " heads = 0x%x\n", id[ATA_ID_HEADS]); in isd200_dump_driveid()
1072 usb_stor_dbg(us, " track_bytes = 0x%x\n", id[4]); in isd200_dump_driveid()
1073 usb_stor_dbg(us, " sector_bytes = 0x%x\n", id[5]); in isd200_dump_driveid()
1074 usb_stor_dbg(us, " sectors = 0x%x\n", id[ATA_ID_SECTORS]); in isd200_dump_driveid()
1075 usb_stor_dbg(us, " serial_no[0] = 0x%x\n", *(char *)&id[ATA_ID_SERNO]); in isd200_dump_driveid()
1076 usb_stor_dbg(us, " buf_type = 0x%x\n", id[20]); in isd200_dump_driveid()
1077 usb_stor_dbg(us, " buf_size = 0x%x\n", id[ATA_ID_BUF_SIZE]); in isd200_dump_driveid()
1078 usb_stor_dbg(us, " ecc_bytes = 0x%x\n", id[22]); in isd200_dump_driveid()
1079 usb_stor_dbg(us, " fw_rev[0] = 0x%x\n", *(char *)&id[ATA_ID_FW_REV]); in isd200_dump_driveid()
1080 usb_stor_dbg(us, " model[0] = 0x%x\n", *(char *)&id[ATA_ID_PROD]); in isd200_dump_driveid()
1081 usb_stor_dbg(us, " max_multsect = 0x%x\n", id[ATA_ID_MAX_MULTSECT] & 0xff); in isd200_dump_driveid()
1082 usb_stor_dbg(us, " dword_io = 0x%x\n", id[ATA_ID_DWORD_IO]); in isd200_dump_driveid()
1083 usb_stor_dbg(us, " capability = 0x%x\n", id[ATA_ID_CAPABILITY] >> 8); in isd200_dump_driveid()
1084 usb_stor_dbg(us, " tPIO = 0x%x\n", id[ATA_ID_OLD_PIO_MODES] >> 8); in isd200_dump_driveid()
1085 usb_stor_dbg(us, " tDMA = 0x%x\n", id[ATA_ID_OLD_DMA_MODES] >> 8); in isd200_dump_driveid()
1086 usb_stor_dbg(us, " field_valid = 0x%x\n", id[ATA_ID_FIELD_VALID]); in isd200_dump_driveid()
1087 usb_stor_dbg(us, " cur_cyls = 0x%x\n", id[ATA_ID_CUR_CYLS]); in isd200_dump_driveid()
1088 usb_stor_dbg(us, " cur_heads = 0x%x\n", id[ATA_ID_CUR_HEADS]); in isd200_dump_driveid()
1089 usb_stor_dbg(us, " cur_sectors = 0x%x\n", id[ATA_ID_CUR_SECTORS]); in isd200_dump_driveid()
1090 usb_stor_dbg(us, " cur_capacity = 0x%x\n", ata_id_u32(id, 57)); in isd200_dump_driveid()
1091 usb_stor_dbg(us, " multsect = 0x%x\n", id[ATA_ID_MULTSECT] & 0xff); in isd200_dump_driveid()
1092 usb_stor_dbg(us, " lba_capacity = 0x%x\n", ata_id_u32(id, ATA_ID_LBA_CAPACITY)); in isd200_dump_driveid()
1093 usb_stor_dbg(us, " command_set_1 = 0x%x\n", id[ATA_ID_COMMAND_SET_1]); in isd200_dump_driveid()
1094 usb_stor_dbg(us, " command_set_2 = 0x%x\n", id[ATA_ID_COMMAND_SET_2]); in isd200_dump_driveid()
1105 static int isd200_get_inquiry_data( struct us_data *us ) in isd200_get_inquiry_data() argument
1107 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_get_inquiry_data()
1111 usb_stor_dbg(us, "Entering isd200_get_inquiry_data\n"); in isd200_get_inquiry_data()
1117 retStatus = isd200_manual_enum(us); in isd200_get_inquiry_data()
1125 transferStatus = isd200_action( us, ACTION_IDENTIFY, in isd200_get_inquiry_data()
1129 usb_stor_dbg(us, " Error issuing ATA Command Identify\n"); in isd200_get_inquiry_data()
1138 isd200_dump_driveid(us, id); in isd200_get_inquiry_data()
1172 usb_stor_dbg(us, " Device supports Media Status Notification\n"); in isd200_get_inquiry_data()
1191 us->protocol_name = "Transparent SCSI"; in isd200_get_inquiry_data()
1192 us->proto_handler = usb_stor_transparent_scsi_command; in isd200_get_inquiry_data()
1194 usb_stor_dbg(us, "Protocol changed to: %s\n", in isd200_get_inquiry_data()
1195 us->protocol_name); in isd200_get_inquiry_data()
1198 us->extra_destructor(info); in isd200_get_inquiry_data()
1200 us->extra = NULL; in isd200_get_inquiry_data()
1201 us->extra_destructor = NULL; in isd200_get_inquiry_data()
1205 usb_stor_dbg(us, "Leaving isd200_get_inquiry_data %08X\n", retStatus); in isd200_get_inquiry_data()
1219 static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us, in isd200_scsi_to_ata() argument
1222 struct isd200_info *info = (struct isd200_info *)us->extra; in isd200_scsi_to_ata()
1236 usb_stor_dbg(us, " ATA OUT - INQUIRY\n"); in isd200_scsi_to_ata()
1246 usb_stor_dbg(us, " ATA OUT - SCSIOP_MODE_SENSE\n"); in isd200_scsi_to_ata()
1260 usb_stor_dbg(us, " Media Status not supported, just report okay\n"); in isd200_scsi_to_ata()
1267 usb_stor_dbg(us, " ATA OUT - SCSIOP_TEST_UNIT_READY\n"); in isd200_scsi_to_ata()
1278 usb_stor_dbg(us, " Media Status not supported, just report okay\n"); in isd200_scsi_to_ata()
1289 usb_stor_dbg(us, " ATA OUT - SCSIOP_READ_CAPACITY\n"); in isd200_scsi_to_ata()
1308 usb_stor_dbg(us, " ATA OUT - SCSIOP_READ\n"); in isd200_scsi_to_ata()
1340 usb_stor_dbg(us, " ATA OUT - SCSIOP_WRITE\n"); in isd200_scsi_to_ata()
1372 usb_stor_dbg(us, " ATA OUT - SCSIOP_MEDIUM_REMOVAL\n"); in isd200_scsi_to_ata()
1375 usb_stor_dbg(us, " srb->cmnd[4] = 0x%X\n", in isd200_scsi_to_ata()
1386 usb_stor_dbg(us, " Not removable media, just report okay\n"); in isd200_scsi_to_ata()
1393 usb_stor_dbg(us, " ATA OUT - SCSIOP_START_STOP_UNIT\n"); in isd200_scsi_to_ata()
1394 usb_stor_dbg(us, " srb->cmnd[4] = 0x%X\n", srb->cmnd[4]); in isd200_scsi_to_ata()
1397 usb_stor_dbg(us, " Media Eject\n"); in isd200_scsi_to_ata()
1404 usb_stor_dbg(us, " Get Media Status\n"); in isd200_scsi_to_ata()
1412 usb_stor_dbg(us, " Nothing to do, just report okay\n"); in isd200_scsi_to_ata()
1419 usb_stor_dbg(us, "Unsupported SCSI command - 0x%X\n", in isd200_scsi_to_ata()
1454 static int isd200_init_info(struct us_data *us) in isd200_init_info() argument
1472 us->extra = info; in isd200_init_info()
1473 us->extra_destructor = isd200_free_info_ptrs; in isd200_init_info()
1482 static int isd200_Initialization(struct us_data *us) in isd200_Initialization() argument
1484 usb_stor_dbg(us, "ISD200 Initialization...\n"); in isd200_Initialization()
1488 if (isd200_init_info(us) == ISD200_ERROR) { in isd200_Initialization()
1489 usb_stor_dbg(us, "ERROR Initializing ISD200 Info struct\n"); in isd200_Initialization()
1493 if (isd200_get_inquiry_data(us) != ISD200_GOOD) in isd200_Initialization()
1494 usb_stor_dbg(us, "ISD200 Initialization Failure\n"); in isd200_Initialization()
1496 usb_stor_dbg(us, "ISD200 Initialization complete\n"); in isd200_Initialization()
1513 static void isd200_ata_command(struct scsi_cmnd *srb, struct us_data *us) in isd200_ata_command() argument
1520 if (us->extra == NULL) { in isd200_ata_command()
1521 usb_stor_dbg(us, "ERROR Driver not initialized\n"); in isd200_ata_command()
1529 sendToTransport = isd200_scsi_to_ata(srb, us, &ataCdb); in isd200_ata_command()
1533 isd200_invoke_transport(us, srb, &ataCdb); in isd200_ata_command()
1543 struct us_data *us; in isd200_probe() local
1546 result = usb_stor_probe1(&us, intf, id, in isd200_probe()
1552 us->protocol_name = "ISD200 ATA/ATAPI"; in isd200_probe()
1553 us->proto_handler = isd200_ata_command; in isd200_probe()
1555 result = usb_stor_probe2(us); in isd200_probe()