Skip to content

i.MX RT685's HiFi 4 DSP support #77814

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

VitekST
Copy link
Contributor

@VitekST VitekST commented Aug 30, 2024

This PR introduces support for the Xtensa LX6 augmented with the HiFi 4 DSP extension on the i.MX RT685, this time compatible with HWMv2.

It instantiates drivers for basic peripherals (GPIO, Flexcomm UART), as well as peripherals responsible for audio (Flexcomm I2S, DMA). Audio playback and capture is enabled and functional. Hardware initialisation, code loading and run control from the CM33 side is also implemented and the support is backed by a set of samples.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Aug 30, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_nxp zephyrproject-rtos/hal_nxp@6b11d19 (master) zephyrproject-rtos/hal_nxp#432 zephyrproject-rtos/hal_nxp#432/files

DNM label due to: 1 project with PR revision

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_nxp DNM This PR should not be merged (Do Not Merge) labels Aug 30, 2024
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from 938d2f1 to 756aeb0 Compare August 30, 2024 14:52
@dbaluta
Copy link
Collaborator

dbaluta commented Sep 16, 2024

@VitekST excellent work. Since this PR is still in draft and depending on other PR I think we can create separate PR for unrelated code here:

So, we can move in seperate PRs following patches:

  1. dma_mcux_lpc: add host directions, DMA driver ctx, getter func
  2. drivers: wm8904: Fix audio input configuration
  3. Maybe some more which I cannot figure out right now.

A PR with more than 7-8 patches will be very hard to review and get traction from community. Lets put the patches PR by PR :) starting from simple ones.

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Nov 16, 2024
@github-actions github-actions bot closed this Nov 30, 2024
@dleach02 dleach02 reopened this Dec 9, 2024
@dleach02 dleach02 removed the Stale label Dec 9, 2024
@fabiobaltieri fabiobaltieri added DNM (manifest) This PR should not be merged (controlled by action-manifest) and removed DNM This PR should not be merged (Do Not Merge) labels Feb 4, 2025
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from 756aeb0 to 306164a Compare February 5, 2025 15:33
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch 3 times, most recently from 68ea788 to 2c5d96a Compare February 13, 2025 14:29
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from 2c5d96a to 15f5282 Compare February 20, 2025 12:34
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from 15f5282 to a3341f5 Compare February 27, 2025 15:53
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from a3341f5 to 08f8dcf Compare March 6, 2025 16:22
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch 4 times, most recently from 1486ba2 to 4e95e01 Compare March 27, 2025 14:01
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch 2 times, most recently from 0f35bd2 to e59e036 Compare March 27, 2025 16:45
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch 4 times, most recently from 10bcefa to 1ee18b0 Compare April 10, 2025 16:42
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from 1ee18b0 to 7137f5b Compare April 10, 2025 17:16
@VitekST VitekST requested a review from iuliana-prodan April 11, 2025 12:35
@dleach02
Copy link
Member

@VitekST What is the plan on this PR?

@VitekST
Copy link
Contributor Author

VitekST commented Apr 22, 2025

@dleach02 The plan is to rebase, resolve conflicts, resolve any points of discussion and wait for it to be merged. The matter of supporting the DSP core is still current on my side. It was actually about 2 weeks ago when I finally caught up and internally asked you and your guys for input.

@maxekman
Copy link

I would also like to see this merged, it is highly relevant and the HiFi core is used in other products too.

VitekST added 15 commits April 24, 2025 08:23
Add drivers/interrupt_controller/intc_nxp_pint/power.h abstracting
EnableDeepSleepIRQ and DisableDeepSleepIRQ invocations from
intc_nxp_pint.c. Modify intc_nxp_pint.c to use that file.

fsl_power.c and fsl_power.h can't be built on the
mimxrt685/mimxrt685s/hifi4 target, so it's excluded from it in hal_nxp.

Signed-off-by: Vit Stanicek <[email protected]>
Support for the i.MX RT685's HiFi 4 DSP domain required changes in the
hal_nxp repo, thus point it to to the HEAD of PR bearing the required
changes.

Temporary.

Signed-off-by: Vit Stanicek <[email protected]>
Exclude fsl_power.c from DSP domains, as it doesn't compile on those
because of missing register definitions. Include fsl_dsp.c wherever it
can be included, as it's required for initialisation of DSP domains.

Signed-off-by: Vit Stanicek <[email protected]>
Add SoC definitions and a linker file for the HiFi 4 DSP on the NXP i.MX
RT685 microcontroller.

Also modify the West manifest - support depends on a different branch of
the Zephyr NXP HAL, which includes some files that were missing when
compiling for the DSP and omits some files that can't compile for the
DSP.

