dwmmc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * (C) Copyright 2012 SAMSUNG Electronics
  3. * Jaehoon Chung <jh80.chung@samsung.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. */
  20. #ifndef __DWMMC_HW_H
  21. #define __DWMMC_HW_H
  22. #include <asm/io.h>
  23. #include <mmc.h>
  24. #define DWMCI_CTRL 0x000
  25. #define DWMCI_PWREN 0x004
  26. #define DWMCI_CLKDIV 0x008
  27. #define DWMCI_CLKSRC 0x00C
  28. #define DWMCI_CLKENA 0x010
  29. #define DWMCI_TMOUT 0x014
  30. #define DWMCI_CTYPE 0x018
  31. #define DWMCI_BLKSIZ 0x01C
  32. #define DWMCI_BYTCNT 0x020
  33. #define DWMCI_INTMASK 0x024
  34. #define DWMCI_CMDARG 0x028
  35. #define DWMCI_CMD 0x02C
  36. #define DWMCI_RESP0 0x030
  37. #define DWMCI_RESP1 0x034
  38. #define DWMCI_RESP2 0x038
  39. #define DWMCI_RESP3 0x03C
  40. #define DWMCI_MINTSTS 0x040
  41. #define DWMCI_RINTSTS 0x044
  42. #define DWMCI_STATUS 0x048
  43. #define DWMCI_FIFOTH 0x04C
  44. #define DWMCI_CDETECT 0x050
  45. #define DWMCI_WRTPRT 0x054
  46. #define DWMCI_GPIO 0x058
  47. #define DWMCI_TCMCNT 0x05C
  48. #define DWMCI_TBBCNT 0x060
  49. #define DWMCI_DEBNCE 0x064
  50. #define DWMCI_USRID 0x068
  51. #define DWMCI_VERID 0x06C
  52. #define DWMCI_HCON 0x070
  53. #define DWMCI_UHS_REG 0x074
  54. #define DWMCI_BMOD 0x080
  55. #define DWMCI_PLDMND 0x084
  56. #define DWMCI_DBADDR 0x088
  57. #define DWMCI_IDSTS 0x08C
  58. #define DWMCI_IDINTEN 0x090
  59. #define DWMCI_DSCADDR 0x094
  60. #define DWMCI_BUFADDR 0x098
  61. #define DWMCI_DATA 0x200
  62. /* Interrupt Mask register */
  63. #define DWMCI_INTMSK_ALL 0xffffffff
  64. #define DWMCI_INTMSK_RE (1 << 1)
  65. #define DWMCI_INTMSK_CDONE (1 << 2)
  66. #define DWMCI_INTMSK_DTO (1 << 3)
  67. #define DWMCI_INTMSK_TXDR (1 << 4)
  68. #define DWMCI_INTMSK_RXDR (1 << 5)
  69. #define DWMCI_INTMSK_DCRC (1 << 7)
  70. #define DWMCI_INTMSK_RTO (1 << 8)
  71. #define DWMCI_INTMSK_DRTO (1 << 9)
  72. #define DWMCI_INTMSK_HTO (1 << 10)
  73. #define DWMCI_INTMSK_FRUN (1 << 11)
  74. #define DWMCI_INTMSK_HLE (1 << 12)
  75. #define DWMCI_INTMSK_SBE (1 << 13)
  76. #define DWMCI_INTMSK_ACD (1 << 14)
  77. #define DWMCI_INTMSK_EBE (1 << 15)
  78. /* Raw interrupt Regsiter */
  79. #define DWMCI_DATA_ERR (DWMCI_INTMSK_EBE | DWMCI_INTMSK_SBE | DWMCI_INTMSK_HLE |\
  80. DWMCI_INTMSK_FRUN | DWMCI_INTMSK_EBE | DWMCI_INTMSK_DCRC)
  81. #define DWMCI_DATA_TOUT (DWMCI_INTMSK_HTO | DWMCI_INTMSK_DRTO)
  82. /* CTRL register */
  83. #define DWMCI_CTRL_RESET (1 << 0)
  84. #define DWMCI_CTRL_FIFO_RESET (1 << 1)
  85. #define DWMCI_CTRL_DMA_RESET (1 << 2)
  86. #define DWMCI_DMA_EN (1 << 5)
  87. #define DWMCI_CTRL_SEND_AS_CCSD (1 << 10)
  88. #define DWMCI_IDMAC_EN (1 << 25)
  89. #define DWMCI_RESET_ALL (DWMCI_CTRL_RESET | DWMCI_CTRL_FIFO_RESET |\
  90. DWMCI_CTRL_DMA_RESET)
  91. /* CMD register */
  92. #define DWMCI_CMD_RESP_EXP (1 << 6)
  93. #define DWMCI_CMD_RESP_LENGTH (1 << 7)
  94. #define DWMCI_CMD_CHECK_CRC (1 << 8)
  95. #define DWMCI_CMD_DATA_EXP (1 << 9)
  96. #define DWMCI_CMD_RW (1 << 10)
  97. #define DWMCI_CMD_SEND_STOP (1 << 12)
  98. #define DWMCI_CMD_ABORT_STOP (1 << 14)
  99. #define DWMCI_CMD_PRV_DAT_WAIT (1 << 13)
  100. #define DWMCI_CMD_UPD_CLK (1 << 21)
  101. #define DWMCI_CMD_USE_HOLD_REG (1 << 29)
  102. #define DWMCI_CMD_START (1 << 31)
  103. /* CLKENA register */
  104. #define DWMCI_CLKEN_ENABLE (1 << 0)
  105. #define DWMCI_CLKEN_LOW_PWR (1 << 16)
  106. /* Card-type registe */
  107. #define DWMCI_CTYPE_1BIT 0
  108. #define DWMCI_CTYPE_4BIT (1 << 0)
  109. #define DWMCI_CTYPE_8BIT (1 << 16)
  110. /* Status Register */
  111. #define DWMCI_BUSY (1 << 9)
  112. /* FIFOTH Register */
  113. #define MSIZE(x) ((x) << 28)
  114. #define RX_WMARK(x) ((x) << 16)
  115. #define TX_WMARK(x) (x)
  116. #define DWMCI_IDMAC_OWN (1 << 31)
  117. #define DWMCI_IDMAC_CH (1 << 4)
  118. #define DWMCI_IDMAC_FS (1 << 3)
  119. #define DWMCI_IDMAC_LD (1 << 2)
  120. /* Bus Mode Register */
  121. #define DWMCI_BMOD_IDMAC_RESET (1 << 0)
  122. #define DWMCI_BMOD_IDMAC_FB (1 << 1)
  123. #define DWMCI_BMOD_IDMAC_EN (1 << 7)
  124. struct dwmci_host {
  125. char *name;
  126. void *ioaddr;
  127. unsigned int quirks;
  128. unsigned int caps;
  129. unsigned int version;
  130. unsigned int clock;
  131. unsigned int bus_hz;
  132. int dev_index;
  133. int buswidth;
  134. u32 fifoth_val;
  135. struct mmc *mmc;
  136. void (*clksel)(struct dwmci_host *host);
  137. unsigned int (*mmc_clk)(int dev_index);
  138. };
  139. struct dwmci_idmac {
  140. u32 flags;
  141. u32 cnt;
  142. u32 addr;
  143. u32 next_addr;
  144. };
  145. static inline void dwmci_writel(struct dwmci_host *host, int reg, u32 val)
  146. {
  147. writel(val, host->ioaddr + reg);
  148. }
  149. static inline void dwmci_writew(struct dwmci_host *host, int reg, u16 val)
  150. {
  151. writew(val, host->ioaddr + reg);
  152. }
  153. static inline void dwmci_writeb(struct dwmci_host *host, int reg, u8 val)
  154. {
  155. writeb(val, host->ioaddr + reg);
  156. }
  157. static inline u32 dwmci_readl(struct dwmci_host *host, int reg)
  158. {
  159. return readl(host->ioaddr + reg);
  160. }
  161. static inline u16 dwmci_readw(struct dwmci_host *host, int reg)
  162. {
  163. return readw(host->ioaddr + reg);
  164. }
  165. static inline u8 dwmci_readb(struct dwmci_host *host, int reg)
  166. {
  167. return readb(host->ioaddr + reg);
  168. }
  169. int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk);
  170. #endif /* __DWMMC_HW_H */