rk, gpu :
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / mali_midg_regmap.h
1 /*
2  *
3  * (C) COPYRIGHT ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18
19
20 #ifndef _MIDGARD_REGMAP_H_
21 #define _MIDGARD_REGMAP_H_
22
23 /*
24  * Begin Register Offsets
25  */
26
27 #define GPU_CONTROL_BASE        0x0000
28 #define GPU_CONTROL_REG(r)      (GPU_CONTROL_BASE + (r))
29 #define GPU_ID                  0x000   /* (RO) GPU and revision identifier */
30 #define L2_FEATURES             0x004   /* (RO) Level 2 cache features */
31 #define L3_FEATURES             0x008   /* (RO) Level 3 cache features */
32 #define TILER_FEATURES          0x00C   /* (RO) Tiler Features */
33 #define MEM_FEATURES            0x010   /* (RO) Memory system features */
34 #define MMU_FEATURES            0x014   /* (RO) MMU features */
35 #define AS_PRESENT              0x018   /* (RO) Address space slots present */
36 #define JS_PRESENT              0x01C   /* (RO) Job slots present */
37 #define GPU_IRQ_RAWSTAT         0x020   /* (RW) */
38 #define GPU_IRQ_CLEAR           0x024   /* (WO) */
39 #define GPU_IRQ_MASK            0x028   /* (RW) */
40 #define GPU_IRQ_STATUS          0x02C   /* (RO) */
41
42 /* IRQ flags */
43 #define GPU_FAULT               (1 << 0)        /* A GPU Fault has occurred */
44 #define MULTIPLE_GPU_FAULTS     (1 << 7)        /* More than one GPU Fault occurred. */
45 #define RESET_COMPLETED         (1 << 8)        /* Set when a reset has completed. Intended to use with SOFT_RESET
46                                                    commands which may take time. */
47 #define POWER_CHANGED_SINGLE    (1 << 9)        /* Set when a single core has finished powering up or down. */
48 #define POWER_CHANGED_ALL       (1 << 10)       /* Set when all cores have finished powering up or down
49                                                    and the power manager is idle. */
50
51 #define PRFCNT_SAMPLE_COMPLETED (1 << 16)       /* Set when a performance count sample has completed. */
52 #define CLEAN_CACHES_COMPLETED  (1 << 17)       /* Set when a cache clean operation has completed. */
53
54 #define GPU_IRQ_REG_ALL (GPU_FAULT | MULTIPLE_GPU_FAULTS | RESET_COMPLETED \
55                         | POWER_CHANGED_ALL | PRFCNT_SAMPLE_COMPLETED)
56
57 #define GPU_COMMAND             0x030   /* (WO) */
58 #define GPU_STATUS              0x034   /* (RO) */
59
60 #define GROUPS_L2_COHERENT      (1 << 0)        /* Cores groups are l2 coherent */
61 #define GROUPS_L3_COHERENT      (1 << 1)        /* Cores groups are l3 coherent */
62
63 #define GPU_FAULTSTATUS         0x03C   /* (RO) GPU exception type and fault status */
64 #define GPU_FAULTADDRESS_LO     0x040   /* (RO) GPU exception fault address, low word */
65 #define GPU_FAULTADDRESS_HI     0x044   /* (RO) GPU exception fault address, high word */
66
67 #define PWR_KEY                 0x050   /* (WO) Power manager key register */
68 #define PWR_OVERRIDE0           0x054   /* (RW) Power manager override settings */
69 #define PWR_OVERRIDE1           0x058   /* (RW) Power manager override settings */
70
71 #define PRFCNT_BASE_LO          0x060   /* (RW) Performance counter memory region base address, low word */
72 #define PRFCNT_BASE_HI          0x064   /* (RW) Performance counter memory region base address, high word */
73 #define PRFCNT_CONFIG           0x068   /* (RW) Performance counter configuration */
74 #define PRFCNT_JM_EN            0x06C   /* (RW) Performance counter enable flags for Job Manager */
75 #define PRFCNT_SHADER_EN        0x070   /* (RW) Performance counter enable flags for shader cores */
76 #define PRFCNT_TILER_EN         0x074   /* (RW) Performance counter enable flags for tiler */
77 #define PRFCNT_L3_CACHE_EN      0x078   /* (RW) Performance counter enable flags for L3 cache */
78 #define PRFCNT_MMU_L2_EN        0x07C   /* (RW) Performance counter enable flags for MMU/L2 cache */
79
80 #define CYCLE_COUNT_LO          0x090   /* (RO) Cycle counter, low word */
81 #define CYCLE_COUNT_HI          0x094   /* (RO) Cycle counter, high word */
82 #define TIMESTAMP_LO            0x098   /* (RO) Global time stamp counter, low word */
83 #define TIMESTAMP_HI            0x09C   /* (RO) Global time stamp counter, high word */
84
85 #define THREAD_MAX_THREADS              0x0A0   /* (RO) Maximum number of threads per core */
86 #define THREAD_MAX_WORKGROUP_SIZE 0x0A4 /* (RO) Maximum workgroup size */
87 #define THREAD_MAX_BARRIER_SIZE 0x0A8   /* (RO) Maximum threads waiting at a barrier */
88 #define THREAD_FEATURES         0x0AC   /* (RO) Thread features */
89
90 #define TEXTURE_FEATURES_0      0x0B0   /* (RO) Support flags for indexed texture formats 0..31 */
91 #define TEXTURE_FEATURES_1      0x0B4   /* (RO) Support flags for indexed texture formats 32..63 */
92 #define TEXTURE_FEATURES_2      0x0B8   /* (RO) Support flags for indexed texture formats 64..95 */
93
94 #define TEXTURE_FEATURES_REG(n) GPU_CONTROL_REG(TEXTURE_FEATURES_0 + ((n) << 2))
95
96 #define JS0_FEATURES            0x0C0   /* (RO) Features of job slot 0 */
97 #define JS1_FEATURES            0x0C4   /* (RO) Features of job slot 1 */
98 #define JS2_FEATURES            0x0C8   /* (RO) Features of job slot 2 */
99 #define JS3_FEATURES            0x0CC   /* (RO) Features of job slot 3 */
100 #define JS4_FEATURES            0x0D0   /* (RO) Features of job slot 4 */
101 #define JS5_FEATURES            0x0D4   /* (RO) Features of job slot 5 */
102 #define JS6_FEATURES            0x0D8   /* (RO) Features of job slot 6 */
103 #define JS7_FEATURES            0x0DC   /* (RO) Features of job slot 7 */
104 #define JS8_FEATURES            0x0E0   /* (RO) Features of job slot 8 */
105 #define JS9_FEATURES            0x0E4   /* (RO) Features of job slot 9 */
106 #define JS10_FEATURES           0x0E8   /* (RO) Features of job slot 10 */
107 #define JS11_FEATURES           0x0EC   /* (RO) Features of job slot 11 */
108 #define JS12_FEATURES           0x0F0   /* (RO) Features of job slot 12 */
109 #define JS13_FEATURES           0x0F4   /* (RO) Features of job slot 13 */
110 #define JS14_FEATURES           0x0F8   /* (RO) Features of job slot 14 */
111 #define JS15_FEATURES           0x0FC   /* (RO) Features of job slot 15 */
112
113 #define JS_FEATURES_REG(n)      GPU_CONTROL_REG(JS0_FEATURES + ((n) << 2))
114
115 #define SHADER_PRESENT_LO       0x100   /* (RO) Shader core present bitmap, low word */
116 #define SHADER_PRESENT_HI       0x104   /* (RO) Shader core present bitmap, high word */
117
118 #define TILER_PRESENT_LO        0x110   /* (RO) Tiler core present bitmap, low word */
119 #define TILER_PRESENT_HI        0x114   /* (RO) Tiler core present bitmap, high word */
120
121 #define L2_PRESENT_LO           0x120   /* (RO) Level 2 cache present bitmap, low word */
122 #define L2_PRESENT_HI           0x124   /* (RO) Level 2 cache present bitmap, high word */
123
124 #define L3_PRESENT_LO           0x130   /* (RO) Level 3 cache present bitmap, low word */
125 #define L3_PRESENT_HI           0x134   /* (RO) Level 3 cache present bitmap, high word */
126
127 #define SHADER_READY_LO         0x140   /* (RO) Shader core ready bitmap, low word */
128 #define SHADER_READY_HI         0x144   /* (RO) Shader core ready bitmap, high word */
129
130 #define TILER_READY_LO          0x150   /* (RO) Tiler core ready bitmap, low word */
131 #define TILER_READY_HI          0x154   /* (RO) Tiler core ready bitmap, high word */
132
133 #define L2_READY_LO             0x160   /* (RO) Level 2 cache ready bitmap, low word */
134 #define L2_READY_HI             0x164   /* (RO) Level 2 cache ready bitmap, high word */
135
136 #define L3_READY_LO             0x170   /* (RO) Level 3 cache ready bitmap, low word */
137 #define L3_READY_HI             0x174   /* (RO) Level 3 cache ready bitmap, high word */
138
139 #define SHADER_PWRON_LO         0x180   /* (WO) Shader core power on bitmap, low word */
140 #define SHADER_PWRON_HI         0x184   /* (WO) Shader core power on bitmap, high word */
141
142 #define TILER_PWRON_LO          0x190   /* (WO) Tiler core power on bitmap, low word */
143 #define TILER_PWRON_HI          0x194   /* (WO) Tiler core power on bitmap, high word */
144
145 #define L2_PWRON_LO             0x1A0   /* (WO) Level 2 cache power on bitmap, low word */
146 #define L2_PWRON_HI             0x1A4   /* (WO) Level 2 cache power on bitmap, high word */
147
148 #define L3_PWRON_LO             0x1B0   /* (WO) Level 3 cache power on bitmap, low word */
149 #define L3_PWRON_HI             0x1B4   /* (WO) Level 3 cache power on bitmap, high word */
150
151 #define SHADER_PWROFF_LO        0x1C0   /* (WO) Shader core power off bitmap, low word */
152 #define SHADER_PWROFF_HI        0x1C4   /* (WO) Shader core power off bitmap, high word */
153
154 #define TILER_PWROFF_LO         0x1D0   /* (WO) Tiler core power off bitmap, low word */
155 #define TILER_PWROFF_HI         0x1D4   /* (WO) Tiler core power off bitmap, high word */
156
157 #define L2_PWROFF_LO            0x1E0   /* (WO) Level 2 cache power off bitmap, low word */
158 #define L2_PWROFF_HI            0x1E4   /* (WO) Level 2 cache power off bitmap, high word */
159
160 #define L3_PWROFF_LO            0x1F0   /* (WO) Level 3 cache power off bitmap, low word */
161 #define L3_PWROFF_HI            0x1F4   /* (WO) Level 3 cache power off bitmap, high word */
162
163 #define SHADER_PWRTRANS_LO      0x200   /* (RO) Shader core power transition bitmap, low word */
164 #define SHADER_PWRTRANS_HI      0x204   /* (RO) Shader core power transition bitmap, high word */
165
166 #define TILER_PWRTRANS_LO       0x210   /* (RO) Tiler core power transition bitmap, low word */
167 #define TILER_PWRTRANS_HI       0x214   /* (RO) Tiler core power transition bitmap, high word */
168
169 #define L2_PWRTRANS_LO          0x220   /* (RO) Level 2 cache power transition bitmap, low word */
170 #define L2_PWRTRANS_HI          0x224   /* (RO) Level 2 cache power transition bitmap, high word */
171
172 #define L3_PWRTRANS_LO          0x230   /* (RO) Level 3 cache power transition bitmap, low word */
173 #define L3_PWRTRANS_HI          0x234   /* (RO) Level 3 cache power transition bitmap, high word */
174
175 #define SHADER_PWRACTIVE_LO     0x240   /* (RO) Shader core active bitmap, low word */
176 #define SHADER_PWRACTIVE_HI     0x244   /* (RO) Shader core active bitmap, high word */
177
178 #define TILER_PWRACTIVE_LO      0x250   /* (RO) Tiler core active bitmap, low word */
179 #define TILER_PWRACTIVE_HI      0x254   /* (RO) Tiler core active bitmap, high word */
180
181 #define L2_PWRACTIVE_LO         0x260   /* (RO) Level 2 cache active bitmap, low word */
182 #define L2_PWRACTIVE_HI         0x264   /* (RO) Level 2 cache active bitmap, high word */
183
184 #define L3_PWRACTIVE_LO         0x270   /* (RO) Level 3 cache active bitmap, low word */
185 #define L3_PWRACTIVE_HI         0x274   /* (RO) Level 3 cache active bitmap, high word */
186
187 #define SHADER_CONFIG           0xF04   /* (RW) Shader core configuration settings (Implementation specific register) */
188 #define TILER_CONFIG            0xF08   /* (RW) Tiler core configuration settings (Implementation specific register) */
189 #define L2_MMU_CONFIG           0xF0C   /* (RW) Configuration of the L2 cache and MMU (Implementation specific register) */
190
191 #define JOB_CONTROL_BASE        0x1000
192
193 #define JOB_CONTROL_REG(r)      (JOB_CONTROL_BASE + (r))
194
195 #define JOB_IRQ_RAWSTAT         0x000   /* Raw interrupt status register */
196 #define JOB_IRQ_CLEAR           0x004   /* Interrupt clear register */
197 #define JOB_IRQ_MASK            0x008   /* Interrupt mask register */
198 #define JOB_IRQ_STATUS          0x00C   /* Interrupt status register */
199 #define JOB_IRQ_JS_STATE        0x010   /* status==active and _next == busy snapshot from last JOB_IRQ_CLEAR */
200 #define JOB_IRQ_THROTTLE        0x014   /* cycles to delay delivering an interrupt externally. The JOB_IRQ_STATUS is NOT affected by this, just the delivery of the interrupt.  */
201
202 #define JOB_SLOT0               0x800   /* Configuration registers for job slot 0 */
203 #define JOB_SLOT1               0x880   /* Configuration registers for job slot 1 */
204 #define JOB_SLOT2               0x900   /* Configuration registers for job slot 2 */
205 #define JOB_SLOT3               0x980   /* Configuration registers for job slot 3 */
206 #define JOB_SLOT4               0xA00   /* Configuration registers for job slot 4 */
207 #define JOB_SLOT5               0xA80   /* Configuration registers for job slot 5 */
208 #define JOB_SLOT6               0xB00   /* Configuration registers for job slot 6 */
209 #define JOB_SLOT7               0xB80   /* Configuration registers for job slot 7 */
210 #define JOB_SLOT8               0xC00   /* Configuration registers for job slot 8 */
211 #define JOB_SLOT9               0xC80   /* Configuration registers for job slot 9 */
212 #define JOB_SLOT10              0xD00   /* Configuration registers for job slot 10 */
213 #define JOB_SLOT11              0xD80   /* Configuration registers for job slot 11 */
214 #define JOB_SLOT12              0xE00   /* Configuration registers for job slot 12 */
215 #define JOB_SLOT13              0xE80   /* Configuration registers for job slot 13 */
216 #define JOB_SLOT14              0xF00   /* Configuration registers for job slot 14 */
217 #define JOB_SLOT15              0xF80   /* Configuration registers for job slot 15 */
218
219 #define JOB_SLOT_REG(n, r)      (JOB_CONTROL_REG(JOB_SLOT0 + ((n) << 7)) + (r))
220
221 #define JS_HEAD_LO             0x00     /* (RO) Job queue head pointer for job slot n, low word */
222 #define JS_HEAD_HI             0x04     /* (RO) Job queue head pointer for job slot n, high word */
223 #define JS_TAIL_LO             0x08     /* (RO) Job queue tail pointer for job slot n, low word */
224 #define JS_TAIL_HI             0x0C     /* (RO) Job queue tail pointer for job slot n, high word */
225 #define JS_AFFINITY_LO         0x10     /* (RO) Core affinity mask for job slot n, low word */
226 #define JS_AFFINITY_HI         0x14     /* (RO) Core affinity mask for job slot n, high word */
227 #define JS_CONFIG              0x18     /* (RO) Configuration settings for job slot n */
228
229 #define JS_COMMAND             0x20     /* (WO) Command register for job slot n */
230 #define JS_STATUS              0x24     /* (RO) Status register for job slot n */
231
232 #define JS_HEAD_NEXT_LO        0x40     /* (RW) Next job queue head pointer for job slot n, low word */
233 #define JS_HEAD_NEXT_HI        0x44     /* (RW) Next job queue head pointer for job slot n, high word */
234
235 #define JS_AFFINITY_NEXT_LO    0x50     /* (RW) Next core affinity mask for job slot n, low word */
236 #define JS_AFFINITY_NEXT_HI    0x54     /* (RW) Next core affinity mask for job slot n, high word */
237 #define JS_CONFIG_NEXT         0x58     /* (RW) Next configuration settings for job slot n */
238
239 #define JS_COMMAND_NEXT        0x60     /* (RW) Next command register for job slot n */
240
241 #define MEMORY_MANAGEMENT_BASE  0x2000
242 #define MMU_REG(r)              (MEMORY_MANAGEMENT_BASE + (r))
243
244 #define MMU_IRQ_RAWSTAT         0x000   /* (RW) Raw interrupt status register */
245 #define MMU_IRQ_CLEAR           0x004   /* (WO) Interrupt clear register */
246 #define MMU_IRQ_MASK            0x008   /* (RW) Interrupt mask register */
247 #define MMU_IRQ_STATUS          0x00C   /* (RO) Interrupt status register */
248
249 #define MMU_AS0                 0x400   /* Configuration registers for address space 0 */
250 #define MMU_AS1                 0x440   /* Configuration registers for address space 1 */
251 #define MMU_AS2                 0x480   /* Configuration registers for address space 2 */
252 #define MMU_AS3                 0x4C0   /* Configuration registers for address space 3 */
253 #define MMU_AS4                 0x500   /* Configuration registers for address space 4 */
254 #define MMU_AS5                 0x540   /* Configuration registers for address space 5 */
255 #define MMU_AS6                 0x580   /* Configuration registers for address space 6 */
256 #define MMU_AS7                 0x5C0   /* Configuration registers for address space 7 */
257 #define MMU_AS8                 0x600   /* Configuration registers for address space 8 */
258 #define MMU_AS9                 0x640   /* Configuration registers for address space 9 */
259 #define MMU_AS10                0x680   /* Configuration registers for address space 10 */
260 #define MMU_AS11                0x6C0   /* Configuration registers for address space 11 */
261 #define MMU_AS12                0x700   /* Configuration registers for address space 12 */
262 #define MMU_AS13                0x740   /* Configuration registers for address space 13 */
263 #define MMU_AS14                0x780   /* Configuration registers for address space 14 */
264 #define MMU_AS15                0x7C0   /* Configuration registers for address space 15 */
265
266 #define MMU_AS_REG(n, r)        (MMU_REG(MMU_AS0 + ((n) << 6)) + (r))
267
268 #define AS_TRANSTAB_LO         0x00     /* (RW) Translation Table Base Address for address space n, low word */
269 #define AS_TRANSTAB_HI         0x04     /* (RW) Translation Table Base Address for address space n, high word */
270 #define AS_MEMATTR_LO          0x08     /* (RW) Memory attributes for address space n, low word. */
271 #define AS_MEMATTR_HI          0x0C     /* (RW) Memory attributes for address space n, high word. */
272 #define AS_LOCKADDR_LO         0x10     /* (RW) Lock region address for address space n, low word */
273 #define AS_LOCKADDR_HI         0x14     /* (RW) Lock region address for address space n, high word */
274 #define AS_COMMAND             0x18     /* (WO) MMU command register for address space n */
275 #define AS_FAULTSTATUS         0x1C     /* (RO) MMU fault status register for address space n */
276 #define AS_FAULTADDRESS_LO     0x20     /* (RO) Fault Address for address space n, low word */
277 #define AS_FAULTADDRESS_HI     0x24     /* (RO) Fault Address for address space n, high word */
278 #define AS_STATUS              0x28     /* (RO) Status flags for address space n */
279
280 /* End Register Offsets */
281
282 /*
283  * MMU_IRQ_RAWSTAT register values. Values are valid also for
284    MMU_IRQ_CLEAR, MMU_IRQ_MASK, MMU_IRQ_STATUS registers.
285  */
286
287 #define MMU_REGS_PAGE_FAULT_FLAGS   16
288
289 /* Macros return bit number to retrvie page fault or bus eror flag from MMU registers */
290 #define MMU_REGS_PAGE_FAULT_FLAG(n) (n)
291 #define MMU_REGS_BUS_ERROR_FLAG(n)  (n + MMU_REGS_PAGE_FAULT_FLAGS)
292
293 /*
294  * Begin MMU TRANSTAB register values
295  */
296 #define AS_TRANSTAB_ADDR_SPACE_MASK   0xfffff000
297 #define AS_TRANSTAB_ADRMODE_UNMAPPED  (0u << 0)
298 #define AS_TRANSTAB_ADRMODE_IDENTITY  (1u << 1)
299 #define AS_TRANSTAB_ADRMODE_TABLE     (3u << 0)
300 #define AS_TRANSTAB_READ_INNER        (1u << 2)
301 #define AS_TRANSTAB_SHARE_OUTER       (1u << 4)
302
303 #define MMU_TRANSTAB_ADRMODE_MASK      0x00000003
304
305 /*
306  * Begin MMU STATUS register values
307  */
308 #define AS_STATUS_AS_ACTIVE 0x01
309
310 #define AS_FAULTSTATUS_ACCESS_TYPE_MASK    (0x3<<8)
311 #define AS_FAULTSTATUS_ACCESS_TYPE_EX      (0x1<<8)
312 #define AS_FAULTSTATUS_ACCESS_TYPE_READ    (0x2<<8)
313 #define AS_FAULTSTATUS_ACCESS_TYPE_WRITE   (0x3<<8)
314
315 /*
316  * Begin Command Values
317  */
318
319 /* JS_COMMAND register commands */
320 #define JS_COMMAND_NOP         0x00     /* NOP Operation. Writing this value is ignored */
321 #define JS_COMMAND_START       0x01     /* Start processing a job chain. Writing this value is ignored */
322 #define JS_COMMAND_SOFT_STOP   0x02     /* Gently stop processing a job chain */
323 #define JS_COMMAND_HARD_STOP   0x03     /* Rudely stop processing a job chain */
324 #define JS_COMMAND_SOFT_STOP_0 0x04     /* Execute SOFT_STOP if JOB_CHAIN_FLAG is 0 */
325 #define JS_COMMAND_HARD_STOP_0 0x05     /* Execute HARD_STOP if JOB_CHAIN_FLAG is 0 */
326 #define JS_COMMAND_SOFT_STOP_1 0x06     /* Execute SOFT_STOP if JOB_CHAIN_FLAG is 1 */
327 #define JS_COMMAND_HARD_STOP_1 0x07     /* Execute HARD_STOP if JOB_CHAIN_FLAG is 1 */
328
329 #define JS_COMMAND_MASK        0x07    /* Mask of bits currently in use by the HW */
330
331 /* AS_COMMAND register commands */
332 #define AS_COMMAND_NOP         0x00     /* NOP Operation */
333 #define AS_COMMAND_UPDATE      0x01     /* Broadcasts the values in AS_TRANSTAB and ASn_MEMATTR to all MMUs */
334 #define AS_COMMAND_LOCK        0x02     /* Issue a lock region command to all MMUs */
335 #define AS_COMMAND_UNLOCK      0x03     /* Issue a flush region command to all MMUs */
336 #define AS_COMMAND_FLUSH       0x04     /* Flush all L2 caches then issue a flush region command to all MMUs
337                                            (deprecated - only for use with T60x) */
338 #define AS_COMMAND_FLUSH_PT    0x04     /* Flush all L2 caches then issue a flush region command to all MMUs */
339 #define AS_COMMAND_FLUSH_MEM   0x05     /* Wait for memory accesses to complete, flush all the L1s cache then
340                                            flush all L2 caches then issue a flush region command to all MMUs */
341
342 /* Possible values of JS_CONFIG and JS_CONFIG_NEXT registers */
343 #define JS_CONFIG_START_FLUSH_NO_ACTION        (0u << 0)
344 #define JS_CONFIG_START_FLUSH_CLEAN            (1u << 8)
345 #define JS_CONFIG_START_FLUSH_CLEAN_INVALIDATE (3u << 8)
346 #define JS_CONFIG_START_MMU                    (1u << 10)
347 #define JS_CONFIG_JOB_CHAIN_FLAG               (1u << 11)
348 #define JS_CONFIG_END_FLUSH_NO_ACTION          JS_CONFIG_START_FLUSH_NO_ACTION
349 #define JS_CONFIG_END_FLUSH_CLEAN              (1u << 12)
350 #define JS_CONFIG_END_FLUSH_CLEAN_INVALIDATE   (3u << 12)
351 #define JS_CONFIG_THREAD_PRI(n)                ((n) << 16)
352
353 /* JS_STATUS register values */
354
355 /* NOTE: Please keep this values in sync with enum base_jd_event_code in mali_base_kernel.h.
356  * The values are separated to avoid dependency of userspace and kernel code.
357  */
358
359 /* Group of values representing the job status insead a particular fault */
360 #define JS_STATUS_NO_EXCEPTION_BASE   0x00
361 #define JS_STATUS_INTERRUPTED         (JS_STATUS_NO_EXCEPTION_BASE + 0x02)      /* 0x02 means INTERRUPTED */
362 #define JS_STATUS_STOPPED             (JS_STATUS_NO_EXCEPTION_BASE + 0x03)      /* 0x03 means STOPPED */
363 #define JS_STATUS_TERMINATED          (JS_STATUS_NO_EXCEPTION_BASE + 0x04)      /* 0x04 means TERMINATED */
364
365 /* General fault values */
366 #define JS_STATUS_FAULT_BASE          0x40
367 #define JS_STATUS_CONFIG_FAULT        (JS_STATUS_FAULT_BASE)    /* 0x40 means CONFIG FAULT */
368 #define JS_STATUS_POWER_FAULT         (JS_STATUS_FAULT_BASE + 0x01)     /* 0x41 means POWER FAULT */
369 #define JS_STATUS_READ_FAULT          (JS_STATUS_FAULT_BASE + 0x02)     /* 0x42 means READ FAULT */
370 #define JS_STATUS_WRITE_FAULT         (JS_STATUS_FAULT_BASE + 0x03)     /* 0x43 means WRITE FAULT */
371 #define JS_STATUS_AFFINITY_FAULT      (JS_STATUS_FAULT_BASE + 0x04)     /* 0x44 means AFFINITY FAULT */
372 #define JS_STATUS_BUS_FAULT           (JS_STATUS_FAULT_BASE + 0x08)     /* 0x48 means BUS FAULT */
373
374 /* Instruction or data faults */
375 #define JS_STATUS_INSTRUCTION_FAULT_BASE  0x50
376 #define JS_STATUS_INSTR_INVALID_PC        (JS_STATUS_INSTRUCTION_FAULT_BASE)    /* 0x50 means INSTR INVALID PC */
377 #define JS_STATUS_INSTR_INVALID_ENC       (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x01)     /* 0x51 means INSTR INVALID ENC */
378 #define JS_STATUS_INSTR_TYPE_MISMATCH     (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x02)     /* 0x52 means INSTR TYPE MISMATCH */
379 #define JS_STATUS_INSTR_OPERAND_FAULT     (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x03)     /* 0x53 means INSTR OPERAND FAULT */
380 #define JS_STATUS_INSTR_TLS_FAULT         (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x04)     /* 0x54 means INSTR TLS FAULT */
381 #define JS_STATUS_INSTR_BARRIER_FAULT     (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x05)     /* 0x55 means INSTR BARRIER FAULT */
382 #define JS_STATUS_INSTR_ALIGN_FAULT       (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x06)     /* 0x56 means INSTR ALIGN FAULT */
383 /* NOTE: No fault with 0x57 code defined in spec. */
384 #define JS_STATUS_DATA_INVALID_FAULT      (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x08)     /* 0x58 means DATA INVALID FAULT */
385 #define JS_STATUS_TILE_RANGE_FAULT        (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x09)     /* 0x59 means TILE RANGE FAULT */
386 #define JS_STATUS_ADDRESS_RANGE_FAULT     (JS_STATUS_INSTRUCTION_FAULT_BASE + 0x0A)     /* 0x5A means ADDRESS RANGE FAULT */
387
388 /* Other faults */
389 #define JS_STATUS_MEMORY_FAULT_BASE   0x60
390 #define JS_STATUS_OUT_OF_MEMORY       (JS_STATUS_MEMORY_FAULT_BASE)     /* 0x60 means OUT OF MEMORY */
391 #define JS_STATUS_UNKNOWN             0x7F      /* 0x7F means UNKNOWN */
392
393 /* GPU_COMMAND values */
394 #define GPU_COMMAND_NOP                0x00     /* No operation, nothing happens */
395 #define GPU_COMMAND_SOFT_RESET         0x01     /* Stop all external bus interfaces, and then reset the entire GPU. */
396 #define GPU_COMMAND_HARD_RESET         0x02     /* Immediately reset the entire GPU. */
397 #define GPU_COMMAND_PRFCNT_CLEAR       0x03     /* Clear all performance counters, setting them all to zero. */
398 #define GPU_COMMAND_PRFCNT_SAMPLE      0x04     /* Sample all performance counters, writing them out to memory */
399 #define GPU_COMMAND_CYCLE_COUNT_START  0x05     /* Starts the cycle counter, and system timestamp propagation */
400 #define GPU_COMMAND_CYCLE_COUNT_STOP   0x06     /* Stops the cycle counter, and system timestamp propagation */
401 #define GPU_COMMAND_CLEAN_CACHES       0x07     /* Clean all caches */
402 #define GPU_COMMAND_CLEAN_INV_CACHES   0x08     /* Clean and invalidate all caches */
403
404 /* End Command Values */
405
406 /* GPU_STATUS values */
407 #define GPU_STATUS_PRFCNT_ACTIVE           (1 << 2)     /* Set if the performance counters are active. */
408
409 /* PRFCNT_CONFIG register values */
410 #define PRFCNT_CONFIG_AS_SHIFT    4     /* address space bitmap starts from bit 4 of the register */
411 #define PRFCNT_CONFIG_MODE_OFF    0     /* The performance counters are disabled. */
412 #define PRFCNT_CONFIG_MODE_MANUAL 1     /* The performance counters are enabled, but are only written out when a PRFCNT_SAMPLE command is issued using the GPU_COMMAND register. */
413 #define PRFCNT_CONFIG_MODE_TILE   2     /* The performance counters are enabled, and are written out each time a tile finishes rendering. */
414
415 /* AS<n>_MEMATTR values: */
416 /* Use GPU implementation-defined  caching policy. */
417 #define AS_MEMATTR_IMPL_DEF_CACHE_POLICY 0x48
418 /* The attribute set to force all resources to be cached. */
419 #define AS_MEMATTR_FORCE_TO_CACHE_ALL    0x4F
420 /* Inner write-alloc cache setup, no outer caching */
421 #define AS_MEMATTR_WRITE_ALLOC           0x4D
422 /* symbol for default MEMATTR to use */
423 #define AS_MEMATTR_INDEX_DEFAULT               0
424 /* HW implementation defined caching */
425 #define AS_MEMATTR_INDEX_IMPL_DEF_CACHE_POLICY 0
426 /* Force cache on */
427 #define AS_MEMATTR_INDEX_FORCE_TO_CACHE_ALL    1
428 /* Write-alloc inner */
429 #define AS_MEMATTR_INDEX_WRITE_ALLOC           2
430
431 /* GPU_ID register */
432 #define GPU_ID_VERSION_STATUS_SHIFT       0
433 #define GPU_ID_VERSION_MINOR_SHIFT        4
434 #define GPU_ID_VERSION_MAJOR_SHIFT        12
435 #define GPU_ID_VERSION_PRODUCT_ID_SHIFT   16
436 #define GPU_ID_VERSION_STATUS             (0xF  << GPU_ID_VERSION_STATUS_SHIFT)
437 #define GPU_ID_VERSION_MINOR              (0xFF << GPU_ID_VERSION_MINOR_SHIFT)
438 #define GPU_ID_VERSION_MAJOR              (0xF  << GPU_ID_VERSION_MAJOR_SHIFT)
439 #define GPU_ID_VERSION_PRODUCT_ID         (0xFFFF << GPU_ID_VERSION_PRODUCT_ID_SHIFT)
440
441 /* Values for GPU_ID_VERSION_PRODUCT_ID bitfield */
442 #define GPU_ID_PI_T60X                    0x6956
443 #define GPU_ID_PI_T62X                    0x0620
444 #define GPU_ID_PI_T76X                    0x0750
445 #define GPU_ID_PI_T72X                    0x0720
446 #ifdef MALI_INCLUDE_TFRX
447 #define GPU_ID_PI_TFRX                    0x0880
448 #endif /* MALI_INCLUDE_TFRX */
449 #ifdef MALI_INCLUDE_TF2X
450 #define GPU_ID_PI_TF2X                    0x0860
451 #endif /* MALI_INCLUDE_TF2X */
452
453 /* Values for GPU_ID_VERSION_STATUS field for PRODUCT_ID GPU_ID_PI_T60X */
454 #define GPU_ID_S_15DEV0                   0x1
455 #define GPU_ID_S_EAC                      0x2
456
457 /* Helper macro to create a GPU_ID assuming valid values for id, major, minor, status */
458 #define GPU_ID_MAKE(id, major, minor, status) \
459                 (((id) << GPU_ID_VERSION_PRODUCT_ID_SHIFT) | \
460                 ((major) << GPU_ID_VERSION_MAJOR_SHIFT) |   \
461                 ((minor) << GPU_ID_VERSION_MINOR_SHIFT) |   \
462                 ((status) << GPU_ID_VERSION_STATUS_SHIFT))
463
464 /* End GPU_ID register */
465
466 /* JS<n>_FEATURES register */
467
468 #define JS_FEATURE_NULL_JOB              (1u << 1)
469 #define JS_FEATURE_SET_VALUE_JOB         (1u << 2)
470 #define JS_FEATURE_CACHE_FLUSH_JOB       (1u << 3)
471 #define JS_FEATURE_COMPUTE_JOB           (1u << 4)
472 #define JS_FEATURE_VERTEX_JOB            (1u << 5)
473 #define JS_FEATURE_GEOMETRY_JOB          (1u << 6)
474 #define JS_FEATURE_TILER_JOB             (1u << 7)
475 #define JS_FEATURE_FUSED_JOB             (1u << 8)
476 #define JS_FEATURE_FRAGMENT_JOB          (1u << 9)
477
478 /* End JS<n>_FEATURES register */
479
480 /* L2_MMU_CONFIG register */
481 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT        (24)
482 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS              (0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
483 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_OCTANT       (0x1 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
484 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_QUARTER      (0x2 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
485 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_HALF         (0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_READS_SHIFT)
486
487 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT       (26)
488 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES             (0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
489 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_OCTANT      (0x1 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
490 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_QUARTER     (0x2 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
491 #define L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_HALF        (0x3 << L2_MMU_CONFIG_LIMIT_EXTERNAL_WRITES_SHIFT)
492 /* End L2_MMU_CONFIG register */
493
494 /* THREAD_* registers */
495
496 /* THREAD_FEATURES IMPLEMENTATION_TECHNOLOGY values */
497 #define IMPLEMENTATION_UNSPECIFIED  0
498 #define IMPLEMENTATION_SILICON      1
499 #define IMPLEMENTATION_FPGA         2
500 #define IMPLEMENTATION_MODEL        3
501
502 /* Default values when registers are not supported by the implemented hardware */
503 #define THREAD_MT_DEFAULT     256
504 #define THREAD_MWS_DEFAULT    256
505 #define THREAD_MBS_DEFAULT    256
506 #define THREAD_MR_DEFAULT     1024
507 #define THREAD_MTQ_DEFAULT    4
508 #define THREAD_MTGS_DEFAULT   10
509
510 /* End THREAD_* registers */
511
512 /* SHADER_CONFIG register */
513
514 #define SC_ALT_COUNTERS             (1ul << 3)
515 #define SC_OVERRIDE_FWD_PIXEL_KILL  (1ul << 4)
516 #define SC_SDC_DISABLE_OQ_DISCARD   (1ul << 6)
517 #define SC_LS_PAUSEBUFFER_DISABLE   (1ul << 16)
518 #define SC_ENABLE_TEXGRD_FLAGS      (1ul << 25)
519 /* End SHADER_CONFIG register */
520
521 /* TILER_CONFIG register */
522
523 #define TC_CLOCK_GATE_OVERRIDE      (1ul << 0)
524
525 /* End TILER_CONFIG register */
526
527
528 #endif                          /* _MIDGARD_REGMAP_H_ */