Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 1 | /* |
Varun Wadekar | 43dad67 | 2017-01-31 14:53:37 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 7 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <arch.h> |
| 10 | #include <lib/psci/psci.h> |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 11 | |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 12 | extern const unsigned char tegra_power_domain_tree_desc[]; |
Varun Wadekar | 43dad67 | 2017-01-31 14:53:37 -0800 | [diff] [blame] | 13 | #pragma weak plat_core_pos_by_mpidr |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 14 | |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 15 | /******************************************************************************* |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 16 | * This function returns the Tegra default topology tree information. |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 17 | ******************************************************************************/ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 18 | const unsigned char *plat_get_power_domain_tree_desc(void) |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 19 | { |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 20 | return tegra_power_domain_tree_desc; |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | /******************************************************************************* |
| 24 | * This function implements a part of the critical interface between the psci |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 25 | * 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 Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 28 | ******************************************************************************/ |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 29 | int plat_core_pos_by_mpidr(u_register_t mpidr) |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 30 | { |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 31 | unsigned int cluster_id, cpu_id; |
| 32 | |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 33 | 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 Wadekar | 43dad67 | 2017-01-31 14:53:37 -0800 | [diff] [blame] | 37 | return PSCI_E_NOT_PRESENT; |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 38 | |
| 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 Wadekar | 43dad67 | 2017-01-31 14:53:37 -0800 | [diff] [blame] | 44 | return PSCI_E_NOT_PRESENT; |
Varun Wadekar | a78bb1b | 2015-08-07 10:03:00 +0530 | [diff] [blame] | 45 | |
| 46 | return (cpu_id + (cluster_id * 4)); |
Varun Wadekar | b316e24 | 2015-05-19 16:48:04 +0530 | [diff] [blame] | 47 | } |