blob: 99c6c52794a54a057dda729dffb3bfd12700385a [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
2 *
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 */
27#define KGSL_CMD_FLAGS_PMODE 0x00000001
28#define KGSL_CMD_FLAGS_NO_TS_CMP 0x00000002
29#define KGSL_CMD_FLAGS_NOT_KERNEL_CMD 0x00000004
30
31/* Command identifiers */
32#define KGSL_CONTEXT_TO_MEM_IDENTIFIER 0xDEADBEEF
33#define KGSL_CMD_IDENTIFIER 0xFEEDFACE
34
35#ifdef CONFIG_MSM_SCM
36#define ADRENO_DEFAULT_PWRSCALE_POLICY (&kgsl_pwrscale_policy_tz)
37#else
38#define ADRENO_DEFAULT_PWRSCALE_POLICY NULL
39#endif
40
Jeremy Gebbenddf6b572011-09-09 13:39:49 -070041/*
42 * constants for the size of shader instructions
43 */
44#define ADRENO_ISTORE_BYTES 12
45#define ADRENO_ISTORE_WORDS 3
Jordan Crousef587fe52011-12-07 11:19:23 -070046#define ADRENO_ISTORE_START 0x5000
Jeremy Gebbenddf6b572011-09-09 13:39:49 -070047
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048enum adreno_gpurev {
49 ADRENO_REV_UNKNOWN = 0,
50 ADRENO_REV_A200 = 200,
51 ADRENO_REV_A205 = 205,
52 ADRENO_REV_A220 = 220,
53 ADRENO_REV_A225 = 225,
54};
55
Jordan Crousea78c9172011-07-11 13:14:09 -060056struct adreno_gpudev;
57
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058struct adreno_device {
59 struct kgsl_device dev; /* Must be first field in this struct */
60 unsigned int chip_id;
61 enum adreno_gpurev gpurev;
62 struct kgsl_memregion gmemspace;
63 struct adreno_context *drawctxt_active;
Jordan Crouse505df9c2011-07-28 08:37:59 -060064 const char *pfp_fwfile;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065 unsigned int *pfp_fw;
66 size_t pfp_fw_size;
Jordan Crouse505df9c2011-07-28 08:37:59 -060067 const char *pm4_fwfile;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068 unsigned int *pm4_fw;
69 size_t pm4_fw_size;
70 struct adreno_ringbuffer ringbuffer;
71 unsigned int mharb;
Jordan Crousea78c9172011-07-11 13:14:09 -060072 struct adreno_gpudev *gpudev;
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +053073 unsigned int wait_timeout;
Jeremy Gebbenddf6b572011-09-09 13:39:49 -070074 unsigned int istore_size;
75 unsigned int pix_shader_start;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076};
77
Jordan Crousea78c9172011-07-11 13:14:09 -060078struct adreno_gpudev {
79 int (*ctxt_gpustate_shadow)(struct adreno_device *,
80 struct adreno_context *);
81 int (*ctxt_gmem_shadow)(struct adreno_device *,
82 struct adreno_context *);
83 void (*ctxt_save)(struct adreno_device *, struct adreno_context *);
84 void (*ctxt_restore)(struct adreno_device *, struct adreno_context *);
85 irqreturn_t (*irq_handler)(struct adreno_device *);
86 void (*irq_control)(struct adreno_device *, int);
87};
88
89extern struct adreno_gpudev adreno_a2xx_gpudev;
90
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091int adreno_idle(struct kgsl_device *device, unsigned int timeout);
92void adreno_regread(struct kgsl_device *device, unsigned int offsetwords,
93 unsigned int *value);
94void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords,
95 unsigned int value);
96
Jeremy Gebben16e80fa2011-11-30 15:56:29 -070097const struct kgsl_memdesc *adreno_find_region(struct kgsl_device *device,
98 unsigned int pt_base,
99 unsigned int gpuaddr,
100 unsigned int size);
101
102uint8_t *adreno_convertaddr(struct kgsl_device *device,
103 unsigned int pt_base, unsigned int gpuaddr, unsigned int size);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104
105static inline int adreno_is_a200(struct adreno_device *adreno_dev)
106{
107 return (adreno_dev->gpurev == ADRENO_REV_A200);
108}
109
110static inline int adreno_is_a205(struct adreno_device *adreno_dev)
111{
112 return (adreno_dev->gpurev == ADRENO_REV_A200);
113}
114
115static inline int adreno_is_a20x(struct adreno_device *adreno_dev)
116{
117 return (adreno_dev->gpurev == ADRENO_REV_A200 ||
118 adreno_dev->gpurev == ADRENO_REV_A205);
119}
120
121static inline int adreno_is_a220(struct adreno_device *adreno_dev)
122{
123 return (adreno_dev->gpurev == ADRENO_REV_A220);
124}
125
126static inline int adreno_is_a225(struct adreno_device *adreno_dev)
127{
128 return (adreno_dev->gpurev == ADRENO_REV_A225);
129}
130
131static inline int adreno_is_a22x(struct adreno_device *adreno_dev)
132{
133 return (adreno_dev->gpurev == ADRENO_REV_A220 ||
134 adreno_dev->gpurev == ADRENO_REV_A225);
135}
136
Jordan Crouse196c45b2011-07-28 08:37:57 -0600137static inline int adreno_is_a2xx(struct adreno_device *adreno_dev)
138{
139 return (adreno_dev->gpurev <= ADRENO_REV_A225);
140}
141
Jeremy Gebbenddf6b572011-09-09 13:39:49 -0700142/**
143 * adreno_encode_istore_size - encode istore size in CP format
144 * @adreno_dev - The 3D device.
145 *
146 * Encode the istore size into the format expected that the
147 * CP_SET_SHADER_BASES and CP_ME_INIT commands:
148 * bits 31:29 - istore size as encoded by this function
149 * bits 27:16 - vertex shader start offset in instructions
150 * bits 11:0 - pixel shader start offset in instructions.
151 */
152static inline int adreno_encode_istore_size(struct adreno_device *adreno_dev)
153{
154 unsigned int size;
155 /* in a225 the CP microcode multiplies the encoded
156 * value by 3 while decoding.
157 */
158 if (adreno_is_a225(adreno_dev))
159 size = adreno_dev->istore_size/3;
160 else
161 size = adreno_dev->istore_size;
162
163 return (ilog2(size) - 5) << 29;
164}
Jordan Crouse196c45b2011-07-28 08:37:57 -0600165
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700166#endif /*__ADRENO_H */