drivers: spi: esp32xx: Add chip select setup and hold time

Added device tree bindings and implementaion for setting the
spi controllers chip select setup and hold time settings.

Signed-off-by: Dean Sellers <dsellers@evos.com.au>
This commit is contained in:
Dean Sellers 2023-05-05 10:44:38 +10:00 committed by Carles Cufí
commit 308cec45b0
3 changed files with 23 additions and 0 deletions

View file

@ -338,6 +338,13 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,
hal_dev->mode |= BIT(1); hal_dev->mode |= BIT(1);
} }
/* Chip select setup and hold times */
/* GPIO CS have their own delay parameter*/
if (!spi_cs_is_gpio(spi_cfg)) {
hal_dev->cs_hold = cfg->cs_hold;
hal_dev->cs_setup = cfg->cs_setup;
}
spi_hal_setup_device(hal, hal_dev); spi_hal_setup_device(hal, hal_dev);
/* /*
@ -496,6 +503,8 @@ static const struct spi_driver_api spi_api = {
.dma_enabled = DT_INST_PROP(idx, dma_enabled), \ .dma_enabled = DT_INST_PROP(idx, dma_enabled), \
.dma_clk_src = DT_INST_PROP(idx, dma_clk), \ .dma_clk_src = DT_INST_PROP(idx, dma_clk), \
.dma_host = DT_INST_PROP(idx, dma_host), \ .dma_host = DT_INST_PROP(idx, dma_host), \
.cs_setup = DT_INST_PROP_OR(idx, cs_setup_time, 0), \
.cs_hold = DT_INST_PROP_OR(idx, cs_hold_time, 0), \
}; \ }; \
\ \
DEVICE_DT_INST_DEFINE(idx, &spi_esp32_init, \ DEVICE_DT_INST_DEFINE(idx, &spi_esp32_init, \

View file

@ -36,6 +36,8 @@ struct spi_esp32_config {
bool dma_enabled; bool dma_enabled;
int dma_clk_src; int dma_clk_src;
int dma_host; int dma_host;
int cs_setup;
int cs_hold;
}; };
struct spi_esp32_data { struct spi_esp32_data {

View file

@ -64,3 +64,15 @@ properties:
Refer to SoC's Technical Reference Manual to check which pins are Refer to SoC's Technical Reference Manual to check which pins are
allowed to use this routing path. allowed to use this routing path.
cs-setup-time:
type: int
description: |
Chip select setup time setting, see TRF for SOC for details of
timing applied.
cs-hold-time:
type: int
description: |
Chip select hold time setting, see TRF for SOC for details of
timing applied.