blob: 5b3d676291cce3a9e4a0a2c09013683c056bab43 [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;
58 unsigned int *pfp_fw;
59 size_t pfp_fw_size;
60 unsigned int *pm4_fw;
61 size_t pm4_fw_size;
62 struct adreno_ringbuffer ringbuffer;
63 unsigned int mharb;
Jordan Crousea78c9172011-07-11 13:14:09 -060064 struct adreno_gpudev *gpudev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065};
66
Jordan Crousea78c9172011-07-11 13:14:09 -060067struct adreno_gpudev {
68 int (*ctxt_gpustate_shadow)(struct adreno_device *,
69 struct adreno_context *);
70 int (*ctxt_gmem_shadow)(struct adreno_device *,
71 struct adreno_context *);
72 void (*ctxt_save)(struct adreno_device *, struct adreno_context *);
73 void (*ctxt_restore)(struct adreno_device *, struct adreno_context *);
74 irqreturn_t (*irq_handler)(struct adreno_device *);
75 void (*irq_control)(struct adreno_device *, int);
76};
77
78extern struct adreno_gpudev adreno_a2xx_gpudev;
79
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070080int adreno_idle(struct kgsl_device *device, unsigned int timeout);
81void adreno_regread(struct kgsl_device *device, unsigned int offsetwords,
82 unsigned int *value);
83void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords,
84 unsigned int value);
85
86uint8_t *kgsl_sharedmem_convertaddr(struct kgsl_device *device,
87 unsigned int pt_base, unsigned int gpuaddr, unsigned int *size);
88
89static inline int adreno_is_a200(struct adreno_device *adreno_dev)
90{
91 return (adreno_dev->gpurev == ADRENO_REV_A200);
92}
93
94static inline int adreno_is_a205(struct adreno_device *adreno_dev)
95{
96 return (adreno_dev->gpurev == ADRENO_REV_A200);
97}
98
99static inline int adreno_is_a20x(struct adreno_device *adreno_dev)
100{
101 return (adreno_dev->gpurev == ADRENO_REV_A200 ||
102 adreno_dev->gpurev == ADRENO_REV_A205);
103}
104
105static inline int adreno_is_a220(struct adreno_device *adreno_dev)
106{
107 return (adreno_dev->gpurev == ADRENO_REV_A220);
108}
109
110static inline int adreno_is_a225(struct adreno_device *adreno_dev)
111{
112 return (adreno_dev->gpurev == ADRENO_REV_A225);
113}
114
115static inline int adreno_is_a22x(struct adreno_device *adreno_dev)
116{
117 return (adreno_dev->gpurev == ADRENO_REV_A220 ||
118 adreno_dev->gpurev == ADRENO_REV_A225);
119}
120
Jordan Crouse196c45b2011-07-28 08:37:57 -0600121static inline int adreno_is_a2xx(struct adreno_device *adreno_dev)
122{
123 return (adreno_dev->gpurev <= ADRENO_REV_A225);
124}
125
126
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127#endif /*__ADRENO_H */