imx8mp_bl2_el3_setup.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2021 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <stdbool.h>
  8. #include <arch_helpers.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <common/desc_image_load.h>
  12. #include <common/tbbr/tbbr_img_def.h>
  13. #include <context.h>
  14. #include <drivers/arm/tzc380.h>
  15. #include <drivers/console.h>
  16. #include <drivers/generic_delay_timer.h>
  17. #include <drivers/mmc.h>
  18. #include <lib/el3_runtime/context_mgmt.h>
  19. #include <lib/mmio.h>
  20. #include <lib/optee_utils.h>
  21. #include <lib/xlat_tables/xlat_tables_v2.h>
  22. #include <imx8m_caam.h>
  23. #include "imx8mp_private.h"
  24. #include <imx_aipstz.h>
  25. #include <imx_rdc.h>
  26. #include <imx_uart.h>
  27. #include <plat/common/platform.h>
  28. #include <plat_imx8.h>
  29. #include <platform_def.h>
  30. static const struct aipstz_cfg aipstz[] = {
  31. {IMX_AIPSTZ1, 0x77777777, 0x77777777, .opacr = {0x0, 0x0, 0x0, 0x0, 0x0}, },
  32. {IMX_AIPSTZ2, 0x77777777, 0x77777777, .opacr = {0x0, 0x0, 0x0, 0x0, 0x0}, },
  33. {IMX_AIPSTZ3, 0x77777777, 0x77777777, .opacr = {0x0, 0x0, 0x0, 0x0, 0x0}, },
  34. {IMX_AIPSTZ4, 0x77777777, 0x77777777, .opacr = {0x0, 0x0, 0x0, 0x0, 0x0}, },
  35. {0},
  36. };
  37. void bl2_el3_early_platform_setup(u_register_t arg0, u_register_t arg1,
  38. u_register_t arg2, u_register_t arg3)
  39. {
  40. static console_t console;
  41. unsigned int i;
  42. /* Enable CSU NS access permission */
  43. for (i = 0U; i < 64; i++) {
  44. mmio_write_32(IMX_CSU_BASE + i * 4, 0x00ff00ff);
  45. }
  46. imx_aipstz_init(aipstz);
  47. console_imx_uart_register(IMX_BOOT_UART_BASE, IMX_BOOT_UART_CLK_IN_HZ,
  48. IMX_CONSOLE_BAUDRATE, &console);
  49. generic_delay_timer_init();
  50. /* select the CKIL source to 32K OSC */
  51. mmio_write_32(IMX_ANAMIX_BASE + ANAMIX_MISC_CTL, 0x1);
  52. /* Open handles to a FIP image */
  53. plat_imx_io_setup();
  54. }
  55. void bl2_el3_plat_arch_setup(void)
  56. {
  57. }
  58. void bl2_platform_setup(void)
  59. {
  60. }
  61. int bl2_plat_handle_post_image_load(unsigned int image_id)
  62. {
  63. int err = 0;
  64. bl_mem_params_node_t *bl_mem_params = get_bl_mem_params_node(image_id);
  65. bl_mem_params_node_t *pager_mem_params = NULL;
  66. bl_mem_params_node_t *paged_mem_params = NULL;
  67. assert(bl_mem_params);
  68. switch (image_id) {
  69. case BL32_IMAGE_ID:
  70. pager_mem_params = get_bl_mem_params_node(BL32_EXTRA1_IMAGE_ID);
  71. assert(pager_mem_params);
  72. paged_mem_params = get_bl_mem_params_node(BL32_EXTRA2_IMAGE_ID);
  73. assert(paged_mem_params);
  74. err = parse_optee_header(&bl_mem_params->ep_info,
  75. &pager_mem_params->image_info,
  76. &paged_mem_params->image_info);
  77. if (err != 0) {
  78. WARN("OPTEE header parse error.\n");
  79. }
  80. break;
  81. default:
  82. /* Do nothing in default case */
  83. break;
  84. }
  85. return err;
  86. }
  87. unsigned int plat_get_syscnt_freq2(void)
  88. {
  89. return COUNTER_FREQUENCY;
  90. }
  91. void bl2_plat_runtime_setup(void)
  92. {
  93. return;
  94. }