diff --git a/drivers/spi/spi_esp32_spim.c b/drivers/spi/spi_esp32_spim.c index 21c29b0847..2bcab3347e 100644 --- a/drivers/spi/spi_esp32_spim.c +++ b/drivers/spi/spi_esp32_spim.c @@ -19,9 +19,11 @@ LOG_MODULE_REGISTER(esp32_spi, CONFIG_SPI_LOG_LEVEL); #ifndef CONFIG_SOC_ESP32C3 #include #else +#include +#endif +#ifdef SOC_GDMA_SUPPORTED #include #include -#include #endif #include #include "spi_context.h" @@ -163,17 +165,17 @@ static int spi_esp32_init_dma(const struct device *dev) return -EIO; } -#ifdef CONFIG_SOC_ESP32C3 - gdma_hal_init(&data->hal_gdma, 0); +#ifdef SOC_GDMA_SUPPORTED + gdma_hal_init(&data->hal_gdma, cfg->dma_host); gdma_ll_enable_clock(data->hal_gdma.dev, true); gdma_ll_tx_reset_channel(data->hal_gdma.dev, cfg->dma_host); gdma_ll_rx_reset_channel(data->hal_gdma.dev, cfg->dma_host); - gdma_ll_tx_connect_to_periph(data->hal_gdma.dev, cfg->dma_host, 0); - gdma_ll_rx_connect_to_periph(data->hal_gdma.dev, cfg->dma_host, 0); + gdma_ll_tx_connect_to_periph(data->hal_gdma.dev, cfg->dma_host, cfg->dma_host); + gdma_ll_rx_connect_to_periph(data->hal_gdma.dev, cfg->dma_host, cfg->dma_host); channel_offset = 0; #else channel_offset = 1; -#endif /* CONFIG_SOC_ESP32C3 */ +#endif /* SOC_GDMA_SUPPORTED */ #ifdef CONFIG_SOC_ESP32 /*Connect SPI and DMA*/ DPORT_SET_PERI_REG_BITS(DPORT_SPI_DMA_CHAN_SEL_REG, 3, cfg->dma_host + 1, diff --git a/drivers/spi/spi_esp32_spim.h b/drivers/spi/spi_esp32_spim.h index f6242c9e71..ecaf6397bb 100644 --- a/drivers/spi/spi_esp32_spim.h +++ b/drivers/spi/spi_esp32_spim.h @@ -9,7 +9,7 @@ #include #include -#ifdef CONFIG_SOC_ESP32C3 +#ifdef SOC_GDMA_SUPPORTED #include #endif @@ -42,7 +42,7 @@ struct spi_esp32_data { struct spi_context ctx; spi_hal_context_t hal; spi_hal_config_t hal_config; -#ifdef CONFIG_SOC_ESP32C3 +#ifdef SOC_GDMA_SUPPORTED gdma_hal_context_t hal_gdma; #endif spi_hal_timing_conf_t timing_config; diff --git a/dts/riscv/espressif/esp32c3.dtsi b/dts/riscv/espressif/esp32c3.dtsi index ac0ef9e028..8e3afbde68 100644 --- a/dts/riscv/espressif/esp32c3.dtsi +++ b/dts/riscv/espressif/esp32c3.dtsi @@ -206,7 +206,7 @@ interrupt-parent = <&intc>; clocks = <&rtc ESP32_SPI2_MODULE>; dma-clk = ; - dma-host = <1>; + dma-host = <0>; status = "disabled"; };