blob: cc80ae3030c282d37e6095c01c3998a7025916bd [file] [log] [blame]
Soby Mathew49473e42015-06-10 13:49:59 +01001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
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
68
69#define psci_get_pstate_afflvl(pstate) psci_get_pstate_pwrlvl(pstate)
70
71/*
72 * This array stores the 'power_state' requests of each CPU during
73 * CPU_SUSPEND and SYSTEM_SUSPEND which will be populated by the
74 * compatibility layer when appropriate platform hooks are invoked.
75 */
76extern unsigned int psci_power_state_compat[PLATFORM_CORE_COUNT];
77
78/*******************************************************************************
79 * Structure populated by platform specific code to export routines which
80 * perform common low level pm functions
81 ******************************************************************************/
82typedef struct plat_pm_ops {
83 void (*affinst_standby)(unsigned int power_state);
84 int (*affinst_on)(unsigned long mpidr,
85 unsigned long sec_entrypoint,
86 unsigned int afflvl,
87 unsigned int state);
88 void (*affinst_off)(unsigned int afflvl, unsigned int state);
89 void (*affinst_suspend)(unsigned long sec_entrypoint,
90 unsigned int afflvl,
91 unsigned int state);
92 void (*affinst_on_finish)(unsigned int afflvl, unsigned int state);
93 void (*affinst_suspend_finish)(unsigned int afflvl,
94 unsigned int state);
95 void (*system_off)(void) __dead2;
96 void (*system_reset)(void) __dead2;
97 int (*validate_power_state)(unsigned int power_state);
98 int (*validate_ns_entrypoint)(unsigned long ns_entrypoint);
99 unsigned int (*get_sys_suspend_power_state)(void);
100} plat_pm_ops_t;
101
102/*******************************************************************************
103 * Function & Data prototypes to enable compatibility for older platform ports
104 ******************************************************************************/
105int psci_get_suspend_stateid_by_mpidr(unsigned long);
106int psci_get_suspend_stateid(void);
107int psci_get_suspend_powerstate(void);
108unsigned int psci_get_max_phys_off_afflvl(void);
109int psci_get_suspend_afflvl(void);
110
111#endif /* ____ASSEMBLY__ */
112#endif /* __PSCI_COMPAT_H__ */