Skip to content

Commit

Permalink
nxp: imx8/imx8x: switch to native Zephyr drivers
Browse files Browse the repository at this point in the history
This commit includes all necessary changes for switching
to native Zephyr drivers on imx8/imx8x.

Signed-off-by: Laurentiu Mihalcea <[email protected]>
  • Loading branch information
LaurentiuM1234 committed Feb 22, 2024
1 parent e06d4d4 commit 4639d7c
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/boards/nxp_adsp_imx8.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CONFIG_TRACE=n
CONFIG_DMA=y
CONFIG_DMA_NXP_EDMA_ENABLE_HALFMAJOR_IRQ=y
CONFIG_SHARED_INTERRUPTS=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
1 change: 1 addition & 0 deletions app/boards/nxp_adsp_imx8x.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CONFIG_TRACE=n
CONFIG_DMA=y
CONFIG_DMA_NXP_EDMA_ENABLE_HALFMAJOR_IRQ=y
CONFIG_SHARED_INTERRUPTS=y
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
2 changes: 1 addition & 1 deletion src/drivers/imx/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

LOG_MODULE_REGISTER(ipc_task, CONFIG_SOF_LOG_LEVEL);

#ifdef CONFIG_ARM64
#if defined(CONFIG_ARM64) || defined(CONFIG_IMX8) || defined(CONFIG_IMX8X)
/* thanks to the fact that ARM's GIC is supported
* by Zephyr there's no need to clear interrupts
* explicitly. This should already be done by Zephyr
Expand Down
2 changes: 0 additions & 2 deletions src/platform/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ config IMX8
select IMX
select IMX_EDMA
select IMX_ESAI
select SCHEDULE_DMA_MULTI_CHANNEL
select IMX_INTERRUPT_IRQSTEER
help
Select if your target platform is imx8-compatible
Expand All @@ -84,7 +83,6 @@ config IMX8X
select IMX
select IMX_EDMA
select IMX_ESAI
select SCHEDULE_DMA_MULTI_CHANNEL
select IMX_INTERRUPT_IRQSTEER
help
Select if your target platform is imx8x-compatible
Expand Down
2 changes: 1 addition & 1 deletion src/platform/imx8/include/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct timer;
#define LPSRAM_SIZE 16384

/* IPC Interrupt */
#define PLATFORM_IPC_INTERRUPT IRQ_NUM_MU
#define PLATFORM_IPC_INTERRUPT 7
#define PLATFORM_IPC_INTERRUPT_NAME NULL

/* Host page size */
Expand Down
14 changes: 0 additions & 14 deletions src/platform/imx8/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ int platform_init(struct sof *sof)
sof->cpu_timers = sof->platform_timer;
#endif

#ifdef __ZEPHYR__
/* initialize cascade interrupts before any usage */
interrupt_init(sof);
#endif

platform_interrupt_init();
platform_clock_init(sof);
scheduler_init_edf();
Expand All @@ -187,15 +182,6 @@ int platform_init(struct sof *sof)
if (ret < 0)
return -ENODEV;

/* Init EDMA platform domain */
sof->platform_dma_domain = dma_multi_chan_domain_init
(&sof->dma_info->dma_array[0], 1,
PLATFORM_DEFAULT_CLOCK, false);

/* i.MX platform DMA domain will be full synchronous, no time dependent */
sof->platform_dma_domain->full_sync = true;
scheduler_init_ll(sof->platform_dma_domain);

/* initialize the host IPC mechanims */
ipc_init(sof);

Expand Down
9 changes: 1 addition & 8 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,26 +234,19 @@ endif()
# NXP IMX8 platforms
if (CONFIG_SOC_SERIES_NXP_IMX8)
zephyr_library_sources(
${SOF_DRIVERS_PATH}/generic/dummy-dma.c
${SOF_DRIVERS_PATH}/imx/edma.c
${SOF_DRIVERS_PATH}/imx/sai.c
${SOF_DRIVERS_PATH}/imx/ipc.c
${SOF_DRIVERS_PATH}/imx/esai.c
${SOF_DRIVERS_PATH}/imx/interrupt-irqsteer.c
)

# Platform sources
zephyr_library_sources(
${SOF_PLATFORM_PATH}/imx8/platform.c
${SOF_PLATFORM_PATH}/imx8/lib/clk.c
${SOF_PLATFORM_PATH}/imx8/lib/dai.c
${SOF_PLATFORM_PATH}/imx8/lib/dma.c
${SOF_PLATFORM_PATH}/imx8/lib/memory.c
)

# SOF core infrastructure - runs on top of Zephyr
zephyr_library_sources(
${SOF_SRC_PATH}/drivers/interrupt.c
lib/dma.c
)

zephyr_library_sources(${SOF_SRC_PATH}/schedule/zephyr_ll.c)
Expand Down
2 changes: 1 addition & 1 deletion zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ config SOF_ZEPHYR_STRICT_HEADERS

config DMA_DOMAIN
bool "Enable the usage of DMA domain."
default y if IMX
default y if IMX8M || IMX8ULP
help
This enables the usage of the DMA domain in scheduling.

Expand Down
8 changes: 6 additions & 2 deletions zephyr/include/rtos/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
#ifndef __ZEPHYR_RTOS_INTERRUPT_H__
#define __ZEPHYR_RTOS_INTERRUPT_H__

#if defined(CONFIG_IMX)
/* TODO: to be removed completely when the following platforms are switched
* to native drivers.
*/
#if defined(CONFIG_IMX8M) || defined(CONFIG_IMX8ULP)
/* imx currently has no IRQ driver in Zephyr so we force to xtos IRQ */
#include "../../../xtos/include/rtos/interrupt.h"
#else
Expand Down Expand Up @@ -55,7 +58,8 @@ static inline void interrupt_unregister(uint32_t irq, const void *arg)
static inline int interrupt_get_irq(unsigned int irq, const char *cascade)
{
#if defined(CONFIG_LIBRARY) || defined(CONFIG_ACE) || \
defined(CONFIG_ZEPHYR_POSIX) || defined(CONFIG_ARM64)
defined(CONFIG_ZEPHYR_POSIX) || defined(CONFIG_ARM64) ||\
defined(CONFIG_IMX8) || defined(CONFIG_IMX8X)
return irq;
#else
if (cascade == irq_name_level2)
Expand Down
2 changes: 1 addition & 1 deletion zephyr/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const char irq_name_level2[] = "level2";
const char irq_name_level5[] = "level5";

/* imx currently has no IRQ driver in Zephyr so we force to xtos IRQ */
#if defined(CONFIG_IMX)
#if defined(CONFIG_IMX8M) || defined(CONFIG_IMX8ULP)
int interrupt_register(uint32_t irq, void(*handler)(void *arg), void *arg)
{
#ifdef CONFIG_DYNAMIC_INTERRUPTS
Expand Down

0 comments on commit 4639d7c

Please sign in to comment.