2024-03-15 22:03:57 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2024 Nordic Semiconductor ASA
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr/irq.h>
|
2024-03-25 21:30:12 +08:00
|
|
|
#include <zephyr/sys/barrier.h>
|
2024-03-15 22:03:57 +08:00
|
|
|
#include <zephyr/tracing/tracing.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Due to a HW issue, VPR requires MSTATUS.MIE to be enabled when entering sleep.
|
|
|
|
* Otherwise it would not wake up.
|
|
|
|
*/
|
|
|
|
void arch_cpu_idle(void)
|
|
|
|
{
|
|
|
|
sys_trace_idle();
|
2024-03-25 21:30:12 +08:00
|
|
|
barrier_dsync_fence_full();
|
2024-03-15 22:03:57 +08:00
|
|
|
irq_unlock(MSTATUS_IEN);
|
|
|
|
__asm__ volatile("wfi");
|
|
|
|
}
|
|
|
|
|
|
|
|
void arch_cpu_atomic_idle(unsigned int key)
|
|
|
|
{
|
|
|
|
sys_trace_idle();
|
2024-03-25 21:30:12 +08:00
|
|
|
barrier_dsync_fence_full();
|
2024-03-15 22:03:57 +08:00
|
|
|
irq_unlock(MSTATUS_IEN);
|
|
|
|
__asm__ volatile("wfi");
|
|
|
|
|
|
|
|
/* Disable interrupts if needed. */
|
|
|
|
__asm__ volatile ("csrc mstatus, %0"
|
|
|
|
:
|
|
|
|
: "r" (~key & MSTATUS_IEN)
|
|
|
|
: "memory");
|
|
|
|
}
|