Nishanth Menon | f97ad37 | 2016-10-14 01:13:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Nishanth Menon | f97ad37 | 2016-10-14 01:13:49 +0000 | [diff] [blame] | 7 | #include <platform_def.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <common/bl_common.h> |
| 10 | #include <common/interrupt_props.h> |
| 11 | #include <drivers/arm/gicv3.h> |
| 12 | #include <lib/utils.h> |
| 13 | #include <plat/common/platform.h> |
| 14 | |
| 15 | #include <k3_gicv3.h> |
Nishanth Menon | f97ad37 | 2016-10-14 01:13:49 +0000 | [diff] [blame] | 16 | |
| 17 | /* The GICv3 driver only needs to be initialized in EL3 */ |
| 18 | uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT]; |
| 19 | |
| 20 | static const interrupt_prop_t k3_interrupt_props[] = { |
| 21 | PLAT_ARM_G1S_IRQ_PROPS(INTR_GROUP1S), |
| 22 | PLAT_ARM_G0_IRQ_PROPS(INTR_GROUP0) |
| 23 | }; |
| 24 | |
| 25 | static unsigned int k3_mpidr_to_core_pos(unsigned long mpidr) |
| 26 | { |
| 27 | return (unsigned int)plat_core_pos_by_mpidr(mpidr); |
| 28 | } |
| 29 | |
| 30 | gicv3_driver_data_t k3_gic_data = { |
| 31 | .rdistif_num = PLATFORM_CORE_COUNT, |
| 32 | .rdistif_base_addrs = rdistif_base_addrs, |
| 33 | .interrupt_props = k3_interrupt_props, |
| 34 | .interrupt_props_num = ARRAY_SIZE(k3_interrupt_props), |
| 35 | .mpidr_to_core_pos = k3_mpidr_to_core_pos, |
| 36 | }; |
| 37 | |
| 38 | void k3_gic_driver_init(uintptr_t gicd_base, uintptr_t gicr_base) |
| 39 | { |
| 40 | /* |
| 41 | * The GICv3 driver is initialized in EL3 and does not need |
| 42 | * to be initialized again in SEL1. This is because the S-EL1 |
| 43 | * can use GIC system registers to manage interrupts and does |
| 44 | * not need GIC interface base addresses to be configured. |
| 45 | */ |
| 46 | k3_gic_data.gicd_base = gicd_base; |
| 47 | k3_gic_data.gicr_base = gicr_base; |
| 48 | gicv3_driver_init(&k3_gic_data); |
| 49 | } |
| 50 | |
| 51 | void k3_gic_init(void) |
| 52 | { |
| 53 | gicv3_distif_init(); |
| 54 | gicv3_rdistif_init(plat_my_core_pos()); |
| 55 | gicv3_cpuif_enable(plat_my_core_pos()); |
| 56 | } |
| 57 | |
| 58 | void k3_gic_cpuif_enable(void) |
| 59 | { |
| 60 | gicv3_cpuif_enable(plat_my_core_pos()); |
| 61 | } |
| 62 | |
| 63 | void k3_gic_cpuif_disable(void) |
| 64 | { |
| 65 | gicv3_cpuif_disable(plat_my_core_pos()); |
| 66 | } |
| 67 | |
| 68 | void k3_gic_pcpu_init(void) |
| 69 | { |
| 70 | gicv3_rdistif_init(plat_my_core_pos()); |
| 71 | } |