blob: 5c2753bbbeb0fb42fc4931edd75eab5af3606768 [file] [log] [blame]
Varun Wadekardbf8a2f2020-06-23 08:13:57 -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 TEGRA186_RUN_STATE_ID U(0) /* Valid for CPUs and Clusters */
18#define TEGRA186_CORE_RETN_STATE_ID U(6) /* Valid for only CPUs */
19#define TEGRA186_CORE_OFF_STATE_ID U(7) /* Valid for CPUs and Clusters */
20#define TEGRA186_SOC_OFF_STATE_ID U(2) /* Valid for the System */
21
22/*
23 * Suspend depth definitions for each power state
24 */
25typedef enum {
26 TEGRA186_RUN_DEPTH = 0,
27 TEGRA186_CORE_RETENTION_DEPTH,
28 TEGRA186_CORE_OFF_DEPTH,
29 TEGRA186_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 {TEGRA186_CORE_OFF_DEPTH, TEGRA186_CORE_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN},
35 {0}
36};
37
38/*
39 * The state property array with details of idle state possible
40 * for the cluster
41 */
42static const plat_state_prop_t cluster_state_prop[] = {
43 {TEGRA186_CORE_OFF_DEPTH, TEGRA186_CORE_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN},
44 {0}
45};
46
47/*
48 * The state property array with details of idle state possible
49 * for the system. Currently Tegra186 does not support CPU SUSPEND
50 * at system power level.
51 */
52static const plat_state_prop_t system_state_prop[] = {
53 {TEGRA186_SYSTEM_OFF_DEPTH, TEGRA186_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 */
65const 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}