Skip to content

Add i2s support for esp32 and esp32s2 #83710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2022-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -74,5 +74,35 @@
output-high;
};
};

i2s0_default: i2s0_default {
group1 {
pinmux = <I2S0_O_WS_GPIO5>,
<I2S0_O_BCK_GPIO6>,
<I2S0_O_SD_GPIO7>,
<I2S0_I_WS_GPIO15>,
<I2S0_I_BCK_GPIO16>;
output-enable;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these the right flags? (usually used for loopback)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are correct

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the input pins be placed in group2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact no. In this configuration they are output pins connected to the input/rx path. In other configuration they could be driven by output sources, but in this conf they will provide output signals.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find it odd the use of the flag, but it shouldn't harm as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#define I2S0_I_BCK_GPIO16 ESP32_PINMUX(16, ESP_I2S0I_BCK_IN, ESP_I2S0I_BCK_OUT)
#define I2S0_I_WS_GPIO15 ESP32_PINMUX(15, ESP_I2S0I_WS_IN, ESP_I2S0I_WS_OUT)

I think that, since the macros I2S0_I_WS_GPIO15 and I2S0_I_BCK_GPIO16 can be use as both input and output, the direction flag is necessary.

};
group2 {
pinmux = <I2S0_I_SD_GPIO17>;
input-enable;
};
};

i2s1_default: i2s1_default {
group1 {
pinmux = <I2S1_O_WS_GPIO8>,
<I2S1_O_BCK_GPIO3>,
<I2S1_O_SD_GPIO9>,
<I2S1_I_WS_GPIO10>,
<I2S1_I_BCK_GPIO11>;
output-enable;
};
group2 {
pinmux = <I2S1_I_SD_GPIO12>;
input-enable;
};
};
};

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2023-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -89,6 +89,18 @@
pinctrl-names = "default";
};

&i2s0 {
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
status = "disabled";
};

&i2s1 {
pinctrl-0 = <&i2s1_default>;
pinctrl-names = "default";
status = "disabled";
};

&spi2 {
#address-cells = <1>;
#size-cells = <0>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ supported:
- dac
- gpio
- i2c
- i2s
- watchdog
- uart
- nvs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2022-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -74,4 +74,34 @@
output-high;
};
};

i2s0_default: i2s0_default {
group1 {
pinmux = <I2S0_O_WS_GPIO5>,
<I2S0_O_BCK_GPIO6>,
<I2S0_O_SD_GPIO7>,
<I2S0_I_WS_GPIO15>,
<I2S0_I_BCK_GPIO16>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO17>;
input-enable;
};
};

i2s1_default: i2s1_default {
group1 {
pinmux = <I2S1_O_WS_GPIO8>,
<I2S1_O_BCK_GPIO3>,
<I2S1_O_SD_GPIO9>,
<I2S1_I_WS_GPIO10>,
<I2S1_I_BCK_GPIO11>;
output-enable;
};
group2 {
pinmux = <I2S1_I_SD_GPIO12>;
input-enable;
};
};
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2023-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -89,6 +89,18 @@
pinctrl-names = "default";
};

&i2s0 {
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
status = "disabled";
};

&i2s1 {
pinctrl-0 = <&i2s1_default>;
pinctrl-names = "default";
status = "disabled";
};

&spi2 {
#address-cells = <1>;
#size-cells = <0>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ supported:
- dac
- gpio
- i2c
- i2s
- watchdog
- uart
- nvs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Grant Ramsay <[email protected]>
* Copyright (c) 2022-2025 Grant Ramsay <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -40,4 +40,33 @@
};
};

i2s0_default: i2s0_default {
group1 {
pinmux = <I2S0_O_WS_GPIO5>,
<I2S0_O_BCK_GPIO6>,
<I2S0_O_SD_GPIO7>,
<I2S0_I_WS_GPIO15>,
<I2S0_I_BCK_GPIO16>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO17>;
input-enable;
};
};

