From b7a50efe7ec3b39f399298f201168d7f25571fd5 Mon Sep 17 00:00:00 2001 From: Vit Stanicek Date: Tue, 2 Jul 2024 10:05:29 +0200 Subject: [PATCH] board: mimxrt685_evk/mimxrt685s/hifi4: Add init code 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 --- boards/nxp/mimxrt685_evk/CMakeLists.txt | 1 + boards/nxp/mimxrt685_evk/hifi4/init.c | 49 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 boards/nxp/mimxrt685_evk/hifi4/init.c diff --git a/boards/nxp/mimxrt685_evk/CMakeLists.txt b/boards/nxp/mimxrt685_evk/CMakeLists.txt index 46b73d726bb3..1901cebbd069 100644 --- a/boards/nxp/mimxrt685_evk/CMakeLists.txt +++ b/boards/nxp/mimxrt685_evk/CMakeLists.txt @@ -11,6 +11,7 @@ endif() if(CONFIG_BOARD_MIMXRT685_EVK_MIMXRT685S_HIFI4) zephyr_library() +zephyr_library_sources(hifi4/init.c) endif() if(CONFIG_NXP_IMXRT_BOOT_HEADER) diff --git a/boards/nxp/mimxrt685_evk/hifi4/init.c b/boards/nxp/mimxrt685_evk/hifi4/init.c new file mode 100644 index 000000000000..ed59377d2bc4 --- /dev/null +++ b/boards/nxp/mimxrt685_evk/hifi4/init.c @@ -0,0 +1,49 @@ +/* + * Copyright 2020-2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +static int mimxrt685_evk_hifi4_init(void) +{ +/* flexcomm1 and flexcomm3 are configured to loopback the TX signal to RX */ +#if (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm1), nxp_lpc_i2s, okay)) && \ + (DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm3), nxp_lpc_i2s, okay)) && \ + CONFIG_I2S + + /* Set shared signal set 0 SCK, WS from Transmit I2S - Flexcomm3 */ + SYSCTL1->SHAREDCTRLSET[0] = SYSCTL1_SHAREDCTRLSET_SHAREDSCKSEL(3) | + SYSCTL1_SHAREDCTRLSET_SHAREDWSSEL(3); + +#ifdef CONFIG_I2S_TEST_SEPARATE_DEVICES + /* Select Data in from Transmit I2S - Flexcomm 3 */ + SYSCTL1->SHAREDCTRLSET[0] |= SYSCTL1_SHAREDCTRLSET_SHAREDDATASEL(3); + /* Enable Transmit I2S - Flexcomm 3 for Shared Data Out */ + SYSCTL1->SHAREDCTRLSET[0] |= SYSCTL1_SHAREDCTRLSET_FC3DATAOUTEN(1); +#endif + + /* Set Receive I2S - Flexcomm 1 SCK, WS from shared signal set 0 */ + SYSCTL1->FCCTRLSEL[1] = SYSCTL1_FCCTRLSEL_SCKINSEL(1) | + SYSCTL1_FCCTRLSEL_WSINSEL(1); + + /* Set Transmit I2S - Flexcomm 3 SCK, WS from shared signal set 0 */ + SYSCTL1->FCCTRLSEL[3] = SYSCTL1_FCCTRLSEL_SCKINSEL(1) | + SYSCTL1_FCCTRLSEL_WSINSEL(1); + +#ifdef CONFIG_I2S_TEST_SEPARATE_DEVICES + /* Select Receive I2S - Flexcomm 1 Data in from shared signal set 0 */ + SYSCTL1->FCCTRLSEL[1] |= SYSCTL1_FCCTRLSEL_DATAINSEL(1); + /* Select Transmit I2S - Flexcomm 3 Data out to shared signal set 0 */ + SYSCTL1->FCCTRLSEL[3] |= SYSCTL1_FCCTRLSEL_DATAOUTSEL(1); +#endif + +#endif + + return 0; +} + +SYS_INIT(mimxrt685_evk_hifi4_init, PRE_KERNEL_1, 0);