summaryrefslogtreecommitdiff
path: root/nuttx/drivers/mmcsd/mmcsd_sdio.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-04 16:24:51 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-04 16:24:51 +0000
commit4215984218b33387d048353b23140f4bec0dfae2 (patch)
treea6659d102e74bc59662e32c513fadb7ea3afcf94 /nuttx/drivers/mmcsd/mmcsd_sdio.c
parent9b77aa21d1f1ee57231a17d589c6c40ef3750a05 (diff)
downloadnuttx-4215984218b33387d048353b23140f4bec0dfae2.tar.gz
nuttx-4215984218b33387d048353b23140f4bec0dfae2.tar.bz2
nuttx-4215984218b33387d048353b23140f4bec0dfae2.zip
SDIO-based MMC/SD fixes from Uros Platise
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3335 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/mmcsd/mmcsd_sdio.c')
-rw-r--r--nuttx/drivers/mmcsd/mmcsd_sdio.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c
index e4994000a..779cfb32e 100644
--- a/nuttx/drivers/mmcsd/mmcsd_sdio.c
+++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c
@@ -626,23 +626,26 @@ static void mmcsd_decodeCSD(FAR struct mmcsd_state_s *priv, uint32_t csd[4])
*/
uint16_t csize = ((csd[1] & 0x03ff) << 2) | ((csd[2] >> 30) & 3);
- uint8_t csizemult = (csd[2] >> 15) & 7;
+ uint8_t csizemult = (csd[2] >> 15) & 7;
priv->nblocks = ((uint32_t)csize + 1) * (1 << (csizemult + 2));
+ priv->blockshift = readbllen;
+ priv->blocksize = (1 << readbllen);
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.
+ /* Some devices, such as 2Gb devices, report blocksizes larger than 512 bytes
+ * but still expect to be accessed with a 512 byte blocksize.
+ *
+ * NOTE: A minor optimization would be to eliminated priv->blocksize and
+ * priv->blockshift: Those values will be 512 and 9 in all cases anyway.
*/
-#if 0
- priv->blockshift = readbllen;
- priv->blocksize = (1 << readbllen);
-#else
- priv->blockshift = 9;
- priv->blocksize = (1 << 9);
-#endif
+ if (priv->blocksize > 512)
+ {
+ priv->nblocks <<= (priv->blockshift - 9);
+ priv->blocksize = 512;
+ priv->blockshift = 9;
+ }
#if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS)
if (IS_SD(priv->type))