sdhost.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //*****************************************************************************
  2. //
  3. // sdhost.h
  4. //
  5. // Defines and Macros for the SDHost.
  6. //
  7. // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
  8. //
  9. //
  10. // Redistribution and use in source and binary forms, with or without
  11. // modification, are permitted provided that the following conditions
  12. // are met:
  13. //
  14. // Redistributions of source code must retain the above copyright
  15. // notice, this list of conditions and the following disclaimer.
  16. //
  17. // Redistributions in binary form must reproduce the above copyright
  18. // notice, this list of conditions and the following disclaimer in the
  19. // documentation and/or other materials provided with the
  20. // distribution.
  21. //
  22. // Neither the name of Texas Instruments Incorporated nor the names of
  23. // its contributors may be used to endorse or promote products derived
  24. // from this software without specific prior written permission.
  25. //
  26. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  30. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  31. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. //
  38. //*****************************************************************************
  39. #ifndef __SDHOST_H__
  40. #define __SDHOST_H__
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. //{
  50. #endif
  51. //*****************************************************************************
  52. // Values that can be passed to SDHostRespGet().
  53. //*****************************************************************************
  54. #define SDHOST_RESP_10 0x00000003
  55. #define SDHOST_RESP_32 0x00000002
  56. #define SDHOST_RESP_54 0x00000001
  57. #define SDHOST_RESP_76 0x00000000
  58. //*****************************************************************************
  59. // Values that can be passed to SDHostIntEnable(), SDHostIntDisable(),
  60. // SDHostIntClear() ,and returned from SDHostIntStatus().
  61. //*****************************************************************************
  62. #define SDHOST_INT_CC 0x00000001
  63. #define SDHOST_INT_TC 0x00000002
  64. #define SDHOST_INT_BWR 0x00000010
  65. #define SDHOST_INT_BRR 0x00000020
  66. #define SDHOST_INT_ERRI 0x00008000
  67. #define SDHOST_INT_CTO 0x00010000
  68. #define SDHOST_INT_CEB 0x00040000
  69. #define SDHOST_INT_DTO 0x00100000
  70. #define SDHOST_INT_DCRC 0x00200000
  71. #define SDHOST_INT_DEB 0x00400000
  72. #define SDHOST_INT_CERR 0x10000000
  73. #define SDHOST_INT_BADA 0x20000000
  74. #define SDHOST_INT_DMARD 0x40000000
  75. #define SDHOST_INT_DMAWR 0x80000000
  76. //*****************************************************************************
  77. // Values that can be passed to SDHostCmdSend().
  78. //*****************************************************************************
  79. #define SDHOST_CMD_0 0x00000000
  80. #define SDHOST_CMD_1 0x01000000
  81. #define SDHOST_CMD_2 0x02000000
  82. #define SDHOST_CMD_3 0x03000000
  83. #define SDHOST_CMD_4 0x04000000
  84. #define SDHOST_CMD_5 0x05000000
  85. #define SDHOST_CMD_6 0x06000000
  86. #define SDHOST_CMD_7 0x07000000
  87. #define SDHOST_CMD_8 0x08000000
  88. #define SDHOST_CMD_9 0x09000000
  89. #define SDHOST_CMD_10 0x0A000000
  90. #define SDHOST_CMD_11 0x0B000000
  91. #define SDHOST_CMD_12 0x0C000000
  92. #define SDHOST_CMD_13 0x0D000000
  93. #define SDHOST_CMD_14 0x0E000000
  94. #define SDHOST_CMD_15 0x0F000000
  95. #define SDHOST_CMD_16 0x10000000
  96. #define SDHOST_CMD_17 0x11000000
  97. #define SDHOST_CMD_18 0x12000000
  98. #define SDHOST_CMD_19 0x13000000
  99. #define SDHOST_CMD_20 0x14000000
  100. #define SDHOST_CMD_21 0x15000000
  101. #define SDHOST_CMD_22 0x16000000
  102. #define SDHOST_CMD_23 0x17000000
  103. #define SDHOST_CMD_24 0x18000000
  104. #define SDHOST_CMD_25 0x19000000
  105. #define SDHOST_CMD_26 0x1A000000
  106. #define SDHOST_CMD_27 0x1B000000
  107. #define SDHOST_CMD_28 0x1C000000
  108. #define SDHOST_CMD_29 0x1D000000
  109. #define SDHOST_CMD_30 0x1E000000
  110. #define SDHOST_CMD_31 0x1F000000
  111. #define SDHOST_CMD_32 0x20000000
  112. #define SDHOST_CMD_33 0x21000000
  113. #define SDHOST_CMD_34 0x22000000
  114. #define SDHOST_CMD_35 0x23000000
  115. #define SDHOST_CMD_36 0x24000000
  116. #define SDHOST_CMD_37 0x25000000
  117. #define SDHOST_CMD_38 0x26000000
  118. #define SDHOST_CMD_39 0x27000000
  119. #define SDHOST_CMD_40 0x28000000
  120. #define SDHOST_CMD_41 0x29000000
  121. #define SDHOST_CMD_42 0x2A000000
  122. #define SDHOST_CMD_43 0x2B000000
  123. #define SDHOST_CMD_44 0x2C000000
  124. #define SDHOST_CMD_45 0x2D000000
  125. #define SDHOST_CMD_46 0x2E000000
  126. #define SDHOST_CMD_47 0x2F000000
  127. #define SDHOST_CMD_48 0x30000000
  128. #define SDHOST_CMD_49 0x31000000
  129. #define SDHOST_CMD_50 0x32000000
  130. #define SDHOST_CMD_51 0x33000000
  131. #define SDHOST_CMD_52 0x34000000
  132. #define SDHOST_CMD_53 0x35000000
  133. #define SDHOST_CMD_54 0x36000000
  134. #define SDHOST_CMD_55 0x37000000
  135. #define SDHOST_CMD_56 0x38000000
  136. #define SDHOST_CMD_57 0x39000000
  137. #define SDHOST_CMD_58 0x3A000000
  138. #define SDHOST_CMD_59 0x3B000000
  139. #define SDHOST_CMD_60 0x3C000000
  140. #define SDHOST_CMD_61 0x3D000000
  141. #define SDHOST_CMD_62 0x3E000000
  142. #define SDHOST_CMD_63 0x3F000000
  143. //*****************************************************************************
  144. // Values that can be logically ORed with ulCmd parameter for SDHostCmdSend().
  145. //*****************************************************************************
  146. #define SDHOST_MULTI_BLK 0x00000022
  147. #define SDHOST_DMA_EN 0x00000001
  148. #define SDHOST_WR_CMD 0x00200000
  149. #define SDHOST_RD_CMD 0x00200010
  150. #define SDHOST_RESP_LEN_136 0x00010000
  151. #define SDHOST_RESP_LEN_48 0x00020000
  152. #define SDHOST_RESP_LEN_48B 0x00030000
  153. //*****************************************************************************
  154. //
  155. // API Function prototypes
  156. //
  157. //*****************************************************************************
  158. extern void SDHostCmdReset(unsigned long ulBase);
  159. extern void SDHostInit(unsigned long ulBase);
  160. extern long SDHostCmdSend(unsigned long ulBase,unsigned long ulCmd,
  161. unsigned ulArg);
  162. extern void SDHostIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
  163. extern void SDHostIntUnregister(unsigned long ulBase);
  164. extern void SDHostIntEnable(unsigned long ulBase,unsigned long ulIntFlags);
  165. extern void SDHostIntDisable(unsigned long ulBase,unsigned long ulIntFlags);
  166. extern unsigned long SDHostIntStatus(unsigned long ulBase);
  167. extern void SDHostIntClear(unsigned long ulBase,unsigned long ulIntFlags);
  168. extern void SDHostCardErrorMaskSet(unsigned long ulBase,
  169. unsigned long ulErrMask);
  170. extern unsigned long SDHostCardErrorMaskGet(unsigned long ulBase);
  171. extern void SDHostSetExpClk(unsigned long ulBase, unsigned long ulSDHostClk,
  172. unsigned long ulCardClk);
  173. extern void SDHostRespGet(unsigned long ulBase, unsigned long ulRespnse[4]);
  174. extern void SDHostBlockSizeSet(unsigned long ulBase, unsigned short ulBlkSize);
  175. extern void SDHostBlockCountSet(unsigned long ulBase,
  176. unsigned short ulBlkCount);
  177. extern tBoolean SDHostDataNonBlockingWrite(unsigned long ulBase,
  178. unsigned long ulData);
  179. extern tBoolean SDHostDataNonBlockingRead(unsigned long ulBase,
  180. unsigned long *pulData);
  181. extern void SDHostDataWrite(unsigned long ulBase, unsigned long ulData);
  182. extern void SDHostDataRead(unsigned long ulBase, unsigned long *ulData);
  183. //*****************************************************************************
  184. //
  185. // Mark the end of the C bindings section for C++ compilers.
  186. //
  187. //*****************************************************************************
  188. #ifdef __cplusplus
  189. //}
  190. #endif
  191. #endif // __SDHOST_H__