apusys_security_ctrl_plat.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2023, 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. /* Vendor header */
  10. #include "apusys_security_ctrl_plat.h"
  11. static void apusys_domain_remap_init(void)
  12. {
  13. const uint32_t remap_domains[] = {
  14. D0_REMAP_DOMAIN, D1_REMAP_DOMAIN, D2_REMAP_DOMAIN, D3_REMAP_DOMAIN,
  15. D4_REMAP_DOMAIN, D5_REMAP_DOMAIN, D6_REMAP_DOMAIN, D7_REMAP_DOMAIN,
  16. D8_REMAP_DOMAIN, D9_REMAP_DOMAIN, D10_REMAP_DOMAIN, D11_REMAP_DOMAIN,
  17. D12_REMAP_DOMAIN, D13_REMAP_DOMAIN, D14_REMAP_DOMAIN, D15_REMAP_DOMAIN
  18. };
  19. uint32_t lower_domain = 0;
  20. uint32_t higher_domain = 0;
  21. int i;
  22. for (i = 0; i < ARRAY_SIZE(remap_domains); i++) {
  23. if (i < REG_DOMAIN_NUM) {
  24. lower_domain |= (remap_domains[i] << (i * REG_DOMAIN_BITS));
  25. } else {
  26. higher_domain |= (remap_domains[i] <<
  27. ((i - REG_DOMAIN_NUM) * REG_DOMAIN_BITS));
  28. }
  29. }
  30. mmio_write_32(SOC2APU_SET1_0, lower_domain);
  31. mmio_write_32(SOC2APU_SET1_1, higher_domain);
  32. mmio_setbits_32(APU_SEC_CON, DOMAIN_REMAP_SEL);
  33. }
  34. void apusys_security_ctrl_init(void)
  35. {
  36. apusys_domain_remap_init();
  37. }