Lines Matching full:us
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()
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()
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()
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()
586 static int do_scsi_inquiry(struct us_data *us, struct scsi_cmnd *srb) in do_scsi_inquiry() argument
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()
631 static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) in sd_scsi_read_capacity() argument
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
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()
879 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_read_readpage()
897 result = ene_send_scsi_cmd(us, FDIR_READ, PageBuf, 0); in ms_read_readpage()
916 result = ene_send_scsi_cmd(us, FDIR_READ, 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()
1013 switch (ms_read_readpage(us, PhyBlock, PageNumber, (u32 *)PageBuffer, &ExtraData)) { 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()
1063 ms_lib_free_logicalmap(us); 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()
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()
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()
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()
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()
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()
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
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()
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()
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()
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()
1367 result = ene_send_scsi_cmd(us, FDIR_READ, 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()
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()
1484 static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb) in ms_scsi_read_capacity() argument
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()
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()
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()
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
1564 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; in ms_lib_scan_logicalblocknumber()
1579 ms_lib_read_extrablock(us, PhyBlock, 0, 0x80, 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()
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()
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()
1669 result = ene_send_scsi_cmd(us, FDIR_READ, scsi_sglist(srb), 1); in ms_scsi_read()
1682 result = ene_load_bincode(us, MS_RW_PATTERN); in ms_scsi_read()
1713 result = ene_send_scsi_cmd(us, FDIR_READ, buf+offset, 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()
1752 result = ene_load_bincode(us, MSP_RW_PATTERN); in ms_scsi_write()
1770 result = ene_send_scsi_cmd(us, FDIR_WRITE, scsi_sglist(srb), 1); 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()
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()
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()
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()
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()
1975 switch (ms_read_readpage(us, TmpBlock, 0, (u32 *)PageBuffer0, &extdat)) { 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()
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()
2095 result = ene_send_scsi_cmd(us, FDIR_READ, 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()
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()
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()
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()
2204 result = ene_sd_init(us); 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()
2227 result = sd_scsi_test_unit_ready(us, srb); in sd_scsi_irp()
2230 result = do_scsi_request_sense(us, srb); in sd_scsi_irp()
2233 result = do_scsi_inquiry(us, srb); in sd_scsi_irp()
2236 result = sd_scsi_mode_sense(us, srb); in sd_scsi_irp()
2240 result = SD_SCSI_Start_Stop(us, srb); in sd_scsi_irp()
2244 result = sd_scsi_read_capacity(us, srb); in sd_scsi_irp()
2247 result = sd_scsi_read(us, srb); in sd_scsi_irp()
2250 result = sd_scsi_write(us, srb); 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()
2272 result = ms_scsi_test_unit_ready(us, srb); in ms_scsi_irp()
2275 result = do_scsi_request_sense(us, srb); in ms_scsi_irp()
2278 result = do_scsi_inquiry(us, srb); in ms_scsi_irp()
2281 result = ms_scsi_mode_sense(us, srb); in ms_scsi_irp()
2284 result = ms_scsi_read_capacity(us, srb); in ms_scsi_irp()
2287 result = ms_scsi_read(us, srb); in ms_scsi_irp()
2290 result = ms_scsi_write(us, srb); 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()
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()
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()
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()