bl31_plat_setup.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2015-2020, Renesas Electronics Corporation. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #include <stddef.h>
  8. #include <arch.h>
  9. #include <arch_helpers.h>
  10. #include <bl31/bl31.h>
  11. #include <common/bl_common.h>
  12. #include <common/debug.h>
  13. #include <drivers/arm/cci.h>
  14. #include <drivers/console.h>
  15. #include <lib/mmio.h>
  16. #include <plat/common/platform.h>
  17. #include "pwrc.h"
  18. #include "rcar_def.h"
  19. #include "rcar_private.h"
  20. #include "rcar_version.h"
  21. static const uint64_t BL31_RO_BASE = BL_CODE_BASE;
  22. static const uint64_t BL31_RO_LIMIT = BL_CODE_END;
  23. #if USE_COHERENT_MEM
  24. static const uint64_t BL31_COHERENT_RAM_BASE = BL_COHERENT_RAM_BASE;
  25. static const uint64_t BL31_COHERENT_RAM_LIMIT = BL_COHERENT_RAM_END;
  26. #endif /* USE_COHERENT_MEM */
  27. extern void plat_rcar_gic_driver_init(void);
  28. extern void plat_rcar_gic_init(void);
  29. u_register_t rcar_boot_mpidr;
  30. static int cci_map[] = {
  31. CCI500_CLUSTER0_SL_IFACE_IX_FOR_M3,
  32. CCI500_CLUSTER1_SL_IFACE_IX_FOR_M3
  33. };
  34. void plat_cci_init(void)
  35. {
  36. uint32_t prd;
  37. prd = mmio_read_32(RCAR_PRR) & (PRR_PRODUCT_MASK | PRR_CUT_MASK);
  38. if (PRR_PRODUCT_H3_CUT10 == prd || PRR_PRODUCT_H3_CUT11 == prd) {
  39. cci_map[0U] = CCI500_CLUSTER0_SL_IFACE_IX;
  40. cci_map[1U] = CCI500_CLUSTER1_SL_IFACE_IX;
  41. }
  42. cci_init(RCAR_CCI_BASE, cci_map, ARRAY_SIZE(cci_map));
  43. }
  44. void plat_cci_enable(void)
  45. {
  46. cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
  47. }
  48. void plat_cci_disable(void)
  49. {
  50. cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
  51. }
  52. struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type)
  53. {
  54. bl2_to_bl31_params_mem_t *from_bl2 = (bl2_to_bl31_params_mem_t *)
  55. PARAMS_BASE;
  56. entry_point_info_t *next_image_info;
  57. next_image_info = (type == NON_SECURE) ?
  58. &from_bl2->bl33_ep_info : &from_bl2->bl32_ep_info;
  59. return next_image_info->pc ? next_image_info : NULL;
  60. }
  61. void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
  62. u_register_t arg2, u_register_t arg3)
  63. {
  64. rcar_console_runtime_init();
  65. NOTICE("BL3-1 : Rev.%s\n", version_of_renesas);
  66. #if RCAR_LSI != RCAR_D3
  67. if (rcar_pwrc_get_cluster() == RCAR_CLUSTER_A53A57) {
  68. plat_cci_init();
  69. plat_cci_enable();
  70. }
  71. #endif /* RCAR_LSI != RCAR_D3 */
  72. }
  73. void bl31_plat_arch_setup(void)
  74. {
  75. rcar_configure_mmu_el3(BL31_BASE,
  76. BL31_LIMIT - BL31_BASE,
  77. BL31_RO_BASE, BL31_RO_LIMIT
  78. #if USE_COHERENT_MEM
  79. , BL31_COHERENT_RAM_BASE, BL31_COHERENT_RAM_LIMIT
  80. #endif /* USE_COHERENT_MEM */
  81. );
  82. rcar_pwrc_code_copy_to_system_ram();
  83. }
  84. void bl31_platform_setup(void)
  85. {
  86. plat_rcar_gic_driver_init();
  87. plat_rcar_gic_init();
  88. /* enable the system level generic timer */
  89. mmio_write_32(RCAR_CNTC_BASE + CNTCR_OFF, CNTCR_FCREQ(U(0)) | CNTCR_EN);
  90. rcar_pwrc_setup();
  91. #if 0
  92. /*
  93. * TODO: there is a broad number of rcar-gen3 SoC configurations; to
  94. * support all of them, Renesas use the pwrc driver to discover what
  95. * cores are on/off before announcing the topology.
  96. * This code hasnt been ported yet
  97. */
  98. rcar_setup_topology();
  99. #endif
  100. /*
  101. * mask should match the kernel's MPIDR_HWID_BITMASK so the core can be
  102. * identified during cpuhotplug (check the kernel's psci migrate set of
  103. * functions
  104. */
  105. rcar_boot_mpidr = read_mpidr_el1() & 0x0000ffffU;
  106. rcar_pwrc_all_disable_interrupt_wakeup();
  107. }