aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/msm/adreno/adreno_gpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/msm/adreno/adreno_gpu.h')
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
new file mode 100644
index 000000000000..6b49c4f27fec
--- /dev/null
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -0,0 +1,142 @@
1/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
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.
8 *
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
12 * more details.
13 *
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/>.
16 */
17
18#ifndef __ADRENO_GPU_H__
19#define __ADRENO_GPU_H__
20
21#include <linux/firmware.h>
22
23#include "msm_gpu.h"
24
25#include "adreno_common.xml.h"
26#include "adreno_pm4.xml.h"
27
28struct adreno_rev {
29 uint8_t core;
30 uint8_t major;
31 uint8_t minor;
32 uint8_t patchid;
33};
34
35#define ADRENO_REV(core, major, minor, patchid) \
36 ((struct adreno_rev){ core, major, minor, patchid })
37
38struct adreno_gpu_funcs {
39 struct msm_gpu_funcs base;
40};
41
42struct adreno_info;
43
44struct adreno_rbmemptrs {
45 volatile uint32_t rptr;
46 volatile uint32_t wptr;
47 volatile uint32_t fence;
48};
49
50struct adreno_gpu {
51 struct msm_gpu base;
52 struct adreno_rev rev;
53 const struct adreno_info *info;
54 uint32_t revn; /* numeric revision name */
55 const struct adreno_gpu_funcs *funcs;
56
57 uint32_t last_fence;
58
59 /* firmware: */
60 const struct firmware *pm4, *pfp;
61
62 /* ringbuffer rptr/wptr: */
63 // TODO should this be in msm_ringbuffer? I think it would be
64 // different for z180..
65 struct adreno_rbmemptrs *memptrs;
66 struct drm_gem_object *memptrs_bo;
67 uint32_t memptrs_iova;
68};
69#define to_adreno_gpu(x) container_of(x, struct adreno_gpu, base)
70
71/* platform config data (ie. from DT, or pdata) */
72struct adreno_platform_config {
73 struct adreno_rev rev;
74 uint32_t fast_rate, slow_rate, bus_freq;
75};
76
77#define ADRENO_IDLE_TIMEOUT (20 * 1000)
78
79static inline bool adreno_is_a3xx(struct adreno_gpu *gpu)
80{
81 return (gpu->revn >= 300) && (gpu->revn < 400);
82}
83
84static inline bool adreno_is_a305(struct adreno_gpu *gpu)
85{
86 return gpu->revn == 305;
87}
88
89static inline bool adreno_is_a320(struct adreno_gpu *gpu)
90{
91 return gpu->revn == 320;
92}
93
94static inline bool adreno_is_a330(struct adreno_gpu *gpu)
95{
96 return gpu->revn == 330;
97}
98
99int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value);
100int adreno_hw_init(struct msm_gpu *gpu);
101uint32_t adreno_last_fence(struct msm_gpu *gpu);
102int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
103 struct msm_file_private *ctx);
104void adreno_flush(struct msm_gpu *gpu);
105void adreno_idle(struct msm_gpu *gpu);
106#ifdef CONFIG_DEBUG_FS
107void adreno_show(struct msm_gpu *gpu, struct seq_file *m);
108#endif
109void adreno_wait_ring(struct msm_gpu *gpu, uint32_t ndwords);
110
111int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
112 struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs,
113 struct adreno_rev rev);
114void adreno_gpu_cleanup(struct adreno_gpu *gpu);
115
116
117/* ringbuffer helpers (the parts that are adreno specific) */
118
119static inline void
120OUT_PKT0(struct msm_ringbuffer *ring, uint16_t regindx, uint16_t cnt)
121{
122 adreno_wait_ring(ring->gpu, cnt+1);
123 OUT_RING(ring, CP_TYPE0_PKT | ((cnt-1) << 16) | (regindx & 0x7FFF));
124}
125
126/* no-op packet: */
127static inline void
128OUT_PKT2(struct msm_ringbuffer *ring)
129{
130 adreno_wait_ring(ring->gpu, 1);
131 OUT_RING(ring, CP_TYPE2_PKT);
132}
133
134static inline void
135OUT_PKT3(struct msm_ringbuffer *ring, uint8_t opcode, uint16_t cnt)
136{
137 adreno_wait_ring(ring->gpu, cnt+1);
138 OUT_RING(ring, CP_TYPE3_PKT | ((cnt-1) << 16) | ((opcode & 0xFF) << 8));
139}
140
141
142#endif /* __ADRENO_GPU_H__ */