Driver_MCI.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "Driver_MCI.h"
  19. #define ARM_MCI_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2, 0) /* driver version */
  20. /* Driver Version */
  21. static const ARM_DRIVER_VERSION DriverVersion = {
  22. ARM_MCI_API_VERSION,
  23. ARM_MCI_DRV_VERSION
  24. };
  25. /* Driver Capabilities */
  26. static const ARM_MCI_CAPABILITIES DriverCapabilities = {
  27. 0, /* cd_state */
  28. 0, /* cd_event */
  29. 0, /* vdd */
  30. 0, /* vdd_1v8 */
  31. 0, /* vccq */
  32. 0, /* vccq_1v8 */
  33. 0, /* vccq_1v2 */
  34. 1, /* data_width_4 */
  35. 1, /* data_width_8 */
  36. 0, /* data_width_4_ddr */
  37. 0, /* data_width_8_ddr */
  38. 0, /* high_speed */
  39. 0, /* uhs_signaling */
  40. 0, /* uhs_tuning */
  41. 0, /* uhs_sdr50 */
  42. 0, /* uhs_sdr104 */
  43. 0, /* uhs_ddr50 */
  44. 0, /* uhs_driver_type_a */
  45. 0, /* uhs_driver_type_c */
  46. 0, /* uhs_driver_type_d */
  47. 1, /* sdio_interrupt */
  48. 1, /* read_wait */
  49. 0, /* suspend_resume */
  50. 0, /* mmc_interrupt */
  51. 0, /* mmc_boot */
  52. 0, /* ccs */
  53. 0 /* ccs_timeout */
  54. };
  55. //
  56. // Functions
  57. //
  58. ARM_DRIVER_VERSION ARM_MCI_GetVersion(void)
  59. {
  60. }
  61. ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities(void)
  62. {
  63. }
  64. int32_t ARM_MCI_Initialize(ARM_MCI_SignalEvent_t cb_event)
  65. {
  66. }
  67. int32_t ARM_MCI_Uninitialize(void)
  68. {
  69. }
  70. int32_t ARM_MCI_PowerControl(ARM_POWER_STATE state)
  71. {
  72. switch (state)
  73. {
  74. case ARM_POWER_OFF:
  75. break;
  76. case ARM_POWER_LOW:
  77. break;
  78. case ARM_POWER_FULL:
  79. break;
  80. default:
  81. return ARM_DRIVER_ERROR_UNSUPPORTED;
  82. }
  83. }
  84. int32_t ARM_MCI_CardPower(uint32_t voltage)
  85. {
  86. switch (voltage & ARM_MCI_POWER_VDD_Msk)
  87. {
  88. case ARM_MCI_POWER_VDD_OFF:
  89. return ARM_DRIVER_OK;
  90. case ARM_MCI_POWER_VDD_3V3:
  91. return ARM_DRIVER_OK;
  92. default:
  93. break;
  94. }
  95. }
  96. int32_t ARM_MCI_ReadCD(void)
  97. {
  98. }
  99. int32_t ARM_MCI_ReadWP(void)
  100. {
  101. }
  102. int32_t ARM_MCI_SendCommand(uint32_t cmd, uint32_t arg, uint32_t flags, uint32_t *response)
  103. {
  104. }
  105. int32_t ARM_MCI_SetupTransfer(uint8_t *data, uint32_t block_count, uint32_t block_size, uint32_t mode)
  106. {
  107. }
  108. int32_t ARM_MCI_AbortTransfer(void)
  109. {
  110. }
  111. int32_t ARM_MCI_Control(uint32_t control, uint32_t arg)
  112. {
  113. switch (control)
  114. {
  115. case ARM_MCI_BUS_SPEED:
  116. break;
  117. case ARM_MCI_BUS_SPEED_MODE:
  118. break;
  119. case ARM_MCI_BUS_CMD_MODE:
  120. /* Implement external pull-up control to support MMC cards in open-drain mode */
  121. /* Default mode is push-pull and is configured in Driver_MCI0.Initialize() */
  122. if (arg == ARM_MCI_BUS_CMD_PUSH_PULL)
  123. {
  124. /* Configure external circuit to work in push-pull mode */
  125. }
  126. else if (arg == ARM_MCI_BUS_CMD_OPEN_DRAIN)
  127. {
  128. /* Configure external circuit to work in open-drain mode */
  129. }
  130. else
  131. {
  132. return ARM_DRIVER_ERROR_UNSUPPORTED;
  133. }
  134. break;
  135. case ARM_MCI_BUS_DATA_WIDTH:
  136. switch (arg)
  137. {
  138. case ARM_MCI_BUS_DATA_WIDTH_1:
  139. break;
  140. case ARM_MCI_BUS_DATA_WIDTH_4:
  141. break;
  142. case ARM_MCI_BUS_DATA_WIDTH_8:
  143. break;
  144. default:
  145. return ARM_DRIVER_ERROR_UNSUPPORTED;
  146. }
  147. break;
  148. case ARM_MCI_CONTROL_RESET:
  149. break;
  150. case ARM_MCI_CONTROL_CLOCK_IDLE:
  151. break;
  152. case ARM_MCI_DATA_TIMEOUT:
  153. break;
  154. case ARM_MCI_MONITOR_SDIO_INTERRUPT:
  155. break;
  156. case ARM_MCI_CONTROL_READ_WAIT:
  157. break;
  158. case ARM_MCI_DRIVER_STRENGTH:
  159. default: return ARM_DRIVER_ERROR_UNSUPPORTED;
  160. }
  161. }
  162. ARM_MCI_STATUS ARM_MCI_GetStatus(void)
  163. {
  164. }
  165. void ARM_MCI_SignalEvent(uint32_t event)
  166. {
  167. // function body
  168. }
  169. // End MCI Interface
  170. ARM_DRIVER_MCI Driver_MCI = {
  171. ARM_MCI_GetVersion,
  172. ARM_MCI_GetCapabilities,
  173. ARM_MCI_Initialize,
  174. ARM_MCI_Uninitialize,
  175. ARM_MCI_PowerControl,
  176. ARM_MCI_CardPower,
  177. ARM_MCI_ReadCD,
  178. ARM_MCI_ReadWP,
  179. ARM_MCI_SendCommand,
  180. ARM_MCI_SetupTransfer,
  181. ARM_MCI_AbortTransfer,
  182. ARM_MCI_Control,
  183. ARM_MCI_GetStatus
  184. };