i2s1_default: i2s1_default {
group1 {
pinmux = <I2S1_O_WS_GPIO8>,
<I2S1_O_BCK_GPIO3>,
<I2S1_O_SD_GPIO9>,
<I2S1_I_WS_GPIO10>,
<I2S1_I_BCK_GPIO11>;
output-enable;
};
group2 {
pinmux = <I2S1_I_SD_GPIO12>;
input-enable;
};
};
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Grant Ramsay <[email protected]>
* Copyright (c) 2022-2025 Grant Ramsay <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -43,6 +43,18 @@
status = "okay";
};

&i2s0 {
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
status = "disabled";
};

&i2s1 {
pinctrl-0 = <&i2s1_default>;
pinctrl-names = "default";
status = "disabled";
};

&spi2 {
#address-cells = <1>;
#size-cells = <0>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ supported:
- uart
- nvs
- pwm
- i2s
vendor: espressif
17 changes: 16 additions & 1 deletion boards/espressif/esp32s2_devkitc/esp32s2_devkitc-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -65,4 +65,19 @@
};
};

i2s0_default: i2s0_default {
group1 {
pinmux = <I2S0_MCLK_GPIO4>,
<I2S0_O_WS_GPIO5>,
<I2S0_O_BCK_GPIO6>,
<I2S0_O_SD_GPIO7>,
<I2S0_I_WS_GPIO15>,
<I2S0_I_BCK_GPIO16>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO17>;
input-enable;
};
};
};
8 changes: 7 additions & 1 deletion boards/espressif/esp32s2_devkitc/esp32s2_devkitc.dts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -96,6 +96,12 @@
pinctrl-names = "default";
};

&i2s0 {
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
status = "disabled";
};

&trng0 {
status = "okay";
};
Expand Down
1 change: 1 addition & 0 deletions boards/espressif/esp32s2_devkitc/esp32s2_devkitc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ supported:
- dac
- gpio
- i2c
- i2s
- watchdog
- uart
- nvs
Expand Down
17 changes: 16 additions & 1 deletion boards/espressif/esp32s2_saola/esp32s2_saola-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2022-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -65,4 +65,19 @@
};
};

i2s0_default: i2s0_default {
group1 {
pinmux = <I2S0_MCLK_GPIO4>,
<I2S0_O_WS_GPIO5>,
<I2S0_O_BCK_GPIO6>,
<I2S0_O_SD_GPIO7>,
<I2S0_I_WS_GPIO15>,
<I2S0_I_BCK_GPIO16>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO17>;
input-enable;
};
};
};
8 changes: 7 additions & 1 deletion boards/espressif/esp32s2_saola/esp32s2_saola.dts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2021-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -96,6 +96,12 @@
pinctrl-names = "default";
};

&i2s0 {
pinctrl-0 = <&i2s0_default>;
pinctrl-names = "default";
status = "disabled";
};

&trng0 {
status = "okay";
};
Expand Down
1 change: 1 addition & 0 deletions boards/espressif/esp32s2_saola/esp32s2_saola.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ supported:
- dac
- gpio
- i2c
- i2s
- watchdog
- uart
- nvs
Expand Down
10 changes: 8 additions & 2 deletions drivers/i2s/Kconfig.esp32
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ config I2S_ESP32
bool "ESP32 I2S driver"
default y
depends on DT_HAS_ESPRESSIF_ESP32_I2S_ENABLED
depends on DT_HAS_ESPRESSIF_ESP32_GDMA_ENABLED
select DMA
select DMA if DT_HAS_ESPRESSIF_ESP32_GDMA_ENABLED
help
Enables the ESP32 I2S driver (GDMA SoCs only).

Expand All @@ -25,4 +24,11 @@ config I2S_ESP32_TX_BLOCK_COUNT
help
Max number of blocks waiting to be transmitted by the I2S TX channel.

config I2S_ESP32_DMA_DESC_NUM_MAX
int "ESP32 I2S number of link descriptors"
default 10
depends on !DT_HAS_ESPRESSIF_ESP32_GDMA_ENABLED
help
Max number of link descriptor available for DMA transfers on each I2S channel

endif
Loading