mtk_iommu_priv.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef IOMMU_PRIV_H
  7. #define IOMMU_PRIV_H
  8. #include <common/debug.h>
  9. #include <lib/mmio.h>
  10. #include <mtk_iommu_plat.h>
  11. #include <mtk_sip_svc.h>
  12. #define LARB_CFG_ENTRY(bs, p_nr, dom) \
  13. { .base = (bs), .port_nr = (p_nr), \
  14. .dom_id = (dom), .to_sram = 0, }
  15. #define LARB_CFG_ENTRY_WITH_PATH(bs, p_nr, dom, sram) \
  16. { .base = (bs), .port_nr = (p_nr), \
  17. .dom_id = (dom), .to_sram = (sram), }
  18. #define IFR_MST_CFG_ENTRY(idx, bit) \
  19. { .cfg_addr_idx = (idx), .r_mmu_en_bit = (bit), }
  20. #define SEC_IOMMU_CFG_ENTRY(s_bs) \
  21. { .base = (s_bs), }
  22. enum IOMMU_ATF_CMD {
  23. IOMMU_ATF_CMD_CONFIG_SMI_LARB, /* For mm master to enable iommu */
  24. IOMMU_ATF_CMD_CONFIG_INFRA_IOMMU, /* For infra master to enable iommu */
  25. IOMMU_ATF_CMD_GET_SECURE_IOMMU_STATUS, /* For secure iommu translation fault report */
  26. IOMMU_ATF_CMD_COUNT,
  27. };
  28. struct mtk_smi_larb_config {
  29. uint32_t base;
  30. uint32_t port_nr;
  31. uint32_t dom_id;
  32. uint32_t to_sram;
  33. uint32_t sec_en_msk;
  34. };
  35. struct mtk_ifr_mst_config {
  36. uint8_t cfg_addr_idx;
  37. uint8_t r_mmu_en_bit;
  38. };
  39. struct mtk_secure_iommu_config {
  40. uint32_t base;
  41. };
  42. #ifdef ATF_MTK_SMI_LARB_CFG_SUPPORT
  43. /* mm smi larb security feature is used */
  44. extern struct mtk_smi_larb_config *g_larb_cfg;
  45. extern const unsigned int g_larb_num;
  46. #endif
  47. #ifdef ATF_MTK_INFRA_MASTER_CFG_SUPPORT
  48. /* infra iommu is used */
  49. extern struct mtk_ifr_mst_config *g_ifr_mst_cfg;
  50. extern const unsigned int g_ifr_mst_num;
  51. extern uint32_t *g_ifr_mst_cfg_base;
  52. extern uint32_t *g_ifr_mst_cfg_offs;
  53. extern void mtk_infra_iommu_enable_protect(void);
  54. #endif
  55. #ifdef ATF_MTK_IOMMU_CFG_SUPPORT
  56. /* secure iommu is used */
  57. extern struct mtk_secure_iommu_config *g_sec_iommu_cfg;
  58. extern const unsigned int g_sec_iommu_num;
  59. #endif
  60. #endif /* IOMMU_PRIV_H */