blob: d70fea52299ed01fbc72f0d7116f1da0e5a6d074 [file] [log] [blame]
developer65014b82015-04-13 14:47:57 +08001/*
2 * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
developer65014b82015-04-13 14:47:57 +08005 */
6#include <arch.h>
developer2026bb92015-08-14 15:25:16 +08007#include <platform_def.h>
developer65014b82015-04-13 14:47:57 +08008#include <psci.h>
9
Koan-Sin Tanbc998072017-01-19 16:43:49 +080010
11const unsigned char mtk_power_domain_tree_desc[] = {
12 /* No of root nodes */
13 PLATFORM_SYSTEM_COUNT,
14 /* No of children for the root node */
15 PLATFORM_CLUSTER_COUNT,
16 /* No of children for the first cluster node */
17 PLATFORM_CLUSTER0_CORE_COUNT,
18 /* No of children for the second cluster node */
19 PLATFORM_CLUSTER1_CORE_COUNT
20};
21
22/*******************************************************************************
23 * This function returns the MT8173 default topology tree information.
24 ******************************************************************************/
25const unsigned char *plat_get_power_domain_tree_desc(void)
26{
27 return mtk_power_domain_tree_desc;
28}
29
30/*******************************************************************************
31 * This function implements a part of the critical interface between the psci
32 * generic layer and the platform that allows the former to query the platform
33 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
34 * in case the MPIDR is invalid.
35 ******************************************************************************/
36int plat_core_pos_by_mpidr(u_register_t mpidr)
37{
38 unsigned int cluster_id, cpu_id;
39
40 mpidr &= MPIDR_AFFINITY_MASK;
41
42 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
43 return -1;
44
45 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
46 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
47
48 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
49 return -1;
50
51 /*
52 * Validate cpu_id by checking whether it represents a CPU in
53 * one of the two clusters present on the platform.
54 */
55 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER)
56 return -1;
57
58 return (cpu_id + (cluster_id * 4));
59}