Skip to content

Commit

Permalink
bus/spi_stm32: Add missing DMA configurations (STM32H7)
Browse files Browse the repository at this point in the history
Ony SPI_0 and SPI_1 had DMA configurations.
Now also SPI_2, SPI_3, SPI_4 and SPI_5 can be used.

Signed-off-by: Jerzy Kasenberg <[email protected]>
  • Loading branch information
kasjer committed Nov 6, 2023
1 parent 0d8e9b7 commit 8f94220
Show file tree
Hide file tree
Showing 3 changed files with 319 additions and 4 deletions.
120 changes: 120 additions & 0 deletions hw/bus/drivers/spi_stm32/stm32h7xx/include/spidmacfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,66 @@ SPI_DMA_RX_CHANNEL(2, 5, 2);
SPI_DMA_RX_CHANNEL(2, 6, 2);
SPI_DMA_RX_CHANNEL(2, 7, 2);

SPI_DMA_RX_CHANNEL(1, 1, 3);
SPI_DMA_RX_CHANNEL(1, 2, 3);
SPI_DMA_RX_CHANNEL(1, 3, 3);
SPI_DMA_RX_CHANNEL(1, 4, 3);
SPI_DMA_RX_CHANNEL(1, 5, 3);
SPI_DMA_RX_CHANNEL(1, 6, 3);
SPI_DMA_RX_CHANNEL(1, 7, 3);
SPI_DMA_RX_CHANNEL(2, 1, 3);
SPI_DMA_RX_CHANNEL(2, 2, 3);
SPI_DMA_RX_CHANNEL(2, 3, 3);
SPI_DMA_RX_CHANNEL(2, 4, 3);
SPI_DMA_RX_CHANNEL(2, 5, 3);
SPI_DMA_RX_CHANNEL(2, 6, 3);
SPI_DMA_RX_CHANNEL(2, 7, 3);

SPI_DMA_RX_CHANNEL(1, 1, 4);
SPI_DMA_RX_CHANNEL(1, 2, 4);
SPI_DMA_RX_CHANNEL(1, 3, 4);
SPI_DMA_RX_CHANNEL(1, 4, 4);
SPI_DMA_RX_CHANNEL(1, 5, 4);
SPI_DMA_RX_CHANNEL(1, 6, 4);
SPI_DMA_RX_CHANNEL(1, 7, 4);
SPI_DMA_RX_CHANNEL(2, 1, 4);
SPI_DMA_RX_CHANNEL(2, 2, 4);
SPI_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PI_DMA_TX_CHANNEL(2, 1, 5);
SPI_DMA_TX_CHANNEL(2, 2, 5);
SPI_DMA_TX_CHANNEL(2, 3, 5);
SPI_DMA_TX_CHANNEL(2, 4, 5);
SPI_DMA_TX_CHANNEL(2, 5, 5);
SPI_DMA_TX_CHANNEL(2, 6, 5);
SPI_DMA_TX_CHANNEL(2, 7, 5);

