Skip to content
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

add support for running SOF on imx95 #9512

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions app/boards/imx95_evk_mimx9596_m7_ddr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CONFIG_DYNAMIC_INTERRUPTS=y
CONFIG_TRACE=n
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_IMX95=y

CONFIG_SAI_HAS_MCLK_CONFIG_OPTION=y

CONFIG_DMA=y
CONFIG_DMA_NXP_EDMA_ENABLE_HALFMAJOR_IRQ=y

CONFIG_SHARED_INTERRUPTS=y
25 changes: 25 additions & 0 deletions app/boards/imx95_evk_mimx9596_m7_ddr.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
host_dma: dma {
compatible = "nxp,sof-host-dma";
dma-channels = <32>;
#dma-cells = <0>;
};
};

&sai3 {
tx-fifo-watermark = <8>;
rx-fifo-watermark = <96>;
fifo-depth = <96>;
rx-sync-mode = <1>;
status = "okay";
};

&edma2 {
status = "okay";
};
6 changes: 5 additions & 1 deletion scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class PlatformConfig:
"hifi4_nxp2_s7_v2_1a_prod",
RIMAGE_KEY = "key param ignored by imx8ulp"
),
"imx95" : PlatformConfig(
"imx", "imx95_evk/mimx9596/m7/ddr",
"", "", "", ""
),
}

platform_configs = platform_configs_all.copy()
Expand Down Expand Up @@ -1160,7 +1164,7 @@ def gzip_compress(fname, gzdst=None):
# Don't run sof_ri_info and ignore silently .ri files that don't have one.
RI_INFO_UNSUPPORTED = []

RI_INFO_UNSUPPORTED += ['imx8', 'imx8x', 'imx8m', 'imx8ulp']
RI_INFO_UNSUPPORTED += ['imx8', 'imx8x', 'imx8m', 'imx8ulp', 'imx95']
RI_INFO_UNSUPPORTED += ['rn']
RI_INFO_UNSUPPORTED += ['mt8186', 'mt8195']

Expand Down
2 changes: 1 addition & 1 deletion src/include/sof/drivers/mu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum imx_mu_type {
IMX_MU_V2,
};

#if defined(CONFIG_IMX8ULP) || defined(CONFIG_IMX93_A55)
#if defined(CONFIG_IMX8ULP) || defined(CONFIG_IMX93_A55) || defined(CONFIG_IMX95)
#define IMX_MU_VERSION IMX_MU_V2
#else
#define IMX_MU_VERSION IMX_MU_V1
Expand Down
9 changes: 9 additions & 0 deletions src/platform/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ config IMX93_A55
help
Select if your target platform is imx93-compatible.

config IMX95
bool "Build for NXP i.MX95"
select ZEPHYR_LOG
select BUILD_OUTPUT_BIN
select HOST_PTABLE
select IMX
help
Select if your target platform is imx95-compatible.

config RENOIR
bool "Build for Renoir"
select XT_INTERRUPT_LEVEL_5
Expand Down
26 changes: 26 additions & 0 deletions src/platform/imx95/include/platform/lib/clk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_LIB_CLK_H__

#ifndef __PLATFORM_LIB_CLK_H__
#define __PLATFORM_LIB_CLK_H__

#define CLK_MAX_CPU_HZ 800000000
#define CPU_DEFAULT_IDX 0
#define NUM_CPU_FREQ 1
#define NUM_CLOCKS 1

Comment on lines +11 to +15
Copy link
Member

Choose a reason for hiding this comment

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

@LaurentiuM1234 I think @kv2019i got rid of a lot of these last week since they should come from Zephyr - can you check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm...double-checked and couldn't find anything else to drop w/o breaking the build... @kv2019i anything obvious that I'm missing?

Copy link
Member

Choose a reason for hiding this comment

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

