ms.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* Driver for Realtek PCI-Express card reader
  2. * Header file
  3. *
  4. * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * Author:
  20. * Wei WANG (wei_wang@realsil.com.cn)
  21. * Micky Ching (micky_ching@realsil.com.cn)
  22. */
  23. #ifndef __REALTEK_RTSX_MS_H
  24. #define __REALTEK_RTSX_MS_H
  25. #define MS_DELAY_WRITE
  26. #define MS_MAX_RETRY_COUNT 3
  27. #define MS_EXTRA_SIZE 0x9
  28. #define WRT_PRTCT 0x01
  29. /* Error Code */
  30. #define MS_NO_ERROR 0x00
  31. #define MS_CRC16_ERROR 0x80
  32. #define MS_TO_ERROR 0x40
  33. #define MS_NO_CARD 0x20
  34. #define MS_NO_MEMORY 0x10
  35. #define MS_CMD_NK 0x08
  36. #define MS_FLASH_READ_ERROR 0x04
  37. #define MS_FLASH_WRITE_ERROR 0x02
  38. #define MS_BREQ_ERROR 0x01
  39. #define MS_NOT_FOUND 0x03
  40. /* Transfer Protocol Command */
  41. #define READ_PAGE_DATA 0x02
  42. #define READ_REG 0x04
  43. #define GET_INT 0x07
  44. #define WRITE_PAGE_DATA 0x0D
  45. #define WRITE_REG 0x0B
  46. #define SET_RW_REG_ADRS 0x08
  47. #define SET_CMD 0x0E
  48. #define PRO_READ_LONG_DATA 0x02
  49. #define PRO_READ_SHORT_DATA 0x03
  50. #define PRO_READ_REG 0x04
  51. #define PRO_READ_QUAD_DATA 0x05
  52. #define PRO_GET_INT 0x07
  53. #define PRO_WRITE_LONG_DATA 0x0D
  54. #define PRO_WRITE_SHORT_DATA 0x0C
  55. #define PRO_WRITE_QUAD_DATA 0x0A
  56. #define PRO_WRITE_REG 0x0B
  57. #define PRO_SET_RW_REG_ADRS 0x08
  58. #define PRO_SET_CMD 0x0E
  59. #define PRO_EX_SET_CMD 0x09
  60. #ifdef SUPPORT_MAGIC_GATE
  61. #define MG_GET_ID 0x40
  62. #define MG_SET_LID 0x41
  63. #define MG_GET_LEKB 0x42
  64. #define MG_SET_RD 0x43
  65. #define MG_MAKE_RMS 0x44
  66. #define MG_MAKE_KSE 0x45
  67. #define MG_SET_IBD 0x46
  68. #define MG_GET_IBD 0x47
  69. #endif
  70. #ifdef XC_POWERCLASS
  71. #define XC_CHG_POWER 0x16
  72. #endif
  73. #define BLOCK_READ 0xAA
  74. #define BLOCK_WRITE 0x55
  75. #define BLOCK_END 0x33
  76. #define BLOCK_ERASE 0x99
  77. #define FLASH_STOP 0xCC
  78. #define SLEEP 0x5A
  79. #define CLEAR_BUF 0xC3
  80. #define MS_RESET 0x3C
  81. #define PRO_READ_DATA 0x20
  82. #define PRO_WRITE_DATA 0x21
  83. #define PRO_READ_ATRB 0x24
  84. #define PRO_STOP 0x25
  85. #define PRO_ERASE 0x26
  86. #define PRO_READ_2K_DATA 0x27
  87. #define PRO_WRITE_2K_DATA 0x28
  88. #define PRO_FORMAT 0x10
  89. #define PRO_SLEEP 0x11
  90. #define IntReg 0x01
  91. #define StatusReg0 0x02
  92. #define StatusReg1 0x03
  93. #define SystemParm 0x10
  94. #define BlockAdrs 0x11
  95. #define CMDParm 0x14
  96. #define PageAdrs 0x15
  97. #define OverwriteFlag 0x16
  98. #define ManagemenFlag 0x17
  99. #define LogicalAdrs 0x18
  100. #define ReserveArea 0x1A
  101. #define Pro_IntReg 0x01
  102. #define Pro_StatusReg 0x02
  103. #define Pro_TypeReg 0x04
  104. #define Pro_IFModeReg 0x05
  105. #define Pro_CatagoryReg 0x06
  106. #define Pro_ClassReg 0x07
  107. #define Pro_SystemParm 0x10
  108. #define Pro_DataCount1 0x11
  109. #define Pro_DataCount0 0x12
  110. #define Pro_DataAddr3 0x13
  111. #define Pro_DataAddr2 0x14
  112. #define Pro_DataAddr1 0x15
  113. #define Pro_DataAddr0 0x16
  114. #define Pro_TPCParm 0x17
  115. #define Pro_CMDParm 0x18
  116. #define INT_REG_CED 0x80
  117. #define INT_REG_ERR 0x40
  118. #define INT_REG_BREQ 0x20
  119. #define INT_REG_CMDNK 0x01
  120. #define BLOCK_BOOT 0xC0
  121. #define BLOCK_OK 0x80
  122. #define PAGE_OK 0x60
  123. #define DATA_COMPL 0x10
  124. #define NOT_BOOT_BLOCK 0x4
  125. #define NOT_TRANSLATION_TABLE 0x8
  126. #define HEADER_ID0 PPBUF_BASE2
  127. #define HEADER_ID1 (PPBUF_BASE2 + 1)
  128. #define DISABLED_BLOCK0 (PPBUF_BASE2 + 0x170 + 4)
  129. #define DISABLED_BLOCK1 (PPBUF_BASE2 + 0x170 + 5)
  130. #define DISABLED_BLOCK2 (PPBUF_BASE2 + 0x170 + 6)
  131. #define DISABLED_BLOCK3 (PPBUF_BASE2 + 0x170 + 7)
  132. #define BLOCK_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 2)
  133. #define BLOCK_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 3)
  134. #define BLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 4)
  135. #define BLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 5)
  136. #define EBLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 6)
  137. #define EBLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 7)
  138. #define PAGE_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 8)
  139. #define PAGE_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 9)
  140. #define MS_Device_Type (PPBUF_BASE2 + 0x1D8)
  141. #define MS_4bit_Support (PPBUF_BASE2 + 0x1D3)
  142. #define setPS_NG 1
  143. #define setPS_Error 0
  144. #define PARALLEL_8BIT_IF 0x40
  145. #define PARALLEL_4BIT_IF 0x00
  146. #define SERIAL_IF 0x80
  147. #define BUF_FULL 0x10
  148. #define BUF_EMPTY 0x20
  149. #define MEDIA_BUSY 0x80
  150. #define FLASH_BUSY 0x40
  151. #define DATA_ERROR 0x20
  152. #define STS_UCDT 0x10
  153. #define EXTRA_ERROR 0x08
  154. #define STS_UCEX 0x04
  155. #define FLAG_ERROR 0x02
  156. #define STS_UCFG 0x01
  157. #define MS_SHORT_DATA_LEN 32
  158. #define FORMAT_SUCCESS 0
  159. #define FORMAT_FAIL 1
  160. #define FORMAT_IN_PROGRESS 2
  161. #define MS_SET_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag |= 0x80)
  162. #define MS_CLR_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag &= 0x7F)
  163. #define MS_TST_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag & 0x80)
  164. void mspro_polling_format_status(struct rtsx_chip *chip);
  165. void mspro_stop_seq_mode(struct rtsx_chip *chip);
  166. int reset_ms_card(struct rtsx_chip *chip);
  167. int ms_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
  168. u32 start_sector, u16 sector_cnt);
  169. int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
  170. int short_data_len, bool quick_format);
  171. void ms_free_l2p_tbl(struct rtsx_chip *chip);
  172. void ms_cleanup_work(struct rtsx_chip *chip);
  173. int ms_power_off_card3v3(struct rtsx_chip *chip);
  174. int release_ms_card(struct rtsx_chip *chip);
  175. #ifdef MS_DELAY_WRITE
  176. int ms_delay_write(struct rtsx_chip *chip);
  177. #endif
  178. #ifdef SUPPORT_MAGIC_GATE
  179. int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  180. int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  181. int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  182. int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  183. int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  184. int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  185. int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip);
  186. #endif
  187. #endif /* __REALTEK_RTSX_MS_H */