blob: 0593053512780e007801ac109f9816789618ac86 [file] [log] [blame]
Varun Wadekarb316e242015-05-19 16:48:04 +05301/*
Varun Wadekar43dad672017-01-31 14:53:37 -08002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Varun Wadekarb316e242015-05-19 16:48:04 +05303 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekarb316e242015-05-19 16:48:04 +05305 */
6
Varun Wadekara78bb1b2015-08-07 10:03:00 +05307#include <arch.h>
Varun Wadekarb316e242015-05-19 16:48:04 +05308#include <platform_def.h>
9#include <psci.h>
10
Varun Wadekara78bb1b2015-08-07 10:03:00 +053011extern const unsigned char tegra_power_domain_tree_desc[];
Varun Wadekar43dad672017-01-31 14:53:37 -080012#pragma weak plat_core_pos_by_mpidr
Varun Wadekara78bb1b2015-08-07 10:03:00 +053013
Varun Wadekarb316e242015-05-19 16:48:04 +053014/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +053015 * This function returns the Tegra default topology tree information.
Varun Wadekarb316e242015-05-19 16:48:04 +053016 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +053017const unsigned char *plat_get_power_domain_tree_desc(void)
Varun Wadekarb316e242015-05-19 16:48:04 +053018{
Varun Wadekara78bb1b2015-08-07 10:03:00 +053019 return tegra_power_domain_tree_desc;
Varun Wadekarb316e242015-05-19 16:48:04 +053020}
21
22/*******************************************************************************
23 * This function implements a part of the critical interface between the psci
Varun Wadekara78bb1b2015-08-07 10:03:00 +053024 * generic layer and the platform that allows the former to query the platform
25 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
26 * in case the MPIDR is invalid.
Varun Wadekarb316e242015-05-19 16:48:04 +053027 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +053028int plat_core_pos_by_mpidr(u_register_t mpidr)
Varun Wadekarb316e242015-05-19 16:48:04 +053029{
Varun Wadekara78bb1b2015-08-07 10:03:00 +053030 unsigned int cluster_id, cpu_id;
31
Varun Wadekara78bb1b2015-08-07 10:03:00 +053032 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
33 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
34
35 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
Varun Wadekar43dad672017-01-31 14:53:37 -080036 return PSCI_E_NOT_PRESENT;
Varun Wadekara78bb1b2015-08-07 10:03:00 +053037
38 /*
39 * Validate cpu_id by checking whether it represents a CPU in
40 * one of the two clusters present on the platform.
41 */
42 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER)
Varun Wadekar43dad672017-01-31 14:53:37 -080043 return PSCI_E_NOT_PRESENT;
Varun Wadekara78bb1b2015-08-07 10:03:00 +053044
45 return (cpu_id + (cluster_id * 4));
Varun Wadekarb316e242015-05-19 16:48:04 +053046}