SPI_DMA_TX_CHANNEL(1, 1, 6);
SPI_DMA_TX_CHANNEL(1, 2, 6);
SPI_DMA_TX_CHANNEL(1, 3, 6);
SPI_DMA_TX_CHANNEL(1, 4, 6);
SPI_DMA_TX_CHANNEL(1, 5, 6);
SPI_DMA_TX_CHANNEL(1, 6, 6);
SPI_DMA_TX_CHANNEL(1, 7, 6);
SPI_DMA_TX_CHANNEL(2, 1, 6);
SPI_DMA_TX_CHANNEL(2, 2, 6);
SPI_DMA_TX_CHANNEL(2, 3, 6);
SPI_DMA_TX_CHANNEL(2, 4, 6);
SPI_DMA_TX_CHANNEL(2, 5, 6);
SPI_DMA_TX_CHANNEL(2, 6, 6);
SPI_DMA_TX_CHANNEL(2, 7, 6);
155 changes: 155 additions & 0 deletions hw/bus/drivers/spi_stm32/stm32h7xx/src/spidmacfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@
.Priority = DMA_PRIORITY_LOW, \
} \
}
#define SPI_BDMA_RX_CHANNEL_DEFINE(dma, st, spi_num) \
const struct stm32_dma_cfg DMA ## dma ## _stream ## st ## _spi ## spi_num ## _rx = { \
st, \
DMA ## dma ## _Stream ## st ## _IRQn, \
stm32_dma ## dma ## _ ## st ## _irq_handler, \
.regs = DMA ## dma ## _Stream ## st, \
.init = { \
.Request = BDMA_REQUEST_SPI ## spi_num ## _RX, \
.Direction = DMA_PERIPH_TO_MEMORY, \
.PeriphInc = DMA_PINC_DISABLE, \
.MemInc = DMA_MINC_ENABLE, \
.PeriphDataAlignment = DMA_PDATAALIGN_BYTE, \
.MemDataAlignment = DMA_MDATAALIGN_BYTE, \
.Mode = DMA_NORMAL, \
.Priority = DMA_PRIORITY_LOW, \
} \
}

#define SPI_DMA_TX_CHANNEL_DEFINE(dma, st, spi_num) \
const struct stm32_dma_cfg DMA ## dma ## _stream ## st ## _spi ## spi_num ## _tx = { \
Expand All @@ -57,6 +74,24 @@
} \
}

#define SPI_BDMA_TX_CHANNEL_DEFINE(dma, st, spi_num) \
const struct stm32_dma_cfg DMA ## dma ## _stream ## st ## _spi ## spi_num ## _tx = { \
st, \
DMA ## dma ## _Stream ## st ## _IRQn, \
stm32_dma ## dma ## _ ## st ## _irq_handler, \
.regs = DMA ## dma ## _Stream ## st, \
.init = { \
.Request = BDMA_REQUEST_SPI ## spi_num ## _TX, \
.Direction = DMA_MEMORY_TO_PERIPH, \
.PeriphInc = DMA_PINC_DISABLE, \
.MemInc = DMA_MINC_ENABLE, \
.PeriphDataAlignment = DMA_PDATAALIGN_BYTE, \
.MemDataAlignment = DMA_MDATAALIGN_BYTE, \
.Mode = DMA_NORMAL, \
.Priority = DMA_PRIORITY_LOW, \
} \
}

SPI_DMA_RX_CHANNEL_DEFINE(1, 1, 1);
SPI_DMA_RX_CHANNEL_DEFINE(1, 2, 1);
SPI_DMA_RX_CHANNEL_DEFINE(1, 3, 1);
Expand Down Expand Up @@ -87,6 +122,66 @@ SPI_DMA_RX_CHANNEL_DEFINE(2, 5, 2);
SPI_DMA_RX_CHANNEL_DEFINE(2, 6, 2);
SPI_DMA_RX_CHANNEL_DEFINE(2, 7, 2);

