2 * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
\r
4 * SPDX-License-Identifier: Apache-2.0
\r
6 * Licensed under the Apache License, Version 2.0 (the License); you may
\r
7 * not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
\r
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
19 #include "Driver_MCI.h"
\r
21 #define ARM_MCI_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2, 0) /* driver version */
\r
23 /* Driver Version */
\r
24 static const ARM_DRIVER_VERSION DriverVersion = {
\r
25 ARM_MCI_API_VERSION,
\r
29 /* Driver Capabilities */
\r
30 static const ARM_MCI_CAPABILITIES DriverCapabilities = {
\r
38 1, /* data_width_4 */
\r
39 1, /* data_width_8 */
\r
40 0, /* data_width_4_ddr */
\r
41 0, /* data_width_8_ddr */
\r
43 0, /* uhs_signaling */
\r
48 0, /* uhs_driver_type_a */
\r
49 0, /* uhs_driver_type_c */
\r
50 0, /* uhs_driver_type_d */
\r
51 1, /* sdio_interrupt */
\r
53 0, /* suspend_resume */
\r
54 0, /* mmc_interrupt */
\r
64 ARM_DRIVER_VERSION ARM_MCI_GetVersion(void)
\r
68 ARM_MCI_CAPABILITIES ARM_MCI_GetCapabilities(void)
\r
72 int32_t ARM_MCI_Initialize(ARM_MCI_SignalEvent_t cb_event)
\r
76 int32_t ARM_MCI_Uninitialize(void)
\r
80 int32_t ARM_MCI_PowerControl(ARM_POWER_STATE state)
\r
90 case ARM_POWER_FULL:
\r
94 return ARM_DRIVER_ERROR_UNSUPPORTED;
\r
98 int32_t ARM_MCI_CardPower(uint32_t voltage)
\r
100 switch (voltage & ARM_MCI_POWER_VDD_Msk)
\r
102 case ARM_MCI_POWER_VDD_OFF:
\r
103 return ARM_DRIVER_OK;
\r
105 case ARM_MCI_POWER_VDD_3V3:
\r
106 return ARM_DRIVER_OK;
\r
113 int32_t ARM_MCI_ReadCD(void)
\r
117 int32_t ARM_MCI_ReadWP(void)
\r
121 int32_t ARM_MCI_SendCommand(uint32_t cmd, uint32_t arg, uint32_t flags, uint32_t *response)
\r
125 int32_t ARM_MCI_SetupTransfer(uint8_t *data, uint32_t block_count, uint32_t block_size, uint32_t mode)
\r
129 int32_t ARM_MCI_AbortTransfer(void)
\r
133 int32_t ARM_MCI_Control(uint32_t control, uint32_t arg)
\r
137 case ARM_MCI_BUS_SPEED:
\r
140 case ARM_MCI_BUS_SPEED_MODE:
\r
143 case ARM_MCI_BUS_CMD_MODE:
\r
144 /* Implement external pull-up control to support MMC cards in open-drain mode */
\r
145 /* Default mode is push-pull and is configured in Driver_MCI0.Initialize() */
\r
146 if (arg == ARM_MCI_BUS_CMD_PUSH_PULL)
\r
148 /* Configure external circuit to work in push-pull mode */
\r
150 else if (arg == ARM_MCI_BUS_CMD_OPEN_DRAIN)
\r
152 /* Configure external circuit to work in open-drain mode */
\r
156 return ARM_DRIVER_ERROR_UNSUPPORTED;
\r
160 case ARM_MCI_BUS_DATA_WIDTH:
\r
163 case ARM_MCI_BUS_DATA_WIDTH_1:
\r
165 case ARM_MCI_BUS_DATA_WIDTH_4:
\r
167 case ARM_MCI_BUS_DATA_WIDTH_8:
\r
170 return ARM_DRIVER_ERROR_UNSUPPORTED;
\r
174 case ARM_MCI_CONTROL_RESET:
\r
177 case ARM_MCI_CONTROL_CLOCK_IDLE:
\r
180 case ARM_MCI_DATA_TIMEOUT:
\r
183 case ARM_MCI_MONITOR_SDIO_INTERRUPT:
\r
186 case ARM_MCI_CONTROL_READ_WAIT:
\r
189 case ARM_MCI_DRIVER_STRENGTH:
\r
190 default: return ARM_DRIVER_ERROR_UNSUPPORTED;
\r
194 ARM_MCI_STATUS ARM_MCI_GetStatus(void)
\r
198 void ARM_MCI_SignalEvent(uint32_t event)
\r
203 // End MCI Interface
\r
205 ARM_DRIVER_MCI Driver_MCI = {
\r
206 ARM_MCI_GetVersion,
\r
207 ARM_MCI_GetCapabilities,
\r
208 ARM_MCI_Initialize,
\r
209 ARM_MCI_Uninitialize,
\r
210 ARM_MCI_PowerControl,
\r
214 ARM_MCI_SendCommand,
\r
215 ARM_MCI_SetupTransfer,
\r
216 ARM_MCI_AbortTransfer,
\r