Driver_MCI.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Copyright (c) 2013-2020 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(1, 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, /* wp_state */
  30. 0, /* vdd */
  31. 0, /* vdd_1v8 */
  32. 0, /* vccq */
  33. 0, /* vccq_1v8 */
  34. 0, /* vccq_1v2 */
  35. 0, /* data_width_4 */
  36. 0, /* data_width_8 */
  37. 0, /* data_width_4_ddr */
  38. 0, /* data_width_8_ddr */
  39. 0, /* high_speed */
  40. 0, /* uhs_signaling */
  41. 0, /* uhs_tuning */
  42. 0, /* uhs_sdr50 */
  43. 0, /* uhs_sdr104 */
  44. 0, /* uhs_ddr50 */
  45. 0, /* uhs_driver_type_a */
  46. 0, /* uhs_driver_type_c */
  47. 0, /* uhs_driver_type_d */
  48. 0, /* sdio_interrupt */
  49. 0, /* read_wait */
  50. 0, /* suspend_resume */
  51. 0, /* mmc_interrupt */
  52. 0, /* mmc_boot */
  53. 0, /* rst_n */
  54. 0, /* ccs */
  55. 0, /* ccs_timeout */
  56. 0 /* Reserved */
  57. };
  58. //
  59. // Functions
  60. //
  61. static ARM_DRIVER_VERSION ARM_MCI_GetVersion(void)
  62. {
  63. return DriverVersion;
  64. }
  65. static ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities(void)
  66. {
  67. return DriverCapabilities;
  68. }
  69. static int32_t ARM_MCI_Initialize(ARM_MCI_SignalEvent_t cb_event)
  70. {
  71. }
  72. static int32_t ARM_MCI_Uninitialize(void)
  73. {
  74. }
  75. static int32_t ARM_MCI_PowerControl(ARM_POWER_STATE state)
  76. {
  77. switch (state)
  78. {
  79. case ARM_POWER_OFF:
  80. break;
  81. case ARM_POWER_LOW:
  82. break;
  83. case ARM_POWER_FULL:
  84. break;
  85. }
  86. return ARM_DRIVER_ERROR_UNSUPPORTED;
  87. }
  88. static int32_t ARM_MCI_CardPower(uint32_t voltage)
  89. {
  90. switch (voltage & ARM_MCI_POWER_VDD_Msk)
  91. {
  92. case ARM_MCI_POWER_VDD_OFF:
  93. return ARM_DRIVER_OK;
  94. case ARM_MCI_POWER_VDD_3V3:
  95. return ARM_DRIVER_OK;
  96. default:
  97. break;
  98. }
  99. return ARM_DRIVER_ERROR;
  100. }
  101. static int32_t ARM_MCI_ReadCD(void)
  102. {
  103. }
  104. static int32_t ARM_MCI_ReadWP(void)
  105. {
  106. }
  107. static int32_t ARM_MCI_SendCommand(uint32_t cmd, uint32_t arg, uint32_t flags, uint32_t *response)
  108. {
  109. }
  110. static int32_t ARM_MCI_SetupTransfer(uint8_t *data, uint32_t block_count, uint32_t block_size, uint32_t mode)
  111. {
  112. }
  113. static int32_t ARM_MCI_AbortTransfer(void)
  114. {
  115. }
  116. static int32_t ARM_MCI_Control(uint32_t control, uint32_t arg)
  117. {
  118. switch (control)
  119. {
  120. case ARM_MCI_BUS_SPEED:
  121. break;
  122. case ARM_MCI_BUS_SPEED_MODE:
  123. break;
  124. case ARM_MCI_BUS_CMD_MODE:
  125. /* Implement external pull-up control to support MMC cards in open-drain mode */
  126. /* Default mode is push-pull and is configured in Driver_MCI0.Initialize() */
  127. if (arg == ARM_MCI_BUS_CMD_PUSH_PULL)
  128. {
  129. /* Configure external circuit to work in push-pull mode */
  130. }
  131. else if (arg == ARM_MCI_BUS_CMD_OPEN_DRAIN)
  132. {
  133. /* Configure external circuit to work in open-drain mode */
  134. }
  135. else
  136. {
  137. return ARM_DRIVER_ERROR_UNSUPPORTED;
  138. }
  139. break;
  140. case ARM_MCI_BUS_DATA_WIDTH:
  141. switch (arg)
  142. {
  143. case ARM_MCI_BUS_DATA_WIDTH_1:
  144. break;
  145. case ARM_MCI_BUS_DATA_WIDTH_4:
  146. break;
  147. case ARM_MCI_BUS_DATA_WIDTH_8:
  148. break;
  149. default:
  150. return ARM_DRIVER_ERROR_UNSUPPORTED;
  151. }
  152. break;
  153. case ARM_MCI_CONTROL_RESET:
  154. break;
  155. case ARM_MCI_CONTROL_CLOCK_IDLE:
  156. break;
  157. case ARM_MCI_DATA_TIMEOUT:
  158. break;
  159. case ARM_MCI_MONITOR_SDIO_INTERRUPT:
  160. break;
  161. case ARM_MCI_CONTROL_READ_WAIT:
  162. break;
  163. case ARM_MCI_DRIVER_STRENGTH:
  164. default: return ARM_DRIVER_ERROR_UNSUPPORTED;
  165. }
  166. }
  167. static ARM_MCI_STATUS ARM_MCI_GetStatus(void)
  168. {
  169. }
  170. static void ARM_MCI_SignalEvent(uint32_t event)
  171. {
  172. // function body
  173. }
  174. // End MCI Interface
  175. extern \
  176. ARM_DRIVER_MCI Driver_MCI0;
  177. ARM_DRIVER_MCI Driver_MCI0 = {
  178. ARM_MCI_GetVersion,
  179. ARM_MCI_GetCapabilities,
  180. ARM_MCI_Initialize,
  181. ARM_MCI_Uninitialize,
  182. ARM_MCI_PowerControl,
  183. ARM_MCI_CardPower,
  184. ARM_MCI_ReadCD,
  185. ARM_MCI_ReadWP,
  186. ARM_MCI_SendCommand,
  187. ARM_MCI_SetupTransfer,
  188. ARM_MCI_AbortTransfer,
  189. ARM_MCI_Control,
  190. ARM_MCI_GetStatus
  191. };