blob: 94b96a1d00da9d102a18eba2cc242b6567e1f3bb [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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041enum adreno_gpurev {
42 ADRENO_REV_UNKNOWN = 0,
43 ADRENO_REV_A200 = 200,
44 ADRENO_REV_A205 = 205,
45 ADRENO_REV_A220 = 220,
46 ADRENO_REV_A225 = 225,
47};
48
Jordan Crousea78c9172011-07-11 13:14:09 -060049struct adreno_gpudev;
50
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051struct adreno_device {
52 struct kgsl_device dev; /* Must be first field in this struct */
53 unsigned int chip_id;
54 enum adreno_gpurev gpurev;
55 struct kgsl_memregion gmemspace;
56 struct adreno_context *drawctxt_active;
57 wait_queue_head_t ib1_wq;
Jordan Crouse505df9c2011-07-28 08:37:59 -060058 const char *pfp_fwfile;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059 unsigned int *pfp_fw;
60 size_t pfp_fw_size;
Jordan Crouse505df9c2011-07-28 08:37:59 -060061 const char *pm4_fwfile;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062 unsigned int *pm4_fw;
63 size_t pm4_fw_size;
64 struct adreno_ringbuffer ringbuffer;
65 unsigned int mharb;
Jordan Crousea78c9172011-07-11 13:14:09 -060066 struct adreno_gpudev *gpudev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067};
68
Jordan Crousea78c9172011-07-11 13:14:09 -060069struct adreno_gpudev {
70 int (*ctxt_gpustate_shadow)(struct adreno_device *,
71 struct adreno_context *);
72 int (*ctxt_gmem_shadow)(struct adreno_device *,
73 struct adreno_context *);
74 void (*ctxt_save)(struct adreno_device *, struct adreno_context *);
75 void (*ctxt_restore)(struct adreno_device *, struct adreno_context *);
76 irqreturn_t (*irq_handler)(struct adreno_device *);
77 void (*irq_control)(struct adreno_device *, int);
78};
79
80extern struct adreno_gpudev adreno_a2xx_gpudev;
81
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070082int adreno_idle(struct kgsl_device *device, unsigned int timeout);
83void adreno_regread(struct kgsl_device *device, unsigned int offsetwords,
84 unsigned int *value);
85void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords,
86 unsigned int value);
87
88uint8_t *kgsl_sharedmem_convertaddr(struct kgsl_device *device,
89 unsigned int pt_base, unsigned int gpuaddr, unsigned int *size);
90
91static inline int adreno_is_a200(struct adreno_device *adreno_dev)
92{
93 return (adreno_dev->gpurev == ADRENO_REV_A200);
94}
95
96static inline int adreno_is_a205(struct adreno_device *adreno_dev)
97{
98 return (adreno_dev->gpurev == ADRENO_REV_A200);
99}
100
101static inline int adreno_is_a20x(struct adreno_device *adreno_dev)
102{
103 return (adreno_dev->gpurev == ADRENO_REV_A200 ||
104 adreno_dev->gpurev == ADRENO_REV_A205);
105}
106
107static inline int adreno_is_a220(struct adreno_device *adreno_dev)
108{
109 return (adreno_dev->gpurev == ADRENO_REV_A220);
110}
111
112static inline int adreno_is_a225(struct adreno_device *adreno_dev)
113{
114 return (adreno_dev->gpurev == ADRENO_REV_A225);
115}
116
117static inline int adreno_is_a22x(struct adreno_device *adreno_dev)
118{
119 return (adreno_dev->gpurev == ADRENO_REV_A220 ||
120 adreno_dev->gpurev == ADRENO_REV_A225);
121}
122
Jordan Crouse196c45b2011-07-28 08:37:57 -0600123static inline int adreno_is_a2xx(struct adreno_device *adreno_dev)
124{
125 return (adreno_dev->gpurev <= ADRENO_REV_A225);
126}
127
128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129#endif /*__ADRENO_H */