Skip to content

Commit 181082e

Browse files
arthur-mmlwkartben
authored andcommitted
drivers: i2s: i2s_ll_stm32: add support for IO swap
This commit adds a new property in the device-tree bindings for swapping the serial data input and output pins of the SPI/I2S peripheral for STM32 microcontrollers that support it. Signed-off-by: Arthur Gay <[email protected]>
1 parent efe5a30 commit 181082e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

drivers/i2s/i2s_ll_stm32.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,12 @@ static int i2s_stm32_initialize(const struct device *dev)
730730
return -EIO;
731731
}
732732

733+
#if defined(SPI_CFG2_IOSWP)
734+
if (cfg->ioswp) {
735+
LL_SPI_EnableIOSwap(cfg->i2s);
736+
}
737+
#endif
738+
733739
/* Configure dt provided device signals when available */
734740
ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
735741
if (ret < 0) {
@@ -970,7 +976,8 @@ static const struct i2s_stm32_cfg i2s_stm32_config_##index = { \
970976
.pclk_len = DT_INST_NUM_CLOCKS(index), \
971977
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
972978
.irq_config = i2s_stm32_irq_config_func_##index, \
973-
.master_clk_sel = DT_INST_PROP(index, mck_enabled) \
979+
.master_clk_sel = DT_INST_PROP(index, mck_enabled), \
980+
.ioswp = DT_INST_PROP(index, ioswp), \
974981
}; \
975982
\
976983
K_MSGQ_DEFINE(rx_##index##_queue, sizeof(struct queue_item), CONFIG_I2S_STM32_RX_BLOCK_COUNT, 4);\

drivers/i2s/i2s_ll_stm32.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ struct i2s_stm32_cfg {
1919
size_t pclk_len;
2020
const struct pinctrl_dev_config *pcfg;
2121
void (*irq_config)(const struct device *dev);
22-
bool master_clk_sel;
22+
bool master_clk_sel: 1;
23+
bool ioswp: 1;
2324
};
2425

2526
struct stream {

dts/bindings/i2s/st,stm32-i2s-common.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ properties:
2929
description: |
3030
Master Clock Output function.
3131
An mck pin must be listed within pinctrl-0 when enabling this property.
32+
33+
ioswp:
34+
type: boolean
35+
description: Swap I2S data input and output pins

0 commit comments

Comments
 (0)