atmel_mci.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Copyright (C) 2005-2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __CPU_AT32AP_ATMEL_MCI_H__
  23. #define __CPU_AT32AP_ATMEL_MCI_H__
  24. /* Atmel MultiMedia Card Interface (MCI) registers */
  25. #define MMCI_CR 0x0000
  26. #define MMCI_MR 0x0004
  27. #define MMCI_DTOR 0x0008
  28. #define MMCI_SDCR 0x000c
  29. #define MMCI_ARGR 0x0010
  30. #define MMCI_CMDR 0x0014
  31. #define MMCI_RSPR 0x0020
  32. #define MMCI_RSPR1 0x0024
  33. #define MMCI_RSPR2 0x0028
  34. #define MMCI_RSPR3 0x002c
  35. #define MMCI_RDR 0x0030
  36. #define MMCI_TDR 0x0034
  37. #define MMCI_SR 0x0040
  38. #define MMCI_IER 0x0044
  39. #define MMCI_IDR 0x0048
  40. #define MMCI_IMR 0x004c
  41. /* Bitfields in CR */
  42. #define MMCI_MCIEN_OFFSET 0
  43. #define MMCI_MCIEN_SIZE 1
  44. #define MMCI_MCIDIS_OFFSET 1
  45. #define MMCI_MCIDIS_SIZE 1
  46. #define MMCI_PWSEN_OFFSET 2
  47. #define MMCI_PWSEN_SIZE 1
  48. #define MMCI_PWSDIS_OFFSET 3
  49. #define MMCI_PWSDIS_SIZE 1
  50. #define MMCI_SWRST_OFFSET 7
  51. #define MMCI_SWRST_SIZE 1
  52. /* Bitfields in MR */
  53. #define MMCI_CLKDIV_OFFSET 0
  54. #define MMCI_CLKDIV_SIZE 8
  55. #define MMCI_PWSDIV_OFFSET 8
  56. #define MMCI_PWSDIV_SIZE 3
  57. #define MMCI_PDCPADV_OFFSET 14
  58. #define MMCI_PDCPADV_SIZE 1
  59. #define MMCI_PDCMODE_OFFSET 15
  60. #define MMCI_PDCMODE_SIZE 1
  61. #define MMCI_BLKLEN_OFFSET 16
  62. #define MMCI_BLKLEN_SIZE 16
  63. /* Bitfields in DTOR */
  64. #define MMCI_DTOCYC_OFFSET 0
  65. #define MMCI_DTOCYC_SIZE 4
  66. #define MMCI_DTOMUL_OFFSET 4
  67. #define MMCI_DTOMUL_SIZE 3
  68. /* Bitfields in SDCR */
  69. #define MMCI_SCDSEL_OFFSET 0
  70. #define MMCI_SCDSEL_SIZE 4
  71. #define MMCI_SCDBUS_OFFSET 7
  72. #define MMCI_SCDBUS_SIZE 1
  73. /* Bitfields in ARGR */
  74. #define MMCI_ARG_OFFSET 0
  75. #define MMCI_ARG_SIZE 32
  76. /* Bitfields in CMDR */
  77. #define MMCI_CMDNB_OFFSET 0
  78. #define MMCI_CMDNB_SIZE 6
  79. #define MMCI_RSPTYP_OFFSET 6
  80. #define MMCI_RSPTYP_SIZE 2
  81. #define MMCI_SPCMD_OFFSET 8
  82. #define MMCI_SPCMD_SIZE 3
  83. #define MMCI_OPDCMD_OFFSET 11
  84. #define MMCI_OPDCMD_SIZE 1
  85. #define MMCI_MAXLAT_OFFSET 12
  86. #define MMCI_MAXLAT_SIZE 1
  87. #define MMCI_TRCMD_OFFSET 16
  88. #define MMCI_TRCMD_SIZE 2
  89. #define MMCI_TRDIR_OFFSET 18
  90. #define MMCI_TRDIR_SIZE 1
  91. #define MMCI_TRTYP_OFFSET 19
  92. #define MMCI_TRTYP_SIZE 2
  93. /* Bitfields in RSPRx */
  94. #define MMCI_RSP_OFFSET 0
  95. #define MMCI_RSP_SIZE 32
  96. /* Bitfields in SR/IER/IDR/IMR */
  97. #define MMCI_CMDRDY_OFFSET 0
  98. #define MMCI_CMDRDY_SIZE 1
  99. #define MMCI_RXRDY_OFFSET 1
  100. #define MMCI_RXRDY_SIZE 1
  101. #define MMCI_TXRDY_OFFSET 2
  102. #define MMCI_TXRDY_SIZE 1
  103. #define MMCI_BLKE_OFFSET 3
  104. #define MMCI_BLKE_SIZE 1
  105. #define MMCI_DTIP_OFFSET 4
  106. #define MMCI_DTIP_SIZE 1
  107. #define MMCI_NOTBUSY_OFFSET 5
  108. #define MMCI_NOTBUSY_SIZE 1
  109. #define MMCI_ENDRX_OFFSET 6
  110. #define MMCI_ENDRX_SIZE 1
  111. #define MMCI_ENDTX_OFFSET 7
  112. #define MMCI_ENDTX_SIZE 1
  113. #define MMCI_RXBUFF_OFFSET 14
  114. #define MMCI_RXBUFF_SIZE 1
  115. #define MMCI_TXBUFE_OFFSET 15
  116. #define MMCI_TXBUFE_SIZE 1
  117. #define MMCI_RINDE_OFFSET 16
  118. #define MMCI_RINDE_SIZE 1
  119. #define MMCI_RDIRE_OFFSET 17
  120. #define MMCI_RDIRE_SIZE 1
  121. #define MMCI_RCRCE_OFFSET 18
  122. #define MMCI_RCRCE_SIZE 1
  123. #define MMCI_RENDE_OFFSET 19
  124. #define MMCI_RENDE_SIZE 1
  125. #define MMCI_RTOE_OFFSET 20
  126. #define MMCI_RTOE_SIZE 1
  127. #define MMCI_DCRCE_OFFSET 21
  128. #define MMCI_DCRCE_SIZE 1
  129. #define MMCI_DTOE_OFFSET 22
  130. #define MMCI_DTOE_SIZE 1
  131. #define MMCI_OVRE_OFFSET 30
  132. #define MMCI_OVRE_SIZE 1
  133. #define MMCI_UNRE_OFFSET 31
  134. #define MMCI_UNRE_SIZE 1
  135. /* Constants for DTOMUL */
  136. #define MMCI_DTOMUL_1_CYCLE 0
  137. #define MMCI_DTOMUL_16_CYCLES 1
  138. #define MMCI_DTOMUL_128_CYCLES 2
  139. #define MMCI_DTOMUL_256_CYCLES 3
  140. #define MMCI_DTOMUL_1024_CYCLES 4
  141. #define MMCI_DTOMUL_4096_CYCLES 5
  142. #define MMCI_DTOMUL_65536_CYCLES 6
  143. #define MMCI_DTOMUL_1048576_CYCLES 7
  144. /* Constants for RSPTYP */
  145. #define MMCI_RSPTYP_NO_RESP 0
  146. #define MMCI_RSPTYP_48_BIT_RESP 1
  147. #define MMCI_RSPTYP_136_BIT_RESP 2
  148. /* Constants for SPCMD */
  149. #define MMCI_SPCMD_NO_SPEC_CMD 0
  150. #define MMCI_SPCMD_INIT_CMD 1
  151. #define MMCI_SPCMD_SYNC_CMD 2
  152. #define MMCI_SPCMD_INT_CMD 4
  153. #define MMCI_SPCMD_INT_RESP 5
  154. /* Constants for TRCMD */
  155. #define MMCI_TRCMD_NO_TRANS 0
  156. #define MMCI_TRCMD_START_TRANS 1
  157. #define MMCI_TRCMD_STOP_TRANS 2
  158. /* Constants for TRTYP */
  159. #define MMCI_TRTYP_BLOCK 0
  160. #define MMCI_TRTYP_MULTI_BLOCK 1
  161. #define MMCI_TRTYP_STREAM 2
  162. /* Bit manipulation macros */
  163. #define MMCI_BIT(name) \
  164. (1 << MMCI_##name##_OFFSET)
  165. #define MMCI_BF(name,value) \
  166. (((value) & ((1 << MMCI_##name##_SIZE) - 1)) \
  167. << MMCI_##name##_OFFSET)
  168. #define MMCI_BFEXT(name,value) \
  169. (((value) >> MMCI_##name##_OFFSET)\
  170. & ((1 << MMCI_##name##_SIZE) - 1))
  171. #define MMCI_BFINS(name,value,old) \
  172. (((old) & ~(((1 << MMCI_##name##_SIZE) - 1) \
  173. << MMCI_##name##_OFFSET)) \
  174. | MMCI_BF(name,value))
  175. /* Register access macros */
  176. #define mmci_readl(reg) \
  177. readl((void *)MMCI_BASE + MMCI_##reg)
  178. #define mmci_writel(reg,value) \
  179. writel((value), (void *)MMCI_BASE + MMCI_##reg)
  180. #endif /* __CPU_AT32AP_ATMEL_MCI_H__ */