Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 1 | /* |
Stephan Gerhold | f0ed728 | 2022-09-16 10:45:19 +0200 | [diff] [blame] | 2 | * Copyright (c) 2022, Stephan Gerhold <stephan@gerhold.net> |
Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 3 | * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. |
| 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
| 8 | #include <arch.h> |
| 9 | #include <plat/common/platform.h> |
| 10 | |
| 11 | #include <platform_def.h> |
| 12 | |
Stephan Gerhold | f0ed728 | 2022-09-16 10:45:19 +0200 | [diff] [blame] | 13 | static const unsigned char plat_power_domain_tree_desc[] = { |
Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 14 | PLATFORM_SYSTEM_COUNT, |
| 15 | PLATFORM_CLUSTER_COUNT, |
Stephan Gerhold | f0ed728 | 2022-09-16 10:45:19 +0200 | [diff] [blame] | 16 | PLATFORM_CPUS_PER_CLUSTER, |
| 17 | #if PLATFORM_CLUSTER_COUNT > 1 |
| 18 | PLATFORM_CPUS_PER_CLUSTER, |
| 19 | #endif |
Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 20 | }; |
| 21 | |
| 22 | int plat_core_pos_by_mpidr(u_register_t mpidr) |
| 23 | { |
Stephan Gerhold | f0ed728 | 2022-09-16 10:45:19 +0200 | [diff] [blame] | 24 | unsigned int cluster = MPIDR_AFFLVL1_VAL(mpidr); |
Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 25 | unsigned int core = MPIDR_AFFLVL0_VAL(mpidr); |
| 26 | |
| 27 | if (MPIDR_AFFLVL3_VAL(mpidr) > 0 || |
| 28 | MPIDR_AFFLVL2_VAL(mpidr) > 0 || |
Stephan Gerhold | f0ed728 | 2022-09-16 10:45:19 +0200 | [diff] [blame] | 29 | cluster >= PLATFORM_CLUSTER_COUNT || |
| 30 | core >= PLATFORM_CPUS_PER_CLUSTER) { |
Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 31 | return -1; |
| 32 | } |
Stephan Gerhold | f0ed728 | 2022-09-16 10:45:19 +0200 | [diff] [blame] | 33 | return core | (cluster << PLATFORM_CPU_PER_CLUSTER_SHIFT); |
Stephan Gerhold | 14fdf07 | 2021-12-01 20:01:11 +0100 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | const unsigned char *plat_get_power_domain_tree_desc(void) |
| 37 | { |
| 38 | return plat_power_domain_tree_desc; |
| 39 | } |