blob: e60c7544580d40dcacf34bad74c8c73a69b825bb [file] [log] [blame]
Jeenu Viswambharan5c503042017-05-26 14:15:40 +01001/*
Olivier Deprez73ad7312022-02-04 12:30:11 +01002 * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved.
Jeenu Viswambharan5c503042017-05-26 14:15:40 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef SMMU_V3_H
8#define SMMU_V3_H
Jeenu Viswambharan5c503042017-05-26 14:15:40 +01009
10#include <stdint.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <lib/utils_def.h>
Olivier Deprez73ad7312022-02-04 12:30:11 +010012#include <platform_def.h>
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010013
14/* SMMUv3 register offsets from device base */
Alexei Fedorov6b4a5f02019-04-26 12:07:07 +010015#define SMMU_GBPA U(0x0044)
Antonio Nino Diazfeacba32018-08-21 16:12:29 +010016#define SMMU_S_IDR1 U(0x8004)
17#define SMMU_S_INIT U(0x803c)
Alexei Fedorov6b4a5f02019-04-26 12:07:07 +010018#define SMMU_S_GBPA U(0x8044)
19
Olivier Deprez73ad7312022-02-04 12:30:11 +010020/*
21 * TODO: SMMU_ROOT_PAGE_OFFSET is platform specific.
22 * Currently defined as a command line model parameter.
23 */
24#if ENABLE_RME
25
26#define SMMU_ROOT_PAGE_OFFSET (PLAT_ARM_SMMUV3_ROOT_REG_OFFSET)
27#define SMMU_ROOT_IDR0 U(SMMU_ROOT_PAGE_OFFSET + 0x0000)
28#define SMMU_ROOT_IIDR U(SMMU_ROOT_PAGE_OFFSET + 0x0008)
29#define SMMU_ROOT_CR0 U(SMMU_ROOT_PAGE_OFFSET + 0x0020)
30#define SMMU_ROOT_CR0ACK U(SMMU_ROOT_PAGE_OFFSET + 0x0024)
31#define SMMU_ROOT_GPT_BASE U(SMMU_ROOT_PAGE_OFFSET + 0x0028)
32#define SMMU_ROOT_GPT_BASE_CFG U(SMMU_ROOT_PAGE_OFFSET + 0x0030)
33#define SMMU_ROOT_GPF_FAR U(SMMU_ROOT_PAGE_OFFSET + 0x0038)
34#define SMMU_ROOT_GPT_CFG_FAR U(SMMU_ROOT_PAGE_OFFSET + 0x0040)
35#define SMMU_ROOT_TLBI U(SMMU_ROOT_PAGE_OFFSET + 0x0050)
36#define SMMU_ROOT_TLBI_CTRL U(SMMU_ROOT_PAGE_OFFSET + 0x0058)
37
38#endif /* ENABLE_RME */
39
Alexei Fedorov6b4a5f02019-04-26 12:07:07 +010040/* SMMU_GBPA register fields */
41#define SMMU_GBPA_UPDATE (1UL << 31)
42#define SMMU_GBPA_ABORT (1UL << 20)
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010043
44/* SMMU_S_IDR1 register fields */
Alexei Fedorov6b4a5f02019-04-26 12:07:07 +010045#define SMMU_S_IDR1_SECURE_IMPL (1UL << 31)
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010046
47/* SMMU_S_INIT register fields */
Alexei Fedorov6b4a5f02019-04-26 12:07:07 +010048#define SMMU_S_INIT_INV_ALL (1UL << 0)
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010049
Alexei Fedorov6b4a5f02019-04-26 12:07:07 +010050/* SMMU_S_GBPA register fields */
51#define SMMU_S_GBPA_UPDATE (1UL << 31)
52#define SMMU_S_GBPA_ABORT (1UL << 20)
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010053
Olivier Deprez73ad7312022-02-04 12:30:11 +010054/* SMMU_ROOT_IDR0 register fields */
55#define SMMU_ROOT_IDR0_ROOT_IMPL (1UL << 0)
56
57/* SMMU_ROOT_CR0 register fields */
58#define SMMU_ROOT_CR0_GPCEN (1UL << 1)
59#define SMMU_ROOT_CR0_ACCESSEN (1UL << 0)
60
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010061int smmuv3_init(uintptr_t smmu_base);
Alexei Fedorov896799a2019-05-09 12:14:40 +010062int smmuv3_security_init(uintptr_t smmu_base);
Jeenu Viswambharan5c503042017-05-26 14:15:40 +010063
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000064#endif /* SMMU_V3_H */