xd.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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_XD_H
  24. #define __REALTEK_RTSX_XD_H
  25. #define XD_DELAY_WRITE
  26. /* Error Codes */
  27. #define XD_NO_ERROR 0x00
  28. #define XD_NO_MEMORY 0x80
  29. #define XD_PRG_ERROR 0x40
  30. #define XD_NO_CARD 0x20
  31. #define XD_READ_FAIL 0x10
  32. #define XD_ERASE_FAIL 0x08
  33. #define XD_WRITE_FAIL 0x04
  34. #define XD_ECC_ERROR 0x02
  35. #define XD_TO_ERROR 0x01
  36. /* XD Commands */
  37. #define READ1_1 0x00
  38. #define READ1_2 0x01
  39. #define READ2 0x50
  40. #define READ_ID 0x90
  41. #define RESET 0xff
  42. #define PAGE_PRG_1 0x80
  43. #define PAGE_PRG_2 0x10
  44. #define BLK_ERASE_1 0x60
  45. #define BLK_ERASE_2 0xD0
  46. #define READ_STS 0x70
  47. #define READ_xD_ID 0x9A
  48. #define COPY_BACK_512 0x8A
  49. #define COPY_BACK_2K 0x85
  50. #define READ1_1_2 0x30
  51. #define READ1_1_3 0x35
  52. #define CHG_DAT_OUT_1 0x05
  53. #define RDM_DAT_OUT_1 0x05
  54. #define CHG_DAT_OUT_2 0xE0
  55. #define RDM_DAT_OUT_2 0xE0
  56. #define CHG_DAT_OUT_2 0xE0
  57. #define CHG_DAT_IN_1 0x85
  58. #define CACHE_PRG 0x15
  59. /* Redundant Area Related */
  60. #define XD_EXTRA_SIZE 0x10
  61. #define XD_2K_EXTRA_SIZE 0x40
  62. #define NOT_WRITE_PROTECTED 0x80
  63. #define READY_STATE 0x40
  64. #define PROGRAM_ERROR 0x01
  65. #define PROGRAM_ERROR_N_1 0x02
  66. #define INTERNAL_READY 0x20
  67. #define READY_FLAG 0x5F
  68. #define XD_8M_X8_512 0xE6
  69. #define XD_16M_X8_512 0x73
  70. #define XD_32M_X8_512 0x75
  71. #define XD_64M_X8_512 0x76
  72. #define XD_128M_X8_512 0x79
  73. #define XD_256M_X8_512 0x71
  74. #define XD_128M_X8_2048 0xF1
  75. #define XD_256M_X8_2048 0xDA
  76. #define XD_512M_X8 0xDC
  77. #define XD_128M_X16_2048 0xC1
  78. #define XD_4M_X8_512_1 0xE3
  79. #define XD_4M_X8_512_2 0xE5
  80. #define xD_1G_X8_512 0xD3
  81. #define xD_2G_X8_512 0xD5
  82. #define XD_ID_CODE 0xB5
  83. #define VENDOR_BLOCK 0xEFFF
  84. #define CIS_BLOCK 0xDFFF
  85. #define BLK_NOT_FOUND 0xFFFFFFFF
  86. #define NO_NEW_BLK 0xFFFFFFFF
  87. #define PAGE_CORRECTABLE 0x0
  88. #define PAGE_NOTCORRECTABLE 0x1
  89. #define NO_OFFSET 0x0
  90. #define WITH_OFFSET 0x1
  91. #define Sect_Per_Page 4
  92. #define XD_ADDR_MODE_2C XD_ADDR_MODE_2A
  93. #define ZONE0_BAD_BLOCK 23
  94. #define NOT_ZONE0_BAD_BLOCK 24
  95. #define XD_RW_ADDR 0x01
  96. #define XD_ERASE_ADDR 0x02
  97. #define XD_PAGE_512(xd_card) \
  98. do { \
  99. (xd_card)->block_shift = 5; \
  100. (xd_card)->page_off = 0x1F; \
  101. } while (0)
  102. #define XD_SET_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag |= 0x01)
  103. #define XD_CLR_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag &= ~0x01)
  104. #define XD_CHK_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag & 0x01)
  105. #define XD_SET_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag |= 0x02)
  106. #define XD_CLR_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag &= ~0x02)
  107. #define XD_CHK_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag & 0x02)
  108. #define XD_SET_MBR_FAIL(xd_card) ((xd_card)->multi_flag |= 0x04)
  109. #define XD_CLR_MBR_FAIL(xd_card) ((xd_card)->multi_flag &= ~0x04)
  110. #define XD_CHK_MBR_FAIL(xd_card) ((xd_card)->multi_flag & 0x04)
  111. #define XD_SET_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag |= 0x08)
  112. #define XD_CLR_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag &= ~0x08)
  113. #define XD_CHK_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag & 0x08)
  114. #define XD_SET_4MB(xd_card) ((xd_card)->multi_flag |= 0x10)
  115. #define XD_CLR_4MB(xd_card) ((xd_card)->multi_flag &= ~0x10)
  116. #define XD_CHK_4MB(xd_card) ((xd_card)->multi_flag & 0x10)
  117. #define XD_SET_ECC_ERR(xd_card) ((xd_card)->multi_flag |= 0x40)
  118. #define XD_CLR_ECC_ERR(xd_card) ((xd_card)->multi_flag &= ~0x40)
  119. #define XD_CHK_ECC_ERR(xd_card) ((xd_card)->multi_flag & 0x40)
  120. #define PAGE_STATUS 0
  121. #define BLOCK_STATUS 1
  122. #define BLOCK_ADDR1_L 2
  123. #define BLOCK_ADDR1_H 3
  124. #define BLOCK_ADDR2_L 4
  125. #define BLOCK_ADDR2_H 5
  126. #define RESERVED0 6
  127. #define RESERVED1 7
  128. #define RESERVED2 8
  129. #define RESERVED3 9
  130. #define PARITY 10
  131. #define CIS0_0 0
  132. #define CIS0_1 1
  133. #define CIS0_2 2
  134. #define CIS0_3 3
  135. #define CIS0_4 4
  136. #define CIS0_5 5
  137. #define CIS0_6 6
  138. #define CIS0_7 7
  139. #define CIS0_8 8
  140. #define CIS0_9 9
  141. #define CIS1_0 256
  142. #define CIS1_1 (256 + 1)
  143. #define CIS1_2 (256 + 2)
  144. #define CIS1_3 (256 + 3)
  145. #define CIS1_4 (256 + 4)
  146. #define CIS1_5 (256 + 5)
  147. #define CIS1_6 (256 + 6)
  148. #define CIS1_7 (256 + 7)
  149. #define CIS1_8 (256 + 8)
  150. #define CIS1_9 (256 + 9)
  151. int reset_xd_card(struct rtsx_chip *chip);
  152. #ifdef XD_DELAY_WRITE
  153. int xd_delay_write(struct rtsx_chip *chip);
  154. #endif
  155. int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
  156. u32 start_sector, u16 sector_cnt);
  157. void xd_free_l2p_tbl(struct rtsx_chip *chip);
  158. void xd_cleanup_work(struct rtsx_chip *chip);
  159. int xd_power_off_card3v3(struct rtsx_chip *chip);
  160. int release_xd_card(struct rtsx_chip *chip);
  161. #endif /* __REALTEK_RTSX_XD_H */