2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-12-04 23:09:39 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief CPU power management
|
|
|
|
*
|
|
|
|
* CPU power management routines.
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2022-05-09 19:56:13 +08:00
|
|
|
#include <zephyr/kernel_structs.h>
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <offsets_short.h>
|
2022-05-09 19:56:13 +08:00
|
|
|
#include <zephyr/toolchain.h>
|
|
|
|
#include <zephyr/linker/sections.h>
|
|
|
|
#include <zephyr/arch/cpu.h>
|
|
|
|
#include <zephyr/arch/arc/asm-compat/assembler.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
GTEXT(arch_cpu_idle)
|
|
|
|
GTEXT(arch_cpu_atomic_idle)
|
2019-09-22 09:07:07 +08:00
|
|
|
GDATA(z_arc_cpu_sleep_mode)
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2019-09-22 09:07:07 +08:00
|
|
|
SECTION_VAR(BSS, z_arc_cpu_sleep_mode)
|
2020-07-03 15:58:41 +08:00
|
|
|
.align 4
|
2015-04-11 07:44:37 +08:00
|
|
|
.word 0
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Put the CPU in low-power mode
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* This function always exits with interrupts unlocked.
|
|
|
|
*
|
|
|
|
* void nanCpuIdle(void)
|
|
|
|
*/
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
SECTION_FUNC(TEXT, arch_cpu_idle)
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2018-04-06 19:48:53 +08:00
|
|
|
#ifdef CONFIG_TRACING
|
2021-04-06 20:58:53 +08:00
|
|
|
PUSHR blink
|
2019-09-19 15:25:19 +08:00
|
|
|
jl sys_trace_idle
|
2021-04-06 20:58:53 +08:00
|
|
|
POPR blink
|
2016-05-05 00:55:33 +08:00
|
|
|
#endif
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2021-04-06 20:58:53 +08:00
|
|
|
/* z_arc_cpu_sleep_mode is 32 bit despite of platform bittnes */
|
2019-09-22 09:07:07 +08:00
|
|
|
ld r1, [z_arc_cpu_sleep_mode]
|
2015-04-11 07:44:37 +08:00
|
|
|
or r1, r1, (1 << 4) /* set IRQ-enabled bit */
|
2020-04-13 15:44:32 +08:00
|
|
|
sleep r1
|
2016-05-26 00:24:55 +08:00
|
|
|
j_s [blink]
|
2015-04-11 07:44:37 +08:00
|
|
|
nop
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Put the CPU in low-power mode, entered with IRQs locked
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* This function exits with interrupts restored to <key>.
|
|
|
|
*
|
2019-11-08 04:43:29 +08:00
|
|
|
* void arch_cpu_atomic_idle(unsigned int key)
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
2019-11-08 04:43:29 +08:00
|
|
|
SECTION_FUNC(TEXT, arch_cpu_atomic_idle)
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2018-04-06 19:48:53 +08:00
|
|
|
#ifdef CONFIG_TRACING
|
2021-04-06 20:58:53 +08:00
|
|
|
PUSHR blink
|
2019-09-19 15:25:19 +08:00
|
|
|
jl sys_trace_idle
|
2021-04-06 20:58:53 +08:00
|
|
|
POPR blink
|
2016-05-05 00:55:33 +08:00
|
|
|
#endif
|
|
|
|
|
2021-04-06 20:58:53 +08:00
|
|
|
/* z_arc_cpu_sleep_mode is 32 bit despite of platform bittnes */
|
2019-09-22 09:07:07 +08:00
|
|
|
ld r1, [z_arc_cpu_sleep_mode]
|
2015-04-11 07:44:37 +08:00
|
|
|
or r1, r1, (1 << 4) /* set IRQ-enabled bit */
|
|
|
|
sleep r1
|
|
|
|
j_s.d [blink]
|
|
|
|
seti r0
|