rpi3_bl1_setup.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2015-2024, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <arch.h>
  8. #include <arch_helpers.h>
  9. #include <common/bl_common.h>
  10. #include <common/debug.h>
  11. #include <lib/mmio.h>
  12. #include <lib/xlat_tables/xlat_mmu_helpers.h>
  13. #include <lib/xlat_tables/xlat_tables_defs.h>
  14. #include <drivers/generic_delay_timer.h>
  15. #include <plat/common/platform.h>
  16. #include <rpi_shared.h>
  17. /* Data structure which holds the extents of the trusted SRAM for BL1 */
  18. static meminfo_t bl1_tzram_layout;
  19. meminfo_t *bl1_plat_sec_mem_layout(void)
  20. {
  21. return &bl1_tzram_layout;
  22. }
  23. /*******************************************************************************
  24. * Perform any BL1 specific platform actions.
  25. ******************************************************************************/
  26. void bl1_early_platform_setup(void)
  27. {
  28. /* use the 19.2 MHz clock for the architected timer */
  29. mmio_write_32(RPI3_INTC_BASE_ADDRESS + RPI3_INTC_CONTROL_OFFSET, 0);
  30. mmio_write_32(RPI3_INTC_BASE_ADDRESS + RPI3_INTC_PRESCALER_OFFSET,
  31. 0x80000000);
  32. /* Initialize the console to provide early debug support */
  33. rpi3_console_init();
  34. /*
  35. * Write the System Timer Frequency to CNTFRQ manually, this
  36. * is required to use the delay_timer functionality.
  37. */
  38. write_cntfrq_el0(plat_get_syscnt_freq2());
  39. /* Enable arch timer */
  40. generic_delay_timer_init();
  41. /* Allow BL1 to see the whole Trusted RAM */
  42. bl1_tzram_layout.total_base = BL_RAM_BASE;
  43. bl1_tzram_layout.total_size = BL_RAM_SIZE;
  44. }
  45. /******************************************************************************
  46. * Perform the very early platform specific architecture setup. This only
  47. * does basic initialization. Later architectural setup (bl1_arch_setup())
  48. * does not do anything platform specific.
  49. *****************************************************************************/
  50. void bl1_plat_arch_setup(void)
  51. {
  52. rpi3_setup_page_tables(bl1_tzram_layout.total_base,
  53. bl1_tzram_layout.total_size,
  54. BL_CODE_BASE, BL1_CODE_END,
  55. BL1_RO_DATA_BASE, BL1_RO_DATA_END
  56. #if USE_COHERENT_MEM
  57. , BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_END
  58. #endif
  59. );
  60. enable_mmu_el3(0);
  61. }
  62. void bl1_platform_setup(void)
  63. {
  64. uint32_t __unused rev;
  65. int __unused rc;
  66. rc = rpi3_vc_hardware_get_board_revision(&rev);
  67. if (rc == 0) {
  68. const char __unused *model, __unused *info;
  69. switch (rev) {
  70. case 0xA02082:
  71. model = "Raspberry Pi 3 Model B";
  72. info = "(1GB, Sony, UK)";
  73. break;
  74. case 0xA22082:
  75. model = "Raspberry Pi 3 Model B";
  76. info = "(1GB, Embest, China)";
  77. break;
  78. case 0xA020D3:
  79. model = "Raspberry Pi 3 Model B+";
  80. info = "(1GB, Sony, UK)";
  81. break;
  82. default:
  83. model = "Unknown";
  84. info = "(Unknown)";
  85. ERROR("rpi3: Unknown board revision 0x%08x\n", rev);
  86. break;
  87. }
  88. NOTICE("rpi3: Detected: %s %s [0x%08x]\n", model, info, rev);
  89. } else {
  90. ERROR("rpi3: Unable to detect board revision\n");
  91. }
  92. /* Initialise the IO layer and register platform IO devices */
  93. plat_rpi3_io_setup();
  94. }