plat_common.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright 2018-2021 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef PLAT_COMMON_H
  8. #define PLAT_COMMON_H
  9. #include <stdbool.h>
  10. #include <dcfg.h>
  11. #include <lib/el3_runtime/cpu_data.h>
  12. #include <platform_def.h>
  13. #ifdef IMAGE_BL31
  14. #define BL31_END (uintptr_t)(&__BL31_END__)
  15. /*******************************************************************************
  16. * This structure represents the superset of information that can be passed to
  17. * BL31 e.g. while passing control to it from BL2. The BL32 parameters will be
  18. * populated only if BL2 detects its presence. A pointer to a structure of this
  19. * type should be passed in X0 to BL31's cold boot entrypoint.
  20. *
  21. * Use of this structure and the X0 parameter is not mandatory: the BL31
  22. * platform code can use other mechanisms to provide the necessary information
  23. * about BL32 and BL33 to the common and SPD code.
  24. *
  25. * BL31 image information is mandatory if this structure is used. If either of
  26. * the optional BL32 and BL33 image information is not provided, this is
  27. * indicated by the respective image_info pointers being zero.
  28. ******************************************************************************/
  29. typedef struct bl31_params {
  30. param_header_t h;
  31. image_info_t *bl31_image_info;
  32. entry_point_info_t *bl32_ep_info;
  33. image_info_t *bl32_image_info;
  34. entry_point_info_t *bl33_ep_info;
  35. image_info_t *bl33_image_info;
  36. } bl31_params_t;
  37. /* BL3 utility functions */
  38. void ls_bl31_early_platform_setup(void *from_bl2,
  39. void *plat_params_from_bl2);
  40. /* LS Helper functions */
  41. unsigned int plat_my_core_mask(void);
  42. unsigned int plat_core_mask(u_register_t mpidr);
  43. unsigned int plat_core_pos(u_register_t mpidr);
  44. //unsigned int plat_my_core_pos(void);
  45. /* BL31 Data API(s) */
  46. void _init_global_data(void);
  47. void _initialize_psci(void);
  48. uint32_t _getCoreState(u_register_t core_mask);
  49. void _setCoreState(u_register_t core_mask, u_register_t core_state);
  50. /* SoC defined structure and API(s) */
  51. void soc_runtime_setup(void);
  52. void soc_init(void);
  53. void soc_platform_setup(void);
  54. void soc_early_platform_setup2(void);
  55. #endif /* IMAGE_BL31 */
  56. #ifdef IMAGE_BL2
  57. void soc_early_init(void);
  58. void soc_mem_access(void);
  59. void soc_preload_setup(void);
  60. void soc_bl2_prepare_exit(void);
  61. /* IO storage utility functions */
  62. int plat_io_setup(void);
  63. int open_backend(const uintptr_t spec);
  64. void ls_bl2_plat_arch_setup(void);
  65. void ls_bl2_el3_plat_arch_setup(void);
  66. enum boot_device {
  67. BOOT_DEVICE_IFC_NOR,
  68. BOOT_DEVICE_IFC_NAND,
  69. BOOT_DEVICE_QSPI,
  70. BOOT_DEVICE_EMMC,
  71. BOOT_DEVICE_SDHC2_EMMC,
  72. BOOT_DEVICE_FLEXSPI_NOR,
  73. BOOT_DEVICE_FLEXSPI_NAND,
  74. BOOT_DEVICE_NONE
  75. };
  76. enum boot_device get_boot_dev(void);
  77. /* DDR Related functions */
  78. #if DDR_INIT
  79. #ifdef NXP_WARM_BOOT
  80. long long init_ddr(uint32_t wrm_bt_flg);
  81. #else
  82. long long init_ddr(void);
  83. #endif
  84. #endif
  85. /* Board specific weak functions */
  86. bool board_enable_povdd(void);
  87. bool board_disable_povdd(void);
  88. void mmap_add_ddr_region_dynamically(void);
  89. #endif /* IMAGE_BL2 */
  90. typedef struct {
  91. uint64_t addr;
  92. uint64_t size;
  93. } region_info_t;
  94. typedef struct {
  95. uint64_t num_dram_regions;
  96. int64_t total_dram_size;
  97. region_info_t region[NUM_DRAM_REGIONS];
  98. } dram_regions_info_t;
  99. dram_regions_info_t *get_dram_regions_info(void);
  100. void ls_setup_page_tables(uintptr_t total_base,
  101. size_t total_size,
  102. uintptr_t code_start,
  103. uintptr_t code_limit,
  104. uintptr_t rodata_start,
  105. uintptr_t rodata_limit
  106. #if USE_COHERENT_MEM
  107. , uintptr_t coh_start,
  108. uintptr_t coh_limit
  109. #endif
  110. );
  111. #define SOC_NAME_MAX_LEN (20)
  112. /* Structure to define SoC personality */
  113. struct soc_type {
  114. char name[SOC_NAME_MAX_LEN];
  115. uint32_t version;
  116. uint8_t num_clusters;
  117. uint8_t cores_per_cluster;
  118. };
  119. void get_cluster_info(const struct soc_type *soc_list, uint8_t ps_count,
  120. uint8_t *num_clusters, uint8_t *cores_per_cluster);
  121. #define SOC_ENTRY(n, v, ncl, nc) { \
  122. .name = #n, \
  123. .version = SVR_##v, \
  124. .num_clusters = (ncl), \
  125. .cores_per_cluster = (nc)}
  126. #endif /* PLAT_COMMON_H */