18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2017, 2019 The Linux Foundation. All rights reserved. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef __A6XX_GPU_H__ 58c2ecf20Sopenharmony_ci#define __A6XX_GPU_H__ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "adreno_gpu.h" 98c2ecf20Sopenharmony_ci#include "a6xx.xml.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "a6xx_gmu.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciextern bool hang_debug; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct a6xx_gpu { 168c2ecf20Sopenharmony_ci struct adreno_gpu base; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci struct drm_gem_object *sqe_bo; 198c2ecf20Sopenharmony_ci uint64_t sqe_iova; 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci struct msm_ringbuffer *cur_ring; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci /** 248c2ecf20Sopenharmony_ci * cur_ctx_seqno: 258c2ecf20Sopenharmony_ci * 268c2ecf20Sopenharmony_ci * The ctx->seqno value of the context with current pgtables 278c2ecf20Sopenharmony_ci * installed. Tracked by seqno rather than pointer value to 288c2ecf20Sopenharmony_ci * avoid dangling pointers, and cases where a ctx can be freed 298c2ecf20Sopenharmony_ci * and a new one created with the same address. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_ci int cur_ctx_seqno; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci struct a6xx_gmu gmu; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci struct drm_gem_object *shadow_bo; 368c2ecf20Sopenharmony_ci uint64_t shadow_iova; 378c2ecf20Sopenharmony_ci uint32_t *shadow; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci bool has_whereami; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define to_a6xx_gpu(x) container_of(x, struct a6xx_gpu, base) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* 458c2ecf20Sopenharmony_ci * Given a register and a count, return a value to program into 468c2ecf20Sopenharmony_ci * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len 478c2ecf20Sopenharmony_ci * registers starting at _reg. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci#define A6XX_PROTECT_NORDWR(_reg, _len) \ 508c2ecf20Sopenharmony_ci ((1 << 31) | \ 518c2ecf20Sopenharmony_ci (((_len) & 0x3FFF) << 18) | ((_reg) & 0x3FFFF)) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * Same as above, but allow reads over the range. For areas of mixed use (such 558c2ecf20Sopenharmony_ci * as performance counters) this allows us to protect a much larger range with a 568c2ecf20Sopenharmony_ci * single register 578c2ecf20Sopenharmony_ci */ 588c2ecf20Sopenharmony_ci#define A6XX_PROTECT_RDONLY(_reg, _len) \ 598c2ecf20Sopenharmony_ci ((((_len) & 0x3FFF) << 18) | ((_reg) & 0x3FFFF)) 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic inline bool a6xx_has_gbif(struct adreno_gpu *gpu) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci if(adreno_is_a630(gpu)) 648c2ecf20Sopenharmony_ci return false; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci return true; 678c2ecf20Sopenharmony_ci} 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define shadowptr(_a6xx_gpu, _ring) ((_a6xx_gpu)->shadow_iova + \ 708c2ecf20Sopenharmony_ci ((_ring)->id * sizeof(uint32_t))) 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciint a6xx_gmu_resume(struct a6xx_gpu *gpu); 738c2ecf20Sopenharmony_ciint a6xx_gmu_stop(struct a6xx_gpu *gpu); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciint a6xx_gmu_wait_for_idle(struct a6xx_gmu *gmu); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cibool a6xx_gmu_isidle(struct a6xx_gmu *gmu); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciint a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state); 808c2ecf20Sopenharmony_civoid a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state); 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciint a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node); 838c2ecf20Sopenharmony_civoid a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu); 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_civoid a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp); 868c2ecf20Sopenharmony_ciunsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_civoid a6xx_show(struct msm_gpu *gpu, struct msm_gpu_state *state, 898c2ecf20Sopenharmony_ci struct drm_printer *p); 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistruct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu); 928c2ecf20Sopenharmony_ciint a6xx_gpu_state_put(struct msm_gpu_state *state); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#endif /* __A6XX_GPU_H__ */ 95