ok, I'm probably wrong, probably in process of being removed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ack @LaurentiuM1234 @lgirdwood platform clk.h is still needed. We have a Zephyr version of clk.h that still depends on it. OTOH, I did a quick look and it seems this could be cleaned up further as well as the usage of clk.h is not much in app code -> #9541

struct sof;

void platform_clock_init(struct sof *sof);

#endif /* __PLATFORM_LIB_CLK_H__ */

#else

#error "This file shouldn't be included from outside of sof/lib/clk.h"

#endif /* __SOF_LIB_CLK_H__ */
19 changes: 19 additions & 0 deletions src/platform/imx95/include/platform/lib/cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_LIB_CPU_H__

#ifndef __PLATFORM_LIB_CPU_H__
#define __PLATFORM_LIB_CPU_H__

#define PLATFORM_PRIMARY_CORE_ID 0

#endif /* __PLATFORM_LIB_CPU_H__ */

#else

#error "This file shouldn't be included from outside of sof/lib/cpu.h"

#endif /* __SOF_LIB_CPU_H__ */
19 changes: 19 additions & 0 deletions src/platform/imx95/include/platform/lib/dai.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_LIB_DAI_H__

#ifndef __PLATFORM_LIB_DAI_H__
#define __PLATFORM_LIB_DAI_H__

/* TODO: remove me whenever possible */

#endif /* __PLATFORM_LIB_DAI_H__ */

#else

#error "This file shouldn't be included from outside of sof/lib/dai.h"

#endif /* __SOF_LIB_DAI_H__ */
19 changes: 19 additions & 0 deletions src/platform/imx95/include/platform/lib/dma.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_LIB_DMA_H__

#ifndef __PLATFORM_LIB_DMA_H__
#define __PLATFORM_LIB_DMA_H__

/* TODO: remove me whenever possible */

#endif /* __PLATFORM_LIB_DMA_H__ */

#else

#error "This file shouldn't be included from outside of sof/lib/dma.h"

#endif /* __SOF_LIB_DMA_H__ */
49 changes: 49 additions & 0 deletions src/platform/imx95/include/platform/lib/mailbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_LIB_MAILBOX_H__

#ifndef __PLATFORM_LIB_MAILBOX_H__
#define __PLATFORM_LIB_MAILBOX_H__

/* i.MX95's mailbox is organized as follows:
*
* +---------------+-------------------------+
* | Region name | Base address | Size |
* +---------------+---------------+---------+
* | Inbox region | 0x8fffd000 | 0x1000 |
* +---------------+---------------+---------+
* | Outbox region | 0x8fffe000 | 0x1000 |
* +---------------+---------------+---------+
* | Stream region | 0x8ffff000 | 0x1000 |
* +---------------+---------------+---------+
*
* IMPORTANT: all regions should be 32-byte aligned.
* This is required because cache maintenance might
* be performed on them.
*/

/* inbox */
#define MAILBOX_HOSTBOX_SIZE 0x1000
#define MAILBOX_HOSTBOX_BASE 0x86000000
#define MAILBOX_HOSTBOX_OFFSET 0

/* outbox */
#define MAILBOX_DSPBOX_SIZE 0x1000
#define MAILBOX_DSPBOX_BASE 0x86001000
#define MAILBOX_DSPBOX_OFFSET (MAILBOX_HOSTBOX_OFFSET + MAILBOX_HOSTBOX_SIZE)

/* stream */
#define MAILBOX_STREAM_SIZE 0x1000
#define MAILBOX_STREAM_BASE 0x86002000
#define MAILBOX_STREAM_OFFSET (MAILBOX_DSPBOX_OFFSET + MAILBOX_DSPBOX_SIZE)

#endif /* __PLATFORM_LIB_MAILBOX_H__ */

#else

#error "This file shouldn't be included from outside of sof/lib/mailbox.h"

#endif /* __SOF_LIB_MAILBOX_H__ */
42 changes: 42 additions & 0 deletions src/platform/imx95/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_LIB_MEMORY_H__

