smmu.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef SMMU_H
  8. #define SMMU_H
  9. #include <lib/mmio.h>
  10. #include <memctrl_v2.h>
  11. #include <tegra_def.h>
  12. #define SMMU_CBn_ACTLR (0x4U)
  13. /*******************************************************************************
  14. * SMMU Global Secure Aux. Configuration Register
  15. ******************************************************************************/
  16. #define SMMU_GSR0_SECURE_ACR 0x10U
  17. #define SMMU_GNSR_ACR (SMMU_GSR0_SECURE_ACR + 0x400U)
  18. #define SMMU_GSR0_PGSIZE_SHIFT 16U
  19. #define SMMU_GSR0_PGSIZE_4K (0U << SMMU_GSR0_PGSIZE_SHIFT)
  20. #define SMMU_GSR0_PGSIZE_64K (1U << SMMU_GSR0_PGSIZE_SHIFT)
  21. #define SMMU_ACR_CACHE_LOCK_ENABLE_BIT (1ULL << 26U)
  22. #define SMMU_GSR0_PER (0x20200U)
  23. /*******************************************************************************
  24. * SMMU Global Aux. Control Register
  25. ******************************************************************************/
  26. #define SMMU_CBn_ACTLR_CPRE_BIT (1ULL << 1U)
  27. /* SMMU IDs currently supported by the driver */
  28. enum {
  29. TEGRA_SMMU0 = 0U,
  30. TEGRA_SMMU1 = 1U,
  31. TEGRA_SMMU2 = 2U
  32. };
  33. static inline uint32_t tegra_smmu_read_32(uint32_t smmu_id, uint32_t off)
  34. {
  35. uint32_t ret = 0U;
  36. #if defined(TEGRA_SMMU0_BASE)
  37. if (smmu_id == TEGRA_SMMU0) {
  38. ret = mmio_read_32(TEGRA_SMMU0_BASE + (uint64_t)off);
  39. }
  40. #endif
  41. #if defined(TEGRA_SMMU1_BASE)
  42. if (smmu_id == TEGRA_SMMU1) {
  43. ret = mmio_read_32(TEGRA_SMMU1_BASE + (uint64_t)off);
  44. }
  45. #endif
  46. #if defined(TEGRA_SMMU2_BASE)
  47. if (smmu_id == TEGRA_SMMU2) {
  48. ret = mmio_read_32(TEGRA_SMMU2_BASE + (uint64_t)off);
  49. }
  50. #endif
  51. return ret;
  52. }
  53. static inline void tegra_smmu_write_32(uint32_t smmu_id,
  54. uint32_t off, uint32_t val)
  55. {
  56. #if defined(TEGRA_SMMU0_BASE)
  57. if (smmu_id == TEGRA_SMMU0) {
  58. mmio_write_32(TEGRA_SMMU0_BASE + (uint64_t)off, val);
  59. }
  60. #endif
  61. #if defined(TEGRA_SMMU1_BASE)
  62. if (smmu_id == TEGRA_SMMU1) {
  63. mmio_write_32(TEGRA_SMMU1_BASE + (uint64_t)off, val);
  64. }
  65. #endif
  66. #if defined(TEGRA_SMMU2_BASE)
  67. if (smmu_id == TEGRA_SMMU2) {
  68. mmio_write_32(TEGRA_SMMU2_BASE + (uint64_t)off, val);
  69. }
  70. #endif
  71. }
  72. void tegra_smmu_init(void);
  73. void tegra_smmu_verify(void);
  74. uint32_t plat_get_num_smmu_devices(void);
  75. #endif /* SMMU_H */