blob: 893f28ff24137b6f5b8a434ab54301b485f6ecc3 [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 Wadekarb316e242015-05-19 16:48:04 +05307#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <arch.h>
10#include <lib/psci/psci.h>
Varun Wadekarb316e242015-05-19 16:48:04 +053011
Varun Wadekara78bb1b2015-08-07 10:03:00 +053012extern const unsigned char tegra_power_domain_tree_desc[];
Varun Wadekar43dad672017-01-31 14:53:37 -080013#pragma weak plat_core_pos_by_mpidr
Varun Wadekara78bb1b2015-08-07 10:03:00 +053014
Varun Wadekarb316e242015-05-19 16:48:04 +053015/*******************************************************************************
Varun Wadekara78bb1b2015-08-07 10:03:00 +053016 * This function returns the Tegra default topology tree information.
Varun Wadekarb316e242015-05-19 16:48:04 +053017 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +053018const unsigned char *plat_get_power_domain_tree_desc(void)
Varun Wadekarb316e242015-05-19 16:48:04 +053019{
Varun Wadekara78bb1b2015-08-07 10:03:00 +053020 return tegra_power_domain_tree_desc;
Varun Wadekarb316e242015-05-19 16:48:04 +053021}
22
23/*******************************************************************************
24 * This function implements a part of the critical interface between the psci
Varun Wadekara78bb1b2015-08-07 10:03:00 +053025 * generic layer and the platform that allows the former to query the platform
26 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
27 * in case the MPIDR is invalid.
Varun Wadekarb316e242015-05-19 16:48:04 +053028 ******************************************************************************/
Varun Wadekara78bb1b2015-08-07 10:03:00 +053029int plat_core_pos_by_mpidr(u_register_t mpidr)
Varun Wadekarb316e242015-05-19 16:48:04 +053030{
Varun Wadekara78bb1b2015-08-07 10:03:00 +053031 unsigned int cluster_id, cpu_id;
32
Varun Wadekara78bb1b2015-08-07 10:03:00 +053033 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
34 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
35
36 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
Varun Wadekar43dad672017-01-31 14:53:37 -080037 return PSCI_E_NOT_PRESENT;
Varun Wadekara78bb1b2015-08-07 10:03:00 +053038
39 /*
40 * Validate cpu_id by checking whether it represents a CPU in
41 * one of the two clusters present on the platform.
42 */
43 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER)
Varun Wadekar43dad672017-01-31 14:53:37 -080044 return PSCI_E_NOT_PRESENT;
Varun Wadekara78bb1b2015-08-07 10:03:00 +053045
46 return (cpu_id + (cluster_id * 4));
Varun Wadekarb316e242015-05-19 16:48:04 +053047}