2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef __ADRENO_GPU_H__
19 #define __ADRENO_GPU_H__
21 #include <linux/firmware.h>
25 #include "adreno_common.xml.h"
26 #include "adreno_pm4.xml.h"
35 #define ADRENO_REV(core, major, minor, patchid) \
36 ((struct adreno_rev){ core, major, minor, patchid })
38 struct adreno_gpu_funcs
{
39 struct msm_gpu_funcs base
;
44 struct adreno_rbmemptrs
{
45 volatile uint32_t rptr
;
46 volatile uint32_t wptr
;
47 volatile uint32_t fence
;
52 struct adreno_rev rev
;
53 const struct adreno_info
*info
;
54 uint32_t gmem
; /* actual gmem size */
55 uint32_t revn
; /* numeric revision name */
56 const struct adreno_gpu_funcs
*funcs
;
59 const struct firmware
*pm4
, *pfp
;
61 /* ringbuffer rptr/wptr: */
62 // TODO should this be in msm_ringbuffer? I think it would be
63 // different for z180..
64 struct adreno_rbmemptrs
*memptrs
;
65 struct drm_gem_object
*memptrs_bo
;
66 uint32_t memptrs_iova
;
68 #define to_adreno_gpu(x) container_of(x, struct adreno_gpu, base)
70 /* platform config data (ie. from DT, or pdata) */
71 struct adreno_platform_config
{
72 struct adreno_rev rev
;
73 uint32_t fast_rate
, slow_rate
, bus_freq
;
74 #ifdef CONFIG_MSM_BUS_SCALING
75 struct msm_bus_scale_pdata
*bus_scale_table
;
79 #define ADRENO_IDLE_TIMEOUT (20 * 1000)
81 static inline bool adreno_is_a3xx(struct adreno_gpu
*gpu
)
83 return (gpu
->revn
>= 300) && (gpu
->revn
< 400);
86 static inline bool adreno_is_a305(struct adreno_gpu
*gpu
)
88 return gpu
->revn
== 305;
91 static inline bool adreno_is_a320(struct adreno_gpu
*gpu
)
93 return gpu
->revn
== 320;
96 static inline bool adreno_is_a330(struct adreno_gpu
*gpu
)
98 return gpu
->revn
== 330;
101 static inline bool adreno_is_a330v2(struct adreno_gpu
*gpu
)
103 return adreno_is_a330(gpu
) && (gpu
->rev
.patchid
> 0);
106 int adreno_get_param(struct msm_gpu
*gpu
, uint32_t param
, uint64_t *value
);
107 int adreno_hw_init(struct msm_gpu
*gpu
);
108 uint32_t adreno_last_fence(struct msm_gpu
*gpu
);
109 void adreno_recover(struct msm_gpu
*gpu
);
110 int adreno_submit(struct msm_gpu
*gpu
, struct msm_gem_submit
*submit
,
111 struct msm_file_private
*ctx
);
112 void adreno_flush(struct msm_gpu
*gpu
);
113 void adreno_idle(struct msm_gpu
*gpu
);
114 #ifdef CONFIG_DEBUG_FS
115 void adreno_show(struct msm_gpu
*gpu
, struct seq_file
*m
);
117 void adreno_wait_ring(struct msm_gpu
*gpu
, uint32_t ndwords
);
119 int adreno_gpu_init(struct drm_device
*drm
, struct platform_device
*pdev
,
120 struct adreno_gpu
*gpu
, const struct adreno_gpu_funcs
*funcs
,
121 struct adreno_rev rev
);
122 void adreno_gpu_cleanup(struct adreno_gpu
*gpu
);
125 /* ringbuffer helpers (the parts that are adreno specific) */
128 OUT_PKT0(struct msm_ringbuffer
*ring
, uint16_t regindx
, uint16_t cnt
)
130 adreno_wait_ring(ring
->gpu
, cnt
+1);
131 OUT_RING(ring
, CP_TYPE0_PKT
| ((cnt
-1) << 16) | (regindx
& 0x7FFF));
136 OUT_PKT2(struct msm_ringbuffer
*ring
)
138 adreno_wait_ring(ring
->gpu
, 1);
139 OUT_RING(ring
, CP_TYPE2_PKT
);
143 OUT_PKT3(struct msm_ringbuffer
*ring
, uint8_t opcode
, uint16_t cnt
)
145 adreno_wait_ring(ring
->gpu
, cnt
+1);
146 OUT_RING(ring
, CP_TYPE3_PKT
| ((cnt
-1) << 16) | ((opcode
& 0xFF) << 8));
150 #endif /* __ADRENO_GPU_H__ */