Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * ARM Power State and Coordination Interface (PSCI) header
0004  *
0005  * This header holds common PSCI defines and macros shared
0006  * by: ARM kernel, ARM64 kernel, KVM ARM/ARM64 and user space.
0007  *
0008  * Copyright (C) 2014 Linaro Ltd.
0009  * Author: Anup Patel <anup.patel@linaro.org>
0010  */
0011 
0012 #ifndef _UAPI_LINUX_PSCI_H
0013 #define _UAPI_LINUX_PSCI_H
0014 
0015 /*
0016  * PSCI v0.1 interface
0017  *
0018  * The PSCI v0.1 function numbers are implementation defined.
0019  *
0020  * Only PSCI return values such as: SUCCESS, NOT_SUPPORTED,
0021  * INVALID_PARAMS, and DENIED defined below are applicable
0022  * to PSCI v0.1.
0023  */
0024 
0025 /* PSCI v0.2 interface */
0026 #define PSCI_0_2_FN_BASE            0x84000000
0027 #define PSCI_0_2_FN(n)              (PSCI_0_2_FN_BASE + (n))
0028 #define PSCI_0_2_64BIT              0x40000000
0029 #define PSCI_0_2_FN64_BASE          \
0030                     (PSCI_0_2_FN_BASE + PSCI_0_2_64BIT)
0031 #define PSCI_0_2_FN64(n)            (PSCI_0_2_FN64_BASE + (n))
0032 
0033 #define PSCI_0_2_FN_PSCI_VERSION        PSCI_0_2_FN(0)
0034 #define PSCI_0_2_FN_CPU_SUSPEND         PSCI_0_2_FN(1)
0035 #define PSCI_0_2_FN_CPU_OFF         PSCI_0_2_FN(2)
0036 #define PSCI_0_2_FN_CPU_ON          PSCI_0_2_FN(3)
0037 #define PSCI_0_2_FN_AFFINITY_INFO       PSCI_0_2_FN(4)
0038 #define PSCI_0_2_FN_MIGRATE         PSCI_0_2_FN(5)
0039 #define PSCI_0_2_FN_MIGRATE_INFO_TYPE       PSCI_0_2_FN(6)
0040 #define PSCI_0_2_FN_MIGRATE_INFO_UP_CPU     PSCI_0_2_FN(7)
0041 #define PSCI_0_2_FN_SYSTEM_OFF          PSCI_0_2_FN(8)
0042 #define PSCI_0_2_FN_SYSTEM_RESET        PSCI_0_2_FN(9)
0043 
0044 #define PSCI_0_2_FN64_CPU_SUSPEND       PSCI_0_2_FN64(1)
0045 #define PSCI_0_2_FN64_CPU_ON            PSCI_0_2_FN64(3)
0046 #define PSCI_0_2_FN64_AFFINITY_INFO     PSCI_0_2_FN64(4)
0047 #define PSCI_0_2_FN64_MIGRATE           PSCI_0_2_FN64(5)
0048 #define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU   PSCI_0_2_FN64(7)
0049 
0050 #define PSCI_1_0_FN_PSCI_FEATURES       PSCI_0_2_FN(10)
0051 #define PSCI_1_0_FN_SYSTEM_SUSPEND      PSCI_0_2_FN(14)
0052 #define PSCI_1_0_FN_SET_SUSPEND_MODE        PSCI_0_2_FN(15)
0053 #define PSCI_1_1_FN_SYSTEM_RESET2       PSCI_0_2_FN(18)
0054 
0055 #define PSCI_1_0_FN64_SYSTEM_SUSPEND        PSCI_0_2_FN64(14)
0056 #define PSCI_1_1_FN64_SYSTEM_RESET2     PSCI_0_2_FN64(18)
0057 
0058 /* PSCI v0.2 power state encoding for CPU_SUSPEND function */
0059 #define PSCI_0_2_POWER_STATE_ID_MASK        0xffff
0060 #define PSCI_0_2_POWER_STATE_ID_SHIFT       0
0061 #define PSCI_0_2_POWER_STATE_TYPE_SHIFT     16
0062 #define PSCI_0_2_POWER_STATE_TYPE_MASK      \
0063                 (0x1 << PSCI_0_2_POWER_STATE_TYPE_SHIFT)
0064 #define PSCI_0_2_POWER_STATE_AFFL_SHIFT     24
0065 #define PSCI_0_2_POWER_STATE_AFFL_MASK      \
0066                 (0x3 << PSCI_0_2_POWER_STATE_AFFL_SHIFT)
0067 
0068 /* PSCI extended power state encoding for CPU_SUSPEND function */
0069 #define PSCI_1_0_EXT_POWER_STATE_ID_MASK    0xfffffff
0070 #define PSCI_1_0_EXT_POWER_STATE_ID_SHIFT   0
0071 #define PSCI_1_0_EXT_POWER_STATE_TYPE_SHIFT 30
0072 #define PSCI_1_0_EXT_POWER_STATE_TYPE_MASK  \
0073                 (0x1 << PSCI_1_0_EXT_POWER_STATE_TYPE_SHIFT)
0074 
0075 /* PSCI v0.2 affinity level state returned by AFFINITY_INFO */
0076 #define PSCI_0_2_AFFINITY_LEVEL_ON      0
0077 #define PSCI_0_2_AFFINITY_LEVEL_OFF     1
0078 #define PSCI_0_2_AFFINITY_LEVEL_ON_PENDING  2
0079 
0080 /* PSCI v0.2 multicore support in Trusted OS returned by MIGRATE_INFO_TYPE */
0081 #define PSCI_0_2_TOS_UP_MIGRATE         0
0082 #define PSCI_0_2_TOS_UP_NO_MIGRATE      1
0083 #define PSCI_0_2_TOS_MP             2
0084 
0085 /* PSCI v1.1 reset type encoding for SYSTEM_RESET2 */
0086 #define PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET   0
0087 #define PSCI_1_1_RESET_TYPE_VENDOR_START    0x80000000U
0088 
0089 /* PSCI version decoding (independent of PSCI version) */
0090 #define PSCI_VERSION_MAJOR_SHIFT        16
0091 #define PSCI_VERSION_MINOR_MASK         \
0092         ((1U << PSCI_VERSION_MAJOR_SHIFT) - 1)
0093 #define PSCI_VERSION_MAJOR_MASK         ~PSCI_VERSION_MINOR_MASK
0094 #define PSCI_VERSION_MAJOR(ver)         \
0095         (((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT)
0096 #define PSCI_VERSION_MINOR(ver)         \
0097         ((ver) & PSCI_VERSION_MINOR_MASK)
0098 #define PSCI_VERSION(maj, min)                      \
0099     ((((maj) << PSCI_VERSION_MAJOR_SHIFT) & PSCI_VERSION_MAJOR_MASK) | \
0100      ((min) & PSCI_VERSION_MINOR_MASK))
0101 
0102 /* PSCI features decoding (>=1.0) */
0103 #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT  1
0104 #define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK   \
0105             (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT)
0106 
0107 #define PSCI_1_0_OS_INITIATED           BIT(0)
0108 #define PSCI_1_0_SUSPEND_MODE_PC        0
0109 #define PSCI_1_0_SUSPEND_MODE_OSI       1
0110 
0111 /* PSCI return values (inclusive of all PSCI versions) */
0112 #define PSCI_RET_SUCCESS            0
0113 #define PSCI_RET_NOT_SUPPORTED          -1
0114 #define PSCI_RET_INVALID_PARAMS         -2
0115 #define PSCI_RET_DENIED             -3
0116 #define PSCI_RET_ALREADY_ON         -4
0117 #define PSCI_RET_ON_PENDING         -5
0118 #define PSCI_RET_INTERNAL_FAILURE       -6
0119 #define PSCI_RET_NOT_PRESENT            -7
0120 #define PSCI_RET_DISABLED           -8
0121 #define PSCI_RET_INVALID_ADDRESS        -9
0122 
0123 #endif /* _UAPI_LINUX_PSCI_H */