#ifndef __PLATFORM_LIB_MEMORY_H__
#define __PLATFORM_LIB_MEMORY_H__

#include <rtos/cache.h>

#define PLATFORM_DCACHE_ALIGN DCACHE_LINE_SIZE

#define SHARED_DATA

#define uncache_to_cache(address) address
#define cache_to_uncache(address) address
#define cache_to_uncache_init(address) address
#define is_uncached(address) 0

/* no address translation required */
#define host_to_local(addr) (addr)
#define local_to_host(addr) (addr)

#define HEAPMEM_SIZE 0x00010000

/* WAKEUP domain MU7 side B */
#define MU_BASE 0x42440000UL

static inline void *platform_shared_get(void *ptr, int bytes)
{
return ptr;
}

#endif /* __PLATFORM_LIB_MEMORY_H__ */

#else

#error "This file shouldn't be included from outside of sof/lib/memory.h"

#endif /* __SOF_LIB_MEMORY_H__*/
35 changes: 35 additions & 0 deletions src/platform/imx95/include/platform/platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_PLATFORM_H__

#ifndef __PLATFORM_PLATFORM_H__
#define __PLATFORM_PLATFORM_H__

/* refers to M7 core clock - one core, one clock */
#define PLATFORM_DEFAULT_CLOCK 0

#define HOST_PAGE_SIZE 4096

#define PLATFORM_PAGE_TABLE_SIZE 256

/* TODO: generous (SOF is usually used with 2 channels at most on i.MX
* platforms) and (potentially) not true. Can be adjusted later on if
* need be.
*/
#define PLATFORM_MAX_CHANNELS 4
/* TODO: same as PLATFORM_MAX_CHANNELS */
#define PLATFORM_MAX_STREAMS 5

/* WAKEUP domain MU7 side B */
#define PLATFORM_IPC_INTERRUPT 207

#endif /* __PLATFORM_PLATFORM_H__ */

#else

#error "This file shouldn't be included from outside of sof/platform.h"

#endif /* __SOF_PLATFORM_H__ */
19 changes: 19 additions & 0 deletions src/platform/imx95/include/platform/trace/trace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2024 NXP
*/

#ifdef __SOF_TRACE_TRACE_H__

#ifndef __PLATFORM_TRACE_TRACE_H__
#define __PLATFORM_TRACE_TRACE_H__

/* TODO: remove me whenever possible */

#endif /* __PLATFORM_TRACE_TRACE_H__ */

#else

#error "This file shouldn't be included from outside of sof/trace/trace.h"

#endif /* __SOF_TRACE_TRACE_H__ */
35 changes: 35 additions & 0 deletions src/platform/imx95/lib/clk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
* Copyright 2024 NXP
*/

#include <rtos/clk.h>
#include <sof/lib/notifier.h>

static const struct freq_table platform_cpu_freq[] = {
{
.freq = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
.ticks_per_msec = CONFIG_SYS_CLOCK_TICKS_PER_SEC * 1000,
},
};

static struct clock_info platform_clocks_info[NUM_CLOCKS];

void platform_clock_init(struct sof *sof)
{
int i;

sof->clocks = platform_clocks_info;

for (i = 0; i < CONFIG_CORE_COUNT; i++) {
sof->clocks[i] = (struct clock_info) {
.freqs_num = NUM_CPU_FREQ,
.freqs = platform_cpu_freq,
.default_freq_idx = CPU_DEFAULT_IDX,
.current_freq_idx = CPU_DEFAULT_IDX,
.notification_id = NOTIFIER_ID_CPU_FREQ,
.notification_mask = NOTIFIER_TARGET_CORE_MASK(i),
.set_freq = NULL,
};
}
}
5 changes: 5 additions & 0 deletions src/platform/imx95/linker/data-sections.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SECTION_PROLOGUE(.fw_metadata,,)
{
KEEP (*(*.fw_metadata))
. = ALIGN(16);
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
Loading
Loading