1 /* Driver for Realtek RTS51xx USB card reader
3 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2, or (at your option) any
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, see <http://www.gnu.org/licenses/>.
19 * wwang (wei_wang@realsil.com.cn)
20 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
22 * Edwin Rong (edwin_rong@realsil.com.cn)
23 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
26 #include <linux/blkdev.h>
27 #include <linux/kthread.h>
28 #include <linux/sched.h>
29 #include <linux/slab.h>
30 #include <linux/vmalloc.h>
31 #include <linux/export.h>
33 #include <scsi/scsi.h>
34 #include <scsi/scsi_eh.h>
35 #include <scsi/scsi_device.h>
39 #include "rts51x_chip.h"
40 #include "rts51x_scsi.h"
41 #include "rts51x_card.h"
42 #include "rts51x_transport.h"
43 #include "rts51x_sys.h"
48 void scsi_show_command(struct scsi_cmnd
*srb
)
51 int i
, unknown_cmd
= 0;
53 switch (srb
->cmnd
[0]) {
55 what
= (char *)"TEST_UNIT_READY";
58 what
= (char *)"REZERO_UNIT";
61 what
= (char *)"REQUEST_SENSE";
64 what
= (char *)"FORMAT_UNIT";
66 case READ_BLOCK_LIMITS
:
67 what
= (char *)"READ_BLOCK_LIMITS";
70 what
= (char *)"REASSIGN_BLOCKS";
73 what
= (char *)"READ_6";
76 what
= (char *)"WRITE_6";
79 what
= (char *)"SEEK_6";
82 what
= (char *)"READ_REVERSE";
85 what
= (char *)"WRITE_FILEMARKS";
88 what
= (char *)"SPACE";
91 what
= (char *)"INQUIRY";
93 case RECOVER_BUFFERED_DATA
:
94 what
= (char *)"RECOVER_BUFFERED_DATA";
97 what
= (char *)"MODE_SELECT";
100 what
= (char *)"RESERVE";
103 what
= (char *)"RELEASE";
106 what
= (char *)"COPY";
109 what
= (char *)"ERASE";
112 what
= (char *)"MODE_SENSE";
115 what
= (char *)"START_STOP";
117 case RECEIVE_DIAGNOSTIC
:
118 what
= (char *)"RECEIVE_DIAGNOSTIC";
120 case SEND_DIAGNOSTIC
:
121 what
= (char *)"SEND_DIAGNOSTIC";
123 case ALLOW_MEDIUM_REMOVAL
:
124 what
= (char *)"ALLOW_MEDIUM_REMOVAL";
127 what
= (char *)"SET_WINDOW";
130 what
= (char *)"READ_CAPACITY";
133 what
= (char *)"READ_10";
136 what
= (char *)"WRITE_10";
139 what
= (char *)"SEEK_10";
142 what
= (char *)"WRITE_VERIFY";
145 what
= (char *)"VERIFY";
148 what
= (char *)"SEARCH_HIGH";
151 what
= (char *)"SEARCH_EQUAL";
154 what
= (char *)"SEARCH_LOW";
157 what
= (char *)"SET_LIMITS";
160 what
= (char *)"READ_POSITION";
162 case SYNCHRONIZE_CACHE
:
163 what
= (char *)"SYNCHRONIZE_CACHE";
165 case LOCK_UNLOCK_CACHE
:
166 what
= (char *)"LOCK_UNLOCK_CACHE";
168 case READ_DEFECT_DATA
:
169 what
= (char *)"READ_DEFECT_DATA";
172 what
= (char *)"MEDIUM_SCAN";
175 what
= (char *)"COMPARE";
178 what
= (char *)"COPY_VERIFY";
181 what
= (char *)"WRITE_BUFFER";
184 what
= (char *)"READ_BUFFER";
187 what
= (char *)"UPDATE_BLOCK";
190 what
= (char *)"READ_LONG";
193 what
= (char *)"WRITE_LONG";
195 case CHANGE_DEFINITION
:
196 what
= (char *)"CHANGE_DEFINITION";
199 what
= (char *)"WRITE_SAME";
201 case GPCMD_READ_SUBCHANNEL
:
202 what
= (char *)"READ SUBCHANNEL";
205 what
= (char *)"READ_TOC";
207 case GPCMD_READ_HEADER
:
208 what
= (char *)"READ HEADER";
210 case GPCMD_PLAY_AUDIO_10
:
211 what
= (char *)"PLAY AUDIO (10)";
213 case GPCMD_PLAY_AUDIO_MSF
:
214 what
= (char *)"PLAY AUDIO MSF";
216 case GPCMD_GET_EVENT_STATUS_NOTIFICATION
:
217 what
= (char *)"GET EVENT/STATUS NOTIFICATION";
219 case GPCMD_PAUSE_RESUME
:
220 what
= (char *)"PAUSE/RESUME";
223 what
= (char *)"LOG_SELECT";
226 what
= (char *)"LOG_SENSE";
228 case GPCMD_STOP_PLAY_SCAN
:
229 what
= (char *)"STOP PLAY/SCAN";
231 case GPCMD_READ_DISC_INFO
:
232 what
= (char *)"READ DISC INFORMATION";
234 case GPCMD_READ_TRACK_RZONE_INFO
:
235 what
= (char *)"READ TRACK INFORMATION";
237 case GPCMD_RESERVE_RZONE_TRACK
:
238 what
= (char *)"RESERVE TRACK";
241 what
= (char *)"SEND OPC";
244 what
= (char *)"MODE_SELECT_10";
246 case GPCMD_REPAIR_RZONE_TRACK
:
247 what
= (char *)"REPAIR TRACK";
250 what
= (char *)"READ MASTER CUE";
253 what
= (char *)"MODE_SENSE_10";
255 case GPCMD_CLOSE_TRACK
:
256 what
= (char *)"CLOSE TRACK/SESSION";
259 what
= (char *)"READ BUFFER CAPACITY";
262 what
= (char *)"SEND CUE SHEET";
265 what
= (char *)"BLANK";
268 what
= (char *)"REPORT LUNS";
271 what
= (char *)"MOVE_MEDIUM or PLAY AUDIO (12)";
274 what
= (char *)"READ_12";
277 what
= (char *)"WRITE_12";
279 case WRITE_VERIFY_12
:
280 what
= (char *)"WRITE_VERIFY_12";
283 what
= (char *)"SEARCH_HIGH_12";
285 case SEARCH_EQUAL_12
:
286 what
= (char *)"SEARCH_EQUAL_12";
289 what
= (char *)"SEARCH_LOW_12";
291 case SEND_VOLUME_TAG
:
292 what
= (char *)"SEND_VOLUME_TAG";
294 case READ_ELEMENT_STATUS
:
295 what
= (char *)"READ_ELEMENT_STATUS";
297 case GPCMD_READ_CD_MSF
:
298 what
= (char *)"READ CD MSF";
301 what
= (char *)"SCAN";
303 case GPCMD_SET_SPEED
:
304 what
= (char *)"SET CD SPEED";
306 case GPCMD_MECHANISM_STATUS
:
307 what
= (char *)"MECHANISM STATUS";
310 what
= (char *)"READ CD";
313 what
= (char *)"WRITE CONTINUE";
316 what
= (char *)"WRITE_LONG_2";
319 what
= (char *)"Realtek's vendor command";
322 what
= (char *)"(unknown command)";
327 if (srb
->cmnd
[0] != TEST_UNIT_READY
)
328 RTS51X_DEBUGP("Command %s (%d bytes)\n", what
, srb
->cmd_len
);
331 for (i
= 0; i
< srb
->cmd_len
&& i
< 16; i
++)
332 RTS51X_DEBUGPN(" %02x", srb
->cmnd
[i
]);
333 RTS51X_DEBUGPN("\n");
337 void set_sense_type(struct rts51x_chip
*chip
, unsigned int lun
, int sense_type
)
339 switch (sense_type
) {
340 case SENSE_TYPE_MEDIA_CHANGE
:
341 set_sense_data(chip
, lun
, CUR_ERR
, 0x06, 0, 0x28, 0, 0, 0);
344 case SENSE_TYPE_MEDIA_NOT_PRESENT
:
345 set_sense_data(chip
, lun
, CUR_ERR
, 0x02, 0, 0x3A, 0, 0, 0);
348 case SENSE_TYPE_MEDIA_LBA_OVER_RANGE
:
349 set_sense_data(chip
, lun
, CUR_ERR
, 0x05, 0, 0x21, 0, 0, 0);
352 case SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
:
353 set_sense_data(chip
, lun
, CUR_ERR
, 0x05, 0, 0x25, 0, 0, 0);
356 case SENSE_TYPE_MEDIA_WRITE_PROTECT
:
357 set_sense_data(chip
, lun
, CUR_ERR
, 0x07, 0, 0x27, 0, 0, 0);
360 case SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
:
361 set_sense_data(chip
, lun
, CUR_ERR
, 0x03, 0, 0x11, 0, 0, 0);
364 case SENSE_TYPE_MEDIA_WRITE_ERR
:
365 set_sense_data(chip
, lun
, CUR_ERR
, 0x03, 0, 0x0C, 0x02, 0, 0);
368 case SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
:
369 set_sense_data(chip
, lun
, CUR_ERR
, ILGAL_REQ
, 0,
370 ASC_INVLD_CDB
, ASCQ_INVLD_CDB
, CDB_ILLEGAL
, 1);
373 case SENSE_TYPE_FORMAT_IN_PROGRESS
:
374 set_sense_data(chip
, lun
, CUR_ERR
, 0x02, 0, 0x04, 0x04, 0, 0);
377 case SENSE_TYPE_FORMAT_CMD_FAILED
:
378 set_sense_data(chip
, lun
, CUR_ERR
, 0x03, 0, 0x31, 0x01, 0, 0);
381 #ifdef SUPPORT_MAGIC_GATE
382 case SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB
:
383 set_sense_data(chip
, lun
, CUR_ERR
, 0x05, 0, 0x6F, 0x02, 0, 0);
386 case SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN
:
387 set_sense_data(chip
, lun
, CUR_ERR
, 0x05, 0, 0x6F, 0x00, 0, 0);
390 case SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM
:
391 set_sense_data(chip
, lun
, CUR_ERR
, 0x02, 0, 0x30, 0x00, 0, 0);
394 case SENSE_TYPE_MG_WRITE_ERR
:
395 set_sense_data(chip
, lun
, CUR_ERR
, 0x03, 0, 0x0C, 0x00, 0, 0);
399 #ifdef SUPPORT_SD_LOCK
400 case SENSE_TYPE_MEDIA_READ_FORBIDDEN
:
401 set_sense_data(chip
, lun
, CUR_ERR
, 0x07, 0, 0x11, 0x13, 0, 0);
405 case SENSE_TYPE_NO_SENSE
:
407 set_sense_data(chip
, lun
, CUR_ERR
, 0, 0, 0, 0, 0, 0);
412 void set_sense_data(struct rts51x_chip
*chip
, unsigned int lun
, u8 err_code
,
413 u8 sense_key
, u32 info
, u8 asc
, u8 ascq
, u8 sns_key_info0
,
416 struct sense_data_t
*sense
= &(chip
->sense_buffer
[lun
]);
418 sense
->err_code
= err_code
;
419 sense
->sense_key
= sense_key
;
420 sense
->info
[0] = (u8
) (info
>> 24);
421 sense
->info
[1] = (u8
) (info
>> 16);
422 sense
->info
[2] = (u8
) (info
>> 8);
423 sense
->info
[3] = (u8
) info
;
425 sense
->ad_sense_len
= sizeof(struct sense_data_t
) - 8;
428 if (sns_key_info0
!= 0) {
429 sense
->sns_key_info
[0] = SKSV
| sns_key_info0
;
430 sense
->sns_key_info
[1] = (sns_key_info1
& 0xf0) >> 8;
431 sense
->sns_key_info
[2] = sns_key_info1
& 0x0f;
435 static int test_unit_ready(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
437 unsigned int lun
= SCSI_LUN(srb
);
439 rts51x_init_cards(chip
);
441 if (!check_card_ready(chip
, lun
)) {
442 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
443 return TRANSPORT_FAILED
;
446 if (!check_lun_mc(chip
, lun
)) {
447 set_lun_mc(chip
, lun
);
448 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_CHANGE
);
449 return TRANSPORT_FAILED
;
451 #ifdef SUPPORT_SD_LOCK
452 if (get_lun_card(chip
, SCSI_LUN(srb
)) == SD_CARD
) {
453 struct sd_info
*sd_card
= &(chip
->sd_card
);
454 if (sd_card
->sd_lock_notify
) {
455 sd_card
->sd_lock_notify
= 0;
456 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_CHANGE
);
457 return TRANSPORT_FAILED
;
458 } else if (sd_card
->sd_lock_status
& SD_LOCKED
) {
459 set_sense_type(chip
, lun
,
460 SENSE_TYPE_MEDIA_READ_FORBIDDEN
);
461 return TRANSPORT_FAILED
;
466 return TRANSPORT_GOOD
;
469 unsigned char formatter_inquiry_str
[20] = {
470 'M', 'E', 'M', 'O', 'R', 'Y', 'S', 'T', 'I', 'C', 'K',
471 '-', 'M', 'G', /* Byte[47:49] */
472 0x0B, /* Byte[50]: MG, MS, MSPro, MSXC */
473 0x00, /* Byte[51]: Category Specific Commands */
474 0x00, /* Byte[52]: Access Control and feature */
475 0x20, 0x20, 0x20, /* Byte[53:55] */
478 static int inquiry(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
480 unsigned int lun
= SCSI_LUN(srb
);
481 char *inquiry_default
= (char *)"Generic-xD/SD/M.S. 1.00 ";
482 char *inquiry_string
;
483 unsigned char sendbytes
;
485 u8 card
= get_lun_card(chip
, lun
);
486 int pro_formatter_flag
= 0;
487 unsigned char inquiry_buf
[] = {
488 QULIFIRE
| DRCT_ACCESS_DEV
,
495 REL_ADR
| WBUS_32
| WBUS_16
| SYNC
| LINKED
| CMD_QUE
| SFT_RE
,
498 inquiry_string
= inquiry_default
;
500 buf
= vmalloc(scsi_bufflen(srb
));
502 TRACE_RET(chip
, TRANSPORT_ERROR
);
504 if (MS_FORMATTER_ENABLED(chip
) && (get_lun2card(chip
, lun
) & MS_CARD
)) {
505 if (!card
|| (card
== MS_CARD
))
506 pro_formatter_flag
= 1;
509 if (pro_formatter_flag
) {
510 if (scsi_bufflen(srb
) < 56)
511 sendbytes
= (unsigned char)(scsi_bufflen(srb
));
515 if (scsi_bufflen(srb
) < 36)
516 sendbytes
= (unsigned char)(scsi_bufflen(srb
));
522 memcpy(buf
, inquiry_buf
, 8);
523 memcpy(buf
+ 8, inquiry_string
, sendbytes
- 8);
524 if (pro_formatter_flag
)
525 buf
[4] = 0x33; /* Additional Length */
527 memcpy(buf
, inquiry_buf
, sendbytes
);
530 if (pro_formatter_flag
) {
532 memcpy(buf
+ 36, formatter_inquiry_str
, sendbytes
- 36);
535 scsi_set_resid(srb
, 0);
537 rts51x_set_xfer_buf(buf
, scsi_bufflen(srb
), srb
);
540 return TRANSPORT_GOOD
;
543 static int start_stop_unit(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
545 unsigned int lun
= SCSI_LUN(srb
);
547 scsi_set_resid(srb
, scsi_bufflen(srb
));
549 if (srb
->cmnd
[1] == 1)
550 return TRANSPORT_GOOD
;
552 switch (srb
->cmnd
[0x4]) {
555 return TRANSPORT_GOOD
;
558 /* Media shall be unload */
559 if (check_card_ready(chip
, lun
))
560 eject_card(chip
, lun
);
561 return TRANSPORT_GOOD
;
563 case MAKE_MEDIUM_READY
:
565 if (check_card_ready(chip
, lun
)) {
566 return TRANSPORT_GOOD
;
568 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
569 TRACE_RET(chip
, TRANSPORT_FAILED
);
575 TRACE_RET(chip
, TRANSPORT_ERROR
);
578 static int allow_medium_removal(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
582 prevent
= srb
->cmnd
[4] & 0x1;
584 scsi_set_resid(srb
, 0);
587 set_sense_type(chip
, SCSI_LUN(srb
),
588 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
589 TRACE_RET(chip
, TRANSPORT_FAILED
);
592 return TRANSPORT_GOOD
;
595 static void ms_mode_sense(struct rts51x_chip
*chip
, u8 cmd
,
596 int lun
, u8
*buf
, int buf_len
)
598 struct ms_info
*ms_card
= &(chip
->ms_card
);
600 int data_size
= buf_len
;
601 int support_format
= 0;
604 if (cmd
== MODE_SENSE
) {
606 if (data_size
> 0x68)
608 buf
[i
++] = 0x67; /* Mode Data Length */
610 sys_info_offset
= 12;
611 if (data_size
> 0x6C)
613 buf
[i
++] = 0x00; /* Mode Data Length (MSB) */
614 buf
[i
++] = 0x6A; /* Mode Data Length (LSB) */
617 /* Medium Type Code */
618 if (check_card_ready(chip
, lun
)) {
619 if (CHK_MSXC(ms_card
)) {
622 } else if (CHK_MSPRO(ms_card
)) {
630 if (check_card_wp(chip
, lun
))
635 buf
[i
++] = 0x00; /* MediaType */
636 buf
[i
++] = 0x00; /* WP */
639 buf
[i
++] = 0x00; /* Reserved */
641 if (cmd
== MODE_SENSE_10
) {
642 buf
[i
++] = 0x00; /* Reserved */
643 buf
[i
++] = 0x00; /* Block descriptor length(MSB) */
644 buf
[i
++] = 0x00; /* Block descriptor length(LSB) */
646 /* The Following Data is the content of "Page 0x20" */
648 buf
[i
++] = 0x20; /* Page Code */
650 buf
[i
++] = 0x62; /* Page Length */
652 buf
[i
++] = 0x00; /* No Access Control */
653 if (data_size
>= 12) {
655 buf
[i
++] = 0xC0; /* SF, SGM */
660 /* The Following Data is the content of "Page 0x20" */
662 buf
[i
++] = 0x20; /* Page Code */
664 buf
[i
++] = 0x62; /* Page Length */
666 buf
[i
++] = 0x00; /* No Access Control */
667 if (data_size
>= 8) {
669 buf
[i
++] = 0xC0; /* SF, SGM */
675 if (data_size
> sys_info_offset
) {
676 /* 96 Bytes Attribute Data */
677 int len
= data_size
- sys_info_offset
;
678 len
= (len
< 96) ? len
: 96;
680 memcpy(buf
+ sys_info_offset
, ms_card
->raw_sys_info
, len
);
684 static int mode_sense(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
686 unsigned int lun
= SCSI_LUN(srb
);
687 unsigned int dataSize
;
689 int pro_formatter_flag
;
690 unsigned char pageCode
, *buf
;
691 u8 card
= get_lun_card(chip
, lun
);
693 if (!check_card_ready(chip
, lun
)) {
694 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
695 scsi_set_resid(srb
, scsi_bufflen(srb
));
696 TRACE_RET(chip
, TRANSPORT_FAILED
);
699 pro_formatter_flag
= 0;
701 /* In Combo mode, device responses ModeSense command as a MS LUN
702 * when no card is inserted */
703 if ((get_lun2card(chip
, lun
) & MS_CARD
)) {
704 if (!card
|| (card
== MS_CARD
)) {
706 if (chip
->option
.mspro_formatter_enable
)
707 pro_formatter_flag
= 1;
711 buf
= kmalloc(dataSize
, GFP_KERNEL
);
713 TRACE_RET(chip
, TRANSPORT_ERROR
);
715 pageCode
= srb
->cmnd
[2] & 0x3f;
717 if ((pageCode
== 0x3F) || (pageCode
== 0x1C) ||
718 (pageCode
== 0x00) || (pro_formatter_flag
&& (pageCode
== 0x20))) {
719 if (srb
->cmnd
[0] == MODE_SENSE
) {
720 if ((pageCode
== 0x3F) || (pageCode
== 0x20)) {
721 ms_mode_sense(chip
, srb
->cmnd
[0], lun
, buf
,
727 if (check_card_wp(chip
, lun
))
733 if ((pageCode
== 0x3F) || (pageCode
== 0x20)) {
734 ms_mode_sense(chip
, srb
->cmnd
[0], lun
, buf
,
741 if (check_card_wp(chip
, lun
))
751 status
= TRANSPORT_GOOD
;
753 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
754 scsi_set_resid(srb
, scsi_bufflen(srb
));
755 status
= TRANSPORT_FAILED
;
758 if (status
== TRANSPORT_GOOD
) {
759 unsigned int len
= min(scsi_bufflen(srb
), dataSize
);
760 rts51x_set_xfer_buf(buf
, len
, srb
);
761 scsi_set_resid(srb
, scsi_bufflen(srb
) - len
);
768 static int request_sense(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
770 struct sense_data_t
*sense
;
771 unsigned int lun
= SCSI_LUN(srb
);
772 struct ms_info
*ms_card
= &(chip
->ms_card
);
773 unsigned char *tmp
, *buf
;
775 sense
= &(chip
->sense_buffer
[lun
]);
777 if ((get_lun_card(chip
, lun
) == MS_CARD
)
778 && PRO_UNDER_FORMATTING(ms_card
)) {
779 mspro_format_sense(chip
, lun
);
782 buf
= vmalloc(scsi_bufflen(srb
));
784 TRACE_RET(chip
, TRANSPORT_ERROR
);
786 tmp
= (unsigned char *)sense
;
787 memcpy(buf
, tmp
, scsi_bufflen(srb
));
789 rts51x_set_xfer_buf(buf
, scsi_bufflen(srb
), srb
);
792 scsi_set_resid(srb
, 0);
793 /* Reset Sense Data */
794 set_sense_type(chip
, lun
, SENSE_TYPE_NO_SENSE
);
795 return TRANSPORT_GOOD
;
798 static int read_write(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
800 #ifdef SUPPORT_SD_LOCK
801 struct sd_info
*sd_card
= &(chip
->sd_card
);
803 unsigned int lun
= SCSI_LUN(srb
);
808 if (!check_card_ready(chip
, lun
) || (chip
->capacity
[lun
] == 0)) {
809 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
810 TRACE_RET(chip
, TRANSPORT_FAILED
);
813 if (!check_lun_mc(chip
, lun
)) {
814 set_lun_mc(chip
, lun
);
815 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_CHANGE
);
816 return TRANSPORT_FAILED
;
819 rts51x_prepare_run(chip
);
820 RTS51X_SET_STAT(chip
, STAT_RUN
);
822 #ifdef SUPPORT_SD_LOCK
823 if (sd_card
->sd_erase_status
) {
824 /* Accessing to any card is forbidden
825 * until the erase procedure of SD is completed */
826 RTS51X_DEBUGP("SD card being erased!\n");
827 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_READ_FORBIDDEN
);
828 TRACE_RET(chip
, TRANSPORT_FAILED
);
831 if (get_lun_card(chip
, lun
) == SD_CARD
) {
832 if (sd_card
->sd_lock_status
& SD_LOCKED
) {
833 RTS51X_DEBUGP("SD card locked!\n");
834 set_sense_type(chip
, lun
,
835 SENSE_TYPE_MEDIA_READ_FORBIDDEN
);
836 TRACE_RET(chip
, TRANSPORT_FAILED
);
841 if ((srb
->cmnd
[0] == READ_10
) || (srb
->cmnd
[0] == WRITE_10
)) {
843 ((u32
) srb
->cmnd
[2] << 24) |
844 ((u32
) srb
->cmnd
[3] << 16) |
845 ((u32
) srb
->cmnd
[4] << 8) |
846 ((u32
) srb
->cmnd
[5]);
847 sec_cnt
= ((u16
) (srb
->cmnd
[7]) << 8) | srb
->cmnd
[8];
848 } else if ((srb
->cmnd
[0] == READ_6
) || (srb
->cmnd
[0] == WRITE_6
)) {
849 start_sec
= ((u32
) (srb
->cmnd
[1] & 0x1F) << 16) |
850 ((u32
) srb
->cmnd
[2] << 8) | ((u32
) srb
->cmnd
[3]);
851 sec_cnt
= srb
->cmnd
[4];
852 } else if ((srb
->cmnd
[0] == VENDOR_CMND
) &&
853 (srb
->cmnd
[1] == SCSI_APP_CMD
) &&
854 ((srb
->cmnd
[2] == PP_READ10
) ||
855 (srb
->cmnd
[2] == PP_WRITE10
))) {
856 start_sec
= ((u32
) srb
->cmnd
[4] << 24) |
857 ((u32
) srb
->cmnd
[5] << 16) |
858 ((u32
) srb
->cmnd
[6] << 8) |
859 ((u32
) srb
->cmnd
[7]);
860 sec_cnt
= ((u16
) (srb
->cmnd
[9]) << 8) | srb
->cmnd
[10];
862 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
863 TRACE_RET(chip
, TRANSPORT_FAILED
);
866 if ((start_sec
> chip
->capacity
[lun
]) ||
867 ((start_sec
+ sec_cnt
) > chip
->capacity
[lun
])) {
868 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LBA_OVER_RANGE
);
869 TRACE_RET(chip
, TRANSPORT_FAILED
);
873 scsi_set_resid(srb
, 0);
874 return TRANSPORT_GOOD
;
877 if ((srb
->sc_data_direction
== DMA_TO_DEVICE
)
878 && check_card_wp(chip
, lun
)) {
879 RTS51X_DEBUGP("Write protected card!\n");
880 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_PROTECT
);
881 TRACE_RET(chip
, TRANSPORT_FAILED
);
884 retval
= card_rw(srb
, chip
, start_sec
, sec_cnt
);
885 if (retval
!= STATUS_SUCCESS
) {
887 if (chip
->need_release
& chip
->lun2card
[lun
]) {
888 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
891 if (srb
->sc_data_direction
== DMA_FROM_DEVICE
) {
892 set_sense_type(chip
, lun
,
893 SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
895 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_ERR
);
900 TRACE_RET(chip
, TRANSPORT_FAILED
);
903 scsi_set_resid(srb
, 0);
905 return TRANSPORT_GOOD
;
908 static int read_format_capacity(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
911 unsigned int lun
= SCSI_LUN(srb
);
912 unsigned int buf_len
;
913 u8 card
= get_lun_card(chip
, lun
);
917 if (!check_card_ready(chip
, lun
)) {
918 if (!chip
->option
.mspro_formatter_enable
) {
919 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
920 TRACE_RET(chip
, TRANSPORT_FAILED
);
924 buf_len
= (scsi_bufflen(srb
) > 12) ? 0x14 : 12;
926 buf
= kmalloc(buf_len
, GFP_KERNEL
);
928 TRACE_RET(chip
, TRANSPORT_ERROR
);
934 /* Capacity List Length */
935 if ((buf_len
> 12) && chip
->option
.mspro_formatter_enable
&&
936 (chip
->lun2card
[lun
] & MS_CARD
) && (!card
|| (card
== MS_CARD
))) {
945 if (check_card_ready(chip
, lun
)) {
946 buf
[i
++] = (unsigned char)((chip
->capacity
[lun
]) >> 24);
947 buf
[i
++] = (unsigned char)((chip
->capacity
[lun
]) >> 16);
948 buf
[i
++] = (unsigned char)((chip
->capacity
[lun
]) >> 8);
949 buf
[i
++] = (unsigned char)(chip
->capacity
[lun
]);
952 /* Byte[8]: Descriptor Type: Formatted medium */
955 buf
[i
++] = 0; /* Byte[16] */
963 /* Byte[8]: Descriptor Type: No medium */
966 buf
[i
++] = 0; /*Byte[16] */
976 buf_len
= min(scsi_bufflen(srb
), buf_len
);
977 rts51x_set_xfer_buf(buf
, buf_len
, srb
);
980 scsi_set_resid(srb
, scsi_bufflen(srb
) - buf_len
);
982 return TRANSPORT_GOOD
;
985 static int read_capacity(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
988 unsigned int lun
= SCSI_LUN(srb
);
990 if (!check_card_ready(chip
, lun
)) {
991 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
992 TRACE_RET(chip
, TRANSPORT_FAILED
);
995 if (!check_lun_mc(chip
, lun
)) {
996 set_lun_mc(chip
, lun
);
997 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_CHANGE
);
998 return TRANSPORT_FAILED
;
1001 buf
= kmalloc(8, GFP_KERNEL
);
1003 TRACE_RET(chip
, TRANSPORT_ERROR
);
1005 buf
[0] = (unsigned char)((chip
->capacity
[lun
] - 1) >> 24);
1006 buf
[1] = (unsigned char)((chip
->capacity
[lun
] - 1) >> 16);
1007 buf
[2] = (unsigned char)((chip
->capacity
[lun
] - 1) >> 8);
1008 buf
[3] = (unsigned char)(chip
->capacity
[lun
] - 1);
1015 rts51x_set_xfer_buf(buf
, scsi_bufflen(srb
), srb
);
1018 scsi_set_resid(srb
, 0);
1020 return TRANSPORT_GOOD
;
1023 static int get_dev_status(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1025 unsigned int lun
= SCSI_LUN(srb
);
1026 unsigned int buf_len
;
1027 u8 status
[32] = { 0 };
1029 rts51x_pp_status(chip
, lun
, status
, 32);
1031 buf_len
= min(scsi_bufflen(srb
), (unsigned int)sizeof(status
));
1032 rts51x_set_xfer_buf(status
, buf_len
, srb
);
1033 scsi_set_resid(srb
, scsi_bufflen(srb
) - buf_len
);
1035 return TRANSPORT_GOOD
;
1038 static int read_status(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1040 u8 rts51x_status
[16];
1041 unsigned int buf_len
;
1042 unsigned int lun
= SCSI_LUN(srb
);
1044 rts51x_read_status(chip
, lun
, rts51x_status
, 16);
1046 buf_len
= min(scsi_bufflen(srb
), (unsigned int)sizeof(rts51x_status
));
1047 rts51x_set_xfer_buf(rts51x_status
, buf_len
, srb
);
1048 scsi_set_resid(srb
, scsi_bufflen(srb
) - buf_len
);
1050 return TRANSPORT_GOOD
;
1053 static int read_mem(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1055 unsigned int lun
= SCSI_LUN(srb
);
1056 unsigned short addr
, len
, i
;
1060 rts51x_prepare_run(chip
);
1061 RTS51X_SET_STAT(chip
, STAT_RUN
);
1063 addr
= ((u16
) srb
->cmnd
[2] << 8) | srb
->cmnd
[3];
1064 len
= ((u16
) srb
->cmnd
[4] << 8) | srb
->cmnd
[5];
1066 if (addr
< 0xe000) {
1067 RTS51X_DEBUGP("filter!addr=0x%x\n", addr
);
1068 return TRANSPORT_GOOD
;
1073 TRACE_RET(chip
, TRANSPORT_ERROR
);
1075 for (i
= 0; i
< len
; i
++) {
1076 retval
= rts51x_ep0_read_register(chip
, addr
+ i
, buf
+ i
);
1077 if (retval
!= STATUS_SUCCESS
) {
1079 set_sense_type(chip
, lun
,
1080 SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
1081 TRACE_RET(chip
, TRANSPORT_FAILED
);
1085 len
= (unsigned short)min(scsi_bufflen(srb
), (unsigned int)len
);
1086 rts51x_set_xfer_buf(buf
, len
, srb
);
1087 scsi_set_resid(srb
, scsi_bufflen(srb
) - len
);
1091 return TRANSPORT_GOOD
;
1094 static int write_mem(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1096 unsigned int lun
= SCSI_LUN(srb
);
1097 unsigned short addr
, len
, i
;
1101 rts51x_prepare_run(chip
);
1102 RTS51X_SET_STAT(chip
, STAT_RUN
);
1104 addr
= ((u16
) srb
->cmnd
[2] << 8) | srb
->cmnd
[3];
1105 len
= ((u16
) srb
->cmnd
[4] << 8) | srb
->cmnd
[5];
1107 if (addr
< 0xe000) {
1108 RTS51X_DEBUGP("filter!addr=0x%x\n", addr
);
1109 return TRANSPORT_GOOD
;
1112 len
= (unsigned short)min(scsi_bufflen(srb
), (unsigned int)len
);
1115 TRACE_RET(chip
, TRANSPORT_ERROR
);
1117 rts51x_get_xfer_buf(buf
, len
, srb
);
1119 for (i
= 0; i
< len
; i
++) {
1121 rts51x_ep0_write_register(chip
, addr
+ i
, 0xFF, buf
[i
]);
1122 if (retval
!= STATUS_SUCCESS
) {
1124 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_ERR
);
1125 TRACE_RET(chip
, TRANSPORT_FAILED
);
1130 scsi_set_resid(srb
, scsi_bufflen(srb
) - len
);
1132 return TRANSPORT_GOOD
;
1135 static int get_sd_csd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1137 struct sd_info
*sd_card
= &(chip
->sd_card
);
1138 unsigned int lun
= SCSI_LUN(srb
);
1140 if (!check_card_ready(chip
, lun
)) {
1141 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1142 TRACE_RET(chip
, TRANSPORT_FAILED
);
1145 if (get_lun_card(chip
, lun
) != SD_CARD
) {
1146 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
1147 TRACE_RET(chip
, TRANSPORT_FAILED
);
1150 scsi_set_resid(srb
, 0);
1151 rts51x_set_xfer_buf(sd_card
->raw_csd
, scsi_bufflen(srb
), srb
);
1153 return TRANSPORT_GOOD
;
1156 static int read_phy_register(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1162 rts51x_prepare_run(chip
);
1163 RTS51X_SET_STAT(chip
, STAT_RUN
);
1165 addr
= srb
->cmnd
[5];
1171 TRACE_RET(chip
, TRANSPORT_ERROR
);
1173 for (i
= 0; i
< len
; i
++) {
1175 rts51x_read_phy_register(chip
, addr
+ i
, buf
+ i
);
1176 if (retval
!= STATUS_SUCCESS
) {
1178 set_sense_type(chip
, SCSI_LUN(srb
),
1179 SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
1180 TRACE_RET(chip
, TRANSPORT_FAILED
);
1184 len
= min(scsi_bufflen(srb
), (unsigned int)len
);
1185 rts51x_set_xfer_buf(buf
, len
, srb
);
1186 scsi_set_resid(srb
, scsi_bufflen(srb
) - len
);
1191 return TRANSPORT_GOOD
;
1194 static int write_phy_register(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1200 rts51x_prepare_run(chip
);
1201 RTS51X_SET_STAT(chip
, STAT_RUN
);
1203 addr
= srb
->cmnd
[5];
1207 len
= min(scsi_bufflen(srb
), (unsigned int)len
);
1211 TRACE_RET(chip
, TRANSPORT_ERROR
);
1213 rts51x_get_xfer_buf(buf
, len
, srb
);
1214 scsi_set_resid(srb
, scsi_bufflen(srb
) - len
);
1216 for (i
= 0; i
< len
; i
++) {
1218 rts51x_write_phy_register(chip
, addr
+ i
, buf
[i
]);
1219 if (retval
!= STATUS_SUCCESS
) {
1221 set_sense_type(chip
, SCSI_LUN(srb
),
1222 SENSE_TYPE_MEDIA_WRITE_ERR
);
1223 TRACE_RET(chip
, TRANSPORT_FAILED
);
1230 return TRANSPORT_GOOD
;
1233 static int get_card_bus_width(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1235 unsigned int lun
= SCSI_LUN(srb
);
1238 if (!check_card_ready(chip
, lun
)) {
1239 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1240 TRACE_RET(chip
, TRANSPORT_FAILED
);
1243 card
= get_lun_card(chip
, lun
);
1244 if ((card
== SD_CARD
) || (card
== MS_CARD
)) {
1245 bus_width
= chip
->card_bus_width
[lun
];
1247 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
1248 TRACE_RET(chip
, TRANSPORT_FAILED
);
1251 scsi_set_resid(srb
, 0);
1252 rts51x_set_xfer_buf(&bus_width
, scsi_bufflen(srb
), srb
);
1254 return TRANSPORT_GOOD
;
1258 static int trace_msg_cmd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1260 unsigned char *buf
= NULL
;
1262 unsigned int buf_len
;
1266 ((2 + MSG_FUNC_LEN
+ MSG_FILE_LEN
+ TIME_VAL_LEN
) * TRACE_ITEM_CNT
);
1268 if ((scsi_bufflen(srb
) < buf_len
) || (scsi_sglist(srb
) == NULL
)) {
1269 set_sense_type(chip
, SCSI_LUN(srb
),
1270 SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
1271 TRACE_RET(chip
, TRANSPORT_FAILED
);
1274 clear
= srb
->cmnd
[2];
1276 buf
= vmalloc(scsi_bufflen(srb
));
1278 TRACE_RET(chip
, TRANSPORT_ERROR
);
1280 rts51x_trace_msg(chip
, buf
, clear
);
1282 rts51x_set_xfer_buf(buf
, scsi_bufflen(srb
), srb
);
1285 scsi_set_resid(srb
, 0);
1286 return TRANSPORT_GOOD
;
1290 static int rw_mem_cmd_buf(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1292 int retval
= STATUS_SUCCESS
;
1293 unsigned int lun
= SCSI_LUN(srb
);
1294 u8 cmd_type
, mask
, value
, idx
, mode
, len
;
1298 rts51x_prepare_run(chip
);
1299 RTS51X_SET_STAT(chip
, STAT_RUN
);
1301 switch (srb
->cmnd
[3]) {
1303 rts51x_init_cmd(chip
);
1307 cmd_type
= srb
->cmnd
[4];
1309 set_sense_type(chip
, lun
,
1310 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1311 TRACE_RET(chip
, TRANSPORT_FAILED
);
1313 addr
= (srb
->cmnd
[5] << 8) | srb
->cmnd
[6];
1314 mask
= srb
->cmnd
[7];
1315 value
= srb
->cmnd
[8];
1316 rts51x_add_cmd(chip
, cmd_type
, addr
, mask
, value
);
1320 mode
= srb
->cmnd
[4];
1323 ((u32
) srb
->cmnd
[6] << 24) | ((u32
) srb
->
1324 cmnd
[7] << 16) | ((u32
) srb
->
1330 retval
= rts51x_send_cmd(chip
, mode
, 1000);
1331 if (retval
!= STATUS_SUCCESS
) {
1332 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_ERR
);
1333 TRACE_RET(chip
, TRANSPORT_FAILED
);
1335 if (mode
& STAGE_R
) {
1336 retval
= rts51x_get_rsp(chip
, len
, timeout
);
1337 if (retval
!= STATUS_SUCCESS
) {
1338 set_sense_type(chip
, lun
,
1339 SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR
);
1340 TRACE_RET(chip
, TRANSPORT_FAILED
);
1347 value
= chip
->rsp_buf
[idx
];
1348 if (scsi_bufflen(srb
) < 1) {
1349 set_sense_type(chip
, lun
,
1350 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1351 TRACE_RET(chip
, TRANSPORT_FAILED
);
1353 rts51x_set_xfer_buf(&value
, 1, srb
);
1354 scsi_set_resid(srb
, 0);
1358 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1359 TRACE_RET(chip
, TRANSPORT_FAILED
);
1362 if (retval
!= STATUS_SUCCESS
) {
1363 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_ERR
);
1364 TRACE_RET(chip
, TRANSPORT_FAILED
);
1367 return TRANSPORT_GOOD
;
1370 static int suit_cmd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1374 switch (srb
->cmnd
[3]) {
1379 result
= rw_mem_cmd_buf(srb
, chip
);
1382 result
= TRANSPORT_ERROR
;
1388 static int app_cmd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1392 switch (srb
->cmnd
[2]) {
1395 result
= read_write(srb
, chip
);
1399 result
= suit_cmd(srb
, chip
);
1403 result
= read_phy_register(srb
, chip
);
1407 result
= write_phy_register(srb
, chip
);
1410 case GET_DEV_STATUS
:
1411 result
= get_dev_status(srb
, chip
);
1415 set_sense_type(chip
, SCSI_LUN(srb
),
1416 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1417 TRACE_RET(chip
, TRANSPORT_FAILED
);
1423 static int vendor_cmnd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1425 int result
= TRANSPORT_GOOD
;
1427 switch (srb
->cmnd
[1]) {
1429 result
= read_status(srb
, chip
);
1433 result
= read_mem(srb
, chip
);
1437 result
= write_mem(srb
, chip
);
1441 result
= get_card_bus_width(srb
, chip
);
1445 result
= get_sd_csd(srb
, chip
);
1450 result
= trace_msg_cmd(srb
, chip
);
1455 result
= app_cmd(srb
, chip
);
1459 set_sense_type(chip
, SCSI_LUN(srb
),
1460 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1461 TRACE_RET(chip
, TRANSPORT_FAILED
);
1467 static int ms_format_cmnd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1469 struct ms_info
*ms_card
= &(chip
->ms_card
);
1470 unsigned int lun
= SCSI_LUN(srb
);
1471 int retval
, quick_format
;
1473 if (get_lun_card(chip
, lun
) != MS_CARD
) {
1474 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
);
1475 TRACE_RET(chip
, TRANSPORT_FAILED
);
1478 if ((srb
->cmnd
[3] != 0x4D) || (srb
->cmnd
[4] != 0x47)
1479 || (srb
->cmnd
[5] != 0x66) || (srb
->cmnd
[6] != 0x6D)
1480 || (srb
->cmnd
[7] != 0x74)) {
1481 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1482 TRACE_RET(chip
, TRANSPORT_FAILED
);
1485 if (srb
->cmnd
[8] & 0x01)
1490 if (!(chip
->card_ready
& MS_CARD
)) {
1491 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1492 TRACE_RET(chip
, TRANSPORT_FAILED
);
1495 if (chip
->card_wp
& MS_CARD
) {
1496 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_PROTECT
);
1497 TRACE_RET(chip
, TRANSPORT_FAILED
);
1500 if (!CHK_MSPRO(ms_card
)) {
1501 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
);
1502 TRACE_RET(chip
, TRANSPORT_FAILED
);
1505 rts51x_prepare_run(chip
);
1506 RTS51X_SET_STAT(chip
, STAT_RUN
);
1508 retval
= mspro_format(srb
, chip
, MS_SHORT_DATA_LEN
, quick_format
);
1509 if (retval
!= STATUS_SUCCESS
) {
1510 set_sense_type(chip
, lun
, SENSE_TYPE_FORMAT_CMD_FAILED
);
1511 TRACE_RET(chip
, TRANSPORT_FAILED
);
1514 scsi_set_resid(srb
, 0);
1515 return TRANSPORT_GOOD
;
1518 #ifdef SUPPORT_PCGL_1P18
1519 int get_ms_information(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1521 struct ms_info
*ms_card
= &(chip
->ms_card
);
1522 unsigned int lun
= SCSI_LUN(srb
);
1523 u8 dev_info_id
, data_len
;
1525 unsigned int buf_len
;
1528 if (!check_card_ready(chip
, lun
)) {
1529 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1530 TRACE_RET(chip
, TRANSPORT_FAILED
);
1532 if ((get_lun_card(chip
, lun
) != MS_CARD
)) {
1533 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
);
1534 TRACE_RET(chip
, TRANSPORT_FAILED
);
1537 if ((srb
->cmnd
[2] != 0xB0) || (srb
->cmnd
[4] != 0x4D) ||
1538 (srb
->cmnd
[5] != 0x53) || (srb
->cmnd
[6] != 0x49) ||
1539 (srb
->cmnd
[7] != 0x44)) {
1540 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1541 TRACE_RET(chip
, TRANSPORT_FAILED
);
1544 dev_info_id
= srb
->cmnd
[3];
1545 if ((CHK_MSXC(ms_card
) && (dev_info_id
== 0x10)) ||
1546 (!CHK_MSXC(ms_card
) && (dev_info_id
== 0x13)) ||
1547 !CHK_MSPRO(ms_card
)) {
1548 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1549 TRACE_RET(chip
, TRANSPORT_FAILED
);
1552 if (dev_info_id
== 0x15)
1553 buf_len
= data_len
= 0x3A;
1555 buf_len
= data_len
= 0x6A;
1557 buf
= kmalloc(buf_len
, GFP_KERNEL
);
1559 TRACE_RET(chip
, TRANSPORT_ERROR
);
1562 /* GET Memory Stick Media Information Response Header */
1563 buf
[i
++] = 0x00; /* Data length MSB */
1564 buf
[i
++] = data_len
; /* Data length LSB */
1565 /* Device Information Type Code */
1566 if (CHK_MSXC(ms_card
))
1576 /* Number of Device Information */
1579 /* Device Information Body
1580 * Device Information ID Number */
1581 buf
[i
++] = dev_info_id
;
1582 /* Device Information Length */
1583 if (dev_info_id
== 0x15)
1587 buf
[i
++] = 0x00; /* Data length MSB */
1588 buf
[i
++] = data_len
; /* Data length LSB */
1591 if ((dev_info_id
== 0x10) || (dev_info_id
== 0x13)) {
1592 /* System Information */
1593 memcpy(buf
+ i
, ms_card
->raw_sys_info
, 96);
1596 memcpy(buf
+ i
, ms_card
->raw_model_name
, 48);
1599 rts51x_set_xfer_buf(buf
, buf_len
, srb
);
1601 if (dev_info_id
== 0x15)
1602 scsi_set_resid(srb
, scsi_bufflen(srb
) - 0x3C);
1604 scsi_set_resid(srb
, scsi_bufflen(srb
) - 0x6C);
1607 return STATUS_SUCCESS
;
1611 static int ms_sp_cmnd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1613 int retval
= TRANSPORT_ERROR
;
1615 if (srb
->cmnd
[2] == MS_FORMAT
)
1616 retval
= ms_format_cmnd(srb
, chip
);
1617 #ifdef SUPPORT_PCGL_1P18
1618 else if (srb
->cmnd
[2] == GET_MS_INFORMATION
)
1619 retval
= get_ms_information(srb
, chip
);
1626 static int sd_extention_cmnd(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1628 unsigned int lun
= SCSI_LUN(srb
);
1631 rts51x_prepare_run(chip
);
1632 RTS51X_SET_STAT(chip
, STAT_RUN
);
1634 sd_cleanup_work(chip
);
1636 if (!check_card_ready(chip
, lun
)) {
1637 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1638 TRACE_RET(chip
, TRANSPORT_FAILED
);
1640 if ((get_lun_card(chip
, lun
) != SD_CARD
)) {
1641 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
);
1642 TRACE_RET(chip
, TRANSPORT_FAILED
);
1645 switch (srb
->cmnd
[0]) {
1646 case SD_PASS_THRU_MODE
:
1647 result
= sd_pass_thru_mode(srb
, chip
);
1650 case SD_EXECUTE_NO_DATA
:
1651 result
= sd_execute_no_data(srb
, chip
);
1654 case SD_EXECUTE_READ
:
1655 result
= sd_execute_read_data(srb
, chip
);
1658 case SD_EXECUTE_WRITE
:
1659 result
= sd_execute_write_data(srb
, chip
);
1663 result
= sd_get_cmd_rsp(srb
, chip
);
1667 result
= sd_hw_rst(srb
, chip
);
1671 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1672 TRACE_RET(chip
, TRANSPORT_FAILED
);
1679 #ifdef SUPPORT_MAGIC_GATE
1680 int mg_report_key(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1682 struct ms_info
*ms_card
= &(chip
->ms_card
);
1683 unsigned int lun
= SCSI_LUN(srb
);
1687 rts51x_prepare_run(chip
);
1688 RTS51X_SET_STAT(chip
, STAT_RUN
);
1690 ms_cleanup_work(chip
);
1692 if (!check_card_ready(chip
, lun
)) {
1693 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1694 TRACE_RET(chip
, TRANSPORT_FAILED
);
1696 if ((get_lun_card(chip
, lun
) != MS_CARD
)) {
1697 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
);
1698 TRACE_RET(chip
, TRANSPORT_FAILED
);
1701 if (srb
->cmnd
[7] != KC_MG_R_PRO
) {
1702 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1703 TRACE_RET(chip
, TRANSPORT_FAILED
);
1706 if (!CHK_MSPRO(ms_card
)) {
1707 set_sense_type(chip
, lun
, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM
);
1708 TRACE_RET(chip
, TRANSPORT_FAILED
);
1711 key_format
= srb
->cmnd
[10] & 0x3F;
1713 switch (key_format
) {
1714 case KF_GET_LOC_EKB
:
1715 if ((scsi_bufflen(srb
) == 0x41C) &&
1716 (srb
->cmnd
[8] == 0x04) && (srb
->cmnd
[9] == 0x1C)) {
1717 retval
= mg_get_local_EKB(srb
, chip
);
1718 if (retval
!= STATUS_SUCCESS
)
1719 TRACE_RET(chip
, TRANSPORT_FAILED
);
1721 set_sense_type(chip
, lun
,
1722 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1723 TRACE_RET(chip
, TRANSPORT_FAILED
);
1728 if ((scsi_bufflen(srb
) == 0x24) &&
1729 (srb
->cmnd
[8] == 0x00) && (srb
->cmnd
[9] == 0x24)) {
1730 retval
= mg_get_rsp_chg(srb
, chip
);
1731 if (retval
!= STATUS_SUCCESS
)
1732 TRACE_RET(chip
, TRANSPORT_FAILED
);
1734 set_sense_type(chip
, lun
,
1735 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1736 TRACE_RET(chip
, TRANSPORT_FAILED
);
1741 ms_card
->mg_entry_num
= srb
->cmnd
[5];
1742 if ((scsi_bufflen(srb
) == 0x404) &&
1743 (srb
->cmnd
[8] == 0x04) &&
1744 (srb
->cmnd
[9] == 0x04) &&
1745 (srb
->cmnd
[2] == 0x00) &&
1746 (srb
->cmnd
[3] == 0x00) &&
1747 (srb
->cmnd
[4] == 0x00) && (srb
->cmnd
[5] < 32)) {
1748 retval
= mg_get_ICV(srb
, chip
);
1749 if (retval
!= STATUS_SUCCESS
)
1750 TRACE_RET(chip
, TRANSPORT_FAILED
);
1752 set_sense_type(chip
, lun
,
1753 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1754 TRACE_RET(chip
, TRANSPORT_FAILED
);
1759 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1760 TRACE_RET(chip
, TRANSPORT_FAILED
);
1763 scsi_set_resid(srb
, 0);
1764 return TRANSPORT_GOOD
;
1767 int mg_send_key(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1769 struct ms_info
*ms_card
= &(chip
->ms_card
);
1770 unsigned int lun
= SCSI_LUN(srb
);
1774 rts51x_prepare_run(chip
);
1775 RTS51X_SET_STAT(chip
, STAT_RUN
);
1777 ms_cleanup_work(chip
);
1779 if (!check_card_ready(chip
, lun
)) {
1780 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_NOT_PRESENT
);
1781 TRACE_RET(chip
, TRANSPORT_FAILED
);
1783 if (check_card_wp(chip
, lun
)) {
1784 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_WRITE_PROTECT
);
1785 TRACE_RET(chip
, TRANSPORT_FAILED
);
1787 if ((get_lun_card(chip
, lun
) != MS_CARD
)) {
1788 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT
);
1789 TRACE_RET(chip
, TRANSPORT_FAILED
);
1792 if (srb
->cmnd
[7] != KC_MG_R_PRO
) {
1793 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1794 TRACE_RET(chip
, TRANSPORT_FAILED
);
1797 if (!CHK_MSPRO(ms_card
)) {
1798 set_sense_type(chip
, lun
, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM
);
1799 TRACE_RET(chip
, TRANSPORT_FAILED
);
1802 key_format
= srb
->cmnd
[10] & 0x3F;
1804 switch (key_format
) {
1805 case KF_SET_LEAF_ID
:
1806 if ((scsi_bufflen(srb
) == 0x0C) &&
1807 (srb
->cmnd
[8] == 0x00) && (srb
->cmnd
[9] == 0x0C)) {
1808 retval
= mg_set_leaf_id(srb
, chip
);
1809 if (retval
!= STATUS_SUCCESS
)
1810 TRACE_RET(chip
, TRANSPORT_FAILED
);
1812 set_sense_type(chip
, lun
,
1813 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1814 TRACE_RET(chip
, TRANSPORT_FAILED
);
1819 if ((scsi_bufflen(srb
) == 0x0C) &&
1820 (srb
->cmnd
[8] == 0x00) && (srb
->cmnd
[9] == 0x0C)) {
1821 retval
= mg_chg(srb
, chip
);
1822 if (retval
!= STATUS_SUCCESS
)
1823 TRACE_RET(chip
, TRANSPORT_FAILED
);
1825 set_sense_type(chip
, lun
,
1826 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1827 TRACE_RET(chip
, TRANSPORT_FAILED
);
1832 if ((scsi_bufflen(srb
) == 0x0C) &&
1833 (srb
->cmnd
[8] == 0x00) && (srb
->cmnd
[9] == 0x0C)) {
1834 retval
= mg_rsp(srb
, chip
);
1835 if (retval
!= STATUS_SUCCESS
)
1836 TRACE_RET(chip
, TRANSPORT_FAILED
);
1838 set_sense_type(chip
, lun
,
1839 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1840 TRACE_RET(chip
, TRANSPORT_FAILED
);
1845 ms_card
->mg_entry_num
= srb
->cmnd
[5];
1846 if ((scsi_bufflen(srb
) == 0x404) &&
1847 (srb
->cmnd
[8] == 0x04) &&
1848 (srb
->cmnd
[9] == 0x04) &&
1849 (srb
->cmnd
[2] == 0x00) &&
1850 (srb
->cmnd
[3] == 0x00) &&
1851 (srb
->cmnd
[4] == 0x00) && (srb
->cmnd
[5] < 32)) {
1852 retval
= mg_set_ICV(srb
, chip
);
1853 if (retval
!= STATUS_SUCCESS
)
1854 TRACE_RET(chip
, TRANSPORT_FAILED
);
1856 set_sense_type(chip
, lun
,
1857 SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1858 TRACE_RET(chip
, TRANSPORT_FAILED
);
1863 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1864 TRACE_RET(chip
, TRANSPORT_FAILED
);
1867 scsi_set_resid(srb
, 0);
1868 return TRANSPORT_GOOD
;
1872 int rts51x_scsi_handler(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
)
1874 #ifdef SUPPORT_SD_LOCK
1875 struct sd_info
*sd_card
= &(chip
->sd_card
);
1877 struct ms_info
*ms_card
= &(chip
->ms_card
);
1878 unsigned int lun
= SCSI_LUN(srb
);
1879 int result
= TRANSPORT_GOOD
;
1881 #ifdef SUPPORT_SD_LOCK
1882 if (sd_card
->sd_erase_status
) {
1883 /* Block all SCSI command except for REQUEST_SENSE
1884 * and rs_ppstatus */
1886 ((srb
->cmnd
[0] == VENDOR_CMND
)
1887 && (srb
->cmnd
[1] == SCSI_APP_CMD
)
1888 && (srb
->cmnd
[2] == GET_DEV_STATUS
))
1889 && (srb
->cmnd
[0] != REQUEST_SENSE
)) {
1890 /* Logical Unit Not Ready Format in Progress */
1891 set_sense_data(chip
, lun
, CUR_ERR
, 0x02, 0, 0x04, 0x04,
1893 TRACE_RET(chip
, TRANSPORT_FAILED
);
1898 if ((get_lun_card(chip
, lun
) == MS_CARD
) &&
1899 (ms_card
->format_status
== FORMAT_IN_PROGRESS
)) {
1900 if ((srb
->cmnd
[0] != REQUEST_SENSE
)
1901 && (srb
->cmnd
[0] != INQUIRY
)) {
1902 /* Logical Unit Not Ready Format in Progress */
1903 set_sense_data(chip
, lun
, CUR_ERR
, 0x02, 0, 0x04, 0x04,
1904 0, (u16
) (ms_card
->progress
));
1905 TRACE_RET(chip
, TRANSPORT_FAILED
);
1909 switch (srb
->cmnd
[0]) {
1914 result
= read_write(srb
, chip
);
1917 case TEST_UNIT_READY
:
1918 result
= test_unit_ready(srb
, chip
);
1922 result
= inquiry(srb
, chip
);
1926 result
= read_capacity(srb
, chip
);
1930 result
= start_stop_unit(srb
, chip
);
1933 case ALLOW_MEDIUM_REMOVAL
:
1934 result
= allow_medium_removal(srb
, chip
);
1938 result
= request_sense(srb
, chip
);
1943 result
= mode_sense(srb
, chip
);
1947 result
= read_format_capacity(srb
, chip
);
1951 result
= vendor_cmnd(srb
, chip
);
1955 result
= ms_sp_cmnd(srb
, chip
);
1959 case SD_PASS_THRU_MODE
:
1960 case SD_EXECUTE_NO_DATA
:
1961 case SD_EXECUTE_READ
:
1962 case SD_EXECUTE_WRITE
:
1965 result
= sd_extention_cmnd(srb
, chip
);
1969 #ifdef SUPPORT_MAGIC_GATE
1970 case CMD_MSPRO_MG_RKEY
:
1971 result
= mg_report_key(srb
, chip
);
1974 case CMD_MSPRO_MG_SKEY
:
1975 result
= mg_send_key(srb
, chip
);
1982 result
= TRANSPORT_GOOD
;
1986 set_sense_type(chip
, lun
, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD
);
1987 result
= TRANSPORT_FAILED
;
1993 /***********************************************************************
1995 ***********************************************************************/
1997 const char *host_info(struct Scsi_Host
*host
)
1999 return "SCSI emulation for RTS51xx USB driver-based card reader";
2002 int slave_alloc(struct scsi_device
*sdev
)
2005 * Set the INQUIRY transfer length to 36. We don't use any of
2006 * the extra data and many devices choke if asked for more or
2007 * less than 36 bytes.
2009 sdev
->inquiry_len
= 36;
2013 int slave_configure(struct scsi_device
*sdev
)
2015 /* Scatter-gather buffers (all but the last) must have a length
2016 * divisible by the bulk maxpacket size. Otherwise a data packet
2017 * would end up being short, causing a premature end to the data
2018 * transfer. Since high-speed bulk pipes have a maxpacket size
2019 * of 512, we'll use that as the scsi device queue's DMA alignment
2020 * mask. Guaranteeing proper alignment of the first buffer will
2021 * have the desired effect because, except at the beginning and
2022 * the end, scatter-gather buffers follow page boundaries. */
2023 blk_queue_dma_alignment(sdev
->request_queue
, (512 - 1));
2025 /* Set the SCSI level to at least 2. We'll leave it at 3 if that's
2026 * what is originally reported. We need this to avoid confusing
2027 * the SCSI layer with devices that report 0 or 1, but need 10-byte
2028 * commands (ala ATAPI devices behind certain bridges, or devices
2029 * which simply have broken INQUIRY data).
2031 * NOTE: This means /dev/sg programs (ala cdrecord) will get the
2032 * actual information. This seems to be the preference for
2033 * programs like that.
2035 * NOTE: This also means that /proc/scsi/scsi and sysfs may report
2036 * the actual value or the modified one, depending on where the
2039 if (sdev
->scsi_level
< SCSI_2
)
2040 sdev
->scsi_level
= sdev
->sdev_target
->scsi_level
= SCSI_2
;
2045 /***********************************************************************
2046 * /proc/scsi/ functions
2047 ***********************************************************************/
2049 /* we use this macro to help us write into the buffer */
2051 #define SPRINTF(args...) \
2052 do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
2054 int proc_info(struct Scsi_Host
*host
, char *buffer
,
2055 char **start
, off_t offset
, int length
, int inout
)
2059 /* if someone is sending us data, just throw it away */
2063 /* print the controller name */
2064 SPRINTF(" Host scsi%d: %s\n", host
->host_no
, RTS51X_NAME
);
2066 /* print product, vendor, and driver version strings */
2067 SPRINTF(" Vendor: Realtek Corp.\n");
2068 SPRINTF(" Product: RTS51xx USB Card Reader\n");
2069 SPRINTF(" Version: %s\n", DRIVER_VERSION
);
2070 SPRINTF(" Build: %s\n", __TIME__
);
2073 * Calculate start of next buffer, and return value.
2075 *start
= buffer
+ offset
;
2077 if ((pos
- buffer
) < offset
)
2079 else if ((pos
- buffer
- offset
) < length
)
2080 return pos
- buffer
- offset
;
2085 /* queue a command */
2086 /* This is always called with scsi_lock(host) held */
2087 int queuecommand_lck(struct scsi_cmnd
*srb
, void (*done
) (struct scsi_cmnd
*))
2089 struct rts51x_chip
*chip
= host_to_rts51x(srb
->device
->host
);
2091 /* check for state-transition errors */
2092 if (chip
->srb
!= NULL
) {
2093 RTS51X_DEBUGP("Error in %s: chip->srb = %p\n",
2094 __func__
, chip
->srb
);
2095 return SCSI_MLQUEUE_HOST_BUSY
;
2098 /* fail the command if we are disconnecting */
2099 if (test_bit(FLIDX_DISCONNECTING
, &chip
->usb
->dflags
)) {
2100 RTS51X_DEBUGP("Fail command during disconnect\n");
2101 srb
->result
= DID_NO_CONNECT
<< 16;
2106 /* enqueue the command and wake up the control thread */
2107 srb
->scsi_done
= done
;
2109 complete(&chip
->usb
->cmnd_ready
);
2114 #if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) */
2115 int queuecommand(struct scsi_cmnd
*srb
, void (*done
) (struct scsi_cmnd
*))
2117 return queuecommand_lck(srb
, done
);
2120 DEF_SCSI_QCMD(queuecommand
)
2122 /***********************************************************************
2123 * Error handling functions
2124 ***********************************************************************/
2125 /* Command timeout and abort */
2126 int command_abort(struct scsi_cmnd
*srb
)
2128 struct rts51x_chip
*chip
= host_to_rts51x(srb
->device
->host
);
2130 RTS51X_DEBUGP("%s called\n", __func__
);
2132 /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING
2133 * bits are protected by the host lock. */
2134 scsi_lock(rts51x_to_host(chip
));
2136 /* Is this command still active? */
2137 if (chip
->srb
!= srb
) {
2138 scsi_unlock(rts51x_to_host(chip
));
2139 RTS51X_DEBUGP("-- nothing to abort\n");
2143 /* Set the TIMED_OUT bit. Also set the ABORTING bit, but only if
2144 * a device reset isn't already in progress (to avoid interfering
2145 * with the reset). Note that we must retain the host lock while
2146 * calling usb_stor_stop_transport(); otherwise it might interfere
2147 * with an auto-reset that begins as soon as we release the lock. */
2148 set_bit(FLIDX_TIMED_OUT
, &chip
->usb
->dflags
);
2149 if (!test_bit(FLIDX_RESETTING
, &chip
->usb
->dflags
)) {
2150 set_bit(FLIDX_ABORTING
, &chip
->usb
->dflags
);
2151 /* rts51x_stop_transport(us); */
2153 scsi_unlock(rts51x_to_host(chip
));
2155 /* Wait for the aborted command to finish */
2156 wait_for_completion(&chip
->usb
->notify
);
2160 /* This invokes the transport reset mechanism to reset the state of the
2162 int device_reset(struct scsi_cmnd
*srb
)
2166 RTS51X_DEBUGP("%s called\n", __func__
);
2168 return result
< 0 ? FAILED
: SUCCESS
;
2171 /* Simulate a SCSI bus reset by resetting the device's USB port. */
2172 int bus_reset(struct scsi_cmnd
*srb
)
2176 RTS51X_DEBUGP("%s called\n", __func__
);
2178 return result
< 0 ? FAILED
: SUCCESS
;
2181 static const char *rts5139_info(struct Scsi_Host
*host
)
2183 return "SCSI emulation for RTS5139 USB card reader";
2186 struct scsi_host_template rts51x_host_template
= {
2187 /* basic userland interface stuff */
2188 .name
= RTS51X_NAME
,
2189 .proc_name
= RTS51X_NAME
,
2190 .proc_info
= proc_info
,
2191 .info
= rts5139_info
,
2193 /* command interface -- queued only */
2194 .queuecommand
= queuecommand
,
2196 /* error and abort handlers */
2197 .eh_abort_handler
= command_abort
,
2198 .eh_device_reset_handler
= device_reset
,
2199 .eh_bus_reset_handler
= bus_reset
,
2201 /* queue commands only, only one command per LUN */
2205 /* unknown initiator id */
2208 .slave_alloc
= slave_alloc
,
2209 .slave_configure
= slave_configure
,
2211 /* lots of sg segments can be handled */
2212 .sg_tablesize
= SG_ALL
,
2214 /* limit the total size of a transfer to 120 KB */
2217 /* merge commands... this seems to help performance, but
2218 * periodically someone should test to see which setting is more
2221 .use_clustering
= 1,
2226 /* we do our own delay after a device or bus reset */
2227 .skip_settle_delay
= 1,
2229 /* sysfs device attributes */
2230 /* .sdev_attrs = sysfs_device_attr_list, */
2232 /* module management */
2233 .module
= THIS_MODULE