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:
Felipe Neves 2021-10-18 23:25:42 -03:00 committed by Anas Nashif
parent c03519fffc
commit 0a0fed7879
6 changed files with 45 additions and 3 deletions

View file

@ -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";
};

View file

@ -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.

View file

@ -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);

View file

@ -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;
};
};
};

View file

@ -0,0 +1,2 @@
CONFIG_SPI_LOOPBACK_DRV_NAME="SPI_2"
CONFIG_SPI_ESP32_INTERRUPT=y

View file

@ -67,7 +67,7 @@ manifest:
groups:
- hal
- name: hal_espressif
revision: 7c46a3fc5b336199392cba0f66c3c27d5fe9025c
revision: 8284e0c251a6450f9cdeff299988a647648296e3
path: modules/hal/espressif
west-commands: west/west-commands.yml
groups: