mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
MCI requires DMA
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2555 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* arch/arm/include/sam3u/irq.h
|
* arch/arm/include/sam3u/irq.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
@@ -73,9 +73,8 @@
|
|||||||
|
|
||||||
/* Configuration ************************************************************/
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_HSMCI_DMA) && !defined(CONFIG_SAM3U_DMA2)
|
#if !defined(CONFIG_SDIO_DMA) || !defined(CONFIG_SAM3U_DMA)
|
||||||
# warning "CONFIG_HSMCI_DMA support requires CONFIG_SAM3U_DMA2"
|
# warning "HSMCI requires CONFIG_SDIO_DMA and CONFIG_SAM3U_DMA"
|
||||||
# undef CONFIG_HSMCI_DMA
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SCHED_WORKQUEUE
|
#ifndef CONFIG_SCHED_WORKQUEUE
|
||||||
@@ -213,7 +212,7 @@
|
|||||||
/* Register logging support */
|
/* Register logging support */
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_XFRDEBUG
|
#ifdef CONFIG_HSMCI_XFRDEBUG
|
||||||
# if defined(CONFIG_DEBUG_DMA) && defined(CONFIG_HSMCI_DMA)
|
#ifdef CONFIG_DEBUG_DMA
|
||||||
# define SAMPLENDX_BEFORE_SETUP 0
|
# define SAMPLENDX_BEFORE_SETUP 0
|
||||||
# define SAMPLENDX_BEFORE_ENABLE 1
|
# define SAMPLENDX_BEFORE_ENABLE 1
|
||||||
# define SAMPLENDX_AFTER_SETUP 2
|
# define SAMPLENDX_AFTER_SETUP 2
|
||||||
@@ -264,10 +263,8 @@ struct sam3u_dev_s
|
|||||||
/* DMA data transfer support */
|
/* DMA data transfer support */
|
||||||
|
|
||||||
bool widebus; /* Required for DMA support */
|
bool widebus; /* Required for DMA support */
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
bool dmamode; /* true: DMA mode transfer */
|
bool dmamode; /* true: DMA mode transfer */
|
||||||
DMA_HANDLE dma; /* Handle for DMA channel */
|
DMA_HANDLE dma; /* Handle for DMA channel */
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Register logging support */
|
/* Register logging support */
|
||||||
@@ -288,8 +285,8 @@ struct sam3u_hsmciregs_s
|
|||||||
|
|
||||||
struct sam3u_sampleregs_s
|
struct sam3u_sampleregs_s
|
||||||
{
|
{
|
||||||
struct sam3u_hsmciregs_s sdio;
|
struct sam3u_hsmciregs_s hsmci;
|
||||||
#if defined(CONFIG_DEBUG_DMA) && defined(CONFIG_HSMCI_DMA)
|
#ifdef CONFIG_DEBUG_DMA
|
||||||
struct sam3u_dmaregs_s dma;
|
struct sam3u_dmaregs_s dma;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -328,9 +325,7 @@ static void sam3u_dumpsamples(struct sam3u_dev_s *priv);
|
|||||||
# define sam3u_dumpsamples(priv)
|
# define sam3u_dumpsamples(priv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
static void sam3u_dmacallback(DMA_HANDLE handle, uint8_t isr, void *arg);
|
static void sam3u_dmacallback(DMA_HANDLE handle, uint8_t isr, void *arg);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Data Transfer Helpers ****************************************************/
|
/* Data Transfer Helpers ****************************************************/
|
||||||
|
|
||||||
@@ -391,13 +386,11 @@ static int sam3u_registercallback(FAR struct sdio_dev_s *dev,
|
|||||||
|
|
||||||
/* DMA */
|
/* DMA */
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
static bool sam3u_dmasupported(FAR struct sdio_dev_s *dev);
|
static bool sam3u_dmasupported(FAR struct sdio_dev_s *dev);
|
||||||
static int sam3u_dmarecvsetup(FAR struct sdio_dev_s *dev,
|
static int sam3u_dmarecvsetup(FAR struct sdio_dev_s *dev,
|
||||||
FAR uint8_t *buffer, size_t buflen);
|
FAR uint8_t *buffer, size_t buflen);
|
||||||
static int sam3u_dmasendsetup(FAR struct sdio_dev_s *dev,
|
static int sam3u_dmasendsetup(FAR struct sdio_dev_s *dev,
|
||||||
FAR const uint8_t *buffer, size_t buflen);
|
FAR const uint8_t *buffer, size_t buflen);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialization/uninitialization/reset ************************************/
|
/* Initialization/uninitialization/reset ************************************/
|
||||||
|
|
||||||
@@ -432,11 +425,9 @@ struct sam3u_dev_s g_sdiodev =
|
|||||||
.eventwait = sam3u_eventwait,
|
.eventwait = sam3u_eventwait,
|
||||||
.callbackenable = sam3u_callbackenable,
|
.callbackenable = sam3u_callbackenable,
|
||||||
.registercallback = sam3u_registercallback,
|
.registercallback = sam3u_registercallback,
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
.dmasupported = sam3u_dmasupported,
|
.dmasupported = sam3u_dmasupported,
|
||||||
.dmarecvsetup = sam3u_dmarecvsetup,
|
.dmarecvsetup = sam3u_dmarecvsetup,
|
||||||
.dmasendsetup = sam3u_dmasendsetup,
|
.dmasendsetup = sam3u_dmasendsetup,
|
||||||
#endif
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -704,13 +695,13 @@ static void sam3u_sdiosample(struct sam3u_hsmciregs_s *regs)
|
|||||||
static void sam3u_sample(struct sam3u_dev_s *priv, int index)
|
static void sam3u_sample(struct sam3u_dev_s *priv, int index)
|
||||||
{
|
{
|
||||||
struct sam3u_sampleregs_s *regs = &g_sampleregs[index];
|
struct sam3u_sampleregs_s *regs = &g_sampleregs[index];
|
||||||
#if defined(CONFIG_DEBUG_DMA) && defined(CONFIG_HSMCI_DMA)
|
#ifdef CONFIG_DEBUG_DMA
|
||||||
if (priv->dmamode)
|
if (priv->dmamode)
|
||||||
{
|
{
|
||||||
sam3u_dmasample(priv->dma, ®s->dma);
|
sam3u_dmasample(priv->dma, ®s->dma);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sam3u_sdiosample(®s->sdio);
|
sam3u_sdiosample(®s->hsmci);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -750,13 +741,13 @@ static void sam3u_sdiodump(struct sam3u_hsmciregs_s *regs, const char *msg)
|
|||||||
static void sam3u_dumpsample(struct sam3u_dev_s *priv,
|
static void sam3u_dumpsample(struct sam3u_dev_s *priv,
|
||||||
struct sam3u_sampleregs_s *regs, const char *msg)
|
struct sam3u_sampleregs_s *regs, const char *msg)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_DEBUG_DMA) && defined(CONFIG_HSMCI_DMA)
|
#ifdef CONFIG_DEBUG_DMA
|
||||||
if (priv->dmamode)
|
if (priv->dmamode)
|
||||||
{
|
{
|
||||||
sam3u_dmadump(priv->dma, ®s->dma, msg);
|
sam3u_dmadump(priv->dma, ®s->dma, msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sam3u_sdiodump(®s->sdio, msg);
|
sam3u_sdiodump(®s->hsmci, msg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -772,7 +763,7 @@ static void sam3u_dumpsample(struct sam3u_dev_s *priv,
|
|||||||
static void sam3u_dumpsamples(struct sam3u_dev_s *priv)
|
static void sam3u_dumpsamples(struct sam3u_dev_s *priv)
|
||||||
{
|
{
|
||||||
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_BEFORE_SETUP], "Before setup");
|
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_BEFORE_SETUP], "Before setup");
|
||||||
#if defined(CONFIG_DEBUG_DMA) && defined(CONFIG_HSMCI_DMA)
|
#ifdef CONFIG_DEBUG_DMA
|
||||||
if (priv->dmamode)
|
if (priv->dmamode)
|
||||||
{
|
{
|
||||||
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_BEFORE_ENABLE], "Before DMA enable");
|
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_BEFORE_ENABLE], "Before DMA enable");
|
||||||
@@ -780,7 +771,7 @@ static void sam3u_dumpsamples(struct sam3u_dev_s *priv)
|
|||||||
#endif
|
#endif
|
||||||
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_AFTER_SETUP], "After setup");
|
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_AFTER_SETUP], "After setup");
|
||||||
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_END_TRANSFER], "End of transfer");
|
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_END_TRANSFER], "End of transfer");
|
||||||
#if defined(CONFIG_DEBUG_DMA) && defined(CONFIG_HSMCI_DMA)
|
#ifdef CONFIG_DEBUG_DMA
|
||||||
if (priv->dmamode)
|
if (priv->dmamode)
|
||||||
{
|
{
|
||||||
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_DMA_CALLBACK], "DMA Callback");
|
sam3u_dumpsample(priv, &g_sampleregs[SAMPLENDX_DMA_CALLBACK], "DMA Callback");
|
||||||
@@ -797,7 +788,6 @@ static void sam3u_dumpsamples(struct sam3u_dev_s *priv)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
static void sam3u_dmacallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
static void sam3u_dmacallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
||||||
{
|
{
|
||||||
/* FAR struct sam3u_spidev_s *priv = (FAR struct sam3u_spidev_s *)arg; */
|
/* FAR struct sam3u_spidev_s *priv = (FAR struct sam3u_spidev_s *)arg; */
|
||||||
@@ -813,7 +803,6 @@ static void sam3u_dmacallback(DMA_HANDLE handle, uint8_t isr, void *arg)
|
|||||||
|
|
||||||
sam3u_sample((struct sam3u_dev_s*)arg, SAMPLENDX_DMA_CALLBACK);
|
sam3u_sample((struct sam3u_dev_s*)arg, SAMPLENDX_DMA_CALLBACK);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Data Transfer Helpers
|
* Data Transfer Helpers
|
||||||
@@ -1121,7 +1110,6 @@ static void sam3u_endtransfer(struct sam3u_dev_s *priv, sdio_eventset_t wkupeven
|
|||||||
|
|
||||||
/* If this was a DMA transfer, make sure that DMA is stopped */
|
/* If this was a DMA transfer, make sure that DMA is stopped */
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
if (priv->dmamode)
|
if (priv->dmamode)
|
||||||
{
|
{
|
||||||
/* DMA debug instrumentation */
|
/* DMA debug instrumentation */
|
||||||
@@ -1135,7 +1123,6 @@ static void sam3u_endtransfer(struct sam3u_dev_s *priv, sdio_eventset_t wkupeven
|
|||||||
|
|
||||||
sam3u_dmastop(priv->dma);
|
sam3u_dmastop(priv->dma);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Mark the transfer finished */
|
/* Mark the transfer finished */
|
||||||
|
|
||||||
@@ -1190,9 +1177,7 @@ static int sam3u_interrupt(int irq, void *context)
|
|||||||
pending = enabled & priv->xfrmask;
|
pending = enabled & priv->xfrmask;
|
||||||
if (pending != 0)
|
if (pending != 0)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
if (!priv->dmamode)
|
if (!priv->dmamode)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* Is the RX FIFO half full or more? Is so then we must be
|
/* Is the RX FIFO half full or more? Is so then we must be
|
||||||
* processing a receive transaction.
|
* processing a receive transaction.
|
||||||
@@ -1227,9 +1212,7 @@ static int sam3u_interrupt(int irq, void *context)
|
|||||||
* half-full interrupt will be received.
|
* half-full interrupt will be received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
if (!priv->dmamode)
|
if (!priv->dmamode)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* Receive data from the RX FIFO */
|
/* Receive data from the RX FIFO */
|
||||||
|
|
||||||
@@ -1413,9 +1396,7 @@ static void sam3u_reset(FAR struct sdio_dev_s *dev)
|
|||||||
/* DMA data transfer support */
|
/* DMA data transfer support */
|
||||||
|
|
||||||
priv->widebus = false; /* Required for DMA support */
|
priv->widebus = false; /* Required for DMA support */
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
priv->dmamode = false; /* true: DMA mode transfer */
|
priv->dmamode = false; /* true: DMA mode transfer */
|
||||||
#endif
|
|
||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1666,9 +1647,7 @@ static int sam3u_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
|
|||||||
|
|
||||||
priv->buffer = (uint32_t*)buffer;
|
priv->buffer = (uint32_t*)buffer;
|
||||||
priv->remaining = nbytes;
|
priv->remaining = nbytes;
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
priv->dmamode = false;
|
priv->dmamode = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Then set up the SDIO data path */
|
/* Then set up the SDIO data path */
|
||||||
|
|
||||||
@@ -1720,9 +1699,7 @@ static int sam3u_sendsetup(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer
|
|||||||
|
|
||||||
priv->buffer = (uint32_t*)buffer;
|
priv->buffer = (uint32_t*)buffer;
|
||||||
priv->remaining = nbytes;
|
priv->remaining = nbytes;
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
priv->dmamode = false;
|
priv->dmamode = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Then set up the HSMCI data path */
|
/* Then set up the HSMCI data path */
|
||||||
|
|
||||||
@@ -1772,7 +1749,6 @@ static int sam3u_cancel(FAR struct sdio_dev_s *dev)
|
|||||||
|
|
||||||
/* If this was a DMA transfer, make sure that DMA is stopped */
|
/* If this was a DMA transfer, make sure that DMA is stopped */
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
if (priv->dmamode)
|
if (priv->dmamode)
|
||||||
{
|
{
|
||||||
/* Make sure that the DMA is stopped (it will be stopped automatically
|
/* Make sure that the DMA is stopped (it will be stopped automatically
|
||||||
@@ -1782,7 +1758,6 @@ static int sam3u_cancel(FAR struct sdio_dev_s *dev)
|
|||||||
|
|
||||||
sam3u_dmastop(priv->dma);
|
sam3u_dmastop(priv->dma);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Mark no transfer in progress */
|
/* Mark no transfer in progress */
|
||||||
|
|
||||||
@@ -2310,12 +2285,10 @@ static int sam3u_registercallback(FAR struct sdio_dev_s *dev,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
static bool sam3u_dmasupported(FAR struct sdio_dev_s *dev)
|
static bool sam3u_dmasupported(FAR struct sdio_dev_s *dev)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sam3u_dmarecvsetup
|
* Name: sam3u_dmarecvsetup
|
||||||
@@ -2336,7 +2309,6 @@ static bool sam3u_dmasupported(FAR struct sdio_dev_s *dev)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
static int sam3u_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
|
static int sam3u_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
|
||||||
size_t buflen)
|
size_t buflen)
|
||||||
{
|
{
|
||||||
@@ -2386,7 +2358,6 @@ static int sam3u_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sam3u_dmasendsetup
|
* Name: sam3u_dmasendsetup
|
||||||
@@ -2407,7 +2378,6 @@ static int sam3u_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_HSMCI_DMA
|
|
||||||
static int sam3u_dmasendsetup(FAR struct sdio_dev_s *dev,
|
static int sam3u_dmasendsetup(FAR struct sdio_dev_s *dev,
|
||||||
FAR const uint8_t *buffer, size_t buflen)
|
FAR const uint8_t *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
@@ -2461,7 +2431,6 @@ static int sam3u_dmasendsetup(FAR struct sdio_dev_s *dev,
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Initialization/uninitialization/reset
|
* Initialization/uninitialization/reset
|
||||||
@@ -2576,9 +2545,8 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno)
|
|||||||
|
|
||||||
/* Allocate a DMA channel */
|
/* Allocate a DMA channel */
|
||||||
|
|
||||||
#if defined(CONFIG_HSMCI_DMA) && defined(CONFIG_SAM3U_MCI2)
|
|
||||||
priv->dma = sam3u_dmachannel();
|
priv->dma = sam3u_dmachannel();
|
||||||
#endif
|
DEBUGASSERT(priv->dma);
|
||||||
|
|
||||||
/* Configure GPIOs for 4-bit, wide-bus operation. NOTE: (1) the chip is capable of
|
/* Configure GPIOs for 4-bit, wide-bus operation. NOTE: (1) the chip is capable of
|
||||||
* 8-bit wide bus operation but D4-D7 are not configured, (2) any card detection
|
* 8-bit wide bus operation but D4-D7 are not configured, (2) any card detection
|
||||||
@@ -2683,4 +2651,4 @@ void sdio_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect)
|
|||||||
fvdbg("cdstatus: %02x\n", priv->cdstatus);
|
fvdbg("cdstatus: %02x\n", priv->cdstatus);
|
||||||
irqrestore(flags);
|
irqrestore(flags);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAM3U_SDIO */
|
#endif /* CONFIG_SAM3U_HSMCI */
|
||||||
|
|||||||
Reference in New Issue
Block a user