drivers: spi: esp32: add esp32c3 support
to the esp32 spi unified driver Signed-off-by: Felipe Neves <felipe.neves@espressif.com>
This commit is contained in:
parent
c03519fffc
commit
0a0fed7879
|
@ -41,6 +41,16 @@
|
|||
status = "okay";
|
||||
};
|
||||
|
||||
&spi2 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
status = "okay";
|
||||
miso-pin = <2>;
|
||||
mosi-pin = <7>;
|
||||
sclk-pin = <6>;
|
||||
csel-pin = <10>;
|
||||
};
|
||||
|
||||
&gpio0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
menuconfig ESP32_SPIM
|
||||
bool "ESP32 SPI Master driver"
|
||||
depends on SOC_ESP32 || SOC_ESP32S2
|
||||
depends on SOC_ESP32 || SOC_ESP32S2 || SOC_ESP32C3
|
||||
default y
|
||||
help
|
||||
Enables support for ESP32 SPI Master driver.
|
||||
|
|
|
@ -15,7 +15,11 @@ LOG_MODULE_REGISTER(esp32_spi, CONFIG_SPI_LOG_LEVEL);
|
|||
|
||||
#include <soc.h>
|
||||
#include <drivers/spi.h>
|
||||
#ifndef CONFIG_SOC_ESP32C3
|
||||
#include <drivers/interrupt_controller/intc_esp32.h>
|
||||
#else
|
||||
#include <drivers/interrupt_controller/intc_esp32c3.h>
|
||||
#endif
|
||||
#include <drivers/gpio/gpio_esp32.h>
|
||||
#include <drivers/clock_control.h>
|
||||
#include "spi_context.h"
|
||||
|
@ -40,6 +44,17 @@ LOG_MODULE_REGISTER(esp32_spi, CONFIG_SPI_LOG_LEVEL);
|
|||
#define SCLK_IDX_3 SPI3_CLK_OUT_MUX_IDX
|
||||
#define CSEL_IDX_2 FSPICS0_OUT_IDX
|
||||
#define CSEL_IDX_3 SPI3_CS0_OUT_IDX
|
||||
#elif defined(CONFIG_SOC_ESP32C3)
|
||||
#define MISO_IDX_2 FSPIQ_IN_IDX
|
||||
#define MOSI_IDX_2 FSPID_OUT_IDX
|
||||
#define SCLK_IDX_2 FSPICLK_OUT_IDX
|
||||
#define CSEL_IDX_2 FSPICS0_OUT_IDX
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SOC_ESP32C3
|
||||
#define ISR_HANDLER isr_handler_t
|
||||
#else
|
||||
#define ISR_HANDLER intr_handler_t
|
||||
#endif
|
||||
|
||||
static bool spi_esp32_transfer_ongoing(struct spi_esp32_data *data)
|
||||
|
@ -124,7 +139,11 @@ static int spi_esp32_init(const struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_SPI_ESP32_INTERRUPT
|
||||
data->irq_line = esp_intr_alloc(cfg->irq_source, 0, spi_esp32_isr, (void *)dev, NULL);
|
||||
data->irq_line = esp_intr_alloc(cfg->irq_source,
|
||||
0,
|
||||
(ISR_HANDLER)spi_esp32_isr,
|
||||
(void *)dev,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
spi_context_unlock_unconditionally(&data->ctx);
|
||||
|
|
|
@ -129,6 +129,17 @@
|
|||
label = "TRNG_0";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
spi2: spi@60024000 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
reg = <0x60024000 DT_SIZE_K(4)>;
|
||||
interrupts = <SPI2_INTR_SOURCE>;
|
||||
interrupt-parent = <&intc>;
|
||||
label = "SPI_2";
|
||||
clocks = <&rtc ESP32_SPI2_MODULE>;
|
||||
status = "disabled";
|
||||
use-iomux;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
CONFIG_SPI_LOOPBACK_DRV_NAME="SPI_2"
|
||||
CONFIG_SPI_ESP32_INTERRUPT=y
|
Loading…
Reference in a new issue