diff options
author | Nicolas Norvez <norvez@chromium.org> | 2019-03-28 16:35:34 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-09 06:19:47 -0700 |
commit | f923afcc99e6ec0ae15d2adeada09ee4571b8a96 (patch) | |
tree | 469ff6599ca012b37b05e32088245f6d06040f4e /chip/stm32/spi.c | |
parent | 6bd030ecd978a8b619da261510490f27f68c4e6c (diff) | |
download | chrome-ec-f923afcc99e6ec0ae15d2adeada09ee4571b8a96.tar.gz |
stm32: spi: Support SPI slave w/ DMA for STM32F4
On STM32F4 we need to set the "request channel" for the SPI RX and TX
DMAs. Add the "request channel" to the dma_option of the SPI RX and TX
when the MCU is operating in SPI slave mode.
BRANCH=None
BUG=b:124996507
TEST=make BOARD=hatch_fp -j
TEST=flash Hatch FPMCU, "ectool --name=cros_fp version" works
Change-Id: I791e39306b088ea28f950d6d5bff11c29828d294
Signed-off-by: Nicolas Norvez <norvez@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1545072
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'chip/stm32/spi.c')
-rw-r--r-- | chip/stm32/spi.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c index 7873fe7772..057827cc7a 100644 --- a/chip/stm32/spi.c +++ b/chip/stm32/spi.c @@ -41,11 +41,17 @@ static const struct dma_option dma_tx_option = { STM32_DMAC_SPI1_TX, (void *)&SPI_TXDR, STM32_DMA_CCR_MSIZE_8_BIT | STM32_DMA_CCR_PSIZE_8_BIT +#ifdef CHIP_FAMILY_STM32F4 + | STM32_DMA_CCR_CHANNEL(STM32_SPI1_TX_REQ_CH) +#endif }; static const struct dma_option dma_rx_option = { STM32_DMAC_SPI1_RX, (void *)&SPI_RXDR, STM32_DMA_CCR_MSIZE_8_BIT | STM32_DMA_CCR_PSIZE_8_BIT +#ifdef CHIP_FAMILY_STM32F4 + | STM32_DMA_CCR_CHANNEL(STM32_SPI1_RX_REQ_CH) +#endif }; /* @@ -667,7 +673,12 @@ static void spi_init(void) /* Delay 1 APB clock cycle after the clock is enabled */ clock_wait_bus_cycles(BUS_APB, 1); - /* Select the right DMA request for the variants using it */ + /* + * Select the right DMA request for the variants using it. + * This is not required for STM32F4 since the channel (aka request) is + * set directly in the respective dma_option. In fact, it would be + * overridden in dma-stm32f4::prepare_stream(). + */ #ifdef CHIP_FAMILY_STM32L4 dma_select_channel(STM32_DMAC_SPI1_TX, 1); dma_select_channel(STM32_DMAC_SPI1_RX, 1); |