blob: 242e31b4b16f1281831381605f8dbdbfa0a2366b [file] [log] [blame]
Anson Huang4c28fc32018-06-05 16:12:27 +08001/*
2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <bl_common.h>
8#include <gicv3.h>
9#include <plat_imx8.h>
10#include <platform.h>
11#include <platform_def.h>
12#include <utils.h>
13
14/* the GICv3 driver only needs to be initialized in EL3 */
15uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT];
16
17/* array of Group1 secure interrupts to be configured by the gic driver */
18const unsigned int g1s_interrupt_array[] = { 6 };
19
20/* array of Group0 interrupts to be configured by the gic driver */
21const unsigned int g0_interrupt_array[] = { 7 };
22
23static unsigned int plat_imx_mpidr_to_core_pos(unsigned long mpidr)
24{
25 return (unsigned int)plat_core_pos_by_mpidr(mpidr);
26}
27
28const gicv3_driver_data_t arm_gic_data = {
29 .gicd_base = PLAT_GICD_BASE,
30 .gicr_base = PLAT_GICR_BASE,
31 .g0_interrupt_num = ARRAY_SIZE(g0_interrupt_array),
32 .g1s_interrupt_num = ARRAY_SIZE(g1s_interrupt_array),
33 .g0_interrupt_array = g0_interrupt_array,
34 .g1s_interrupt_array = g1s_interrupt_array,
35 .rdistif_num = PLATFORM_CORE_COUNT,
36 .rdistif_base_addrs = rdistif_base_addrs,
37 .mpidr_to_core_pos = plat_imx_mpidr_to_core_pos,
38};
39
40void plat_gic_driver_init(void)
41{
42 /*
43 * the GICv3 driver is initialized in EL3 and does not need
44 * to be initialized again in S-EL1. This is because the S-EL1
45 * can use GIC system registers to manage interrupts and does
46 * not need GIC interface base addresses to be configured.
47 */
48#if IMAGE_BL31
49 gicv3_driver_init(&arm_gic_data);
50#endif
51}
52
53void plat_gic_init(void)
54{
55 gicv3_distif_init();
56 gicv3_rdistif_init(plat_my_core_pos());
57 gicv3_cpuif_enable(plat_my_core_pos());
58}
59
60void plat_gic_cpuif_enable(void)
61{
62 gicv3_cpuif_enable(plat_my_core_pos());
63}
64
65void plat_gic_cpuif_disable(void)
66{
67 gicv3_cpuif_disable(plat_my_core_pos());
68}
69
70void plat_gic_pcpu_init(void)
71{
72 gicv3_rdistif_init(plat_my_core_pos());
73}