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
5 changes: 4 additions & 1 deletion src/platform/imx8/lib/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

#include <sof/common.h>
#include <sof/lib/clk.h>
#include <sof/lib/cpu.h>
#include <sof/lib/memory.h>
#include <sof/lib/notifier.h>
#include <sof/sof.h>
#include <sof/spinlock.h>

#ifdef __ZEPHYR__
#include <sys/util.h>
#endif

const struct freq_table platform_cpu_freq[] = {
#ifdef CONFIG_IMX8
{ 666000000, 666000 },
Expand Down
5 changes: 5 additions & 0 deletions src/platform/imx8/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ int platform_init(struct sof *sof)
timer_domain_init(sof->platform_timer, PLATFORM_DEFAULT_CLOCK);
scheduler_init_ll(sof->platform_timer_domain);

#ifndef __ZEPHYR__
platform_timer_start(sof->platform_timer);
#endif

sa_init(sof, CONFIG_SYSTICK_PERIOD);

clock_set_freq(CLK_CPU(cpu_get_id()), CLK_MAX_CPU_HZ);
Expand All @@ -191,6 +194,7 @@ int platform_init(struct sof *sof)
if (ret < 0)
return -ENODEV;

#ifndef __ZEPHYR__
#if CONFIG_TRACE
/* Initialize DMA for Trace*/
trace_point(TRACE_BOOT_PLATFORM_DMA_TRACE);
Expand All @@ -199,6 +203,7 @@ int platform_init(struct sof *sof)

/* show heap status */
heap_trace_all(1);
#endif /* __ZEPHYR__ */

return 0;
}
Expand Down
5 changes: 5 additions & 0 deletions src/platform/imx8m/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ int platform_init(struct sof *sof)
timer_domain_init(sof->platform_timer, PLATFORM_DEFAULT_CLOCK);
scheduler_init_ll(sof->platform_timer_domain);

#ifndef __ZEPHYR__
platform_timer_start(sof->platform_timer);
#endif

sa_init(sof, CONFIG_SYSTICK_PERIOD);

clock_set_freq(CLK_CPU(cpu_get_id()), CLK_MAX_CPU_HZ);
Expand All @@ -191,6 +194,7 @@ int platform_init(struct sof *sof)
if (ret < 0)
return -ENODEV;

#ifndef __ZEPHYR__
#if CONFIG_TRACE
/* Initialize DMA for Trace*/
trace_point(TRACE_BOOT_PLATFORM_DMA_TRACE);
Expand All @@ -199,6 +203,7 @@ int platform_init(struct sof *sof)

/* show heap status */
heap_trace_all(1);
#endif /* __ZEPHYR__ */

return 0;
}
Expand Down
44 changes: 38 additions & 6 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,45 @@ endif()
# NXP IMX8 platforms
if (CONFIG_SOC_SERIES_NXP_IMX8)
zephyr_library_sources(
#${SOF_DRIVERS_PATH}/generic/dummy-dma.c
#${SOF_DRIVERS_PATH}/imx/sdma.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}/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
)

# 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
)

set(PLATFORM "imx8")
endif()

if (CONFIG_SOC_SERIES_NXP_IMX8M)
zephyr_library_sources(
${SOF_DRIVERS_PATH}/generic/dummy-dma.c
${SOF_DRIVERS_PATH}/imx/sdma.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
)

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

set(PLATFORM "imx8m")
endif()

