0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef __REALTEK_RTSX_MS_H
0013 #define __REALTEK_RTSX_MS_H
0014
0015 #define MS_DELAY_WRITE
0016
0017 #define MS_MAX_RETRY_COUNT 3
0018
0019 #define MS_EXTRA_SIZE 0x9
0020
0021 #define WRT_PRTCT 0x01
0022
0023
0024 #define MS_NO_ERROR 0x00
0025 #define MS_CRC16_ERROR 0x80
0026 #define MS_TO_ERROR 0x40
0027 #define MS_NO_CARD 0x20
0028 #define MS_NO_MEMORY 0x10
0029 #define MS_CMD_NK 0x08
0030 #define MS_FLASH_READ_ERROR 0x04
0031 #define MS_FLASH_WRITE_ERROR 0x02
0032 #define MS_BREQ_ERROR 0x01
0033 #define MS_NOT_FOUND 0x03
0034
0035
0036 #define READ_PAGE_DATA 0x02
0037 #define READ_REG 0x04
0038 #define GET_INT 0x07
0039 #define WRITE_PAGE_DATA 0x0D
0040 #define WRITE_REG 0x0B
0041 #define SET_RW_REG_ADRS 0x08
0042 #define SET_CMD 0x0E
0043
0044 #define PRO_READ_LONG_DATA 0x02
0045 #define PRO_READ_SHORT_DATA 0x03
0046 #define PRO_READ_REG 0x04
0047 #define PRO_READ_QUAD_DATA 0x05
0048 #define PRO_GET_INT 0x07
0049 #define PRO_WRITE_LONG_DATA 0x0D
0050 #define PRO_WRITE_SHORT_DATA 0x0C
0051 #define PRO_WRITE_QUAD_DATA 0x0A
0052 #define PRO_WRITE_REG 0x0B
0053 #define PRO_SET_RW_REG_ADRS 0x08
0054 #define PRO_SET_CMD 0x0E
0055 #define PRO_EX_SET_CMD 0x09
0056
0057 #ifdef SUPPORT_MAGIC_GATE
0058
0059 #define MG_GET_ID 0x40
0060 #define MG_SET_LID 0x41
0061 #define MG_GET_LEKB 0x42
0062 #define MG_SET_RD 0x43
0063 #define MG_MAKE_RMS 0x44
0064 #define MG_MAKE_KSE 0x45
0065 #define MG_SET_IBD 0x46
0066 #define MG_GET_IBD 0x47
0067
0068 #endif
0069
0070 #ifdef XC_POWERCLASS
0071 #define XC_CHG_POWER 0x16
0072 #endif
0073
0074 #define BLOCK_READ 0xAA
0075 #define BLOCK_WRITE 0x55
0076 #define BLOCK_END 0x33
0077 #define BLOCK_ERASE 0x99
0078 #define FLASH_STOP 0xCC
0079
0080 #define SLEEP 0x5A
0081 #define CLEAR_BUF 0xC3
0082 #define MS_RESET 0x3C
0083
0084 #define PRO_READ_DATA 0x20
0085 #define PRO_WRITE_DATA 0x21
0086 #define PRO_READ_ATRB 0x24
0087 #define PRO_STOP 0x25
0088 #define PRO_ERASE 0x26
0089 #define PRO_READ_2K_DATA 0x27
0090 #define PRO_WRITE_2K_DATA 0x28
0091
0092 #define PRO_FORMAT 0x10
0093 #define PRO_SLEEP 0x11
0094
0095 #define INT_REG 0x01
0096 #define STATUS_REG0 0x02
0097 #define STATUS_REG1 0x03
0098
0099 #define SYSTEM_PARAM 0x10
0100 #define BLOCK_ADRS 0x11
0101 #define CMD_PARM 0x14
0102 #define PAGE_ADRS 0x15
0103
0104 #define OVERWRITE_FLAG 0x16
0105 #define MANAGEMEN_FLAG 0x17
0106 #define LOGICAL_ADRS 0x18
0107 #define RESERVE_AREA 0x1A
0108
0109 #define PRO_INT_REG 0x01
0110 #define PRO_STATUS_REG 0x02
0111 #define PRO_TYPE_REG 0x04
0112 #define PRO_IF_mode_REG 0x05
0113 #define PRO_CATEGORY_REG 0x06
0114 #define PRO_CLASS_REG 0x07
0115
0116 #define PRO_SYSTEM_PARAM 0x10
0117 #define PRO_DATA_COUNT1 0x11
0118 #define PRO_DATA_COUNT0 0x12
0119 #define PRO_DATA_ADDR3 0x13
0120 #define PRO_DATA_ADDR2 0x14
0121 #define PRO_DATA_ADDR1 0x15
0122 #define PRO_DATA_ADDR0 0x16
0123
0124 #define PRO_TPC_PARM 0x17
0125 #define PRO_CMD_PARM 0x18
0126
0127 #define INT_REG_CED 0x80
0128 #define INT_REG_ERR 0x40
0129 #define INT_REG_BREQ 0x20
0130 #define INT_REG_CMDNK 0x01
0131
0132 #define BLOCK_BOOT 0xC0
0133 #define BLOCK_OK 0x80
0134 #define PAGE_OK 0x60
0135 #define DATA_COMPL 0x10
0136
0137 #define NOT_BOOT_BLOCK 0x4
0138 #define NOT_TRANSLATION_TABLE 0x8
0139
0140 #define HEADER_ID0 PPBUF_BASE2
0141 #define HEADER_ID1 (PPBUF_BASE2 + 1)
0142 #define DISABLED_BLOCK0 (PPBUF_BASE2 + 0x170 + 4)
0143 #define DISABLED_BLOCK1 (PPBUF_BASE2 + 0x170 + 5)
0144 #define DISABLED_BLOCK2 (PPBUF_BASE2 + 0x170 + 6)
0145 #define DISABLED_BLOCK3 (PPBUF_BASE2 + 0x170 + 7)
0146 #define BLOCK_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 2)
0147 #define BLOCK_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 3)
0148 #define BLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 4)
0149 #define BLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 5)
0150 #define EBLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 6)
0151 #define EBLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 7)
0152 #define PAGE_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 8)
0153 #define PAGE_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 9)
0154
0155 #define MS_device_type (PPBUF_BASE2 + 0x1D8)
0156
0157 #define MS_4bit_support (PPBUF_BASE2 + 0x1D3)
0158
0159 #define set_PS_NG 1
0160 #define set_PS_error 0
0161
0162 #define PARALLEL_8BIT_IF 0x40
0163 #define PARALLEL_4BIT_IF 0x00
0164 #define SERIAL_IF 0x80
0165
0166 #define BUF_FULL 0x10
0167 #define BUF_EMPTY 0x20
0168
0169 #define MEDIA_BUSY 0x80
0170 #define FLASH_BUSY 0x40
0171 #define DATA_ERROR 0x20
0172 #define STS_UCDT 0x10
0173 #define EXTRA_ERROR 0x08
0174 #define STS_UCEX 0x04
0175 #define FLAG_ERROR 0x02
0176 #define STS_UCFG 0x01
0177
0178 #define MS_SHORT_DATA_LEN 32
0179
0180 #define FORMAT_SUCCESS 0
0181 #define FORMAT_FAIL 1
0182 #define FORMAT_IN_PROGRESS 2
0183
0184 #define MS_SET_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag |= 0x80)
0185 #define MS_CLR_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag &= 0x7F)
0186 #define MS_TST_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag & 0x80)
0187
0188 void mspro_polling_format_status(struct rtsx_chip *chip);
0189
0190 void mspro_stop_seq_mode(struct rtsx_chip *chip);
0191 int reset_ms_card(struct rtsx_chip *chip);
0192 int ms_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
0193 u32 start_sector, u16 sector_cnt);
0194 int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
0195 int short_data_len, bool quick_format);
0196 void ms_free_l2p_tbl(struct rtsx_chip *chip);
0197 void ms_cleanup_work(struct rtsx_chip *chip);
0198 int ms_power_off_card3v3(struct rtsx_chip *chip);
0199 int release_ms_card(struct rtsx_chip *chip);
0200 #ifdef MS_DELAY_WRITE
0201 int ms_delay_write(struct rtsx_chip *chip);
0202 #endif
0203
0204 #ifdef SUPPORT_MAGIC_GATE
0205 int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0206 int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0207 int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0208 int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0209 int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0210 int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0211 int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip);
0212 #endif
0213
0214 #endif