Maheedhar Bollapalli | 7dbb6c1 | 2024-10-04 03:22:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2024, Advanced Micro Devices, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stddef.h> |
| 8 | |
| 9 | #include <arch.h> |
| 10 | #include <platform.h> |
| 11 | #include <psci.h> |
| 12 | |
| 13 | /* |
| 14 | * State IDs for local power states. |
| 15 | */ |
| 16 | #define VERSAL2_RETENTION_STATE_ID 1 /* Valid for only CPUs */ |
| 17 | #define VERSAL2_OFF_STATE_ID 0 /* Valid for CPUs and Clusters */ |
| 18 | |
| 19 | /* |
| 20 | * Suspend depth definitions for each power state |
| 21 | */ |
| 22 | typedef enum { |
| 23 | VERSAL2_RUN_DEPTH = 0, |
| 24 | VERSAL2_RETENTION_DEPTH, |
| 25 | VERSAL2_OFF_DEPTH, |
| 26 | } suspend_depth_t; |
| 27 | |
| 28 | /* The state property array with details of idle state possible for the core */ |
| 29 | static const plat_state_prop_t core_state_prop[] = { |
| 30 | {VERSAL2_RETENTION_DEPTH, VERSAL2_RETENTION_STATE_ID, PSTATE_TYPE_STANDBY}, |
| 31 | {VERSAL2_OFF_DEPTH, VERSAL2_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN}, |
| 32 | {0}, |
| 33 | }; |
| 34 | |
| 35 | /* The state property array with details of idle state possible for the cluster */ |
| 36 | static const plat_state_prop_t cluster_state_prop[] = { |
| 37 | {VERSAL2_OFF_DEPTH, VERSAL2_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN}, |
| 38 | {0}, |
| 39 | }; |
| 40 | |
| 41 | /* The state property array with details of idle state possible for the system level */ |
| 42 | static const plat_state_prop_t system_state_prop[] = { |
| 43 | {VERSAL2_OFF_DEPTH, VERSAL2_OFF_STATE_ID, PSTATE_TYPE_POWERDOWN}, |
| 44 | {0}, |
| 45 | }; |
| 46 | |
| 47 | const plat_state_prop_t *plat_get_state_prop(unsigned int level) |
| 48 | { |
| 49 | switch (level) { |
| 50 | case MPIDR_AFFLVL0: |
| 51 | return core_state_prop; |
| 52 | case MPIDR_AFFLVL1: |
| 53 | return cluster_state_prop; |
| 54 | case MPIDR_AFFLVL2: |
| 55 | return system_state_prop; |
| 56 | default: |
| 57 | return NULL; |
| 58 | } |
| 59 | } |