Skip to content

Commit

Permalink
drivers/dma: dma_stm32f4x: use dma_slot to select peripheral
Browse files Browse the repository at this point in the history
The DMA API provides dma_slot field as a method to configure at
runtime which peripheral DMA_request the DMA controller should
select.

This method allows to specify different selections for different stm32
DMA streams. So, all the Kconfig definitions, which by the way where
fixing the same selection for all DMA streams, have been deleted.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
  • Loading branch information
avisconti authored and galak committed Jul 5, 2018
1 parent 86de204 commit b29daba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 67 deletions.
54 changes: 0 additions & 54 deletions drivers/dma/Kconfig.stm32f4x
Expand Up @@ -11,57 +11,3 @@ menuconfig DMA_STM32F4X
depends on SOC_SERIES_STM32F4X
help
DMA driver for STM32F4x series SoCs.

config DMA_0_RX_SUB_CHANNEL_ID
int "Requested RX sub-channel ID"
default 0
depends on DMA_STM32F4X
help
This configuration is required to choose a valid sub-channel
for communication from a peripheral/device. Not required
for memory to memory comms.

config DMA_0_TX_SUB_CHANNEL_ID
int "Requested TX sub-channel ID"
default 0
depends on DMA_STM32F4X
help
This configuration is required to choose a valid sub-channel
for communication to a peripheral/device. Not required
for memory to memory comms.

config DMA_1_RX_SUB_CHANNEL_ID
int "Requested RX sub-channel ID"
default 0
depends on DMA_STM32F4X
help
This configuration is required to choose a valid sub-channel
for communication from a peripheral/device. Not required
for memory to memory comms.

config DMA_1_TX_SUB_CHANNEL_ID
int "Requested TX sub-channel ID"
default 0
depends on DMA_STM32F4X
help
This configuration is required to choose a valid sub-channel
for communication to a peripheral/device. Not required
for memory to memory comms.

config DMA_2_RX_SUB_CHANNEL_ID
int "Requested RX sub-channel ID"
default 0
depends on DMA_STM32F4X
help
This configuration is required to choose a valid sub-channel
for communication from a peripheral/device. Not required
for memory to memory comms.

config DMA_2_TX_SUB_CHANNEL_ID
int "Requested TX sub-channel ID"
default 0
depends on DMA_STM32F4X
help
This configuration is required to choose a valid sub-channel
for communication to a peripheral/device. Not required
for memory to memory comms.
15 changes: 2 additions & 13 deletions drivers/dma/dma_stm32f4x.c
Expand Up @@ -25,11 +25,6 @@

#define DMA_STM32_IRQ_PRI CONFIG_DMA_0_IRQ_PRI

#define DMA_STM32_1_RX_CHANNEL_ID CONFIG_DMA_1_RX_SUB_CHANNEL_ID
#define DMA_STM32_1_TX_CHANNEL_ID CONFIG_DMA_1_TX_SUB_CHANNEL_ID
#define DMA_STM32_2_RX_CHANNEL_ID CONFIG_DMA_2_RX_SUB_CHANNEL_ID
#define DMA_STM32_2_TX_CHANNEL_ID CONFIG_DMA_2_TX_SUB_CHANNEL_ID

struct dma_stm32_stream_reg {
/* Shared registers */
u32_t lisr;
Expand Down Expand Up @@ -61,8 +56,6 @@ static struct dma_stm32_device {
struct device *clk;
struct dma_stm32_stream stream[DMA_STM32_MAX_STREAMS];
bool mem2mem;
u8_t channel_rx;
u8_t channel_tx;
} device_data[DMA_STM32_MAX_DEVS];

struct dma_stm32_config {
Expand Down Expand Up @@ -311,7 +304,7 @@ static int dma_stm32_config_devcpy(struct device *dev, u32_t id,
DMA_STM32_SCR_MSIZE(src_bus_width) |
DMA_STM32_SCR_PBURST(dst_burst_size) |
DMA_STM32_SCR_MBURST(src_burst_size) |
DMA_STM32_SCR_REQ(ddata->channel_tx) |
DMA_STM32_SCR_REQ(config->dma_slot) |
DMA_STM32_SCR_TCIE | DMA_STM32_SCR_TEIE |
DMA_STM32_SCR_MINC;
break;
Expand All @@ -321,7 +314,7 @@ static int dma_stm32_config_devcpy(struct device *dev, u32_t id,
DMA_STM32_SCR_MSIZE(dst_bus_width) |
DMA_STM32_SCR_PBURST(src_burst_size) |
DMA_STM32_SCR_MBURST(dst_burst_size) |
DMA_STM32_SCR_REQ(ddata->channel_rx) |
DMA_STM32_SCR_REQ(config->dma_slot) |
DMA_STM32_SCR_TCIE | DMA_STM32_SCR_TEIE |
DMA_STM32_SCR_MINC;
break;
Expand Down Expand Up @@ -548,8 +541,6 @@ static void dma_stm32_irq_7(void *arg) { dma_stm32_irq_handler(arg, 7); }
static void dma_stm32_1_config(struct dma_stm32_device *ddata)
{
ddata->base = DMA_STM32_1_BASE;
ddata->channel_tx = DMA_STM32_1_TX_CHANNEL_ID;
ddata->channel_rx = DMA_STM32_1_RX_CHANNEL_ID;

IRQ_CONNECT(DMA1_Stream0_IRQn, DMA_STM32_IRQ_PRI,
dma_stm32_irq_0, DEVICE_GET(dma_stm32_1), 0);
Expand Down Expand Up @@ -588,8 +579,6 @@ static void dma_stm32_2_config(struct dma_stm32_device *ddata)
{
ddata->base = DMA_STM32_2_BASE;
ddata->mem2mem = true;
ddata->channel_tx = DMA_STM32_2_TX_CHANNEL_ID;
ddata->channel_rx = DMA_STM32_2_RX_CHANNEL_ID;

IRQ_CONNECT(DMA2_Stream0_IRQn, DMA_STM32_IRQ_PRI,
dma_stm32_irq_0, DEVICE_GET(dma_stm32_2), 0);
Expand Down

0 comments on commit b29daba

Please sign in to comment.