apusys_security_ctrl_plat.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2023-2024, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /* TF-A system header */
  7. #include <common/debug.h>
  8. #include <lib/mmio.h>
  9. #include "emi_mpu.h"
  10. /* Vendor header */
  11. #include "apusys_security_ctrl_plat.h"
  12. static void apusys_domain_remap_init(void)
  13. {
  14. const uint32_t remap_domains[] = {
  15. D0_REMAP_DOMAIN, D1_REMAP_DOMAIN, D2_REMAP_DOMAIN, D3_REMAP_DOMAIN,
  16. D4_REMAP_DOMAIN, D5_REMAP_DOMAIN, D6_REMAP_DOMAIN, D7_REMAP_DOMAIN,
  17. D8_REMAP_DOMAIN, D9_REMAP_DOMAIN, D10_REMAP_DOMAIN, D11_REMAP_DOMAIN,
  18. D12_REMAP_DOMAIN, D13_REMAP_DOMAIN, D14_REMAP_DOMAIN, D15_REMAP_DOMAIN
  19. };
  20. uint32_t lower_domain = 0;
  21. uint32_t higher_domain = 0;
  22. int i;
  23. for (i = 0; i < ARRAY_SIZE(remap_domains); i++) {
  24. if (i < REG_DOMAIN_NUM) {
  25. lower_domain |= (remap_domains[i] << (i * REG_DOMAIN_BITS));
  26. } else {
  27. higher_domain |= (remap_domains[i] <<
  28. ((i - REG_DOMAIN_NUM) * REG_DOMAIN_BITS));
  29. }
  30. }
  31. mmio_write_32(SOC2APU_SET1_0, lower_domain);
  32. mmio_write_32(SOC2APU_SET1_1, higher_domain);
  33. mmio_setbits_32(APU_SEC_CON, DOMAIN_REMAP_SEL);
  34. }
  35. void apusys_security_ctrl_init(void)
  36. {
  37. apusys_domain_remap_init();
  38. }
  39. int apusys_plat_setup_sec_mem(void)
  40. {
  41. return set_apu_emi_mpu_region();
  42. }