diff options
author | Eric Yilun Lin <yllin@chromium.org> | 2020-12-24 10:50:04 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-31 07:11:06 +0000 |
commit | d2736a71fb342419ed7e548affe252e93e95196c (patch) | |
tree | cbcaf711e69189ab4206f41c693ac25807178bdb | |
parent | 88fe4d62a29b4f825db7fd0c7d827b9c99e079b4 (diff) | |
download | chrome-ec-d2736a71fb342419ed7e548affe252e93e95196c.tar.gz |
stm32/spi: disable DMA TX if it's not needed.
This CL disable DMA TX when SPI NSS high, which means
SPI client stops and won't receive any contents.
Also, disable DMA on receiving SPI (spi_init) because there is no
TX on SPI NSS just deasserted.
BUG=b:156027159, b:173732816
TEST=run reboot test
BRANCH=kukui
Change-Id: Ia86a8728056f651db4b481eca4717b506f84498e
Signed-off-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2600811
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | chip/stm32/spi.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c index 4a36162f40..cee65a644c 100644 --- a/chip/stm32/spi.c +++ b/chip/stm32/spi.c @@ -315,6 +315,9 @@ static void setup_for_transaction(void) /* clear this as soon as possible */ setup_transaction_later = 0; + /* Stop sending DMA response before TX, if any */ + dma_disable(STM32_DMAC_SPI1_TX); + #ifndef CHIP_FAMILY_STM32H7 /* H7 is not ready to set status here */ /* Not ready to receive yet */ tx_status(EC_SPI_NOT_READY); @@ -323,9 +326,6 @@ static void setup_for_transaction(void) /* We are no longer actively processing a transaction */ state = SPI_STATE_PREPARE_RX; - /* Stop sending response, if any */ - dma_disable(STM32_DMAC_SPI1_TX); - /* * Read dummy bytes in case there are some pending; this prevents the * receive DMA from getting that byte right when we start it. @@ -478,6 +478,12 @@ void spi_event(enum gpio_signal signal) enable_sleep(SLEEP_MASK_SPI); /* + * NSS is high (CS is deasserted), which means we can't + * do TX, disable DMA TX anyway. + */ + dma_get_channel(STM32_DMAC_SPI1_TX)->ccr &= ~STM32_DMA_CCR_TCIE; + + /* * If the buffer is still used by the host command, postpone * the DMA rx setup. */ @@ -671,6 +677,9 @@ static void spi_init(void) STM32_RCC_APB2RSTR |= STM32_RCC_PB2_SPI1; STM32_RCC_APB2RSTR &= ~STM32_RCC_PB2_SPI1; + /* Reset the DMA TX. */ + dma_disable(STM32_DMAC_SPI1_TX); + /* Config SPI GPIO to high speed. This varies from board to board. */ board_set_stm32_spi_pin_speed(); |