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 | */ |
| 6 | #include <arch.h> |
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 | #include <psci.h> |
| 9 | |
Koan-Sin Tan | bc99807 | 2017-01-19 16:43:49 +0800 | [diff] [blame] | 10 | #if ENABLE_PLAT_COMPAT |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 11 | unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr) |
| 12 | { |
| 13 | /* Report 1 (absent) instance at levels higher that the cluster level */ |
| 14 | if (aff_lvl > MPIDR_AFFLVL1) |
developer | 2026bb9 | 2015-08-14 15:25:16 +0800 | [diff] [blame] | 15 | return PLATFORM_SYSTEM_COUNT; |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 16 | |
| 17 | if (aff_lvl == MPIDR_AFFLVL1) |
developer | 2026bb9 | 2015-08-14 15:25:16 +0800 | [diff] [blame] | 18 | return PLATFORM_CLUSTER_COUNT; |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 19 | |
developer | 2026bb9 | 2015-08-14 15:25:16 +0800 | [diff] [blame] | 20 | return mpidr & 0x100 ? PLATFORM_CLUSTER1_CORE_COUNT : |
| 21 | PLATFORM_CLUSTER0_CORE_COUNT; |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr) |
| 25 | { |
| 26 | return aff_lvl <= MPIDR_AFFLVL2 ? PSCI_AFF_PRESENT : PSCI_AFF_ABSENT; |
| 27 | } |
| 28 | |
| 29 | int mt_setup_topology(void) |
| 30 | { |
| 31 | /* [TODO] Make topology configurable via SCC */ |
| 32 | return 0; |
| 33 | } |
Koan-Sin Tan | bc99807 | 2017-01-19 16:43:49 +0800 | [diff] [blame] | 34 | #else |
| 35 | |
| 36 | const unsigned char mtk_power_domain_tree_desc[] = { |
| 37 | /* No of root nodes */ |
| 38 | PLATFORM_SYSTEM_COUNT, |
| 39 | /* No of children for the root node */ |
| 40 | PLATFORM_CLUSTER_COUNT, |
| 41 | /* No of children for the first cluster node */ |
| 42 | PLATFORM_CLUSTER0_CORE_COUNT, |
| 43 | /* No of children for the second cluster node */ |
| 44 | PLATFORM_CLUSTER1_CORE_COUNT |
| 45 | }; |
| 46 | |
| 47 | /******************************************************************************* |
| 48 | * This function returns the MT8173 default topology tree information. |
| 49 | ******************************************************************************/ |
| 50 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 51 | { |
| 52 | return mtk_power_domain_tree_desc; |
| 53 | } |
| 54 | |
| 55 | /******************************************************************************* |
| 56 | * This function implements a part of the critical interface between the psci |
| 57 | * generic layer and the platform that allows the former to query the platform |
| 58 | * to convert an MPIDR to a unique linear index. An error code (-1) is returned |
| 59 | * in case the MPIDR is invalid. |
| 60 | ******************************************************************************/ |
| 61 | int plat_core_pos_by_mpidr(u_register_t mpidr) |
| 62 | { |
| 63 | unsigned int cluster_id, cpu_id; |
| 64 | |
| 65 | mpidr &= MPIDR_AFFINITY_MASK; |
| 66 | |
| 67 | if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) |
| 68 | return -1; |
| 69 | |
| 70 | cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK; |
| 71 | cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK; |
| 72 | |
| 73 | if (cluster_id >= PLATFORM_CLUSTER_COUNT) |
| 74 | return -1; |
| 75 | |
| 76 | /* |
| 77 | * Validate cpu_id by checking whether it represents a CPU in |
| 78 | * one of the two clusters present on the platform. |
| 79 | */ |
| 80 | if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER) |
| 81 | return -1; |
| 82 | |
| 83 | return (cpu_id + (cluster_id * 4)); |
| 84 | } |
| 85 | #endif |