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