blob: c74faf2d99ccdbcf85079f7db500f4ce21b84170 [file] [log] [blame]
Michal Simek91794362022-08-31 16:45:14 +02001/*
Michal Simek2a47faa2023-04-14 08:43:51 +02002 * Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
Michal Simek91794362022-08-31 16:45:14 +02003 * Copyright (c) 2018-2022, Xilinx, Inc. All rights reserved.
4 * Copyright (C) 2022, Advanced Micro Devices, Inc. All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include <common/debug.h>
10#include <plat/common/platform.h>
11
12#include <plat_private.h>
13#include <platform_def.h>
14
15static const uint8_t plat_power_domain_tree_desc[] = {
16 /* Number of root nodes */
17 1,
18 /* Number of clusters */
19 PLATFORM_CLUSTER_COUNT,
20 /* Number of children for the first cluster node */
21 PLATFORM_CORE_COUNT_PER_CLUSTER,
22 /* Number of children for the second cluster node */
23 PLATFORM_CORE_COUNT_PER_CLUSTER,
24 /* Number of children for the third cluster node */
25 PLATFORM_CORE_COUNT_PER_CLUSTER,
26 /* Number of children for the fourth cluster node */
27 PLATFORM_CORE_COUNT_PER_CLUSTER,
28};
29
30const uint8_t *plat_get_power_domain_tree_desc(void)
31{
32 return plat_power_domain_tree_desc;
33}
34
35/*******************************************************************************
36 * This function implements a part of the critical interface between the psci
37 * generic layer and the platform that allows the former to query the platform
38 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
39 * in case the MPIDR is invalid.
40 ******************************************************************************/
41int32_t plat_core_pos_by_mpidr(u_register_t mpidr)
42{
43 uint32_t cluster_id, cpu_id;
44
45 mpidr &= MPIDR_AFFINITY_MASK;
46
47 cluster_id = MPIDR_AFFLVL2_VAL(mpidr);
48 cpu_id = MPIDR_AFFLVL1_VAL(mpidr);
49
50 if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
51 return -3;
52 }
53
54 /*
55 * Validate cpu_id by checking whether it represents a CPU in
56 * one of the two clusters present on the platform.
57 */
58 if (cpu_id >= PLATFORM_CORE_COUNT_PER_CLUSTER) {
59 return -1;
60 }
61
62 return (cpu_id + (cluster_id * PLATFORM_CORE_COUNT_PER_CLUSTER));
63}