Varun Wadekar | 91535cd | 2020-03-12 14:32:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, NVIDIA Corporation. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <stddef.h> |
| 9 | |
| 10 | #include <platform.h> |
| 11 | #include <psci.h> |
| 12 | #include <utils_def.h> |
| 13 | |
| 14 | /* |
| 15 | * State IDs for local power states |
| 16 | */ |
| 17 | #define TEGRA194_RUN_STATE_ID U(0) /* Valid for CPUs and Clusters */ |
| 18 | #define TEGRA194_CORE_RETN_STATE_ID U(6) /* Valid for only CPUs */ |
| 19 | #define TEGRA194_CORE_OFF_STATE_ID U(7) /* Valid for CPUs and Clusters */ |
| 20 | #define TEGRA194_SOC_OFF_STATE_ID U(2) /* Valid for the System */ |
| 21 | |
| 22 | /* |
| 23 | * Suspend depth definitions for each power state |
| 24 | */ |
| 25 | typedef enum { |
| 26 | TEGRA194_RUN_DEPTH = 0, |
| 27 | TEGRA194_CORE_RETENTION_DEPTH, |
| 28 | TEGRA194_CORE_OFF_DEPTH, |
| 29 | TEGRA194_SYSTEM_OFF_DEPTH, |
| 30 | } suspend_depth_t; |
| 31 | |
| 32 | /* The state property array with details of idle state possible for the core */ |
| 33 | static const plat_state_prop_t core_state_prop[] = { |
| 34 | {TEGRA194_CORE_RETENTION_DEPTH, TEGRA194_CORE_RETN_STATE_ID, PSTATE_TYPE_STANDBY}, |
| 35 | {0}, |
| 36 | }; |
| 37 | |
| 38 | /* |
| 39 | * The state property array with details of idle state possible |
| 40 | * for the cluster |
| 41 | */ |
| 42 | static const plat_state_prop_t cluster_state_prop[] = { |
| 43 | {TEGRA194_CORE_OFF_DEPTH, TEGRA194_CORE_RETN_STATE_ID, PSTATE_TYPE_STANDBY}, |
| 44 | {0}, |
| 45 | }; |
| 46 | |
| 47 | /* |
| 48 | * The state property array with details of idle state possible |
| 49 | * for the system. Currently Tegra194 does not support CPU SUSPEND |
| 50 | * at system power level. |
| 51 | */ |
| 52 | static const plat_state_prop_t system_state_prop[] = { |
| 53 | {TEGRA194_SYSTEM_OFF_DEPTH, TEGRA194_SOC_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN}, |
| 54 | {0}, |
| 55 | }; |
| 56 | |
| 57 | /* |
| 58 | * This functions returns the plat_state_prop_t array for all the valid low |
| 59 | * power states from platform for a specified affinity level and returns NULL |
| 60 | * for an invalid affinity level. The array is expected to be NULL-terminated. |
| 61 | * This function is expected to be used by tests that need to compose the power |
| 62 | * state parameter for use in PSCI_CPU_SUSPEND API or PSCI_STAT/RESIDENCY |
| 63 | * API. |
| 64 | */ |
| 65 | const plat_state_prop_t *plat_get_state_prop(unsigned int level) |
| 66 | { |
| 67 | switch (level) { |
| 68 | case MPIDR_AFFLVL0: |
| 69 | return core_state_prop; |
| 70 | case MPIDR_AFFLVL1: |
| 71 | return cluster_state_prop; |
| 72 | case MPIDR_AFFLVL2: |
| 73 | return system_state_prop; |
| 74 | default: |
| 75 | return NULL; |
| 76 | } |
| 77 | } |