Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/platform/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ config IMX8ULP
Select if your target platform is imx8ulp-compatible.
imx.8ulp support dsp.

config IMX93_A55
bool "Build for NXP i.MX93 arm64 architecture (Zephyr-only)"
select BUILD_OUTPUT_BIN
select ZEPHYR_LOG
select HOST_PTABLE
select DMA_DOMAIN
help
Select if your target platform is imx93-compatible.
Comment thread
LaurentiuM1234 marked this conversation as resolved.
Outdated

config RENOIR
bool "Build for Renoir"
select XT_INTERRUPT_LEVEL_5
Expand Down
5 changes: 5 additions & 0 deletions src/platform/imx93_a55/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: BSD-3-Clause

add_subdirectory(lib)

add_local_sources(sof platform.c)
28 changes: 28 additions & 0 deletions src/platform/imx93_a55/include/platform/drivers/idc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 NXP
*/

#ifdef __ZEPHYR_RTOS_IDC_H__

#ifndef __PLATFORM_DRIVERS_IDC_H__
#define __PLATFORM_DRIVERS_IDC_H__

#include <stdint.h>

/* TODO: remove me if possible */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this referring to idc_msg? Then maybe remove the empty line below? Or to the whole file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's referring to the whole file. Same goes for interrupt.h, dai.h and trace.h. Apart from the fact that they help silence compilation errors they serve no purpose in i.MX93's case ATM.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The idc file specifically shouldn't really have been needed for any of the i.MX platforms, as IDC is Intel specific, and future multi-core DSPs from others will likely use different inter-core communication standards.

A future refactor should make sure to remove this file being needed from all non-CAVS platforms.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ack @paulstelian97 . With Zephyr we don't really need IDC as a public interface in SOF anymore. It's now used to send messages between DSP cores, but with Zephyr we can now use Zephyr OS primitives (threads, semaphores, locks) to implement this.

It's just this cleanup will take time as we still have non-Zephyr platforms in SOF main. See #7248 for background.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ack - cleanup will remove this incrementally.


struct idc_msg;

static inline int idc_send_msg(struct idc_msg *msg, uint32_t mode)
{
return 0;
}

#endif /* __PLATFORM_DRIVERS_IDC_H__ */

#else

#error "This file shouldn't be included from outside of Zephyr's rtos/idc.h"

#endif /* __ZEPHYR_RTOS_IDC_H__ */
19 changes: 19 additions & 0 deletions src/platform/imx93_a55/include/platform/drivers/interrupt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 NXP
*/

#ifdef __SOF_DRIVERS_INTERRUPT_H__

#ifndef __PLATFORM_DRIVERS_INTERRUPT_H__
#define __PLATFORM_DRIVERS_INTERRUPT_H__

/* TODO: remove me if possible */

#endif /* __PLATFORM_DRIVERS_INTERRUPT_H__ */

#else

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

#endif /* __SOF_DRIVERS_INTERRUPT_H__ */
26 changes: 26 additions & 0 deletions src/platform/imx93_a55/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 2023 NXP
*/

#ifdef __SOF_LIB_CLK_H__

#ifndef __PLATFORM_LIB_CLK_H__
#define __PLATFORM_LIB_CLK_H___

#define CLK_CPU(x) (x)
#define CPU_DEFAULT_IDX 0
#define NUM_CLOCKS 1
#define NUM_CPU_FREQ 1

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__ */
23 changes: 23 additions & 0 deletions src/platform/imx93_a55/include/platform/lib/cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 NXP
*/

#ifdef __SOF_LIB_CPU_H__

#ifndef __PLATFORM_LIB_CPU_H__
#define __PLATFORM_LIB_CPU_H__

/* note: although the core assigned to the inmate
* might not have the ID = 0 according to Linux,
* Zephyr will still index its cores starting from 0.
*/
#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/imx93_a55/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 2023 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__ */
30 changes: 30 additions & 0 deletions src/platform/imx93_a55/include/platform/lib/dma.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 NXP
*/

#ifdef __SOF_LIB_DMA_H__

#ifndef __PLATFORM_LIB_DMA_H__
#define __PLATFORM_LIB_DMA_H__

/* i.MX93 uses dummy DMA and EDMA */
#define PLATFORM_NUM_DMACS 2

#define DMA_ID_EDMA2 0
#define DMA_ID_HOST 1

/* TODO: this is already defined with EDMA2_CHAN_MAX */
#define PLATFORM_MAX_DMA_CHAN 64

/* TODO: required by Zephyr DMA domain to work */
#define dma_chan_irq_name(dma, chan) dma_irq_name(dma)
#define dma_chan_irq(dma, chan) ((int *)(dma)->plat_data.drv_plat_data)[chan]

#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__ */
67 changes: 67 additions & 0 deletions src/platform/imx93_a55/include/platform/lib/mailbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 NXP
*/

#ifdef __SOF_LIB_MAILBOX_H__

#ifndef __PLATFORM_LIB_MAILBOX_H__
#define __PLATFORM_LIB_MAILBOX_H__

