Lines Matching +full:0 +full:us
78 #define ENE_BIN_CODE_LEN 0x800
80 #define REG_CARD_STATUS 0xFF83
81 #define REG_HW_TRAP1 0xFF89
84 #define SS_SUCCESS 0x000000 /* No Sense */
85 #define SS_NOT_READY 0x023A00 /* Medium not present */
86 #define SS_MEDIUM_ERR 0x031100 /* Unrecovered read error */
87 #define SS_HW_ERR 0x040800 /* Communication failure */
88 #define SS_ILLEGAL_REQUEST 0x052000 /* Invalid command */
89 #define SS_UNIT_ATTENTION 0x062900 /* Reset occurred */
101 #define FDIR_WRITE 0
107 #define MS_REG_ST1_MB 0x80 /* media busy */
108 #define MS_REG_ST1_FB1 0x40 /* flush busy 1 */
109 #define MS_REG_ST1_DTER 0x20 /* error on data(corrected) */
110 #define MS_REG_ST1_UCDT 0x10 /* unable to correct data */
111 #define MS_REG_ST1_EXER 0x08 /* error on extra(corrected) */
112 #define MS_REG_ST1_UCEX 0x04 /* unable to correct extra */
113 #define MS_REG_ST1_FGER 0x02 /* error on overwrite flag(corrected) */
114 #define MS_REG_ST1_UCFG 0x01 /* unable to correct overwrite flag */
118 #define MS_REG_OVR_BKST 0x80 /* block status */
120 #define MS_REG_OVR_BKST_NG 0x00 /* NG */
121 #define MS_REG_OVR_PGST0 0x40 /* page status */
122 #define MS_REG_OVR_PGST1 0x20
126 #define MS_REG_OVR_PGST_DATA_ERROR 0x00 /* data error */
127 #define MS_REG_OVR_UDST 0x10 /* update status */
128 #define MS_REG_OVR_UDST_UPDATING 0x00 /* updating */
130 #define MS_REG_OVR_RESERVED 0x08
134 #define MS_REG_MNG_SCMS0 0x20 /* serial copy management system */
135 #define MS_REG_MNG_SCMS1 0x10
139 #define MS_REG_MNG_SCMS_NO_COPY 0x00
140 #define MS_REG_MNG_ATFLG 0x08 /* address transfer table flag */
142 #define MS_REG_MNG_ATFLG_ATTBL 0x00 /* address transfer table */
143 #define MS_REG_MNG_SYSFLG 0x04 /* system flag */
145 #define MS_REG_MNG_SYSFLG_BOOT 0x00 /* system block */
146 #define MS_REG_MNG_RESERVED 0xc3
155 #define MS_SYSINF_USAGE_GENERAL 0
163 #define MS_SYSINF_SECURITY 0x01
165 #define MS_SYSINF_SECURITY_SUPPORT 0
170 #define MS_SYSENT_TYPE_INVALID_BLOCK 0x01
171 #define MS_SYSENT_TYPE_CIS_IDI 0x0a /* CIS/IDI */
174 #define BYTE_MASK 0xff
177 #define MS_STATUS_WRITE_PROTECT 0x0106
178 #define MS_STATUS_SUCCESS 0x0000
179 #define MS_ERROR_FLASH_READ 0x8003
180 #define MS_ERROR_FLASH_ERASE 0x8005
181 #define MS_LB_ERROR 0xfff0
182 #define MS_LB_BOOT_BLOCK 0xfff1
183 #define MS_LB_INITIAL_ERROR 0xfff2
184 #define MS_STATUS_SUCCESS_WITH_ECC 0xfff3
185 #define MS_LB_ACQUIRED_ERROR 0xfff4
186 #define MS_LB_NOT_USED_ERASED 0xfff5
187 #define MS_NOCARD_ERROR 0xfff8
188 #define MS_NO_MEMORY_ERROR 0xfff9
189 #define MS_STATUS_INT_ERROR 0xfffa
190 #define MS_STATUS_ERROR 0xfffe
191 #define MS_LB_NOT_USED 0xffff
193 #define MS_REG_MNG_SYSFLG 0x04 /* system flag */
196 #define MS_BOOT_BLOCK_ID 0x0001
197 #define MS_BOOT_BLOCK_FORMAT_VERSION 0x0100
206 #define MS_PHYSICAL_BLOCKS_PER_SEGMENT 0x200 /* 512 */
207 #define MS_PHYSICAL_BLOCKS_PER_SEGMENT_MASK 0x1ff
210 #define MS_REG_OVR_BKST 0x80 /* block status */
212 #define MS_REG_OVR_BKST_NG 0x00 /* NG */
215 #define MS_REG_ST1_DTER 0x20 /* error on data(corrected) */
216 #define MS_REG_ST1_EXER 0x08 /* error on extra(corrected) */
217 #define MS_REG_ST1_FGER 0x02 /* error on overwrite flag(corrected) */
220 /* Status Register 0 */
221 #define MS_REG_ST0_WP 0x01 /* write protected */
224 #define MS_LIB_CTRL_RDONLY 0
235 …ms_lib_ctrl_check((pdx), MS_LIB_CTRL_RDONLY) == 0) && (ms_lib_ctrl_check(pdx, MS_LIB_CTRL_WRPROTEC…
236 #define ms_lib_clear_pagemap(pdx) memset((pdx)->MS_Lib.pagemap, 0, sizeof((pdx)->MS_Lib.pagemap))
241 #define SD_Insert BIT(0)
251 #define MS_Insert BIT(0)
261 #define SM_Insert BIT(0)
269 u8 bCistplDEVICE[6]; /* 0 */
290 #define MS_IDI_GENERAL_CONF 0x848A
291 u16 wIDIgeneralConfiguration; /* 0 */
340 u16 wPageSize; /* must be 0x200 */
341 u8 bExtraSize; /* 0x10 */
477 static int ene_sd_init(struct us_data *us);
478 static int ene_ms_init(struct us_data *us);
479 static int ene_load_bincode(struct us_data *us, unsigned char flag);
490 static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg) in ene_send_scsi_cmd() argument
492 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ene_send_scsi_cmd()
493 struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf; in ene_send_scsi_cmd()
497 unsigned int cswlen = 0, partial = 0; in ene_send_scsi_cmd()
500 /* usb_stor_dbg(us, "transport --- ene_send_scsi_cmd\n"); */ in ene_send_scsi_cmd()
502 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, in ene_send_scsi_cmd()
505 usb_stor_dbg(us, "send cmd to out endpoint fail ---\n"); in ene_send_scsi_cmd()
513 pipe = us->recv_bulk_pipe; in ene_send_scsi_cmd()
515 pipe = us->send_bulk_pipe; in ene_send_scsi_cmd()
519 result = usb_stor_bulk_srb(us, pipe, us->srb); in ene_send_scsi_cmd()
521 result = usb_stor_bulk_transfer_sg(us, pipe, buf, in ene_send_scsi_cmd()
522 transfer_length, 0, &partial); in ene_send_scsi_cmd()
525 usb_stor_dbg(us, "data transfer fail ---\n"); in ene_send_scsi_cmd()
531 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, in ene_send_scsi_cmd()
534 if (result == USB_STOR_XFER_SHORT && cswlen == 0) { in ene_send_scsi_cmd()
535 usb_stor_dbg(us, "Received 0-length CSW; retrying...\n"); in ene_send_scsi_cmd()
536 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in ene_send_scsi_cmd()
542 usb_stor_dbg(us, "Attempting to get CSW (2nd try)...\n"); in ene_send_scsi_cmd()
543 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, in ene_send_scsi_cmd()
555 * was really transferred and what the device tells us in ene_send_scsi_cmd()
557 if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { in ene_send_scsi_cmd()
559 if (us->srb != NULL) in ene_send_scsi_cmd()
560 scsi_set_resid(us->srb, max(scsi_get_resid(us->srb), in ene_send_scsi_cmd()
570 static int do_scsi_request_sense(struct us_data *us, struct scsi_cmnd *srb) in do_scsi_request_sense() argument
572 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in do_scsi_request_sense()
575 memset(buf, 0, 18); in do_scsi_request_sense()
576 buf[0] = 0x70; /* Current error */ in do_scsi_request_sense()
586 static int do_scsi_inquiry(struct us_data *us, struct scsi_cmnd *srb) in do_scsi_inquiry() argument
589 0x00, 0x00, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, in do_scsi_inquiry()
590 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, in do_scsi_inquiry()
591 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, in do_scsi_inquiry()
592 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30 }; in do_scsi_inquiry()
598 static int sd_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_test_unit_ready() argument
600 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in sd_scsi_test_unit_ready()
605 ene_sd_init(us); in sd_scsi_test_unit_ready()
612 static int sd_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_mode_sense() argument
614 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in sd_scsi_mode_sense()
616 0x0b, 0x00, 0x00, 0x08, 0x00, 0x00, in sd_scsi_mode_sense()
617 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 }; in sd_scsi_mode_sense()
619 0x0b, 0x00, 0x80, 0x08, 0x00, 0x00, in sd_scsi_mode_sense()
620 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 }; in sd_scsi_mode_sense()
631 static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_read_capacity() argument
635 unsigned int offset = 0; in sd_scsi_read_capacity()
638 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in sd_scsi_read_capacity()
640 usb_stor_dbg(us, "sd_scsi_read_capacity\n"); in sd_scsi_read_capacity()
642 bl_len = 0x200; in sd_scsi_read_capacity()
653 usb_stor_dbg(us, "bl_len = %x\n", bl_len); in sd_scsi_read_capacity()
654 usb_stor_dbg(us, "bl_num = %x\n", bl_num); in sd_scsi_read_capacity()
657 buf[0] = (bl_num >> 24) & 0xff; in sd_scsi_read_capacity()
658 buf[1] = (bl_num >> 16) & 0xff; in sd_scsi_read_capacity()
659 buf[2] = (bl_num >> 8) & 0xff; in sd_scsi_read_capacity()
660 buf[3] = (bl_num >> 0) & 0xff; in sd_scsi_read_capacity()
661 buf[4] = (bl_len >> 24) & 0xff; in sd_scsi_read_capacity()
662 buf[5] = (bl_len >> 16) & 0xff; in sd_scsi_read_capacity()
663 buf[6] = (bl_len >> 8) & 0xff; in sd_scsi_read_capacity()
664 buf[7] = (bl_len >> 0) & 0xff; in sd_scsi_read_capacity()
671 static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_read() argument
675 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in sd_scsi_read()
676 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in sd_scsi_read()
678 u32 bn = ((cdb[2] << 24) & 0xff000000) | ((cdb[3] << 16) & 0x00ff0000) | in sd_scsi_read()
679 ((cdb[4] << 8) & 0x0000ff00) | ((cdb[5] << 0) & 0x000000ff); in sd_scsi_read()
680 u16 blen = ((cdb[7] << 8) & 0xff00) | ((cdb[8] << 0) & 0x00ff); in sd_scsi_read()
681 u32 bnByte = bn * 0x200; in sd_scsi_read()
682 u32 blenByte = blen * 0x200; in sd_scsi_read()
687 result = ene_load_bincode(us, SD_RW_PATTERN); in sd_scsi_read()
689 usb_stor_dbg(us, "Load SD RW pattern Fail !!\n"); in sd_scsi_read()
697 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in sd_scsi_read()
701 bcb->CDB[0] = 0xF1; in sd_scsi_read()
707 result = ene_send_scsi_cmd(us, FDIR_READ, scsi_sglist(srb), 1); in sd_scsi_read()
711 static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_write() argument
715 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in sd_scsi_write()
716 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in sd_scsi_write()
718 u32 bn = ((cdb[2] << 24) & 0xff000000) | ((cdb[3] << 16) & 0x00ff0000) | in sd_scsi_write()
719 ((cdb[4] << 8) & 0x0000ff00) | ((cdb[5] << 0) & 0x000000ff); in sd_scsi_write()
720 u16 blen = ((cdb[7] << 8) & 0xff00) | ((cdb[8] << 0) & 0x00ff); in sd_scsi_write()
721 u32 bnByte = bn * 0x200; in sd_scsi_write()
722 u32 blenByte = blen * 0x200; in sd_scsi_write()
727 result = ene_load_bincode(us, SD_RW_PATTERN); in sd_scsi_write()
729 usb_stor_dbg(us, "Load SD RW pattern Fail !!\n"); in sd_scsi_write()
737 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in sd_scsi_write()
740 bcb->Flags = 0x00; in sd_scsi_write()
741 bcb->CDB[0] = 0xF0; in sd_scsi_write()
747 result = ene_send_scsi_cmd(us, FDIR_WRITE, scsi_sglist(srb), 1); in sd_scsi_write()
755 static int ms_lib_set_logicalpair(struct us_data *us, u16 logblk, u16 phyblk) in ms_lib_set_logicalpair() argument
757 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_set_logicalpair()
765 return 0; in ms_lib_set_logicalpair()
768 static int ms_lib_set_logicalblockmark(struct us_data *us, u16 phyblk, u16 mark) in ms_lib_set_logicalblockmark() argument
770 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_set_logicalblockmark()
777 return 0; in ms_lib_set_logicalblockmark()
780 static int ms_lib_set_initialerrorblock(struct us_data *us, u16 phyblk) in ms_lib_set_initialerrorblock() argument
782 return ms_lib_set_logicalblockmark(us, phyblk, MS_LB_INITIAL_ERROR); in ms_lib_set_initialerrorblock()
785 static int ms_lib_set_bootblockmark(struct us_data *us, u16 phyblk) in ms_lib_set_bootblockmark() argument
787 return ms_lib_set_logicalblockmark(us, phyblk, MS_LB_BOOT_BLOCK); in ms_lib_set_bootblockmark()
790 static int ms_lib_free_logicalmap(struct us_data *us) in ms_lib_free_logicalmap() argument
792 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_free_logicalmap()
800 return 0; in ms_lib_free_logicalmap()
803 static int ms_lib_alloc_logicalmap(struct us_data *us) in ms_lib_alloc_logicalmap() argument
806 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_alloc_logicalmap()
816 ms_lib_free_logicalmap(us); in ms_lib_alloc_logicalmap()
820 for (i = 0; i < info->MS_Lib.NumberOfPhyBlock; i++) in ms_lib_alloc_logicalmap()
823 for (i = 0; i < info->MS_Lib.NumberOfLogBlock; i++) in ms_lib_alloc_logicalmap()
826 return 0; in ms_lib_alloc_logicalmap()
829 static void ms_lib_clear_writebuf(struct us_data *us) in ms_lib_clear_writebuf() argument
832 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_clear_writebuf()
838 memset(info->MS_Lib.blkpag, 0xff, info->MS_Lib.PagesPerBlock * info->MS_Lib.BytesPerSector); in ms_lib_clear_writebuf()
841 for (i = 0; i < info->MS_Lib.PagesPerBlock; i++) { in ms_lib_clear_writebuf()
850 static int ms_count_freeblock(struct us_data *us, u16 PhyBlock) in ms_count_freeblock() argument
853 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_count_freeblock()
856 for (Count = 0; PhyBlock < Ende; PhyBlock++) { in ms_count_freeblock()
870 static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr, in ms_read_readpage() argument
873 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_read_readpage()
874 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_read_readpage()
877 u32 bn = PhyBlockAddr * 0x20 + PageNum; in ms_read_readpage()
879 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_read_readpage()
884 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_read_readpage()
886 bcb->DataTransferLength = 0x200; in ms_read_readpage()
888 bcb->CDB[0] = 0xF1; in ms_read_readpage()
890 bcb->CDB[1] = 0x02; /* in init.c ENE_MSInit() is 0x01 */ in ms_read_readpage()
897 result = ene_send_scsi_cmd(us, FDIR_READ, PageBuf, 0); in ms_read_readpage()
903 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_read_readpage()
905 bcb->DataTransferLength = 0x4; in ms_read_readpage()
907 bcb->CDB[0] = 0xF1; in ms_read_readpage()
908 bcb->CDB[1] = 0x03; in ms_read_readpage()
914 bcb->CDB[6] = 0x01; in ms_read_readpage()
916 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0); in ms_read_readpage()
920 ExtraDat->reserved = 0; in ms_read_readpage()
921 ExtraDat->intr = 0x80; /* Not yet,fireware support */ in ms_read_readpage()
922 ExtraDat->status0 = 0x10; /* Not yet,fireware support */ in ms_read_readpage()
924 ExtraDat->status1 = 0x00; /* Not yet,fireware support */ in ms_read_readpage()
925 ExtraDat->ovrflg = bbuf[0]; in ms_read_readpage()
932 static int ms_lib_process_bootblock(struct us_data *us, u16 PhyBlock, u8 *PageData) in ms_lib_process_bootblock() argument
940 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_process_bootblock()
979 if (ms_lib_alloc_logicalmap(us)) in ms_lib_process_bootblock()
983 ms_lib_set_bootblockmark(us, PhyBlock); in ms_lib_process_bootblock()
987 for (i = 0; i < MS_NUMBER_OF_SYSTEM_ENTRY; i++) { in ms_lib_process_bootblock()
992 if (EntryOffset == 0xffffff) in ms_lib_process_bootblock()
996 if (EntrySize == 0) in ms_lib_process_bootblock()
1002 if (i == 0) { in ms_lib_process_bootblock()
1003 u8 PrevPageNumber = 0; in ms_lib_process_bootblock()
1009 while (EntrySize > 0) { in ms_lib_process_bootblock()
1013 switch (ms_read_readpage(us, PhyBlock, PageNumber, (u32 *)PageBuffer, &ExtraData)) { in ms_lib_process_bootblock()
1027 if (phyblk < 0x0fff) in ms_lib_process_bootblock()
1028 ms_lib_set_initialerrorblock(us, phyblk); in ms_lib_process_bootblock()
1039 …switch (ms_read_readpage(us, PhyBlock, (u8)(EntryOffset / MS_BYTES_PER_PAGE + 1), (u32 *)PageBuffe… in ms_lib_process_bootblock()
1059 result = 0; in ms_lib_process_bootblock()
1063 ms_lib_free_logicalmap(us); in ms_lib_process_bootblock()
1067 result = 0; in ms_lib_process_bootblock()
1071 static void ms_lib_free_writebuf(struct us_data *us) in ms_lib_free_writebuf() argument
1073 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_free_writebuf()
1076 /* memset((fdoExt)->MS_Lib.pagemap, 0, sizeof((fdoExt)->MS_Lib.pagemap)) */ in ms_lib_free_writebuf()
1078 ms_lib_clear_pagemap(info); /* (pdx)->MS_Lib.pagemap memset 0 in ms.h */ in ms_lib_free_writebuf()
1092 static void ms_lib_free_allocatedarea(struct us_data *us) in ms_lib_free_allocatedarea() argument
1094 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_free_allocatedarea()
1096 ms_lib_free_writebuf(us); /* Free MS_Lib.pagemap */ in ms_lib_free_allocatedarea()
1097 ms_lib_free_logicalmap(us); /* kfree MS_Lib.Phy2LogMap and MS_Lib.Log2PhyMap */ in ms_lib_free_allocatedarea()
1099 /* set struct us point flag to 0 */ in ms_lib_free_allocatedarea()
1100 info->MS_Lib.flags = 0; in ms_lib_free_allocatedarea()
1101 info->MS_Lib.BytesPerSector = 0; in ms_lib_free_allocatedarea()
1102 info->MS_Lib.SectorsPerCylinder = 0; in ms_lib_free_allocatedarea()
1104 info->MS_Lib.cardType = 0; in ms_lib_free_allocatedarea()
1105 info->MS_Lib.blockSize = 0; in ms_lib_free_allocatedarea()
1106 info->MS_Lib.PagesPerBlock = 0; in ms_lib_free_allocatedarea()
1108 info->MS_Lib.NumberOfPhyBlock = 0; in ms_lib_free_allocatedarea()
1109 info->MS_Lib.NumberOfLogBlock = 0; in ms_lib_free_allocatedarea()
1113 static int ms_lib_alloc_writebuf(struct us_data *us) in ms_lib_alloc_writebuf() argument
1115 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_alloc_writebuf()
1127 ms_lib_free_writebuf(us); in ms_lib_alloc_writebuf()
1131 ms_lib_clear_writebuf(us); in ms_lib_alloc_writebuf()
1133 return 0; in ms_lib_alloc_writebuf()
1136 static int ms_lib_force_setlogical_pair(struct us_data *us, u16 logblk, u16 phyblk) in ms_lib_force_setlogical_pair() argument
1138 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_force_setlogical_pair()
1141 return 0; in ms_lib_force_setlogical_pair()
1150 return 0; in ms_lib_force_setlogical_pair()
1153 static int ms_read_copyblock(struct us_data *us, u16 oldphy, u16 newphy, in ms_read_copyblock() argument
1156 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_read_copyblock()
1159 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_read_copyblock()
1163 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_read_copyblock()
1165 bcb->DataTransferLength = 0x200*len; in ms_read_copyblock()
1166 bcb->Flags = 0x00; in ms_read_copyblock()
1167 bcb->CDB[0] = 0xF0; in ms_read_copyblock()
1168 bcb->CDB[1] = 0x08; in ms_read_copyblock()
1171 bcb->CDB[2] = 0; /* (BYTE)(oldphy>>16) */ in ms_read_copyblock()
1174 bcb->CDB[5] = 0; /* (BYTE)(newphy>>16) */ in ms_read_copyblock()
1179 result = ene_send_scsi_cmd(us, FDIR_WRITE, buf, 0); in ms_read_copyblock()
1186 static int ms_read_eraseblock(struct us_data *us, u32 PhyBlockAddr) in ms_read_eraseblock() argument
1188 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_read_eraseblock()
1192 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_read_eraseblock()
1196 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_read_eraseblock()
1198 bcb->DataTransferLength = 0x200; in ms_read_eraseblock()
1200 bcb->CDB[0] = 0xF2; in ms_read_eraseblock()
1201 bcb->CDB[1] = 0x06; in ms_read_eraseblock()
1206 result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); in ms_read_eraseblock()
1213 static int ms_lib_check_disableblock(struct us_data *us, u16 PhyBlock) in ms_lib_check_disableblock() argument
1217 u16 blk, index = 0; in ms_lib_check_disableblock()
1219 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_check_disableblock()
1227 ms_read_readpage(us, PhyBlock, 1, (u32 *)PageBuf, &extdat); in ms_lib_check_disableblock()
1232 if (blk == info->MS_Lib.Log2PhyMap[0]) { in ms_lib_check_disableblock()
1244 static int ms_lib_setacquired_errorblock(struct us_data *us, u16 phyblk) in ms_lib_setacquired_errorblock() argument
1247 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_setacquired_errorblock()
1260 return 0; in ms_lib_setacquired_errorblock()
1263 static int ms_lib_overwrite_extra(struct us_data *us, u32 PhyBlockAddr, in ms_lib_overwrite_extra() argument
1266 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_lib_overwrite_extra()
1269 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_lib_overwrite_extra()
1273 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_lib_overwrite_extra()
1275 bcb->DataTransferLength = 0x4; in ms_lib_overwrite_extra()
1277 bcb->CDB[0] = 0xF2; in ms_lib_overwrite_extra()
1278 bcb->CDB[1] = 0x05; in ms_lib_overwrite_extra()
1284 bcb->CDB[7] = 0xFF; in ms_lib_overwrite_extra()
1285 bcb->CDB[8] = 0xFF; in ms_lib_overwrite_extra()
1286 bcb->CDB[9] = 0xFF; in ms_lib_overwrite_extra()
1288 result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); in ms_lib_overwrite_extra()
1295 static int ms_lib_error_phyblock(struct us_data *us, u16 phyblk) in ms_lib_error_phyblock() argument
1297 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_error_phyblock()
1302 ms_lib_setacquired_errorblock(us, phyblk); in ms_lib_error_phyblock()
1305 return ms_lib_overwrite_extra(us, phyblk, 0, (u8)(~MS_REG_OVR_BKST & BYTE_MASK)); in ms_lib_error_phyblock()
1310 static int ms_lib_erase_phyblock(struct us_data *us, u16 phyblk) in ms_lib_erase_phyblock() argument
1313 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_erase_phyblock()
1326 switch (ms_read_eraseblock(us, phyblk)) { in ms_lib_erase_phyblock()
1332 ms_lib_error_phyblock(us, phyblk); in ms_lib_erase_phyblock()
1336 …fo, MS_LIB_CTRL_RDONLY); /* MS_LibCtrlSet will used by ENE_MSInit ,need check, and why us to info*/ in ms_lib_erase_phyblock()
1337 ms_lib_setacquired_errorblock(us, phyblk); in ms_lib_erase_phyblock()
1342 ms_lib_setacquired_errorblock(us, phyblk); in ms_lib_erase_phyblock()
1347 static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock, in ms_lib_read_extra() argument
1350 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_lib_read_extra()
1351 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_read_extra()
1355 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_lib_read_extra()
1357 bcb->DataTransferLength = 0x4; in ms_lib_read_extra()
1359 bcb->CDB[0] = 0xF1; in ms_lib_read_extra()
1360 bcb->CDB[1] = 0x03; in ms_lib_read_extra()
1365 bcb->CDB[6] = 0x01; in ms_lib_read_extra()
1367 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0); in ms_lib_read_extra()
1371 ExtraDat->reserved = 0; in ms_lib_read_extra()
1372 ExtraDat->intr = 0x80; /* Not yet, waiting for fireware support */ in ms_lib_read_extra()
1373 ExtraDat->status0 = 0x10; /* Not yet, waiting for fireware support */ in ms_lib_read_extra()
1374 ExtraDat->status1 = 0x00; /* Not yet, waiting for fireware support */ in ms_lib_read_extra()
1375 ExtraDat->ovrflg = bbuf[0]; in ms_lib_read_extra()
1382 static int ms_libsearch_block_from_physical(struct us_data *us, u16 phyblk) in ms_libsearch_block_from_physical() argument
1386 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_libsearch_block_from_physical()
1393 if ((blk & MS_PHYSICAL_BLOCKS_PER_SEGMENT_MASK) == 0) in ms_libsearch_block_from_physical()
1399 switch (ms_lib_read_extra(us, blk, 0, &extdat)) { in ms_libsearch_block_from_physical()
1409 ms_lib_setacquired_errorblock(us, blk); in ms_libsearch_block_from_physical()
1414 ms_lib_setacquired_errorblock(us, blk); in ms_libsearch_block_from_physical()
1418 switch (ms_lib_erase_phyblock(us, blk)) { in ms_libsearch_block_from_physical()
1425 ms_lib_error_phyblock(us, blk); in ms_libsearch_block_from_physical()
1433 static int ms_libsearch_block_from_logical(struct us_data *us, u16 logblk) in ms_libsearch_block_from_logical() argument
1436 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_libsearch_block_from_logical()
1448 return ms_libsearch_block_from_physical(us, phyblk); in ms_libsearch_block_from_logical()
1451 static int ms_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_test_unit_ready() argument
1453 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); in ms_scsi_test_unit_ready()
1459 ene_ms_init(us); in ms_scsi_test_unit_ready()
1466 static int ms_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_mode_sense() argument
1468 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_scsi_mode_sense()
1470 0x0b, 0x00, 0x00, 0x08, 0x00, 0x00, in ms_scsi_mode_sense()
1471 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 }; in ms_scsi_mode_sense()
1473 0x0b, 0x00, 0x80, 0x08, 0x00, 0x00, in ms_scsi_mode_sense()
1474 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 }; in ms_scsi_mode_sense()
1484 static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_read_capacity() argument
1488 unsigned int offset = 0; in ms_scsi_read_capacity()
1491 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_scsi_read_capacity()
1493 usb_stor_dbg(us, "ms_scsi_read_capacity\n"); in ms_scsi_read_capacity()
1494 bl_len = 0x200; in ms_scsi_read_capacity()
1501 usb_stor_dbg(us, "bl_len = %x\n", bl_len); in ms_scsi_read_capacity()
1502 usb_stor_dbg(us, "bl_num = %x\n", bl_num); in ms_scsi_read_capacity()
1505 buf[0] = (bl_num >> 24) & 0xff; in ms_scsi_read_capacity()
1506 buf[1] = (bl_num >> 16) & 0xff; in ms_scsi_read_capacity()
1507 buf[2] = (bl_num >> 8) & 0xff; in ms_scsi_read_capacity()
1508 buf[3] = (bl_num >> 0) & 0xff; in ms_scsi_read_capacity()
1509 buf[4] = (bl_len >> 24) & 0xff; in ms_scsi_read_capacity()
1510 buf[5] = (bl_len >> 16) & 0xff; in ms_scsi_read_capacity()
1511 buf[6] = (bl_len >> 8) & 0xff; in ms_scsi_read_capacity()
1512 buf[7] = (bl_len >> 0) & 0xff; in ms_scsi_read_capacity()
1527 *LogStart = 0; in ms_lib_phy_to_log_range()
1532 static int ms_lib_read_extrablock(struct us_data *us, u32 PhyBlock, in ms_lib_read_extrablock() argument
1535 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_lib_read_extrablock()
1539 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_lib_read_extrablock()
1541 bcb->DataTransferLength = 0x4 * blen; in ms_lib_read_extrablock()
1543 bcb->CDB[0] = 0xF1; in ms_lib_read_extrablock()
1544 bcb->CDB[1] = 0x03; in ms_lib_read_extrablock()
1551 result = ene_send_scsi_cmd(us, FDIR_READ, buf, 0); in ms_lib_read_extrablock()
1558 static int ms_lib_scan_logicalblocknumber(struct us_data *us, u16 btBlk1st) in ms_lib_scan_logicalblocknumber() argument
1563 u32 count = 0, index = 0; in ms_lib_scan_logicalblocknumber()
1564 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_scan_logicalblocknumber()
1567 for (PhyBlock = 0; PhyBlock < info->MS_Lib.NumberOfPhyBlock;) { in ms_lib_scan_logicalblocknumber()
1570 for (i = 0; i < MS_PHYSICAL_BLOCKS_PER_SEGMENT; i++, PhyBlock++) { in ms_lib_scan_logicalblocknumber()
1579 ms_lib_read_extrablock(us, PhyBlock, 0, 0x80, in ms_lib_scan_logicalblocknumber()
1581 count += 0x80; in ms_lib_scan_logicalblocknumber()
1583 index = (PhyBlock % 0x80) * 4; in ms_lib_scan_logicalblocknumber()
1591 ms_lib_setacquired_errorblock(us, PhyBlock); in ms_lib_scan_logicalblocknumber()
1596 ms_lib_erase_phyblock(us, PhyBlock); in ms_lib_scan_logicalblocknumber()
1602 ms_lib_erase_phyblock(us, PhyBlock); in ms_lib_scan_logicalblocknumber()
1609 if (extdat.logadr == 0) { in ms_lib_scan_logicalblocknumber()
1610 ms_lib_set_logicalpair(us, extdat.logadr, PhyBlock); in ms_lib_scan_logicalblocknumber()
1611 if (ms_lib_check_disableblock(us, btBlk1st)) { in ms_lib_scan_logicalblocknumber()
1612 ms_lib_set_logicalpair(us, extdat.logadr, newblk); in ms_lib_scan_logicalblocknumber()
1617 ms_lib_read_extra(us, newblk, 0, &extdat); in ms_lib_scan_logicalblocknumber()
1619 ms_lib_erase_phyblock(us, PhyBlock); in ms_lib_scan_logicalblocknumber()
1622 ms_lib_erase_phyblock(us, newblk); in ms_lib_scan_logicalblocknumber()
1626 ms_lib_set_logicalpair(us, extdat.logadr, PhyBlock); in ms_lib_scan_logicalblocknumber()
1635 static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_read() argument
1639 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_scsi_read()
1640 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_scsi_read()
1642 u32 bn = ((cdb[2] << 24) & 0xff000000) | ((cdb[3] << 16) & 0x00ff0000) | in ms_scsi_read()
1643 ((cdb[4] << 8) & 0x0000ff00) | ((cdb[5] << 0) & 0x000000ff); in ms_scsi_read()
1644 u16 blen = ((cdb[7] << 8) & 0xff00) | ((cdb[8] << 0) & 0x00ff); in ms_scsi_read()
1645 u32 blenByte = blen * 0x200; in ms_scsi_read()
1651 result = ene_load_bincode(us, MSP_RW_PATTERN); in ms_scsi_read()
1653 usb_stor_dbg(us, "Load MPS RW pattern Fail !!\n"); in ms_scsi_read()
1658 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_scsi_read()
1662 bcb->CDB[0] = 0xF1; in ms_scsi_read()
1663 bcb->CDB[1] = 0x02; in ms_scsi_read()
1669 result = ene_send_scsi_cmd(us, FDIR_READ, scsi_sglist(srb), 1); in ms_scsi_read()
1672 int offset = 0; in ms_scsi_read()
1682 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_scsi_read()
1699 blkno = phyblk * 0x20 + PageNum; in ms_scsi_read()
1702 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_scsi_read()
1704 bcb->DataTransferLength = 0x200 * len; in ms_scsi_read()
1706 bcb->CDB[0] = 0xF1; in ms_scsi_read()
1707 bcb->CDB[1] = 0x02; in ms_scsi_read()
1713 result = ene_send_scsi_cmd(us, FDIR_READ, buf+offset, 0); in ms_scsi_read()
1721 if (blen <= 0) in ms_scsi_read()
1724 PageNum = 0; in ms_scsi_read()
1734 static int ms_scsi_write(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_write() argument
1737 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ms_scsi_write()
1739 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_scsi_write()
1741 u32 bn = ((cdb[2] << 24) & 0xff000000) | in ms_scsi_write()
1742 ((cdb[3] << 16) & 0x00ff0000) | in ms_scsi_write()
1743 ((cdb[4] << 8) & 0x0000ff00) | in ms_scsi_write()
1744 ((cdb[5] << 0) & 0x000000ff); in ms_scsi_write()
1745 u16 blen = ((cdb[7] << 8) & 0xff00) | ((cdb[8] << 0) & 0x00ff); in ms_scsi_write()
1746 u32 blenByte = blen * 0x200; in ms_scsi_write()
1752 result = ene_load_bincode(us, MSP_RW_PATTERN); in ms_scsi_write()
1759 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ms_scsi_write()
1762 bcb->Flags = 0x00; in ms_scsi_write()
1763 bcb->CDB[0] = 0xF0; in ms_scsi_write()
1764 bcb->CDB[1] = 0x04; in ms_scsi_write()
1770 result = ene_send_scsi_cmd(us, FDIR_WRITE, scsi_sglist(srb), 1); in ms_scsi_write()
1773 int offset = 0; in ms_scsi_write()
1783 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_scsi_write()
1799 oldphy = ms_libconv_to_physical(info, PhyBlockAddr); /* need check us <-> info */ in ms_scsi_write()
1800 newphy = ms_libsearch_block_from_logical(us, PhyBlockAddr); in ms_scsi_write()
1802 result = ms_read_copyblock(us, oldphy, newphy, PhyBlockAddr, PageNum, buf+offset, len); in ms_scsi_write()
1811 ms_lib_force_setlogical_pair(us, PhyBlockAddr, newphy); in ms_scsi_write()
1814 if (blen <= 0) in ms_scsi_write()
1817 PageNum = 0; in ms_scsi_write()
1830 static int ene_get_card_type(struct us_data *us, u16 index, void *buf) in ene_get_card_type() argument
1832 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ene_get_card_type()
1835 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ene_get_card_type()
1837 bcb->DataTransferLength = 0x01; in ene_get_card_type()
1839 bcb->CDB[0] = 0xED; in ene_get_card_type()
1843 result = ene_send_scsi_cmd(us, FDIR_READ, buf, 0); in ene_get_card_type()
1847 static int ene_get_card_status(struct us_data *us, u8 *buf) in ene_get_card_status() argument
1851 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ene_get_card_status()
1853 /*usb_stor_dbg(us, "transport --- ENE_ReadSDReg\n");*/ in ene_get_card_status()
1854 reg4b = *(u32 *)&buf[0x18]; in ene_get_card_status()
1855 info->SD_READ_BL_LEN = (u8)((reg4b >> 8) & 0x0f); in ene_get_card_status()
1858 reg4b = *(u32 *)(&buf[0x14]); in ene_get_card_status()
1860 info->HC_C_SIZE = (reg4b >> 8) & 0x3fffff; in ene_get_card_status()
1862 info->SD_C_SIZE = ((tmpreg & 0x03) << 10) | (u16)(reg4b >> 22); in ene_get_card_status()
1863 info->SD_C_SIZE_MULT = (u8)(reg4b >> 7) & 0x07; in ene_get_card_status()
1865 info->HC_C_SIZE = *(u32 *)(&buf[0x100]); in ene_get_card_status()
1877 static int ene_load_bincode(struct us_data *us, unsigned char flag) in ene_load_bincode() argument
1884 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ene_load_bincode()
1885 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ene_load_bincode()
1893 usb_stor_dbg(us, "SD_INIT1_PATTERN\n"); in ene_load_bincode()
1897 usb_stor_dbg(us, "SD_INIT2_PATTERN\n"); in ene_load_bincode()
1901 usb_stor_dbg(us, "SD_RW_PATTERN\n"); in ene_load_bincode()
1906 usb_stor_dbg(us, "MS_INIT_PATTERN\n"); in ene_load_bincode()
1910 usb_stor_dbg(us, "MSP_RW_PATTERN\n"); in ene_load_bincode()
1914 usb_stor_dbg(us, "MS_RW_PATTERN\n"); in ene_load_bincode()
1918 usb_stor_dbg(us, "----------- Unknown PATTERN ----------\n"); in ene_load_bincode()
1922 err = request_firmware(&sd_fw, fw_name, &us->pusb_dev->dev); in ene_load_bincode()
1924 usb_stor_dbg(us, "load firmware %s failed\n", fw_name); in ene_load_bincode()
1931 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ene_load_bincode()
1934 bcb->Flags = 0x00; in ene_load_bincode()
1935 bcb->CDB[0] = 0xEF; in ene_load_bincode()
1937 result = ene_send_scsi_cmd(us, FDIR_WRITE, buf, 0); in ene_load_bincode()
1938 if (us->srb != NULL) in ene_load_bincode()
1939 scsi_set_resid(us->srb, 0); in ene_load_bincode()
1948 static int ms_card_init(struct us_data *us) in ms_card_init() argument
1956 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_card_init()
1960 ms_lib_free_allocatedarea(us); /* Clean buffer and set struct us_data flag to 0 */ in ms_card_init()
1971 btBlk1stErred = 0; in ms_card_init()
1973 for (TmpBlock = 0; TmpBlock < MS_MAX_INITIAL_ERROR_BLOCKS+2; TmpBlock++) { in ms_card_init()
1975 switch (ms_read_readpage(us, TmpBlock, 0, (u32 *)PageBuffer0, &extdat)) { in ms_card_init()
2016 if (btBlk1stErred == 0) in ms_card_init()
2017 result = ms_lib_process_bootblock(us, btBlk1st, PageBuffer1); in ms_card_init()
2021 result = ms_lib_process_bootblock(us, btBlk2nd, PageBuffer0); in ms_card_init()
2028 for (TmpBlock = 0; TmpBlock < btBlk1st; TmpBlock++) in ms_card_init()
2040 result = ms_lib_scan_logicalblocknumber(us, btBlk1st); in ms_card_init()
2047 if (ms_count_freeblock(us, TmpBlock) == 0) { in ms_card_init()
2054 if (ms_lib_alloc_writebuf(us)) { in ms_card_init()
2069 static int ene_ms_init(struct us_data *us) in ene_ms_init() argument
2071 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ene_ms_init()
2074 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ene_ms_init()
2082 result = ene_load_bincode(us, MS_INIT_PATTERN); in ene_ms_init()
2088 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ene_ms_init()
2090 bcb->DataTransferLength = 0x200; in ene_ms_init()
2092 bcb->CDB[0] = 0xF1; in ene_ms_init()
2093 bcb->CDB[1] = 0x01; in ene_ms_init()
2095 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0); in ene_ms_init()
2101 info->MS_Status = bbuf[0]; in ene_ms_init()
2115 ms_card_init(us); /* Card is MS (to ms.c)*/ in ene_ms_init()
2117 usb_stor_dbg(us, "MS Init Code OK !!\n"); in ene_ms_init()
2119 usb_stor_dbg(us, "MS Card Not Ready --- %x\n", bbuf[0]); in ene_ms_init()
2126 static int ene_sd_init(struct us_data *us) in ene_sd_init() argument
2129 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; in ene_sd_init()
2130 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ene_sd_init()
2133 usb_stor_dbg(us, "transport --- ENE_SDInit\n"); in ene_sd_init()
2135 result = ene_load_bincode(us, SD_INIT1_PATTERN); in ene_sd_init()
2137 usb_stor_dbg(us, "Load SD Init Code Part-1 Fail !!\n"); in ene_sd_init()
2141 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ene_sd_init()
2144 bcb->CDB[0] = 0xF2; in ene_sd_init()
2146 result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); in ene_sd_init()
2148 usb_stor_dbg(us, "Execution SD Init Code Fail !!\n"); in ene_sd_init()
2153 result = ene_load_bincode(us, SD_INIT2_PATTERN); in ene_sd_init()
2155 usb_stor_dbg(us, "Load SD Init Code Part-2 Fail !!\n"); in ene_sd_init()
2159 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); in ene_sd_init()
2161 bcb->DataTransferLength = 0x200; in ene_sd_init()
2163 bcb->CDB[0] = 0xF1; in ene_sd_init()
2165 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0); in ene_sd_init()
2167 usb_stor_dbg(us, "Execution SD Init Code Fail !!\n"); in ene_sd_init()
2171 info->SD_Status = bbuf[0]; in ene_sd_init()
2175 ene_get_card_status(us, bbuf); in ene_sd_init()
2176 usb_stor_dbg(us, "Insert = %x\n", !!(s & SD_Insert)); in ene_sd_init()
2177 usb_stor_dbg(us, "Ready = %x\n", !!(s & SD_Ready)); in ene_sd_init()
2178 usb_stor_dbg(us, "IsMMC = %x\n", !!(s & SD_IsMMC)); in ene_sd_init()
2179 usb_stor_dbg(us, "HiCapacity = %x\n", !!(s & SD_HiCapacity)); in ene_sd_init()
2180 usb_stor_dbg(us, "HiSpeed = %x\n", !!(s & SD_HiSpeed)); in ene_sd_init()
2181 usb_stor_dbg(us, "WtP = %x\n", !!(s & SD_WtP)); in ene_sd_init()
2183 usb_stor_dbg(us, "SD Card Not Ready --- %x\n", bbuf[0]); in ene_sd_init()
2190 static int ene_init(struct us_data *us) in ene_init() argument
2194 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); in ene_init()
2197 result = ene_get_card_type(us, REG_CARD_STATUS, bbuf); in ene_init()
2201 misc_reg03 = bbuf[0]; in ene_init()
2202 if (misc_reg03 & 0x01) { in ene_init()
2204 result = ene_sd_init(us); in ene_init()
2209 if (misc_reg03 & 0x02) { in ene_init()
2211 result = ene_ms_init(us); in ene_init()
2220 static int sd_scsi_irp(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_irp() argument
2223 struct ene_ub6250_info *info = (struct ene_ub6250_info *)us->extra; in sd_scsi_irp()
2225 switch (srb->cmnd[0]) { in sd_scsi_irp()
2227 result = sd_scsi_test_unit_ready(us, srb); in sd_scsi_irp()
2228 break; /* 0x00 */ in sd_scsi_irp()
2230 result = do_scsi_request_sense(us, srb); in sd_scsi_irp()
2231 break; /* 0x03 */ in sd_scsi_irp()
2233 result = do_scsi_inquiry(us, srb); in sd_scsi_irp()
2234 break; /* 0x12 */ in sd_scsi_irp()
2236 result = sd_scsi_mode_sense(us, srb); in sd_scsi_irp()
2237 break; /* 0x1A */ in sd_scsi_irp()
2240 result = SD_SCSI_Start_Stop(us, srb); in sd_scsi_irp()
2241 break; //0x1B in sd_scsi_irp()
2244 result = sd_scsi_read_capacity(us, srb); in sd_scsi_irp()
2245 break; /* 0x25 */ in sd_scsi_irp()
2247 result = sd_scsi_read(us, srb); in sd_scsi_irp()
2248 break; /* 0x28 */ in sd_scsi_irp()
2250 result = sd_scsi_write(us, srb); in sd_scsi_irp()
2251 break; /* 0x2A */ in sd_scsi_irp()
2265 static int ms_scsi_irp(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_irp() argument
2268 struct ene_ub6250_info *info = (struct ene_ub6250_info *)us->extra; in ms_scsi_irp()
2270 switch (srb->cmnd[0]) { in ms_scsi_irp()
2272 result = ms_scsi_test_unit_ready(us, srb); in ms_scsi_irp()
2273 break; /* 0x00 */ in ms_scsi_irp()
2275 result = do_scsi_request_sense(us, srb); in ms_scsi_irp()
2276 break; /* 0x03 */ in ms_scsi_irp()
2278 result = do_scsi_inquiry(us, srb); in ms_scsi_irp()
2279 break; /* 0x12 */ in ms_scsi_irp()
2281 result = ms_scsi_mode_sense(us, srb); in ms_scsi_irp()
2282 break; /* 0x1A */ in ms_scsi_irp()
2284 result = ms_scsi_read_capacity(us, srb); in ms_scsi_irp()
2285 break; /* 0x25 */ in ms_scsi_irp()
2287 result = ms_scsi_read(us, srb); in ms_scsi_irp()
2288 break; /* 0x28 */ in ms_scsi_irp()
2290 result = ms_scsi_write(us, srb); in ms_scsi_irp()
2291 break; /* 0x2A */ in ms_scsi_irp()
2302 static int ene_transport(struct scsi_cmnd *srb, struct us_data *us) in ene_transport() argument
2305 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); in ene_transport()
2307 /*US_DEBUG(usb_stor_show_command(us, srb)); */ in ene_transport()
2308 scsi_set_resid(srb, 0); in ene_transport()
2310 result = ene_init(us); in ene_transport()
2314 result = sd_scsi_irp(us, srb); in ene_transport()
2317 result = ms_scsi_irp(us, srb); in ene_transport()
2329 struct us_data *us; in ene_ub6250_probe() local
2332 result = usb_stor_probe1(&us, intf, id, in ene_ub6250_probe()
2339 us->extra = kzalloc(sizeof(struct ene_ub6250_info), GFP_KERNEL); in ene_ub6250_probe()
2340 if (!us->extra) in ene_ub6250_probe()
2342 us->extra_destructor = ene_ub6250_info_destructor; in ene_ub6250_probe()
2344 info = (struct ene_ub6250_info *)(us->extra); in ene_ub6250_probe()
2347 kfree(us->extra); in ene_ub6250_probe()
2351 us->transport_name = "ene_ub6250"; in ene_ub6250_probe()
2352 us->transport = ene_transport; in ene_ub6250_probe()
2353 us->max_lun = 0; in ene_ub6250_probe()
2355 result = usb_stor_probe2(us); in ene_ub6250_probe()
2360 result = ene_get_card_type(us, REG_CARD_STATUS, info->bbuf); in ene_ub6250_probe()
2366 misc_reg03 = info->bbuf[0]; in ene_ub6250_probe()
2367 if (!(misc_reg03 & 0x01)) { in ene_ub6250_probe()
2380 struct us_data *us = usb_get_intfdata(iface); in ene_ub6250_resume() local
2381 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); in ene_ub6250_resume()
2383 mutex_lock(&us->dev_mutex); in ene_ub6250_resume()
2385 if (us->suspend_resume_hook) in ene_ub6250_resume()
2386 (us->suspend_resume_hook)(us, US_RESUME); in ene_ub6250_resume()
2388 mutex_unlock(&us->dev_mutex); in ene_ub6250_resume()
2392 info->SD_Status = 0; in ene_ub6250_resume()
2393 info->MS_Status = 0; in ene_ub6250_resume()
2394 info->SM_Status = 0; in ene_ub6250_resume()
2396 return 0; in ene_ub6250_resume()
2401 struct us_data *us = usb_get_intfdata(iface); in ene_ub6250_reset_resume() local
2402 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); in ene_ub6250_reset_resume()
2413 info->SD_Status = 0; in ene_ub6250_reset_resume()
2414 info->MS_Status = 0; in ene_ub6250_reset_resume()
2415 info->SM_Status = 0; in ene_ub6250_reset_resume()
2417 return 0; in ene_ub6250_reset_resume()