blob: 351ab09c7d4f3093ed93d724cfd14d81019b68fc [file] [log] [blame]
Thomas Gleixner45051532019-05-29 16:57:47 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Rob Clark2b037742017-08-09 10:43:03 -04002/*
3 * IOMMU API for ARM architected SMMU implementations.
4 *
Rob Clark2b037742017-08-09 10:43:03 -04005 * Copyright (C) 2013 ARM Limited
6 *
7 * Author: Will Deacon <will.deacon@arm.com>
8 */
9
10#ifndef _ARM_SMMU_REGS_H
11#define _ARM_SMMU_REGS_H
12
Robin Murphy0caf5f42019-08-15 19:37:23 +010013#include <linux/bits.h>
14
Rob Clark2b037742017-08-09 10:43:03 -040015/* Configuration registers */
16#define ARM_SMMU_GR0_sCR0 0x0
Robin Murphy0caf5f42019-08-15 19:37:23 +010017#define sCR0_VMID16EN BIT(31)
18#define sCR0_BSU GENMASK(15, 14)
19#define sCR0_FB BIT(13)
20#define sCR0_PTM BIT(12)
21#define sCR0_VMIDPNE BIT(11)
22#define sCR0_USFCFG BIT(10)
23#define sCR0_GCFGFIE BIT(5)
24#define sCR0_GCFGFRE BIT(4)
25#define sCR0_EXIDENABLE BIT(3)
26#define sCR0_GFIE BIT(2)
27#define sCR0_GFRE BIT(1)
28#define sCR0_CLIENTPD BIT(0)
Rob Clark2b037742017-08-09 10:43:03 -040029
30/* Auxiliary Configuration register */
31#define ARM_SMMU_GR0_sACR 0x10
32
33/* Identification registers */
34#define ARM_SMMU_GR0_ID0 0x20
Robin Murphy0caf5f42019-08-15 19:37:23 +010035#define ID0_S1TS BIT(30)
36#define ID0_S2TS BIT(29)
37#define ID0_NTS BIT(28)
38#define ID0_SMS BIT(27)
39#define ID0_ATOSNS BIT(26)
40#define ID0_PTFS_NO_AARCH32 BIT(25)
41#define ID0_PTFS_NO_AARCH32S BIT(24)
42#define ID0_NUMIRPT GENMASK(23, 16)
43#define ID0_CTTW BIT(14)
44#define ID0_NUMSIDB GENMASK(12, 9)
45#define ID0_EXIDS BIT(8)
46#define ID0_NUMSMRG GENMASK(7, 0)
47
Rob Clark2b037742017-08-09 10:43:03 -040048#define ARM_SMMU_GR0_ID1 0x24
Robin Murphy0caf5f42019-08-15 19:37:23 +010049#define ID1_PAGESIZE BIT(31)
50#define ID1_NUMPAGENDXB GENMASK(30, 28)
51#define ID1_NUMS2CB GENMASK(23, 16)
52#define ID1_NUMCB GENMASK(7, 0)
53
Rob Clark2b037742017-08-09 10:43:03 -040054#define ARM_SMMU_GR0_ID2 0x28
Robin Murphy0caf5f42019-08-15 19:37:23 +010055#define ID2_VMID16 BIT(15)
56#define ID2_PTFS_64K BIT(14)
57#define ID2_PTFS_16K BIT(13)
58#define ID2_PTFS_4K BIT(12)
59#define ID2_UBS GENMASK(11, 8)
60#define ID2_OAS GENMASK(7, 4)
61#define ID2_IAS GENMASK(3, 0)
62
Rob Clark2b037742017-08-09 10:43:03 -040063#define ARM_SMMU_GR0_ID3 0x2c
64#define ARM_SMMU_GR0_ID4 0x30
65#define ARM_SMMU_GR0_ID5 0x34
66#define ARM_SMMU_GR0_ID6 0x38
Robin Murphy0caf5f42019-08-15 19:37:23 +010067
Rob Clark2b037742017-08-09 10:43:03 -040068#define ARM_SMMU_GR0_ID7 0x3c
Robin Murphy0caf5f42019-08-15 19:37:23 +010069#define ID7_MAJOR GENMASK(7, 4)
70#define ID7_MINOR GENMASK(3, 0)
71
Rob Clark2b037742017-08-09 10:43:03 -040072#define ARM_SMMU_GR0_sGFSR 0x48
73#define ARM_SMMU_GR0_sGFSYNR0 0x50
74#define ARM_SMMU_GR0_sGFSYNR1 0x54
75#define ARM_SMMU_GR0_sGFSYNR2 0x58
76
Rob Clark2b037742017-08-09 10:43:03 -040077/* Global TLB invalidation */
78#define ARM_SMMU_GR0_TLBIVMID 0x64
79#define ARM_SMMU_GR0_TLBIALLNSNH 0x68
80#define ARM_SMMU_GR0_TLBIALLH 0x6c
81#define ARM_SMMU_GR0_sTLBGSYNC 0x70
Robin Murphy0caf5f42019-08-15 19:37:23 +010082
Rob Clark2b037742017-08-09 10:43:03 -040083#define ARM_SMMU_GR0_sTLBGSTATUS 0x74
Robin Murphy0caf5f42019-08-15 19:37:23 +010084#define sTLBGSTATUS_GSACTIVE BIT(0)
Rob Clark2b037742017-08-09 10:43:03 -040085
86/* Stream mapping registers */
87#define ARM_SMMU_GR0_SMR(n) (0x800 + ((n) << 2))
Robin Murphy0caf5f42019-08-15 19:37:23 +010088#define SMR_VALID BIT(31)
89#define SMR_MASK GENMASK(31, 16)
90#define SMR_ID GENMASK(15, 0)
Rob Clark2b037742017-08-09 10:43:03 -040091
92#define ARM_SMMU_GR0_S2CR(n) (0xc00 + ((n) << 2))
Robin Murphy0caf5f42019-08-15 19:37:23 +010093#define S2CR_PRIVCFG GENMASK(25, 24)
Rob Clark2b037742017-08-09 10:43:03 -040094enum arm_smmu_s2cr_privcfg {
95 S2CR_PRIVCFG_DEFAULT,
96 S2CR_PRIVCFG_DIPAN,
97 S2CR_PRIVCFG_UNPRIV,
98 S2CR_PRIVCFG_PRIV,
99};
Robin Murphy0caf5f42019-08-15 19:37:23 +0100100#define S2CR_TYPE GENMASK(17, 16)
101enum arm_smmu_s2cr_type {
102 S2CR_TYPE_TRANS,
103 S2CR_TYPE_BYPASS,
104 S2CR_TYPE_FAULT,
105};
106#define S2CR_EXIDVALID BIT(10)
107#define S2CR_CBNDX GENMASK(7, 0)
Rob Clark2b037742017-08-09 10:43:03 -0400108
109/* Context bank attribute registers */
110#define ARM_SMMU_GR1_CBAR(n) (0x0 + ((n) << 2))
111#define CBAR_VMID_SHIFT 0
112#define CBAR_VMID_MASK 0xff
113#define CBAR_S1_BPSHCFG_SHIFT 8
114#define CBAR_S1_BPSHCFG_MASK 3
115#define CBAR_S1_BPSHCFG_NSH 3
116#define CBAR_S1_MEMATTR_SHIFT 12
117#define CBAR_S1_MEMATTR_MASK 0xf
118#define CBAR_S1_MEMATTR_WB 0xf
119#define CBAR_TYPE_SHIFT 16
120#define CBAR_TYPE_MASK 0x3
121#define CBAR_TYPE_S2_TRANS (0 << CBAR_TYPE_SHIFT)
122#define CBAR_TYPE_S1_TRANS_S2_BYPASS (1 << CBAR_TYPE_SHIFT)
123#define CBAR_TYPE_S1_TRANS_S2_FAULT (2 << CBAR_TYPE_SHIFT)
124#define CBAR_TYPE_S1_TRANS_S2_TRANS (3 << CBAR_TYPE_SHIFT)
125#define CBAR_IRPTNDX_SHIFT 24
126#define CBAR_IRPTNDX_MASK 0xff
127
Vivek Gautambc580b52019-04-22 12:40:36 +0530128#define ARM_SMMU_GR1_CBFRSYNRA(n) (0x400 + ((n) << 2))
129
Rob Clark2b037742017-08-09 10:43:03 -0400130#define ARM_SMMU_GR1_CBA2R(n) (0x800 + ((n) << 2))
131#define CBA2R_RW64_32BIT (0 << 0)
132#define CBA2R_RW64_64BIT (1 << 0)
133#define CBA2R_VMID_SHIFT 16
134#define CBA2R_VMID_MASK 0xffff
135
136#define ARM_SMMU_CB_SCTLR 0x0
137#define ARM_SMMU_CB_ACTLR 0x4
138#define ARM_SMMU_CB_RESUME 0x8
139#define ARM_SMMU_CB_TTBCR2 0x10
140#define ARM_SMMU_CB_TTBR0 0x20
141#define ARM_SMMU_CB_TTBR1 0x28
142#define ARM_SMMU_CB_TTBCR 0x30
143#define ARM_SMMU_CB_CONTEXTIDR 0x34
144#define ARM_SMMU_CB_S1_MAIR0 0x38
145#define ARM_SMMU_CB_S1_MAIR1 0x3c
146#define ARM_SMMU_CB_PAR 0x50
147#define ARM_SMMU_CB_FSR 0x58
148#define ARM_SMMU_CB_FAR 0x60
149#define ARM_SMMU_CB_FSYNR0 0x68
150#define ARM_SMMU_CB_S1_TLBIVA 0x600
151#define ARM_SMMU_CB_S1_TLBIASID 0x610
152#define ARM_SMMU_CB_S1_TLBIVAL 0x620
153#define ARM_SMMU_CB_S2_TLBIIPAS2 0x630
154#define ARM_SMMU_CB_S2_TLBIIPAS2L 0x638
155#define ARM_SMMU_CB_TLBSYNC 0x7f0
156#define ARM_SMMU_CB_TLBSTATUS 0x7f4
157#define ARM_SMMU_CB_ATS1PR 0x800
158#define ARM_SMMU_CB_ATSR 0x8f0
159
160#define SCTLR_S1_ASIDPNE (1 << 12)
161#define SCTLR_CFCFG (1 << 7)
162#define SCTLR_CFIE (1 << 6)
163#define SCTLR_CFRE (1 << 5)
164#define SCTLR_E (1 << 4)
165#define SCTLR_AFE (1 << 2)
166#define SCTLR_TRE (1 << 1)
167#define SCTLR_M (1 << 0)
168
169#define CB_PAR_F (1 << 0)
170
171#define ATSR_ACTIVE (1 << 0)
172
173#define RESUME_RETRY (0 << 0)
174#define RESUME_TERMINATE (1 << 0)
175
176#define TTBCR2_SEP_SHIFT 15
177#define TTBCR2_SEP_UPSTREAM (0x7 << TTBCR2_SEP_SHIFT)
178#define TTBCR2_AS (1 << 4)
179
180#define TTBRn_ASID_SHIFT 48
181
182#define FSR_MULTI (1 << 31)
183#define FSR_SS (1 << 30)
184#define FSR_UUT (1 << 8)
185#define FSR_ASF (1 << 7)
186#define FSR_TLBLKF (1 << 6)
187#define FSR_TLBMCF (1 << 5)
188#define FSR_EF (1 << 4)
189#define FSR_PF (1 << 3)
190#define FSR_AFF (1 << 2)
191#define FSR_TF (1 << 1)
192
193#define FSR_IGN (FSR_AFF | FSR_ASF | \
194 FSR_TLBMCF | FSR_TLBLKF)
195#define FSR_FAULT (FSR_MULTI | FSR_SS | FSR_UUT | \
196 FSR_EF | FSR_PF | FSR_TF | FSR_IGN)
197
198#define FSYNR0_WNR (1 << 4)
199
200#endif /* _ARM_SMMU_REGS_H */