-
Notifications
You must be signed in to change notification settings - Fork 7k
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
i2s support for esp32 and esp32s2 #83710
base: main
Are you sure you want to change the base?
Conversation
af5e945
to
60d7026
Compare
4431669
to
045619f
Compare
045619f
to
652e2aa
Compare
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
|
||
#include <zephyr/logging/log.h> | ||
#include <zephyr/irq.h> | ||
|
||
#include <esp_clk_tree.h> | ||
#include <hal/i2s_hal.h> | ||
|
||
#if !SOC_GDMA_SUPPORTED | ||
#include <soc/lldesc.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to line 20 to use a single #if !SOC_GDMA_SUPPORTED
?
drivers/i2s/i2s_esp32.c
Outdated
#if !SOC_GDMA_SUPPORTED | ||
#include <soc/lldesc.h> | ||
#endif /* !SOC_GDMA_SUPPORTED */ | ||
|
||
LOG_MODULE_REGISTER(i2s_esp32, CONFIG_I2S_LOG_LEVEL); | ||
|
||
#if !SOC_GDMA_SUPPORTED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this #ifdef is not necessary, just leave the definition in there.
drivers/i2s/i2s_esp32.c
Outdated
@@ -12,18 +12,28 @@ | |||
#include <soc.h> | |||
#include <zephyr/drivers/clock_control.h> | |||
#include <zephyr/drivers/pinctrl.h> | |||
#include <zephyr/devicetree.h> | |||
|
|||
#if !SOC_GDMA_SUPPORTED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is SOC_GDMA_SUPPORTED
is set per SoC but dma
is not enabled, i.e, app is using descriptors instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not implement dma transfers using descriptor on SoCs that support GDMA. It is only made for those SoCs that do not support GDMA. Since a dma
instance is required to perform i2s transfers on SoCs that support GDMA, the build process will fail. I will provide an preprocessor error conditional on SOC_GDMA_SUPPORTED
and !DT_HAS_COMPAT_STATUS_OKAY(espressif_esp32_gdma)
for the cases where dma has been disable:
#if SOC_GDMA_SUPPORTED && !DT_HAS_COMPAT_STATUS_OKAY(espressif_esp32_gdma)
#error "DMA peripheral is not enabled!"
#endif /* SOC_GDMA_SUPPORTED */
Even so I bilieve the failure will continue to occur despite the error message being issued
@@ -310,8 +310,6 @@ | |||
#address-cells = <1>; | |||
#size-cells = <0>; | |||
reg = <0x6000f000 0x1000>; | |||
interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this removed from ESP32S3 and C3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I thought it was necessary, but now I see it's a mistake.
I'll revert it
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright (c) 2019 Intel Corporation. | |||
* Copyright (c) 2019-2025 Intel Corporation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of extending the copyright of the original creator, append a new line adding Espressif's. Do the same for all files that copyright was changed.
@@ -17,18 +17,6 @@ properties: | |||
clocks: | |||
required: true | |||
|
|||
interrupts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interrupts really need to go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interrupts
along with interrupt-names
was the way I found to inform to the driver during build time which i2s channels are enabled so those resources that are not being used due to a not used i2s channel can be not allocated or removed by optimization process. The same stuff is achieved by using dmas
along with dma-names
for the GDMA SoCs .
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for the other files.
i2s_rxtx: &i2s0 { | ||
status = "okay"; | ||
|
||
interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interrupts are already defined in .dtsi. Is it needed again here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for the other files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interrupts along with interrupt-names was the way I found to inform to the driver during build time which i2s channels are enabled so those resources that are not being used due to a not used i2s channel can be not allocated or removed by optimization process.
samples/drivers/i2s/echo/Kconfig
Outdated
@@ -17,3 +17,6 @@ config STOP_START_STREAMS_SW1 | |||
depends on $(dt_alias_enabled,sw1) | |||
select GPIO | |||
default y | |||
|
|||
config DOESNT_SUPPORT_I2S_DIR_BOTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest I2S_DIR_BOTH_NOT_SUPPORTED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure we can't have I2S_DIR_BOTH implemented in the I2S driver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rework the i2s_esp32_trigger()
and the ì2s_esp32_configure()
functions to accept I2S_DIR_BOTH
and revert the changes made on echo
sample
d27f92c
to
33d75c2
Compare
33d75c2
to
e11d6dc
Compare
8bcbe65
to
17e904c
Compare
<I2S0_O_SD_GPIO7>, | ||
<I2S0_I_WS_GPIO15>, | ||
<I2S0_I_BCK_GPIO16>; | ||
output-enable; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
const struct i2s_esp32_stream *stream; | ||
int err; | ||
|
||
switch (dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use a fallthrough between RX/TX (and the appropriate checks for break
instructions), it's possible to avoid repeated code (suggestion only), for I2S_DIR_BOTH
#address-cells = <1>; | ||
#size-cells = <0>; | ||
reg = <0x3ff4f000 0x1000>; | ||
interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to declare the same source twice (could it be avoided)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was the way I found to save resources (throughout interrup-names and dma-names)
as the interrupt source is the same for TX and RX I had to declare the same source for each channel.
Code and data refactoring to prepare for adding support for non-gdma SoCs Signed-off-by: Marcio Ribeiro <[email protected]>
hal_espressif revision update to add i2s support for esp32 and esp32s2 Signed-off-by: Marcio Ribeiro <[email protected]>
Adds support for: - esp32 - esp32s2 Signed-off-by: Marcio Ribeiro <[email protected]>
17e904c
to
73f2fd1
Compare
Adds i2s support for boards based on: - esp32 - esp32s2 Signed-off-by: Marcio Ribeiro <[email protected]>
Adds esp32 board overlay files to i2s samples Signed-off-by: Marcio Ribeiro <[email protected]>
73f2fd1
to
97c1a72
Compare
This PR adds i2s support to those SoCs lacking GDMA: