SDIO-based MMC/SD fixes from Uros Platise

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3334 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-03-04 13:14:04 +00:00
parent 99a0f819cd
commit f81d416b37
5 changed files with 27 additions and 7 deletions

View File

@ -1518,4 +1518,5 @@
the internals of the memory manager as does mm/mm_test.c, but it has the
advantage that it runs in the actual NuttX tasking environment (the
mm/mm_test.c only runs in a PC simulation environment).
* drivers/mmcsd_sdio.c/h -- Several corrections submitted by Uros Platise.

View File

@ -2120,6 +2120,7 @@ nuttx-5.19 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
the internals of the memory manager as does mm/mm_test.c, but it has the
advantage that it runs in the actual NuttX tasking environment (the
mm/mm_test.c only runs in a PC simulation environment).
* drivers/mmcsd_sdio.c/h -- Several corrections submitted by Uros Platise.
pascal-2.1 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>

6
TODO
View File

@ -1,5 +1,5 @@
NuttX TODO List (Last updated February 28, 2011)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NuttX TODO List (Last updated March 4, 2011)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(5) Task/Scheduler (sched/)
(1) On-demand paging (sched/)
@ -896,6 +896,8 @@ o ARM/STM32 (arch/arm/src/stm32/)
the STM3210E-EVAL board. The card reports that it is a SDV1.x card
with a 1Kb block size, but the CMD16 to set the block length to
1024 fails.
Update: Part of the fix appears to be to ignore the reported block
size and to force the block size to 512.
Status: Open
Priority: Uncertain. I don't this is a bug, I think I just don't understand
how to work with this type of SD card.

View File

@ -1,7 +1,7 @@
/****************************************************************************
* drivers/mmcsd/mmcsd_sdio.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -596,7 +596,9 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4])
if (IS_BLOCK(priv->type))
{
/* C_SIZE: 69:64 from Word 2 and 63:48 from Word 3
/* Block addressed SD:
*
* C_SIZE: 69:64 from Word 2 and 63:48 from Word 3
*
* 512 = (1 << 9)
* 1024 = (1 << 10)
@ -618,15 +620,29 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4])
}
else
{
/* C_SIZE: 73:64 from Word 2 and 63:62 from Word 3 */
/* Byte addressed SD:
*
* C_SIZE: 73:64 from Word 2 and 63:62 from Word 3
*/
uint16_t csize = ((csd[1] & 0x03ff) << 2) | ((csd[2] >> 30) & 3);
uint8_t csizemult = (csd[2] >> 15) & 7;
priv->nblocks = ((uint32_t)csize + 1) * (1 << (csizemult + 2));
priv->capacity = (priv->nblocks << readbllen);
/* Force the block size to 512 bytes in any event. Some devices, such
* as 2Gb report blocksizes larger than 512 bytes but still expect to be
* accessed with a 512 byte blocksize.
*/
#if 0
priv->blockshift = readbllen;
priv->blocksize = (1 << readbllen);
priv->capacity = (priv->nblocks << readbllen);
#else
priv->blockshift = 9;
priv->blocksize = (1 << 9);
#endif
#if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS)
if (IS_SD(priv->type))

View File

@ -169,7 +169,7 @@
# define MMCSD_R6_STATE_RCV ((uint32_t)6 << MMCSD_R6_STATE_SHIFT) /* 6=Receiving data state */
# define MMCSD_R6_STATE_PRG ((uint32_t)7 << MMCSD_R6_STATE_SHIFT) /* 7=Programming state */
# define MMCSD_R6_STATE_DIS ((uint32_t) << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */
#define MMCSD_R6_ERRORMASK ((uint32_t)0x0000e00) /* Error mask */
#define MMCSD_R6_ERRORMASK ((uint32_t)0x0000e000) /* Error mask */
/* SD Configuration Register (SCR) encoding */