dw_mmc.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Synopsys DesignWare Multimedia Card Interface driver
  3. * (Based on NXP driver for lpc 31xx)
  4. *
  5. * Copyright (C) 2009 NXP Semiconductors
  6. * Copyright (C) 2009, 2010 Imagination Technologies Ltd.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #ifndef _DW_MMC_H_
  14. #define _DW_MMC_H_
  15. #define DW_MMC_240A 0x240a
  16. #define SDMMC_CTRL 0x000
  17. #define SDMMC_PWREN 0x004
  18. #define SDMMC_CLKDIV 0x008
  19. #define SDMMC_CLKSRC 0x00c
  20. #define SDMMC_CLKENA 0x010
  21. #define SDMMC_TMOUT 0x014
  22. #define SDMMC_CTYPE 0x018
  23. #define SDMMC_BLKSIZ 0x01c
  24. #define SDMMC_BYTCNT 0x020
  25. #define SDMMC_INTMASK 0x024
  26. #define SDMMC_CMDARG 0x028
  27. #define SDMMC_CMD 0x02c
  28. #define SDMMC_RESP0 0x030
  29. #define SDMMC_RESP1 0x034
  30. #define SDMMC_RESP2 0x038
  31. #define SDMMC_RESP3 0x03c
  32. #define SDMMC_MINTSTS 0x040
  33. #define SDMMC_RINTSTS 0x044
  34. #define SDMMC_STATUS 0x048
  35. #define SDMMC_FIFOTH 0x04c
  36. #define SDMMC_CDETECT 0x050
  37. #define SDMMC_WRTPRT 0x054
  38. #define SDMMC_GPIO 0x058
  39. #define SDMMC_TCBCNT 0x05c
  40. #define SDMMC_TBBCNT 0x060
  41. #define SDMMC_DEBNCE 0x064
  42. #define SDMMC_USRID 0x068
  43. #define SDMMC_VERID 0x06c
  44. #define SDMMC_HCON 0x070
  45. #define SDMMC_UHS_REG 0x074
  46. #define SDMMC_BMOD 0x080
  47. #define SDMMC_PLDMND 0x084
  48. #define SDMMC_DBADDR 0x088
  49. #define SDMMC_IDSTS 0x08c
  50. #define SDMMC_IDINTEN 0x090
  51. #define SDMMC_DSCADDR 0x094
  52. #define SDMMC_BUFADDR 0x098
  53. #define SDMMC_DATA(x) (x)
  54. /*
  55. * Data offset is difference according to Version
  56. * Lower than 2.40a : data register offest is 0x100
  57. */
  58. #define DATA_OFFSET 0x100
  59. #define DATA_240A_OFFSET 0x200
  60. /* shift bit field */
  61. #define _SBF(f, v) ((v) << (f))
  62. /* Control register defines */
  63. #define SDMMC_CTRL_USE_IDMAC BIT(25)
  64. #define SDMMC_CTRL_CEATA_INT_EN BIT(11)
  65. #define SDMMC_CTRL_SEND_AS_CCSD BIT(10)
  66. #define SDMMC_CTRL_SEND_CCSD BIT(9)
  67. #define SDMMC_CTRL_ABRT_READ_DATA BIT(8)
  68. #define SDMMC_CTRL_SEND_IRQ_RESP BIT(7)
  69. #define SDMMC_CTRL_READ_WAIT BIT(6)
  70. #define SDMMC_CTRL_DMA_ENABLE BIT(5)
  71. #define SDMMC_CTRL_INT_ENABLE BIT(4)
  72. #define SDMMC_CTRL_DMA_RESET BIT(2)
  73. #define SDMMC_CTRL_FIFO_RESET BIT(1)
  74. #define SDMMC_CTRL_RESET BIT(0)
  75. /* Clock Enable register defines */
  76. #define SDMMC_CLKEN_LOW_PWR BIT(16)
  77. #define SDMMC_CLKEN_ENABLE BIT(0)
  78. /* time-out register defines */
  79. #define SDMMC_TMOUT_DATA(n) _SBF(8, (n))
  80. #define SDMMC_TMOUT_DATA_MSK 0xFFFFFF00
  81. #define SDMMC_TMOUT_RESP(n) ((n) & 0xFF)
  82. #define SDMMC_TMOUT_RESP_MSK 0xFF
  83. /* card-type register defines */
  84. #define SDMMC_CTYPE_8BIT BIT(16)
  85. #define SDMMC_CTYPE_4BIT BIT(0)
  86. #define SDMMC_CTYPE_1BIT 0
  87. /* Interrupt status & mask register defines */
  88. #define SDMMC_INT_SDIO(n) BIT(16 + (n))
  89. #define SDMMC_INT_EBE BIT(15)
  90. #define SDMMC_INT_ACD BIT(14)
  91. #define SDMMC_INT_SBE BIT(13)
  92. #define SDMMC_INT_HLE BIT(12)
  93. #define SDMMC_INT_FRUN BIT(11)
  94. #define SDMMC_INT_HTO BIT(10)
  95. #define SDMMC_INT_DTO BIT(9)
  96. #define SDMMC_INT_RTO BIT(8)
  97. #define SDMMC_INT_DCRC BIT(7)
  98. #define SDMMC_INT_RCRC BIT(6)
  99. #define SDMMC_INT_RXDR BIT(5)
  100. #define SDMMC_INT_TXDR BIT(4)
  101. #define SDMMC_INT_DATA_OVER BIT(3)
  102. #define SDMMC_INT_CMD_DONE BIT(2)
  103. #define SDMMC_INT_RESP_ERR BIT(1)
  104. #define SDMMC_INT_CD BIT(0)
  105. #define SDMMC_INT_ERROR 0xbfc2
  106. /* Command register defines */
  107. #define SDMMC_CMD_START BIT(31)
  108. #define SDMMC_CMD_CCS_EXP BIT(23)
  109. #define SDMMC_CMD_CEATA_RD BIT(22)
  110. #define SDMMC_CMD_UPD_CLK BIT(21)
  111. #define SDMMC_CMD_INIT BIT(15)
  112. #define SDMMC_CMD_STOP BIT(14)
  113. #define SDMMC_CMD_PRV_DAT_WAIT BIT(13)
  114. #define SDMMC_CMD_SEND_STOP BIT(12)
  115. #define SDMMC_CMD_STRM_MODE BIT(11)
  116. #define SDMMC_CMD_DAT_WR BIT(10)
  117. #define SDMMC_CMD_DAT_EXP BIT(9)
  118. #define SDMMC_CMD_RESP_CRC BIT(8)
  119. #define SDMMC_CMD_RESP_LONG BIT(7)
  120. #define SDMMC_CMD_RESP_EXP BIT(6)
  121. #define SDMMC_CMD_INDX(n) ((n) & 0x1F)
  122. /* Status register defines */
  123. #define SDMMC_GET_FCNT(x) (((x)>>17) & 0x1FFF)
  124. /* Internal DMAC interrupt defines */
  125. #define SDMMC_IDMAC_INT_AI BIT(9)
  126. #define SDMMC_IDMAC_INT_NI BIT(8)
  127. #define SDMMC_IDMAC_INT_CES BIT(5)
  128. #define SDMMC_IDMAC_INT_DU BIT(4)
  129. #define SDMMC_IDMAC_INT_FBE BIT(2)
  130. #define SDMMC_IDMAC_INT_RI BIT(1)
  131. #define SDMMC_IDMAC_INT_TI BIT(0)
  132. /* Internal DMAC bus mode bits */
  133. #define SDMMC_IDMAC_ENABLE BIT(7)
  134. #define SDMMC_IDMAC_FB BIT(1)
  135. #define SDMMC_IDMAC_SWRESET BIT(0)
  136. /* Version ID register define */
  137. #define SDMMC_GET_VERID(x) ((x) & 0xFFFF)
  138. /* Register access macros */
  139. #define mci_readl(dev, reg) \
  140. __raw_readl((dev)->regs + SDMMC_##reg)
  141. #define mci_writel(dev, reg, value) \
  142. __raw_writel((value), (dev)->regs + SDMMC_##reg)
  143. /* 16-bit FIFO access macros */
  144. #define mci_readw(dev, reg) \
  145. __raw_readw((dev)->regs + SDMMC_##reg)
  146. #define mci_writew(dev, reg, value) \
  147. __raw_writew((value), (dev)->regs + SDMMC_##reg)
  148. /* 64-bit FIFO access macros */
  149. #ifdef readq
  150. #define mci_readq(dev, reg) \
  151. __raw_readq((dev)->regs + SDMMC_##reg)
  152. #define mci_writeq(dev, reg, value) \
  153. __raw_writeq((value), (dev)->regs + SDMMC_##reg)
  154. #else
  155. /*
  156. * Dummy readq implementation for architectures that don't define it.
  157. *
  158. * We would assume that none of these architectures would configure
  159. * the IP block with a 64bit FIFO width, so this code will never be
  160. * executed on those machines. Defining these macros here keeps the
  161. * rest of the code free from ifdefs.
  162. */
  163. #define mci_readq(dev, reg) \
  164. (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg))
  165. #define mci_writeq(dev, reg, value) \
  166. (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg) = (value))
  167. #endif
  168. extern int dw_mci_probe(struct dw_mci *host);
  169. extern void dw_mci_remove(struct dw_mci *host);
  170. #ifdef CONFIG_PM
  171. extern int dw_mci_suspend(struct dw_mci *host);
  172. extern int dw_mci_resume(struct dw_mci *host);
  173. #endif
  174. #endif /* _DW_MMC_H_ */