Signed-off-by: Vit Stanicek <[email protected]>
Add a basic device tree for the HiFi 4 DSP on the NXP i.MX RT685
microcontroller.

While no peripherals are instantiated, Zephyr is able to technically run
on this target.

Signed-off-by: Vit Stanicek <[email protected]>
Add board definitions for the HiFi 4 DSP located on the MIMXRT685-EVK.
Also add a basic board-level DT to get Zephyr to technically run.

Signed-off-by: Vit Stanicek <[email protected]>
Add init code - responsible for clock attachment of peripherals
responsible for audio playback (DMA, Flexcomms in I2S mode, ...) and for
INPUTMUX settings (IRQ line routing).

Signed-off-by: Vit Stanicek <[email protected]>
Modify HiFi 4 domain's DT to instantiate GPIO peripherals and the 0th
Flexcomm peripheral in UART mode. Also instantiate associated
peripherals - Pinctrl, Clkctl, PINT.

Signed-off-by: Vit Stanicek <[email protected]>
Add the nxp,rtxxx-adsp-ctrl driver. Responsibility of this driver is to
load code executed by Xtensa-family cores on NXP i.MX RTxxx
microcontrollers and to control their run.

Signed-off-by: Vit Stanicek <[email protected]>
Instantiate the nxp,rtxxx-adsp-ctrl driver to enable DSP code upload and
run control.

Signed-off-by: Vit Stanicek <[email protected]>
Instantiate the MU driver (mbox_nxp_imx_mu.c) for both the CM33 domain
and the HiFi4 domain of the NXP i.MX RT685. Add neccessary definitions
for instantiated boards.

Signed-off-by: Vit Stanicek <[email protected]>
Instantiate Flexcomm #1, Flexcomm #3, DMA #1 and I3C - these are
peripherals responsible for audio playback and capture on the i.MX
RT685's HiFi 4 domain.

Signed-off-by: Vit Stanicek <[email protected]>
Add initialisation code for the HiFi 4 DSP domain of the mimxrt685_evk
board. Responsible for setting up signal sharing between Flexcomm #1 and
Flexcomm #3 peripherals both in the I2S mode (simultaneous audio
playback and capture).

Signed-off-by: Vit Stanicek <[email protected]>
Instantiate, configure and enable Flexcomm #1, Flexcomm #3, DMA, I3C for
audio capture and playback on mimxrt685_evk's HiFi 4 DSP domain. Add
pinmux definitions for those.

Signed-off-by: Vit Stanicek <[email protected]>
Add common structure for RTxxx AMP samples. Add amp_blink, amp_mbox,
amp_audio_output and amp_audio_loopback samples.

These samples are now configured only for the mimxrt685_evk, but are
intended to support other NXP microcontrollers with HiFi x DSP cores
at a later date.

Signed-off-by: Vit Stanicek <[email protected]>
@VitekST VitekST force-pushed the feature/rt685-hifi4-support branch from 7137f5b to 8a603a7 Compare April 24, 2025 06:51
@VitekST
Copy link
Contributor Author

VitekST commented Apr 24, 2025

@dleach02 @mmahadevan108 Rebased, PR checks and tests do pass and based on my manual testing, the support seems to work. Now I am waiting for your inputs and for those of everyone else involved.

@dleach02
Copy link
Member

okay. we will sequence merging of the HAL component

default 198000000

config MCUX_CORE_SUFFIX
default "_dsp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should use everywhere hifi4

Copy link
Contributor Author

@VitekST VitekST Apr 28, 2025

Choose a reason for hiding this comment

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

@iuliana-prodan I agree, however, this name is tied to the MCUX SDK, from which the NXP's HAL is derived. Renaming the core suffix to something more appropriate, like hifi4, would imply conflicts while syncing the HAL with the release MCUX SDK, necessitating the act of renaming a good number of directories, files and in-code references to that in the SDK.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, fair enough - I remember we have some restriction here.
But in other places, where we don't have a dependency on hal you can use hifi4 - like here or other places like this.

#include <zephyr/device.h>
#include <zephyr/dt-bindings/misc/nxp_rtxxx_adsp_ctrl.h>

#ifndef __NXP_RTXXX_ADSP_CTRL_H__
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, in this file (also the naming) can it be applied for other DSPs (from other i.MXRTs) or is just for rt600?
If it applies to other you should name it DSP, not ADSP (not just for audio).

As a summary, where possible name it hifi4, if applies to multiple i.MXRTs put dsp. :)

PS: Please split this in multiple PRs, is very hard to review all these together.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iuliana-prodan Yes, I intend to support other 3-digit RT devices.
As was communicated internally, I intend to split the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants