rcar_private.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2015-2020, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef RCAR_PRIVATE_H
  7. #define RCAR_PRIVATE_H
  8. #include <common/bl_common.h>
  9. #include <lib/bakery_lock.h>
  10. #include <lib/el3_runtime/cpu_data.h>
  11. #include <platform_def.h>
  12. typedef volatile struct mailbox {
  13. unsigned long value __aligned(CACHE_WRITEBACK_GRANULE);
  14. } mailbox_t;
  15. /*
  16. * This structure represents the superset of information that is passed to
  17. * BL31 e.g. while passing control to it from BL2 which is bl31_params
  18. * and bl31_plat_params and its elements
  19. */
  20. typedef struct bl2_to_bl31_params_mem {
  21. image_info_t bl32_image_info;
  22. image_info_t bl33_image_info;
  23. entry_point_info_t bl33_ep_info;
  24. entry_point_info_t bl32_ep_info;
  25. } bl2_to_bl31_params_mem_t;
  26. #if USE_COHERENT_MEM
  27. #define RCAR_INSTANTIATE_LOCK DEFINE_BAKERY_LOCK(rcar_lock);
  28. #define rcar_lock_init() bakery_lock_init(&rcar_lock)
  29. #define rcar_lock_get() bakery_lock_get(&rcar_lock)
  30. #define rcar_lock_release() bakery_lock_release(&rcar_lock)
  31. #else
  32. /*
  33. * Constants to specify how many bakery locks this platform implements. These
  34. * are used if the platform chooses not to use coherent memory for bakery lock
  35. * data structures.
  36. */
  37. #define RCAR_MAX_BAKERIES 2
  38. #define RCAR_PWRC_BAKERY_ID 0
  39. /*
  40. * Definition of structure which holds platform specific per-cpu data. Currently
  41. * it holds only the bakery lock information for each cpu. Constants to
  42. * specify how many bakeries this platform implements and bakery ids are
  43. * specified in rcar_def.h
  44. */
  45. typedef struct rcar_cpu_data {
  46. bakery_info_t pcpu_bakery_info[RCAR_MAX_BAKERIES];
  47. } rcar_cpu_data_t;
  48. #define RCAR_CPU_DATA_LOCK_OFFSET \
  49. __builtin_offsetof(rcar_cpu_data_t, pcpu_bakery_info)
  50. /*
  51. * Helper macros for bakery lock api when using the above rcar_cpu_data_t for
  52. * bakery lock data structures. It assumes that the bakery_info is at the
  53. * beginning of the platform specific per-cpu data.
  54. */
  55. #define rcar_lock_init(_lock_arg)
  56. #define rcar_lock_get(_lock_arg) \
  57. bakery_lock_get(_lock_arg, \
  58. CPU_DATA_PLAT_PCPU_OFFSET + RCAR_CPU_DATA_LOCK_OFFSET)
  59. #define rcar_lock_release(_lock_arg) \
  60. bakery_lock_release(_lock_arg, \
  61. CPU_DATA_PLAT_PCPU_OFFSET + RCAR_CPU_DATA_LOCK_OFFSET)
  62. /*
  63. * Ensure that the size of the RCAR specific per-cpu data structure and the size
  64. * of the memory allocated in generic per-cpu data for the platform are the same
  65. */
  66. CASSERT(sizeof(rcar_cpu_data_t) == PLAT_PCPU_DATA_SIZE,
  67. rcar_pcpu_data_size_mismatch);
  68. #endif
  69. /*
  70. * Function and variable prototypes
  71. */
  72. void rcar_configure_mmu_el3(unsigned long total_base,
  73. unsigned long total_size,
  74. unsigned long ro_start, unsigned long ro_limit
  75. #if USE_COHERENT_MEM
  76. , unsigned long coh_start, unsigned long coh_limit
  77. #endif
  78. );
  79. void rcar_setup_topology(void);
  80. void rcar_cci_disable(void);
  81. void rcar_cci_enable(void);
  82. void rcar_cci_init(void);
  83. void plat_invalidate_icache(void);
  84. void plat_cci_disable(void);
  85. void plat_cci_enable(void);
  86. void plat_cci_init(void);
  87. void mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit);
  88. void cpg_write(uintptr_t regadr, uint32_t regval);
  89. void rcar_console_boot_init(void);
  90. void rcar_console_boot_end(void);
  91. void rcar_console_runtime_init(void);
  92. void rcar_console_runtime_end(void);
  93. #endif /* RCAR_PRIVATE_H */