mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
arch/arm/src/lpc54xx: DMA driver is code compelete. Untested and still needs more review.
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
********************************************************************************************/
|
||||
|
||||
#define LPC54_DMA_NCHANNELS 30 /* Channels 0..29 */
|
||||
#define LPC54_DMA_MAXXFRS 1024 /* Maximum number of transfers per DMA */
|
||||
|
||||
/* Register offsets *************************************************************************/
|
||||
|
||||
@@ -201,4 +202,77 @@
|
||||
#define DMA_XFERCFG_XFERCOUNT_MASK (0x3ff << DMA_XFERCFG_XFERCOUNT_SHIFT)
|
||||
# define DMA_XFERCFG_XFERCOUNT(n) ((uint32_t)((n)-1) << DMA_XFERCFG_XFERCOUNT_SHIFT)
|
||||
|
||||
/* DMA requests *****************************************************************************/
|
||||
/* DMA requests are directly connected to the peripherals. Each channel supports one DMA
|
||||
* request line and one trigger input. Some DMA requests allow a selection of requests
|
||||
* sources. DMA triggers are selected from many possible input sources.
|
||||
*/
|
||||
|
||||
/* Peripheral request inputs to DMA channel. For DMA channel 'n', the corresponding DMA
|
||||
* trigger input is provided by the setting of the INPUT MUX register DMA_ITRIG_INMUXn
|
||||
*/
|
||||
|
||||
#define FLEXCOMM0_RX_DMACHAN (0) /* Flexcomm Interface 0 RX */
|
||||
#define FLEXCOMM0_I2CSLAVE_DMACHAN (0) /* Flexcomm Interface 0 I2C Slave */
|
||||
#define FLEXCOMM0_TX_DMACHAN (1) /* Flexcomm Interface 0 TX */
|
||||
#define FLEXCOMM0_I2CMASTER_DMACHAN (1) /* Flexcomm Interface 0 I2C Master */
|
||||
#define FLEXCOMM1_RX_DMACHAN (2) /* Flexcomm Interface 1 RX */
|
||||
#define FLEXCOMM1_I2CSLAVE_DMACHAN (2) /* Flexcomm Interface 1 I2C Slave */
|
||||
#define FLEXCOMM1_TX_DMACHAN (3) /* Flexcomm Interface 1 TX */
|
||||
#define FLEXCOMM1_I2CMASTER_DMACHAN (3) /* Flexcomm Interface 1 I2C Master */
|
||||
#define FLEXCOMM2_RX_DMACHAN (4) /* Flexcomm Interface 2 RX */
|
||||
#define FLEXCOMM2_I2CSLAVE_DMACHAN (4) /* Flexcomm Interface 2 I2C Slave */
|
||||
#define FLEXCOMM2_TX_DMACHAN (5) /* Flexcomm Interface 2 TX */
|
||||
#define FLEXCOMM2_I2CMASTER_DMACHAN (5) /* Flexcomm Interface 2 I2C Master */
|
||||
#define FLEXCOMM3_RX_DMACHAN (6) /* Flexcomm Interface 3 RX */
|
||||
#define FLEXCOMM3_I2CSLAVE_DMACHAN (6) /* Flexcomm Interface 3 I2C Slave */
|
||||
#define FLEXCOMM3_TX_DMACHAN (7) /* Flexcomm Interface 3 TX */
|
||||
#define FLEXCOMM3_I2CMASTER_DMACHAN (7) /* Flexcomm Interface 3 I2C Master */
|
||||
#define FLEXCOMM4_RX_DMACHAN (8) /* Flexcomm Interface 4 RX */
|
||||
#define FLEXCOMM4_I2CSLAVE_DMACHAN (8) /* Flexcomm Interface 4 I2C Slave */
|
||||
#define FLEXCOMM4_TX_DMACHAN (9) /* Flexcomm Interface 4 TX */
|
||||
#define FLEXCOMM4_I2CMASTER_DMACHAN (9) /* Flexcomm Interface 4 I2C Master */
|
||||
#define FLEXCOMM5_RX_DMACHAN (10) /* Flexcomm Interface 5 RX */
|
||||
#define FLEXCOMM5_I2CSLAVE_DMACHAN (10) /* Flexcomm Interface 5 I2C Slave */
|
||||
#define FLEXCOMM5_TX_DMACHAN (11) /* Flexcomm Interface 5 TX */
|
||||
#define FLEXCOMM5_I2CMASTER_DMACHAN (11) /* Flexcomm Interface 5 I2C Master */
|
||||
#define FLEXCOMM6_RX_DMACHAN (12) /* Flexcomm Interface 6 RX */
|
||||
#define FLEXCOMM6_I2CSLAVE_DMACHAN (12) /* Flexcomm Interface 6 I2C Slave */
|
||||
#define FLEXCOMM6_TX_DMACHAN (13) /* Flexcomm Interface 6 TX */
|
||||
#define FLEXCOMM6_I2CMASTER_DMACHAN (13) /* Flexcomm Interface 6 I2C Master */
|
||||
#define FLEXCOMM7_RX_DMACHAN (14) /* Flexcomm Interface 7 RX */
|
||||
#define FLEXCOMM7_I2CSLAVE_DMACHAN (14) /* Flexcomm Interface 7 I2C Slave */
|
||||
#define FLEXCOMM7_TX_DMACHAN (15) /* Flexcomm Interface 7 TX */
|
||||
#define FLEXCOMM7_I2CMASTER_DMACHAN (15) /* Flexcomm Interface 7 I2C Master */
|
||||
#define DMIC0_DMACHAN (16) /* DMIC0 */
|
||||
#define DMIC1_DMACHAN (17) /* DMIC1 */
|
||||
#define SPIFI_DMACHAN (18) /* SPIFI */
|
||||
#define SHA_DMACHAN (19) /* SHA */
|
||||
#define FLEXCOMM8_RX_DMACHAN (20) /* Flexcomm Interface 8 RX */
|
||||
#define FLEXCOMM8_I2CSLAVE_DMACHAN (20) /* Flexcomm Interface 8 I2C Slave */
|
||||
#define FLEXCOMM8_TX_DMACHAN (21) /* Flexcomm Interface 8 TX */
|
||||
#define FLEXCOMM8_I2CMASTER_DMACHAN (21) /* Flexcomm Interface 8 I2C Slave (?) */
|
||||
#define FLEXCOMM9_RX_DMACHAN (22) /* Flexcomm Interface 9 RX */
|
||||
#define FLEXCOMM9_I2CSLAVE_DMACHAN (22) /* Flexcomm Interface 9 I2C Slave */
|
||||
#define FLEXCOMM9_TX_DMACHAN (23) /* Flexcomm Interface 9 TX */
|
||||
#define FLEXCOMM9_I2CMASTER_DMACHAN (23) /* Flexcomm Interface 9 I2C Slave (?) */
|
||||
#define SMARTCARD0_RX_DMACHAN (24) /* SMARTCARD0_RX */
|
||||
#define SMARTCARD0_TX_DMACHAN (25) /* SMARTCARD0_TX */
|
||||
#define SMARTCARD1_RX_DMACHAN (26) /* SMARTCARD1_RX */
|
||||
#define SMARTCARD1_TX_DMACHAN (27) /* SMARTCARD1_TX */
|
||||
|
||||
/********************************************************************************************
|
||||
* Public Types
|
||||
********************************************************************************************/
|
||||
|
||||
/* DMA channel descriptor */
|
||||
|
||||
struct lpc54_dmachan_desc_s
|
||||
{
|
||||
uint32_t reserved;
|
||||
uint32_t srcend; /* Source data end address */
|
||||
uint32_t dstend; /* Destination end address */
|
||||
uint32_t link; /* Link to next descriptor */
|
||||
};
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_LPC54XX_CHIP_LPC54_DMA_H */
|
||||
|
||||
@@ -214,8 +214,32 @@
|
||||
|
||||
/* Trigger select register for DMA channel 0-29 */
|
||||
|
||||
#define ITRIG_INMUX_ADC0A (0) /* ADC0 Sequence A interrupt */
|
||||
#define ITRIG_INMUX_ADC0B (1) /* ADC0 Sequence B interrupt */
|
||||
#define ITRIG_INMUX_SCT0DMA0 (2) /* SCT0 DMA request 0 */
|
||||
#define ITRIG_INMUX_SCT0DMA1 (3) /* SCT0 DMA request 1 */
|
||||
#define ITRIG_INMUX_PININT0 (4) /* Pin interrupt 0 */
|
||||
#define ITRIG_INMUX_PININT1 (5) /* Pin interrupt 1 */
|
||||
#define ITRIG_INMUX_PININT2 (6) /* Pin interrupt 2 */
|
||||
#define ITRIG_INMUX_PININT3 (7) /* Pin interrupt 3 */
|
||||
#define ITRIG_INMUX_CTIMER0MAT0 (8) /* Timer CTIMER0 Match 0 */
|
||||
#define ITRIG_INMUX_CTIMER0MAT1 (9) /* Timer CTIMER0 Match 1 */
|
||||
#define ITRIG_INMUX_CTIMER1MAT0 (10) /* Timer CTIMER1 Match 0 */
|
||||
#define ITRIG_INMUX_CTIMER1MAT1 (11) /* Timer CTIMER1 Match 1 */
|
||||
#define ITRIG_INMUX_CTIMER2MAT0 (12) /* Timer CTIMER2 Match 0 */
|
||||
#define ITRIG_INMUX_CTIMER2MAT1 (13) /* Timer CTIMER2 Match 1 */
|
||||
#define ITRIG_INMUX_CTIMER3MAT0 (14) /* Timer CTIMER3 Match 0 */
|
||||
#define ITRIG_INMUX_CTIMER3MAT1 (15) /* Timer CTIMER3 Match 1 */
|
||||
#define ITRIG_INMUX_CTIMER4MAT0 (16) /* Timer CTIMER4 Match 0 */
|
||||
#define ITRIG_INMUX_CTIMER4MAT1 (17) /* Timer CTIMER4 Match 1 */
|
||||
#define ITRIG_INMUX_DMAMUX0 (18) /* DMA output trigger mux 0 */
|
||||
#define ITRIG_INMUX_DMAMUX1 (19) /* DMA output trigger mux 1 */
|
||||
#define ITRIG_INMUX_DMAMUX2 (20) /* DMA output trigger mux 2 */
|
||||
#define ITRIG_INMUX_DMAMUX3 (21) /* DMA output trigger mux 3 */
|
||||
|
||||
#define MUX_DMA_ITRIG_INMUX_SHIFT (0) /* Bit 0-4: Trigger input number for DMA channel n (n = 0 to 29) */
|
||||
#define MUX_DMA_ITRIG_INMUX_MASK (31 << MUX_DMA_ITRIG_INMUX_SHIFT)
|
||||
# define MUX_DMA_ITRIG_INMUX(n) ((uint32_t)(n) << MUX_DMA_ITRIG_INMUX_SHIFT)
|
||||
# define MUX_DMA_ITRIG_INMUX_ADC0A (0 << MUX_DMA_ITRIG_INMUX_SHIFT) /* ADC0 Sequence A interrupt */
|
||||
# define MUX_DMA_ITRIG_INMUX_ADC0B (1 << MUX_DMA_ITRIG_INMUX_SHIFT) /* ADC0 Sequence B interrupt */
|
||||
# define MUX_DMA_ITRIG_INMUX_SCT0DMA0 (2 << MUX_DMA_ITRIG_INMUX_SHIFT) /* SCT0 DMA request 0 */
|
||||
|
||||
+216
-222
File diff suppressed because it is too large
Load Diff
@@ -55,8 +55,7 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
typedef FAR void *DMA_HANDLE;
|
||||
typedef void (*dma_callback_t)(DMA_HANDLE handle, void *arg, int result);
|
||||
typedef void (*dma_callback_t)(int ch, void *arg, int result);
|
||||
|
||||
/* The following is used for sampling DMA registers when CONFIG DEBUG_DMA is selected */
|
||||
|
||||
@@ -116,46 +115,32 @@ extern "C"
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc54_dmachannel
|
||||
*
|
||||
* Description:
|
||||
* Allocate a DMA channel. This function sets aside a DMA channel and
|
||||
* gives the caller exclusive access to the DMA channel.
|
||||
*
|
||||
* Returned Value:
|
||||
* One success, this function returns a non-NULL, void* DMA channel
|
||||
* handle. NULL is returned on any failure. This function can fail only
|
||||
* if no DMA channel is available.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
DMA_HANDLE lpc54_dmachannel(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc54_dmafree
|
||||
*
|
||||
* Description:
|
||||
* Release a DMA channel. NOTE: The 'handle' used in this argument must
|
||||
* NEVER be used again until lpc54_dmachannel() is called again to re-gain
|
||||
* a valid handle.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lpc54_dmafree(DMA_HANDLE handle);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc54_dmasetup
|
||||
* Name: lpc54_dma_setup
|
||||
*
|
||||
* Description:
|
||||
* Configure DMA for one transfer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - DMA channel number
|
||||
* cfg - The content of the DMA channel configuration register. See
|
||||
* peripheral channel definitions in chip/lpc54_dma.h. The
|
||||
* caller must provide all fields: PERIPHREQEN, TRIGPOL,
|
||||
* TRIGTYPE, TRIGBURST, BURSTPOWER, SRCBURSTWRAP, DSTBURSTWRAP,
|
||||
* and CHPRIORITY.
|
||||
* xfrcfg - The content of the DMA channel configuration register. See
|
||||
* peripheral channel definitions in chip/lpc54_dma.h. The
|
||||
* caller must provide all fields: WIDTH, SRCINC, and DSTINC.\
|
||||
* All of fields are managed by the DMA driver
|
||||
* trigsrc - See input mux DMA trigger ITRIG_INMUX_* definitions in
|
||||
* chip/lpc54_inputmux.h.
|
||||
* srcaddr - Source address of the DMA transfer
|
||||
* dstaddr - Destination address of the DMA transfer
|
||||
* nbytes - Number of bytes to transfer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lpc54_dmarxsetup(DMA_HANDLE handle, uint32_t control, uint32_t config,
|
||||
uint32_t srcaddr, uint32_t destaddr, size_t nbytes);
|
||||
int lpc54_dma_setup(int ch, uint32_t cfg, uint32_t xfrcfg, uint8_t trigsrc,
|
||||
uintptr_t srcaddr, uintptr_t dstaddr, size_t nbytes);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc54_dmastart
|
||||
@@ -165,7 +150,7 @@ int lpc54_dmarxsetup(DMA_HANDLE handle, uint32_t control, uint32_t config,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int lpc54_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg);
|
||||
int lpc54_dmastart(int ch, dma_callback_t callback, void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc54_dmastop
|
||||
@@ -177,7 +162,7 @@ int lpc54_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lpc54_dmastop(DMA_HANDLE handle);
|
||||
void lpc54_dmastop(int ch);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: lpc54_dmasample
|
||||
@@ -188,7 +173,7 @@ void lpc54_dmastop(DMA_HANDLE handle);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_DMA
|
||||
void lpc54_dmasample(DMA_HANDLE handle, struct lpc54_dmaregs_s *regs);
|
||||
void lpc54_dmasample(int ch, struct lpc54_dmaregs_s *regs);
|
||||
#else
|
||||
# define lpc54_dmasample(handle,regs)
|
||||
#endif
|
||||
@@ -202,7 +187,7 @@ void lpc54_dmasample(DMA_HANDLE handle, struct lpc54_dmaregs_s *regs);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_DMA
|
||||
void lpc54_dmadump(DMA_HANDLE handle, const struct lpc54_dmaregs_s *regs,
|
||||
void lpc54_dmadump(int ch, const struct lpc54_dmaregs_s *regs,
|
||||
const char *msg);
|
||||
#else
|
||||
# define lpc54_dmadump(handle,regs,msg)
|
||||
|
||||
@@ -70,6 +70,7 @@ STATUS
|
||||
2017-12-23: SDMMC is still non-functional. The first DMA read of 512 bytes
|
||||
fails with a CRC error. Similar result if clock is reduced, if 1-bit bus
|
||||
is used, if DMA is disabled., if DEBUG output is disabled.
|
||||
2017-12-24: Added fragmentary DMA support. Much more still needed.
|
||||
|
||||
There is still no support for the Accelerometer, SPIFI, Ethernet, or USB.
|
||||
There is a complete, but not-yet-functional SD card drirver. There is a
|
||||
|
||||
Reference in New Issue
Block a user