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