/* i.MX93's mailbox is organized as follows:
*
* +---------------+----------------------+------------------------+-----------+
* | Region name | Base address | Offset | Size | Permissions |
* +---------------+---------------+--------+---------+------------------------+
* | Inbox region | 0xce100000 | 0 | 0x1000 | ROOT: R/W, INMATE: R/W |
* +---------------+---------------+--------+---------+------------------------+
* | Outbox region | 0xce101000 | 0x1000 | 0x1000 | ROOT: R/W, INMATE: R/W |
* +---------------+---------------+--------+---------+------------+-----------+
* | Stream region | 0xce102000 | 0x2000 | 0x1000 | ROOT: R/W, INMATE: R/W |
* +---------------+---------------+--------+---------+------------------------+
*
*
* RESTRICTIONS:
* * the inbox region always needs to be placed at offset 0
* relative to the mailbox memory region used by the Linux host
* driver. Other than that, there's no restrictions regarding the
* placement of these mailbox regions.
*
* Notes:
* * if there's a need to add new regions, simply append the
* new regions to the above table and create memory regions
* inside the Jailhouse configurations for root/inmate cells.
* Also, please make sure that the Linux host driver is also
* aware of these new regions.
*
* * although these regions are placed one after the other please
* note that this isn't a restriction. If there's a need to place
* these regions elsewhere please not that the offset is relative
* to the mailbox memory region used by the Linux host driver.
*
* * TODO: root and inmate shouldn't have the same permissions, fix
* it.
*/

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

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

/* stream */
#define MAILBOX_STREAM_SIZE 0x1000
#define MAILBOX_STREAM_BASE 0xce102000
#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__ */
72 changes: 72 additions & 0 deletions src/platform/imx93_a55/include/platform/lib/memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 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

/* seems like in xtensa architecture cached data
* may be placed at some special addresses in the
* SRAM?
Comment thread
LaurentiuM1234 marked this conversation as resolved.
Outdated
*
* since we're running on A55 cores, there's no such
* thing so all the below cache/shared data "management"
* functions aren't necessary.
*/
#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

/* number of heaps to be used.
*
* i.MX93 is non-SMP so we're only going to use 1 heap.
*/
#define PLATFORM_HEAP_SYSTEM 1
#define PLATFORM_HEAP_SYSTEM_RUNTIME 1
#define PLATFORM_HEAP_RUNTIME 1
#define PLATFORM_HEAP_BUFFER 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think you can share system vs runtime/buffer heaps can you? Or is my knowledge of them being structurally different (and thus mandatory to separate) only applicable on XTOS builds?

On XTOS, for reference, the system heap works very differently from the others (allocation is a pointer increment, as opposed to using a structure to keep track of allocated vs freed heap slots)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Currently these are mapped to a single heap in Zephyr SOF builds and the PLATFORM_HEAP_FOO definitions are implemented. Instead, we have a single heap implemented with sys_heap and the SOF heap type definitions are only used to control alloc time behaviour (and we maintain existing semantics here, e.g. SYSTEM allocs can never fail).

There is lot of activity in this area though. On Intel side, we recently added support for a separately managed persistant memory heap (SOF_MEM_CAPS_L3), and there's been active discussions about adding infra to support per-core heaps. But no PRs yet how to expose this via memory.h, so for now, we stick to implementing existing semantics to SOF app code. Platform code needs to provide necessary definitions both for XTOS and Zephyr builds.


/* host and firmware use shared memory */
#define host_to_local(addr) (addr)
#define local_to_host(addr) (addr)

/* if this gets too big then it will be
* necessary to increase the SRAM size from
* the Zephyr DTS. This should be fine as
* we're going to reserve 800MB for Jailhouse
* usage.
*/
#define HEAPMEM_SIZE 0x00010000

/* SOF uses A side of the WAKEUPMIX MU */
#define MU_BASE 0x42430000

/* SOF uses EDMA2 (a.k.a EDMA4 in the TRM) */
#define EDMA2_BASE 0x42010000
#define EDMA2_CHAN_SIZE 0x8000

/* WM8962 is connected to SAI3 */
#define SAI3_BASE 0x42660000

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__*/
56 changes: 56 additions & 0 deletions src/platform/imx93_a55/include/platform/lib/pm_runtime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2023 NXP
*/

#ifdef __SOF_LIB_PM_RUNTIME_H__

#ifndef __PLATFORM_LIB_PM_RUNTIME_H__
#define __PLATFORM_LIB_PM_RUNTIME_H__

/* TODO: is this required? Should this be implemented using Zephyr PM
* API?
*/
#include <stdint.h>

struct pm_runtime_data;

static inline void platform_pm_runtime_init(struct pm_runtime_data *prd)
{
}

static inline void platform_pm_runtime_get(uint32_t context,
uint32_t index,
uint32_t flags)
{
}

static inline void platform_pm_runtime_put(uint32_t context,
uint32_t index,
uint32_t flags)
{
}

static inline void platform_pm_runtime_enable(uint32_t context,
uint32_t index)
{
}

static inline void platform_pm_runtime_disable(uint32_t context,
uint32_t index)
{
}

static inline bool platform_pm_runtime_is_active(uint32_t context,
uint32_t index)
{
return false;
}

#endif /* __PLATFORM_LIB_PM_RUNTIME_H__ */

#else

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

#endif /* __SOF_LIB_PM_RUNTIME_H__ */
Loading