diff --git a/arch/arm/src/sama5/sam_adc.c b/arch/arm/src/sama5/sam_adc.c index ef415ee598..111259de5a 100644 --- a/arch/arm/src/sama5/sam_adc.c +++ b/arch/arm/src/sama5/sam_adc.c @@ -319,12 +319,12 @@ #ifdef CONFIG_SAMA5_ADC_DMA # define DMA_FLAGS \ DMACH_FLAG_FIFOCFG_LARGEST | \ - ((SAM_IRQ_ADC << DMACH_FLAG_PERIPHPID_SHIFT) | DMACH_FLAG_PERIPHAHB_AHB_IF2 | \ + DMACH_FLAG_PERIPHPID(SAM_IRQ_ADC) | DMACH_FLAG_PERIPHAHB_AHB_IF2 | \ DMACH_FLAG_PERIPHH2SEL | DMACH_FLAG_PERIPHISPERIPH | \ DMACH_FLAG_PERIPHWIDTH_16BITS | DMACH_FLAG_PERIPHCHUNKSIZE_1 | \ - DMACH_FLAG_MEMPID(0x3f) | DMACH_FLAG_MEMAHB_AHB_IF0 | \ + DMACH_FLAG_MEMPID_MAX | DMACH_FLAG_MEMAHB_AHB_IF0 | \ DMACH_FLAG_MEMWIDTH_16BITS | DMACH_FLAG_MEMINCREMENT | \ - DMACH_FLAG_MEMCHUNKSIZE_1) + DMACH_FLAG_MEMCHUNKSIZE_1 | DMACH_FLAG_MEMBURST_4) #endif /* Pick an unused channel number */ diff --git a/arch/arm/src/sama5/sam_dmac.h b/arch/arm/src/sama5/sam_dmac.h index f909883504..0fa1919a24 100644 --- a/arch/arm/src/sama5/sam_dmac.h +++ b/arch/arm/src/sama5/sam_dmac.h @@ -100,7 +100,8 @@ # define DMACH_FLAG_PERIPHPID_SHIFT (2) /* Bits 1-7: Peripheral PID */ # define DMACH_FLAG_PERIPHPID_MASK (0x3f << DMACH_FLAG_PERIPHPID_SHIFT) -# define DMACH_FLAG_PERIPHPID(n) ((uint32_t) << DMACH_FLAG_PERIPHPID_SHIFT) +# define DMACH_FLAG_PERIPHPID(n) ((uint32_t)(n) << DMACH_FLAG_PERIPHPID_SHIFT) +# define DMACH_FLAG_PERIPHPID_MAX DMACH_FLAG_PERIPHPID_MASK # define DMACH_FLAG_PERIPHH2SEL (1 << 8) /* Bits 8: HW handshaking */ # define DMACH_FLAG_PERIPHISPERIPH (1 << 9) /* Bits 9: 0=memory; 1=peripheral */ # define DMACH_FLAG_PERIPHAHB_SHIFT (10) /* Bits 10-11: Peripheral ABH layer number */ @@ -138,6 +139,7 @@ # define DMACH_FLAG_MEMPID_SHIFT (17) /* Bits 17-22: Memory PID */ # define DMACH_FLAG_MEMPID_MASK (0x3f << DMACH_FLAG_MEMPID_SHIFT) # define DMACH_FLAG_MEMPID(n) ((uint32_t)(n) << DMACH_FLAG_MEMPID_SHIFT) +# define DMACH_FLAG_MEMPID_MAX DMACH_FLAG_MEMPID_MASK # define DMACH_FLAG_MEMH2SEL (1 << 23) /* Bits 23: HW handshaking */ # define DMACH_FLAG_MEMISPERIPH (1 << 24) /* Bits 24: 0=memory; 1=peripheral */ # define DMACH_FLAG_MEMAHB_SHIFT (25) /* Bits 25-26: Peripheral ABH layer number */ @@ -199,7 +201,8 @@ # define DMACH_FLAG_PERIPHPID_SHIFT (0) /* Bits 0-7: Peripheral PID */ # define DMACH_FLAG_PERIPHPID_MASK (0x7f << DMACH_FLAG_PERIPHPID_SHIFT) -# define DMACH_FLAG_PERIPHPID(n) ((uint32_t) << DMACH_FLAG_PERIPHPID_SHIFT) +# define DMACH_FLAG_PERIPHPID(n) ((uint32_t)(n) << DMACH_FLAG_PERIPHPID_SHIFT) +# define DMACH_FLAG_PERIPHPID_MAX DMACH_FLAG_PERIPHPID_MASK # define DMACH_FLAG_PERIPHH2SEL (0) /* No HW handshaking */ # define DMACH_FLAG_PERIPHISPERIPH (1 << 7) /* Bit 7: 0=memory; 1=peripheral */ # define DMACH_FLAG_PERIPHAHB_MASK (1 << 8) /* Bit 8: Peripheral ABH layer 1 */ @@ -234,6 +237,7 @@ */ # define DMACH_FLAG_MEMPID(n) (0) /* No memory peripheral identifier */ +# define DMACH_FLAG_MEMPID_MAX (0) # define DMACH_FLAG_MEMH2SEL (0) /* No HW handshaking */ # define DMACH_FLAG_MEMISPERIPH (0) /* No peripheral-to-peripheral */ # define DMACH_FLAG_MEMAHB_MASK (1 << 16) /* Bit 16: Memory ABH layer 1 */ diff --git a/arch/arm/src/sama5/sam_hsmci.c b/arch/arm/src/sama5/sam_hsmci.c index 3628fb8aa0..9f37a22548 100644 --- a/arch/arm/src/sama5/sam_hsmci.c +++ b/arch/arm/src/sama5/sam_hsmci.c @@ -100,6 +100,11 @@ # error "HSMCI2 support requires CONFIG_SAMA5_DMAC1" # endif + /* System Bus Interfaces */ + +# define HSMCI_SYSBUS_IF DMACH_FLAG_PERIPHAHB_AHB_IF2 +# define MEMORY_SYSBUS_IF DMACH_FLAG_MEMAHB_AHB_IF0 + #elif defined(ATSAMA5D4) /* The SAMA5D3 has two HSMCI blocks: HSMCI0-1. They can be driven * either by XDMAC0 (secure) or XDMAC1 (unsecure). @@ -125,6 +130,18 @@ # error No valid DMA configuration for HSMCI1 # endif + /* System Bus Interfaces + * + * HSMCI0 is on H32MX, APB1; HSMCI1 is on H32MX, APB0. Both are + * accessible on MATRIX IF1. + * + * Memory is available on either port 5 (IF0 for both XDMAC0 and 1) or + * port 6 (IF1 for both XDMAC0 and 1). + */ + +# define HSMCI_SYSBUS_IF DMACH_FLAG_PERIPHAHB_AHB_IF1 +# define MEMORY_SYSBUS_IF DMACH_FLAG_MEMAHB_AHB_IF0 + #else # error Unrecognized SAMA5 architecture #endif @@ -193,22 +210,22 @@ #ifdef HSCMI_FIFODMA # define DMA_FLAGS(pid) \ - (((pid) << DMACH_FLAG_PERIPHPID_SHIFT) | DMACH_FLAG_PERIPHAHB_AHB_IF2 | \ + (DMACH_FLAG_PERIPHPID(pid) | HSMCI_SYSBUS_IF | \ DMACH_FLAG_PERIPHH2SEL | DMACH_FLAG_PERIPHISPERIPH | \ DMACH_FLAG_PERIPHWIDTH_32BITS | DMACH_FLAG_PERIPHINCREMENT | \ DMACH_FLAG_PERIPHCHUNKSIZE_1 | \ - DMACH_FLAG_MEMPID(0x3f) | DMACH_FLAG_MEMAHB_AHB_IF0 | \ + DMACH_FLAG_MEMPID_MAX | MEMORY_SYSBUS_IF | \ DMACH_FLAG_MEMWIDTH_32BITS | DMACH_FLAG_MEMINCREMENT | \ - DMACH_FLAG_MEMCHUNKSIZE_4) + DMACH_FLAG_MEMCHUNKSIZE_4 | DMACH_FLAG_MEMBURST_4) #else # define DMA_FLAGS(pid) \ - (((pid) << DMACH_FLAG_PERIPHPID_SHIFT) | DMACH_FLAG_PERIPHAHB_AHB_IF2 | \ + (DMACH_FLAG_PERIPHPID(pid) | HSMCI_SYSBUS_IF | \ DMACH_FLAG_PERIPHH2SEL | DMACH_FLAG_PERIPHISPERIPH | \ DMACH_FLAG_PERIPHWIDTH_32BITS | DMACH_FLAG_PERIPHCHUNKSIZE_1 | \ - DMACH_FLAG_MEMPID(0x3f) | DMACH_FLAG_MEMAHB_AHB_IF0 | \ + DMACH_FLAG_MEMPID_MAX | MEMORY_SYSBUS_IF | \ DMACH_FLAG_MEMWIDTH_32BITS | DMACH_FLAG_MEMINCREMENT | \ - DMACH_FLAG_MEMCHUNKSIZE_4) + DMACH_FLAG_MEMCHUNKSIZE_4 | DMACH_FLAG_MEMBURST_4) #endif diff --git a/arch/arm/src/sama5/sam_nand.c b/arch/arm/src/sama5/sam_nand.c index 47c6d5e6ca..2f53aa98aa 100644 --- a/arch/arm/src/sama5/sam_nand.c +++ b/arch/arm/src/sama5/sam_nand.c @@ -109,28 +109,28 @@ #define NFCSRAM_DMA_FLAGS \ DMACH_FLAG_FIFOCFG_LARGEST | \ - (((0x3f) << DMACH_FLAG_PERIPHPID_SHIFT) | DMACH_FLAG_PERIPHAHB_AHB_IF0 | \ + (DMACH_FLAG_PERIPHPID_MAX | DMACH_FLAG_PERIPHAHB_AHB_IF0 | \ DMACH_FLAG_PERIPHWIDTH_32BITS | DMACH_FLAG_PERIPHINCREMENT | \ DMACH_FLAG_PERIPHCHUNKSIZE_1 | \ - DMACH_FLAG_MEMPID(0x3f) | DMACH_FLAG_MEMAHB_AHB_IF0 | \ + DMACH_FLAG_MEMPID_MAX | DMACH_FLAG_MEMAHB_AHB_IF0 | \ DMACH_FLAG_MEMWIDTH_32BITS | DMACH_FLAG_MEMINCREMENT | \ - DMACH_FLAG_MEMCHUNKSIZE_1) + DMACH_FLAG_MEMCHUNKSIZE_1 | DMACH_FLAG_MEMBURST_4) #define NAND_DMA_FLAGS8 \ DMACH_FLAG_FIFOCFG_LARGEST | \ - (((0x3f) << DMACH_FLAG_PERIPHPID_SHIFT) | DMACH_FLAG_PERIPHAHB_AHB_IF0 | \ + (DMACH_FLAG_PERIPHPID_MAX | DMACH_FLAG_PERIPHAHB_AHB_IF0 | \ DMACH_FLAG_PERIPHWIDTH_8BITS | DMACH_FLAG_PERIPHCHUNKSIZE_1 | \ - DMACH_FLAG_MEMPID(0x3f) | DMACH_FLAG_MEMAHB_AHB_IF0 | \ + DMACH_FLAG_MEMPID_MAX | DMACH_FLAG_MEMAHB_AHB_IF0 | \ DMACH_FLAG_MEMWIDTH_8BITS | DMACH_FLAG_MEMINCREMENT | \ - DMACH_FLAG_MEMCHUNKSIZE_1) + DMACH_FLAG_MEMCHUNKSIZE_1 | DMACH_FLAG_MEMBURST_4) #define NAND_DMA_FLAGS16 \ DMACH_FLAG_FIFOCFG_LARGEST | \ - (((0x3f) << DMACH_FLAG_PERIPHPID_SHIFT) | DMACH_FLAG_PERIPHAHB_AHB_IF0 | \ + (DMACH_FLAG_PERIPHPID_MAX | DMACH_FLAG_PERIPHAHB_AHB_IF0 | \ DMACH_FLAG_PERIPHWIDTH_16BITS | DMACH_FLAG_PERIPHCHUNKSIZE_1 | \ - DMACH_FLAG_MEMPID(0x3f) | DMACH_FLAG_MEMAHB_AHB_IF0 | \ + DMACH_FLAG_MEMPID_MAX | DMACH_FLAG_MEMAHB_AHB_IF0 | \ DMACH_FLAG_MEMWIDTH_16BITS | DMACH_FLAG_MEMINCREMENT | \ - DMACH_FLAG_MEMCHUNKSIZE_1) + DMACH_FLAG_MEMCHUNKSIZE_1 | DMACH_FLAG_MEMBURST_4) /**************************************************************************** * Private Types diff --git a/arch/arm/src/sama5/sam_spi.c b/arch/arm/src/sama5/sam_spi.c index 549ac675d3..1046910772 100644 --- a/arch/arm/src/sama5/sam_spi.c +++ b/arch/arm/src/sama5/sam_spi.c @@ -1436,13 +1436,12 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, * provided on the SPI bus. */ - rxflags = DMACH_FLAG_FIFOCFG_LARGEST | - ((uint32_t)spi->pid << DMACH_FLAG_PERIPHPID_SHIFT) | + rxflags = DMACH_FLAG_FIFOCFG_LARGEST | DMACH_FLAG_PERIPHPID(spi->pid) | DMACH_FLAG_PERIPHH2SEL | DMACH_FLAG_PERIPHISPERIPH | DMACH_FLAG_PERIPHAHB_AHB_IF2 | DMACH_FLAG_PERIPHWIDTH_8BITS | - DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID(0x3f) | + DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID_MAX | DMACH_FLAG_MEMAHB_AHB_IF0 | DMACH_FLAG_MEMWIDTH_8BITS | - DMACH_FLAG_MEMCHUNKSIZE_1; + DMACH_FLAG_MEMCHUNKSIZE_1 | DMACH_FLAG_MEMBURST_4; if (!rxbuffer) { @@ -1459,13 +1458,12 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer, rxflags |= DMACH_FLAG_MEMINCREMENT; } - txflags = DMACH_FLAG_FIFOCFG_LARGEST | - ((uint32_t)spi->pid << DMACH_FLAG_PERIPHPID_SHIFT) | + txflags = DMACH_FLAG_FIFOCFG_LARGEST | DMACH_FLAG_PERIPHPID(spi->pid) | DMACH_FLAG_PERIPHH2SEL | DMACH_FLAG_PERIPHISPERIPH | DMACH_FLAG_PERIPHAHB_AHB_IF2 | DMACH_FLAG_PERIPHWIDTH_8BITS | - DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID(0x3f) | + DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID_MAX | DMACH_FLAG_MEMAHB_AHB_IF0 | DMACH_FLAG_MEMWIDTH_8BITS | - DMACH_FLAG_MEMCHUNKSIZE_1; + DMACH_FLAG_MEMCHUNKSIZE_1 | DMACH_FLAG_MEMBURST_4; if (!txbuffer) { diff --git a/arch/arm/src/sama5/sam_ssc.c b/arch/arm/src/sama5/sam_ssc.c index 821002330f..4750ecf18b 100644 --- a/arch/arm/src/sama5/sam_ssc.c +++ b/arch/arm/src/sama5/sam_ssc.c @@ -186,28 +186,29 @@ /* DMA configuration */ -#define DMA_PID(pid) ((pid) << DMACH_FLAG_PERIPHPID_SHIFT) - #define DMA8_FLAGS \ (DMACH_FLAG_PERIPHAHB_AHB_IF2 | DMACH_FLAG_PERIPHH2SEL | \ DMACH_FLAG_PERIPHISPERIPH | DMACH_FLAG_PERIPHWIDTH_8BITS | \ - DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID(0x3f) | \ + DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID_MAX | \ DMACH_FLAG_MEMAHB_AHB_IF0 | DMACH_FLAG_MEMWIDTH_16BITS | \ - DMACH_FLAG_MEMINCREMENT | DMACH_FLAG_MEMCHUNKSIZE_4) + DMACH_FLAG_MEMINCREMENT | DMACH_FLAG_MEMCHUNKSIZE_4| \ + DMACH_FLAG_MEMBURST_4) #define DMA16_FLAGS \ (DMACH_FLAG_PERIPHAHB_AHB_IF2 | DMACH_FLAG_PERIPHH2SEL | \ DMACH_FLAG_PERIPHISPERIPH | DMACH_FLAG_PERIPHWIDTH_16BITS | \ - DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID(0x3f) | \ + DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID_MAX | \ DMACH_FLAG_MEMAHB_AHB_IF0 | DMACH_FLAG_MEMWIDTH_16BITS | \ - DMACH_FLAG_MEMINCREMENT | DMACH_FLAG_MEMCHUNKSIZE_4) + DMACH_FLAG_MEMINCREMENT | DMACH_FLAG_MEMCHUNKSIZE_4 | \ + DMACH_FLAG_MEMBURST_4) #define DMA32_FLAGS \ (DMACH_FLAG_PERIPHAHB_AHB_IF2 | DMACH_FLAG_PERIPHH2SEL | \ DMACH_FLAG_PERIPHISPERIPH | DMACH_FLAG_PERIPHWIDTH_32BITS | \ - DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID(0x3f) | \ + DMACH_FLAG_PERIPHCHUNKSIZE_1 | DMACH_FLAG_MEMPID_MAX | \ DMACH_FLAG_MEMAHB_AHB_IF0 | DMACH_FLAG_MEMWIDTH_32BITS | \ - DMACH_FLAG_MEMINCREMENT | DMACH_FLAG_MEMCHUNKSIZE_4) + DMACH_FLAG_MEMINCREMENT | DMACH_FLAG_MEMCHUNKSIZE_4 | \ + DMACH_FLAG_MEMBURST_4) /* DMA timeout. The value is not critical; we just don't want the system to * hang in the event that a DMA does not finish. This is set to @@ -2655,20 +2656,20 @@ static void ssc_clocking(struct sam_ssc_s *priv) static int ssc_dma_flags(struct sam_ssc_s *priv, uint32_t *dmaflags) { - uint32_t regval; + uint32_t flags; switch (priv->datalen) { case 8: - regval = DMA8_FLAGS; + flags = DMA8_FLAGS; break; case 16: - regval = DMA16_FLAGS; + flags = DMA16_FLAGS; break; case 32: - regval = DMA32_FLAGS; + flags = DMA32_FLAGS; break; default: @@ -2676,7 +2677,7 @@ static int ssc_dma_flags(struct sam_ssc_s *priv, uint32_t *dmaflags) return -ENOSYS; } - *dmaflags = (regval | DMA_PID(priv->pid)); + *dmaflags = (flags | DMACH_FLAG_PERIPHPID(priv->pid)); return OK; }