source: umon/ports/beagleboneblack/am335x_sd.c @ 0e24873

Last change on this file since 0e24873 was 0e24873, checked in by Jarielle Catbagan <jcatbagan93@…>, on Aug 4, 2015 at 6:03:22 PM

BBB: Migrate MMC0 clock enable from am335x_sd.c:sdInit() to cpuio.c:initCPUio()

The reason why the MMC0 clock enable has to be executed much earlier is a result of the invocation
of sdInstalled() in sd.h before sdInit(). Without this migration, an exception occurs since the
MMC0 interface has not been enabled before it is accessed by sdInstalled().

  • Property mode set to 100644
File size: 14.4 KB
Line 
1/*
2 * Copyright (c) 2015 Jarielle Catbagan <jcatbagan93@gmail.com>
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 */
8
9#include "stddefs.h"
10#include "am335x.h"
11#include "sd.h"
12
13uint16_t sdrca;
14
15int
16sdcmd(uint32_t cmd, uint32_t arg, uint32_t resp[4])
17{
18        /* Clear the SD_STAT register for proper update of status bits after CMD invocation */
19        MMCHS0_REG(SD_STAT) = 0xFFFFFFFF;
20
21        MMCHS0_REG(SD_ARG) = arg;
22        MMCHS0_REG(SD_CMD) = cmd;
23
24        /* CMDx complete? */
25        while (!(MMCHS0_REG(SD_STAT) & (SD_STAT_CC | SD_STAT_ERRI)));
26
27        resp[0] = MMCHS0_REG(SD_RSP10);
28        resp[1] = MMCHS0_REG(SD_RSP32);
29        resp[2] = MMCHS0_REG(SD_RSP54);
30        resp[3] = MMCHS0_REG(SD_RSP76);
31
32        /* CMDx error? */
33        if (MMCHS0_REG(SD_STAT) & SD_STAT_ERRI)
34                return(-1);
35        else
36                return(0);
37}
38
39int
40sdCardCmd(int interface, int cmd, unsigned long arg, unsigned char *resp)
41{
42        return(-1);
43}
44
45int
46sdInit(int interface, int verbosity)
47{
48        uint32_t cmd, arg, resp[4];
49
50        /* Reset the MMC/SD controller */
51        MMCHS0_REG(SD_SYSCONFIG) = SD_SYSCONFIG_SOFTRESET;
52        while (!(MMCHS0_REG(SD_SYSSTATUS) & SD_SYSSTATUS_RESETDONE));
53
54        /* Reset the command and data lines */
55        MMCHS0_REG(SD_SYSCTL) |= SD_SYSCTL_SRA;
56        while (MMCHS0_REG(SD_SYSCTL) & SD_SYSCTL_SRA);
57
58        /* Configure the MMC/SD controller capabilities to enable 3.0 V operating voltage */
59        MMCHS0_REG(SD_CAPA) = SD_CAPA_VS30;
60
61        /* Configure SD_IE register to update certain status bits in SD_STAT */
62        MMCHS0_REG(SD_IE) = SD_IE_BADA_ENABLE | SD_IE_CERR_ENABLE | SD_IE_ACE_ENABLE |
63                SD_IE_DEB_ENABLE | SD_IE_DCRC_ENABLE | SD_IE_DTO_ENABLE | SD_IE_CIE_ENABLE |
64                SD_IE_CEB_ENABLE | SD_IE_CCRC_ENABLE | SD_IE_CIRQ_ENABLE | SD_IE_CREM_ENABLE |
65                SD_IE_CINS_ENABLE | SD_IE_BRR_ENABLE | SD_IE_BWR_ENABLE |
66                SD_IE_TC_ENABLE | SD_IE_CC_ENABLE;
67
68        /* Disable open-drain mode (only used for MMC cards) and 8-bit data width  */
69        MMCHS0_REG(SD_CON) &= ~(SD_CON_OD | SD_CON_DW8);
70
71        /* Configure the operating voltage to 3.0 V */
72        MMCHS0_REG(SD_HCTL) &= ~(SD_HCTL_SDVS);
73        MMCHS0_REG(SD_HCTL) |= SD_HCTL_SDVS_VS30;
74
75        /* Set the data width to 4-bits */
76        MMCHS0_REG(SD_HCTL) |= SD_HCTL_DTW;
77
78        /* Turn on the bus */
79        MMCHS0_REG(SD_HCTL) |= SD_HCTL_SDBP;
80        while (!(MMCHS0_REG(SD_HCTL) & SD_HCTL_SDBP));
81
82        /* Enable the internal clock */
83        MMCHS0_REG(SD_SYSCTL) |= SD_SYSCTL_ICE;
84
85        /* Configure Clock Frequency Select to 100 KHz */
86        MMCHS0_REG(SD_SYSCTL) = (MMCHS0_REG(SD_SYSCTL) & ~(SD_SYSCTL_CLKD)) | (960 << 6);
87
88        /* Wait for clock to stabilize */
89        while (!(MMCHS0_REG(SD_SYSCTL) & SD_SYSCTL_ICS));
90
91        /* Configure SD_SYSCONFIG */
92        MMCHS0_REG(SD_SYSCONFIG) &= ~(SD_SYSCONFIG_CLOCKACTIVITY | SD_SYSCONFIG_SIDLEMODE);
93        MMCHS0_REG(SD_SYSCONFIG) |= SD_SYSCONFIG_SIDLEMODE_WKUP | SD_SYSCONFIG_ENAWAKEUP_ENABLE |
94                SD_SYSCONFIG_AUTOIDLE_AUTOGATE;
95
96        /* Enable the clock to the SD card */
97        MMCHS0_REG(SD_SYSCTL) |= SD_SYSCTL_CEN_ENABLE;
98
99        /* Perform the Initialization Stream as specified in the AM335x TRM, Section 18.3.3.2
100           "Card Detection, Identicication, and Selection" */
101        MMCHS0_REG(SD_CON) |= SD_CON_INIT;
102        /* Clear the SD_STAT register */
103        MMCHS0_REG(SD_STAT) = 0xFFFFFFFF;
104        MMCHS0_REG(SD_ARG) = 0x00000000;
105        MMCHS0_REG(SD_CMD) = 0x00000000;
106        while (!(MMCHS0_REG(SD_STAT) & SD_STAT_CC));
107        /* Clear CC flag in SD_STAT */
108        MMCHS0_REG(SD_STAT) |= SD_STAT_CC;
109        MMCHS0_REG(SD_CON) &= ~SD_CON_INIT;
110
111        /* Change the clock frequency to 6 MHz and set the DTO to the maximum value setting */
112        MMCHS0_REG(SD_SYSCTL) &= ~SD_SYSCTL_DTO;
113        MMCHS0_REG(SD_SYSCTL) |= SD_SYSCTL_DTO_TCF_2_27;
114        MMCHS0_REG(SD_SYSCTL) = (MMCHS0_REG(SD_SYSCTL) & ~SD_SYSCTL_CLKD) | (16 << 6);
115
116        /* Wait for clock to stabilize */
117        while ((MMCHS0_REG(SD_SYSCTL) & SD_SYSCTL_ICS) != SD_SYSCTL_ICS);
118
119        /* Send CMD0/GO_IDLE_STATE to reset the SD card connected to MMC0 interface */
120        arg = 0x00000000;
121        cmd = SD_CMD_CMD0_GO_IDLE_STATE | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
122                SD_CMD_CICE_DISABLE | SD_CMD_CCCE_DISABLE | SD_CMD_RSP_TYPE_NO_RESPONSE;
123        if (sdcmd(cmd, arg, resp) == -1)
124                return(-1);
125
126        /* Send CMD8/SEND_IF_COND to verify that the SD card satisfies MMC/SD controller
127           requirements */
128        arg = 0x00000188;
129        cmd = SD_CMD_CMD8_SEND_IF_COND | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
130                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R7;
131        if (sdcmd(cmd, arg, resp) == -1)
132                return(-1);
133
134        /* Determine what type of SD card is connected, i.e. standard capacity, high capacity, etc.
135         * We perform a CMD55/ACMD41 loop until the "Card power up status bit" is set in the OCR
136         * register from the SD card to determine when we have a valid response */
137        do {
138                arg = 0x00000000;
139                cmd = SD_CMD_CMD55_APP_CMD | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
140                        SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
141                if (sdcmd(cmd, arg, resp) == -1)
142                        return(-1);
143
144                arg = 0x40060000;
145                cmd = SD_CMD_ACMD41_SD_SEND_OP_COND | SD_CMD_CMD_TYPE_NORMAL |
146                        SD_CMD_DP_NO_DATA_PRESENT | SD_CMD_CICE_DISABLE | SD_CMD_CCCE_DISABLE |
147                        SD_CMD_RSP_TYPE_R3;
148                if (sdcmd(cmd, arg, resp) == -1)
149                        return(-1);
150        } while (!(resp[0] & SD_RSP10_R3_CARD_POWER_UP_STATUS));
151
152        /* Check SD_RSP10 to determine whether the card connected is high capacity or not */
153        if (resp[0] & SD_RSP10_R3_CARD_CAPACITY_STATUS)
154                sdInfoTbl[interface].highcapacity = 1;
155        else
156                sdInfoTbl[interface].highcapacity = 0;
157
158        /* Send CMD2 to get SD's CID and to put the card into Identification State */
159        arg = 0x00000000;
160        cmd = SD_CMD_CMD2_ALL_SEND_CID | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
161                SD_CMD_CICE_DISABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R2;
162        if (sdcmd(cmd, arg, resp) == -1)
163                return(-1);
164
165        /* Send CMD3, i.e. request new relative address (RCA) and to put the card into
166           Stand-by State */
167        arg = 0x00000000;
168        cmd = SD_CMD_CMD3_SEND_RELATIVE_ADDR | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
169                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R6;
170        if (sdcmd(cmd, arg, resp) == -1)
171                return(-1);
172
173        /* Save the RCA published from the SD card, this will be used in future CMDx commands */
174        sdrca = (MMCHS0_REG(SD_RSP10) >> 16) & 0xFFFF;
175
176        /* Wait for the SD card to enter Stand-by State */
177        do {
178                arg = (sdrca << 16) & 0xFFFF0000;
179                cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
180                        SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
181                if (sdcmd(cmd, arg, resp) == -1)
182                        return(-1);
183        } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_STANDBY);
184
185        /* Put the card with the RCA obtained previously into Transfer State via CMD7 */
186        arg = (sdrca << 16) & 0xFFFF0000;
187        cmd = SD_CMD_CMD7_SELECT_DESELECT_CARD | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
188                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1B;
189        if (sdcmd(cmd, arg, resp) == -1)
190                return(-1);
191
192        /* Wait for the SD card to enter Transfer State */
193        do {
194                arg = (sdrca << 16) & 0xFFFF0000;
195                cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
196                        SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
197                if (sdcmd(cmd, arg, resp) == -1)
198                        return(-1);
199        } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_TRANSFER);
200
201        /* Set the bus-width to 4-bits */
202
203        /* Send CMD55 to get ready to configure the bus-width via ACMD6 */
204        arg = (sdrca << 16) & 0xFFFF0000;
205        cmd = SD_CMD_CMD55_APP_CMD | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
206                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
207        if (sdcmd(cmd, arg, resp) == -1)
208                return(-1);
209
210        /* Send ACMD6, SET_BUS_WIDTH to set the bus-width to 4-bits */
211        arg = 0x00000002;
212        cmd = SD_CMD_ACMD6_SET_BUS_WIDTH | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
213                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
214        if (sdcmd(cmd, arg, resp) == -1)
215                return(-1);
216
217        /* Put the SD card into Stand-by State */
218        arg = 0x00000000;
219        cmd = SD_CMD_CMD7_SELECT_DESELECT_CARD | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
220                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_NO_RESPONSE;
221        if (sdcmd(cmd, arg, resp) == -1)
222                return(-1);
223
224        /* Wait for the SD card to enter Stand-by State */
225        do {
226                arg = (sdrca << 16) & 0xFFFF0000;
227                cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
228                        SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
229                if (sdcmd(cmd, arg, resp) == -1)
230                        return(-1);
231        } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_STANDBY);
232
233        /* This point is reached when SD controller initialization and SD card
234           communication is successful */
235        return(0);
236}
237
238int
239sdRead(int interface, char *buf, int blknum, int blkcount)
240{
241        uint32_t cmd, arg, resp[4];
242        uint32_t *wordptr = (uint32_t *) buf;
243        int byteindex;
244
245        /* Get the SD card's status via CMD13 */
246        arg = (sdrca << 16) & 0xFFFF0000;
247        cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
248                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
249        if (sdcmd(cmd, arg, resp) == -1)
250                return(-1);
251
252        /* Ensure that the card is in Transfer State before proceeding */
253        if ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_TRANSFER) {
254                arg = (sdrca << 16) & 0xFFFF0000;
255                cmd = SD_CMD_CMD7_SELECT_DESELECT_CARD | SD_CMD_CMD_TYPE_NORMAL |
256                        SD_CMD_DP_NO_DATA_PRESENT | SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE |
257                        SD_CMD_RSP_TYPE_R1B;
258                if (sdcmd(cmd, arg, resp) == -1)
259                        return(-1);
260
261                /* Wait for the SD card to enter Transfer State */
262                do {
263                        arg = (sdrca << 16) & 0xFFFF0000;
264                        cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL |
265                                SD_CMD_DP_NO_DATA_PRESENT | SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE |
266                                SD_CMD_RSP_TYPE_R1;
267                        if (sdcmd(cmd, arg, resp) == -1)
268                                return(-1);
269                } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_TRANSFER);
270        }
271
272        /* Set the block length and the number of blocks to read */
273        MMCHS0_REG(SD_BLK) = SD_BLKSIZE | (blkcount << 16);
274        /* Send CMD18, i.e. read multiple blocks */
275        arg = blknum;
276        cmd = SD_CMD_CMD18_READ_MULTIPLE_BLOCK | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_DATA_PRESENT |
277                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1 | SD_CMD_MSBS_MULTIPLE |
278                SD_CMD_DDIR_READ | SD_CMD_ACEN_CMD12_ENABLE | SD_CMD_BCE_ENABLE;
279        if (sdcmd(cmd, arg, resp) == -1)
280                return(-1);
281
282        /* Check the data buffer to see if there is data to be read */
283        do {
284                while (!(MMCHS0_REG(SD_STAT) & SD_STAT_BRR));
285
286                /* Clear the BRR status bit in SD_STAT */
287                MMCHS0_REG(SD_STAT) |= SD_STAT_BRR;
288
289                for (byteindex = 0; byteindex < (SD_BLKSIZE / 4); byteindex++) {
290                        *wordptr = (MMCHS0_REG(SD_DATA));
291                        wordptr++;
292                }
293        } while (!(MMCHS0_REG(SD_STAT) & SD_STAT_TC));
294
295        /* Put the SD card into Stand-by State */
296        arg = 0;
297        cmd = SD_CMD_CMD7_SELECT_DESELECT_CARD | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
298                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_NO_RESPONSE;
299        if (sdcmd(cmd, arg, resp) == -1)
300                return(-1);
301
302        /* Wait for the SD card to enter Stand-by State */
303        do {
304                arg = (sdrca << 16) & 0xFFFF0000;
305                cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
306                        SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
307                if (sdcmd(cmd, arg, resp) == -1)
308                        return(-1);
309        } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_STANDBY);
310
311        return(0);
312}
313
314int
315sdWrite(int interface, char *buf, int blknum, int blkcount)
316{
317        uint32_t cmd, arg, resp[4];
318        uint32_t *wordptr = (uint32_t *) buf;
319        int byteindex;
320
321        /* Get the SD card's status by sending CMD13 */
322        arg = (sdrca << 16) & 0xFFFF0000;
323        cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
324                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
325        if (sdcmd(cmd, arg, resp) == -1)
326                return(-1);
327
328        /* Ensure that the card is in the Transfer State before proceeding */
329        if ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_TRANSFER) {
330                arg = (sdrca << 16) & 0xFFFF0000;
331                cmd  = SD_CMD_CMD7_SELECT_DESELECT_CARD | SD_CMD_CMD_TYPE_NORMAL |
332                        SD_CMD_DP_NO_DATA_PRESENT | SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE |
333                        SD_CMD_RSP_TYPE_R1B;
334                if (sdcmd(cmd, arg, resp) == -1)
335                        return(-1);
336
337                /* Wait for SD card to enter Transfer State */
338                do {
339                        arg = (sdrca << 16) & 0xFFFF0000;
340                        cmd = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL |
341                                SD_CMD_DP_NO_DATA_PRESENT | SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE |
342                                SD_CMD_RSP_TYPE_R1;
343                        if (sdcmd(cmd, arg, resp) == -1)
344                                return(-1);
345                } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_TRANSFER);
346        }
347
348        /* Set the block length in bytes and the number of blocks to write to the SD card */
349        MMCHS0_REG(SD_BLK) = SD_BLKSIZE | ( blkcount << 16);
350        /* Send CMD25, that is write the number of blocks specified in 'blkcount' from 'buf' to the
351         * location that is 512 byte aligned in the SD card specified by the block number 'blknum'
352         */
353        arg = blknum;
354        cmd = SD_CMD_CMD25_WRITE_MULTIPLE_BLOCK | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_DATA_PRESENT |
355                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1 | SD_CMD_MSBS_MULTIPLE |
356                SD_CMD_DDIR_WRITE | SD_CMD_ACEN_CMD12_ENABLE | SD_CMD_BCE_ENABLE;
357        if (sdcmd(cmd, arg, resp) == -1)
358                return(-1);
359
360        /* Write the data */
361        do {
362                /* Wait until data is ready to be written */
363                while (!(MMCHS0_REG(SD_STAT) & (SD_STAT_BWR | SD_STAT_TC)));
364
365                if (MMCHS0_REG(SD_STAT) & SD_STAT_TC)
366                        break;
367
368                /* Clear the BWR status bit in SD_STAT */
369                MMCHS0_REG(SD_STAT) |= SD_STAT_BWR;
370
371                for (byteindex = 0; byteindex < (SD_BLKSIZE / 4); byteindex++)
372                        MMCHS0_REG(SD_DATA) = *wordptr++;
373        } while (!(MMCHS0_REG(SD_STAT) & SD_STAT_TC));
374
375        /* Put the SD card into Stand-by State */
376        arg = 0x00000000;
377        cmd = SD_CMD_CMD7_SELECT_DESELECT_CARD | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
378                SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_NO_RESPONSE;
379        if (sdcmd(cmd, arg, resp) == -1)
380                return(-1);
381
382        /* Wait for SD card to enter Stand-by State */
383        do {
384                arg= (sdrca << 16) & 0xFFFF0000;
385                cmd  = SD_CMD_CMD13_SEND_STATUS | SD_CMD_CMD_TYPE_NORMAL | SD_CMD_DP_NO_DATA_PRESENT |
386                        SD_CMD_CICE_ENABLE | SD_CMD_CCCE_ENABLE | SD_CMD_RSP_TYPE_R1;
387                if (sdcmd(cmd, arg, resp) == -1)
388                        return(-1);
389        } while ((resp[0] & SD_RSP10_R1_CURRENT_STATE) != SD_RSP10_R1_CURRENT_STATE_STANDBY);
390
391        return(0);
392}
393
394int
395sdInstalled(int interface)
396{
397        if ((MMCHS0_REG(SD_CON) & SD_CON_CDP) == SD_CON_CDP_ACTIVE_HIGH)
398                if (MMCHS0_REG(SD_PSTATE) & SD_PSTATE_CINS)
399                        return(1);
400                else
401                        return(0);
402        else
403                if (MMCHS0_REG(SD_PSTATE) & SD_PSTATE_CINS)
404                        return(0);
405                else
406                        return(1);
407}
408
409int
410sdPowerup(int tot)
411{
412        return(-1);
413}
414
415int
416sdReadCxD(int interface, unsigned char *buf, int cmd)
417{
418        return(-1);
419}
Note: See TracBrowser for help on using the repository browser.