mmcsd.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * File : mmcsd.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  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 along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. */
  24. #ifndef __DAVINCI_MMC_H__
  25. #define __DAVINCI_MMC_H__
  26. /* DAVINCI_MMCCTL definitions */
  27. #define MMCCTL_DATRST (1 << 0)
  28. #define MMCCTL_CMDRST (1 << 1)
  29. #define MMCCTL_WIDTH_8_BIT (1 << 8)
  30. #define MMCCTL_WIDTH_4_BIT (1 << 2)
  31. #define MMCCTL_DATEG_DISABLED (0 << 6)
  32. #define MMCCTL_DATEG_RISING (1 << 6)
  33. #define MMCCTL_DATEG_FALLING (2 << 6)
  34. #define MMCCTL_DATEG_BOTH (3 << 6)
  35. #define MMCCTL_PERMDR_LE (0 << 9)
  36. #define MMCCTL_PERMDR_BE (1 << 9)
  37. #define MMCCTL_PERMDX_LE (0 << 10)
  38. #define MMCCTL_PERMDX_BE (1 << 10)
  39. /* DAVINCI_MMCCLK definitions */
  40. #define MMCCLK_CLKEN (1 << 8)
  41. #define MMCCLK_CLKRT_MASK (0xFF << 0)
  42. /* IRQ bit definitions, for DAVINCI_MMCST0 and DAVINCI_MMCIM */
  43. #define MMCST0_DATDNE (1 << 0) /* data done */
  44. #define MMCST0_BSYDNE (1 << 1) /* busy done */
  45. #define MMCST0_RSPDNE (1 << 2) /* command done */
  46. #define MMCST0_TOUTRD (1 << 3) /* data read timeout */
  47. #define MMCST0_TOUTRS (1 << 4) /* command response timeout */
  48. #define MMCST0_CRCWR (1 << 5) /* data write CRC error */
  49. #define MMCST0_CRCRD (1 << 6) /* data read CRC error */
  50. #define MMCST0_CRCRS (1 << 7) /* command response CRC error */
  51. #define MMCST0_DXRDY (1 << 9) /* data transmit ready (fifo empty) */
  52. #define MMCST0_DRRDY (1 << 10) /* data receive ready (data in fifo)*/
  53. #define MMCST0_DATED (1 << 11) /* DAT3 edge detect */
  54. #define MMCST0_TRNDNE (1 << 12) /* transfer done */
  55. /* DAVINCI_MMCST1 definitions */
  56. #define MMCST1_BUSY (1 << 0)
  57. /* DAVINCI_MMCCMD definitions */
  58. #define MMCCMD_CMD_MASK (0x3F << 0)
  59. #define MMCCMD_PPLEN (1 << 7)
  60. #define MMCCMD_BSYEXP (1 << 8)
  61. #define MMCCMD_RSPFMT_MASK (3 << 9)
  62. #define MMCCMD_RSPFMT_NONE (0 << 9)
  63. #define MMCCMD_RSPFMT_R1456 (1 << 9)
  64. #define MMCCMD_RSPFMT_R2 (2 << 9)
  65. #define MMCCMD_RSPFMT_R3 (3 << 9)
  66. #define MMCCMD_DTRW (1 << 11)
  67. #define MMCCMD_STRMTP (1 << 12)
  68. #define MMCCMD_WDATX (1 << 13)
  69. #define MMCCMD_INITCK (1 << 14)
  70. #define MMCCMD_DCLR (1 << 15)
  71. #define MMCCMD_DMATRIG (1 << 16)
  72. /* DAVINCI_MMCFIFOCTL definitions */
  73. #define MMCFIFOCTL_FIFORST (1 << 0)
  74. #define MMCFIFOCTL_FIFODIR_WR (1 << 1)
  75. #define MMCFIFOCTL_FIFODIR_RD (0 << 1)
  76. #define MMCFIFOCTL_FIFOLEV (1 << 2) /* 0 = 128 bits, 1 = 256 bits */
  77. #define MMCFIFOCTL_ACCWD_4 (0 << 3) /* access width of 4 bytes */
  78. #define MMCFIFOCTL_ACCWD_3 (1 << 3) /* access width of 3 bytes */
  79. #define MMCFIFOCTL_ACCWD_2 (2 << 3) /* access width of 2 bytes */
  80. #define MMCFIFOCTL_ACCWD_1 (3 << 3) /* access width of 1 byte */
  81. /* DAVINCI_SDIOST0 definitions */
  82. #define SDIOST0_DAT1_HI (1 << 0)
  83. #define SDIOST0_INTPRD (1 << 1)
  84. #define SDIOST0_RDWTST (1 << 2)
  85. /* DAVINCI_SDIOIEN definitions */
  86. #define SDIOIEN_IOINTEN (1 << 0)
  87. #define SDIOIEN_RWSEN (1 << 1)
  88. /* DAVINCI_SDIOIST definitions */
  89. #define SDIOIST_IOINT (1 << 0)
  90. #define SDIOIST_RWS (1 << 1)
  91. /* MMCSD Init clock in Hz in opendrain mode */
  92. #define MMCSD_INIT_CLOCK 200000
  93. #define MAX_CCNT ((1 << 16) - 1)
  94. #define MAX_NR_SG 16
  95. #define MMC_DATA_WRITE (1 << 8)
  96. #define MMC_DATA_READ (1 << 9)
  97. #define MMC_DATA_STREAM (1 << 10)
  98. typedef struct {
  99. volatile rt_uint32_t MMCCTL;
  100. volatile rt_uint32_t MMCCLK;
  101. volatile rt_uint32_t MMCST0;
  102. volatile rt_uint32_t MMCST1;
  103. volatile rt_uint32_t MMCIM;
  104. volatile rt_uint32_t MMCTOR;
  105. volatile rt_uint32_t MMCTOD;
  106. volatile rt_uint32_t MMCBLEN;
  107. volatile rt_uint32_t MMCNBLK;
  108. volatile rt_uint32_t MMCNBLC;
  109. volatile rt_uint32_t MMCDRR;
  110. volatile rt_uint32_t MMCDXR;
  111. volatile rt_uint32_t MMCCMD;
  112. volatile rt_uint32_t MMCARGHL;
  113. volatile rt_uint32_t MMCRSP01;
  114. volatile rt_uint32_t MMCRSP23;
  115. volatile rt_uint32_t MMCRSP45;
  116. volatile rt_uint32_t MMCRSP67;
  117. volatile rt_uint32_t MMCDRSP;
  118. volatile rt_uint32_t reserved0;
  119. volatile rt_uint32_t MMCCIDX;
  120. volatile rt_uint32_t reserved1[4];
  121. volatile rt_uint32_t SDIOCTL;
  122. volatile rt_uint32_t SDIOST0;
  123. volatile rt_uint32_t SDIOIEN;
  124. volatile rt_uint32_t SDIOIST;
  125. volatile rt_uint32_t MMCFIFOCTL;
  126. }mmcsd_regs_t;
  127. extern rt_int32_t rt_hw_mmcsd_init(void);
  128. #endif