1/* 2 * Copyright (c) 2014 Wind River Systems, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7/** 8 * @file 9 * @brief CPU power management 10 * 11 * CPU power management routines. 12 */ 13 14#include <kernel_structs.h> 15#include <offsets_short.h> 16#include <toolchain.h> 17#include <linker/sections.h> 18#include <arch/cpu.h> 19#include <arch/arc/asm-compat/assembler.h> 20 21GTEXT(arch_cpu_idle) 22GTEXT(arch_cpu_atomic_idle) 23GDATA(z_arc_cpu_sleep_mode) 24 25SECTION_VAR(BSS, z_arc_cpu_sleep_mode) 26 .align 4 27 .word 0 28 29/* 30 * @brief Put the CPU in low-power mode 31 * 32 * This function always exits with interrupts unlocked. 33 * 34 * void nanCpuIdle(void) 35 */ 36 37SECTION_FUNC(TEXT, arch_cpu_idle) 38 39#ifdef CONFIG_TRACING 40 PUSHR blink 41 jl sys_trace_idle 42 POPR blink 43#endif 44 45 /* z_arc_cpu_sleep_mode is 32 bit despite of platform bittnes */ 46 ld r1, [z_arc_cpu_sleep_mode] 47 or r1, r1, (1 << 4) /* set IRQ-enabled bit */ 48 sleep r1 49 j_s [blink] 50 nop 51 52/* 53 * @brief Put the CPU in low-power mode, entered with IRQs locked 54 * 55 * This function exits with interrupts restored to <key>. 56 * 57 * void arch_cpu_atomic_idle(unsigned int key) 58 */ 59SECTION_FUNC(TEXT, arch_cpu_atomic_idle) 60 61#ifdef CONFIG_TRACING 62 PUSHR blink 63 jl sys_trace_idle 64 POPR blink 65#endif 66 67 /* z_arc_cpu_sleep_mode is 32 bit despite of platform bittnes */ 68 ld r1, [z_arc_cpu_sleep_mode] 69 or r1, r1, (1 << 4) /* set IRQ-enabled bit */ 70 sleep r1 71 j_s.d [blink] 72 seti r0 73