dma: Export dma_get_channel()

Access to dma is currently via a channel number. It is more efficient
to export a pointer to the dma channel since it avoids the conversion
on every API call. This helps, because dma is often on the critical
path.

Export the function to provide a pointer to a dma channel given its
number.

BUG=chrome-os-parter:10533
TEST=manual: build for all boards

Change-Id: I0318e59dbb1b9077f0445804692ca7ea99cf6581
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26164
Reviewed-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
Simon Glass
2012-06-26 16:02:24 -07:00
committed by Gerrit
parent 6d04819930
commit a366d64981
2 changed files with 13 additions and 11 deletions

View File

@@ -13,13 +13,7 @@
#define CPRINTF(format, args...) cprintf(CC_DMA, format, ## args)
/**
* Get a pointer to a DMA channel.
*
* @param channel Channel number to read (DMAC_...)
* @return pointer to DMA channel registers
*/
static struct dma_channel *get_channel(int channel)
struct dma_channel *dma_get_channel(int channel)
{
struct dma_channel *chan;
struct dma_ctlr *dma;
@@ -41,7 +35,7 @@ void dma_disable(unsigned channel)
{
struct dma_channel *chan;
chan = get_channel(channel);
chan = dma_get_channel(channel);
if (REG32(&chan->ccr) & DMA_EN)
REG32(&chan->ccr) &= ~DMA_EN;
@@ -65,7 +59,7 @@ static int prepare_channel(unsigned channel, unsigned count, void *periph,
struct dma_channel *chan;
uint32_t ctrl;
chan = get_channel(channel);
chan = dma_get_channel(channel);
if (REG32(&chan->ccr) & DMA_EN)
REG32(&chan->ccr) &= ~DMA_EN;
@@ -111,7 +105,7 @@ void dma_check(int channel, char *buff)
int count;
int i;
chan = get_channel(channel);
chan = dma_get_channel(channel);
count = REG32(&chan->cndtr);
CPRINTF("c=%d\n", count);
udelay(1000 * 100);
@@ -136,7 +130,7 @@ void dma_test(void)
unsigned count = sizeof(periph);
int i;
chan = get_channel(channel);
chan = dma_get_channel(channel);
memset(memory, '\0', sizeof(memory));
for (i = 0; i < count; i++)
periph[i] = 10 + i;

View File

@@ -75,6 +75,14 @@ enum {
#define DMA_CHANNEL_FOR_SPI_TX(spi) \
((spi) == STM32_SPI1_PORT ? DMAC_SPI1_TX : DMAC_SPI2_TX)
/**
* Get a pointer to a DMA channel.
*
* @param channel Channel number to read (DMAC_...)
* @return pointer to DMA channel registers
*/
struct dma_channel *dma_get_channel(int channel);
/**
* Start a DMA transfer to transmit data from memory to a peripheral
*