blob: bdba624f605c257d37d6830abc9e070f30e51e87 [file] [log] [blame]
Jordan Crousef7597bf2012-01-03 08:43:34 -07001/* Copyright (c) 2008-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#ifndef __ADRENO_H
14#define __ADRENO_H
15
16#include "kgsl_device.h"
17#include "adreno_drawctxt.h"
18#include "adreno_ringbuffer.h"
19
20#define DEVICE_3D_NAME "kgsl-3d"
21#define DEVICE_3D0_NAME "kgsl-3d0"
22
23#define ADRENO_DEVICE(device) \
24 KGSL_CONTAINER_OF(device, struct adreno_device, dev)
25
26/* Flags to control command packet settings */
Jordan Crousee0ea7622012-01-24 09:32:04 -070027#define KGSL_CMD_FLAGS_NONE 0x00000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#define KGSL_CMD_FLAGS_PMODE 0x00000001
29#define KGSL_CMD_FLAGS_NO_TS_CMP 0x00000002
30#define KGSL_CMD_FLAGS_NOT_KERNEL_CMD 0x00000004
31
32/* Command identifiers */
33#define KGSL_CONTEXT_TO_MEM_IDENTIFIER 0xDEADBEEF
34#define KGSL_CMD_IDENTIFIER 0xFEEDFACE
35
36#ifdef CONFIG_MSM_SCM
37#define ADRENO_DEFAULT_PWRSCALE_POLICY (&kgsl_pwrscale_policy_tz)
38#else
39#define ADRENO_DEFAULT_PWRSCALE_POLICY NULL
40#endif
41
Jeremy Gebbenddf6b572011-09-09 13:39:49 -070042/*
43 * constants for the size of shader instructions
44 */
45#define ADRENO_ISTORE_BYTES 12
46#define ADRENO_ISTORE_WORDS 3
Jordan Crousef587fe52011-12-07 11:19:23 -070047#define ADRENO_ISTORE_START 0x5000
Jeremy Gebbenddf6b572011-09-09 13:39:49 -070048
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049enum adreno_gpurev {
50 ADRENO_REV_UNKNOWN = 0,
51 ADRENO_REV_A200 = 200,
52 ADRENO_REV_A205 = 205,
53 ADRENO_REV_A220 = 220,
54 ADRENO_REV_A225 = 225,
55};
56
Jordan Crousea78c9172011-07-11 13:14:09 -060057struct adreno_gpudev;
58
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059struct adreno_device {
60 struct kgsl_device dev; /* Must be first field in this struct */
61 unsigned int chip_id;
62 enum adreno_gpurev gpurev;
63 struct kgsl_memregion gmemspace;
64 struct adreno_context *drawctxt_active;
Jordan Crouse505df9c2011-07-28 08:37:59 -060065 const char *pfp_fwfile;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066 unsigned int *pfp_fw;
67 size_t pfp_fw_size;
Jordan Crouse505df9c2011-07-28 08:37:59 -060068 const char *pm4_fwfile;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069 unsigned int *pm4_fw;
70 size_t pm4_fw_size;
71 struct adreno_ringbuffer ringbuffer;
72 unsigned int mharb;
Jordan Crousea78c9172011-07-11 13:14:09 -060073 struct adreno_gpudev *gpudev;
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +053074 unsigned int wait_timeout;
Jeremy Gebbenddf6b572011-09-09 13:39:49 -070075 unsigned int istore_size;
76 unsigned int pix_shader_start;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077};
78
Jordan Crousea78c9172011-07-11 13:14:09 -060079struct adreno_gpudev {
80 int (*ctxt_gpustate_shadow)(struct adreno_device *,
81 struct adreno_context *);
82 int (*ctxt_gmem_shadow)(struct adreno_device *,
83 struct adreno_context *);
84 void (*ctxt_save)(struct adreno_device *, struct adreno_context *);
85 void (*ctxt_restore)(struct adreno_device *, struct adreno_context *);
86 irqreturn_t (*irq_handler)(struct adreno_device *);
87 void (*irq_control)(struct adreno_device *, int);
Jordan Crouse156cfbc2012-01-24 09:32:04 -070088 void * (*snapshot)(struct adreno_device *, void *, int *, int);
Jordan Crousea78c9172011-07-11 13:14:09 -060089};
90
91extern struct adreno_gpudev adreno_a2xx_gpudev;
92
Jordan Crousef7597bf2012-01-03 08:43:34 -070093/* A2XX register sets defined in adreno_a2xx.c */
94extern const unsigned int a200_registers[];
95extern const unsigned int a220_registers[];
96extern const unsigned int a200_registers_count;
97extern const unsigned int a220_registers_count;
98
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099int adreno_idle(struct kgsl_device *device, unsigned int timeout);
100void adreno_regread(struct kgsl_device *device, unsigned int offsetwords,
101 unsigned int *value);
102void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords,
103 unsigned int value);
104
Jeremy Gebben16e80fa2011-11-30 15:56:29 -0700105const struct kgsl_memdesc *adreno_find_region(struct kgsl_device *device,
106 unsigned int pt_base,
107 unsigned int gpuaddr,
108 unsigned int size);
109
110uint8_t *adreno_convertaddr(struct kgsl_device *device,
111 unsigned int pt_base, unsigned int gpuaddr, unsigned int size);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112
Jordan Crouse156cfbc2012-01-24 09:32:04 -0700113void *adreno_snapshot(struct kgsl_device *device, void *snapshot, int *remain,
114 int hang);
115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116static inline int adreno_is_a200(struct adreno_device *adreno_dev)
117{
118 return (adreno_dev->gpurev == ADRENO_REV_A200);
119}
120
121static inline int adreno_is_a205(struct adreno_device *adreno_dev)
122{
123 return (adreno_dev->gpurev == ADRENO_REV_A200);
124}
125
126static inline int adreno_is_a20x(struct adreno_device *adreno_dev)
127{
128 return (adreno_dev->gpurev == ADRENO_REV_A200 ||
129 adreno_dev->gpurev == ADRENO_REV_A205);
130}
131
132static inline int adreno_is_a220(struct adreno_device *adreno_dev)
133{
134 return (adreno_dev->gpurev == ADRENO_REV_A220);
135}
136
137static inline int adreno_is_a225(struct adreno_device *adreno_dev)
138{
139 return (adreno_dev->gpurev == ADRENO_REV_A225);
140}
141
142static inline int adreno_is_a22x(struct adreno_device *adreno_dev)
143{
144 return (adreno_dev->gpurev == ADRENO_REV_A220 ||
145 adreno_dev->gpurev == ADRENO_REV_A225);
146}
147
Jordan Crouse196c45b2011-07-28 08:37:57 -0600148static inline int adreno_is_a2xx(struct adreno_device *adreno_dev)
149{
150 return (adreno_dev->gpurev <= ADRENO_REV_A225);
151}
152
Jeremy Gebbenddf6b572011-09-09 13:39:49 -0700153/**
154 * adreno_encode_istore_size - encode istore size in CP format
155 * @adreno_dev - The 3D device.
156 *
157 * Encode the istore size into the format expected that the
158 * CP_SET_SHADER_BASES and CP_ME_INIT commands:
159 * bits 31:29 - istore size as encoded by this function
160 * bits 27:16 - vertex shader start offset in instructions
161 * bits 11:0 - pixel shader start offset in instructions.
162 */
163static inline int adreno_encode_istore_size(struct adreno_device *adreno_dev)
164{
165 unsigned int size;
166 /* in a225 the CP microcode multiplies the encoded
167 * value by 3 while decoding.
168 */
169 if (adreno_is_a225(adreno_dev))
170 size = adreno_dev->istore_size/3;
171 else
172 size = adreno_dev->istore_size;
173
174 return (ilog2(size) - 5) << 29;
175}
Jordan Crouse196c45b2011-07-28 08:37:57 -0600176
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700177#endif /*__ADRENO_H */