summaryrefslogtreecommitdiff
path: root/peripherals/dma
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-07-04 20:52:54 +0200
committerHarald Welte <laforge@gnumonks.org>2011-07-04 20:52:54 +0200
commit044ad7c3987460ede48ff27afd6bdb0ca05a0432 (patch)
tree924818cdb0d39ca08aec540d18da7bd406eaae8c /peripherals/dma
import at91lib from at91lib_20100901_softpack_1_9_v_1_0_svn_v1501120100901_softpack_1_9_v_1_0_svn_v15011
it's sad to see that atmel doesn't publish their svn repo or has a centralized location or even puts proper version/release info into the library itself
Diffstat (limited to 'peripherals/dma')
-rw-r--r--peripherals/dma/dma.c393
-rw-r--r--peripherals/dma/dma.dir37
-rw-r--r--peripherals/dma/dma.h190
3 files changed, 620 insertions, 0 deletions
diff --git a/peripherals/dma/dma.c b/peripherals/dma/dma.c
new file mode 100644
index 0000000..cfae3dc
--- /dev/null
+++ b/peripherals/dma/dma.c
@@ -0,0 +1,393 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "dma.h"
+#include <utility/assert.h>
+#include <utility/trace.h>
+
+//------------------------------------------------------------------------------
+// Global functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Configure a DMAC peripheral
+//------------------------------------------------------------------------------
+void DMA_Config(unsigned int flag)
+{
+ AT91C_BASE_HDMA->HDMA_GCFG = flag;
+}
+
+//------------------------------------------------------------------------------
+/// Enables a DMAC peripheral
+//------------------------------------------------------------------------------
+void DMA_Enable(void)
+{
+ AT91C_BASE_HDMA->HDMA_EN = AT91C_HDMA_ENABLE;
+}
+
+//------------------------------------------------------------------------------
+/// Disables DMAC peripheral
+//------------------------------------------------------------------------------
+void DMA_Disable(void)
+{
+ AT91C_BASE_HDMA->HDMA_EN = ~(unsigned int)AT91C_HDMA_ENABLE;
+}
+
+//-----------------------------------------------------------------------------
+/// Enable DMA interrupt
+/// \param flag IT to be enabled
+//-----------------------------------------------------------------------------
+void DMA_EnableIt (unsigned int flag)
+{
+ AT91C_BASE_HDMA->HDMA_EBCIER = flag;
+}
+
+//-----------------------------------------------------------------------------
+/// Disable DMA interrupt
+/// \param flag IT to be enabled
+//-----------------------------------------------------------------------------
+void DMA_DisableIt (unsigned int flag)
+{
+ AT91C_BASE_HDMA->HDMA_EBCIDR = flag;
+}
+
+//-----------------------------------------------------------------------------
+/// Return DMA Interrupt Status
+//-----------------------------------------------------------------------------
+unsigned int DMA_GetStatus(void)
+{
+ return (AT91C_BASE_HDMA->HDMA_EBCISR);
+}
+
+//-----------------------------------------------------------------------------
+/// Return DMA Interrupt Mask Status
+//-----------------------------------------------------------------------------
+unsigned int DMA_GetInterruptMask(void)
+{
+ return (AT91C_BASE_HDMA->HDMA_EBCIMR);
+}
+
+//-----------------------------------------------------------------------------
+/// Returns the current status register of the given DMA peripheral, but
+/// masking interrupt sources which are not currently enabled.
+//-----------------------------------------------------------------------------
+unsigned int DMA_GetMaskedStatus(void)
+{
+ unsigned int status;
+ status = AT91C_BASE_HDMA->HDMA_EBCISR;
+ status &= AT91C_BASE_HDMA->HDMA_EBCIMR;
+ return status;
+}
+
+//------------------------------------------------------------------------------
+/// Enables DMAC channel
+/// \param channel Particular channel number.
+//------------------------------------------------------------------------------
+void DMA_EnableChannel(unsigned int channel)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CHER |= DMA_ENA << channel;
+}
+void DMA_EnableChannels(unsigned int bmChannels)
+{
+ AT91C_BASE_HDMA->HDMA_CHER = bmChannels;
+}
+
+//------------------------------------------------------------------------------
+/// Disables a DMAC channel
+/// \param channel Particular channel number.
+//------------------------------------------------------------------------------
+void DMA_DisableChannel(unsigned int channel)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CHDR |= DMA_DIS << channel;
+}
+void DMA_DisableChannels(unsigned int bmChannels)
+{
+ AT91C_BASE_HDMA->HDMA_CHDR = bmChannels;
+}
+
+//------------------------------------------------------------------------------
+/// Resume DMAC channel from an stall state.
+/// \param channel Particular channel number.
+//------------------------------------------------------------------------------
+void DMA_KeeponChannel(unsigned int channel)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CHER |= DMA_KEEPON << channel;
+}
+
+//------------------------------------------------------------------------------
+/// Clear automatic mode for multi-buffer transfer.
+/// \param channel Particular channel number.
+//------------------------------------------------------------------------------
+void DMA_ClearAutoMode(unsigned int channel)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB &= 0x7FFFFFFF;
+}
+
+//------------------------------------------------------------------------------
+/// Return DMAC channel status
+//------------------------------------------------------------------------------
+unsigned int DMA_GetChannelStatus(void)
+{
+ return( AT91C_BASE_HDMA->HDMA_CHSR);
+}
+
+//-----------------------------------------------------------------------------
+/// Set DMA source address used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param sources sources address.
+//-----------------------------------------------------------------------------
+void DMA_SetSourceAddr(unsigned char channel, unsigned int address)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_SADDR = address;
+}
+
+//-----------------------------------------------------------------------------
+/// Set DMA destination address used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param sources destination address.
+//-----------------------------------------------------------------------------
+void DMA_SetDestinationAddr(unsigned char channel, unsigned int address)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_DADDR = address;
+}
+
+//-----------------------------------------------------------------------------
+/// Set DMA descriptor address used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param sources destination address.
+//-----------------------------------------------------------------------------
+void DMA_SetDescriptorAddr(unsigned char channel, unsigned int address)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_DSCR = address ;
+}
+
+
+//-----------------------------------------------------------------------------
+/// Set DMA control A register used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param size Dma transfer size in byte.
+/// \param sourceWidth Single transfer width for source.
+/// \param destWidth Single transfer width for destination.
+/// \param done Transfer done field.
+//-----------------------------------------------------------------------------
+void DMA_SetSourceBufferSize(unsigned char channel,
+ unsigned int size,
+ unsigned char sourceWidth,
+ unsigned char destWidth,
+ unsigned char done)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ ASSERT(sourceWidth < 4, "width does not support");
+ ASSERT(destWidth < 4, "width does not support");
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLA = (size |
+ sourceWidth << 24 |
+ destWidth << 28 |
+ done << 31);
+}
+
+//-----------------------------------------------------------------------------
+/// Set DMA transfer mode for source used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param transferMode Transfer buffer mode (single, LLI, reload or contiguous)
+/// \param addressingType Type of addrassing mode
+/// 0 : incrementing, 1: decrementing, 2: fixed.
+//-----------------------------------------------------------------------------
+void DMA_SetSourceBufferMode(unsigned char channel,
+ unsigned char transferMode,
+ unsigned char addressingType)
+{
+ unsigned int value;
+
+ ASSERT(channel < DMA_CHANNEL_NUM, "channel %d does not exist", channel);
+
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB;
+ value &= ~ (AT91C_SRC_DSCR | AT91C_SRC_INCR | 1<<31);
+ switch(transferMode){
+ case DMA_TRANSFER_SINGLE:
+ value |= AT91C_SRC_DSCR | addressingType << 24;
+ break;
+ case DMA_TRANSFER_LLI:
+ value |= addressingType << 24;
+ break;
+ case DMA_TRANSFER_RELOAD:
+ case DMA_TRANSFER_CONTIGUOUS:
+ value |= AT91C_SRC_DSCR | addressingType << 24 | 1<<31;
+ break;
+ }
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB = value;
+
+ if(transferMode == DMA_TRANSFER_RELOAD || transferMode == DMA_TRANSFER_CONTIGUOUS){
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG;
+ #if defined(AT91C_SRC_REP)
+ value &= ~(unsigned int)AT91C_SRC_REP;
+ // When automatic mode is activated, the source address and the control register are reloaded from previous transfer.
+ if(transferMode == DMA_TRANSFER_RELOAD) {
+ value |= AT91C_SRC_REP;
+ }
+ #endif
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG = value;
+ }
+ else {
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG = 0;
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Set DMA transfer mode for destination used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param transferMode Transfer buffer mode (single, LLI, reload or contiguous)
+/// \param addressingType Type of addrassing mode
+/// 0 : incrementing, 1: decrementing, 2: fixed.
+//-----------------------------------------------------------------------------
+void DMA_SetDestBufferMode(unsigned char channel,
+ unsigned char transferMode,
+ unsigned char addressingType)
+{
+ unsigned int value;
+
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB;
+ value &= ~(unsigned int)(AT91C_DST_DSCR | AT91C_DST_INCR);
+
+ switch(transferMode){
+ case DMA_TRANSFER_SINGLE:
+ case DMA_TRANSFER_RELOAD:
+ case DMA_TRANSFER_CONTIGUOUS:
+ value |= AT91C_DST_DSCR | addressingType << 28;
+ break;
+ case DMA_TRANSFER_LLI:
+ value |= addressingType << 28;
+ break;
+ }
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB = value;
+ if(transferMode == DMA_TRANSFER_RELOAD || transferMode == DMA_TRANSFER_CONTIGUOUS){
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG;
+ #if defined(AT91C_DST_REP)
+ value &= ~(unsigned int)AT91C_DST_REP;
+ // When automatic mode is activated, the source address and the control register are reloaded from previous transfer.
+ if(transferMode == DMA_TRANSFER_RELOAD) {
+ value |= AT91C_DST_REP;
+ }
+ #endif
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG = value;
+ }
+ else {
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG = 0;
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Set DMA configuration registe used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param value configuration value.
+//------------------------------------------------------------------------------
+void DMA_SetConfiguration(unsigned char channel, unsigned int value)
+{
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CFG = value;
+}
+
+#if defined(AT91C_SRC_PIP)
+//------------------------------------------------------------------------------
+/// Set DMA source PIP configuration used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param pipHole stop on done mode.
+/// \param pipBoundary lock mode.
+//------------------------------------------------------------------------------
+void DMA_SPIPconfiguration(unsigned char channel,
+ unsigned int pipHole,
+ unsigned int pipBoundary)
+
+{
+ unsigned int value;
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB;
+ value &= ~(unsigned int)AT91C_SRC_PIP;
+ value |= AT91C_SRC_PIP;
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB = value;
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_SPIP = (pipHole + 1) | pipBoundary <<16;
+}
+#endif
+
+#if defined(AT91C_DST_PIP)
+//------------------------------------------------------------------------------
+/// Set DMA destination PIP configuration used by a HDMA channel.
+/// \param channel Particular channel number.
+/// \param pipHole stop on done mode.
+/// \param pipBoundary lock mode.
+//------------------------------------------------------------------------------
+void DMA_DPIPconfiguration(unsigned char channel,
+ unsigned int pipHole,
+ unsigned int pipBoundary)
+
+{
+ unsigned int value;
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB;
+ value &= ~(unsigned int)AT91C_DST_PIP;
+ value |= AT91C_DST_PIP;
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB = value;
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_DPIP = (pipHole + 1) | pipBoundary <<16;
+}
+#endif
+
+//-----------------------------------------------------------------------------
+/// Set DMA control B register Flow control bit field.
+/// \param channel Particular channel number.
+/// \param size Dma transfer size in byte.
+/// \param sourceWidth Single transfer width for source.
+/// \param destWidth Single transfer width for destination.
+/// \param done Transfer done field.
+//-----------------------------------------------------------------------------
+void DMA_SetFlowControl(unsigned char channel,
+ unsigned int flow)
+{
+ unsigned int value;
+
+ ASSERT(channel < DMA_CHANNEL_NUM, "this channel does not exist");
+ ASSERT(flow < 4, "flow control does not support");
+
+ value = AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB;
+ value &= ~(unsigned int)AT91C_FC;
+ value |= flow << 21;
+ AT91C_BASE_HDMA->HDMA_CH[channel].HDMA_CTRLB = value;
+}
+
diff --git a/peripherals/dma/dma.dir b/peripherals/dma/dma.dir
new file mode 100644
index 0000000..af77f27
--- /dev/null
+++ b/peripherals/dma/dma.dir
@@ -0,0 +1,37 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+/// \dir
+///
+/// !!!Purpose
+///
+/// Contains the peripheral API for the DMA controller (DMAC).
+//------------------------------------------------------------------------------
+
diff --git a/peripherals/dma/dma.h b/peripherals/dma/dma.h
new file mode 100644
index 0000000..dbf50b9
--- /dev/null
+++ b/peripherals/dma/dma.h
@@ -0,0 +1,190 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support - ROUSSET -
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2006, Atmel Corporation
+
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaiimer below.
+ *
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the disclaimer below in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+//------------------------------------------------------------------------------
+/// \dir
+/// !Purpose
+///
+/// Interface for configuration the %DMA controller(DMAC).
+///
+/// !Usage
+///
+/// -# Enable or disable the a DMAC controller with
+/// DMA_Enable() and or DMA_Disable().
+/// -# Enable or disable %Dma interrupt using DMA_EnableIt()
+/// or DMA_DisableIt().
+/// -# Get %Dma interrupt status by DMA_GetStatus().
+/// -# Enable or disable specified %Dma channel with
+/// DMA_EnableChannel() or DMA_DisableChannel().
+/// -# Get %Dma channel status by DMA_GetChannelStatus().
+/// -# Configure source and/or destination start address with
+/// DMA_SetSourceAddr() and/or DMA_SetDestAddr().
+/// -# Set %Dma descriptor address using DMA_SetDescriptorAddr().
+/// -# Set source transfer buffer size with DMA_SetSourceBufferSize().
+/// -# Configure source and/or destination transfer mode with
+/// DMA_SetSourceBufferMode() and/or DMA_SetDestBufferMode().
+/// -# Configure source and/or destination Picture-In-Picutre
+/// mode with DMA_SPIPconfiguration() and/or DMA_DPIPconfiguration().
+//------------------------------------------------------------------------------
+
+#ifndef DMA_H
+#define DMA_H
+
+#include <board.h>
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+#define DMA_CHANNEL_0 0
+#define DMA_CHANNEL_1 1
+#define DMA_CHANNEL_2 2
+#define DMA_CHANNEL_3 3
+#define DMA_CHANNEL_4 4
+#define DMA_CHANNEL_5 5
+#define DMA_CHANNEL_6 6
+#define DMA_CHANNEL_7 7
+
+#if defined(CHIP_DMA_CHANNEL_NUM)
+#define DMA_CHANNEL_NUM CHIP_DMA_CHANNEL_NUM
+#endif
+
+#define DMA_TRANSFER_SINGLE 0
+#define DMA_TRANSFER_LLI 1
+#define DMA_TRANSFER_RELOAD 2
+#define DMA_TRANSFER_CONTIGUOUS 3
+
+
+#define DMA_ENA (1 << 0)
+#define DMA_DIS (1 << 0)
+#define DMA_SUSP (1 << 8)
+#define DMA_KEEPON (1 << 24)
+
+#define DMA_BTC (1 << 0)
+#define DMA_CBTC (1 << 8)
+#define DMA_ERR (1 << 16)
+
+#ifdef AT91C_HDMA_SRC_DSCR
+ #define AT91C_SRC_DSCR AT91C_HDMA_SRC_DSCR
+ #define AT91C_DST_DSCR AT91C_HDMA_DST_DSCR
+ #define AT91C_SRC_INCR AT91C_HDMA_SRC_ADDRESS_MODE
+ #define AT91C_DST_INCR AT91C_HDMA_DST_ADDRESS_MODE
+ #define AT91C_SRC_PER AT91C_HDMA_SRC_PER
+ #define AT91C_DST_PER AT91C_HDMA_DST_PER
+#if defined(AT91C_HDMA_SRC_REP)
+ #define AT91C_SRC_REP AT91C_HDMA_SRC_REP
+#endif
+#if defined(AT91C_HDMA_DST_REP)
+ #define AT91C_DST_REP AT91C_HDMA_DST_REP
+#endif
+#if defined(AT91C_HDMA_SRC_PIP)
+ #define AT91C_SRC_PIP AT91C_HDMA_SRC_PIP
+#endif
+#if defined(AT91C_HDMA_DST_PIP)
+ #define AT91C_DST_PIP AT91C_HDMA_DST_PIP
+#endif
+ #define AT91C_FC AT91C_HDMA_FC
+
+ #define AT91C_BTC (0xFF << 0)
+ #define AT91C_CBTC (0xFF << 8)
+ #define AT91C_ERR (0xFF << 16)
+#endif
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+extern void DMA_Config(unsigned int flag);
+
+extern void DMA_Enable(void);
+
+extern void DMA_Disable(void);
+
+extern void DMA_EnableChannel(unsigned int channel);
+extern void DMA_EnableChannels(unsigned int bmChannels);
+
+extern void DMA_DisableChannel(unsigned int channel);
+extern void DMA_DisableChannels(unsigned int bmChannels);
+
+extern void DMA_KeeponChannel(unsigned int channel);
+
+extern void DMA_ClearAutoMode(unsigned int channel);
+
+extern unsigned int DMA_GetChannelStatus(void);
+
+extern unsigned int DMA_GetStatus(void);
+
+extern unsigned int DMA_GetInterruptMask(void);
+
+extern unsigned int DMA_GetMaskedStatus(void);
+
+extern void DMA_EnableIt (unsigned int flag);
+
+extern void DMA_DisableIt (unsigned int flag);
+
+extern void DMA_SetSourceAddr(unsigned char channel, unsigned int address);
+
+extern void DMA_SetDestinationAddr(unsigned char channel, unsigned int address);
+
+extern void DMA_SetDescriptorAddr(unsigned char channel, unsigned int address);
+
+extern void DMA_SetSourceBufferSize(unsigned char channel,
+ unsigned int size,
+ unsigned char sourceWidth,
+ unsigned char desDMAdth,
+ unsigned char done);
+
+extern void DMA_SetSourceBufferMode(unsigned char channel,
+ unsigned char transferMode,
+ unsigned char addressingType);
+
+extern void DMA_SetDestBufferMode(unsigned char channel,
+ unsigned char transferMode,
+ unsigned char addressingType);
+
+extern void DMA_SetConfiguration(unsigned char channel, unsigned int value);
+
+#if defined(AT91C_SRC_PIP)
+extern void DMA_SPIPconfiguration(unsigned char channel,
+ unsigned int pipHole, unsigned int pipBoundary);
+#endif
+
+#if defined(AT91C_DST_PIP)
+extern void DMA_DPIPconfiguration(unsigned char channel,
+ unsigned int pipHole, unsigned int pipBoundary);
+#endif
+
+extern void DMA_SetFlowControl(unsigned char channel,
+ unsigned int flow);
+
+
+#endif //#ifndef DMA_H
personal git repositories of Harald Welte. Your mileage may vary