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