Staging: Merge ENE UB6250 SD card codes from keucr to drivers/usb/storage

The usb portion of this driver can now go into drivers/usb/storage.
This leaves the non-usb portion of the code still in staging.

Signed-off-by: Huajun Li <huajun.li.lee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
huajun li 2011-03-04 10:56:18 +08:00 committed by Greg Kroah-Hartman
parent 153775d948
commit 41e568d14e
13 changed files with 876 additions and 1112 deletions

View File

@ -1,8 +1,9 @@
config USB_ENESTORAGE
tristate "USB ENE card reader support"
tristate "USB ENE SM/MS card reader support"
depends on USB && SCSI && m
---help---
Say Y here if you wish to control a ENE Card reader.
Say Y here if you wish to control a ENE SM/MS Card reader.
To use SD card, please build driver/usb/storage/ums-eneub6250.ko
This option depends on 'SCSI' support being enabled, but you
probably also need 'SCSI device support: SCSI disk support'

View File

@ -7,7 +7,6 @@ keucr-y := \
scsiglue.o \
transport.o \
init.o \
sdscsi.o \
msscsi.o \
ms.o \
smscsi.o \

View File

@ -30,14 +30,6 @@ int ENE_InitMedia(struct us_data *us)
}
printk(KERN_INFO "MiscReg03 = %x\n", MiscReg03);
if (MiscReg03 & 0x01) {
if (!us->SD_Status.Ready) {
result = ENE_SDInit(us);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
}
}
if (MiscReg03 & 0x02) {
if (!us->SM_Status.Ready && !us->MS_Status.Ready) {
result = ENE_SMInit(us);
@ -72,69 +64,6 @@ int ENE_Read_BYTE(struct us_data *us, WORD index, void *buf)
return result;
}
/*
* ENE_SDInit():
*/
int ENE_SDInit(struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
BYTE buf[0x200];
printk(KERN_INFO "transport --- ENE_SDInit\n");
/* SD Init Part-1 */
result = ENE_LoadBinCode(us, SD_INIT1_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
printk(KERN_ERR "Load SD Init Code Part-1 Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF2;
result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
if (result != USB_STOR_XFER_GOOD) {
printk(KERN_ERR "Exection SD Init Code Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* SD Init Part-2 */
result = ENE_LoadBinCode(us, SD_INIT2_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
printk(KERN_ERR "Load SD Init Code Part-2 Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = 0x200;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0);
if (result != USB_STOR_XFER_GOOD) {
printk(KERN_ERR "Exection SD Init Code Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
us->SD_Status = *(PSD_STATUS)&buf[0];
if (us->SD_Status.Insert && us->SD_Status.Ready) {
ENE_ReadSDReg(us, (PBYTE)&buf);
printk(KERN_INFO "Insert = %x\n", us->SD_Status.Insert);
printk(KERN_INFO "Ready = %x\n", us->SD_Status.Ready);
printk(KERN_INFO "IsMMC = %x\n", us->SD_Status.IsMMC);
printk(KERN_INFO "HiCapacity = %x\n", us->SD_Status.HiCapacity);
printk(KERN_INFO "HiSpeed = %x\n", us->SD_Status.HiSpeed);
printk(KERN_INFO "WtP = %x\n", us->SD_Status.WtP);
} else {
printk(KERN_ERR "SD Card Not Ready --- %x\n", buf[0]);
return USB_STOR_TRANSPORT_ERROR;
}
return USB_STOR_TRANSPORT_GOOD;
}
/*
* ENE_MSInit():
*/
@ -241,38 +170,6 @@ int ENE_SMInit(struct us_data *us)
return USB_STOR_TRANSPORT_GOOD;
}
/*
* ENE_ReadSDReg()
*/
int ENE_ReadSDReg(struct us_data *us, u8 *RdBuf)
{
WORD tmpreg;
DWORD reg4b;
/* printk(KERN_INFO "transport --- ENE_ReadSDReg\n"); */
reg4b = *(PDWORD)&RdBuf[0x18];
us->SD_READ_BL_LEN = (BYTE)((reg4b >> 8) & 0x0f);
tmpreg = (WORD) reg4b;
reg4b = *(PDWORD)(&RdBuf[0x14]);
if (us->SD_Status.HiCapacity && !us->SD_Status.IsMMC)
us->HC_C_SIZE = (reg4b >> 8) & 0x3fffff;
us->SD_C_SIZE = ((tmpreg & 0x03) << 10) | (WORD)(reg4b >> 22);
us->SD_C_SIZE_MULT = (BYTE)(reg4b >> 7) & 0x07;
if (us->SD_Status.HiCapacity && us->SD_Status.IsMMC)
us->HC_C_SIZE = *(PDWORD)(&RdBuf[0x100]);
if (us->SD_READ_BL_LEN > SD_BLOCK_LEN) {
us->SD_Block_Mult =
1 << (us->SD_READ_BL_LEN - SD_BLOCK_LEN);
us->SD_READ_BL_LEN = SD_BLOCK_LEN;
} else {
us->SD_Block_Mult = 1;
}
return USB_STOR_TRANSPORT_GOOD;
}
/*
* ENE_LoadBinCode()
*/
@ -291,19 +188,6 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
switch (flag) {
/* For SD */
case SD_INIT1_PATTERN:
printk(KERN_INFO "SD_INIT1_PATTERN\n");
memcpy(buf, SD_Init1, 0x800);
break;
case SD_INIT2_PATTERN:
printk(KERN_INFO "SD_INIT2_PATTERN\n");
memcpy(buf, SD_Init2, 0x800);
break;
case SD_RW_PATTERN:
printk(KERN_INFO "SD_RW_PATTERN\n");
memcpy(buf, SD_Rdwr, 0x800);
break;
/* For MS */
case MS_INIT_PATTERN:
printk(KERN_INFO "MS_INIT_PATTERN\n");
@ -412,8 +296,9 @@ int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg)
*/
if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
residue = min(residue, transfer_length);
scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
(int) residue));
if (us->srb)
scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
(int) residue));
}
if (bcs->Status != US_BULK_STAT_OK)
@ -558,4 +443,3 @@ void usb_stor_print_cmd(struct scsi_cmnd *srb)
blen = 0;
}

View File

@ -3,779 +3,6 @@
extern DWORD MediaChange;
extern int Check_D_MediaFmt(struct us_data *);
BYTE SD_Init1[] = {
0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90,
0xFF, 0x23, 0x74, 0x80, 0xF0, 0x90, 0xFF, 0x09,
0xE0, 0x30, 0xE5, 0xFC, 0x90, 0xFF, 0x83, 0xE0,
0xA2, 0xE0, 0x92, 0x14, 0x20, 0x14, 0x0A, 0xC2,
0x0F, 0xD2, 0x10, 0xC2, 0x17, 0xC3, 0x02, 0xE3,
0x13, 0x7F, 0x03, 0x12, 0x2F, 0xCB, 0x7E, 0x00,
0x7F, 0x10, 0x12, 0xE3, 0xFA, 0x90, 0xFE, 0x07,
0xE0, 0x54, 0xBA, 0xF0, 0x75, 0x16, 0x00, 0x75,
0x17, 0x00, 0x90, 0xFE, 0x05, 0x74, 0x80, 0xF0,
0x90, 0xFE, 0x07, 0x74, 0x80, 0xF0, 0x7F, 0x32,
0x7E, 0x00, 0x12, 0xE3, 0xFA, 0x90, 0xFE, 0x05,
0xE0, 0x44, 0x01, 0xF0, 0xE0, 0x44, 0x08, 0xF0,
0x7F, 0x32, 0x7E, 0x00, 0x12, 0xE3, 0xFA, 0x90,
0xFE, 0x05, 0xE0, 0x54, 0xF7, 0xF0, 0x7F, 0x32,
0x7E, 0x00, 0x12, 0xE3, 0xFA, 0x90, 0xFF, 0x81,
0xE0, 0xC2, 0xE3, 0xF0, 0xE0, 0x54, 0xCF, 0x44,
0x20, 0xD2, 0xE3, 0xF0, 0x90, 0xFF, 0x84, 0xE0,
0x54, 0x1F, 0x44, 0x40, 0xF0, 0x90, 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0x22, 0x50, 0x02, 0x21, 0xED, 0x90, 0xFF, 0x83,
0xE0, 0xA2, 0xE0, 0x92, 0x14, 0x20, 0x14, 0x03,
0x02, 0xE2, 0xFC, 0x30, 0x13, 0x02, 0x80, 0x17,
0x78, 0x37, 0x79, 0x50, 0x7A, 0x00, 0x7B, 0x00,
0x7C, 0x00, 0x7D, 0x00, 0x12, 0xE3, 0x22, 0x50,
0x02, 0x80, 0x7A, 0x78, 0x69, 0x80, 0x02, 0x78,
0x01, 0x79, 0x2A, 0x7A, 0x80, 0x30, 0x17, 0x02,
0x7A, 0x40, 0x7B, 0x70, 0x7C, 0x00, 0x7D, 0x00,
0x12, 0xE3, 0x22, 0x50, 0x16, 0x90, 0xFE, 0x04,
0xE0, 0x44, 0x06, 0xF0, 0x90, 0xFE, 0x04, 0x30,
0x14, 0x06, 0xE0, 0x70, 0xFA, 0xD3, 0x80, 0x01,
0xC3, 0x80, 0x4A, 0x90, 0xFE, 0x20, 0xE0, 0x54,
0x00, 0xB4, 0x00, 0x23, 0x90, 0xFE, 0x21, 0xE0,
0x54, 0x00, 0xB4, 0x00, 0x1A, 0x90, 0xFE, 0x22,
0xE0, 0x54, 0x70, 0xB4, 0x70, 0x11, 0x90, 0xFE,
0x23, 0xE0, 0x30, 0xE7, 0x0A, 0x30, 0x17, 0x05,
0x20, 0xE6, 0x02, 0xC2, 0x17, 0x41, 0x02, 0xC3,
0xEF, 0x94, 0x01, 0xFF, 0xEE, 0x94, 0x00, 0xFE,
0xC0, 0x06, 0xC0, 0x07, 0x7F, 0x64, 0x7E, 0x00,
0x12, 0xE3, 0xFA, 0xD0, 0x07, 0xD0, 0x06, 0xEE,
0x4F, 0x60, 0x02, 0x21, 0x4D, 0x7F, 0x64, 0x7E,
0x00, 0x12, 0xE3, 0xFA, 0xB2, 0x17, 0x30, 0x17,
0x07, 0xB2, 0x13, 0x20, 0x13, 0x02, 0x01, 0xFE,
0x21, 0x0C, 0x78, 0x02, 0x79, 0x2D, 0x12, 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
0x2F, 0x8C, 0x40, 0x03, 0x02, 0xE4, 0x45, 0x90,
0xEA, 0x49, 0xE5, 0x14, 0xF0, 0x05, 0x14, 0x02,
0xE2, 0xDC, 0xD2, 0x22, 0x90, 0xEA, 0x49, 0xE0,
0x64, 0xFF, 0x70, 0x02, 0x80, 0x02, 0x80, 0x12,
0x90, 0xFE, 0x44, 0x74, 0x02, 0xF0, 0x30, 0x25,
0x04, 0xE0, 0x20, 0xE1, 0xF9, 0x12, 0x2F, 0x9E,
0xC3, 0x22, 0x30, 0x3F, 0x36, 0x74, 0x88, 0x90,
0xEA, 0x44, 0xF0, 0x75, 0x17, 0x00, 0x79, 0x00,
0x7A, 0x00, 0x7B, 0x10, 0x7C, 0x02, 0x7D, 0x02,
0x12, 0x2F, 0xA7, 0x7F, 0x80, 0x12, 0x2F, 0xC5,
0x90, 0xFE, 0x45, 0xE0, 0x54, 0xFE, 0xF0, 0x90,
0xFE, 0x45, 0xE0, 0x44, 0x04, 0xF0, 0x90, 0xFE,
0x44, 0x74, 0x02, 0xF0, 0x30, 0x25, 0x04, 0xE0,
0x20, 0xE1, 0xF9, 0xD3, 0x22, 0x75, 0x8A, 0x00,
0x75, 0x8C, 0xCE, 0xC2, 0x8D, 0x90, 0xEA, 0x65,
0xE4, 0xF0, 0xA3, 0xF0, 0xD2, 0x8C, 0x90, 0xEA,
0x65, 0xE0, 0xFC, 0xA3, 0xE0, 0xFD, 0xEC, 0xC3,
0x9E, 0x40, 0xF3, 0x70, 0x05, 0xED, 0xC3, 0x9F,
0x40, 0xEC, 0xC2, 0x8C, 0x22, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x53, 0x44, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x31,
0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };
BYTE SD_Init2[] = {
0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90,
0xFF, 0x23, 0x74, 0x80, 0xF0, 0x90, 0xFF, 0x09,
0xE0, 0x30, 0xE5, 0xFC, 0x90, 0xFF, 0x83, 0xE0,
0xA2, 0xE0, 0x92, 0x14, 0x20, 0x14, 0x0A, 0xC2,
0x0F, 0xD2, 0x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xC3, 0x80, 0x01, 0xD3,
0x40, 0x03, 0x02, 0xE5, 0x5B, 0x90, 0xFE, 0xCC,
0xE0, 0x44, 0x80, 0xF0, 0x90, 0xF4, 0x0D, 0xE0,
0x90, 0xF4, 0x10, 0xE0, 0x64, 0x0F, 0x60, 0x03,
0xD3, 0x80, 0x01, 0xC3, 0x22, 0xC0, 0x04, 0xC0,
0x05, 0x8E, 0x83, 0x8F, 0x82, 0xEB, 0x60, 0x17,
0xC0, 0x82, 0xC0, 0x83, 0x8C, 0x83, 0x8D, 0x82,
0xE0, 0xA3, 0xAC, 0x83, 0xAD, 0x82, 0xD0, 0x83,
0xD0, 0x82, 0xF0, 0xA3, 0x1B, 0x80, 0xE6, 0xD0,
0x05, 0xD0, 0x04, 0x22, 0x75, 0x8A, 0x00, 0x75,
0x8C, 0xCE, 0xC2, 0x8D, 0x90, 0xEA, 0x65, 0xE4,
0xF0, 0xA3, 0xF0, 0xD2, 0x8C, 0x90, 0xEA, 0x65,
0xE0, 0xFC, 0xA3, 0xE0, 0xFD, 0xEC, 0xC3, 0x9E,
0x40, 0xF3, 0x70, 0x05, 0xED, 0xC3, 0x9F, 0x40,
0xEC, 0xC2, 0x8C, 0x22, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x53, 0x44, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x32,
0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };
BYTE SD_Rdwr[] = {
0x90, 0xF0, 0x11, 0xE0, 0x90, 0xEB, 0x2A, 0xF0,
0x90, 0xF0, 0x12, 0xE0, 0x90, 0xEB, 0x2B, 0xF0,
0x90, 0xF0, 0x13, 0xE0, 0x90, 0xEB, 0x2C, 0xF0,
0x90, 0xF0, 0x14, 0xE0, 0x90, 0xEB, 0x2D, 0xF0,
0x90, 0xFF, 0x83, 0xE0, 0xA2, 0xE0, 0x92, 0x14,
0x30, 0x14, 0x3E, 0x30, 0x0F, 0x3B, 0x90, 0xEB,
0x2A, 0xE0, 0xF5, 0x10, 0xA3, 0xE0, 0xF5, 0x11,
0xA3, 0xE0, 0xF5, 0x12, 0xA3, 0xE0, 0xF5, 0x13,
0xC3, 0xE5, 0x3D, 0x13, 0xF5, 0x14, 0xE5, 0x3E,
0x13, 0xF5, 0x15, 0x85, 0x14, 0x16, 0x85, 0x15,
0x17, 0x90, 0xF0, 0x0C, 0xE0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0xFA, 0x30, 0x14, 0x07, 0x90, 0xFE, 0x12, 0xE0,
0x30, 0xE4, 0xF6, 0x20, 0x14, 0x03, 0x02, 0xE1,
0xFA, 0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE5, 0xFC,
0x90, 0xFE, 0xC8, 0x74, 0x01, 0xF0, 0x90, 0xFE,
0xC4, 0xE0, 0x44, 0x01, 0xF0, 0xC3, 0xE5, 0x17,
0x94, 0x01, 0xF5, 0x17, 0xE5, 0x16, 0x94, 0x00,
0xF5, 0x16, 0x45, 0x17, 0x60, 0x42, 0x30, 0x14,
0x10, 0x90, 0xFE, 0xC8, 0xE0, 0x64, 0x01, 0x60,
0x11, 0x90, 0xFE, 0x10, 0xE0, 0x54, 0x0A, 0x60,
0xED, 0x90, 0xFE, 0xD8, 0x74, 0x01, 0xF0, 0xC3,
0x80, 0x01, 0xD3, 0x40, 0x03, 0x02, 0xE1, 0xFA,
0x90, 0xFF, 0x2A, 0x74, 0x02, 0xF0, 0xA3, 0x74,
0x00, 0xF0, 0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE5,
0xFC, 0x90, 0xFE, 0xC8, 0x74, 0x01, 0xF0, 0x90,
0xFE, 0xC4, 0xE0, 0x44, 0x01, 0xF0, 0x80, 0xAD,
0x30, 0x14, 0x10, 0x90, 0xFE, 0xC8, 0xE0, 0x64,
0x01, 0x60, 0x11, 0x90, 0xFE, 0x10, 0xE0, 0x54,
0x0A, 0x60, 0xED, 0x90, 0xFE, 0xD8, 0x74, 0x01,
0xF0, 0xC3, 0x80, 0x01, 0xD3, 0x40, 0x03, 0x02,
0xE1, 0xFA, 0x90, 0xFF, 0x2A, 0x74, 0x02, 0xF0,
0xA3, 0x74, 0x00, 0xF0, 0xE5, 0x15, 0x64, 0x01,
0x45, 0x14, 0x60, 0x29, 0x90, 0xFF, 0x09, 0xE0,
0x30, 0xE5, 0xFC, 0x78, 0x8C, 0x79, 0x50, 0x12,
0xE3, 0xEA, 0x50, 0x03, 0x02, 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 0xFE,
0xCC, 0xE0, 0x54, 0x7F, 0xF0, 0x78, 0x10, 0x79,
0x50, 0x7A, 0x00, 0x7B, 0x00, 0x7C, 0x02, 0x7D,
0x00, 0x12, 0xE3, 0xEA, 0x50, 0x03, 0x02, 0xE3,
0x9E, 0x12, 0xE4, 0x44, 0x50, 0x03, 0x02, 0xE3,
0x9E, 0xAD, 0x13, 0xAC, 0x12, 0xAB, 0x11, 0xAA,
0x10, 0x80, 0x10, 0x74, 0x00, 0xFD, 0xC3, 0xE5,
0x13, 0x33, 0xFC, 0xE5, 0x12, 0x33, 0xFB, 0xE5,
0x11, 0x33, 0xFA, 0xE5, 0x15, 0x64, 0x01, 0x45,
0x14, 0x70, 0x0E, 0x78, 0x18, 0x79, 0x68, 0x12,
0xE3, 0xEA, 0x50, 0x03, 0x02, 0xE3, 0x9E, 0x80,
0x0C, 0x78, 0x19, 0x79, 0x68, 0x12, 0xE3, 0xEA,
0x50, 0x03, 0x02, 0xE3, 0x9E, 0x12, 0xE4, 0x44,
0x50, 0x03, 0x02, 0xE3, 0x9E, 0x75, 0x1F, 0x01,
0x20, 0x2D, 0x03, 0x75, 0x1F, 0x08, 0xE5, 0x16,
0x45, 0x17, 0x70, 0x03, 0x02, 0xE3, 0x6B, 0x85,
0x1F, 0x1E, 0x30, 0x14, 0x3C, 0x90, 0xFF, 0x09,
0x30, 0x14, 0x04, 0xE0, 0x30, 0xE1, 0xF9, 0x90,
0xFE, 0xC8, 0x74, 0x01, 0xF0, 0x90, 0xFE, 0xC4,
0xE0, 0x44, 0x01, 0xF0, 0x30, 0x14, 0x10, 0x90,
0xFE, 0xC8, 0xE0, 0x64, 0x01, 0x60, 0x11, 0x90,
0xFE, 0x10, 0xE0, 0x54, 0x0A, 0x60, 0xED, 0x90,
0xFE, 0xD8, 0x74, 0x01, 0xF0, 0xC3, 0x80, 0x01,
0xD3, 0x40, 0x03, 0x02, 0xE3, 0x9E, 0x90, 0xFE,
0x12, 0x30, 0x14, 0x2A, 0xE0, 0x30, 0xE1, 0xF9,
0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90,
0xFF, 0x23, 0x74, 0x80, 0xF0, 0x15, 0x1E, 0xE5,
0x1E, 0x70, 0xA7, 0xC3, 0xE5, 0x17, 0x94, 0x01,
0xF5, 0x17, 0xE5, 0x16, 0x94, 0x00, 0xF5, 0x16,
0x02, 0xE2, 0xF6, 0x90, 0xFE, 0x12, 0x30, 0x14,
0x2D, 0xE0, 0x20, 0xE4, 0xF9, 0xE5, 0x15, 0x64,
0x01, 0x45, 0x14, 0x60, 0x58, 0x78, 0x8C, 0x79,
0x50, 0x12, 0xE3, 0xEA, 0x50, 0x03, 0x02, 0xE3,
0x9E, 0x12, 0xE4, 0x44, 0x50, 0x03, 0x02, 0xE3,
0x9E, 0x30, 0x14, 0x41, 0x90, 0xFE, 0x12, 0xE0,
0x20, 0xE4, 0xF6, 0x02, 0xE3, 0xD5, 0x30, 0x14,
0x14, 0x90, 0xFE, 0x04, 0xE0, 0x44, 0x06, 0xF0,
0x90, 0xFE, 0x04, 0x30, 0x14, 0x06, 0xE0, 0x70,
0xFA, 0xD3, 0x80, 0x01, 0xC3, 0x90, 0xFE, 0xD8,
0x74, 0x01, 0xF0, 0x90, 0xFE, 0xCC, 0xE0, 0x44,
0x80, 0xF0, 0x75, 0x3F, 0x00, 0xC3, 0xE5, 0x17,
0x33, 0xF5, 0x3E, 0xE5, 0x16, 0x33, 0xF5, 0x3D,
0x75, 0x3C, 0x00, 0xC3, 0x22, 0x90, 0xFE, 0xCC,
0xE0, 0x44, 0x80, 0xF0, 0x75, 0x3C, 0x00, 0x75,
0x3D, 0x00, 0x75, 0x3E, 0x00, 0x75, 0x3F, 0x00,
0xD3, 0x22, 0xE8, 0x90, 0xFE, 0x15, 0xF0, 0xE9,
0x90, 0xFE, 0x14, 0xF0, 0xED, 0x90, 0xFE, 0x18,
0xF0, 0xEC, 0x90, 0xFE, 0x19, 0xF0, 0xEB, 0x90,
0xFE, 0x1A, 0xF0, 0xEA, 0x90, 0xFE, 0x1B, 0xF0,
0x74, 0xFF, 0x90, 0xFE, 0x10, 0xF0, 0x90, 0xFE,
0x11, 0xF0, 0x90, 0xFE, 0x12, 0xF0, 0xE8, 0x54,
0x80, 0xFE, 0x90, 0xFE, 0x04, 0x74, 0x01, 0xF0,
0x30, 0x14, 0x08, 0x90, 0xFE, 0x10, 0xE0, 0x54,
0x05, 0x60, 0x02, 0xD3, 0x22, 0x90, 0xFE, 0x11,
0xE0, 0x30, 0xE0, 0xEC, 0xBE, 0x80, 0x03, 0x30,
0xE1, 0xE6, 0x90, 0xFE, 0x10, 0xE0, 0x54, 0x05,
0x70, 0xE9, 0xC3, 0x22, 0x30, 0x13, 0x02, 0xC3,
0x22, 0x90, 0xFE, 0x22, 0xE0, 0x70, 0x06, 0x90,
0xFE, 0x23, 0xE0, 0x60, 0x02, 0xD3, 0x22, 0xC3,
0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x53, 0x44, 0x2D, 0x52, 0x57, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };
BYTE MS_Init[] = {
0x90, 0xF0, 0x15, 0xE0, 0xF5, 0x1C, 0x11, 0x2C,

View File

@ -1,210 +0,0 @@
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_device.h>
#include "usb.h"
#include "scsiglue.h"
#include "transport.h"
int SD_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Inquiry (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Mode_Sense (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Start_Stop (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Read_Capacity (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Read (struct us_data *us, struct scsi_cmnd *srb);
int SD_SCSI_Write (struct us_data *us, struct scsi_cmnd *srb);
//----- SD_SCSIIrp() --------------------------------------------------
int SD_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
us->SrbStatus = SS_SUCCESS;
switch (srb->cmnd[0])
{
case TEST_UNIT_READY : result = SD_SCSI_Test_Unit_Ready (us, srb); break; //0x00
case INQUIRY : result = SD_SCSI_Inquiry (us, srb); break; //0x12
case MODE_SENSE : result = SD_SCSI_Mode_Sense (us, srb); break; //0x1A
// case START_STOP : result = SD_SCSI_Start_Stop (us, srb); break; //0x1B
case READ_CAPACITY : result = SD_SCSI_Read_Capacity (us, srb); break; //0x25
case READ_10 : result = SD_SCSI_Read (us, srb); break; //0x28
case WRITE_10 : result = SD_SCSI_Write (us, srb); break; //0x2A
default:
us->SrbStatus = SS_ILLEGAL_REQUEST;
result = USB_STOR_TRANSPORT_FAILED;
break;
}
return result;
}
//----- SD_SCSI_Test_Unit_Ready() --------------------------------------------------
int SD_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("SD_SCSI_Test_Unit_Ready\n");
if (us->SD_Status.Insert && us->SD_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
else
{
ENE_SDInit(us);
return USB_STOR_TRANSPORT_GOOD;
}
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Inquiry() --------------------------------------------------
int SD_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
//printk("SD_SCSI_Inquiry\n");
BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Mode_Sense() --------------------------------------------------
int SD_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
{
BYTE mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
BYTE mediaWP[12] = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
if (us->SD_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
else
usb_stor_set_xfer_buf(us, mediaNoWP, 12, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Read_Capacity() --------------------------------------------------
int SD_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
struct scatterlist *sg = NULL;
DWORD bl_num;
WORD bl_len;
BYTE buf[8];
printk("SD_SCSI_Read_Capacity\n");
if ( us->SD_Status.HiCapacity )
{
bl_len = 0x200;
if (us->SD_Status.IsMMC)
bl_num = us->HC_C_SIZE-1;
else
bl_num = (us->HC_C_SIZE + 1) * 1024 - 1;
}
else
{
bl_len = 1<<(us->SD_READ_BL_LEN);
bl_num = us->SD_Block_Mult*(us->SD_C_SIZE+1)*(1<<(us->SD_C_SIZE_MULT+2)) - 1;
}
us->bl_num = bl_num;
printk("bl_len = %x\n", bl_len);
printk("bl_num = %x\n", bl_num);
//srb->request_bufflen = 8;
buf[0] = (bl_num>>24) & 0xff;
buf[1] = (bl_num>>16) & 0xff;
buf[2] = (bl_num>> 8) & 0xff;
buf[3] = (bl_num>> 0) & 0xff;
buf[4] = (bl_len>>24) & 0xff;
buf[5] = (bl_len>>16) & 0xff;
buf[6] = (bl_len>> 8) & 0xff;
buf[7] = (bl_len>> 0) & 0xff;
usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
//usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
//----- SD_SCSI_Read() --------------------------------------------------
int SD_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD bnByte = bn * 0x200;
DWORD blenByte = blen * 0x200;
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
result = ENE_LoadBinCode(us, SD_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load SD RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
if ( us->SD_Status.HiCapacity )
bnByte = bn;
// set up the command wrapper
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[5] = (BYTE)(bnByte);
bcb->CDB[4] = (BYTE)(bnByte>>8);
bcb->CDB[3] = (BYTE)(bnByte>>16);
bcb->CDB[2] = (BYTE)(bnByte>>24);
result = ENE_SendScsiCmd(us, FDIR_READ, scsi_sglist(srb), 1);
return result;
}
//----- SD_SCSI_Write() --------------------------------------------------
int SD_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
PBYTE Cdb = srb->cmnd;
DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
DWORD bnByte = bn * 0x200;
DWORD blenByte = blen * 0x200;
if (bn > us->bl_num)
return USB_STOR_TRANSPORT_ERROR;
result = ENE_LoadBinCode(us, SD_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD)
{
printk("Load SD RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
if ( us->SD_Status.HiCapacity )
bnByte = bn;
// set up the command wrapper
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[5] = (BYTE)(bnByte);
bcb->CDB[4] = (BYTE)(bnByte>>8);
bcb->CDB[3] = (BYTE)(bnByte>>16);
bcb->CDB[2] = (BYTE)(bnByte>>24);
result = ENE_SendScsiCmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
return result;
}

View File

@ -413,7 +413,7 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
usb_stor_print_cmd(srb);
/* send the command to the transport layer */
scsi_set_resid(srb, 0);
if ( !(us->SD_Status.Ready || us->MS_Status.Ready || us->SM_Status.Ready) )
if (!(us->MS_Status.Ready || us->SM_Status.Ready))
result = ENE_InitMedia(us);
if (us->Power_IsResum == true) {
@ -421,7 +421,6 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
us->Power_IsResum = false;
}
if (us->SD_Status.Ready) result = SD_SCSIIrp(us, srb);
if (us->MS_Status.Ready) result = MS_SCSIIrp(us, srb);
if (us->SM_Status.Ready) result = SM_SCSIIrp(us, srb);

View File

@ -92,10 +92,8 @@ extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer, unsign
// ENE scsi function
extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
extern int ENE_InitMedia(struct us_data*);
extern int ENE_SDInit(struct us_data*);
extern int ENE_MSInit(struct us_data*);
extern int ENE_SMInit(struct us_data*);
extern int ENE_ReadSDReg(struct us_data*, u8*);
extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int);
extern int ENE_LoadBinCode(struct us_data*, BYTE);
extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf);
@ -104,7 +102,6 @@ extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
extern void BuildSenseBuffer(struct scsi_cmnd *, int);
// ENE scsi function
extern int SD_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
extern int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);

View File

@ -74,7 +74,6 @@ int eucr_resume(struct usb_interface *iface)
us->Power_IsResum = true;
//
//us->SD_Status.Ready = 0; //??
us->SD_Status = *(PSD_STATUS)&tmp;
us->MS_Status = *(PMS_STATUS)&tmp;
us->SM_Status = *(PSM_STATUS)&tmp;
@ -98,7 +97,6 @@ int eucr_reset_resume(struct usb_interface *iface)
us->Power_IsResum = true;
//
//us->SD_Status.Ready = 0; //??
us->SD_Status = *(PSD_STATUS)&tmp;
us->MS_Status = *(PMS_STATUS)&tmp;
us->SM_Status = *(PSM_STATUS)&tmp;
return 0;
@ -582,6 +580,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
struct Scsi_Host *host;
struct us_data *us;
int result;
BYTE MiscReg03 = 0;
struct task_struct *th;
printk("usb --- eucr_probe\n");
@ -647,6 +646,24 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
goto BadDevice;
}
wake_up_process(th);
/* probe card type */
result = ENE_Read_BYTE(us, REG_CARD_STATUS, &MiscReg03);
if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
quiesce_and_remove_host(us);
goto BadDevice;
}
if (!(MiscReg03 & 0x02)) {
result = -ENODEV;
quiesce_and_remove_host(us);
printk(KERN_NOTICE "keucr: The driver only supports SM/MS card.\
To use SD card, \
please build driver/usb/storage/ums-eneub6250.ko\n");
goto BadDevice;
}
return 0;
/* We come here if there are any problems */

View File

@ -198,3 +198,17 @@ config USB_LIBUSUAL
options libusual bias="ub"
If unsure, say N.
config USB_STORAGE_ENE_UB6250
tristate "USB ENE card reader support"
depends on USB && SCSI
---help---
Say Y here if you wish to control a ENE SD Card reader.
To use SM/MS card, please build driver/staging/keucr/keucr.ko
This option depends on 'SCSI' support being enabled, but you
probably also need 'SCSI device support: SCSI disk support'
(BLK_DEV_SD) for most USB storage devices.
To compile this driver as a module, choose M here: the
module will be called ums-eneub6250.

View File

@ -25,6 +25,7 @@ endif
obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o
obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o
obj-$(CONFIG_USB_STORAGE_DATAFAB) += ums-datafab.o
obj-$(CONFIG_USB_STORAGE_ENE_UB6250) += ums-eneub6250.o
obj-$(CONFIG_USB_STORAGE_FREECOM) += ums-freecom.o
obj-$(CONFIG_USB_STORAGE_ISD200) += ums-isd200.o
obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += ums-jumpshot.o
@ -37,6 +38,7 @@ obj-$(CONFIG_USB_STORAGE_USBAT) += ums-usbat.o
ums-alauda-y := alauda.o
ums-cypress-y := cypress_atacb.o
ums-datafab-y := datafab.o
ums-eneub6250-y := ene_ub6250.o
ums-freecom-y := freecom.o
ums-isd200-y := isd200.o
ums-jumpshot-y := jumpshot.o

View File

@ -0,0 +1,807 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/jiffies.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <linux/firmware.h>
#include "usb.h"
#include "transport.h"
#include "protocol.h"
#include "debug.h"
MODULE_DESCRIPTION("Driver for ENE UB6250 reader");
MODULE_LICENSE("GPL");
/*
* The table of devices
*/
#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
vendorName, productName, useProtocol, useTransport, \
initFunction, flags) \
{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
.driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
struct usb_device_id ene_ub6250_usb_ids[] = {
# include "unusual_ene_ub6250.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, ene_ub6250_usb_ids);
#undef UNUSUAL_DEV
/*
* The flags table
*/
#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
vendor_name, product_name, use_protocol, use_transport, \
init_function, Flags) \
{ \
.vendorName = vendor_name, \
.productName = product_name, \
.useProtocol = use_protocol, \
.useTransport = use_transport, \
.initFunction = init_function, \
}
static struct us_unusual_dev ene_ub6250_unusual_dev_list[] = {
# include "unusual_ene_ub6250.h"
{ } /* Terminating entry */
};
#undef UNUSUAL_DEV
/* ENE bin code len */
#define ENE_BIN_CODE_LEN 0x800
/* EnE HW Register */
#define REG_CARD_STATUS 0xFF83
#define REG_HW_TRAP1 0xFF89
/* SRB Status */
#define SS_SUCCESS 0x00 /* No Sense */
#define SS_NOT_READY 0x02
#define SS_MEDIUM_ERR 0x03
#define SS_HW_ERR 0x04
#define SS_ILLEGAL_REQUEST 0x05
#define SS_UNIT_ATTENTION 0x06
/* ENE Load FW Pattern */
#define SD_INIT1_PATTERN 1
#define SD_INIT2_PATTERN 2
#define SD_RW_PATTERN 3
#define MS_INIT_PATTERN 4
#define MSP_RW_PATTERN 5
#define MS_RW_PATTERN 6
#define SM_INIT_PATTERN 7
#define SM_RW_PATTERN 8
#define FDIR_WRITE 0
#define FDIR_READ 1
struct SD_STATUS {
u8 Insert:1;
u8 Ready:1;
u8 MediaChange:1;
u8 IsMMC:1;
u8 HiCapacity:1;
u8 HiSpeed:1;
u8 WtP:1;
u8 Reserved:1;
};
struct MS_STATUS {
u8 Insert:1;
u8 Ready:1;
u8 MediaChange:1;
u8 IsMSPro:1;
u8 IsMSPHG:1;
u8 Reserved1:1;
u8 WtP:1;
u8 Reserved2:1;
};
struct SM_STATUS {
u8 Insert:1;
u8 Ready:1;
u8 MediaChange:1;
u8 Reserved:3;
u8 WtP:1;
u8 IsMS:1;
};
/* SD Block Length */
/* 2^9 = 512 Bytes, The HW maximum read/write data length */
#define SD_BLOCK_LEN 9
struct ene_ub6250_info {
/* for 6250 code */
struct SD_STATUS SD_Status;
struct MS_STATUS MS_Status;
struct SM_STATUS SM_Status;
/* ----- SD Control Data ---------------- */
/*SD_REGISTER SD_Regs; */
u16 SD_Block_Mult;
u8 SD_READ_BL_LEN;
u16 SD_C_SIZE;
u8 SD_C_SIZE_MULT;
/* SD/MMC New spec. */
u8 SD_SPEC_VER;
u8 SD_CSD_VER;
u8 SD20_HIGH_CAPACITY;
u32 HC_C_SIZE;
u8 MMC_SPEC_VER;
u8 MMC_BusWidth;
u8 MMC_HIGH_CAPACITY;
/*----- MS Control Data ---------------- */
bool MS_SWWP;
u32 MSP_TotalBlock;
/*MS_LibControl MS_Lib;*/
bool MS_IsRWPage;
u16 MS_Model;
/*----- SM Control Data ---------------- */
u8 SM_DeviceID;
u8 SM_CardID;
unsigned char *testbuf;
u8 BIN_FLAG;
u32 bl_num;
int SrbStatus;
/*------Power Managerment ---------------*/
bool Power_IsResum;
};
static int ene_sd_init(struct us_data *us);
static int ene_load_bincode(struct us_data *us, unsigned char flag);
static void ene_ub6250_info_destructor(void *extra)
{
if (!extra)
return;
}
static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
int result;
unsigned int residue;
unsigned int cswlen = 0, partial = 0;
unsigned int transfer_length = bcb->DataTransferLength;
/* US_DEBUGP("transport --- ene_send_scsi_cmd\n"); */
/* send cmd to out endpoint */
result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
bcb, US_BULK_CB_WRAP_LEN, NULL);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("send cmd to out endpoint fail ---\n");
return USB_STOR_TRANSPORT_ERROR;
}
if (buf) {
unsigned int pipe = fDir;
if (fDir == FDIR_READ)
pipe = us->recv_bulk_pipe;
else
pipe = us->send_bulk_pipe;
/* Bulk */
if (use_sg) {
result = usb_stor_bulk_srb(us, pipe, us->srb);
} else {
result = usb_stor_bulk_transfer_sg(us, pipe, buf,
transfer_length, 0, &partial);
}
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("data transfer fail ---\n");
return USB_STOR_TRANSPORT_ERROR;
}
}
/* Get CSW for device status */
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
US_BULK_CS_WRAP_LEN, &cswlen);
if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
US_DEBUGP("Received 0-length CSW; retrying...\n");
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
bcs, US_BULK_CS_WRAP_LEN, &cswlen);
}
if (result == USB_STOR_XFER_STALLED) {
/* get the status again */
US_DEBUGP("Attempting to get CSW (2nd try)...\n");
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
bcs, US_BULK_CS_WRAP_LEN, NULL);
}
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
/* check bulk status */
residue = le32_to_cpu(bcs->Residue);
/* try to compute the actual residue, based on how much data
* was really transferred and what the device tells us */
if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
residue = min(residue, transfer_length);
if (us->srb != NULL)
scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
(int)residue));
}
if (bcs->Status != US_BULK_STAT_OK)
return USB_STOR_TRANSPORT_ERROR;
return USB_STOR_TRANSPORT_GOOD;
}
static int sd_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
{
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
if (info->SD_Status.Insert && info->SD_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
else {
ene_sd_init(us);
return USB_STOR_TRANSPORT_GOOD;
}
return USB_STOR_TRANSPORT_GOOD;
}
static int sd_scsi_inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned char data_ptr[36] = {
0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55,
0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61,
0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30 };
usb_stor_set_xfer_buf(data_ptr, 36, srb);
return USB_STOR_TRANSPORT_GOOD;
}
static int sd_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
{
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
unsigned char mediaNoWP[12] = {
0x0b, 0x00, 0x00, 0x08, 0x00, 0x00,
0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 };
unsigned char mediaWP[12] = {
0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 };
if (info->SD_Status.WtP)
usb_stor_set_xfer_buf(mediaWP, 12, srb);
else
usb_stor_set_xfer_buf(mediaNoWP, 12, srb);
return USB_STOR_TRANSPORT_GOOD;
}
static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
{
u32 bl_num;
u16 bl_len;
unsigned int offset = 0;
unsigned char buf[8];
struct scatterlist *sg = NULL;
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
US_DEBUGP("sd_scsi_read_capacity\n");
if (info->SD_Status.HiCapacity) {
bl_len = 0x200;
if (info->SD_Status.IsMMC)
bl_num = info->HC_C_SIZE-1;
else
bl_num = (info->HC_C_SIZE + 1) * 1024 - 1;
} else {
bl_len = 1<<(info->SD_READ_BL_LEN);
bl_num = info->SD_Block_Mult * (info->SD_C_SIZE + 1)
* (1 << (info->SD_C_SIZE_MULT + 2)) - 1;
}
info->bl_num = bl_num;
US_DEBUGP("bl_len = %x\n", bl_len);
US_DEBUGP("bl_num = %x\n", bl_num);
/*srb->request_bufflen = 8; */
buf[0] = (bl_num >> 24) & 0xff;
buf[1] = (bl_num >> 16) & 0xff;
buf[2] = (bl_num >> 8) & 0xff;
buf[3] = (bl_num >> 0) & 0xff;
buf[4] = (bl_len >> 24) & 0xff;
buf[5] = (bl_len >> 16) & 0xff;
buf[6] = (bl_len >> 8) & 0xff;
buf[7] = (bl_len >> 0) & 0xff;
usb_stor_access_xfer_buf(buf, 8, srb, &sg, &offset, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
unsigned char *cdb = srb->cmnd;
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
u32 bn = ((cdb[2] << 24) & 0xff000000) | ((cdb[3] << 16) & 0x00ff0000) |
((cdb[4] << 8) & 0x0000ff00) | ((cdb[5] << 0) & 0x000000ff);
u16 blen = ((cdb[7] << 8) & 0xff00) | ((cdb[8] << 0) & 0x00ff);
u32 bnByte = bn * 0x200;
u32 blenByte = blen * 0x200;
if (bn > info->bl_num)
return USB_STOR_TRANSPORT_ERROR;
result = ene_load_bincode(us, SD_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Load SD RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
if (info->SD_Status.HiCapacity)
bnByte = bn;
/* set up the command wrapper */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
bcb->CDB[5] = (unsigned char)(bnByte);
bcb->CDB[4] = (unsigned char)(bnByte>>8);
bcb->CDB[3] = (unsigned char)(bnByte>>16);
bcb->CDB[2] = (unsigned char)(bnByte>>24);
result = ene_send_scsi_cmd(us, FDIR_READ, scsi_sglist(srb), 1);
return result;
}
static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
unsigned char *cdb = srb->cmnd;
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
u32 bn = ((cdb[2] << 24) & 0xff000000) | ((cdb[3] << 16) & 0x00ff0000) |
((cdb[4] << 8) & 0x0000ff00) | ((cdb[5] << 0) & 0x000000ff);
u16 blen = ((cdb[7] << 8) & 0xff00) | ((cdb[8] << 0) & 0x00ff);
u32 bnByte = bn * 0x200;
u32 blenByte = blen * 0x200;
if (bn > info->bl_num)
return USB_STOR_TRANSPORT_ERROR;
result = ene_load_bincode(us, SD_RW_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Load SD RW pattern Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
if (info->SD_Status.HiCapacity)
bnByte = bn;
/* set up the command wrapper */
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = blenByte;
bcb->Flags = 0x00;
bcb->CDB[0] = 0xF0;
bcb->CDB[5] = (unsigned char)(bnByte);
bcb->CDB[4] = (unsigned char)(bnByte>>8);
bcb->CDB[3] = (unsigned char)(bnByte>>16);
bcb->CDB[2] = (unsigned char)(bnByte>>24);
result = ene_send_scsi_cmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
return result;
}
static int ene_get_card_type(struct us_data *us, u16 index, void *buf)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = 0x01;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xED;
bcb->CDB[2] = (unsigned char)(index>>8);
bcb->CDB[3] = (unsigned char)index;
result = ene_send_scsi_cmd(us, FDIR_READ, buf, 0);
return result;
}
static int ene_get_card_status(struct us_data *us, u8 *buf)
{
u16 tmpreg;
u32 reg4b;
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
/*US_DEBUGP("transport --- ENE_ReadSDReg\n");*/
reg4b = *(u32 *)&buf[0x18];
info->SD_READ_BL_LEN = (u8)((reg4b >> 8) & 0x0f);
tmpreg = (u16) reg4b;
reg4b = *(u32 *)(&buf[0x14]);
if (info->SD_Status.HiCapacity && !info->SD_Status.IsMMC)
info->HC_C_SIZE = (reg4b >> 8) & 0x3fffff;
info->SD_C_SIZE = ((tmpreg & 0x03) << 10) | (u16)(reg4b >> 22);
info->SD_C_SIZE_MULT = (u8)(reg4b >> 7) & 0x07;
if (info->SD_Status.HiCapacity && info->SD_Status.IsMMC)
info->HC_C_SIZE = *(u32 *)(&buf[0x100]);
if (info->SD_READ_BL_LEN > SD_BLOCK_LEN) {
info->SD_Block_Mult = 1 << (info->SD_READ_BL_LEN-SD_BLOCK_LEN);
info->SD_READ_BL_LEN = SD_BLOCK_LEN;
} else {
info->SD_Block_Mult = 1;
}
return USB_STOR_TRANSPORT_GOOD;
}
static int ene_load_bincode(struct us_data *us, unsigned char flag)
{
int err;
char *fw_name = NULL;
unsigned char *buf = NULL;
const struct firmware *sd_fw = NULL;
int result = USB_STOR_TRANSPORT_ERROR;
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
if (info->BIN_FLAG == flag)
return USB_STOR_TRANSPORT_GOOD;
buf = kmalloc(ENE_BIN_CODE_LEN, GFP_KERNEL);
if (buf == NULL)
return USB_STOR_TRANSPORT_ERROR;
switch (flag) {
/* For SD */
case SD_INIT1_PATTERN:
US_DEBUGP("SD_INIT1_PATTERN\n");
fw_name = "ene-ub6250/sd_init1.bin";
break;
case SD_INIT2_PATTERN:
US_DEBUGP("SD_INIT2_PATTERN\n");
fw_name = "ene-ub6250/sd_init2.bin";
break;
case SD_RW_PATTERN:
US_DEBUGP("SD_RDWR_PATTERN\n");
fw_name = "ene-ub6250/sd_rdwr.bin";
break;
default:
US_DEBUGP("----------- Unknown PATTERN ----------\n");
goto nofw;
}
err = request_firmware(&sd_fw, fw_name, &us->pusb_dev->dev);
if (err) {
US_DEBUGP("load firmware %s failed\n", fw_name);
goto nofw;
}
buf = kmalloc(sd_fw->size, GFP_KERNEL);
if (buf == NULL) {
US_DEBUGP("Malloc memory for fireware failed!\n");
goto nofw;
}
memcpy(buf, sd_fw->data, sd_fw->size);
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = sd_fw->size;
bcb->Flags = 0x00;
bcb->CDB[0] = 0xEF;
result = ene_send_scsi_cmd(us, FDIR_WRITE, buf, 0);
info->BIN_FLAG = flag;
kfree(buf);
nofw:
if (sd_fw != NULL) {
release_firmware(sd_fw);
sd_fw = NULL;
}
return result;
}
static int ene_sd_init(struct us_data *us)
{
int result;
u8 buf[0x200];
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
US_DEBUGP("transport --- ENE_SDInit\n");
/* SD Init Part-1 */
result = ene_load_bincode(us, SD_INIT1_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Load SD Init Code Part-1 Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF2;
result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Exection SD Init Code Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
/* SD Init Part-2 */
result = ene_load_bincode(us, SD_INIT2_PATTERN);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Load SD Init Code Part-2 Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = 0x200;
bcb->Flags = 0x80;
bcb->CDB[0] = 0xF1;
result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Exection SD Init Code Fail !!\n");
return USB_STOR_TRANSPORT_ERROR;
}
info->SD_Status = *(struct SD_STATUS *)&buf[0];
if (info->SD_Status.Insert && info->SD_Status.Ready) {
ene_get_card_status(us, (unsigned char *)&buf);
US_DEBUGP("Insert = %x\n", info->SD_Status.Insert);
US_DEBUGP("Ready = %x\n", info->SD_Status.Ready);
US_DEBUGP("IsMMC = %x\n", info->SD_Status.IsMMC);
US_DEBUGP("HiCapacity = %x\n", info->SD_Status.HiCapacity);
US_DEBUGP("HiSpeed = %x\n", info->SD_Status.HiSpeed);
US_DEBUGP("WtP = %x\n", info->SD_Status.WtP);
} else {
US_DEBUGP("SD Card Not Ready --- %x\n", buf[0]);
return USB_STOR_TRANSPORT_ERROR;
}
return USB_STOR_TRANSPORT_GOOD;
}
static int ene_init(struct us_data *us)
{
int result;
u8 misc_reg03 = 0;
struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
result = ene_get_card_type(us, REG_CARD_STATUS, &misc_reg03);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
if (misc_reg03 & 0x01) {
if (!info->SD_Status.Ready) {
result = ene_sd_init(us);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
}
}
return result;
}
/*----- sd_scsi_irp() ---------*/
static int sd_scsi_irp(struct us_data *us, struct scsi_cmnd *srb)
{
int result;
struct ene_ub6250_info *info = (struct ene_ub6250_info *)us->extra;
info->SrbStatus = SS_SUCCESS;
switch (srb->cmnd[0]) {
case TEST_UNIT_READY:
result = sd_scsi_test_unit_ready(us, srb);
break; /* 0x00 */
case INQUIRY:
result = sd_scsi_inquiry(us, srb);
break; /* 0x12 */
case MODE_SENSE:
result = sd_scsi_mode_sense(us, srb);
break; /* 0x1A */
/*
case START_STOP:
result = SD_SCSI_Start_Stop(us, srb);
break; //0x1B
*/
case READ_CAPACITY:
result = sd_scsi_read_capacity(us, srb);
break; /* 0x25 */
case READ_10:
result = sd_scsi_read(us, srb);
break; /* 0x28 */
case WRITE_10:
result = sd_scsi_write(us, srb);
break; /* 0x2A */
default:
info->SrbStatus = SS_ILLEGAL_REQUEST;
result = USB_STOR_TRANSPORT_FAILED;
break;
}
return result;
}
static int ene_transport(struct scsi_cmnd *srb, struct us_data *us)
{
int result = 0;
struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
/*US_DEBUG(usb_stor_show_command(srb)); */
scsi_set_resid(srb, 0);
if (unlikely(!info->SD_Status.Ready))
result = ene_init(us);
else
result = sd_scsi_irp(us, srb);
return 0;
}
static int ene_ub6250_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
int result;
u8 misc_reg03 = 0;
struct us_data *us;
result = usb_stor_probe1(&us, intf, id,
(id - ene_ub6250_usb_ids) + ene_ub6250_unusual_dev_list);
if (result)
return result;
/* FIXME: where should the code alloc extra buf ? */
if (!us->extra) {
us->extra = kzalloc(sizeof(struct ene_ub6250_info), GFP_KERNEL);
if (!us->extra)
return -ENOMEM;
us->extra_destructor = ene_ub6250_info_destructor;
}
us->transport_name = "ene_ub6250";
us->transport = ene_transport;
us->max_lun = 0;
result = usb_stor_probe2(us);
if (result)
return result;
/* probe card type */
result = ene_get_card_type(us, REG_CARD_STATUS, &misc_reg03);
if (result != USB_STOR_XFER_GOOD) {
usb_stor_disconnect(intf);
return USB_STOR_TRANSPORT_ERROR;
}
if (!(misc_reg03 & 0x01)) {
result = -ENODEV;
printk(KERN_NOTICE "ums_eneub6250: The driver only supports SD\
card. To use SM/MS card, please build driver/stagging/keucr\n");
usb_stor_disconnect(intf);
}
return result;
}
#ifdef CONFIG_PM
static int ene_ub6250_resume(struct usb_interface *iface)
{
u8 tmp = 0;
struct us_data *us = usb_get_intfdata(iface);
struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
mutex_lock(&us->dev_mutex);
US_DEBUGP("%s\n", __func__);
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_RESUME);
mutex_unlock(&us->dev_mutex);
info->Power_IsResum = true;
/*info->SD_Status.Ready = 0; */
info->SD_Status = *(struct SD_STATUS *)&tmp;
info->MS_Status = *(struct MS_STATUS *)&tmp;
info->SM_Status = *(struct SM_STATUS *)&tmp;
return 0;
}
static int ene_ub6250_reset_resume(struct usb_interface *iface)
{
u8 tmp = 0;
struct us_data *us = usb_get_intfdata(iface);
struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
US_DEBUGP("%s\n", __func__);
/* Report the reset to the SCSI core */
usb_stor_reset_resume(iface);
/* FIXME: Notify the subdrivers that they need to reinitialize
* the device */
info->Power_IsResum = true;
/*info->SD_Status.Ready = 0; */
info->SD_Status = *(struct SD_STATUS *)&tmp;
info->MS_Status = *(struct MS_STATUS *)&tmp;
info->SM_Status = *(struct SM_STATUS *)&tmp;
return 0;
}
#else
#define ene_ub6250_resume NULL
#define ene_ub6250_reset_resume NULL
#endif
static struct usb_driver ene_ub6250_driver = {
.name = "ums_eneub6250",
.probe = ene_ub6250_probe,
.disconnect = usb_stor_disconnect,
.suspend = usb_stor_suspend,
.resume = ene_ub6250_resume,
.reset_resume = ene_ub6250_reset_resume,
.pre_reset = usb_stor_pre_reset,
.post_reset = usb_stor_post_reset,
.id_table = ene_ub6250_usb_ids,
.soft_unbind = 1,
};
static int __init ene_ub6250_init(void)
{
return usb_register(&ene_ub6250_driver);
}
static void __exit ene_ub6250_exit(void)
{
usb_deregister(&ene_ub6250_driver);
}
module_init(ene_ub6250_init);
module_exit(ene_ub6250_exit);

View File

@ -0,0 +1,26 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if defined(CONFIG_USB_STORAGE_ENE_UB6250) || \
defined(CONFIG_USB_STORAGE_ENE_UB6250_MODULE)
UNUSUAL_DEV(0x0cf2, 0x6250, 0x0000, 0x9999,
"ENE",
"ENE UB6250 reader",
USB_SC_DEVICE, USB_PR_DEVICE, NULL, 0),
#endif /* defined(CONFIG_USB_STORAGE_ENE_UB6250) || ... */

View File

@ -80,6 +80,7 @@ static struct ignore_entry ignore_ids[] = {
# include "unusual_alauda.h"
# include "unusual_cypress.h"
# include "unusual_datafab.h"
# include "unusual_ene_ub6250.h"
# include "unusual_freecom.h"
# include "unusual_isd200.h"
# include "unusual_jumpshot.h"