0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef VI_H
0024 #define VI_H
0025
0026 #define SDMA0_REGISTER_OFFSET 0x0
0027 #define SDMA1_REGISTER_OFFSET 0x200
0028 #define SDMA_MAX_INSTANCE 2
0029
0030 #define KFD_VI_SDMA_QUEUE_OFFSET 0x80
0031
0032
0033 #define CRTC0_REGISTER_OFFSET (0x1b9c - 0x1b9c)
0034 #define CRTC1_REGISTER_OFFSET (0x1d9c - 0x1b9c)
0035 #define CRTC2_REGISTER_OFFSET (0x1f9c - 0x1b9c)
0036 #define CRTC3_REGISTER_OFFSET (0x419c - 0x1b9c)
0037 #define CRTC4_REGISTER_OFFSET (0x439c - 0x1b9c)
0038 #define CRTC5_REGISTER_OFFSET (0x459c - 0x1b9c)
0039 #define CRTC6_REGISTER_OFFSET (0x479c - 0x1b9c)
0040
0041
0042 #define DIG0_REGISTER_OFFSET (0x4a00 - 0x4a00)
0043 #define DIG1_REGISTER_OFFSET (0x4b00 - 0x4a00)
0044 #define DIG2_REGISTER_OFFSET (0x4c00 - 0x4a00)
0045 #define DIG3_REGISTER_OFFSET (0x4d00 - 0x4a00)
0046 #define DIG4_REGISTER_OFFSET (0x4e00 - 0x4a00)
0047 #define DIG5_REGISTER_OFFSET (0x4f00 - 0x4a00)
0048 #define DIG6_REGISTER_OFFSET (0x5400 - 0x4a00)
0049 #define DIG7_REGISTER_OFFSET (0x5600 - 0x4a00)
0050 #define DIG8_REGISTER_OFFSET (0x5700 - 0x4a00)
0051
0052
0053 #define AUD0_REGISTER_OFFSET (0x17a8 - 0x17a8)
0054 #define AUD1_REGISTER_OFFSET (0x17ac - 0x17a8)
0055 #define AUD2_REGISTER_OFFSET (0x17b0 - 0x17a8)
0056 #define AUD3_REGISTER_OFFSET (0x17b4 - 0x17a8)
0057 #define AUD4_REGISTER_OFFSET (0x17b8 - 0x17a8)
0058 #define AUD5_REGISTER_OFFSET (0x17bc - 0x17a8)
0059 #define AUD6_REGISTER_OFFSET (0x17c0 - 0x17a8)
0060 #define AUD7_REGISTER_OFFSET (0x17c4 - 0x17a8)
0061
0062
0063 #define HPD0_REGISTER_OFFSET (0x1898 - 0x1898)
0064 #define HPD1_REGISTER_OFFSET (0x18a0 - 0x1898)
0065 #define HPD2_REGISTER_OFFSET (0x18a8 - 0x1898)
0066 #define HPD3_REGISTER_OFFSET (0x18b0 - 0x1898)
0067 #define HPD4_REGISTER_OFFSET (0x18b8 - 0x1898)
0068 #define HPD5_REGISTER_OFFSET (0x18c0 - 0x1898)
0069
0070 #define PIPEID(x) ((x) << 0)
0071 #define MEID(x) ((x) << 2)
0072 #define VMID(x) ((x) << 4)
0073 #define QUEUEID(x) ((x) << 8)
0074
0075 #define MC_SEQ_MISC0__MT__MASK 0xf0000000
0076 #define MC_SEQ_MISC0__MT__GDDR1 0x10000000
0077 #define MC_SEQ_MISC0__MT__DDR2 0x20000000
0078 #define MC_SEQ_MISC0__MT__GDDR3 0x30000000
0079 #define MC_SEQ_MISC0__MT__GDDR4 0x40000000
0080 #define MC_SEQ_MISC0__MT__GDDR5 0x50000000
0081 #define MC_SEQ_MISC0__MT__HBM 0x60000000
0082 #define MC_SEQ_MISC0__MT__DDR3 0xB0000000
0083
0084
0085
0086
0087 #define PACKET_TYPE0 0
0088 #define PACKET_TYPE1 1
0089 #define PACKET_TYPE2 2
0090 #define PACKET_TYPE3 3
0091
0092 #define CP_PACKET_GET_TYPE(h) (((h) >> 30) & 3)
0093 #define CP_PACKET_GET_COUNT(h) (((h) >> 16) & 0x3FFF)
0094 #define CP_PACKET0_GET_REG(h) ((h) & 0xFFFF)
0095 #define CP_PACKET3_GET_OPCODE(h) (((h) >> 8) & 0xFF)
0096 #define PACKET0(reg, n) ((PACKET_TYPE0 << 30) | \
0097 ((reg) & 0xFFFF) | \
0098 ((n) & 0x3FFF) << 16)
0099 #define CP_PACKET2 0x80000000
0100 #define PACKET2_PAD_SHIFT 0
0101 #define PACKET2_PAD_MASK (0x3fffffff << 0)
0102
0103 #define PACKET2(v) (CP_PACKET2 | REG_SET(PACKET2_PAD, (v)))
0104
0105 #define PACKET3(op, n) ((PACKET_TYPE3 << 30) | \
0106 (((op) & 0xFF) << 8) | \
0107 ((n) & 0x3FFF) << 16)
0108
0109 #define PACKET3_COMPUTE(op, n) (PACKET3(op, n) | 1 << 1)
0110
0111
0112 #define PACKET3_NOP 0x10
0113 #define PACKET3_SET_BASE 0x11
0114 #define PACKET3_BASE_INDEX(x) ((x) << 0)
0115 #define CE_PARTITION_BASE 3
0116 #define PACKET3_CLEAR_STATE 0x12
0117 #define PACKET3_INDEX_BUFFER_SIZE 0x13
0118 #define PACKET3_DISPATCH_DIRECT 0x15
0119 #define PACKET3_DISPATCH_INDIRECT 0x16
0120 #define PACKET3_ATOMIC_GDS 0x1D
0121 #define PACKET3_ATOMIC_MEM 0x1E
0122 #define PACKET3_OCCLUSION_QUERY 0x1F
0123 #define PACKET3_SET_PREDICATION 0x20
0124 #define PACKET3_REG_RMW 0x21
0125 #define PACKET3_COND_EXEC 0x22
0126 #define PACKET3_PRED_EXEC 0x23
0127 #define PACKET3_DRAW_INDIRECT 0x24
0128 #define PACKET3_DRAW_INDEX_INDIRECT 0x25
0129 #define PACKET3_INDEX_BASE 0x26
0130 #define PACKET3_DRAW_INDEX_2 0x27
0131 #define PACKET3_CONTEXT_CONTROL 0x28
0132 #define PACKET3_INDEX_TYPE 0x2A
0133 #define PACKET3_DRAW_INDIRECT_MULTI 0x2C
0134 #define PACKET3_DRAW_INDEX_AUTO 0x2D
0135 #define PACKET3_NUM_INSTANCES 0x2F
0136 #define PACKET3_DRAW_INDEX_MULTI_AUTO 0x30
0137 #define PACKET3_INDIRECT_BUFFER_CONST 0x33
0138 #define PACKET3_STRMOUT_BUFFER_UPDATE 0x34
0139 #define PACKET3_DRAW_INDEX_OFFSET_2 0x35
0140 #define PACKET3_DRAW_PREAMBLE 0x36
0141 #define PACKET3_WRITE_DATA 0x37
0142 #define WRITE_DATA_DST_SEL(x) ((x) << 8)
0143
0144
0145
0146
0147
0148
0149
0150 #define WR_ONE_ADDR (1 << 16)
0151 #define WR_CONFIRM (1 << 20)
0152 #define WRITE_DATA_CACHE_POLICY(x) ((x) << 25)
0153
0154
0155
0156 #define WRITE_DATA_ENGINE_SEL(x) ((x) << 30)
0157
0158
0159
0160
0161 #define PACKET3_DRAW_INDEX_INDIRECT_MULTI 0x38
0162 #define PACKET3_MEM_SEMAPHORE 0x39
0163 # define PACKET3_SEM_USE_MAILBOX (0x1 << 16)
0164 # define PACKET3_SEM_SEL_SIGNAL_TYPE (0x1 << 20)
0165 # define PACKET3_SEM_CLIENT_CODE ((x) << 24)
0166 # define PACKET3_SEM_SEL_SIGNAL (0x6 << 29)
0167 # define PACKET3_SEM_SEL_WAIT (0x7 << 29)
0168 #define PACKET3_WAIT_REG_MEM 0x3C
0169 #define WAIT_REG_MEM_FUNCTION(x) ((x) << 0)
0170
0171
0172
0173
0174
0175
0176
0177
0178 #define WAIT_REG_MEM_MEM_SPACE(x) ((x) << 4)
0179
0180
0181
0182 #define WAIT_REG_MEM_OPERATION(x) ((x) << 6)
0183
0184
0185
0186 #define WAIT_REG_MEM_ENGINE(x) ((x) << 8)
0187
0188
0189
0190 #define PACKET3_INDIRECT_BUFFER 0x3F
0191 #define INDIRECT_BUFFER_TCL2_VOLATILE (1 << 22)
0192 #define INDIRECT_BUFFER_VALID (1 << 23)
0193 #define INDIRECT_BUFFER_CACHE_POLICY(x) ((x) << 28)
0194
0195
0196
0197
0198 #define INDIRECT_BUFFER_PRE_ENB(x) ((x) << 21)
0199 #define PACKET3_COPY_DATA 0x40
0200 #define PACKET3_PFP_SYNC_ME 0x42
0201 #define PACKET3_SURFACE_SYNC 0x43
0202 # define PACKET3_DEST_BASE_0_ENA (1 << 0)
0203 # define PACKET3_DEST_BASE_1_ENA (1 << 1)
0204 # define PACKET3_CB0_DEST_BASE_ENA (1 << 6)
0205 # define PACKET3_CB1_DEST_BASE_ENA (1 << 7)
0206 # define PACKET3_CB2_DEST_BASE_ENA (1 << 8)
0207 # define PACKET3_CB3_DEST_BASE_ENA (1 << 9)
0208 # define PACKET3_CB4_DEST_BASE_ENA (1 << 10)
0209 # define PACKET3_CB5_DEST_BASE_ENA (1 << 11)
0210 # define PACKET3_CB6_DEST_BASE_ENA (1 << 12)
0211 # define PACKET3_CB7_DEST_BASE_ENA (1 << 13)
0212 # define PACKET3_DB_DEST_BASE_ENA (1 << 14)
0213 # define PACKET3_TCL1_VOL_ACTION_ENA (1 << 15)
0214 # define PACKET3_TC_VOL_ACTION_ENA (1 << 16)
0215 # define PACKET3_TC_WB_ACTION_ENA (1 << 18)
0216 # define PACKET3_DEST_BASE_2_ENA (1 << 19)
0217 # define PACKET3_DEST_BASE_3_ENA (1 << 21)
0218 # define PACKET3_TCL1_ACTION_ENA (1 << 22)
0219 # define PACKET3_TC_ACTION_ENA (1 << 23)
0220 # define PACKET3_CB_ACTION_ENA (1 << 25)
0221 # define PACKET3_DB_ACTION_ENA (1 << 26)
0222 # define PACKET3_SH_KCACHE_ACTION_ENA (1 << 27)
0223 # define PACKET3_SH_KCACHE_VOL_ACTION_ENA (1 << 28)
0224 # define PACKET3_SH_ICACHE_ACTION_ENA (1 << 29)
0225 #define PACKET3_COND_WRITE 0x45
0226 #define PACKET3_EVENT_WRITE 0x46
0227 #define EVENT_TYPE(x) ((x) << 0)
0228 #define EVENT_INDEX(x) ((x) << 8)
0229
0230
0231
0232
0233
0234
0235
0236
0237 #define PACKET3_EVENT_WRITE_EOP 0x47
0238 #define EOP_TCL1_VOL_ACTION_EN (1 << 12)
0239 #define EOP_TC_VOL_ACTION_EN (1 << 13)
0240 #define EOP_TC_WB_ACTION_EN (1 << 15)
0241 #define EOP_TCL1_ACTION_EN (1 << 16)
0242 #define EOP_TC_ACTION_EN (1 << 17)
0243 #define EOP_TCL2_VOLATILE (1 << 24)
0244 #define EOP_CACHE_POLICY(x) ((x) << 25)
0245
0246
0247
0248
0249 #define DATA_SEL(x) ((x) << 29)
0250
0251
0252
0253
0254
0255
0256 #define INT_SEL(x) ((x) << 24)
0257
0258
0259
0260
0261 #define DST_SEL(x) ((x) << 16)
0262
0263
0264
0265 #define PACKET3_EVENT_WRITE_EOS 0x48
0266 #define PACKET3_RELEASE_MEM 0x49
0267 #define PACKET3_PREAMBLE_CNTL 0x4A
0268 # define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE (2 << 28)
0269 # define PACKET3_PREAMBLE_END_CLEAR_STATE (3 << 28)
0270 #define PACKET3_DMA_DATA 0x50
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280 # define PACKET3_DMA_DATA_ENGINE(x) ((x) << 0)
0281
0282
0283
0284 # define PACKET3_DMA_DATA_SRC_CACHE_POLICY(x) ((x) << 13)
0285
0286
0287
0288
0289 # define PACKET3_DMA_DATA_SRC_VOLATILE (1 << 15)
0290 # define PACKET3_DMA_DATA_DST_SEL(x) ((x) << 20)
0291
0292
0293
0294
0295 # define PACKET3_DMA_DATA_DST_CACHE_POLICY(x) ((x) << 25)
0296
0297
0298
0299
0300 # define PACKET3_DMA_DATA_DST_VOLATILE (1 << 27)
0301 # define PACKET3_DMA_DATA_SRC_SEL(x) ((x) << 29)
0302
0303
0304
0305
0306
0307 # define PACKET3_DMA_DATA_CP_SYNC (1 << 31)
0308
0309 # define PACKET3_DMA_DATA_DIS_WC (1 << 21)
0310 # define PACKET3_DMA_DATA_CMD_SRC_SWAP(x) ((x) << 22)
0311
0312
0313
0314
0315
0316 # define PACKET3_DMA_DATA_CMD_DST_SWAP(x) ((x) << 24)
0317
0318
0319
0320
0321
0322 # define PACKET3_DMA_DATA_CMD_SAS (1 << 26)
0323
0324
0325
0326 # define PACKET3_DMA_DATA_CMD_DAS (1 << 27)
0327
0328
0329
0330 # define PACKET3_DMA_DATA_CMD_SAIC (1 << 28)
0331 # define PACKET3_DMA_DATA_CMD_DAIC (1 << 29)
0332 # define PACKET3_DMA_DATA_CMD_RAW_WAIT (1 << 30)
0333 #define PACKET3_ACQUIRE_MEM 0x58
0334 #define PACKET3_REWIND 0x59
0335 #define PACKET3_LOAD_UCONFIG_REG 0x5E
0336 #define PACKET3_LOAD_SH_REG 0x5F
0337 #define PACKET3_LOAD_CONFIG_REG 0x60
0338 #define PACKET3_LOAD_CONTEXT_REG 0x61
0339 #define PACKET3_SET_CONFIG_REG 0x68
0340 #define PACKET3_SET_CONFIG_REG_START 0x00002000
0341 #define PACKET3_SET_CONFIG_REG_END 0x00002c00
0342 #define PACKET3_SET_CONTEXT_REG 0x69
0343 #define PACKET3_SET_CONTEXT_REG_START 0x0000a000
0344 #define PACKET3_SET_CONTEXT_REG_END 0x0000a400
0345 #define PACKET3_SET_CONTEXT_REG_INDIRECT 0x73
0346 #define PACKET3_SET_SH_REG 0x76
0347 #define PACKET3_SET_SH_REG_START 0x00002c00
0348 #define PACKET3_SET_SH_REG_END 0x00003000
0349 #define PACKET3_SET_SH_REG_OFFSET 0x77
0350 #define PACKET3_SET_QUEUE_REG 0x78
0351 #define PACKET3_SET_UCONFIG_REG 0x79
0352 #define PACKET3_SET_UCONFIG_REG_START 0x0000c000
0353 #define PACKET3_SET_UCONFIG_REG_END 0x0000c400
0354 #define PACKET3_SCRATCH_RAM_WRITE 0x7D
0355 #define PACKET3_SCRATCH_RAM_READ 0x7E
0356 #define PACKET3_LOAD_CONST_RAM 0x80
0357 #define PACKET3_WRITE_CONST_RAM 0x81
0358 #define PACKET3_DUMP_CONST_RAM 0x83
0359 #define PACKET3_INCREMENT_CE_COUNTER 0x84
0360 #define PACKET3_INCREMENT_DE_COUNTER 0x85
0361 #define PACKET3_WAIT_ON_CE_COUNTER 0x86
0362 #define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88
0363 #define PACKET3_SWITCH_BUFFER 0x8B
0364 #define PACKET3_FRAME_CONTROL 0x90
0365 # define FRAME_CMD(x) ((x) << 28)
0366
0367
0368
0369
0370 #define PACKET3_SET_RESOURCES 0xA0
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380 # define PACKET3_SET_RESOURCES_VMID_MASK(x) ((x) << 0)
0381 # define PACKET3_SET_RESOURCES_UNMAP_LATENTY(x) ((x) << 16)
0382 # define PACKET3_SET_RESOURCES_QUEUE_TYPE(x) ((x) << 29)
0383 #define PACKET3_MAP_QUEUES 0xA2
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393 # define PACKET3_MAP_QUEUES_QUEUE_SEL(x) ((x) << 4)
0394 # define PACKET3_MAP_QUEUES_VMID(x) ((x) << 8)
0395 # define PACKET3_MAP_QUEUES_QUEUE_TYPE(x) ((x) << 21)
0396 # define PACKET3_MAP_QUEUES_ALLOC_FORMAT(x) ((x) << 24)
0397 # define PACKET3_MAP_QUEUES_ENGINE_SEL(x) ((x) << 26)
0398 # define PACKET3_MAP_QUEUES_NUM_QUEUES(x) ((x) << 29)
0399
0400 # define PACKET3_MAP_QUEUES_CHECK_DISABLE(x) ((x) << 1)
0401 # define PACKET3_MAP_QUEUES_DOORBELL_OFFSET(x) ((x) << 2)
0402 # define PACKET3_MAP_QUEUES_QUEUE(x) ((x) << 26)
0403 # define PACKET3_MAP_QUEUES_PIPE(x) ((x) << 29)
0404 # define PACKET3_MAP_QUEUES_ME(x) ((x) << 31)
0405 #define PACKET3_UNMAP_QUEUES 0xA3
0406
0407
0408
0409
0410
0411
0412
0413
0414 # define PACKET3_UNMAP_QUEUES_ACTION(x) ((x) << 0)
0415
0416
0417
0418
0419
0420 # define PACKET3_UNMAP_QUEUES_QUEUE_SEL(x) ((x) << 4)
0421 # define PACKET3_UNMAP_QUEUES_ENGINE_SEL(x) ((x) << 26)
0422 # define PACKET3_UNMAP_QUEUES_NUM_QUEUES(x) ((x) << 29)
0423
0424 # define PACKET3_UNMAP_QUEUES_PASID(x) ((x) << 0)
0425
0426 # define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(x) ((x) << 2)
0427
0428 # define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET1(x) ((x) << 2)
0429
0430 # define PACKET3_UNMAP_QUEUES_RB_WPTR(x) ((x) << 0)
0431
0432 # define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET2(x) ((x) << 2)
0433
0434 # define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET3(x) ((x) << 2)
0435 #define PACKET3_QUERY_STATUS 0xA4
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445 # define PACKET3_QUERY_STATUS_CONTEXT_ID(x) ((x) << 0)
0446 # define PACKET3_QUERY_STATUS_INTERRUPT_SEL(x) ((x) << 28)
0447 # define PACKET3_QUERY_STATUS_COMMAND(x) ((x) << 30)
0448
0449 # define PACKET3_QUERY_STATUS_PASID(x) ((x) << 0)
0450
0451 # define PACKET3_QUERY_STATUS_DOORBELL_OFFSET(x) ((x) << 2)
0452 # define PACKET3_QUERY_STATUS_ENG_SEL(x) ((x) << 25)
0453
0454
0455 #define VCE_CMD_NO_OP 0x00000000
0456 #define VCE_CMD_END 0x00000001
0457 #define VCE_CMD_IB 0x00000002
0458 #define VCE_CMD_FENCE 0x00000003
0459 #define VCE_CMD_TRAP 0x00000004
0460 #define VCE_CMD_IB_AUTO 0x00000005
0461 #define VCE_CMD_SEMAPHORE 0x00000006
0462
0463 #define VCE_CMD_IB_VM 0x00000102
0464 #define VCE_CMD_WAIT_GE 0x00000106
0465 #define VCE_CMD_UPDATE_PTB 0x00000107
0466 #define VCE_CMD_FLUSH_TLB 0x00000108
0467
0468
0469 #define HEVC_ENC_CMD_NO_OP 0x00000000
0470 #define HEVC_ENC_CMD_END 0x00000001
0471 #define HEVC_ENC_CMD_FENCE 0x00000003
0472 #define HEVC_ENC_CMD_TRAP 0x00000004
0473 #define HEVC_ENC_CMD_IB_VM 0x00000102
0474 #define HEVC_ENC_CMD_WAIT_GE 0x00000106
0475 #define HEVC_ENC_CMD_UPDATE_PTB 0x00000107
0476 #define HEVC_ENC_CMD_FLUSH_TLB 0x00000108
0477
0478
0479 #define RB_MAP_PKR0(x) ((x) << 0)
0480 #define RB_MAP_PKR0_MASK (0x3 << 0)
0481 #define RB_MAP_PKR1(x) ((x) << 2)
0482 #define RB_MAP_PKR1_MASK (0x3 << 2)
0483 #define RB_XSEL2(x) ((x) << 4)
0484 #define RB_XSEL2_MASK (0x3 << 4)
0485 #define RB_XSEL (1 << 6)
0486 #define RB_YSEL (1 << 7)
0487 #define PKR_MAP(x) ((x) << 8)
0488 #define PKR_MAP_MASK (0x3 << 8)
0489 #define PKR_XSEL(x) ((x) << 10)
0490 #define PKR_XSEL_MASK (0x3 << 10)
0491 #define PKR_YSEL(x) ((x) << 12)
0492 #define PKR_YSEL_MASK (0x3 << 12)
0493 #define SC_MAP(x) ((x) << 16)
0494 #define SC_MAP_MASK (0x3 << 16)
0495 #define SC_XSEL(x) ((x) << 18)
0496 #define SC_XSEL_MASK (0x3 << 18)
0497 #define SC_YSEL(x) ((x) << 20)
0498 #define SC_YSEL_MASK (0x3 << 20)
0499 #define SE_MAP(x) ((x) << 24)
0500 #define SE_MAP_MASK (0x3 << 24)
0501 #define SE_XSEL(x) ((x) << 26)
0502 #define SE_XSEL_MASK (0x3 << 26)
0503 #define SE_YSEL(x) ((x) << 28)
0504 #define SE_YSEL_MASK (0x3 << 28)
0505
0506
0507 #define SE_PAIR_MAP(x) ((x) << 0)
0508 #define SE_PAIR_MAP_MASK (0x3 << 0)
0509 #define SE_PAIR_XSEL(x) ((x) << 2)
0510 #define SE_PAIR_XSEL_MASK (0x3 << 2)
0511 #define SE_PAIR_YSEL(x) ((x) << 4)
0512 #define SE_PAIR_YSEL_MASK (0x3 << 4)
0513
0514 #endif