blob: 022e7bee9dd2c36bbe70343a79f32e89516509a2 [file] [log] [blame]
Varun Wadekar4d0dcc82020-06-25 19:39:27 -07001/*
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 <platform.h>
9#include <stddef.h>
10
11#include <psci.h>
12#include <utils_def.h>
13
14/*
15 * State IDs for local power states
16 */
17#define TEGRA210_RUN_STATE_ID U(0) /* Valid for CPUs and Clusters */
18#define TEGRA210_CORE_RETN_STATE_ID U(6) /* Valid for only CPUs */
19#define TEGRA210_CORE_OFF_STATE_ID U(7) /* Valid for CPUs and Clusters */
20#define TEGRA210_SOC_OFF_STATE_ID U(2) /* Valid for the System */
21
22/*
23 * Suspend depth definitions for each power state
24 */
25typedef enum {
26 TEGRA210_RUN_DEPTH = 0,
27 TEGRA210_CORE_RETENTION_DEPTH,
28 TEGRA210_CORE_OFF_DEPTH,
29 TEGRA210_SYSTEM_OFF_DEPTH
30} suspend_depth_t;
31
32/* The state property array with details of idle state possible for the core */
33static const plat_state_prop_t core_state_prop[] = {
34 {TEGRA210_CORE_RETENTION_DEPTH, TEGRA210_CORE_RETN_STATE_ID, PSTATE_TYPE_STANDBY},
35 {TEGRA210_CORE_OFF_DEPTH, TEGRA210_CORE_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN},
36 {0}
37};
38
39/*
40 * The state property array with details of idle state possible
41 * for the cluster
42 */
43static const plat_state_prop_t cluster_state_prop[] = {
44 {TEGRA210_CORE_OFF_DEPTH, TEGRA210_CORE_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN},
45 {0}
46};
47
48/*
49 * The state property array with details of idle state possible
50 * for the system. Currently Tegra210 does not support CPU SUSPEND
51 * at system power level.
52 */
53static const plat_state_prop_t system_state_prop[] = {
54 {TEGRA210_SYSTEM_OFF_DEPTH, TEGRA210_SOC_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN},
55 {0}
56};
57
58/*
59 * This functions returns the plat_state_prop_t array for all the valid low
60 * power states from platform for a specified affinity level and returns NULL
61 * for an invalid affinity level. The array is expected to be NULL-terminated.
62 * This function is expected to be used by tests that need to compose the power
63 * state parameter for use in PSCI_CPU_SUSPEND API or PSCI_STAT/RESIDENCY
64 * API.
65 */
66const plat_state_prop_t *plat_get_state_prop(unsigned int level)
67{
68 switch (level) {
69 case MPIDR_AFFLVL0:
70 return core_state_prop;
71 case MPIDR_AFFLVL1:
72 return cluster_state_prop;
73 case MPIDR_AFFLVL2:
74 return system_state_prop;
75 default:
76 return NULL;
77 }
78}