Lines Matching +full:0 +full:- +full:63
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
21 #include <misc/cxl-base.h>
62 /* Configuration and Control area - CAIA 1&2 */
63 static const cxl_p1_reg_t CXL_PSL_CtxTime = {0x0000};
64 static const cxl_p1_reg_t CXL_PSL_ErrIVTE = {0x0008};
65 static const cxl_p1_reg_t CXL_PSL_KEY1 = {0x0010};
66 static const cxl_p1_reg_t CXL_PSL_KEY2 = {0x0018};
67 static const cxl_p1_reg_t CXL_PSL_Control = {0x0020};
69 static const cxl_p1_reg_t CXL_PSL_DLCNTL = {0x0060};
70 static const cxl_p1_reg_t CXL_PSL_DLADDR = {0x0068};
72 /* PSL Lookaside Buffer Management Area - CAIA 1 */
73 static const cxl_p1_reg_t CXL_PSL_LBISEL = {0x0080};
74 static const cxl_p1_reg_t CXL_PSL_SLBIE = {0x0088};
75 static const cxl_p1_reg_t CXL_PSL_SLBIA = {0x0090};
76 static const cxl_p1_reg_t CXL_PSL_TLBIE = {0x00A0};
77 static const cxl_p1_reg_t CXL_PSL_TLBIA = {0x00A8};
78 static const cxl_p1_reg_t CXL_PSL_AFUSEL = {0x00B0};
80 /* 0x00C0:7EFF Implementation dependent area */
81 /* PSL registers - CAIA 1 */
82 static const cxl_p1_reg_t CXL_PSL_FIR1 = {0x0100};
83 static const cxl_p1_reg_t CXL_PSL_FIR2 = {0x0108};
84 static const cxl_p1_reg_t CXL_PSL_Timebase = {0x0110};
85 static const cxl_p1_reg_t CXL_PSL_VERSION = {0x0118};
86 static const cxl_p1_reg_t CXL_PSL_RESLCKTO = {0x0128};
87 static const cxl_p1_reg_t CXL_PSL_TB_CTLSTAT = {0x0140};
88 static const cxl_p1_reg_t CXL_PSL_FIR_CNTL = {0x0148};
89 static const cxl_p1_reg_t CXL_PSL_DSNDCTL = {0x0150};
90 static const cxl_p1_reg_t CXL_PSL_SNWRALLOC = {0x0158};
91 static const cxl_p1_reg_t CXL_PSL_TRACE = {0x0170};
92 /* PSL registers - CAIA 2 */
93 static const cxl_p1_reg_t CXL_PSL9_CONTROL = {0x0020};
94 static const cxl_p1_reg_t CXL_XSL9_INV = {0x0110};
95 static const cxl_p1_reg_t CXL_XSL9_DBG = {0x0130};
96 static const cxl_p1_reg_t CXL_XSL9_DEF = {0x0140};
97 static const cxl_p1_reg_t CXL_XSL9_DSNCTL = {0x0168};
98 static const cxl_p1_reg_t CXL_PSL9_FIR1 = {0x0300};
99 static const cxl_p1_reg_t CXL_PSL9_FIR_MASK = {0x0308};
100 static const cxl_p1_reg_t CXL_PSL9_Timebase = {0x0310};
101 static const cxl_p1_reg_t CXL_PSL9_DEBUG = {0x0320};
102 static const cxl_p1_reg_t CXL_PSL9_FIR_CNTL = {0x0348};
103 static const cxl_p1_reg_t CXL_PSL9_DSNDCTL = {0x0350};
104 static const cxl_p1_reg_t CXL_PSL9_TB_CTLSTAT = {0x0340};
105 static const cxl_p1_reg_t CXL_PSL9_TRACECFG = {0x0368};
106 static const cxl_p1_reg_t CXL_PSL9_APCDEDALLOC = {0x0378};
107 static const cxl_p1_reg_t CXL_PSL9_APCDEDTYPE = {0x0380};
108 static const cxl_p1_reg_t CXL_PSL9_TNR_ADDR = {0x0388};
109 static const cxl_p1_reg_t CXL_PSL9_CTCCFG = {0x0390};
110 static const cxl_p1_reg_t CXL_PSL9_GP_CT = {0x0398};
111 static const cxl_p1_reg_t CXL_XSL9_IERAT = {0x0588};
112 static const cxl_p1_reg_t CXL_XSL9_ILPP = {0x0590};
114 /* 0x7F00:7FFF Reserved PCIe MSI-X Pending Bit Array area */
115 /* 0x8000:FFFF Reserved PCIe MSI-X Table Area */
118 /* Configuration Area - CAIA 1&2 */
119 static const cxl_p1n_reg_t CXL_PSL_SR_An = {0x00};
120 static const cxl_p1n_reg_t CXL_PSL_LPID_An = {0x08};
121 static const cxl_p1n_reg_t CXL_PSL_AMBAR_An = {0x10};
122 static const cxl_p1n_reg_t CXL_PSL_SPOffset_An = {0x18};
123 static const cxl_p1n_reg_t CXL_PSL_ID_An = {0x20};
124 static const cxl_p1n_reg_t CXL_PSL_SERR_An = {0x28};
125 /* Memory Management and Lookaside Buffer Management - CAIA 1*/
126 static const cxl_p1n_reg_t CXL_PSL_SDR_An = {0x30};
127 /* Memory Management and Lookaside Buffer Management - CAIA 1&2 */
128 static const cxl_p1n_reg_t CXL_PSL_AMOR_An = {0x38};
129 /* Pointer Area - CAIA 1&2 */
130 static const cxl_p1n_reg_t CXL_HAURP_An = {0x80};
131 static const cxl_p1n_reg_t CXL_PSL_SPAP_An = {0x88};
132 static const cxl_p1n_reg_t CXL_PSL_LLCMD_An = {0x90};
133 /* Control Area - CAIA 1&2 */
134 static const cxl_p1n_reg_t CXL_PSL_SCNTL_An = {0xA0};
135 static const cxl_p1n_reg_t CXL_PSL_CtxTime_An = {0xA8};
136 static const cxl_p1n_reg_t CXL_PSL_IVTE_Offset_An = {0xB0};
137 static const cxl_p1n_reg_t CXL_PSL_IVTE_Limit_An = {0xB8};
138 /* 0xC0:FF Implementation Dependent Area - CAIA 1&2 */
139 static const cxl_p1n_reg_t CXL_PSL_FIR_SLICE_An = {0xC0};
140 static const cxl_p1n_reg_t CXL_AFU_DEBUG_An = {0xC8};
141 /* 0xC0:FF Implementation Dependent Area - CAIA 1 */
142 static const cxl_p1n_reg_t CXL_PSL_APCALLOC_A = {0xD0};
143 static const cxl_p1n_reg_t CXL_PSL_COALLOC_A = {0xD8};
144 static const cxl_p1n_reg_t CXL_PSL_RXCTL_A = {0xE0};
145 static const cxl_p1n_reg_t CXL_PSL_SLICE_TRACE = {0xE8};
148 /* Configuration and Control Area - CAIA 1&2 */
149 static const cxl_p2n_reg_t CXL_PSL_PID_TID_An = {0x000};
150 static const cxl_p2n_reg_t CXL_CSRP_An = {0x008};
151 /* Configuration and Control Area - CAIA 1 */
152 static const cxl_p2n_reg_t CXL_AURP0_An = {0x010};
153 static const cxl_p2n_reg_t CXL_AURP1_An = {0x018};
154 static const cxl_p2n_reg_t CXL_SSTP0_An = {0x020};
155 static const cxl_p2n_reg_t CXL_SSTP1_An = {0x028};
156 /* Configuration and Control Area - CAIA 1 */
157 static const cxl_p2n_reg_t CXL_PSL_AMR_An = {0x030};
158 /* Segment Lookaside Buffer Management - CAIA 1 */
159 static const cxl_p2n_reg_t CXL_SLBIE_An = {0x040};
160 static const cxl_p2n_reg_t CXL_SLBIA_An = {0x048};
161 static const cxl_p2n_reg_t CXL_SLBI_Select_An = {0x050};
162 /* Interrupt Registers - CAIA 1&2 */
163 static const cxl_p2n_reg_t CXL_PSL_DSISR_An = {0x060};
164 static const cxl_p2n_reg_t CXL_PSL_DAR_An = {0x068};
165 static const cxl_p2n_reg_t CXL_PSL_DSR_An = {0x070};
166 static const cxl_p2n_reg_t CXL_PSL_TFC_An = {0x078};
167 static const cxl_p2n_reg_t CXL_PSL_PEHandle_An = {0x080};
168 static const cxl_p2n_reg_t CXL_PSL_ErrStat_An = {0x088};
169 /* AFU Registers - CAIA 1&2 */
170 static const cxl_p2n_reg_t CXL_AFU_Cntl_An = {0x090};
171 static const cxl_p2n_reg_t CXL_AFU_ERR_An = {0x098};
172 /* Work Element Descriptor - CAIA 1&2 */
173 static const cxl_p2n_reg_t CXL_PSL_WED_An = {0x0A0};
174 /* 0x0C0:FFF Implementation Dependent Area */
176 #define CXL_PSL_SPAP_Addr 0x0ffffffffffff000ULL
177 #define CXL_PSL_SPAP_Size 0x0000000000000ff0ULL
179 #define CXL_PSL_SPAP_V 0x0000000000000001ULL
182 #define CXL_PSL_Control_tb (0x1ull << (63-63))
183 #define CXL_PSL_Control_Fr (0x1ull << (63-31))
184 #define CXL_PSL_Control_Fs_MASK (0x3ull << (63-29))
185 #define CXL_PSL_Control_Fs_Complete (0x3ull << (63-29))
188 #define CXL_PSL_DLCNTL_D (0x1ull << (63-28))
189 #define CXL_PSL_DLCNTL_C (0x1ull << (63-29))
190 #define CXL_PSL_DLCNTL_E (0x1ull << (63-30))
191 #define CXL_PSL_DLCNTL_S (0x1ull << (63-31))
197 #define CXL_PSL_SR_An_TA (1ull << (63-1)) /* Tags active, GA1: 0 */
198 #define CXL_PSL_SR_An_HV MSR_HV /* Hypervisor, GA1: 0 */
199 #define CXL_PSL_SR_An_XLAT_hpt (0ull << (63-6))/* Hashed page table (HPT) mode */
200 #define CXL_PSL_SR_An_XLAT_roh (2ull << (63-6))/* Radix on HPT mode */
201 #define CXL_PSL_SR_An_XLAT_ror (3ull << (63-6))/* Radix on Radix mode */
202 #define CXL_PSL_SR_An_BOT (1ull << (63-10)) /* Use the in-memory segment table */
204 #define CXL_PSL_SR_An_ISL (1ull << (63-53)) /* Ignore Segment Large Page */
205 #define CXL_PSL_SR_An_TC (1ull << (63-54)) /* Page Table secondary hash */
206 #define CXL_PSL_SR_An_US (1ull << (63-56)) /* User state, GA1: X */
207 #define CXL_PSL_SR_An_SC (1ull << (63-58)) /* Segment Table secondary hash */
209 #define CXL_PSL_SR_An_MP (1ull << (63-62)) /* Master Process */
210 #define CXL_PSL_SR_An_LE (1ull << (63-63)) /* Little Endian */
213 #define CXL_PSL_ID_An_F (1ull << (63-31))
214 #define CXL_PSL_ID_An_L (1ull << (63-30))
217 #define CXL_PSL_SERR_An_afuto (1ull << (63-0))
218 #define CXL_PSL_SERR_An_afudis (1ull << (63-1))
219 #define CXL_PSL_SERR_An_afuov (1ull << (63-2))
220 #define CXL_PSL_SERR_An_badsrc (1ull << (63-3))
221 #define CXL_PSL_SERR_An_badctx (1ull << (63-4))
222 #define CXL_PSL_SERR_An_llcmdis (1ull << (63-5))
223 #define CXL_PSL_SERR_An_llcmdto (1ull << (63-6))
224 #define CXL_PSL_SERR_An_afupar (1ull << (63-7))
225 #define CXL_PSL_SERR_An_afudup (1ull << (63-8))
230 #define CXL_PSL_SERR_An_afuto_mask (1ull << (63-32))
231 #define CXL_PSL_SERR_An_afudis_mask (1ull << (63-33))
232 #define CXL_PSL_SERR_An_afuov_mask (1ull << (63-34))
233 #define CXL_PSL_SERR_An_badsrc_mask (1ull << (63-35))
234 #define CXL_PSL_SERR_An_badctx_mask (1ull << (63-36))
235 #define CXL_PSL_SERR_An_llcmdis_mask (1ull << (63-37))
236 #define CXL_PSL_SERR_An_llcmdto_mask (1ull << (63-38))
237 #define CXL_PSL_SERR_An_afupar_mask (1ull << (63-39))
238 #define CXL_PSL_SERR_An_afudup_mask (1ull << (63-40))
244 #define CXL_PSL_SERR_An_AE (1ull << (63-30))
247 #define CXL_PSL_SCNTL_An_CR (0x1ull << (63-15))
249 #define CXL_PSL_SCNTL_An_PM_MASK (0xffffull << (63-31))
250 #define CXL_PSL_SCNTL_An_PM_Shared (0x0000ull << (63-31))
251 #define CXL_PSL_SCNTL_An_PM_OS (0x0001ull << (63-31))
252 #define CXL_PSL_SCNTL_An_PM_Process (0x0002ull << (63-31))
253 #define CXL_PSL_SCNTL_An_PM_AFU (0x0004ull << (63-31))
254 #define CXL_PSL_SCNTL_An_PM_AFU_PBT (0x0104ull << (63-31))
256 #define CXL_PSL_SCNTL_An_Ps_MASK (0x3ull << (63-39))
257 #define CXL_PSL_SCNTL_An_Ps_Pending (0x1ull << (63-39))
258 #define CXL_PSL_SCNTL_An_Ps_Complete (0x3ull << (63-39))
260 #define CXL_PSL_SCNTL_An_Pc (0x1ull << (63-48))
262 #define CXL_PSL_SCNTL_An_Ss_MASK (0x3ull << (63-55))
263 #define CXL_PSL_SCNTL_An_Ss_Pending (0x1ull << (63-55))
264 #define CXL_PSL_SCNTL_An_Ss_Complete (0x3ull << (63-55))
266 #define CXL_PSL_SCNTL_An_Sc (0x1ull << (63-63))
269 #define CXL_AFU_Cntl_An_ES_MASK (0x7ull << (63-2))
270 #define CXL_AFU_Cntl_An_ES_Disabled (0x0ull << (63-2))
271 #define CXL_AFU_Cntl_An_ES_Enabled (0x4ull << (63-2))
273 #define CXL_AFU_Cntl_An_E (0x1ull << (63-3))
275 #define CXL_AFU_Cntl_An_RS_MASK (0x3ull << (63-5))
276 #define CXL_AFU_Cntl_An_RS_Pending (0x1ull << (63-5))
277 #define CXL_AFU_Cntl_An_RS_Complete (0x2ull << (63-5))
279 #define CXL_AFU_Cntl_An_RA (0x1ull << (63-7))
284 #define CXL_SSTP0_An_KS (1ull << (63-2))
285 #define CXL_SSTP0_An_KP (1ull << (63-3))
286 #define CXL_SSTP0_An_N (1ull << (63-4))
287 #define CXL_SSTP0_An_L (1ull << (63-5))
288 #define CXL_SSTP0_An_C (1ull << (63-6))
289 #define CXL_SSTP0_An_TA (1ull << (63-7))
290 #define CXL_SSTP0_An_LP_SHIFT (63-9) /* 2 Bits */
292 #define CXL_SSTP0_An_SegTableSize_SHIFT (63-31) /* 12 Bits */
294 (((1ull << 12) - 1) << CXL_SSTP0_An_SegTableSize_SHIFT)
295 #define CXL_SSTP0_An_STVA_U_MASK ((1ull << (63-49))-1)
296 #define CXL_SSTP1_An_STVA_L_MASK (~((1ull << (63-55))-1))
297 #define CXL_SSTP1_An_V (1ull << (63-63))
299 /****** CXL_PSL_SLBIE_[An] - CAIA 1 **************************************************/
307 #define CXL_SLBIE_PENDING PPC_BITMASK(56, 63)
309 /****** Common to all CXL_TLBIA/SLBIA_[An] - CAIA 1 **********************************/
312 /****** Common to all CXL_TLB/SLB_IA/IE_[An] registers - CAIA 1 **********************/
313 #define CXL_TLB_SLB_IQ_ALL (0ull) /* Inv qualifier */
318 #define CXL_PSL_AFUSEL_A (1ull << (63-55)) /* Adapter wide invalidates affect all AFUs */
320 /****** CXL_PSL_DSISR_An - CAIA 1 ****************************************************/
321 #define CXL_PSL_DSISR_An_DS (1ull << (63-0)) /* Segment not found */
322 #define CXL_PSL_DSISR_An_DM (1ull << (63-1)) /* PTE not found (See also: M) or protection fault */
323 #define CXL_PSL_DSISR_An_ST (1ull << (63-2)) /* Segment Table PTE not found */
324 #define CXL_PSL_DSISR_An_UR (1ull << (63-3)) /* AURP PTE not found */
326 #define CXL_PSL_DSISR_An_PE (1ull << (63-4)) /* PSL Error (implementation specific) */
327 #define CXL_PSL_DSISR_An_AE (1ull << (63-5)) /* AFU Error */
328 #define CXL_PSL_DSISR_An_OC (1ull << (63-6)) /* OS Context Warning */
330 /* NOTE: Bits 32:63 are undefined if DSISR[DS] = 1 */
333 #define CXL_PSL_DSISR_An_A (1ull << (63-37)) /* AFU lock access to write through or cache inhibite…
337 /****** CXL_PSL_DSISR_An - CAIA 2 ****************************************************/
338 #define CXL_PSL9_DSISR_An_TF (1ull << (63-3)) /* Translation fault */
339 #define CXL_PSL9_DSISR_An_PE (1ull << (63-4)) /* PSL Error (implementation specific) */
340 #define CXL_PSL9_DSISR_An_AE (1ull << (63-5)) /* AFU Error */
341 #define CXL_PSL9_DSISR_An_OC (1ull << (63-6)) /* OS Context Warning */
342 #define CXL_PSL9_DSISR_An_S (1ull << (63-38)) /* TF for a write operation */
345 * NOTE: Bits 56:63 (Checkout Response Status) are valid when DSISR_An[TF] = 1
346 * Status (0:7) Encoding
348 #define CXL_PSL9_DSISR_An_CO_MASK 0x00000000000000ffULL
349 #define CXL_PSL9_DSISR_An_SF 0x0000000000000080ULL /* Segment Fault 0b…
350 #define CXL_PSL9_DSISR_An_PF_SLR 0x0000000000000088ULL /* PTE not found (Single Level Radix) 0b…
351 #define CXL_PSL9_DSISR_An_PF_RGC 0x000000000000008CULL /* PTE not found (Radix Guest (child)) 0b…
352 #define CXL_PSL9_DSISR_An_PF_RGP 0x0000000000000090ULL /* PTE not found (Radix Guest (parent)) 0b…
353 #define CXL_PSL9_DSISR_An_PF_HRH 0x0000000000000094ULL /* PTE not found (HPT/Radix Host) 0b…
354 #define CXL_PSL9_DSISR_An_PF_STEG 0x000000000000009CULL /* PTE not found (STEG VA) 0b…
355 #define CXL_PSL9_DSISR_An_URTCH 0x00000000000000B4ULL /* Unsupported Radix Tree Configuration 0b…
358 #define CXL_PSL_TFC_An_A (1ull << (63-28)) /* Acknowledge non-translation fault */
359 #define CXL_PSL_TFC_An_C (1ull << (63-29)) /* Continue (abort transaction) */
360 #define CXL_PSL_TFC_An_AE (1ull << (63-30)) /* Restart PSL with address error */
361 #define CXL_PSL_TFC_An_R (1ull << (63-31)) /* Restart PSL transaction */
364 #define CXL_PSL_DEBUG_CDC (1ull << (63-27)) /* Coherent Data cache support */
366 /****** CXL_XSL9_IERAT_ERAT - CAIA 2 **********************************/
367 #define CXL_XSL9_IERAT_MLPID (1ull << (63-0)) /* Match LPID */
368 #define CXL_XSL9_IERAT_MPID (1ull << (63-1)) /* Match PID */
369 #define CXL_XSL9_IERAT_PRS (1ull << (63-4)) /* PRS bit for Radix invalidations */
370 #define CXL_XSL9_IERAT_INVR (1ull << (63-3)) /* Invalidate Radix */
371 #define CXL_XSL9_IERAT_IALL (1ull << (63-8)) /* Invalidate All */
372 #define CXL_XSL9_IERAT_IINPROG (1ull << (63-63)) /* Invalidate in progress */
374 /* cxl_process_element->software_status */
375 #define CXL_PE_SOFTWARE_STATE_V (1ul << (31 - 0)) /* Valid */
376 #define CXL_PE_SOFTWARE_STATE_C (1ul << (31 - 29)) /* Complete */
377 #define CXL_PE_SOFTWARE_STATE_S (1ul << (31 - 30)) /* Suspend */
378 #define CXL_PE_SOFTWARE_STATE_T (1ul << (31 - 31)) /* Terminate */
385 #define CXL_PSL_RXCTL_AFUHP_4S 0x7000000000000000ULL
387 /* SPA->sw_command_status */
388 #define CXL_SPA_SW_CMD_MASK 0xffff000000000000ULL
389 #define CXL_SPA_SW_CMD_TERMINATE 0x0001000000000000ULL
390 #define CXL_SPA_SW_CMD_REMOVE 0x0002000000000000ULL
391 #define CXL_SPA_SW_CMD_SUSPEND 0x0003000000000000ULL
392 #define CXL_SPA_SW_CMD_RESUME 0x0004000000000000ULL
393 #define CXL_SPA_SW_CMD_ADD 0x0005000000000000ULL
394 #define CXL_SPA_SW_CMD_UPDATE 0x0006000000000000ULL
395 #define CXL_SPA_SW_STATE_MASK 0x0000ffff00000000ULL
396 #define CXL_SPA_SW_STATE_TERMINATED 0x0000000100000000ULL
397 #define CXL_SPA_SW_STATE_REMOVED 0x0000000200000000ULL
398 #define CXL_SPA_SW_STATE_SUSPENDED 0x0000000300000000ULL
399 #define CXL_SPA_SW_STATE_RESUMED 0x0000000400000000ULL
400 #define CXL_SPA_SW_STATE_ADDED 0x0000000500000000ULL
401 #define CXL_SPA_SW_STATE_UPDATED 0x0000000600000000ULL
402 #define CXL_SPA_SW_PSL_ID_MASK 0x00000000ffff0000ULL
403 #define CXL_SPA_SW_LINK_MASK 0x000000000000ffffULL
408 #define CXL_MODE_TIME_SLICED 0x4
412 #define CXL_CARD_MINOR(adapter) (adapter->adapter_num * CXL_DEV_MINORS)
415 #define CXL_PSL9_TRACEID_MAX 0xAU
416 #define CXL_PSL9_TRACESTATE_FIN 0x3U
495 /* -1: AFU deconfigured/locked, >= 0: number of readers */
595 * On bare-metal, pe=external_pe, because we decide what the handle is.
705 * >0: Number of contexts mapped and new one can be mapped.
706 * 0: No active contexts and new ones can be mapped.
707 * -1: No contexts mapped and new ones cannot be mapped.
722 /* common == phyp + powernv - CAIA 1&2 */
746 /* just powernv - CAIA 1&2 */
768 pdev = to_pci_dev(cxl->dev.parent); in cxl_adapter_link_ok()
777 return cxl->native->p1_mmio + cxl_reg_off(reg); in _cxl_p1_addr()
791 return ~0ULL; in cxl_p1_read()
797 return afu->native->p1n_mmio + cxl_reg_off(reg); in _cxl_p1n_addr()
802 if (likely(cxl_adapter_link_ok(afu->adapter, afu))) in cxl_p1n_write()
808 if (likely(cxl_adapter_link_ok(afu->adapter, afu))) in cxl_p1n_read()
811 return ~0ULL; in cxl_p1n_read()
816 return afu->p2n_mmio + cxl_reg_off(reg); in _cxl_p2n_addr()
821 if (likely(cxl_adapter_link_ok(afu->adapter, afu))) in cxl_p2n_write()
827 if (likely(cxl_adapter_link_ok(afu->adapter, afu))) in cxl_p2n_read()
830 return ~0ULL; in cxl_p2n_read()
992 * Field pid_tid is now 'reserved' because it's no more used on bare-metal.
1113 * In case an adapter_context_lock is taken the return -EBUSY.
1123 /* Unlock the contexts-lock if taken. Warn and force unlock otherwise */