sdmmc_defs.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Davinci MMC Controller Defines - Based on Linux davinci_mmc.c
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #ifndef _SDMMC_DEFS_H_
  21. #define _SDMMC_DEFS_H_
  22. #include <asm/arch/hardware.h>
  23. /* MMC Control Reg fields */
  24. #define MMCCTL_DATRST (1 << 0)
  25. #define MMCCTL_CMDRST (1 << 1)
  26. #define MMCCTL_WIDTH_4_BIT (1 << 2)
  27. #define MMCCTL_DATEG_DISABLED (0 << 6)
  28. #define MMCCTL_DATEG_RISING (1 << 6)
  29. #define MMCCTL_DATEG_FALLING (2 << 6)
  30. #define MMCCTL_DATEG_BOTH (3 << 6)
  31. #define MMCCTL_PERMDR_LE (0 << 9)
  32. #define MMCCTL_PERMDR_BE (1 << 9)
  33. #define MMCCTL_PERMDX_LE (0 << 10)
  34. #define MMCCTL_PERMDX_BE (1 << 10)
  35. /* MMC Clock Control Reg fields */
  36. #define MMCCLK_CLKEN (1 << 8)
  37. #define MMCCLK_CLKRT_MASK (0xFF << 0)
  38. /* MMC Status Reg0 fields */
  39. #define MMCST0_DATDNE (1 << 0)
  40. #define MMCST0_BSYDNE (1 << 1)
  41. #define MMCST0_RSPDNE (1 << 2)
  42. #define MMCST0_TOUTRD (1 << 3)
  43. #define MMCST0_TOUTRS (1 << 4)
  44. #define MMCST0_CRCWR (1 << 5)
  45. #define MMCST0_CRCRD (1 << 6)
  46. #define MMCST0_CRCRS (1 << 7)
  47. #define MMCST0_DXRDY (1 << 9)
  48. #define MMCST0_DRRDY (1 << 10)
  49. #define MMCST0_DATED (1 << 11)
  50. #define MMCST0_TRNDNE (1 << 12)
  51. #define MMCST0_ERR_MASK (0x00F8)
  52. /* MMC Status Reg1 fields */
  53. #define MMCST1_BUSY (1 << 0)
  54. #define MMCST1_CLKSTP (1 << 1)
  55. #define MMCST1_DXEMP (1 << 2)
  56. #define MMCST1_DRFUL (1 << 3)
  57. #define MMCST1_DAT3ST (1 << 4)
  58. #define MMCST1_FIFOEMP (1 << 5)
  59. #define MMCST1_FIFOFUL (1 << 6)
  60. /* MMC INT Mask Reg fields */
  61. #define MMCIM_EDATDNE (1 << 0)
  62. #define MMCIM_EBSYDNE (1 << 1)
  63. #define MMCIM_ERSPDNE (1 << 2)
  64. #define MMCIM_ETOUTRD (1 << 3)
  65. #define MMCIM_ETOUTRS (1 << 4)
  66. #define MMCIM_ECRCWR (1 << 5)
  67. #define MMCIM_ECRCRD (1 << 6)
  68. #define MMCIM_ECRCRS (1 << 7)
  69. #define MMCIM_EDXRDY (1 << 9)
  70. #define MMCIM_EDRRDY (1 << 10)
  71. #define MMCIM_EDATED (1 << 11)
  72. #define MMCIM_ETRNDNE (1 << 12)
  73. #define MMCIM_MASKALL (0xFFFFFFFF)
  74. /* MMC Resp Tout Reg fields */
  75. #define MMCTOR_TOR_MASK (0xFF) /* dont write to reg, | it */
  76. #define MMCTOR_TOD_20_16_SHIFT (8)
  77. /* MMC Data Read Tout Reg fields */
  78. #define MMCTOD_TOD_0_15_MASK (0xFFFF)
  79. /* MMC Block len Reg fields */
  80. #define MMCBLEN_BLEN_MASK (0xFFF)
  81. /* MMC Num Blocks Reg fields */
  82. #define MMCNBLK_NBLK_MASK (0xFFFF)
  83. #define MMCNBLK_NBLK_MAX (0xFFFF)
  84. /* MMC Num Blocks Counter Reg fields */
  85. #define MMCNBLC_NBLC_MASK (0xFFFF)
  86. /* MMC Cmd Reg fields */
  87. #define MMCCMD_CMD_MASK (0x3F)
  88. #define MMCCMD_PPLEN (1 << 7)
  89. #define MMCCMD_BSYEXP (1 << 8)
  90. #define MMCCMD_RSPFMT_NONE (0 << 9)
  91. #define MMCCMD_RSPFMT_R1567 (1 << 9)
  92. #define MMCCMD_RSPFMT_R2 (2 << 9)
  93. #define MMCCMD_RSPFMT_R3 (3 << 9)
  94. #define MMCCMD_DTRW (1 << 11)
  95. #define MMCCMD_STRMTP (1 << 12)
  96. #define MMCCMD_WDATX (1 << 13)
  97. #define MMCCMD_INITCK (1 << 14)
  98. #define MMCCMD_DCLR (1 << 15)
  99. #define MMCCMD_DMATRIG (1 << 16)
  100. /* FIFO control Reg fields */
  101. #define MMCFIFOCTL_FIFORST (1 << 0)
  102. #define MMCFIFOCTL_FIFODIR (1 << 1)
  103. #define MMCFIFOCTL_FIFOLEV (1 << 2)
  104. #define MMCFIFOCTL_ACCWD_4 (0 << 3) /* access width of 4 bytes */
  105. #define MMCFIFOCTL_ACCWD_3 (1 << 3) /* access width of 3 bytes */
  106. #define MMCFIFOCTL_ACCWD_2 (2 << 3) /* access width of 2 bytes */
  107. #define MMCFIFOCTL_ACCWD_1 (3 << 3) /* access width of 1 byte */
  108. /* Davinci MMC Register definitions */
  109. struct davinci_mmc_regs {
  110. dv_reg mmcctl;
  111. dv_reg mmcclk;
  112. dv_reg mmcst0;
  113. dv_reg mmcst1;
  114. dv_reg mmcim;
  115. dv_reg mmctor;
  116. dv_reg mmctod;
  117. dv_reg mmcblen;
  118. dv_reg mmcnblk;
  119. dv_reg mmcnblc;
  120. dv_reg mmcdrr;
  121. dv_reg mmcdxr;
  122. dv_reg mmccmd;
  123. dv_reg mmcarghl;
  124. dv_reg mmcrsp01;
  125. dv_reg mmcrsp23;
  126. dv_reg mmcrsp45;
  127. dv_reg mmcrsp67;
  128. dv_reg mmcdrsp;
  129. dv_reg mmcetok;
  130. dv_reg mmccidx;
  131. dv_reg mmcckc;
  132. dv_reg mmctorc;
  133. dv_reg mmctodc;
  134. dv_reg mmcblnc;
  135. dv_reg sdioctl;
  136. dv_reg sdiost0;
  137. dv_reg sdioien;
  138. dv_reg sdioist;
  139. dv_reg mmcfifoctl;
  140. };
  141. /* Davinci MMC board definitions */
  142. struct davinci_mmc {
  143. struct davinci_mmc_regs *reg_base; /* Register base address */
  144. uint input_clk; /* Input clock to MMC controller */
  145. uint host_caps; /* Host capabilities */
  146. uint voltages; /* Host supported voltages */
  147. uint version; /* MMC Controller version */
  148. };
  149. enum {
  150. MMC_CTLR_VERSION_1 = 0, /* DM644x and DM355 */
  151. MMC_CTLR_VERSION_2, /* DA830 */
  152. };
  153. int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host);
  154. #endif /* _SDMMC_DEFS_H */