xref: /openbmc/qemu/target/arm/arm-powerctl.h (revision 9403bccfe3e271f04e12c8c64d306e0cff589009)
1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth  * QEMU support -- ARM Power Control specific functions.
3fcf5ef2aSThomas Huth  *
4fcf5ef2aSThomas Huth  * Copyright (c) 2016 Jean-Christophe Dubois
5fcf5ef2aSThomas Huth  *
6fcf5ef2aSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7fcf5ef2aSThomas Huth  * See the COPYING file in the top-level directory.
8fcf5ef2aSThomas Huth  *
9fcf5ef2aSThomas Huth  */
10fcf5ef2aSThomas Huth 
11fcf5ef2aSThomas Huth #ifndef QEMU_ARM_POWERCTL_H
12fcf5ef2aSThomas Huth #define QEMU_ARM_POWERCTL_H
13fcf5ef2aSThomas Huth 
14fcf5ef2aSThomas Huth #include "kvm-consts.h"
15fcf5ef2aSThomas Huth 
16fcf5ef2aSThomas Huth #define QEMU_ARM_POWERCTL_RET_SUCCESS QEMU_PSCI_RET_SUCCESS
17fcf5ef2aSThomas Huth #define QEMU_ARM_POWERCTL_INVALID_PARAM QEMU_PSCI_RET_INVALID_PARAMS
18fcf5ef2aSThomas Huth #define QEMU_ARM_POWERCTL_ALREADY_ON QEMU_PSCI_RET_ALREADY_ON
19fcf5ef2aSThomas Huth #define QEMU_ARM_POWERCTL_IS_OFF QEMU_PSCI_RET_DENIED
20062ba099SAlex Bennée #define QEMU_ARM_POWERCTL_ON_PENDING QEMU_PSCI_RET_ON_PENDING
21fcf5ef2aSThomas Huth 
22fcf5ef2aSThomas Huth /*
23fcf5ef2aSThomas Huth  * arm_get_cpu_by_id:
24fcf5ef2aSThomas Huth  * @cpuid: the id of the CPU we want to retrieve the state
25fcf5ef2aSThomas Huth  *
26fcf5ef2aSThomas Huth  * Retrieve a CPUState object from its CPU ID provided in @cpuid.
27fcf5ef2aSThomas Huth  *
28fcf5ef2aSThomas Huth  * Returns: a pointer to the CPUState structure of the requested CPU.
29fcf5ef2aSThomas Huth  */
30fcf5ef2aSThomas Huth CPUState *arm_get_cpu_by_id(uint64_t cpuid);
31fcf5ef2aSThomas Huth 
32fcf5ef2aSThomas Huth /*
33fcf5ef2aSThomas Huth  * arm_set_cpu_on:
34fcf5ef2aSThomas Huth  * @cpuid: the id of the CPU we want to start/wake up.
35fcf5ef2aSThomas Huth  * @entry: the address the CPU shall start from.
36fcf5ef2aSThomas Huth  * @context_id: the value to put in r0/x0.
37fcf5ef2aSThomas Huth  * @target_el: The desired exception level.
38fcf5ef2aSThomas Huth  * @target_aa64: 1 if the requested mode is AArch64. 0 otherwise.
39fcf5ef2aSThomas Huth  *
40fcf5ef2aSThomas Huth  * Start the cpu designated by @cpuid in @target_el exception level. The mode
41fcf5ef2aSThomas Huth  * shall be AArch64 if @target_aa64 is set to 1. Otherwise the mode is
42fcf5ef2aSThomas Huth  * AArch32. The CPU shall start at @entry with @context_id in r0/x0.
43fcf5ef2aSThomas Huth  *
44fcf5ef2aSThomas Huth  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
45fcf5ef2aSThomas Huth  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
46fcf5ef2aSThomas Huth  * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU was already started.
47062ba099SAlex Bennée  * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is still powering up
48fcf5ef2aSThomas Huth  */
49fcf5ef2aSThomas Huth int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
50fcf5ef2aSThomas Huth                    uint32_t target_el, bool target_aa64);
51fcf5ef2aSThomas Huth 
52fcf5ef2aSThomas Huth /*
53fcf5ef2aSThomas Huth  * arm_set_cpu_off:
54fcf5ef2aSThomas Huth  * @cpuid: the id of the CPU we want to stop/shut down.
55fcf5ef2aSThomas Huth  *
56fcf5ef2aSThomas Huth  * Stop the cpu designated by @cpuid.
57fcf5ef2aSThomas Huth  *
58fcf5ef2aSThomas Huth  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
59fcf5ef2aSThomas Huth  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
60fcf5ef2aSThomas Huth  * QEMU_ARM_POWERCTL_IS_OFF if CPU is already off
61fcf5ef2aSThomas Huth  */
62fcf5ef2aSThomas Huth 
63fcf5ef2aSThomas Huth int arm_set_cpu_off(uint64_t cpuid);
64fcf5ef2aSThomas Huth 
65fcf5ef2aSThomas Huth /*
66fcf5ef2aSThomas Huth  * arm_reset_cpu:
67fcf5ef2aSThomas Huth  * @cpuid: the id of the CPU we want to reset.
68fcf5ef2aSThomas Huth  *
69fcf5ef2aSThomas Huth  * Reset the cpu designated by @cpuid.
70fcf5ef2aSThomas Huth  *
71fcf5ef2aSThomas Huth  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
72fcf5ef2aSThomas Huth  * QEMU_ARM_POWERCTL_INVALID_PARAM if bad parameters are provided.
73fcf5ef2aSThomas Huth  * QEMU_ARM_POWERCTL_IS_OFF if CPU is off
74fcf5ef2aSThomas Huth  */
75fcf5ef2aSThomas Huth int arm_reset_cpu(uint64_t cpuid);
76fcf5ef2aSThomas Huth 
77*ea824b97SPeter Maydell /*
78*ea824b97SPeter Maydell  * arm_set_cpu_on_and_reset:
79*ea824b97SPeter Maydell  * @cpuid: the id of the CPU we want to star
80*ea824b97SPeter Maydell  *
81*ea824b97SPeter Maydell  * Start the cpu designated by @cpuid and put it through its normal
82*ea824b97SPeter Maydell  * CPU reset process. The CPU will start in the way it is architected
83*ea824b97SPeter Maydell  * to start after a power-on reset.
84*ea824b97SPeter Maydell  *
85*ea824b97SPeter Maydell  * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
86*ea824b97SPeter Maydell  * QEMU_ARM_POWERCTL_INVALID_PARAM if there is no CPU with that ID.
87*ea824b97SPeter Maydell  * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU is already on.
88*ea824b97SPeter Maydell  * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is already partway through
89*ea824b97SPeter Maydell  * powering on.
90*ea824b97SPeter Maydell  */
91*ea824b97SPeter Maydell int arm_set_cpu_on_and_reset(uint64_t cpuid);
92*ea824b97SPeter Maydell 
93fcf5ef2aSThomas Huth #endif
94