tegra_gicv3.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <common/bl_common.h>
  8. #include <drivers/arm/gicv3.h>
  9. #include <lib/utils.h>
  10. #include <plat/common/platform.h>
  11. #include <platform_def.h>
  12. #include <tegra_private.h>
  13. #include <tegra_def.h>
  14. /* The GICv3 driver only needs to be initialized in EL3 */
  15. static uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT];
  16. static unsigned int plat_tegra_mpidr_to_core_pos(unsigned long mpidr)
  17. {
  18. return (unsigned int)plat_core_pos_by_mpidr(mpidr);
  19. }
  20. /******************************************************************************
  21. * Tegra common helper to setup the GICv3 driver data.
  22. *****************************************************************************/
  23. void tegra_gic_setup(const interrupt_prop_t *interrupt_props,
  24. unsigned int interrupt_props_num)
  25. {
  26. /*
  27. * Tegra GIC configuration settings
  28. */
  29. static gicv3_driver_data_t tegra_gic_data;
  30. /*
  31. * Register Tegra GICv3 driver
  32. */
  33. tegra_gic_data.gicd_base = TEGRA_GICD_BASE;
  34. tegra_gic_data.gicr_base = TEGRA_GICR_BASE;
  35. tegra_gic_data.rdistif_num = PLATFORM_CORE_COUNT;
  36. tegra_gic_data.rdistif_base_addrs = rdistif_base_addrs;
  37. tegra_gic_data.mpidr_to_core_pos = plat_tegra_mpidr_to_core_pos;
  38. tegra_gic_data.interrupt_props = interrupt_props;
  39. tegra_gic_data.interrupt_props_num = interrupt_props_num;
  40. gicv3_driver_init(&tegra_gic_data);
  41. /* initialize the GICD and GICR */
  42. tegra_gic_init();
  43. }
  44. /******************************************************************************
  45. * Tegra common helper to initialize the GICv3 only driver.
  46. *****************************************************************************/
  47. void tegra_gic_init(void)
  48. {
  49. gicv3_distif_init();
  50. gicv3_rdistif_init(plat_my_core_pos());
  51. gicv3_cpuif_enable(plat_my_core_pos());
  52. }
  53. /******************************************************************************
  54. * Tegra common helper to disable the GICv3 CPU interface
  55. *****************************************************************************/
  56. void tegra_gic_cpuif_deactivate(void)
  57. {
  58. gicv3_cpuif_disable(plat_my_core_pos());
  59. }
  60. /******************************************************************************
  61. * Tegra common helper to initialize the per cpu distributor interface
  62. * in GICv3
  63. *****************************************************************************/
  64. void tegra_gic_pcpu_init(void)
  65. {
  66. gicv3_rdistif_init(plat_my_core_pos());
  67. gicv3_cpuif_enable(plat_my_core_pos());
  68. }