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