More Kinetis SDHC fixes

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3907 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-08-23 14:58:15 +00:00
parent c2aa7d046c
commit 01232ab6c7
4 changed files with 22 additions and 45 deletions

8
TODO
View File

@ -1,4 +1,4 @@
NuttX TODO List (Last updated August 8, 2011) NuttX TODO List (Last updated August 22, 2011)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
nuttx/ nuttx/
@ -13,7 +13,7 @@ nuttx/
(16) Network (net/, drivers/net) (16) Network (net/, drivers/net)
(2) USB (drivers/usbdev, drivers/usbhost) (2) USB (drivers/usbdev, drivers/usbhost)
(6) Libraries (lib/) (6) Libraries (lib/)
(10) File system/Generic drivers (fs/, drivers/) (9) File system/Generic drivers (fs/, drivers/)
(2) Graphics subystem (graphics/) (2) Graphics subystem (graphics/)
(1) Pascal add-on (pcode/) (1) Pascal add-on (pcode/)
(1) Documentation (Documentation/) (1) Documentation (Documentation/)
@ -413,10 +413,6 @@ o File system / Generic drivers (fs/, drivers/)
Status: Open Status: Open
Priority: Low Priority: Low
Description: The CAN driver is untested. Add a test for the CAN driver.
Status: Open
Priority: Medium
Description: At present, the CAN driver does not support the poll() method. Description: At present, the CAN driver does not support the poll() method.
Status: Open Status: Open
Priority: Low Priority: Low

View File

