mmc.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * linux/drivers/mmc/mmc_pxa.h
  3. *
  4. * Author: Vladimir Shebordaev, Igor Oblakov
  5. * Copyright: MontaVista Software Inc.
  6. *
  7. * $Id: mmc_pxa.h,v 0.3.1.6 2002/09/25 19:25:48 ted Exp ted $
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef __MMC_PXA_P_H__
  14. #define __MMC_PXA_P_H__
  15. /* PXA-250 MMC controller registers */
  16. /* MMC_STRPCL */
  17. #define MMC_STRPCL_STOP_CLK (0x0001UL)
  18. #define MMC_STRPCL_START_CLK (0x0002UL)
  19. /* MMC_STAT */
  20. #define MMC_STAT_END_CMD_RES (0x0001UL << 13)
  21. #define MMC_STAT_PRG_DONE (0x0001UL << 12)
  22. #define MMC_STAT_DATA_TRAN_DONE (0x0001UL << 11)
  23. #define MMC_STAT_CLK_EN (0x0001UL << 8)
  24. #define MMC_STAT_RECV_FIFO_FULL (0x0001UL << 7)
  25. #define MMC_STAT_XMIT_FIFO_EMPTY (0x0001UL << 6)
  26. #define MMC_STAT_RES_CRC_ERROR (0x0001UL << 5)
  27. #define MMC_STAT_SPI_READ_ERROR_TOKEN (0x0001UL << 4)
  28. #define MMC_STAT_CRC_READ_ERROR (0x0001UL << 3)
  29. #define MMC_STAT_CRC_WRITE_ERROR (0x0001UL << 2)
  30. #define MMC_STAT_TIME_OUT_RESPONSE (0x0001UL << 1)
  31. #define MMC_STAT_READ_TIME_OUT (0x0001UL)
  32. #define MMC_STAT_ERRORS (MMC_STAT_RES_CRC_ERROR|MMC_STAT_SPI_READ_ERROR_TOKEN\
  33. |MMC_STAT_CRC_READ_ERROR|MMC_STAT_TIME_OUT_RESPONSE\
  34. |MMC_STAT_READ_TIME_OUT|MMC_STAT_CRC_WRITE_ERROR)
  35. /* MMC_CLKRT */
  36. #define MMC_CLKRT_20MHZ (0x0000UL)
  37. #define MMC_CLKRT_10MHZ (0x0001UL)
  38. #define MMC_CLKRT_5MHZ (0x0002UL)
  39. #define MMC_CLKRT_2_5MHZ (0x0003UL)
  40. #define MMC_CLKRT_1_25MHZ (0x0004UL)
  41. #define MMC_CLKRT_0_625MHZ (0x0005UL)
  42. #define MMC_CLKRT_0_3125MHZ (0x0006UL)
  43. /* MMC_SPI */
  44. #define MMC_SPI_DISABLE (0x00UL)
  45. #define MMC_SPI_EN (0x01UL)
  46. #define MMC_SPI_CS_EN (0x01UL << 2)
  47. #define MMC_SPI_CS_ADDRESS (0x01UL << 3)
  48. #define MMC_SPI_CRC_ON (0x01UL << 1)
  49. /* MMC_CMDAT */
  50. #define MMC_CMDAT_SD_4DAT (0x0001UL << 8)
  51. #define MMC_CMDAT_MMC_DMA_EN (0x0001UL << 7)
  52. #define MMC_CMDAT_INIT (0x0001UL << 6)
  53. #define MMC_CMDAT_BUSY (0x0001UL << 5)
  54. #define MMC_CMDAT_BCR (0x0003UL << 5)
  55. #define MMC_CMDAT_STREAM (0x0001UL << 4)
  56. #define MMC_CMDAT_BLOCK (0x0000UL << 4)
  57. #define MMC_CMDAT_WRITE (0x0001UL << 3)
  58. #define MMC_CMDAT_READ (0x0000UL << 3)
  59. #define MMC_CMDAT_DATA_EN (0x0001UL << 2)
  60. #define MMC_CMDAT_R0 (0)
  61. #define MMC_CMDAT_R1 (0x0001UL)
  62. #define MMC_CMDAT_R2 (0x0002UL)
  63. #define MMC_CMDAT_R3 (0x0003UL)
  64. /* MMC_RESTO */
  65. #define MMC_RES_TO_MAX (0x007fUL) /* [6:0] */
  66. /* MMC_RDTO */
  67. #define MMC_READ_TO_MAX (0x0ffffUL) /* [15:0] */
  68. /* MMC_BLKLEN */
  69. #define MMC_BLK_LEN_MAX (0x03ffUL) /* [9:0] */
  70. /* MMC_PRTBUF */
  71. #define MMC_PRTBUF_BUF_PART_FULL (0x01UL)
  72. #define MMC_PRTBUF_BUF_FULL (0x00UL )
  73. /* MMC_I_MASK */
  74. #define MMC_I_MASK_TXFIFO_WR_REQ (0x01UL << 6)
  75. #define MMC_I_MASK_RXFIFO_RD_REQ (0x01UL << 5)
  76. #define MMC_I_MASK_CLK_IS_OFF (0x01UL << 4)
  77. #define MMC_I_MASK_STOP_CMD (0x01UL << 3)
  78. #define MMC_I_MASK_END_CMD_RES (0x01UL << 2)
  79. #define MMC_I_MASK_PRG_DONE (0x01UL << 1)
  80. #define MMC_I_MASK_DATA_TRAN_DONE (0x01UL)
  81. #define MMC_I_MASK_ALL (0x07fUL)
  82. /* MMC_I_REG */
  83. #define MMC_I_REG_TXFIFO_WR_REQ (0x01UL << 6)
  84. #define MMC_I_REG_RXFIFO_RD_REQ (0x01UL << 5)
  85. #define MMC_I_REG_CLK_IS_OFF (0x01UL << 4)
  86. #define MMC_I_REG_STOP_CMD (0x01UL << 3)
  87. #define MMC_I_REG_END_CMD_RES (0x01UL << 2)
  88. #define MMC_I_REG_PRG_DONE (0x01UL << 1)
  89. #define MMC_I_REG_DATA_TRAN_DONE (0x01UL)
  90. #define MMC_I_REG_ALL (0x007fUL)
  91. /* MMC_CMD */
  92. #define MMC_CMD_INDEX_MAX (0x006fUL) /* [5:0] */
  93. #define CMD(x) (x)
  94. #define MMC_DEFAULT_RCA 1
  95. #define MMC_BLOCK_SIZE 512
  96. #define MMC_MAX_BLOCK_SIZE 512
  97. #define MMC_R1_IDLE_STATE 0x01
  98. #define MMC_R1_ERASE_STATE 0x02
  99. #define MMC_R1_ILLEGAL_CMD 0x04
  100. #define MMC_R1_COM_CRC_ERR 0x08
  101. #define MMC_R1_ERASE_SEQ_ERR 0x01
  102. #define MMC_R1_ADDR_ERR 0x02
  103. #define MMC_R1_PARAM_ERR 0x04
  104. #define MMC_R1B_WP_ERASE_SKIP 0x0002
  105. #define MMC_R1B_ERR 0x0004
  106. #define MMC_R1B_CC_ERR 0x0008
  107. #define MMC_R1B_CARD_ECC_ERR 0x0010
  108. #define MMC_R1B_WP_VIOLATION 0x0020
  109. #define MMC_R1B_ERASE_PARAM 0x0040
  110. #define MMC_R1B_OOR 0x0080
  111. #define MMC_R1B_IDLE_STATE 0x0100
  112. #define MMC_R1B_ERASE_RESET 0x0200
  113. #define MMC_R1B_ILLEGAL_CMD 0x0400
  114. #define MMC_R1B_COM_CRC_ERR 0x0800
  115. #define MMC_R1B_ERASE_SEQ_ERR 0x1000
  116. #define MMC_R1B_ADDR_ERR 0x2000
  117. #define MMC_R1B_PARAM_ERR 0x4000
  118. typedef struct mmc_cid
  119. {
  120. /* FIXME: BYTE_ORDER */
  121. uchar year:4,
  122. month:4;
  123. uchar sn[3];
  124. uchar fwrev:4,
  125. hwrev:4;
  126. uchar name[6];
  127. uchar id[3];
  128. } mmc_cid_t;
  129. typedef struct mmc_csd
  130. {
  131. uint8_t csd_structure:2,
  132. spec_ver:4,
  133. rsvd1:2;
  134. uint8_t taac;
  135. uint8_t nsac;
  136. uint8_t tran_speed;
  137. uint16_t ccc:12,
  138. read_bl_len:4;
  139. uint64_t read_bl_partial:1,
  140. write_blk_misalign:1,
  141. read_blk_misalign:1,
  142. dsr_imp:1,
  143. rsvd2:2,
  144. c_size:12,
  145. vdd_r_curr_min:3,
  146. vdd_r_curr_max:3,
  147. vdd_w_curr_min:3,
  148. vdd_w_curr_max:3,
  149. c_size_mult:3,
  150. erase_blk_en:1,
  151. sector_size:7,
  152. wp_grp_size:7,
  153. wp_grp_enable:1,
  154. default_ecc:2,
  155. r2w_factor:3,
  156. write_bl_len:4,
  157. write_bl_partial:1,
  158. rsvd3:4,
  159. content_prot_app:1;
  160. uint8_t file_format_grp:1,
  161. copy:1,
  162. perm_write_protect:1,
  163. tmp_write_protect:1,
  164. file_format:2,
  165. ecc:2;
  166. } mmc_csd_t;
  167. #endif /* __MMC_PXA_P_H__ */