Skip to content

Commit 7109632

Browse files
xingrzGlauber Maroto Ferreira
authored andcommitted
drivers: spi_esp32_spim: Add support for IOMUX mode
In order to work on a clock speed higher than 20 MHz, IO MUX is required. Co-authored-by: Glauber Maroto Ferreira <[email protected]> Signed-off-by: XiNGRZ Chan <[email protected]>
1 parent ac0bf71 commit 7109632

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

drivers/spi/spi_esp32_spim.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,
199199
.clock_speed_hz = spi_cfg->frequency,
200200
.duty_cycle = cfg->duty_cycle == 0 ? 128 : cfg->duty_cycle,
201201
.input_delay_ns = cfg->input_delay_ns,
202-
.use_gpio = true
202+
.use_gpio = !cfg->use_iomux,
203203
};
204204

205205
spi_hal_cal_clock_conf(&timing_param, &freq, &hal_dev->timing_conf);
@@ -365,6 +365,7 @@ static const struct spi_driver_api spi_api = {
365365
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
366366
.clock_subsys = \
367367
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(idx, offset), \
368+
.use_iomux = DT_INST_PROP(idx, use_iomux), \
368369
}; \
369370
\
370371
DEVICE_DT_INST_DEFINE(idx, &spi_esp32_init, \

drivers/spi/spi_esp32_spim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct spi_esp32_config {
2828
int irq_source;
2929
const struct pinctrl_dev_config *pcfg;
3030
clock_control_subsys_t clock_subsys;
31+
bool use_iomux;
3132
};
3233

3334
struct spi_esp32_data {

dts/bindings/spi/espressif,esp32-spi.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,14 @@ properties:
5555
type: boolean
5656
required: false
5757
description: Make CS positive during a transaction instead of negative
58+
59+
use-iomux:
60+
type: boolean
61+
required: false
62+
description: |
63+
Some pins are allowed to bypass the GPIO Matrix and use the IO_MUX
64+
routing mechanism instead, this avoids extra routing latency and makes
65+
possible the use of operating frequencies higher than 20 MHz.
66+
67+
Refer to SoC's Technical Reference Manual to check which pins are
68+
allowed to use this routing path.

0 commit comments

Comments
 (0)