uniphier_xlat_setup.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <platform_def.h>
  8. #include <common/debug.h>
  9. #include <lib/xlat_tables/xlat_tables_v2.h>
  10. #include <plat/common/platform.h>
  11. #include "uniphier.h"
  12. struct uniphier_reg_region {
  13. uintptr_t base;
  14. size_t size;
  15. };
  16. static const struct uniphier_reg_region uniphier_reg_region[] = {
  17. [UNIPHIER_SOC_LD11] = {
  18. .base = 0x50000000UL,
  19. .size = 0x20000000UL,
  20. },
  21. [UNIPHIER_SOC_LD20] = {
  22. .base = 0x50000000UL,
  23. .size = 0x20000000UL,
  24. },
  25. [UNIPHIER_SOC_PXS3] = {
  26. .base = 0x50000000UL,
  27. .size = 0x20000000UL,
  28. },
  29. };
  30. void uniphier_mmap_setup(unsigned int soc)
  31. {
  32. VERBOSE("Trusted RAM seen by this BL image: %p - %p\n",
  33. (void *)BL_CODE_BASE, (void *)BL_END);
  34. mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
  35. round_up(BL_END, PAGE_SIZE) - BL_CODE_BASE,
  36. MT_MEMORY | MT_RW | MT_SECURE);
  37. /* remap the code section */
  38. VERBOSE("Code region: %p - %p\n",
  39. (void *)BL_CODE_BASE, (void *)BL_CODE_END);
  40. mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
  41. round_up(BL_CODE_END, PAGE_SIZE) - BL_CODE_BASE,
  42. MT_CODE | MT_SECURE);
  43. /* remap the coherent memory region */
  44. VERBOSE("Coherent region: %p - %p\n",
  45. (void *)BL_COHERENT_RAM_BASE, (void *)BL_COHERENT_RAM_END);
  46. mmap_add_region(BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_BASE,
  47. BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
  48. MT_DEVICE | MT_RW | MT_SECURE);
  49. /* register region */
  50. assert(soc < ARRAY_SIZE(uniphier_reg_region));
  51. mmap_add_region(uniphier_reg_region[soc].base,
  52. uniphier_reg_region[soc].base,
  53. uniphier_reg_region[soc].size,
  54. MT_DEVICE | MT_RW | MT_SECURE);
  55. init_xlat_tables();
  56. enable_mmu(0);
  57. #if PLAT_RO_XLAT_TABLES
  58. {
  59. int ret;
  60. ret = xlat_make_tables_readonly();
  61. if (ret) {
  62. ERROR("Failed to make translation tables read-only.");
  63. plat_error_handler(ret);
  64. }
  65. }
  66. #endif
  67. }