2 * Copyright (C) 2015 Etnaviv Project
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef __ETNAVIV_GPU_H__
18 #define __ETNAVIV_GPU_H__
20 #include <linux/clk.h>
21 #include <linux/regulator/consumer.h>
23 #include "etnaviv_cmdbuf.h"
24 #include "etnaviv_drv.h"
26 struct etnaviv_gem_submit;
27 struct etnaviv_vram_mapping;
29 struct etnaviv_chip_identity {
36 /* Supported feature fields. */
39 /* Supported minor feature fields. */
53 /* Number of streams supported. */
56 /* Total number of temporary registers per thread. */
59 /* Maximum number of threads. */
62 /* Number of shader cores. */
63 u32 shader_core_count;
65 /* Size of the vertex cache. */
66 u32 vertex_cache_size;
68 /* Number of entries in the vertex output buffer. */
69 u32 vertex_output_buffer_size;
71 /* Number of pixel pipes. */
74 /* Number of instructions. */
75 u32 instruction_count;
77 /* Number of constants. */
83 /* Number of varyings */
87 enum etnaviv_sec_mode {
93 struct etnaviv_event {
94 struct dma_fence *fence;
95 struct etnaviv_gem_submit *submit;
97 void (*sync_point)(struct etnaviv_gpu *gpu, struct etnaviv_event *event);
100 struct etnaviv_cmdbuf_suballoc;
101 struct etnaviv_cmdbuf;
103 #define ETNA_NR_EVENTS 30
106 struct drm_device *drm;
107 struct thermal_cooling_device *cooling;
110 struct etnaviv_chip_identity identity;
111 enum etnaviv_sec_mode sec_mode;
112 struct etnaviv_file_private *lastctx;
113 struct workqueue_struct *wq;
114 struct drm_gpu_scheduler sched;
117 struct etnaviv_cmdbuf buffer;
120 /* bus base address of memory */
123 /* event management: */
124 DECLARE_BITMAP(event_bitmap, ETNA_NR_EVENTS);
125 struct etnaviv_event event[ETNA_NR_EVENTS];
126 struct completion event_free;
127 spinlock_t event_spinlock;
131 /* Fencing support */
132 struct mutex fence_idr_lock;
133 struct idr fence_idr;
137 wait_queue_head_t fence_event;
139 spinlock_t fence_spinlock;
141 /* worker for handling 'sync' points: */
142 struct work_struct sync_point_work;
143 int sync_point_event;
148 struct etnaviv_iommu *mmu;
149 struct etnaviv_cmdbuf_suballoc *cmdbuf_suballoc;
154 struct clk *clk_core;
155 struct clk *clk_shader;
157 unsigned int freq_scale;
158 unsigned long base_rate_core;
159 unsigned long base_rate_shader;
162 static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data)
164 etnaviv_writel(data, gpu->mmio + reg);
167 static inline u32 gpu_read(struct etnaviv_gpu *gpu, u32 reg)
169 return etnaviv_readl(gpu->mmio + reg);
172 static inline bool fence_completed(struct etnaviv_gpu *gpu, u32 fence)
174 return fence_after_eq(gpu->completed_fence, fence);
177 int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value);
179 int etnaviv_gpu_init(struct etnaviv_gpu *gpu);
180 bool etnaviv_fill_identity_from_hwdb(struct etnaviv_gpu *gpu);
182 #ifdef CONFIG_DEBUG_FS
183 int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m);
186 void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu);
187 void etnaviv_gpu_retire(struct etnaviv_gpu *gpu);
188 int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
189 u32 fence, struct timespec *timeout);
190 int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
191 struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout);
192 struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit);
193 int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu);
194 void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu);
195 int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms);
196 void etnaviv_gpu_start_fe(struct etnaviv_gpu *gpu, u32 address, u16 prefetch);
198 extern struct platform_driver etnaviv_gpu_driver;
200 #endif /* __ETNAVIV_GPU_H__ */