1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2013 Red Hat 4 * Author: Rob Clark <robdclark@gmail.com> 5 * 6 * Copyright (c) 2014,2017, 2019 The Linux Foundation. All rights reserved. 7 */ 8 9 #ifndef __ADRENO_GPU_H__ 10 #define __ADRENO_GPU_H__ 11 12 #include <linux/firmware.h> 13 #include <linux/iopoll.h> 14 15 #include <linux/soc/qcom/ubwc.h> 16 17 #include "msm_gpu.h" 18 19 #include "adreno_common.xml.h" 20 #include "adreno_pm4.xml.h" 21 22 extern bool snapshot_debugbus; 23 24 enum { 25 ADRENO_FW_PM4 = 0, 26 ADRENO_FW_SQE = 0, /* a6xx */ 27 ADRENO_FW_PFP = 1, 28 ADRENO_FW_GMU = 1, /* a6xx */ 29 ADRENO_FW_GPMU = 2, 30 ADRENO_FW_MAX, 31 }; 32 33 /** 34 * @enum adreno_family: identify generation and possibly sub-generation 35 * 36 * In some cases there are distinct sub-generations within a major revision 37 * so it helps to be able to group the GPU devices by generation and if 38 * necessary sub-generation. 39 */ 40 enum adreno_family { 41 ADRENO_2XX_GEN1, /* a20x */ 42 ADRENO_2XX_GEN2, /* a22x */ 43 ADRENO_3XX, 44 ADRENO_4XX, 45 ADRENO_5XX, 46 ADRENO_6XX_GEN1, /* a630 family */ 47 ADRENO_6XX_GEN2, /* a640 family */ 48 ADRENO_6XX_GEN3, /* a650 family */ 49 ADRENO_6XX_GEN4, /* a660 family */ 50 ADRENO_7XX_GEN1, /* a730 family */ 51 ADRENO_7XX_GEN2, /* a740 family */ 52 ADRENO_7XX_GEN3, /* a750 family */ 53 }; 54 55 #define ADRENO_QUIRK_TWO_PASS_USE_WFI BIT(0) 56 #define ADRENO_QUIRK_FAULT_DETECT_MASK BIT(1) 57 #define ADRENO_QUIRK_LMLOADKILL_DISABLE BIT(2) 58 #define ADRENO_QUIRK_HAS_HW_APRIV BIT(3) 59 #define ADRENO_QUIRK_HAS_CACHED_COHERENT BIT(4) 60 #define ADRENO_QUIRK_PREEMPTION BIT(5) 61 #define ADRENO_QUIRK_4GB_VA BIT(6) 62 #define ADRENO_QUIRK_IFPC BIT(7) 63 64 /* Helper for formating the chip_id in the way that userspace tools like 65 * crashdec expect. 66 */ 67 #define ADRENO_CHIPID_FMT "u.%u.%u.%u" 68 #define ADRENO_CHIPID_ARGS(_c) \ 69 (((_c) >> 24) & 0xff), \ 70 (((_c) >> 16) & 0xff), \ 71 (((_c) >> 8) & 0xff), \ 72 ((_c) & 0xff) 73 74 struct adreno_gpu_funcs { 75 struct msm_gpu_funcs base; 76 int (*get_timestamp)(struct msm_gpu *gpu, uint64_t *value); 77 }; 78 79 struct adreno_reglist { 80 u32 offset; 81 u32 value; 82 }; 83 84 struct adreno_speedbin { 85 uint16_t fuse; 86 uint16_t speedbin; 87 }; 88 89 struct a6xx_info; 90 91 struct adreno_info { 92 const char *machine; 93 /** 94 * @chipids: Table of matching chip-ids 95 * 96 * Terminated with 0 sentinal 97 */ 98 uint32_t *chip_ids; 99 enum adreno_family family; 100 uint32_t revn; 101 const char *fw[ADRENO_FW_MAX]; 102 uint32_t gmem; 103 u64 quirks; 104 struct msm_gpu *(*init)(struct drm_device *dev); 105 const char *zapfw; 106 u32 inactive_period; 107 union { 108 const struct a6xx_info *a6xx; 109 }; 110 /** 111 * @speedbins: Optional table of fuse to speedbin mappings 112 * 113 * Consists of pairs of fuse, index mappings, terminated with 114 * {SHRT_MAX, 0} sentinal. 115 */ 116 struct adreno_speedbin *speedbins; 117 u64 preempt_record_size; 118 }; 119 120 #define ADRENO_CHIP_IDS(tbl...) (uint32_t[]) { tbl, 0 } 121 122 struct adreno_gpulist { 123 const struct adreno_info *gpus; 124 unsigned gpus_count; 125 }; 126 127 #define DECLARE_ADRENO_GPULIST(name) \ 128 const struct adreno_gpulist name ## _gpulist = { \ 129 name ## _gpus, ARRAY_SIZE(name ## _gpus) \ 130 } 131 132 /* 133 * Helper to build a speedbin table, ie. the table: 134 * fuse | speedbin 135 * -----+--------- 136 * 0 | 0 137 * 169 | 1 138 * 174 | 2 139 * 140 * would be declared as: 141 * 142 * .speedbins = ADRENO_SPEEDBINS( 143 * { 0, 0 }, 144 * { 169, 1 }, 145 * { 174, 2 }, 146 * ), 147 */ 148 #define ADRENO_SPEEDBINS(tbl...) (struct adreno_speedbin[]) { tbl {SHRT_MAX, 0} } 149 150 struct adreno_protect { 151 const uint32_t *regs; 152 uint32_t count; 153 uint32_t count_max; 154 }; 155 156 #define DECLARE_ADRENO_PROTECT(name, __count_max) \ 157 static const struct adreno_protect name = { \ 158 .regs = name ## _regs, \ 159 .count = ARRAY_SIZE(name ## _regs), \ 160 .count_max = __count_max, \ 161 }; 162 163 struct adreno_reglist_list { 164 /** @reg: List of register **/ 165 const u32 *regs; 166 /** @count: Number of registers in the list **/ 167 u32 count; 168 }; 169 170 #define DECLARE_ADRENO_REGLIST_LIST(name) \ 171 static const struct adreno_reglist_list name = { \ 172 .regs = name ## _regs, \ 173 .count = ARRAY_SIZE(name ## _regs), \ 174 }; 175 176 struct adreno_gpu { 177 struct msm_gpu base; 178 const struct adreno_info *info; 179 uint32_t chip_id; 180 uint16_t speedbin; 181 const struct adreno_gpu_funcs *funcs; 182 183 /* interesting register offsets to dump: */ 184 const unsigned int *registers; 185 186 /* 187 * Are we loading fw from legacy path? Prior to addition 188 * of gpu firmware to linux-firmware, the fw files were 189 * placed in toplevel firmware directory, following qcom's 190 * android kernel. But linux-firmware preferred they be 191 * placed in a 'qcom' subdirectory. 192 * 193 * For backwards compatibility, we try first to load from 194 * the new path, using request_firmware_direct() to avoid 195 * any potential timeout waiting for usermode helper, then 196 * fall back to the old path (with direct load). And 197 * finally fall back to request_firmware() with the new 198 * path to allow the usermode helper. 199 */ 200 enum { 201 FW_LOCATION_UNKNOWN = 0, 202 FW_LOCATION_NEW, /* /lib/firmware/qcom/$fwfile */ 203 FW_LOCATION_LEGACY, /* /lib/firmware/$fwfile */ 204 FW_LOCATION_HELPER, 205 } fwloc; 206 207 /* firmware: */ 208 const struct firmware *fw[ADRENO_FW_MAX]; 209 210 /* 211 * The migration to the central UBWC config db is still in flight - keep 212 * a copy containing some local fixups until that's done. 213 */ 214 const struct qcom_ubwc_cfg_data *ubwc_config; 215 struct qcom_ubwc_cfg_data _ubwc_config; 216 217 /* 218 * Register offsets are different between some GPUs. 219 * GPU specific offsets will be exported by GPU specific 220 * code (a3xx_gpu.c) and stored in this common location. 221 */ 222 const unsigned int *reg_offsets; 223 bool gmu_is_wrapper; 224 225 bool has_ray_tracing; 226 227 u64 uche_trap_base; 228 }; 229 #define to_adreno_gpu(x) container_of(x, struct adreno_gpu, base) 230 231 struct adreno_ocmem { 232 struct ocmem *ocmem; 233 unsigned long base; 234 void *hdl; 235 }; 236 237 /* platform config data (ie. from DT, or pdata) */ 238 struct adreno_platform_config { 239 uint32_t chip_id; 240 const struct adreno_info *info; 241 }; 242 243 #define ADRENO_IDLE_TIMEOUT msecs_to_jiffies(1000) 244 245 #define spin_until(X) ({ \ 246 int __ret = -ETIMEDOUT; \ 247 unsigned long __t = jiffies + ADRENO_IDLE_TIMEOUT; \ 248 do { \ 249 if (X) { \ 250 __ret = 0; \ 251 break; \ 252 } \ 253 } while (time_before(jiffies, __t)); \ 254 __ret; \ 255 }) 256 257 static inline uint8_t adreno_patchid(const struct adreno_gpu *gpu) 258 { 259 /* It is probably ok to assume legacy "adreno_rev" format 260 * for all a6xx devices, but probably best to limit this 261 * to older things. 262 */ 263 WARN_ON_ONCE(gpu->info->family >= ADRENO_6XX_GEN1); 264 return gpu->chip_id & 0xff; 265 } 266 267 static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn) 268 { 269 if (WARN_ON_ONCE(!gpu->info)) 270 return false; 271 return gpu->info->revn == revn; 272 } 273 274 static inline bool adreno_has_gmu_wrapper(const struct adreno_gpu *gpu) 275 { 276 return gpu->gmu_is_wrapper; 277 } 278 279 static inline bool adreno_is_a2xx(const struct adreno_gpu *gpu) 280 { 281 if (WARN_ON_ONCE(!gpu->info)) 282 return false; 283 return gpu->info->family <= ADRENO_2XX_GEN2; 284 } 285 286 static inline bool adreno_is_a20x(const struct adreno_gpu *gpu) 287 { 288 if (WARN_ON_ONCE(!gpu->info)) 289 return false; 290 return gpu->info->family == ADRENO_2XX_GEN1; 291 } 292 293 static inline bool adreno_is_a225(const struct adreno_gpu *gpu) 294 { 295 return adreno_is_revn(gpu, 225); 296 } 297 298 static inline bool adreno_is_a305(const struct adreno_gpu *gpu) 299 { 300 return adreno_is_revn(gpu, 305); 301 } 302 303 static inline bool adreno_is_a305b(const struct adreno_gpu *gpu) 304 { 305 return gpu->info->chip_ids[0] == 0x03000512; 306 } 307 308 static inline bool adreno_is_a306(const struct adreno_gpu *gpu) 309 { 310 /* yes, 307, because a305c is 306 */ 311 return adreno_is_revn(gpu, 307); 312 } 313 314 static inline bool adreno_is_a306a(const struct adreno_gpu *gpu) 315 { 316 /* a306a (marketing name is a308) */ 317 return adreno_is_revn(gpu, 308); 318 } 319 320 static inline bool adreno_is_a320(const struct adreno_gpu *gpu) 321 { 322 return adreno_is_revn(gpu, 320); 323 } 324 325 static inline bool adreno_is_a330(const struct adreno_gpu *gpu) 326 { 327 return adreno_is_revn(gpu, 330); 328 } 329 330 static inline bool adreno_is_a330v2(const struct adreno_gpu *gpu) 331 { 332 return adreno_is_a330(gpu) && (adreno_patchid(gpu) > 0); 333 } 334 335 static inline int adreno_is_a405(const struct adreno_gpu *gpu) 336 { 337 return adreno_is_revn(gpu, 405); 338 } 339 340 static inline int adreno_is_a420(const struct adreno_gpu *gpu) 341 { 342 return adreno_is_revn(gpu, 420); 343 } 344 345 static inline int adreno_is_a430(const struct adreno_gpu *gpu) 346 { 347 return adreno_is_revn(gpu, 430); 348 } 349 350 static inline int adreno_is_a505(const struct adreno_gpu *gpu) 351 { 352 return adreno_is_revn(gpu, 505); 353 } 354 355 static inline int adreno_is_a506(const struct adreno_gpu *gpu) 356 { 357 return adreno_is_revn(gpu, 506); 358 } 359 360 static inline int adreno_is_a508(const struct adreno_gpu *gpu) 361 { 362 return adreno_is_revn(gpu, 508); 363 } 364 365 static inline int adreno_is_a509(const struct adreno_gpu *gpu) 366 { 367 return adreno_is_revn(gpu, 509); 368 } 369 370 static inline int adreno_is_a510(const struct adreno_gpu *gpu) 371 { 372 return adreno_is_revn(gpu, 510); 373 } 374 375 static inline int adreno_is_a512(const struct adreno_gpu *gpu) 376 { 377 return adreno_is_revn(gpu, 512); 378 } 379 380 static inline int adreno_is_a530(const struct adreno_gpu *gpu) 381 { 382 return adreno_is_revn(gpu, 530); 383 } 384 385 static inline int adreno_is_a540(const struct adreno_gpu *gpu) 386 { 387 return adreno_is_revn(gpu, 540); 388 } 389 390 static inline int adreno_is_a610(const struct adreno_gpu *gpu) 391 { 392 return adreno_is_revn(gpu, 610); 393 } 394 395 static inline int adreno_is_a618(const struct adreno_gpu *gpu) 396 { 397 return adreno_is_revn(gpu, 618); 398 } 399 400 static inline int adreno_is_a619(const struct adreno_gpu *gpu) 401 { 402 return adreno_is_revn(gpu, 619); 403 } 404 405 static inline int adreno_is_a619_holi(const struct adreno_gpu *gpu) 406 { 407 return adreno_is_a619(gpu) && adreno_has_gmu_wrapper(gpu); 408 } 409 410 static inline int adreno_is_a621(const struct adreno_gpu *gpu) 411 { 412 return gpu->info->chip_ids[0] == 0x06020100; 413 } 414 415 static inline int adreno_is_a623(const struct adreno_gpu *gpu) 416 { 417 return gpu->info->chip_ids[0] == 0x06020300; 418 } 419 420 static inline int adreno_is_a630(const struct adreno_gpu *gpu) 421 { 422 return adreno_is_revn(gpu, 630); 423 } 424 425 static inline int adreno_is_a640(const struct adreno_gpu *gpu) 426 { 427 return adreno_is_revn(gpu, 640); 428 } 429 430 static inline int adreno_is_a650(const struct adreno_gpu *gpu) 431 { 432 return adreno_is_revn(gpu, 650); 433 } 434 435 static inline int adreno_is_7c3(const struct adreno_gpu *gpu) 436 { 437 return gpu->info->chip_ids[0] == 0x06030500; 438 } 439 440 static inline int adreno_is_a660(const struct adreno_gpu *gpu) 441 { 442 return adreno_is_revn(gpu, 660); 443 } 444 445 static inline int adreno_is_a680(const struct adreno_gpu *gpu) 446 { 447 return adreno_is_revn(gpu, 680); 448 } 449 450 static inline int adreno_is_a663(const struct adreno_gpu *gpu) 451 { 452 return gpu->info->chip_ids[0] == 0x06060300; 453 } 454 455 static inline int adreno_is_a690(const struct adreno_gpu *gpu) 456 { 457 return gpu->info->chip_ids[0] == 0x06090000; 458 } 459 460 static inline int adreno_is_a702(const struct adreno_gpu *gpu) 461 { 462 return gpu->info->chip_ids[0] == 0x07000200; 463 } 464 465 static inline int adreno_is_a610_family(const struct adreno_gpu *gpu) 466 { 467 if (WARN_ON_ONCE(!gpu->info)) 468 return false; 469 470 /* TODO: A612 */ 471 return adreno_is_a610(gpu) || adreno_is_a702(gpu); 472 } 473 474 /* TODO: 615/616 */ 475 static inline int adreno_is_a615_family(const struct adreno_gpu *gpu) 476 { 477 return adreno_is_a618(gpu) || 478 adreno_is_a619(gpu); 479 } 480 481 static inline int adreno_is_a630_family(const struct adreno_gpu *gpu) 482 { 483 if (WARN_ON_ONCE(!gpu->info)) 484 return false; 485 return gpu->info->family == ADRENO_6XX_GEN1; 486 } 487 488 static inline int adreno_is_a660_family(const struct adreno_gpu *gpu) 489 { 490 if (WARN_ON_ONCE(!gpu->info)) 491 return false; 492 return gpu->info->family == ADRENO_6XX_GEN4; 493 } 494 495 /* check for a650, a660, or any derivatives */ 496 static inline int adreno_is_a650_family(const struct adreno_gpu *gpu) 497 { 498 if (WARN_ON_ONCE(!gpu->info)) 499 return false; 500 return gpu->info->family == ADRENO_6XX_GEN3 || 501 gpu->info->family == ADRENO_6XX_GEN4; 502 } 503 504 static inline int adreno_is_a640_family(const struct adreno_gpu *gpu) 505 { 506 if (WARN_ON_ONCE(!gpu->info)) 507 return false; 508 return gpu->info->family == ADRENO_6XX_GEN2; 509 } 510 511 static inline int adreno_is_a730(struct adreno_gpu *gpu) 512 { 513 return gpu->info->chip_ids[0] == 0x07030001; 514 } 515 516 static inline int adreno_is_a740(struct adreno_gpu *gpu) 517 { 518 return gpu->info->chip_ids[0] == 0x43050a01; 519 } 520 521 static inline int adreno_is_a750(struct adreno_gpu *gpu) 522 { 523 return gpu->info->chip_ids[0] == 0x43051401; 524 } 525 526 static inline int adreno_is_x185(struct adreno_gpu *gpu) 527 { 528 return gpu->info->chip_ids[0] == 0x43050c01; 529 } 530 531 static inline int adreno_is_a740_family(struct adreno_gpu *gpu) 532 { 533 if (WARN_ON_ONCE(!gpu->info)) 534 return false; 535 return gpu->info->family == ADRENO_7XX_GEN2 || 536 gpu->info->family == ADRENO_7XX_GEN3; 537 } 538 539 static inline int adreno_is_a750_family(struct adreno_gpu *gpu) 540 { 541 return gpu->info->family == ADRENO_7XX_GEN3; 542 } 543 544 static inline int adreno_is_a7xx(struct adreno_gpu *gpu) 545 { 546 /* Update with non-fake (i.e. non-A702) Gen 7 GPUs */ 547 return gpu->info->family == ADRENO_7XX_GEN1 || 548 adreno_is_a740_family(gpu); 549 } 550 551 /* Put vm_start above 32b to catch issues with not setting xyz_BASE_HI */ 552 #define ADRENO_VM_START 0x100000000ULL 553 u64 adreno_private_vm_size(struct msm_gpu *gpu); 554 int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx, 555 uint32_t param, uint64_t *value, uint32_t *len); 556 int adreno_set_param(struct msm_gpu *gpu, struct msm_context *ctx, 557 uint32_t param, uint64_t value, uint32_t len); 558 const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu, 559 const char *fwname); 560 struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu, 561 const struct firmware *fw, u64 *iova); 562 int adreno_hw_init(struct msm_gpu *gpu); 563 void adreno_recover(struct msm_gpu *gpu); 564 void adreno_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring, u32 reg); 565 bool adreno_idle(struct msm_gpu *gpu, struct msm_ringbuffer *ring); 566 #if defined(CONFIG_DEBUG_FS) || defined(CONFIG_DEV_COREDUMP) 567 void adreno_show(struct msm_gpu *gpu, struct msm_gpu_state *state, 568 struct drm_printer *p); 569 #endif 570 void adreno_dump_info(struct msm_gpu *gpu); 571 void adreno_dump(struct msm_gpu *gpu); 572 void adreno_wait_ring(struct msm_ringbuffer *ring, uint32_t ndwords); 573 struct msm_ringbuffer *adreno_active_ring(struct msm_gpu *gpu); 574 575 int adreno_gpu_ocmem_init(struct device *dev, struct adreno_gpu *adreno_gpu, 576 struct adreno_ocmem *ocmem); 577 void adreno_gpu_ocmem_cleanup(struct adreno_ocmem *ocmem); 578 579 int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, 580 struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs, 581 int nr_rings); 582 void adreno_gpu_cleanup(struct adreno_gpu *gpu); 583 int adreno_load_fw(struct adreno_gpu *adreno_gpu); 584 585 void adreno_gpu_state_destroy(struct msm_gpu_state *state); 586 587 int adreno_gpu_state_get(struct msm_gpu *gpu, struct msm_gpu_state *state); 588 int adreno_gpu_state_put(struct msm_gpu_state *state); 589 void adreno_show_object(struct drm_printer *p, void **ptr, int len, 590 bool *encoded); 591 592 /* 593 * Common helper function to initialize the default address space for arm-smmu 594 * attached targets 595 */ 596 struct drm_gpuvm * 597 adreno_create_vm(struct msm_gpu *gpu, 598 struct platform_device *pdev); 599 600 struct drm_gpuvm * 601 adreno_iommu_create_vm(struct msm_gpu *gpu, 602 struct platform_device *pdev, 603 unsigned long quirks); 604 605 int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags, 606 struct adreno_smmu_fault_info *info, const char *block, 607 u32 scratch[4]); 608 609 void adreno_check_and_reenable_stall(struct adreno_gpu *gpu); 610 611 int adreno_read_speedbin(struct device *dev, u32 *speedbin); 612 613 /* 614 * For a5xx and a6xx targets load the zap shader that is used to pull the GPU 615 * out of secure mode 616 */ 617 int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid); 618 619 /* ringbuffer helpers (the parts that are adreno specific) */ 620 621 static inline void 622 OUT_PKT0(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt) 623 { 624 adreno_wait_ring(ring, cnt+1); 625 OUT_RING(ring, CP_TYPE0_PKT | ((cnt-1) << 16) | (regindx & 0x7FFF)); 626 } 627 628 /* no-op packet: */ 629 static inline void 630 OUT_PKT2(struct msm_ringbuffer *ring) 631 { 632 adreno_wait_ring(ring, 1); 633 OUT_RING(ring, CP_TYPE2_PKT); 634 } 635 636 static inline void 637 OUT_PKT3(struct msm_ringbuffer *ring, uint8_t opcode, uint16_t cnt) 638 { 639 adreno_wait_ring(ring, cnt+1); 640 OUT_RING(ring, CP_TYPE3_PKT | ((cnt-1) << 16) | ((opcode & 0xFF) << 8)); 641 } 642 643 static inline u32 PM4_PARITY(u32 val) 644 { 645 return (0x9669 >> (0xF & (val ^ 646 (val >> 4) ^ (val >> 8) ^ (val >> 12) ^ 647 (val >> 16) ^ ((val) >> 20) ^ (val >> 24) ^ 648 (val >> 28)))) & 1; 649 } 650 651 /* Maximum number of values that can be executed for one opcode */ 652 #define TYPE4_MAX_PAYLOAD 127 653 654 #define PKT4(_reg, _cnt) \ 655 (CP_TYPE4_PKT | ((_cnt) << 0) | (PM4_PARITY((_cnt)) << 7) | \ 656 (((_reg) & 0x3FFFF) << 8) | (PM4_PARITY((_reg)) << 27)) 657 658 static inline void 659 OUT_PKT4(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt) 660 { 661 adreno_wait_ring(ring, cnt + 1); 662 OUT_RING(ring, PKT4(regindx, cnt)); 663 } 664 665 #define PKT7(opcode, cnt) \ 666 (CP_TYPE7_PKT | (cnt << 0) | (PM4_PARITY(cnt) << 15) | \ 667 ((opcode & 0x7F) << 16) | (PM4_PARITY(opcode) << 23)) 668 669 static inline void 670 OUT_PKT7(struct msm_ringbuffer *ring, uint8_t opcode, uint16_t cnt) 671 { 672 adreno_wait_ring(ring, cnt + 1); 673 OUT_RING(ring, PKT7(opcode, cnt)); 674 } 675 676 struct msm_gpu *a2xx_gpu_init(struct drm_device *dev); 677 struct msm_gpu *a3xx_gpu_init(struct drm_device *dev); 678 struct msm_gpu *a4xx_gpu_init(struct drm_device *dev); 679 struct msm_gpu *a5xx_gpu_init(struct drm_device *dev); 680 struct msm_gpu *a6xx_gpu_init(struct drm_device *dev); 681 682 static inline uint32_t get_wptr(struct msm_ringbuffer *ring) 683 { 684 return (ring->cur - ring->start) % (MSM_GPU_RINGBUFFER_SZ >> 2); 685 } 686 687 /* 688 * Given a register and a count, return a value to program into 689 * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len 690 * registers starting at _reg. 691 * 692 * The register base needs to be a multiple of the length. If it is not, the 693 * hardware will quietly mask off the bits for you and shift the size. For 694 * example, if you intend the protection to start at 0x07 for a length of 4 695 * (0x07-0x0A) the hardware will actually protect (0x04-0x07) which might 696 * expose registers you intended to protect! 697 */ 698 #define ADRENO_PROTECT_RW(_reg, _len) \ 699 ((1 << 30) | (1 << 29) | \ 700 ((ilog2((_len)) & 0x1F) << 24) | (((_reg) << 2) & 0xFFFFF)) 701 702 /* 703 * Same as above, but allow reads over the range. For areas of mixed use (such 704 * as performance counters) this allows us to protect a much larger range with a 705 * single register 706 */ 707 #define ADRENO_PROTECT_RDONLY(_reg, _len) \ 708 ((1 << 29) \ 709 ((ilog2((_len)) & 0x1F) << 24) | (((_reg) << 2) & 0xFFFFF)) 710 711 712 #define gpu_poll_timeout(gpu, addr, val, cond, interval, timeout) \ 713 readl_poll_timeout((gpu)->mmio + ((addr) << 2), val, cond, \ 714 interval, timeout) 715 716 #endif /* __ADRENO_GPU_H__ */ 717