Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 7 | #ifndef PSCI_COMPAT_H |
| 8 | #define PSCI_COMPAT_H |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 9 | |
| 10 | #include <arch.h> |
| 11 | #include <platform_def.h> |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 12 | #include <utils_def.h> |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 13 | |
| 14 | #ifndef __ASSEMBLY__ |
| 15 | /* |
| 16 | * The below declarations are to enable compatibility for the platform ports |
| 17 | * using the old platform interface and psci helpers. |
| 18 | */ |
| 19 | #define PLAT_MAX_PWR_LVL PLATFORM_MAX_AFFLVL |
| 20 | #define PLAT_NUM_PWR_DOMAINS PLATFORM_NUM_AFFS |
| 21 | |
| 22 | /******************************************************************************* |
| 23 | * PSCI affinity related constants. An affinity instance could |
| 24 | * be present or absent physically to cater for asymmetric topologies. |
| 25 | ******************************************************************************/ |
| 26 | #define PSCI_AFF_ABSENT 0x0 |
| 27 | #define PSCI_AFF_PRESENT 0x1 |
| 28 | |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 29 | #define PSCI_STATE_ON U(0x0) |
| 30 | #define PSCI_STATE_OFF U(0x1) |
| 31 | #define PSCI_STATE_ON_PENDING U(0x2) |
| 32 | #define PSCI_STATE_SUSPEND U(0x3) |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 33 | |
| 34 | /* |
| 35 | * Using the compatibility platform interfaces means that the local states |
| 36 | * used in psci_power_state_t need to only convey whether its power down |
| 37 | * or standby state. The onus is on the platform port to do the right thing |
| 38 | * including the state coordination in case multiple power down states are |
| 39 | * involved. Hence if we assume 3 generic states viz, run, standby and |
| 40 | * power down, we can assign 1 and 2 to standby and power down respectively. |
| 41 | */ |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 42 | #define PLAT_MAX_RET_STATE U(1) |
| 43 | #define PLAT_MAX_OFF_STATE U(2) |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 44 | |
Soby Mathew | 011ca18 | 2015-07-29 17:05:03 +0100 | [diff] [blame] | 45 | /* |
| 46 | * Macro to represent invalid affinity level within PSCI. |
| 47 | */ |
| 48 | #define PSCI_INVALID_DATA -1 |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 49 | |
| 50 | #define psci_get_pstate_afflvl(pstate) psci_get_pstate_pwrlvl(pstate) |
| 51 | |
| 52 | /* |
| 53 | * This array stores the 'power_state' requests of each CPU during |
| 54 | * CPU_SUSPEND and SYSTEM_SUSPEND which will be populated by the |
| 55 | * compatibility layer when appropriate platform hooks are invoked. |
| 56 | */ |
| 57 | extern unsigned int psci_power_state_compat[PLATFORM_CORE_COUNT]; |
| 58 | |
| 59 | /******************************************************************************* |
| 60 | * Structure populated by platform specific code to export routines which |
| 61 | * perform common low level pm functions |
| 62 | ******************************************************************************/ |
| 63 | typedef struct plat_pm_ops { |
| 64 | void (*affinst_standby)(unsigned int power_state); |
| 65 | int (*affinst_on)(unsigned long mpidr, |
| 66 | unsigned long sec_entrypoint, |
| 67 | unsigned int afflvl, |
| 68 | unsigned int state); |
| 69 | void (*affinst_off)(unsigned int afflvl, unsigned int state); |
| 70 | void (*affinst_suspend)(unsigned long sec_entrypoint, |
| 71 | unsigned int afflvl, |
| 72 | unsigned int state); |
| 73 | void (*affinst_on_finish)(unsigned int afflvl, unsigned int state); |
| 74 | void (*affinst_suspend_finish)(unsigned int afflvl, |
| 75 | unsigned int state); |
| 76 | void (*system_off)(void) __dead2; |
| 77 | void (*system_reset)(void) __dead2; |
| 78 | int (*validate_power_state)(unsigned int power_state); |
| 79 | int (*validate_ns_entrypoint)(unsigned long ns_entrypoint); |
| 80 | unsigned int (*get_sys_suspend_power_state)(void); |
| 81 | } plat_pm_ops_t; |
| 82 | |
| 83 | /******************************************************************************* |
| 84 | * Function & Data prototypes to enable compatibility for older platform ports |
| 85 | ******************************************************************************/ |
| 86 | int psci_get_suspend_stateid_by_mpidr(unsigned long); |
| 87 | int psci_get_suspend_stateid(void); |
| 88 | int psci_get_suspend_powerstate(void); |
| 89 | unsigned int psci_get_max_phys_off_afflvl(void); |
| 90 | int psci_get_suspend_afflvl(void); |
| 91 | |
| 92 | #endif /* ____ASSEMBLY__ */ |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 93 | #endif /* PSCI_COMPAT_H */ |