SPI_DMA_RX_CHANNEL_DEFINE(1, 1, 3);
SPI_DMA_RX_CHANNEL_DEFINE(1, 2, 3);
SPI_DMA_RX_CHANNEL_DEFINE(1, 3, 3);
SPI_DMA_RX_CHANNEL_DEFINE(1, 4, 3);
SPI_DMA_RX_CHANNEL_DEFINE(1, 5, 3);
SPI_DMA_RX_CHANNEL_DEFINE(1, 6, 3);
SPI_DMA_RX_CHANNEL_DEFINE(1, 7, 3);
SPI_DMA_RX_CHANNEL_DEFINE(2, 1, 3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
SPI_DMA_RX_CHANNEL_DEFINE(2, 5, 5);
SPI_DMA_RX_CHANNEL_DEFINE(2, 6, 5);
SPI_DMA_RX_CHANNEL_DEFINE(2, 7, 5);

SPI_BDMA_RX_CHANNEL_DEFINE(1, 1, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(1, 2, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(1, 3, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(1, 4, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(1, 5, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(1, 6, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(1, 7, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 1, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 2, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 3, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 4, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 5, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 6, 6);
SPI_BDMA_RX_CHANNEL_DEFINE(2, 7, 6);

SPI_DMA_TX_CHANNEL_DEFINE(1, 1, 1);
SPI_DMA_TX_CHANNEL_DEFINE(1, 2, 1);
SPI_DMA_TX_CHANNEL_DEFINE(1, 3, 1);
Expand Down Expand Up @@ -116,3 +211,63 @@ SPI_DMA_TX_CHANNEL_DEFINE(2, 4, 2);
SPI_DMA_TX_CHANNEL_DEFINE(2, 5, 2);
SPI_DMA_TX_CHANNEL_DEFINE(2, 6, 2);
SPI_DMA_TX_CHANNEL_DEFINE(2, 7, 2);

SPI_DMA_TX_CHANNEL_DEFINE(1, 1, 3);
SPI_DMA_TX_CHANNEL_DEFINE(1, 2, 3);
SPI_DMA_TX_CHANNEL_DEFINE(1, 3, 3);
SPI_DMA_TX_CHANNEL_DEFINE(1, 4, 3);
SPI_DMA_TX_CHANNEL_DEFINE(1, 5, 3);
SPI_DMA_TX_CHANNEL_DEFINE(1,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2, 5);
SPI_DMA_TX_CHANNEL_DEFINE(2, 3, 5);
SPI_DMA_TX_CHANNEL_DEFINE(2, 4, 5);
SPI_DMA_TX_CHANNEL_DEFINE(2, 5, 5);
SPI_DMA_TX_CHANNEL_DEFINE(2, 6, 5);
SPI_DMA_TX_CHANNEL_DEFINE(2, 7, 5);

SPI_BDMA_TX_CHANNEL_DEFINE(1, 1, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(1, 2, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(1, 3, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(1, 4, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(1, 5, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(1, 6, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(1, 7, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 1, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 2, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 3, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 4, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 5, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 6, 6);
SPI_BDMA_TX_CHANNEL_DEFINE(2, 7, 6);
48 changes: 44 additions & 4 deletions hw/bus/drivers/spi_stm32/stm32h7xx/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,60 @@ syscfg.defs:
SPI1_RX_DMA:
description: >
DMA channel to use for SPI1. DMA number can be 1 or 2.
channel can be 1-7.
stream can be 1-7.
value: DMA1_stream1_spi1_rx
SPI1_TX_DMA:
description: >
DMA channel to use for SPI1. DMA number can be 1 or 2.
channel can be 1-7.
stream can be 1-7.
value: DMA1_stream2_spi1_tx
SPI2_RX_DMA:
description: >
DMA channel to use for SPI2. DMA number can be 1 or 2.
channel can be 1-7.
stream can be 1-7.
value: DMA1_stream3_spi2_rx
SPI2_TX_DMA:
description: >
DMA channel to use for SPI2. DMA number can be 1 or 2.
channel can be 1-7.
stream can be 1-7.
value: DMA1_stream4_spi2_tx
SPI3_RX_DMA:
description: >
DMA channel to use for SPI3. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream1_spi3_rx
SPI3_TX_DMA:
description: >
DMA channel to use for SPI3. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream2_spi3_tx
SPI4_RX_DMA:
description: >
DMA channel to use for SPI4. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream3_spi4_rx
SPI4_TX_DMA:
description: >
DMA channel to use for SPI4. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream4_spi4_tx
SPI5_RX_DMA:
description: >
DMA channel to use for SPI5. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream1_spi5_rx
SPI5_TX_DMA:
description: >
DMA channel to use for SPI5. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream2_spi5_tx
SPI6_RX_DMA:
description: >
DMA channel to use for SPI6. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream3_spi6_rx
SPI6_TX_DMA:
description: >
DMA channel to use for SPI6. DMA number can be 1 or 2.
stream can be 1-7.
value: DMA1_stream4_spi6_tx

0 comments on commit 8f94220

Please sign in to comment.