blob: 3554667e5093cb0cf85ee280c5db944c3975041c [file] [log] [blame]
Soby Mathew49473e42015-06-10 13:49:59 +01001/*
Soby Mathew0d786072016-03-24 16:56:29 +00002 * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
Soby Mathew49473e42015-06-10 13:49:59 +01003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __PSCI_COMPAT_H__
32#define __PSCI_COMPAT_H__
33
34#include <arch.h>
35#include <platform_def.h>
36
37#ifndef __ASSEMBLY__
38/*
39 * The below declarations are to enable compatibility for the platform ports
40 * using the old platform interface and psci helpers.
41 */
42#define PLAT_MAX_PWR_LVL PLATFORM_MAX_AFFLVL
43#define PLAT_NUM_PWR_DOMAINS PLATFORM_NUM_AFFS
44
45/*******************************************************************************
46 * PSCI affinity related constants. An affinity instance could
47 * be present or absent physically to cater for asymmetric topologies.
48 ******************************************************************************/
49#define PSCI_AFF_ABSENT 0x0
50#define PSCI_AFF_PRESENT 0x1
51
52#define PSCI_STATE_ON 0x0
53#define PSCI_STATE_OFF 0x1
54#define PSCI_STATE_ON_PENDING 0x2
55#define PSCI_STATE_SUSPEND 0x3
56
57/*
58 * Using the compatibility platform interfaces means that the local states
59 * used in psci_power_state_t need to only convey whether its power down
60 * or standby state. The onus is on the platform port to do the right thing
61 * including the state coordination in case multiple power down states are
62 * involved. Hence if we assume 3 generic states viz, run, standby and
63 * power down, we can assign 1 and 2 to standby and power down respectively.
64 */
65#define PLAT_MAX_RET_STATE 1
66#define PLAT_MAX_OFF_STATE 2
67
Soby Mathew011ca182015-07-29 17:05:03 +010068/*
69 * Macro to represent invalid affinity level within PSCI.
70 */
71#define PSCI_INVALID_DATA -1
Soby Mathew49473e42015-06-10 13:49:59 +010072
73#define psci_get_pstate_afflvl(pstate) psci_get_pstate_pwrlvl(pstate)
74
75/*
76 * This array stores the 'power_state' requests of each CPU during
77 * CPU_SUSPEND and SYSTEM_SUSPEND which will be populated by the
78 * compatibility layer when appropriate platform hooks are invoked.
79 */
80extern unsigned int psci_power_state_compat[PLATFORM_CORE_COUNT];
81
82/*******************************************************************************
83 * Structure populated by platform specific code to export routines which
84 * perform common low level pm functions
85 ******************************************************************************/
86typedef struct plat_pm_ops {
87 void (*affinst_standby)(unsigned int power_state);
88 int (*affinst_on)(unsigned long mpidr,
89 unsigned long sec_entrypoint,
90 unsigned int afflvl,
91 unsigned int state);
92 void (*affinst_off)(unsigned int afflvl, unsigned int state);
93 void (*affinst_suspend)(unsigned long sec_entrypoint,
94 unsigned int afflvl,
95 unsigned int state);
96 void (*affinst_on_finish)(unsigned int afflvl, unsigned int state);
97 void (*affinst_suspend_finish)(unsigned int afflvl,
98 unsigned int state);
99 void (*system_off)(void) __dead2;
100 void (*system_reset)(void) __dead2;
101 int (*validate_power_state)(unsigned int power_state);
102 int (*validate_ns_entrypoint)(unsigned long ns_entrypoint);
103 unsigned int (*get_sys_suspend_power_state)(void);
104} plat_pm_ops_t;
105
106/*******************************************************************************
107 * Function & Data prototypes to enable compatibility for older platform ports
108 ******************************************************************************/
109int psci_get_suspend_stateid_by_mpidr(unsigned long);
110int psci_get_suspend_stateid(void);
111int psci_get_suspend_powerstate(void);
112unsigned int psci_get_max_phys_off_afflvl(void);
113int psci_get_suspend_afflvl(void);
114
115#endif /* ____ASSEMBLY__ */
116#endif /* __PSCI_COMPAT_H__ */