memstick: automatically retrieve "INT" value from command response
[sfrench/cifs-2.6.git] / include / linux / memstick.h
index 334d059d67944e1bd651580df57a482be62079c8..3e686ec6a9678d82694ffc9c22bccc1bdf89a12a 100644 (file)
@@ -22,6 +22,8 @@ struct ms_status_register {
        unsigned char reserved;
        unsigned char interrupt;
 #define MEMSTICK_INT_CMDNAK             0x0001
+#define MEMSTICK_INT_IOREQ              0x0008
+#define MEMSTICK_INT_IOBREQ             0x0010
 #define MEMSTICK_INT_BREQ               0x0020
 #define MEMSTICK_INT_ERR                0x0040
 #define MEMSTICK_INT_CED                0x0080
@@ -47,13 +49,17 @@ struct ms_status_register {
 
 struct ms_id_register {
        unsigned char type;
-       unsigned char reserved;
+       unsigned char if_mode;
        unsigned char category;
        unsigned char class;
 } __attribute__((packed));
 
 struct ms_param_register {
        unsigned char system;
+#define MEMSTICK_SYS_ATEN 0xc0
+#define MEMSTICK_SYS_BAMD 0x80
+#define MEMSTICK_SYS_PAM  0x08
+
        unsigned char block_address_msb;
        unsigned short block_address;
        unsigned char cp;
@@ -90,16 +96,48 @@ struct ms_register {
 
 struct mspro_param_register {
        unsigned char  system;
+#define MEMSTICK_SYS_SERIAL 0x80
+#define MEMSTICK_SYS_PAR4   0x00
+#define MEMSTICK_SYS_PAR8   0x40
+
+       unsigned short data_count;
+       unsigned int   data_address;
+       unsigned char  tpc_param;
+} __attribute__((packed));
+
+struct mspro_io_info_register {
+       unsigned char version;
+       unsigned char io_category;
+       unsigned char current_req;
+       unsigned char card_opt_info;
+       unsigned char rdy_wait_time;
+} __attribute__((packed));
+
+struct mspro_io_func_register {
+       unsigned char func_enable;
+       unsigned char func_select;
+       unsigned char func_intmask;
+       unsigned char transfer_mode;
+} __attribute__((packed));
+
+struct mspro_io_cmd_register {
+       unsigned short tpc_param;
        unsigned short data_count;
        unsigned int   data_address;
-       unsigned char  cmd_param;
 } __attribute__((packed));
 
 struct mspro_register {
-       struct ms_status_register    status;
-       struct ms_id_register        id;
-       unsigned char                reserved[8];
-       struct mspro_param_register  param;
+       struct ms_status_register     status;
+       struct ms_id_register         id;
+       unsigned char                 reserved0[8];
+       struct mspro_param_register   param;
+       unsigned char                 reserved1[8];
+       struct mspro_io_info_register io_info;
+       struct mspro_io_func_register io_func;
+       unsigned char                 reserved2[7];
+       struct mspro_io_cmd_register  io_cmd;
+       unsigned char                 io_int;
+       unsigned char                 io_int_func;
 } __attribute__((packed));
 
 struct ms_register_addr {
@@ -110,49 +148,55 @@ struct ms_register_addr {
 } __attribute__((packed));
 
 enum {
+       MS_TPC_READ_MG_STATUS   = 0x01,
        MS_TPC_READ_LONG_DATA   = 0x02,
        MS_TPC_READ_SHORT_DATA  = 0x03,
+       MS_TPC_READ_MG_DATA     = 0x03,
        MS_TPC_READ_REG         = 0x04,
-       MS_TPC_READ_IO_DATA     = 0x05, /* unverified */
+       MS_TPC_READ_QUAD_DATA   = 0x05,
+       MS_TPC_READ_IO_DATA     = 0x05,
        MS_TPC_GET_INT          = 0x07,
        MS_TPC_SET_RW_REG_ADRS  = 0x08,
        MS_TPC_EX_SET_CMD       = 0x09,
-       MS_TPC_WRITE_IO_DATA    = 0x0a, /* unverified */
+       MS_TPC_WRITE_QUAD_DATA  = 0x0a,
+       MS_TPC_WRITE_IO_DATA    = 0x0a,
        MS_TPC_WRITE_REG        = 0x0b,
        MS_TPC_WRITE_SHORT_DATA = 0x0c,
+       MS_TPC_WRITE_MG_DATA    = 0x0c,
        MS_TPC_WRITE_LONG_DATA  = 0x0d,
        MS_TPC_SET_CMD          = 0x0e
 };
 
 enum {
-       MS_CMD_BLOCK_END     = 0x33,
-       MS_CMD_RESET         = 0x3c,
-       MS_CMD_BLOCK_WRITE   = 0x55,
-       MS_CMD_SLEEP         = 0x5a,
-       MS_CMD_BLOCK_ERASE   = 0x99,
-       MS_CMD_BLOCK_READ    = 0xaa,
-       MS_CMD_CLEAR_BUF     = 0xc3,
-       MS_CMD_FLASH_STOP    = 0xcc,
-       MSPRO_CMD_FORMAT     = 0x10,
-       MSPRO_CMD_SLEEP      = 0x11,
-       MSPRO_CMD_READ_DATA  = 0x20,
-       MSPRO_CMD_WRITE_DATA = 0x21,
-       MSPRO_CMD_READ_ATRB  = 0x24,
-       MSPRO_CMD_STOP       = 0x25,
-       MSPRO_CMD_ERASE      = 0x26,
-       MSPRO_CMD_SET_IBA    = 0x46,
-       MSPRO_CMD_SET_IBD    = 0x47
-/*
-       MSPRO_CMD_RESET
-       MSPRO_CMD_WAKEUP
-       MSPRO_CMD_IN_IO_DATA
-       MSPRO_CMD_OUT_IO_DATA
-       MSPRO_CMD_READ_IO_ATRB
-       MSPRO_CMD_IN_IO_FIFO
-       MSPRO_CMD_OUT_IO_FIFO
-       MSPRO_CMD_IN_IOM
-       MSPRO_CMD_OUT_IOM
-*/
+       MS_CMD_BLOCK_END       = 0x33,
+       MS_CMD_RESET           = 0x3c,
+       MS_CMD_BLOCK_WRITE     = 0x55,
+       MS_CMD_SLEEP           = 0x5a,
+       MS_CMD_BLOCK_ERASE     = 0x99,
+       MS_CMD_BLOCK_READ      = 0xaa,
+       MS_CMD_CLEAR_BUF       = 0xc3,
+       MS_CMD_FLASH_STOP      = 0xcc,
+       MS_CMD_LOAD_ID         = 0x60,
+       MS_CMD_CMP_ICV         = 0x7f,
+       MSPRO_CMD_FORMAT       = 0x10,
+       MSPRO_CMD_SLEEP        = 0x11,
+       MSPRO_CMD_WAKEUP       = 0x12,
+       MSPRO_CMD_READ_DATA    = 0x20,
+       MSPRO_CMD_WRITE_DATA   = 0x21,
+       MSPRO_CMD_READ_ATRB    = 0x24,
+       MSPRO_CMD_STOP         = 0x25,
+       MSPRO_CMD_ERASE        = 0x26,
+       MSPRO_CMD_READ_QUAD    = 0x27,
+       MSPRO_CMD_WRITE_QUAD   = 0x28,
+       MSPRO_CMD_SET_IBD      = 0x46,
+       MSPRO_CMD_GET_IBD      = 0x47,
+       MSPRO_CMD_IN_IO_DATA   = 0xb0,
+       MSPRO_CMD_OUT_IO_DATA  = 0xb1,
+       MSPRO_CMD_READ_IO_ATRB = 0xb2,
+       MSPRO_CMD_IN_IO_FIFO   = 0xb3,
+       MSPRO_CMD_OUT_IO_FIFO  = 0xb4,
+       MSPRO_CMD_IN_IOM       = 0xb5,
+       MSPRO_CMD_OUT_IOM      = 0xb6,
 };
 
 /*** Driver structures and functions ***/
@@ -165,7 +209,8 @@ enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE };
 #define MEMSTICK_POWER_ON  1
 
 #define MEMSTICK_SERIAL   0
-#define MEMSTICK_PARALLEL 1
+#define MEMSTICK_PAR4     1
+#define MEMSTICK_PAR8     2
 
 struct memstick_host;
 struct memstick_driver;
@@ -194,12 +239,7 @@ struct memstick_request {
        unsigned char tpc;
        unsigned char data_dir:1,
                      need_card_int:1,
-                     get_int_reg:1,
-                     io_type:2;
-#define               MEMSTICK_IO_NONE 0
-#define               MEMSTICK_IO_VAL  1
-#define               MEMSTICK_IO_SG   2
-
+                     long_data:1;
        unsigned char int_reg;
        int           error;
        union {
@@ -231,8 +271,9 @@ struct memstick_host {
        struct mutex        lock;
        unsigned int        id;
        unsigned int        caps;
-#define MEMSTICK_CAP_PARALLEL      1
-#define MEMSTICK_CAP_AUTO_GET_INT  2
+#define MEMSTICK_CAP_AUTO_GET_INT  1
+#define MEMSTICK_CAP_PAR4          2
+#define MEMSTICK_CAP_PAR8          4
 
        struct work_struct  media_checker;
        struct class_device cdev;
@@ -270,6 +311,8 @@ int memstick_add_host(struct memstick_host *host);
 void memstick_remove_host(struct memstick_host *host);
 void memstick_free_host(struct memstick_host *host);
 void memstick_detect_change(struct memstick_host *host);
+void memstick_suspend_host(struct memstick_host *host);
+void memstick_resume_host(struct memstick_host *host);
 
 void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc,
                          struct scatterlist *sg);