blob: 0098045046ea4d3649ab574c4bb90e3955777797 [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;
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +053067 unsigned int wait_timeout;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068};
69
Jordan Crousea78c9172011-07-11 13:14:09 -060070struct adreno_gpudev {
71 int (*ctxt_gpustate_shadow)(struct adreno_device *,
72 struct adreno_context *);
73 int (*ctxt_gmem_shadow)(struct adreno_device *,
74 struct adreno_context *);
75 void (*ctxt_save)(struct adreno_device *, struct adreno_context *);
76 void (*ctxt_restore)(struct adreno_device *, struct adreno_context *);
77 irqreturn_t (*irq_handler)(struct adreno_device *);
78 void (*irq_control)(struct adreno_device *, int);
79};
80
81extern struct adreno_gpudev adreno_a2xx_gpudev;
82
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083int adreno_idle(struct kgsl_device *device, unsigned int timeout);
84void adreno_regread(struct kgsl_device *device, unsigned int offsetwords,
85 unsigned int *value);
86void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords,
87 unsigned int value);
88
89uint8_t *kgsl_sharedmem_convertaddr(struct kgsl_device *device,
90 unsigned int pt_base, unsigned int gpuaddr, unsigned int *size);
91
92static inline int adreno_is_a200(struct adreno_device *adreno_dev)
93{
94 return (adreno_dev->gpurev == ADRENO_REV_A200);
95}
96
97static inline int adreno_is_a205(struct adreno_device *adreno_dev)
98{
99 return (adreno_dev->gpurev == ADRENO_REV_A200);
100}
101
102static inline int adreno_is_a20x(struct adreno_device *adreno_dev)
103{
104 return (adreno_dev->gpurev == ADRENO_REV_A200 ||
105 adreno_dev->gpurev == ADRENO_REV_A205);
106}
107
108static inline int adreno_is_a220(struct adreno_device *adreno_dev)
109{
110 return (adreno_dev->gpurev == ADRENO_REV_A220);
111}
112
113static inline int adreno_is_a225(struct adreno_device *adreno_dev)
114{
115 return (adreno_dev->gpurev == ADRENO_REV_A225);
116}
117
118static inline int adreno_is_a22x(struct adreno_device *adreno_dev)
119{
120 return (adreno_dev->gpurev == ADRENO_REV_A220 ||
121 adreno_dev->gpurev == ADRENO_REV_A225);
122}
123
Jordan Crouse196c45b2011-07-28 08:37:57 -0600124static inline int adreno_is_a2xx(struct adreno_device *adreno_dev)
125{
126 return (adreno_dev->gpurev <= ADRENO_REV_A225);
127}
128
129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700130#endif /*__ADRENO_H */