zephyr_library_sources_ifdef(CONFIG_LIBRARY
Expand Down
49 changes: 49 additions & 0 deletions zephyr/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <soc.h>
#include <kernel.h>

#ifndef CONFIG_KERNEL_COHERENCE
#include <arch/xtensa/cache.h>
#endif

extern K_KERNEL_STACK_ARRAY_DEFINE(z_interrupt_stacks, CONFIG_MP_NUM_CPUS,
CONFIG_ISR_STACK_SIZE);

Expand All @@ -51,12 +55,21 @@ DECLARE_TR_CTX(zephyr_tr, SOF_UUID(zephyr_uuid), LOG_LEVEL_INFO);
#endif

/* The Zephyr heap */
#ifdef CONFIG_IMX
#define HEAPMEM_SIZE (HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE + HEAP_BUFFER_SIZE)
/*
* Include heapmem variable in .heap_mem section, otherwise the HEAPMEM_SIZE is
* duplicated in two sections and the sdram0 region overflows.
*/
__section(".heap_mem") static uint8_t __aligned(64) heapmem[HEAPMEM_SIZE];
#else
#define HEAPMEM_SIZE HEAP_BUFFER_SIZE
#define HEAPMEM_SHARED_SIZE (HEAP_SYSTEM_SIZE + HEAP_RUNTIME_SIZE + \
HEAP_RUNTIME_SHARED_SIZE + HEAP_SYSTEM_SHARED_SIZE)

static uint8_t __aligned(PLATFORM_DCACHE_ALIGN)heapmem[HEAPMEM_SIZE];
static uint8_t __aligned(PLATFORM_DCACHE_ALIGN)heapmem_shared[HEAPMEM_SHARED_SIZE];
#endif

/* Use k_heap structure */
static struct k_heap sof_heap;
Expand All @@ -67,7 +80,9 @@ static int statics_init(const struct device *unused)
ARG_UNUSED(unused);

sys_heap_init(&sof_heap.heap, heapmem, HEAPMEM_SIZE);
#ifndef CONFIG_IMX
sys_heap_init(&sof_heap_shared.heap, heapmem_shared, HEAPMEM_SHARED_SIZE);
#endif

return 0;
}
Expand Down Expand Up @@ -136,6 +151,8 @@ void *rmalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes)
{
if (zone_is_cached(zone))
return heap_alloc_aligned_cached(&sof_heap, 0, bytes);
else
return heap_alloc_aligned(&sof_heap, 8, bytes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line "reliably" crashes my Up Squared board on the second aplay command every time, see partial revert PR #4472

git bisect found this commit and then it was easy to identify this line because it seems to be the only one not IMX-specific.

Cc: @lyakh , @lgirdwood , @andyross

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a pull request to fix this, for both i.MX and Up Squared: #4477
The PR #4472 breaks i.MX.


return heap_alloc_aligned(&sof_heap_shared, 8, bytes);
}
Expand Down Expand Up @@ -238,11 +255,14 @@ const char irq_name_level5[] = "level5";

/*
* CAVS IRQs are multilevel whereas BYT and BDW are DSP level only.
*
* For i.MX we use the IRQ_STEER
*/
int interrupt_get_irq(unsigned int irq, const char *cascade)
{
#if CONFIG_SOC_SERIES_INTEL_ADSP_BAYTRAIL ||\
CONFIG_SOC_SERIES_INTEL_ADSP_BROADWELL || \
CONFIG_IMX || \
CONFIG_LIBRARY
return irq;
#else
Expand Down Expand Up @@ -355,6 +375,35 @@ uint64_t platform_timer_get(struct timer *timer)
#elif CONFIG_SOC_SERIES_INTEL_ADSP_BROADWELL || CONFIG_LIBRARY
// FIXME!
return 0;
#elif CONFIG_IMX
/* For i.MX use Xtensa timer, as we do now with SOF */
uint64_t time = 0;
uint32_t low;
uint32_t high;
uint32_t ccompare;

if (!timer || timer->id >= ARCH_TIMER_COUNT)
goto out;

ccompare = xthal_get_ccompare(timer->id);

/* read low 32 bits */
low = xthal_get_ccount();

/* check and see whether 32bit IRQ is pending for timer */
if (arch_interrupt_get_status() & (1 << timer->irq) && ccompare == 1) {
/* yes, overflow has occurred but handler has not run */
high = timer->hitime + 1;
} else {
/* no overflow */
high = timer->hitime;
}

time = ((uint64_t)high << 32) | low;

out:

return time;
#else
/* CAVS versions */
return shim_read64(SHIM_DSPWC);
Expand Down