summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-04 13:14:04 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-04 13:14:04 +0000
commit9b77aa21d1f1ee57231a17d589c6c40ef3750a05 (patch)
treed07ef8415877ae176ac01d5e4df9ce2fb1747b4d /nuttx
parenta4ed011490d08b77fbdfc72b8ada8b5f068ca2e6 (diff)
downloadpx4-nuttx-9b77aa21d1f1ee57231a17d589c6c40ef3750a05.tar.gz
px4-nuttx-9b77aa21d1f1ee57231a17d589c6c40ef3750a05.tar.bz2
px4-nuttx-9b77aa21d1f1ee57231a17d589c6c40ef3750a05.zip
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
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog1
-rw-r--r--nuttx/Documentation/NuttX.html1
-rw-r--r--nuttx/TODO6
-rw-r--r--nuttx/drivers/mmcsd/mmcsd_sdio.c24
-rw-r--r--nuttx/drivers/mmcsd/mmcsd_sdio.h2
5 files changed, 27 insertions, 7 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index b4fba6ab7..5cc86cc55 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -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.
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index ea00922fd..3e46d58e8 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -2120,6 +2120,7 @@ nuttx-5.19 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
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 &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/TODO b/nuttx/TODO
index 5fb772cd6..f7878bf87 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -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.
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c
index 2503685e1..e4994000a 100644
--- a/nuttx/drivers/mmcsd/mmcsd_sdio.c
+++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c
@@ -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))
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.h b/nuttx/drivers/mmcsd/mmcsd_sdio.h
index e4eb02b3c..75f09aae0 100644
--- a/nuttx/drivers/mmcsd/mmcsd_sdio.h
+++ b/nuttx/drivers/mmcsd/mmcsd_sdio.h
@@ -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 */