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