@ -1182,12 +1182,10 @@ static int kinetis_interrupt(int irq, void *context)
} }
} }
/* Handle data end events */ /* Handle transfer complete events */
if ((pending & SDHC_INT_TC) != 0) if ((pending & SDHC_INT_TC) != 0)
{ {
/* Handle any data remaining the RX buffer */
/* Was this transfer performed in DMA mode? */ /* Was this transfer performed in DMA mode? */
#ifdef CONFIG_SDIO_DMA #ifdef CONFIG_SDIO_DMA
@ -1924,10 +1922,9 @@ static int kinetis_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t ar
putreg32(arg, KINETIS_SDHC_CMDARG); putreg32(arg, KINETIS_SDHC_CMDARG);
/* Enable appropriate interrupts and write the SDHC CMD */ /* Clear interrupt status and write the SDHC CMD */
putreg32(SDHC_RESPDONE_INTS, KINETIS_SDHC_IRQSTAT); putreg32(SDHC_RESPDONE_INTS, KINETIS_SDHC_IRQSTAT);
putreg32(SDHC_RESPDONE_INTS|SDHC_INT_CINT, KINETIS_SDHC_IRQSIGEN);
putreg32(regval, KINETIS_SDHC_XFERTYP); putreg32(regval, KINETIS_SDHC_XFERTYP);
return OK; return OK;
} }
@ -2262,9 +2259,11 @@ static int kinetis_recvshortcrc(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32
} }
} }
/* Clear all pending message completion events and return the R1/R6 response */ /* Return the R1/R1b/R6 response. These responses are returned in
* CDMRSP0. NOTE: This is not true for R1b (Auto CMD12 response) which
* is returned in CMDRSP3.
*/
putreg32(SDHC_RESPDONE_INTS, KINETIS_SDHC_IRQSTAT);
*rshort = getreg32(KINETIS_SDHC_CMDRSP0); *rshort = getreg32(KINETIS_SDHC_CMDRSP0);
return ret; return ret;
} }
@ -2309,18 +2308,14 @@ static int kinetis_recvlong(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t r
} }
} }
/* Disable interrupts and return the long response */ /* Return the long response in CMDRSP3..0*/
regval = getreg32(KINETIS_SDHC_IRQSIGEN);
regval &= ~SDHC_RESPDONE_INTS;
putreg32(regval, KINETIS_SDHC_IRQSIGEN);
if (rlong) if (rlong)
{ {
rlong[0] = getreg32(KINETIS_SDHC_CMDRSP0); rlong[0] = getreg32(KINETIS_SDHC_CMDRSP3);
rlong[1] = getreg32(KINETIS_SDHC_CMDRSP1); rlong[1] = getreg32(KINETIS_SDHC_CMDRSP2);
rlong[2] = getreg32(KINETIS_SDHC_CMDRSP2); rlong[2] = getreg32(KINETIS_SDHC_CMDRSP1);
rlong[3] = getreg32(KINETIS_SDHC_CMDRSP3); rlong[3] = getreg32(KINETIS_SDHC_CMDRSP0);
} }
return ret; return ret;
} }
@ -2361,20 +2356,15 @@ static int kinetis_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t
fdbg("ERROR: Timeout IRQSTAT: %08x\n", regval); fdbg("ERROR: Timeout IRQSTAT: %08x\n", regval);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
} }
/* Return the short response */
} }
/* Disable interrupts and return the short response */ /* Return the short response in CMDRSP0 */
regval = getreg32(KINETIS_SDHC_IRQSIGEN);
regval &= ~SDHC_RESPDONE_INTS;
putreg32(regval, KINETIS_SDHC_IRQSIGEN);
if (rshort) if (rshort)
{ {
*rshort = getreg32(KINETIS_SDHC_CMDRSP0); *rshort = getreg32(KINETIS_SDHC_CMDRSP0);
} }
return ret; return ret;
} }
@ -2384,11 +2374,7 @@ static int kinetis_recvnotimpl(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_
{ {
uint32_t regval; uint32_t regval;
/* Disable interrupts and return an error */ /* Just return an error */
regval = getreg32(KINETIS_SDHC_IRQSIGEN);
regval &= ~SDHC_RESPDONE_INTS;
putreg32(regval, KINETIS_SDHC_IRQSIGEN);
return -ENOSYS; return -ENOSYS;
} }
@ -2422,7 +2408,6 @@ static void kinetis_waitenable(FAR struct sdio_dev_s *dev,
{ {
struct kinetis_dev_s *priv = (struct kinetis_dev_s*)dev; struct kinetis_dev_s *priv = (struct kinetis_dev_s*)dev;
uint32_t waitints; uint32_t waitints;
uint32_t regval;
DEBUGASSERT(priv != NULL); DEBUGASSERT(priv != NULL);
@ -2447,10 +2432,6 @@ static void kinetis_waitenable(FAR struct sdio_dev_s *dev,
/* Enable event-related interrupts */ /* Enable event-related interrupts */
regval = getreg32(KINETIS_SDHC_IRQSIGEN);
regval &= ~(SDHC_WAITALL_INTS);
putreg32(regval, KINETIS_SDHC_IRQSIGEN);
kinetis_configwaitints(priv, waitints, eventset, 0); kinetis_configwaitints(priv, waitints, eventset, 0);
} }
@ -3059,6 +3040,7 @@ void sdhc_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect)
{ {
priv->cdstatus &= ~SDIO_STATUS_WRPROTECTED; priv->cdstatus &= ~SDIO_STATUS_WRPROTECTED;
} }
fvdbg("cdstatus: %02x\n", priv->cdstatus); fvdbg("cdstatus: %02x\n", priv->cdstatus);
irqrestore(flags); irqrestore(flags);
} }

View File

@ -2054,8 +2054,6 @@ static int stm32_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t *r
fdbg("ERROR: Timeout STA: %08x\n", regval); fdbg("ERROR: Timeout STA: %08x\n", regval);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
} }
/* Return the short response */
} }
putreg32(SDIO_RESPDONE_ICR|SDIO_CMDDONE_ICR, STM32_SDIO_ICR); putreg32(SDIO_RESPDONE_ICR|SDIO_CMDDONE_ICR, STM32_SDIO_ICR);

View File

@ -174,12 +174,13 @@ static void kinetis_mediachange(void)
sdhc_mediachange(g_nsh.sdhc, inserted); sdhc_mediachange(g_nsh.sdhc, inserted);
/* If the card has been inserted, then check if it is write protected /* If the card has been inserted, then check if it is write protected
* aw well. * as well. The pin is pulled up, but apparently logic high means
* write protected.
*/ */
if (inserted) if (inserted)
{ {
sdhc_wrprotect(g_nsh.sdhc, !kinetis_gpioread(GPIO_SD_WRPROTECT)); sdhc_wrprotect(g_nsh.sdhc, kinetis_gpioread(GPIO_SD_WRPROTECT));
} }
} }
} }