1 /* Transport & Protocol Driver for In-System Design, Inc. ISD200 ASIC
3 * $Id: isd200.c,v 1.16 2002/04/22 03:39:43 mdharm Exp $
5 * Current development and maintenance:
6 * (C) 2001-2002 Björn Stenberg (bjorn@haxx.se)
8 * Developed with the assistance of:
9 * (C) 2002 Alan Stern <stern@rowland.org>
12 * (C) 2000 In-System Design, Inc. (support@in-system.com)
14 * The ISD200 ASIC does not natively support ATA devices. The chip
15 * does implement an interface, the ATA Command Block (ATACB) which provides
16 * a means of passing ATA commands and ATA register accesses to a device.
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 2, or (at your option) any
23 * This program is distributed in the hope that it will be useful, but
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * General Public License for more details.
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 * 2002-10-19: Removed the specialized transfer routines.
35 * (Alan Stern <stern@rowland.harvard.edu>)
36 * 2001-02-24: Removed lots of duplicate code and simplified the structure.
38 * 2002-01-16: Fixed endianness bug so it works on the ppc arch.
39 * (Luc Saillard <luc@saillard.org>)
40 * 2002-01-17: All bitfields removed.
47 #include "transport.h"
54 #include <linux/jiffies.h>
55 #include <linux/errno.h>
56 #include <linux/slab.h>
57 #include <linux/hdreg.h>
58 #include <linux/ide.h>
60 /* Timeout defines (in Seconds) */
62 #define ISD200_ENUM_BSY_TIMEOUT 35
63 #define ISD200_ENUM_DETECT_TIMEOUT 30
64 #define ISD200_DEFAULT_TIMEOUT 30
67 #define DF_ATA_DEVICE 0x0001
68 #define DF_MEDIA_STATUS_ENABLED 0x0002
69 #define DF_REMOVABLE_MEDIA 0x0004
71 /* capability bit definitions */
72 #define CAPABILITY_DMA 0x01
73 #define CAPABILITY_LBA 0x02
75 /* command_setX bit definitions */
76 #define COMMANDSET_REMOVABLE 0x02
77 #define COMMANDSET_MEDIA_STATUS 0x10
79 /* ATA Vendor Specific defines */
80 #define ATA_ADDRESS_DEVHEAD_STD 0xa0
81 #define ATA_ADDRESS_DEVHEAD_LBA_MODE 0x40
82 #define ATA_ADDRESS_DEVHEAD_SLAVE 0x10
84 /* Action Select bits */
85 #define ACTION_SELECT_0 0x01
86 #define ACTION_SELECT_1 0x02
87 #define ACTION_SELECT_2 0x04
88 #define ACTION_SELECT_3 0x08
89 #define ACTION_SELECT_4 0x10
90 #define ACTION_SELECT_5 0x20
91 #define ACTION_SELECT_6 0x40
92 #define ACTION_SELECT_7 0x80
94 /* Register Select bits */
95 #define REG_ALTERNATE_STATUS 0x01
96 #define REG_DEVICE_CONTROL 0x01
97 #define REG_ERROR 0x02
98 #define REG_FEATURES 0x02
99 #define REG_SECTOR_COUNT 0x04
100 #define REG_SECTOR_NUMBER 0x08
101 #define REG_CYLINDER_LOW 0x10
102 #define REG_CYLINDER_HIGH 0x20
103 #define REG_DEVICE_HEAD 0x40
104 #define REG_STATUS 0x80
105 #define REG_COMMAND 0x80
107 /* ATA error definitions not in <linux/hdreg.h> */
108 #define ATA_ERROR_MEDIA_CHANGE 0x20
110 /* ATA command definitions not in <linux/hdreg.h> */
111 #define ATA_COMMAND_GET_MEDIA_STATUS 0xDA
112 #define ATA_COMMAND_MEDIA_EJECT 0xED
114 /* ATA drive control definitions */
115 #define ATA_DC_DISABLE_INTERRUPTS 0x02
116 #define ATA_DC_RESET_CONTROLLER 0x04
117 #define ATA_DC_REENABLE_CONTROLLER 0x00
120 * General purpose return codes
123 #define ISD200_ERROR -1
124 #define ISD200_GOOD 0
127 * Transport return codes
130 #define ISD200_TRANSPORT_GOOD 0 /* Transport good, command good */
131 #define ISD200_TRANSPORT_FAILED 1 /* Transport good, command failed */
132 #define ISD200_TRANSPORT_ERROR 2 /* Transport bad (i.e. device dead) */
134 /* driver action codes */
135 #define ACTION_READ_STATUS 0
136 #define ACTION_RESET 1
137 #define ACTION_REENABLE 2
138 #define ACTION_SOFT_RESET 3
139 #define ACTION_ENUM 4
140 #define ACTION_IDENTIFY 5
150 unsigned char SignatureByte0;
151 unsigned char SignatureByte1;
152 unsigned char ActionSelect;
153 unsigned char RegisterSelect;
154 unsigned char TransferBlockSize;
155 unsigned char WriteData3F6;
156 unsigned char WriteData1F1;
157 unsigned char WriteData1F2;
158 unsigned char WriteData1F3;
159 unsigned char WriteData1F4;
160 unsigned char WriteData1F5;
161 unsigned char WriteData1F6;
162 unsigned char WriteData1F7;
163 unsigned char Reserved[3];
167 unsigned char SignatureByte0;
168 unsigned char SignatureByte1;
169 unsigned char ActionSelect;
170 unsigned char RegisterSelect;
171 unsigned char TransferBlockSize;
172 unsigned char AlternateStatusByte;
173 unsigned char ErrorByte;
174 unsigned char SectorCountByte;
175 unsigned char SectorNumberByte;
176 unsigned char CylinderLowByte;
177 unsigned char CylinderHighByte;
178 unsigned char DeviceHeadByte;
179 unsigned char StatusByte;
180 unsigned char Reserved[3];
184 unsigned char SignatureByte0;
185 unsigned char SignatureByte1;
186 unsigned char ActionSelect;
187 unsigned char RegisterSelect;
188 unsigned char TransferBlockSize;
189 unsigned char DeviceControlByte;
190 unsigned char FeaturesByte;
191 unsigned char SectorCountByte;
192 unsigned char SectorNumberByte;
193 unsigned char CylinderLowByte;
194 unsigned char CylinderHighByte;
195 unsigned char DeviceHeadByte;
196 unsigned char CommandByte;
197 unsigned char Reserved[3];
203 * Inquiry data structure. This is the data returned from the target
204 * after it receives an inquiry.
206 * This structure may be extended by the number of bytes specified
207 * in the field AdditionalLength. The defined size constant only
208 * includes fields through ProductRevisionLevel.
214 #define DIRECT_ACCESS_DEVICE 0x00 /* disks */
215 #define DEVICE_REMOVABLE 0x80
217 struct inquiry_data {
218 unsigned char DeviceType;
219 unsigned char DeviceTypeModifier;
220 unsigned char Versions;
221 unsigned char Format;
222 unsigned char AdditionalLength;
223 unsigned char Reserved[2];
224 unsigned char Capability;
225 unsigned char VendorId[8];
226 unsigned char ProductId[16];
227 unsigned char ProductRevisionLevel[4];
228 unsigned char VendorSpecific[20];
229 unsigned char Reserved3[40];
230 } __attribute__ ((packed));
233 * INQUIRY data buffer size
236 #define INQUIRYDATABUFFERSIZE 36
240 * ISD200 CONFIG data struct
243 #define ATACFG_TIMING 0x0f
244 #define ATACFG_ATAPI_RESET 0x10
245 #define ATACFG_MASTER 0x20
246 #define ATACFG_BLOCKSIZE 0xa0
248 #define ATACFGE_LAST_LUN 0x07
249 #define ATACFGE_DESC_OVERRIDE 0x08
250 #define ATACFGE_STATE_SUSPEND 0x10
251 #define ATACFGE_SKIP_BOOT 0x20
252 #define ATACFGE_CONF_DESC2 0x40
253 #define ATACFGE_INIT_STATUS 0x80
255 #define CFG_CAPABILITY_SRST 0x01
257 struct isd200_config {
258 unsigned char EventNotification;
259 unsigned char ExternalClock;
260 unsigned char ATAInitTimeout;
261 unsigned char ATAConfig;
262 unsigned char ATAMajorCommand;
263 unsigned char ATAMinorCommand;
264 unsigned char ATAExtraConfig;
265 unsigned char Capability;
266 }__attribute__ ((packed));
270 * ISD200 driver information struct
274 struct inquiry_data InquiryData;
275 struct hd_driveid *id;
276 struct isd200_config ConfigData;
277 unsigned char *RegsBuf;
278 unsigned char ATARegs[8];
279 unsigned char DeviceHead;
280 unsigned char DeviceFlags;
282 /* maximum number of LUNs supported */
283 unsigned char MaxLUNs;
284 struct scsi_cmnd srb;
289 * Read Capacity Data - returned in Big Endian format
292 struct read_capacity_data {
293 unsigned long LogicalBlockAddress;
294 unsigned long BytesPerBlock;
298 * Read Block Limits Data - returned in Big Endian format
299 * This structure returns the maximum and minimum block
300 * size for a TAPE device.
303 struct read_block_limits {
304 unsigned char Reserved;
305 unsigned char BlockMaximumSize[3];
306 unsigned char BlockMinimumSize[2];
314 #define SENSE_ERRCODE 0x7f
315 #define SENSE_ERRCODE_VALID 0x80
316 #define SENSE_FLAG_SENSE_KEY 0x0f
317 #define SENSE_FLAG_BAD_LENGTH 0x20
318 #define SENSE_FLAG_END_OF_MEDIA 0x40
319 #define SENSE_FLAG_FILE_MARK 0x80
321 unsigned char ErrorCode;
322 unsigned char SegmentNumber;
324 unsigned char Information[4];
325 unsigned char AdditionalSenseLength;
326 unsigned char CommandSpecificInformation[4];
327 unsigned char AdditionalSenseCode;
328 unsigned char AdditionalSenseCodeQualifier;
329 unsigned char FieldReplaceableUnitCode;
330 unsigned char SenseKeySpecific[3];
331 } __attribute__ ((packed));
334 * Default request sense buffer size
337 #define SENSE_BUFFER_SIZE 18
339 /***********************************************************************
341 ***********************************************************************/
343 /**************************************************************************
346 * Builds an artificial sense buffer to report the results of a
352 static void isd200_build_sense(struct us_data *us, Scsi_Cmnd *srb)
354 struct isd200_info *info = (struct isd200_info *)us->extra;
355 struct sense_data *buf = (struct sense_data *) &srb->sense_buffer[0];
356 unsigned char error = info->ATARegs[IDE_ERROR_OFFSET];
358 if(error & ATA_ERROR_MEDIA_CHANGE) {
359 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID;
360 buf->AdditionalSenseLength = 0xb;
361 buf->Flags = UNIT_ATTENTION;
362 buf->AdditionalSenseCode = 0;
363 buf->AdditionalSenseCodeQualifier = 0;
364 } else if(error & MCR_ERR) {
365 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID;
366 buf->AdditionalSenseLength = 0xb;
367 buf->Flags = UNIT_ATTENTION;
368 buf->AdditionalSenseCode = 0;
369 buf->AdditionalSenseCodeQualifier = 0;
370 } else if(error & TRK0_ERR) {
371 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID;
372 buf->AdditionalSenseLength = 0xb;
373 buf->Flags = NOT_READY;
374 buf->AdditionalSenseCode = 0;
375 buf->AdditionalSenseCodeQualifier = 0;
376 } else if(error & ECC_ERR) {
377 buf->ErrorCode = 0x70 | SENSE_ERRCODE_VALID;
378 buf->AdditionalSenseLength = 0xb;
379 buf->Flags = DATA_PROTECT;
380 buf->AdditionalSenseCode = 0;
381 buf->AdditionalSenseCodeQualifier = 0;
384 buf->AdditionalSenseLength = 0;
386 buf->AdditionalSenseCode = 0;
387 buf->AdditionalSenseCodeQualifier = 0;
392 /***********************************************************************
394 ***********************************************************************/
397 /**************************************************************************
400 * Routine for sending commands to the isd200
405 static int isd200_action( struct us_data *us, int action,
406 void* pointer, int value )
409 struct scsi_device srb_dev;
410 struct isd200_info *info = (struct isd200_info *)us->extra;
411 struct scsi_cmnd *srb = &info->srb;
414 memset(&ata, 0, sizeof(ata));
415 memset(&srb_dev, 0, sizeof(srb_dev));
416 srb->device = &srb_dev;
417 ++srb->serial_number;
419 ata.generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
420 ata.generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
421 ata.generic.TransferBlockSize = 1;
424 case ACTION_READ_STATUS:
425 US_DEBUGP(" isd200_action(READ_STATUS)\n");
426 ata.generic.ActionSelect = ACTION_SELECT_0|ACTION_SELECT_2;
427 ata.generic.RegisterSelect =
428 REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
429 REG_STATUS | REG_ERROR;
430 srb->sc_data_direction = SCSI_DATA_READ;
431 srb->request_buffer = pointer;
432 srb->request_bufflen = value;
436 US_DEBUGP(" isd200_action(ENUM,0x%02x)\n",value);
437 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2|
438 ACTION_SELECT_3|ACTION_SELECT_4|
440 ata.generic.RegisterSelect = REG_DEVICE_HEAD;
441 ata.write.DeviceHeadByte = value;
442 srb->sc_data_direction = SCSI_DATA_NONE;
446 US_DEBUGP(" isd200_action(RESET)\n");
447 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2|
448 ACTION_SELECT_3|ACTION_SELECT_4;
449 ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
450 ata.write.DeviceControlByte = ATA_DC_RESET_CONTROLLER;
451 srb->sc_data_direction = SCSI_DATA_NONE;
454 case ACTION_REENABLE:
455 US_DEBUGP(" isd200_action(REENABLE)\n");
456 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_2|
457 ACTION_SELECT_3|ACTION_SELECT_4;
458 ata.generic.RegisterSelect = REG_DEVICE_CONTROL;
459 ata.write.DeviceControlByte = ATA_DC_REENABLE_CONTROLLER;
460 srb->sc_data_direction = SCSI_DATA_NONE;
463 case ACTION_SOFT_RESET:
464 US_DEBUGP(" isd200_action(SOFT_RESET)\n");
465 ata.generic.ActionSelect = ACTION_SELECT_1|ACTION_SELECT_5;
466 ata.generic.RegisterSelect = REG_DEVICE_HEAD | REG_COMMAND;
467 ata.write.DeviceHeadByte = info->DeviceHead;
468 ata.write.CommandByte = WIN_SRST;
469 srb->sc_data_direction = SCSI_DATA_NONE;
472 case ACTION_IDENTIFY:
473 US_DEBUGP(" isd200_action(IDENTIFY)\n");
474 ata.generic.RegisterSelect = REG_COMMAND;
475 ata.write.CommandByte = WIN_IDENTIFY;
476 srb->sc_data_direction = SCSI_DATA_READ;
477 srb->request_buffer = (void *) info->id;
478 srb->request_bufflen = sizeof(struct hd_driveid);
482 US_DEBUGP("Error: Undefined action %d\n",action);
486 memcpy(srb->cmnd, &ata, sizeof(ata.generic));
487 srb->cmd_len = sizeof(ata.generic);
488 status = usb_stor_Bulk_transport(srb, us);
489 if (status == USB_STOR_TRANSPORT_GOOD)
490 status = ISD200_GOOD;
492 US_DEBUGP(" isd200_action(0x%02x) error: %d\n",action,status);
493 status = ISD200_ERROR;
494 /* need to reset device here */
500 /**************************************************************************
508 static int isd200_read_regs( struct us_data *us )
510 struct isd200_info *info = (struct isd200_info *)us->extra;
511 int retStatus = ISD200_GOOD;
514 US_DEBUGP("Entering isd200_IssueATAReadRegs\n");
516 transferStatus = isd200_action( us, ACTION_READ_STATUS,
517 info->RegsBuf, sizeof(info->ATARegs) );
518 if (transferStatus != ISD200_TRANSPORT_GOOD) {
519 US_DEBUGP(" Error reading ATA registers\n");
520 retStatus = ISD200_ERROR;
522 memcpy(info->ATARegs, info->RegsBuf, sizeof(info->ATARegs));
523 US_DEBUGP(" Got ATA Register[IDE_ERROR_OFFSET] = 0x%x\n",
524 info->ATARegs[IDE_ERROR_OFFSET]);
531 /**************************************************************************
532 * Invoke the transport and basic error-handling/recovery methods
534 * This is used by the protocol layers to actually send the message to
535 * the device and receive the response.
537 static void isd200_invoke_transport( struct us_data *us,
539 union ata_cdb *ataCdb )
541 int need_auto_sense = 0;
545 /* send the command to the transport layer */
546 memcpy(srb->cmnd, ataCdb, sizeof(ataCdb->generic));
547 srb->cmd_len = sizeof(ataCdb->generic);
548 transferStatus = usb_stor_Bulk_transport(srb, us);
550 /* if the command gets aborted by the higher layers, we need to
551 * short-circuit all other processing
553 if (us->sm_state == US_STATE_ABORTING) {
554 US_DEBUGP("-- command was aborted\n");
558 switch (transferStatus) {
560 case USB_STOR_TRANSPORT_GOOD:
561 /* Indicate a good result */
562 srb->result = SAM_STAT_GOOD;
565 case USB_STOR_TRANSPORT_NO_SENSE:
566 US_DEBUGP("-- transport indicates protocol failure\n");
567 srb->result = SAM_STAT_CHECK_CONDITION;
570 case USB_STOR_TRANSPORT_FAILED:
571 US_DEBUGP("-- transport indicates command failure\n");
575 case USB_STOR_TRANSPORT_ERROR:
576 US_DEBUGP("-- transport indicates transport error\n");
577 srb->result = DID_ERROR << 16;
578 /* Need reset here */
582 US_DEBUGP("-- transport indicates unknown error\n");
583 srb->result = DID_ERROR << 16;
584 /* Need reset here */
588 if ((srb->resid > 0) &&
589 !((srb->cmnd[0] == REQUEST_SENSE) ||
590 (srb->cmnd[0] == INQUIRY) ||
591 (srb->cmnd[0] == MODE_SENSE) ||
592 (srb->cmnd[0] == LOG_SENSE) ||
593 (srb->cmnd[0] == MODE_SENSE_10))) {
594 US_DEBUGP("-- unexpectedly short transfer\n");
598 if (need_auto_sense) {
599 result = isd200_read_regs(us);
600 if (us->sm_state == US_STATE_ABORTING) {
601 US_DEBUGP("-- auto-sense aborted\n");
604 if (result == ISD200_GOOD) {
605 isd200_build_sense(us, srb);
606 srb->result = SAM_STAT_CHECK_CONDITION;
608 /* If things are really okay, then let's show that */
609 if ((srb->sense_buffer[2] & 0xf) == 0x0)
610 srb->result = SAM_STAT_GOOD;
612 srb->result = DID_ERROR << 16;
613 /* Need reset here */
617 /* Regardless of auto-sense, if we _know_ we have an error
618 * condition, show that in the result code
620 if (transferStatus == USB_STOR_TRANSPORT_FAILED)
621 srb->result = SAM_STAT_CHECK_CONDITION;
624 /* abort processing: the bulk-only transport requires a reset
625 * following an abort */
627 srb->result = DID_ABORT << 16;
629 /* permit the reset transfer to take place */
630 clear_bit(US_FLIDX_ABORTING, &us->flags);
631 /* Need reset here */
634 #ifdef CONFIG_USB_STORAGE_DEBUG
635 static void isd200_log_config( struct isd200_info* info )
637 US_DEBUGP(" Event Notification: 0x%x\n",
638 info->ConfigData.EventNotification);
639 US_DEBUGP(" External Clock: 0x%x\n",
640 info->ConfigData.ExternalClock);
641 US_DEBUGP(" ATA Init Timeout: 0x%x\n",
642 info->ConfigData.ATAInitTimeout);
643 US_DEBUGP(" ATAPI Command Block Size: 0x%x\n",
644 (info->ConfigData.ATAConfig & ATACFG_BLOCKSIZE) >> 6);
645 US_DEBUGP(" Master/Slave Selection: 0x%x\n",
646 info->ConfigData.ATAConfig & ATACFG_MASTER);
647 US_DEBUGP(" ATAPI Reset: 0x%x\n",
648 info->ConfigData.ATAConfig & ATACFG_ATAPI_RESET);
649 US_DEBUGP(" ATA Timing: 0x%x\n",
650 info->ConfigData.ATAConfig & ATACFG_TIMING);
651 US_DEBUGP(" ATA Major Command: 0x%x\n",
652 info->ConfigData.ATAMajorCommand);
653 US_DEBUGP(" ATA Minor Command: 0x%x\n",
654 info->ConfigData.ATAMinorCommand);
655 US_DEBUGP(" Init Status: 0x%x\n",
656 info->ConfigData.ATAExtraConfig & ATACFGE_INIT_STATUS);
657 US_DEBUGP(" Config Descriptor 2: 0x%x\n",
658 info->ConfigData.ATAExtraConfig & ATACFGE_CONF_DESC2);
659 US_DEBUGP(" Skip Device Boot: 0x%x\n",
660 info->ConfigData.ATAExtraConfig & ATACFGE_SKIP_BOOT);
661 US_DEBUGP(" ATA 3 State Supsend: 0x%x\n",
662 info->ConfigData.ATAExtraConfig & ATACFGE_STATE_SUSPEND);
663 US_DEBUGP(" Descriptor Override: 0x%x\n",
664 info->ConfigData.ATAExtraConfig & ATACFGE_DESC_OVERRIDE);
665 US_DEBUGP(" Last LUN Identifier: 0x%x\n",
666 info->ConfigData.ATAExtraConfig & ATACFGE_LAST_LUN);
667 US_DEBUGP(" SRST Enable: 0x%x\n",
668 info->ConfigData.ATAExtraConfig & CFG_CAPABILITY_SRST);
672 /**************************************************************************
673 * isd200_write_config
675 * Write the ISD200 Configuration data
680 static int isd200_write_config( struct us_data *us )
682 struct isd200_info *info = (struct isd200_info *)us->extra;
683 int retStatus = ISD200_GOOD;
686 #ifdef CONFIG_USB_STORAGE_DEBUG
687 US_DEBUGP("Entering isd200_write_config\n");
688 US_DEBUGP(" Writing the following ISD200 Config Data:\n");
689 isd200_log_config(info);
692 /* let's send the command via the control pipe */
693 result = usb_stor_ctrl_transfer(
697 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
700 (void *) &info->ConfigData,
701 sizeof(info->ConfigData));
704 US_DEBUGP(" ISD200 Config Data was written successfully\n");
706 US_DEBUGP(" Request to write ISD200 Config Data failed!\n");
707 retStatus = ISD200_ERROR;
710 US_DEBUGP("Leaving isd200_write_config %08X\n", retStatus);
715 /**************************************************************************
718 * Reads the ISD200 Configuration data
723 static int isd200_read_config( struct us_data *us )
725 struct isd200_info *info = (struct isd200_info *)us->extra;
726 int retStatus = ISD200_GOOD;
729 US_DEBUGP("Entering isd200_read_config\n");
731 /* read the configuration information from ISD200. Use this to */
732 /* determine what the special ATA CDB bytes are. */
734 result = usb_stor_ctrl_transfer(
738 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
741 (void *) &info->ConfigData,
742 sizeof(info->ConfigData));
746 US_DEBUGP(" Retrieved the following ISD200 Config Data:\n");
747 #ifdef CONFIG_USB_STORAGE_DEBUG
748 isd200_log_config(info);
751 US_DEBUGP(" Request to get ISD200 Config Data failed!\n");
752 retStatus = ISD200_ERROR;
755 US_DEBUGP("Leaving isd200_read_config %08X\n", retStatus);
760 /**************************************************************************
761 * isd200_atapi_soft_reset
763 * Perform an Atapi Soft Reset on the device
768 static int isd200_atapi_soft_reset( struct us_data *us )
770 int retStatus = ISD200_GOOD;
773 US_DEBUGP("Entering isd200_atapi_soft_reset\n");
775 transferStatus = isd200_action( us, ACTION_SOFT_RESET, NULL, 0 );
776 if (transferStatus != ISD200_TRANSPORT_GOOD) {
777 US_DEBUGP(" Error issuing Atapi Soft Reset\n");
778 retStatus = ISD200_ERROR;
781 US_DEBUGP("Leaving isd200_atapi_soft_reset %08X\n", retStatus);
786 /**************************************************************************
789 * Perform an SRST on the device
794 static int isd200_srst( struct us_data *us )
796 int retStatus = ISD200_GOOD;
799 US_DEBUGP("Entering isd200_SRST\n");
801 transferStatus = isd200_action( us, ACTION_RESET, NULL, 0 );
803 /* check to see if this request failed */
804 if (transferStatus != ISD200_TRANSPORT_GOOD) {
805 US_DEBUGP(" Error issuing SRST\n");
806 retStatus = ISD200_ERROR;
808 /* delay 10ms to give the drive a chance to see it */
811 transferStatus = isd200_action( us, ACTION_REENABLE, NULL, 0 );
812 if (transferStatus != ISD200_TRANSPORT_GOOD) {
813 US_DEBUGP(" Error taking drive out of reset\n");
814 retStatus = ISD200_ERROR;
816 /* delay 50ms to give the drive a chance to recover after SRST */
821 US_DEBUGP("Leaving isd200_srst %08X\n", retStatus);
826 /**************************************************************************
829 * Helper function for isd200_manual_enum(). Does ENUM and READ_STATUS
830 * and tries to analyze the status registers
835 static int isd200_try_enum(struct us_data *us, unsigned char master_slave,
838 int status = ISD200_GOOD;
839 unsigned long endTime;
840 struct isd200_info *info = (struct isd200_info *)us->extra;
841 unsigned char *regs = info->RegsBuf;
842 int recheckAsMaster = FALSE;
845 endTime = jiffies + ISD200_ENUM_DETECT_TIMEOUT * HZ;
847 endTime = jiffies + ISD200_ENUM_BSY_TIMEOUT * HZ;
849 /* loop until we detect !BSY or timeout */
851 #ifdef CONFIG_USB_STORAGE_DEBUG
852 char* mstr = master_slave == ATA_ADDRESS_DEVHEAD_STD ?
856 status = isd200_action( us, ACTION_ENUM, NULL, master_slave );
857 if ( status != ISD200_GOOD )
860 status = isd200_action( us, ACTION_READ_STATUS,
862 if ( status != ISD200_GOOD )
866 if (regs[IDE_STATUS_OFFSET] & BUSY_STAT ) {
867 US_DEBUGP(" %s status is still BSY, try again...\n",mstr);
869 US_DEBUGP(" %s status !BSY, continue with next operation\n",mstr);
873 /* check for BUSY_STAT and */
874 /* WRERR_STAT (workaround ATA Zip drive) and */
875 /* ERR_STAT (workaround for Archos CD-ROM) */
876 else if (regs[IDE_STATUS_OFFSET] &
877 (BUSY_STAT | WRERR_STAT | ERR_STAT )) {
878 US_DEBUGP(" Status indicates it is not ready, try again...\n");
880 /* check for DRDY, ATA devices set DRDY after SRST */
881 else if (regs[IDE_STATUS_OFFSET] & READY_STAT) {
882 US_DEBUGP(" Identified ATA device\n");
883 info->DeviceFlags |= DF_ATA_DEVICE;
884 info->DeviceHead = master_slave;
887 /* check Cylinder High/Low to
888 determine if it is an ATAPI device
890 else if ((regs[IDE_HCYL_OFFSET] == 0xEB) &&
891 (regs[IDE_LCYL_OFFSET] == 0x14)) {
892 /* It seems that the RICOH
893 MP6200A CD/RW drive will
894 report itself okay as a
895 slave when it is really a
896 master. So this check again
897 as a master device just to
898 make sure it doesn't report
899 itself okay as a master also
901 if ((master_slave & ATA_ADDRESS_DEVHEAD_SLAVE) &&
902 (recheckAsMaster == FALSE)) {
903 US_DEBUGP(" Identified ATAPI device as slave. Rechecking again as master\n");
904 recheckAsMaster = TRUE;
905 master_slave = ATA_ADDRESS_DEVHEAD_STD;
907 US_DEBUGP(" Identified ATAPI device\n");
908 info->DeviceHead = master_slave;
910 status = isd200_atapi_soft_reset(us);
914 US_DEBUGP(" Not ATA, not ATAPI. Weird.\n");
918 /* check for timeout on this request */
919 if (time_after_eq(jiffies, endTime)) {
921 US_DEBUGP(" BSY check timeout, just continue with next operation...\n");
923 US_DEBUGP(" Device detect timeout!\n");
931 /**************************************************************************
934 * Determines if the drive attached is an ATA or ATAPI and if it is a
940 static int isd200_manual_enum(struct us_data *us)
942 struct isd200_info *info = (struct isd200_info *)us->extra;
943 int retStatus = ISD200_GOOD;
945 US_DEBUGP("Entering isd200_manual_enum\n");
947 retStatus = isd200_read_config(us);
948 if (retStatus == ISD200_GOOD) {
950 /* master or slave? */
951 retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, FALSE );
952 if (retStatus == ISD200_GOOD)
953 retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_SLAVE, FALSE );
955 if (retStatus == ISD200_GOOD) {
956 retStatus = isd200_srst(us);
957 if (retStatus == ISD200_GOOD)
959 retStatus = isd200_try_enum( us, ATA_ADDRESS_DEVHEAD_STD, TRUE );
962 isslave = (info->DeviceHead & ATA_ADDRESS_DEVHEAD_SLAVE) ? 1 : 0;
963 if (!(info->ConfigData.ATAConfig & ATACFG_MASTER)) {
964 US_DEBUGP(" Setting Master/Slave selection to %d\n", isslave);
965 info->ConfigData.ATAConfig &= 0x3f;
966 info->ConfigData.ATAConfig |= (isslave<<6);
967 retStatus = isd200_write_config(us);
971 US_DEBUGP("Leaving isd200_manual_enum %08X\n", retStatus);
976 /**************************************************************************
977 * isd200_get_inquiry_data
984 static int isd200_get_inquiry_data( struct us_data *us )
986 struct isd200_info *info = (struct isd200_info *)us->extra;
987 int retStatus = ISD200_GOOD;
988 struct hd_driveid *id = info->id;
990 US_DEBUGP("Entering isd200_get_inquiry_data\n");
992 /* set default to Master */
993 info->DeviceHead = ATA_ADDRESS_DEVHEAD_STD;
995 /* attempt to manually enumerate this device */
996 retStatus = isd200_manual_enum(us);
997 if (retStatus == ISD200_GOOD) {
1000 /* check for an ATA device */
1001 if (info->DeviceFlags & DF_ATA_DEVICE) {
1002 /* this must be an ATA device */
1003 /* perform an ATA Command Identify */
1004 transferStatus = isd200_action( us, ACTION_IDENTIFY,
1006 sizeof(struct hd_driveid) );
1007 if (transferStatus != ISD200_TRANSPORT_GOOD) {
1008 /* Error issuing ATA Command Identify */
1009 US_DEBUGP(" Error issuing ATA Command Identify\n");
1010 retStatus = ISD200_ERROR;
1012 /* ATA Command Identify successful */
1015 ide_fix_driveid(id);
1017 US_DEBUGP(" Identify Data Structure:\n");
1018 US_DEBUGP(" config = 0x%x\n", id->config);
1019 US_DEBUGP(" cyls = 0x%x\n", id->cyls);
1020 US_DEBUGP(" heads = 0x%x\n", id->heads);
1021 US_DEBUGP(" track_bytes = 0x%x\n", id->track_bytes);
1022 US_DEBUGP(" sector_bytes = 0x%x\n", id->sector_bytes);
1023 US_DEBUGP(" sectors = 0x%x\n", id->sectors);
1024 US_DEBUGP(" serial_no[0] = 0x%x\n", id->serial_no[0]);
1025 US_DEBUGP(" buf_type = 0x%x\n", id->buf_type);
1026 US_DEBUGP(" buf_size = 0x%x\n", id->buf_size);
1027 US_DEBUGP(" ecc_bytes = 0x%x\n", id->ecc_bytes);
1028 US_DEBUGP(" fw_rev[0] = 0x%x\n", id->fw_rev[0]);
1029 US_DEBUGP(" model[0] = 0x%x\n", id->model[0]);
1030 US_DEBUGP(" max_multsect = 0x%x\n", id->max_multsect);
1031 US_DEBUGP(" dword_io = 0x%x\n", id->dword_io);
1032 US_DEBUGP(" capability = 0x%x\n", id->capability);
1033 US_DEBUGP(" tPIO = 0x%x\n", id->tPIO);
1034 US_DEBUGP(" tDMA = 0x%x\n", id->tDMA);
1035 US_DEBUGP(" field_valid = 0x%x\n", id->field_valid);
1036 US_DEBUGP(" cur_cyls = 0x%x\n", id->cur_cyls);
1037 US_DEBUGP(" cur_heads = 0x%x\n", id->cur_heads);
1038 US_DEBUGP(" cur_sectors = 0x%x\n", id->cur_sectors);
1039 US_DEBUGP(" cur_capacity = 0x%x\n", (id->cur_capacity1 << 16) + id->cur_capacity0 );
1040 US_DEBUGP(" multsect = 0x%x\n", id->multsect);
1041 US_DEBUGP(" lba_capacity = 0x%x\n", id->lba_capacity);
1042 US_DEBUGP(" command_set_1 = 0x%x\n", id->command_set_1);
1043 US_DEBUGP(" command_set_2 = 0x%x\n", id->command_set_2);
1045 memset(&info->InquiryData, 0, sizeof(info->InquiryData));
1047 /* Standard IDE interface only supports disks */
1048 info->InquiryData.DeviceType = DIRECT_ACCESS_DEVICE;
1050 /* Fix-up the return data from an INQUIRY command to show
1051 * ANSI SCSI rev 2 so we don't confuse the SCSI layers above us
1054 info->InquiryData.Versions = 0x2;
1056 /* The length must be at least 36 (5 + 31) */
1057 info->InquiryData.AdditionalLength = 0x1F;
1059 if (id->command_set_1 & COMMANDSET_MEDIA_STATUS) {
1060 /* set the removable bit */
1061 info->InquiryData.DeviceTypeModifier = DEVICE_REMOVABLE;
1062 info->DeviceFlags |= DF_REMOVABLE_MEDIA;
1065 /* Fill in vendor identification fields */
1066 src = (__u16*)id->model;
1067 dest = (__u16*)info->InquiryData.VendorId;
1069 dest[i] = be16_to_cpu(src[i]);
1071 src = (__u16*)(id->model+8);
1072 dest = (__u16*)info->InquiryData.ProductId;
1074 dest[i] = be16_to_cpu(src[i]);
1076 src = (__u16*)id->fw_rev;
1077 dest = (__u16*)info->InquiryData.ProductRevisionLevel;
1079 dest[i] = be16_to_cpu(src[i]);
1081 /* determine if it supports Media Status Notification */
1082 if (id->command_set_2 & COMMANDSET_MEDIA_STATUS) {
1083 US_DEBUGP(" Device supports Media Status Notification\n");
1085 /* Indicate that it is enabled, even though it is not
1086 * This allows the lock/unlock of the media to work
1089 info->DeviceFlags |= DF_MEDIA_STATUS_ENABLED;
1092 info->DeviceFlags &= ~DF_MEDIA_STATUS_ENABLED;
1097 * this must be an ATAPI device
1098 * use an ATAPI protocol (Transparent SCSI)
1100 us->protocol_name = "Transparent SCSI";
1101 us->proto_handler = usb_stor_transparent_scsi_command;
1103 US_DEBUGP("Protocol changed to: %s\n", us->protocol_name);
1105 /* Free driver structure */
1106 us->extra_destructor(info);
1108 us->extra_destructor = NULL;
1112 US_DEBUGP("Leaving isd200_get_inquiry_data %08X\n", retStatus);
1118 /**************************************************************************
1119 * isd200_scsi_to_ata
1121 * Translate SCSI commands to ATA commands.
1124 * TRUE if the command needs to be sent to the transport layer
1127 static int isd200_scsi_to_ata(Scsi_Cmnd *srb, struct us_data *us,
1128 union ata_cdb * ataCdb)
1130 struct isd200_info *info = (struct isd200_info *)us->extra;
1131 struct hd_driveid *id = info->id;
1132 int sendToTransport = TRUE;
1133 unsigned char sectnum, head;
1134 unsigned short cylinder;
1136 unsigned long blockCount;
1137 unsigned char senseData[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
1139 memset(ataCdb, 0, sizeof(union ata_cdb));
1142 switch (srb->cmnd[0]) {
1144 US_DEBUGP(" ATA OUT - INQUIRY\n");
1146 /* copy InquiryData */
1147 usb_stor_set_xfer_buf((unsigned char *) &info->InquiryData,
1148 sizeof(info->InquiryData), srb);
1149 srb->result = SAM_STAT_GOOD;
1150 sendToTransport = FALSE;
1154 US_DEBUGP(" ATA OUT - SCSIOP_MODE_SENSE\n");
1156 /* Initialize the return buffer */
1157 usb_stor_set_xfer_buf(senseData, sizeof(senseData), srb);
1159 if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED)
1161 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1162 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1163 ataCdb->generic.TransferBlockSize = 1;
1164 ataCdb->generic.RegisterSelect = REG_COMMAND;
1165 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
1166 srb->request_bufflen = 0;
1168 US_DEBUGP(" Media Status not supported, just report okay\n");
1169 srb->result = SAM_STAT_GOOD;
1170 sendToTransport = FALSE;
1174 case TEST_UNIT_READY:
1175 US_DEBUGP(" ATA OUT - SCSIOP_TEST_UNIT_READY\n");
1177 if (info->DeviceFlags & DF_MEDIA_STATUS_ENABLED)
1179 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1180 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1181 ataCdb->generic.TransferBlockSize = 1;
1182 ataCdb->generic.RegisterSelect = REG_COMMAND;
1183 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
1184 srb->request_bufflen = 0;
1186 US_DEBUGP(" Media Status not supported, just report okay\n");
1187 srb->result = SAM_STAT_GOOD;
1188 sendToTransport = FALSE;
1194 unsigned long capacity;
1195 struct read_capacity_data readCapacityData;
1197 US_DEBUGP(" ATA OUT - SCSIOP_READ_CAPACITY\n");
1199 if (id->capability & CAPABILITY_LBA ) {
1200 capacity = id->lba_capacity - 1;
1202 capacity = (id->heads *
1206 readCapacityData.LogicalBlockAddress = cpu_to_be32(capacity);
1207 readCapacityData.BytesPerBlock = cpu_to_be32(0x200);
1209 usb_stor_set_xfer_buf((unsigned char *) &readCapacityData,
1210 sizeof(readCapacityData), srb);
1211 srb->result = SAM_STAT_GOOD;
1212 sendToTransport = FALSE;
1217 US_DEBUGP(" ATA OUT - SCSIOP_READ\n");
1219 lba = *(unsigned long *)&srb->cmnd[2];
1220 lba = cpu_to_be32(lba);
1221 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
1223 if (id->capability & CAPABILITY_LBA) {
1224 sectnum = (unsigned char)(lba);
1225 cylinder = (unsigned short)(lba>>8);
1226 head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F);
1228 sectnum = (unsigned char)((lba % id->sectors) + 1);
1229 cylinder = (unsigned short)(lba / (id->sectors *
1231 head = (unsigned char)((lba / id->sectors) %
1234 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1235 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1236 ataCdb->generic.TransferBlockSize = 1;
1237 ataCdb->generic.RegisterSelect =
1238 REG_SECTOR_COUNT | REG_SECTOR_NUMBER |
1239 REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
1240 REG_DEVICE_HEAD | REG_COMMAND;
1241 ataCdb->write.SectorCountByte = (unsigned char)blockCount;
1242 ataCdb->write.SectorNumberByte = sectnum;
1243 ataCdb->write.CylinderHighByte = (unsigned char)(cylinder>>8);
1244 ataCdb->write.CylinderLowByte = (unsigned char)cylinder;
1245 ataCdb->write.DeviceHeadByte = (head | ATA_ADDRESS_DEVHEAD_STD);
1246 ataCdb->write.CommandByte = WIN_READ;
1250 US_DEBUGP(" ATA OUT - SCSIOP_WRITE\n");
1252 lba = *(unsigned long *)&srb->cmnd[2];
1253 lba = cpu_to_be32(lba);
1254 blockCount = (unsigned long)srb->cmnd[7]<<8 | (unsigned long)srb->cmnd[8];
1256 if (id->capability & CAPABILITY_LBA) {
1257 sectnum = (unsigned char)(lba);
1258 cylinder = (unsigned short)(lba>>8);
1259 head = ATA_ADDRESS_DEVHEAD_LBA_MODE | (unsigned char)(lba>>24 & 0x0F);
1261 sectnum = (unsigned char)((lba % id->sectors) + 1);
1262 cylinder = (unsigned short)(lba / (id->sectors * id->heads));
1263 head = (unsigned char)((lba / id->sectors) % id->heads);
1265 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1266 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1267 ataCdb->generic.TransferBlockSize = 1;
1268 ataCdb->generic.RegisterSelect =
1269 REG_SECTOR_COUNT | REG_SECTOR_NUMBER |
1270 REG_CYLINDER_LOW | REG_CYLINDER_HIGH |
1271 REG_DEVICE_HEAD | REG_COMMAND;
1272 ataCdb->write.SectorCountByte = (unsigned char)blockCount;
1273 ataCdb->write.SectorNumberByte = sectnum;
1274 ataCdb->write.CylinderHighByte = (unsigned char)(cylinder>>8);
1275 ataCdb->write.CylinderLowByte = (unsigned char)cylinder;
1276 ataCdb->write.DeviceHeadByte = (head | ATA_ADDRESS_DEVHEAD_STD);
1277 ataCdb->write.CommandByte = WIN_WRITE;
1280 case ALLOW_MEDIUM_REMOVAL:
1281 US_DEBUGP(" ATA OUT - SCSIOP_MEDIUM_REMOVAL\n");
1283 if (info->DeviceFlags & DF_REMOVABLE_MEDIA) {
1284 US_DEBUGP(" srb->cmnd[4] = 0x%X\n", srb->cmnd[4]);
1286 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1287 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1288 ataCdb->generic.TransferBlockSize = 1;
1289 ataCdb->generic.RegisterSelect = REG_COMMAND;
1290 ataCdb->write.CommandByte = (srb->cmnd[4] & 0x1) ?
1291 WIN_DOORLOCK : WIN_DOORUNLOCK;
1292 srb->request_bufflen = 0;
1294 US_DEBUGP(" Not removeable media, just report okay\n");
1295 srb->result = SAM_STAT_GOOD;
1296 sendToTransport = FALSE;
1301 US_DEBUGP(" ATA OUT - SCSIOP_START_STOP_UNIT\n");
1302 US_DEBUGP(" srb->cmnd[4] = 0x%X\n", srb->cmnd[4]);
1304 if ((srb->cmnd[4] & 0x3) == 0x2) {
1305 US_DEBUGP(" Media Eject\n");
1306 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1307 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1308 ataCdb->generic.TransferBlockSize = 0;
1309 ataCdb->generic.RegisterSelect = REG_COMMAND;
1310 ataCdb->write.CommandByte = ATA_COMMAND_MEDIA_EJECT;
1311 } else if ((srb->cmnd[4] & 0x3) == 0x1) {
1312 US_DEBUGP(" Get Media Status\n");
1313 ataCdb->generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
1314 ataCdb->generic.SignatureByte1 = info->ConfigData.ATAMinorCommand;
1315 ataCdb->generic.TransferBlockSize = 1;
1316 ataCdb->generic.RegisterSelect = REG_COMMAND;
1317 ataCdb->write.CommandByte = ATA_COMMAND_GET_MEDIA_STATUS;
1318 srb->request_bufflen = 0;
1320 US_DEBUGP(" Nothing to do, just report okay\n");
1321 srb->result = SAM_STAT_GOOD;
1322 sendToTransport = FALSE;
1327 US_DEBUGP("Unsupported SCSI command - 0x%X\n", srb->cmnd[0]);
1328 srb->result = DID_ERROR << 16;
1329 sendToTransport = FALSE;
1333 return(sendToTransport);
1337 /**************************************************************************
1340 * Frees the driver structure.
1342 static void isd200_free_info_ptrs(void *info_)
1344 struct isd200_info *info = (struct isd200_info *) info_;
1348 kfree(info->RegsBuf);
1352 /**************************************************************************
1355 * Allocates (if necessary) and initializes the driver structure.
1360 static int isd200_init_info(struct us_data *us)
1362 int retStatus = ISD200_GOOD;
1363 struct isd200_info *info;
1365 info = (struct isd200_info *)
1366 kmalloc(sizeof(struct isd200_info), GFP_KERNEL);
1368 retStatus = ISD200_ERROR;
1370 memset(info, 0, sizeof(struct isd200_info));
1371 info->id = (struct hd_driveid *)
1372 kmalloc(sizeof(struct hd_driveid), GFP_KERNEL);
1373 info->RegsBuf = (unsigned char *)
1374 kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
1375 if (!info->id || !info->RegsBuf) {
1376 isd200_free_info_ptrs(info);
1378 retStatus = ISD200_ERROR;
1380 memset(info->id, 0, sizeof(struct hd_driveid));
1383 if (retStatus == ISD200_GOOD) {
1385 us->extra_destructor = isd200_free_info_ptrs;
1387 US_DEBUGP("ERROR - kmalloc failure\n");
1392 /**************************************************************************
1393 * Initialization for the ISD200
1396 int isd200_Initialization(struct us_data *us)
1398 US_DEBUGP("ISD200 Initialization...\n");
1400 /* Initialize ISD200 info struct */
1402 if (isd200_init_info(us) == ISD200_ERROR) {
1403 US_DEBUGP("ERROR Initializing ISD200 Info struct\n");
1405 /* Get device specific data */
1407 if (isd200_get_inquiry_data(us) != ISD200_GOOD)
1408 US_DEBUGP("ISD200 Initialization Failure\n");
1410 US_DEBUGP("ISD200 Initialization complete\n");
1417 /**************************************************************************
1418 * Protocol and Transport for the ISD200 ASIC
1420 * This protocol and transport are for ATA devices connected to an ISD200
1421 * ASIC. An ATAPI device that is conected as a slave device will be
1422 * detected in the driver initialization function and the protocol will
1423 * be changed to an ATAPI protocol (Transparent SCSI).
1427 void isd200_ata_command(Scsi_Cmnd *srb, struct us_data *us)
1429 int sendToTransport = TRUE;
1430 union ata_cdb ataCdb;
1432 /* Make sure driver was initialized */
1434 if (us->extra == NULL)
1435 US_DEBUGP("ERROR Driver not initialized\n");
1437 /* Convert command */
1439 sendToTransport = isd200_scsi_to_ata(srb, us, &ataCdb);
1441 /* send the command to the transport layer */
1442 if (sendToTransport)
1443 isd200_invoke_transport(us, srb, &ataCdb);