diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-11-15 19:56:33 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-11-15 19:56:33 +0000 |
commit | 95fed89d38ac353532f9688ff4b9e1b36771c730 (patch) | |
tree | 39d9cd31b5db3ab2916d648e4b53f1f7ccc49009 | |
parent | 59bb946412549e5be5d4b5696c7eab3bbd847da4 (diff) | |
download | px4-nuttx-95fed89d38ac353532f9688ff4b9e1b36771c730.tar.gz px4-nuttx-95fed89d38ac353532f9688ff4b9e1b36771c730.tar.bz2 px4-nuttx-95fed89d38ac353532f9688ff4b9e1b36771c730.zip |
Eliminate some warnings
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2260 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/drivers/mmcsd/mmcsd_sdio.c | 187 |
1 files changed, 94 insertions, 93 deletions
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c index c7f168b40..cab079556 100644 --- a/nuttx/drivers/mmcsd/mmcsd_sdio.c +++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c @@ -312,11 +312,11 @@ static inline int mmcsd_sendcmd4(struct mmcsd_state_s *priv) static int mmcsd_recvR1(struct mmcsd_state_s *priv, uint32 cmd) { - uint32 r1;
- int ret;
+ uint32 r1; + int ret; /* Get the R1 response from the hardware */ -
+ ret = SDIO_RECVR1(priv->dev, cmd, &r1); if (ret == OK) { @@ -344,41 +344,41 @@ static int mmcsd_recvR1(struct mmcsd_state_s *priv, uint32 cmd) static int mmcsd_getSCR(struct mmcsd_state_s *priv, uint32 scr[2]) { int ret; -
- /* Set Block Size To 8 Bytes */
- /* Send CMD55 APP_CMD with argument as card's RCA */
-
- mmcsd_sendcmdpoll(priv, MMCSD_CMD16, 8);
- ret = mmcsd_recvR1(priv, MMCSD_CMD16);
- if (ret != OK)
+ + /* Set Block Size To 8 Bytes */ + /* Send CMD55 APP_CMD with argument as card's RCA */ + + mmcsd_sendcmdpoll(priv, MMCSD_CMD16, 8); + ret = mmcsd_recvR1(priv, MMCSD_CMD16); + if (ret != OK) + { + fdbg("ERROR: RECVR1 for CMD16 failed: %d\n", ret); + return ret; + } + + /* Send CMD55 APP_CMD with argument as card's RCA */ + + mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16); + ret = mmcsd_recvR1(priv, SD_CMD55); + if (ret != OK) { - fdbg("ERROR: RECVR1 for CMD16 failed: %d\n", ret);
- return ret;
- }
-
- /* Send CMD55 APP_CMD with argument as card's RCA */
-
- mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16);
- ret = mmcsd_recvR1(priv, SD_CMD55);
- if (ret != OK)
- {
fdbg("ERROR: RECVR1 for CMD55 failed: %d\n", ret); - return ret;
- }
+ return ret; + } /* Setup up to receive data */ - SDIO_RECVSETUP(priv->dev, 8);
-
- /* Send ACMD51 SD_APP_SEND_SCR with argument as 0 to start data receipt */
-
+ SDIO_RECVSETUP(priv->dev, 8); + + /* Send ACMD51 SD_APP_SEND_SCR with argument as 0 to start data receipt */ + (void)SDIO_EVENTENABLE(priv->dev, SDIOEVENT_READDATADONE); - mmcsd_sendcmdpoll(priv, SD_ACMD51, 0);
- ret = mmcsd_recvR1(priv, SD_ACMD51);
- if (ret != OK)
- {
+ mmcsd_sendcmdpoll(priv, SD_ACMD51, 0); + ret = mmcsd_recvR1(priv, SD_ACMD51); + if (ret != OK) + { fdbg("ERROR: RECVR1 for ACMD51 failed: %d\n", ret); - return ret;
+ return ret; } /* Wait for data available */ @@ -388,7 +388,7 @@ static int mmcsd_getSCR(struct mmcsd_state_s *priv, uint32 scr[2]) { fdbg("ERROR: WAITEVENT for READ DATA failed: %d\n", ret); return ret; - }
+ } /* Receive the SCR data from the SD card. Card data is sent big-endian; * if we are running on a little-endian machine, then we need to swap @@ -503,7 +503,7 @@ static void mmcsd_decodeCSD(struct mmcsd_state_s *priv, uint32 csd[4]) * MMC_WP_GRP_SIZE 36:32 Write protect group size */ - if (IS_BLOCK(priv->type))
+ if (IS_BLOCK(priv->type)) { /* C_SIZE: 69:64 from Word 2 and 63:48 from Word 3 * @@ -515,7 +515,7 @@ static void mmcsd_decodeCSD(struct mmcsd_state_s *priv, uint32 csd[4]) uint32 csize = ((csd[1] & 0x3f) << 16) | (csd[2] >> 16); priv->capacity = (csize + 1) << 19; priv->blocksize = 1 << 9; - priv->nblocks = priv->capacity >> 9;
+ priv->nblocks = priv->capacity >> 9; #if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) decoded.u.sdblock.csize = csize; @@ -523,7 +523,7 @@ static void mmcsd_decodeCSD(struct mmcsd_state_s *priv, uint32 csd[4]) decoded.u.sdblock.sdsectorsize = (csd[2] >> 7) & 0x7f; decoded.u.sdblock.sdwpgrpsize = csd[2] & 0x7f; #endif - }
+ } else { /* C_SIZE: 73:64 from Word 2 and 63:62 from Word 3 */ @@ -533,11 +533,11 @@ static void mmcsd_decodeCSD(struct mmcsd_state_s *priv, uint32 csd[4]) priv->nblocks = ((uint32)csize + 1) * (1 << (csizemult + 2)); priv->blocksize = (1 << readbllen); - priv->capacity = priv->nblocks * priv->blocksize;
+ priv->capacity = priv->nblocks * priv->blocksize; #if defined(CONFIG_DEBUG) && defined (CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS) - if (IS_SD(priv->type))
- {
+ if (IS_SD(priv->type)) + { decoded.u.sdbyte.csize = csize; decoded.u.sdbyte.vddrcurrmin = (csd[2] >> 27) & 7; decoded.u.sdbyte.vddrcurrmax = (csd[2] >> 24) & 7; @@ -610,14 +610,14 @@ static void mmcsd_decodeCSD(struct mmcsd_state_s *priv, uint32 csd[4]) fvdbg(" DSR_IMP: %d\n", decoded.dsrimp); - if (IS_BLOCK(priv->type))
+ if (IS_BLOCK(priv->type)) { fvdbg(" SD Block Addressing:\n"); fvdbg(" C_SIZE: %d SD_ER_BLK_EN: %d\n", decoded.u.sdblock.csize, decoded.u.sdblock.sderblen); fvdbg(" SD_SECTOR_SIZE: %d SD_WP_GRP_SIZE: %d\n", decoded.u.sdblock.sdsectorsize, decoded.u.sdblock.sdwpgrpsize); - }
+ } else if (IS_SD(priv->type)) { fvdbg(" SD Byte Addressing:\n"); @@ -975,12 +975,12 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) fvdbg("Entry\n"); DEBUGASSERT(inode && inode->i_private); - mmcsd_takesem(priv); if (geometry) { /* Is there a (supported) card inserted in the slot? */ priv = (struct mmcsd_state_s *)inode->i_private; + mmcsd_takesem(priv); if (IS_EMPTY(priv)) { /* No.. return ENODEV */ @@ -1011,9 +1011,9 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry) priv->mediachanged = FALSE; ret = OK; } + mmcsd_givesem(priv); } - mmcsd_givesem(priv); return ret; } @@ -1142,62 +1142,62 @@ static int mmcsd_widebus(struct mmcsd_state_s *priv) /* Check if the SD card supports this feature (as reported in the SCR) */ - if ((priv->buswidth & MMCSD_SCR_BUSWIDTH_4BIT) != 0)
+ if ((priv->buswidth & MMCSD_SCR_BUSWIDTH_4BIT) != 0) { /* Disconnect any CD/DAT3 pull up using ACMD42. ACMD42 is optional and * need not be supported by all SD calls. * * First end CMD55 APP_CMD with argument as card's RCA. - */
+ */ - mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16);
- ret = mmcsd_recvR1(priv, SD_CMD55);
- if (ret != OK)
+ mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16); + ret = mmcsd_recvR1(priv, SD_CMD55); + if (ret != OK) { - fdbg("ERROR: RECVR1 for CMD55 of ACMD42: %d\n", ret);
- return ret;
- }
+ fdbg("ERROR: RECVR1 for CMD55 of ACMD42: %d\n", ret); + return ret; + } /* Then send ACMD42 with the argument to disconnect the CD/DAT3 * pullup */ - mmcsd_sendcmdpoll(priv, SD_ACMD42, MMCSD_ACMD42_CD_DISCONNECT);
- ret = mmcsd_recvR1(priv, SD_ACMD42);
- if (ret != OK)
+ mmcsd_sendcmdpoll(priv, SD_ACMD42, MMCSD_ACMD42_CD_DISCONNECT); + ret = mmcsd_recvR1(priv, SD_ACMD42); + if (ret != OK) { - fvdbg("WARNING: SD card does not support ACMD42: %d\n", ret);
- return ret;
+ fvdbg("WARNING: SD card does not support ACMD42: %d\n", ret); + return ret; } /* Now send ACMD6 to select wide, 4-bit bus operation, beginning * with CMD55, APP_CMD: */ -
- mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16);
- ret = mmcsd_recvR1(priv, SD_CMD55);
- if (ret != OK)
+ + mmcsd_sendcmdpoll(priv, SD_CMD55, (uint32)priv->rca << 16); + ret = mmcsd_recvR1(priv, SD_CMD55); + if (ret != OK) { - fdbg("ERROR: RECVR1 for CMD55 of ACMD6: %d\n", ret);
- return ret;
+ fdbg("ERROR: RECVR1 for CMD55 of ACMD6: %d\n", ret); + return ret; } /* Then send ACMD6 */ - mmcsd_sendcmdpoll(priv, SD_ACMD6, MMCSD_ACMD6_BUSWIDTH_4);
- ret = mmcsd_recvR1(priv, SD_ACMD6);
- if (ret != OK)
- {
- return ret;
- }
-
- /* Configure the SDIO peripheral */
+ mmcsd_sendcmdpoll(priv, SD_ACMD6, MMCSD_ACMD6_BUSWIDTH_4); + ret = mmcsd_recvR1(priv, SD_ACMD6); + if (ret != OK) + { + return ret; + } + + /* Configure the SDIO peripheral */ fvdbg("Wide bus operation selected\n"); SDIO_WIDEBUS(priv->dev, TRUE); priv->widebus = TRUE; - SDIO_CLOCK(priv->dev, CLOCK_SD_TRANSFER_4BIT);
+ SDIO_CLOCK(priv->dev, CLOCK_SD_TRANSFER_4BIT); up_udelay(MMCSD_CLK_DELAY); return OK; } @@ -1353,11 +1353,11 @@ static int mmcsd_sdinitialize(struct mmcsd_state_s *priv) * Send CMD3 with argument 0, SD card publishes its RCA in the response. */ - mmcsd_sendcmdpoll(priv, SD_CMD3, 0);
- ret = SDIO_RECVR6(priv->dev, SD_CMD3, &rca);
- if (ret != OK)
- {
- return ret;
+ mmcsd_sendcmdpoll(priv, SD_CMD3, 0); + ret = SDIO_RECVR6(priv->dev, SD_CMD3, &rca); + if (ret != OK) + { + return ret; } /* R6 Published RCA Response (48-bit, SD card only) @@ -1372,7 +1372,7 @@ static int mmcsd_sdinitialize(struct mmcsd_state_s *priv) */ priv->rca = (uint16)(rca >> 16); - fvdbg("RCA: %04x\n", priv->rca);
+ fvdbg("RCA: %04x\n", priv->rca); /* This should have caused a transition to standby state. However, this will * not be reflected in the present R1 status. R1/6 contains the state of @@ -1471,7 +1471,7 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) } /* Initialize device state structure */ -
+ priv->type = MMCSD_CARDTYPE_SDV1; priv->mode = MMCSDMODE_POLLED; @@ -1495,14 +1495,14 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) * operating condition. CMD 8 is reserved on SD version 1.0 and MMC. * * CMD8 Argument: - * [31:12]: Reserved (shall be set to '0')
* [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
- * [7:0]: Check Pattern (recommended 0xaa)
+ * [31:12]: Reserved (shall be set to '0')
* [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V) + * [7:0]: Check Pattern (recommended 0xaa) * CMD8 Response: R7 - */
-
- mmcsd_sendcmdpoll(priv, SD_CMD8, MMCSD_CMD8CHECKPATTERN|MMCSD_CMD8VOLTAGE_27);
- ret = SDIO_RECVR7(priv->dev, SD_CMD8, &response);
- if (ret == OK)
+ */ + + mmcsd_sendcmdpoll(priv, SD_CMD8, MMCSD_CMD8CHECKPATTERN|MMCSD_CMD8VOLTAGE_27); + ret = SDIO_RECVR7(priv->dev, SD_CMD8, &response); + if (ret == OK) { /* CMD8 succeeded this is probably a SDHC card. Verify the operating * voltage and that the check pattern was correctly echoed @@ -1510,17 +1510,17 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) if (((response & MMCSD_R7VOLTAGE_MASK) == MMCSD_R7VOLTAGE_27) && ((response & MMCSD_R7ECHO_MASK) == MMCSD_R7CHECKPATTERN)) - {
+ { fvdbg("SD V2.x card\n"); - priv->type = MMCSD_CARDTYPE_SDV2;
+ priv->type = MMCSD_CARDTYPE_SDV2; sdcapacity = MMCSD_ACMD41_HIGHCAPACITY; } else { fdbg("ERROR: R7: %08x\n", response); return -EIO; - }
- }
+ } + } /* At this point, type is either UNKNOWN or SDV2. Try sending * CMD55 and (maybe) ACMD41 for up to 1 second or until the card @@ -1543,7 +1543,7 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) { /* Send CMD55 */ - mmcsd_sendcmdpoll(priv, SD_CMD55, 0);
+ mmcsd_sendcmdpoll(priv, SD_CMD55, 0); ret = mmcsd_recvR1(priv, SD_CMD55); if (ret != OK) { @@ -1578,7 +1578,7 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) if (priv->type == MMCSD_CARDTYPE_UNKNOWN) { fvdbg("SD V1.x card\n"); - priv->type = MMCSD_CARDTYPE_SDV1;
+ priv->type = MMCSD_CARDTYPE_SDV1; } /* Check if the card is busy */ @@ -1604,7 +1604,7 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) /* And break out of the loop with an SD card identified */ break; - }
+ } } } } @@ -1660,14 +1660,14 @@ static int mmcsd_cardidentify(struct mmcsd_state_s *priv) break; } - }
+ } } #endif /* Check the elapsed time. We won't keep trying this forever! */ elapsed = g_system_timer - start; } - while (elapsed < TICK_PER_SEC && ret != OK);
+ while (elapsed < TICK_PER_SEC && ret != OK); /* We get here when the above loop completes, either (1) we could not * communicate properly with the card due to errors (and the loop times @@ -1794,6 +1794,7 @@ static int mmcsd_probe(struct mmcsd_state_s *priv) fvdbg("No card\n"); SDIO_EVENTENABLE(priv->dev, SDIOEVENT_INSERTED); + ret = -ENODEV; } return ret; |