regs-mmc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #ifndef __REGS_MMC_H__
  20. #define __REGS_MMC_H__
  21. #define MMC0_BASE 0x41100000
  22. #define MMC1_BASE 0x42000000
  23. int pxa_mmc_register(int card_index);
  24. struct pxa_mmc_regs {
  25. uint32_t strpcl;
  26. uint32_t stat;
  27. uint32_t clkrt;
  28. uint32_t spi;
  29. uint32_t cmdat;
  30. uint32_t resto;
  31. uint32_t rdto;
  32. uint32_t blklen;
  33. uint32_t nob;
  34. uint32_t prtbuf;
  35. uint32_t i_mask;
  36. uint32_t i_reg;
  37. uint32_t cmd;
  38. uint32_t argh;
  39. uint32_t argl;
  40. uint32_t res;
  41. uint32_t rxfifo;
  42. uint32_t txfifo;
  43. };
  44. /* MMC_STRPCL */
  45. #define MMC_STRPCL_STOP_CLK (1 << 0)
  46. #define MMC_STRPCL_START_CLK (1 << 1)
  47. /* MMC_STAT */
  48. #define MMC_STAT_END_CMD_RES (1 << 13)
  49. #define MMC_STAT_PRG_DONE (1 << 12)
  50. #define MMC_STAT_DATA_TRAN_DONE (1 << 11)
  51. #define MMC_STAT_CLK_EN (1 << 8)
  52. #define MMC_STAT_RECV_FIFO_FULL (1 << 7)
  53. #define MMC_STAT_XMIT_FIFO_EMPTY (1 << 6)
  54. #define MMC_STAT_RES_CRC_ERROR (1 << 5)
  55. #define MMC_STAT_SPI_READ_ERROR_TOKEN (1 << 4)
  56. #define MMC_STAT_CRC_READ_ERROR (1 << 3)
  57. #define MMC_STAT_CRC_WRITE_ERROR (1 << 2)
  58. #define MMC_STAT_TIME_OUT_RESPONSE (1 << 1)
  59. #define MMC_STAT_READ_TIME_OUT (1 << 0)
  60. /* MMC_CLKRT */
  61. #define MMC_CLKRT_20MHZ 0
  62. #define MMC_CLKRT_10MHZ 1
  63. #define MMC_CLKRT_5MHZ 2
  64. #define MMC_CLKRT_2_5MHZ 3
  65. #define MMC_CLKRT_1_25MHZ 4
  66. #define MMC_CLKRT_0_625MHZ 5
  67. #define MMC_CLKRT_0_3125MHZ 6
  68. /* MMC_SPI */
  69. #define MMC_SPI_EN (1 << 0)
  70. #define MMC_SPI_CS_EN (1 << 2)
  71. #define MMC_SPI_CS_ADDRESS (1 << 3)
  72. #define MMC_SPI_CRC_ON (1 << 1)
  73. /* MMC_CMDAT */
  74. #define MMC_CMDAT_SD_4DAT (1 << 8)
  75. #define MMC_CMDAT_MMC_DMA_EN (1 << 7)
  76. #define MMC_CMDAT_INIT (1 << 6)
  77. #define MMC_CMDAT_BUSY (1 << 5)
  78. #define MMC_CMDAT_BCR (MMC_CMDAT_BUSY | MMC_CMDAT_INIT)
  79. #define MMC_CMDAT_STREAM (1 << 4)
  80. #define MMC_CMDAT_WRITE (1 << 3)
  81. #define MMC_CMDAT_DATA_EN (1 << 2)
  82. #define MMC_CMDAT_R0 0
  83. #define MMC_CMDAT_R1 1
  84. #define MMC_CMDAT_R2 2
  85. #define MMC_CMDAT_R3 3
  86. /* MMC_RESTO */
  87. #define MMC_RES_TO_MAX_MASK 0x7f
  88. /* MMC_RDTO */
  89. #define MMC_READ_TO_MAX_MASK 0xffff
  90. /* MMC_BLKLEN */
  91. #define MMC_BLK_LEN_MAX_MASK 0x3ff
  92. /* MMC_PRTBUF */
  93. #define MMC_PRTBUF_BUF_PART_FULL (1 << 0)
  94. /* MMC_I_MASK */
  95. #define MMC_I_MASK_TXFIFO_WR_REQ (1 << 6)
  96. #define MMC_I_MASK_RXFIFO_RD_REQ (1 << 5)
  97. #define MMC_I_MASK_CLK_IS_OFF (1 << 4)
  98. #define MMC_I_MASK_STOP_CMD (1 << 3)
  99. #define MMC_I_MASK_END_CMD_RES (1 << 2)
  100. #define MMC_I_MASK_PRG_DONE (1 << 1)
  101. #define MMC_I_MASK_DATA_TRAN_DONE (1 << 0)
  102. #define MMC_I_MASK_ALL 0x7f
  103. /* MMC_I_REG */
  104. #define MMC_I_REG_TXFIFO_WR_REQ (1 << 6)
  105. #define MMC_I_REG_RXFIFO_RD_REQ (1 << 5)
  106. #define MMC_I_REG_CLK_IS_OFF (1 << 4)
  107. #define MMC_I_REG_STOP_CMD (1 << 3)
  108. #define MMC_I_REG_END_CMD_RES (1 << 2)
  109. #define MMC_I_REG_PRG_DONE (1 << 1)
  110. #define MMC_I_REG_DATA_TRAN_DONE (1 << 0)
  111. /* MMC_CMD */
  112. #define MMC_CMD_INDEX_MAX 0x6f
  113. #define MMC_R1_IDLE_STATE 0x01
  114. #define MMC_R1_ERASE_STATE 0x02
  115. #define MMC_R1_ILLEGAL_CMD 0x04
  116. #define MMC_R1_COM_CRC_ERR 0x08
  117. #define MMC_R1_ERASE_SEQ_ERR 0x01
  118. #define MMC_R1_ADDR_ERR 0x02
  119. #define MMC_R1_PARAM_ERR 0x04
  120. #define MMC_R1B_WP_ERASE_SKIP 0x0002
  121. #define MMC_R1B_ERR 0x0004
  122. #define MMC_R1B_CC_ERR 0x0008
  123. #define MMC_R1B_CARD_ECC_ERR 0x0010
  124. #define MMC_R1B_WP_VIOLATION 0x0020
  125. #define MMC_R1B_ERASE_PARAM 0x0040
  126. #define MMC_R1B_OOR 0x0080
  127. #define MMC_R1B_IDLE_STATE 0x0100
  128. #define MMC_R1B_ERASE_RESET 0x0200
  129. #define MMC_R1B_ILLEGAL_CMD 0x0400
  130. #define MMC_R1B_COM_CRC_ERR 0x0800
  131. #define MMC_R1B_ERASE_SEQ_ERR 0x1000
  132. #define MMC_R1B_ADDR_ERR 0x2000
  133. #define MMC_R1B_PARAM_ERR 0x4000
  134. #endif /* __REGS_MMC_H__ */