Add Broadcom's code for bcm63xx support
[project/bcm63xx/atf.git] / plat / bcm / topology.c
1 /*
2 <:copyright-BRCM:2012:DUAL/GPL:standard
3
4 Copyright (c) 2012 Broadcom
5 All Rights Reserved
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License, version 2, as published by
9 the Free Software Foundation (the "GPL").
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16
17 A copy of the GPL is available at http://www.broadcom.com/licenses/GPLv2.php, or by
18 writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20
21 :>
22 */
23
24 #include <arch.h>
25 #include <platform_def.h>
26 #include "bcm_private.h"
27
28 /* The power domain tree descriptor */
29 static unsigned char power_domain_tree_desc[] = {
30 /* Number of root nodes */
31 PLATFORM_CLUSTER_COUNT,
32 /* Number of children for the first node */
33 PLATFORM_CLUSTER0_CORE_COUNT,
34 /* Number of children for the second node */
35 PLATFORM_CLUSTER1_CORE_COUNT,
36 };
37
38 /*******************************************************************************
39 * This function returns the ARM default topology tree information.
40 ******************************************************************************/
41 const unsigned char *plat_get_power_domain_tree_desc(void)
42 {
43 return power_domain_tree_desc;
44 }
45
46 /*******************************************************************************
47 * This function implements a part of the critical interface between the psci
48 * generic layer and the platform that allows the former to query the platform
49 * to convert an MPIDR to a unique linear index. An error code (-1) is returned
50 * in case the MPIDR is invalid.
51 ******************************************************************************/
52 int plat_core_pos_by_mpidr(u_register_t mpidr)
53 {
54 unsigned int cluster_id, cpu_id;
55
56 mpidr &= MPIDR_AFFINITY_MASK;
57 if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK))
58 return -1;
59
60 cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK;
61 cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK;
62
63 if (cluster_id >= PLATFORM_CLUSTER_COUNT)
64 return -1;
65
66 if (cpu_id >= PLATFORM_MAX_CPUS_PER_CLUSTER)
67 return -1;
68
69 return plat_bcm_calc_core_pos(mpidr);
70 }
71
72 /* Needed for floating point lib */
73 void raise (void) { asm("b ."); }
74