blob: 846a9a115748b90d86bf76c14102cb76cbd1da5a [file] [log] [blame]
Jeremy Gebbenb7bc9552012-01-09 13:32:49 -07001/* Copyright (c) 2002,2007-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#include <linux/uaccess.h>
14
15#include "kgsl.h"
16#include "kgsl_cffdump.h"
17#include "kgsl_sharedmem.h"
18
19#include "z180.h"
20#include "z180_reg.h"
Norman Geed7402ff2011-10-28 08:51:11 -060021#include "z180_trace.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022
23#define DRIVER_VERSION_MAJOR 3
24#define DRIVER_VERSION_MINOR 1
25
26#define Z180_DEVICE(device) \
27 KGSL_CONTAINER_OF(device, struct z180_device, dev)
28
29#define GSL_VGC_INT_MASK \
30 (REG_VGC_IRQSTATUS__MH_MASK | \
31 REG_VGC_IRQSTATUS__G2D_MASK | \
32 REG_VGC_IRQSTATUS__FIFO_MASK)
33
34#define VGV3_NEXTCMD_JUMP 0x01
35
36#define VGV3_NEXTCMD_NEXTCMD_FSHIFT 12
37#define VGV3_NEXTCMD_NEXTCMD_FMASK 0x7
38
39#define VGV3_CONTROL_MARKADD_FSHIFT 0
40#define VGV3_CONTROL_MARKADD_FMASK 0xfff
41
42#define Z180_PACKET_SIZE 15
43#define Z180_MARKER_SIZE 10
44#define Z180_CALL_CMD 0x1000
45#define Z180_MARKER_CMD 0x8000
46#define Z180_STREAM_END_CMD 0x9000
47#define Z180_STREAM_PACKET 0x7C000176
48#define Z180_STREAM_PACKET_CALL 0x7C000275
49#define Z180_PACKET_COUNT 8
50#define Z180_RB_SIZE (Z180_PACKET_SIZE*Z180_PACKET_COUNT \
51 *sizeof(uint32_t))
52
53#define NUMTEXUNITS 4
54#define TEXUNITREGCOUNT 25
55#define VG_REGCOUNT 0x39
56
57#define PACKETSIZE_BEGIN 3
58#define PACKETSIZE_G2DCOLOR 2
59#define PACKETSIZE_TEXUNIT (TEXUNITREGCOUNT * 2)
60#define PACKETSIZE_REG (VG_REGCOUNT * 2)
61#define PACKETSIZE_STATE (PACKETSIZE_TEXUNIT * NUMTEXUNITS + \
62 PACKETSIZE_REG + PACKETSIZE_BEGIN + \
63 PACKETSIZE_G2DCOLOR)
64#define PACKETSIZE_STATESTREAM (ALIGN((PACKETSIZE_STATE * \
65 sizeof(unsigned int)), 32) / \
66 sizeof(unsigned int))
67
68#define Z180_INVALID_CONTEXT UINT_MAX
69
70/* z180 MH arbiter config*/
71#define Z180_CFG_MHARB \
72 (0x10 \
73 | (0 << MH_ARBITER_CONFIG__SAME_PAGE_GRANULARITY__SHIFT) \
74 | (1 << MH_ARBITER_CONFIG__L1_ARB_ENABLE__SHIFT) \
75 | (1 << MH_ARBITER_CONFIG__L1_ARB_HOLD_ENABLE__SHIFT) \
76 | (0 << MH_ARBITER_CONFIG__L2_ARB_CONTROL__SHIFT) \
77 | (1 << MH_ARBITER_CONFIG__PAGE_SIZE__SHIFT) \
78 | (1 << MH_ARBITER_CONFIG__TC_REORDER_ENABLE__SHIFT) \
79 | (1 << MH_ARBITER_CONFIG__TC_ARB_HOLD_ENABLE__SHIFT) \
80 | (0 << MH_ARBITER_CONFIG__IN_FLIGHT_LIMIT_ENABLE__SHIFT) \
81 | (0x8 << MH_ARBITER_CONFIG__IN_FLIGHT_LIMIT__SHIFT) \
82 | (1 << MH_ARBITER_CONFIG__CP_CLNT_ENABLE__SHIFT) \
83 | (1 << MH_ARBITER_CONFIG__VGT_CLNT_ENABLE__SHIFT) \
84 | (1 << MH_ARBITER_CONFIG__TC_CLNT_ENABLE__SHIFT) \
85 | (1 << MH_ARBITER_CONFIG__RB_CLNT_ENABLE__SHIFT) \
86 | (1 << MH_ARBITER_CONFIG__PA_CLNT_ENABLE__SHIFT))
87
88#define Z180_TIMESTAMP_EPSILON 20000
89#define Z180_IDLE_COUNT_MAX 1000000
90
91enum z180_cmdwindow_type {
92 Z180_CMDWINDOW_2D = 0x00000000,
93 Z180_CMDWINDOW_MMU = 0x00000002,
94};
95
96#define Z180_CMDWINDOW_TARGET_MASK 0x000000FF
97#define Z180_CMDWINDOW_ADDR_MASK 0x00FFFF00
98#define Z180_CMDWINDOW_TARGET_SHIFT 0
99#define Z180_CMDWINDOW_ADDR_SHIFT 8
100
101static int z180_start(struct kgsl_device *device, unsigned int init_ram);
102static int z180_stop(struct kgsl_device *device);
103static int z180_wait(struct kgsl_device *device,
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700104 struct kgsl_context *context,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105 unsigned int timestamp,
106 unsigned int msecs);
107static void z180_regread(struct kgsl_device *device,
108 unsigned int offsetwords,
109 unsigned int *value);
110static void z180_regwrite(struct kgsl_device *device,
111 unsigned int offsetwords,
112 unsigned int value);
113static void z180_cmdwindow_write(struct kgsl_device *device,
114 unsigned int addr,
115 unsigned int data);
116
117#define Z180_MMU_CONFIG \
118 (0x01 \
119 | (MMU_CONFIG << MH_MMU_CONFIG__RB_W_CLNT_BEHAVIOR__SHIFT) \
120 | (MMU_CONFIG << MH_MMU_CONFIG__CP_W_CLNT_BEHAVIOR__SHIFT) \
121 | (MMU_CONFIG << MH_MMU_CONFIG__CP_R0_CLNT_BEHAVIOR__SHIFT) \
122 | (MMU_CONFIG << MH_MMU_CONFIG__CP_R1_CLNT_BEHAVIOR__SHIFT) \
123 | (MMU_CONFIG << MH_MMU_CONFIG__CP_R2_CLNT_BEHAVIOR__SHIFT) \
124 | (MMU_CONFIG << MH_MMU_CONFIG__CP_R3_CLNT_BEHAVIOR__SHIFT) \
125 | (MMU_CONFIG << MH_MMU_CONFIG__CP_R4_CLNT_BEHAVIOR__SHIFT) \
126 | (MMU_CONFIG << MH_MMU_CONFIG__VGT_R0_CLNT_BEHAVIOR__SHIFT) \
127 | (MMU_CONFIG << MH_MMU_CONFIG__VGT_R1_CLNT_BEHAVIOR__SHIFT) \
128 | (MMU_CONFIG << MH_MMU_CONFIG__TC_R_CLNT_BEHAVIOR__SHIFT) \
129 | (MMU_CONFIG << MH_MMU_CONFIG__PA_W_CLNT_BEHAVIOR__SHIFT))
130
131static const struct kgsl_functable z180_functable;
132
133static struct z180_device device_2d0 = {
134 .dev = {
Jeremy Gebben84d75d02012-03-01 14:47:45 -0700135 KGSL_DEVICE_COMMON_INIT(device_2d0.dev),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136 .name = DEVICE_2D0_NAME,
137 .id = KGSL_DEVICE_2D0,
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600138 .mh = {
139 .mharb = Z180_CFG_MHARB,
140 .mh_intf_cfg1 = 0x00032f07,
141 .mh_intf_cfg2 = 0x004b274f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142 /* turn off memory protection unit by setting
143 acceptable physical address range to include
144 all pages. */
145 .mpu_base = 0x00000000,
146 .mpu_range = 0xFFFFF000,
147 },
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600148 .mmu = {
149 .config = Z180_MMU_CONFIG,
150 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151 .pwrctrl = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152 .irq_name = KGSL_2D0_IRQ,
153 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700154 .iomemname = KGSL_2D0_REG_MEMORY,
155 .ftbl = &z180_functable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156 },
Jeremy Gebben84d75d02012-03-01 14:47:45 -0700157 .cmdwin_lock = __SPIN_LOCK_INITIALIZER(device_2d1.cmdwin_lock),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158};
159
160static struct z180_device device_2d1 = {
161 .dev = {
Jeremy Gebben84d75d02012-03-01 14:47:45 -0700162 KGSL_DEVICE_COMMON_INIT(device_2d1.dev),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163 .name = DEVICE_2D1_NAME,
164 .id = KGSL_DEVICE_2D1,
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600165 .mh = {
166 .mharb = Z180_CFG_MHARB,
167 .mh_intf_cfg1 = 0x00032f07,
168 .mh_intf_cfg2 = 0x004b274f,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700169 /* turn off memory protection unit by setting
170 acceptable physical address range to include
171 all pages. */
172 .mpu_base = 0x00000000,
173 .mpu_range = 0xFFFFF000,
174 },
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600175 .mmu = {
176 .config = Z180_MMU_CONFIG,
177 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178 .pwrctrl = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179 .irq_name = KGSL_2D1_IRQ,
180 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700181 .iomemname = KGSL_2D1_REG_MEMORY,
182 .ftbl = &z180_functable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700183 },
Jeremy Gebben84d75d02012-03-01 14:47:45 -0700184 .cmdwin_lock = __SPIN_LOCK_INITIALIZER(device_2d1.cmdwin_lock),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700185};
186
Jordan Crouseb368e9b2012-04-27 14:01:59 -0600187static irqreturn_t z180_irq_handler(struct kgsl_device *device)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700188{
189 irqreturn_t result = IRQ_NONE;
190 unsigned int status;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700191 struct z180_device *z180_dev = Z180_DEVICE(device);
192
193 z180_regread(device, ADDR_VGC_IRQSTATUS >> 2, &status);
194
Norman Geed7402ff2011-10-28 08:51:11 -0600195 trace_kgsl_z180_irq_status(device, status);
196
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700197 if (status & GSL_VGC_INT_MASK) {
198 z180_regwrite(device,
199 ADDR_VGC_IRQSTATUS >> 2, status & GSL_VGC_INT_MASK);
200
201 result = IRQ_HANDLED;
202
203 if (status & REG_VGC_IRQSTATUS__FIFO_MASK)
204 KGSL_DRV_ERR(device, "z180 fifo interrupt\n");
205 if (status & REG_VGC_IRQSTATUS__MH_MASK)
206 kgsl_mh_intrcallback(device);
207 if (status & REG_VGC_IRQSTATUS__G2D_MASK) {
208 int count;
209
210 z180_regread(device,
211 ADDR_VGC_IRQ_ACTIVE_CNT >> 2,
212 &count);
213
214 count >>= 8;
215 count &= 255;
216 z180_dev->timestamp += count;
217
Jordan Crouse1bf80aa2011-10-12 16:57:47 -0600218 queue_work(device->work_queue, &device->ts_expired_ws);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219 wake_up_interruptible(&device->wait_queue);
220
221 atomic_notifier_call_chain(
222 &(device->ts_notifier_list),
223 device->id, NULL);
224 }
225 }
226
227 if ((device->pwrctrl.nap_allowed == true) &&
228 (device->requested_state == KGSL_STATE_NONE)) {
Jeremy Gebben388c2972011-12-16 09:05:07 -0700229 kgsl_pwrctrl_request_state(device, KGSL_STATE_NAP);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230 queue_work(device->work_queue, &device->idle_check_ws);
231 }
Tarun Karra68755762012-01-12 16:07:09 -0800232 mod_timer_pending(&device->idle_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700233 jiffies + device->pwrctrl.interval_timeout);
234
235 return result;
236}
237
Jordan Crouse9f739212011-07-28 08:37:57 -0600238static void z180_cleanup_pt(struct kgsl_device *device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239 struct kgsl_pagetable *pagetable)
240{
241 struct z180_device *z180_dev = Z180_DEVICE(device);
242
Shubhraprakash Das767fdda2011-08-15 15:49:45 -0600243 kgsl_mmu_unmap(pagetable, &device->mmu.setstate_memory);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700244
245 kgsl_mmu_unmap(pagetable, &device->memstore);
246
247 kgsl_mmu_unmap(pagetable, &z180_dev->ringbuffer.cmdbufdesc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248}
249
250static int z180_setup_pt(struct kgsl_device *device,
251 struct kgsl_pagetable *pagetable)
252{
253 int result = 0;
254 struct z180_device *z180_dev = Z180_DEVICE(device);
255
Shubhraprakash Das767fdda2011-08-15 15:49:45 -0600256 result = kgsl_mmu_map_global(pagetable, &device->mmu.setstate_memory,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700257 GSL_PT_PAGE_RV | GSL_PT_PAGE_WV);
258
259 if (result)
260 goto error;
261
262 result = kgsl_mmu_map_global(pagetable, &device->memstore,
263 GSL_PT_PAGE_RV | GSL_PT_PAGE_WV);
264 if (result)
265 goto error_unmap_dummy;
266
267 result = kgsl_mmu_map_global(pagetable,
268 &z180_dev->ringbuffer.cmdbufdesc,
269 GSL_PT_PAGE_RV);
270 if (result)
271 goto error_unmap_memstore;
272 return result;
273
274error_unmap_dummy:
Shubhraprakash Das767fdda2011-08-15 15:49:45 -0600275 kgsl_mmu_unmap(pagetable, &device->mmu.setstate_memory);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700276
277error_unmap_memstore:
278 kgsl_mmu_unmap(pagetable, &device->memstore);
279
280error:
281 return result;
282}
283
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600284static inline unsigned int rb_offset(unsigned int timestamp)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285{
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600286 return (timestamp % Z180_PACKET_COUNT)
287 *sizeof(unsigned int)*(Z180_PACKET_SIZE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700288}
289
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600290static inline unsigned int rb_gpuaddr(struct z180_device *z180_dev,
291 unsigned int timestamp)
292{
293 return z180_dev->ringbuffer.cmdbufdesc.gpuaddr + rb_offset(timestamp);
294}
295
296static void addmarker(struct z180_ringbuffer *rb, unsigned int timestamp)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700297{
298 char *ptr = (char *)(rb->cmdbufdesc.hostptr);
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600299 unsigned int *p = (unsigned int *)(ptr + rb_offset(timestamp));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700300
301 *p++ = Z180_STREAM_PACKET;
302 *p++ = (Z180_MARKER_CMD | 5);
303 *p++ = ADDR_VGV3_LAST << 24;
304 *p++ = ADDR_VGV3_LAST << 24;
305 *p++ = ADDR_VGV3_LAST << 24;
306 *p++ = Z180_STREAM_PACKET;
307 *p++ = 5;
308 *p++ = ADDR_VGV3_LAST << 24;
309 *p++ = ADDR_VGV3_LAST << 24;
310 *p++ = ADDR_VGV3_LAST << 24;
311}
312
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600313static void addcmd(struct z180_ringbuffer *rb, unsigned int timestamp,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700314 unsigned int cmd, unsigned int nextcnt)
315{
316 char * ptr = (char *)(rb->cmdbufdesc.hostptr);
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600317 unsigned int *p = (unsigned int *)(ptr + (rb_offset(timestamp)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700318 + (Z180_MARKER_SIZE * sizeof(unsigned int))));
319
320 *p++ = Z180_STREAM_PACKET_CALL;
321 *p++ = cmd;
322 *p++ = Z180_CALL_CMD | nextcnt;
323 *p++ = ADDR_VGV3_LAST << 24;
324 *p++ = ADDR_VGV3_LAST << 24;
325}
326
Shubhraprakash Das8cbd2322012-03-04 14:41:39 -0700327static void z180_cmdstream_start(struct kgsl_device *device, int init_ram)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328{
329 struct z180_device *z180_dev = Z180_DEVICE(device);
330 unsigned int cmd = VGV3_NEXTCMD_JUMP << VGV3_NEXTCMD_NEXTCMD_FSHIFT;
331
Shubhraprakash Das8cbd2322012-03-04 14:41:39 -0700332 if (init_ram) {
333 z180_dev->timestamp = 0;
334 z180_dev->current_timestamp = 0;
335 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700336
337 addmarker(&z180_dev->ringbuffer, 0);
338
339 z180_cmdwindow_write(device, ADDR_VGV3_MODE, 4);
340
341 z180_cmdwindow_write(device, ADDR_VGV3_NEXTADDR,
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600342 rb_gpuaddr(z180_dev, z180_dev->current_timestamp));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700343
344 z180_cmdwindow_write(device, ADDR_VGV3_NEXTCMD, cmd | 5);
345
346 z180_cmdwindow_write(device, ADDR_VGV3_WRITEADDR,
347 device->memstore.gpuaddr);
348
349 cmd = (int)(((1) & VGV3_CONTROL_MARKADD_FMASK)
350 << VGV3_CONTROL_MARKADD_FSHIFT);
351
352 z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, cmd);
353
354 z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, 0);
355}
356
357static int room_in_rb(struct z180_device *device)
358{
359 int ts_diff;
360
361 ts_diff = device->current_timestamp - device->timestamp;
362
363 return ts_diff < Z180_PACKET_COUNT;
364}
365
366static int z180_idle(struct kgsl_device *device, unsigned int timeout)
367{
368 int status = 0;
369 struct z180_device *z180_dev = Z180_DEVICE(device);
370
Jordan Crousee6239dd2011-11-17 13:39:21 -0700371 if (timestamp_cmp(z180_dev->current_timestamp,
372 z180_dev->timestamp) > 0)
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700373 status = z180_wait(device, NULL,
374 z180_dev->current_timestamp, timeout);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700375
376 if (status)
377 KGSL_DRV_ERR(device, "z180_waittimestamp() timed out\n");
378
379 return status;
380}
381
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700382int
383z180_cmdstream_issueibcmds(struct kgsl_device_private *dev_priv,
384 struct kgsl_context *context,
385 struct kgsl_ibdesc *ibdesc,
386 unsigned int numibs,
387 uint32_t *timestamp,
388 unsigned int ctrl)
389{
Tarun Karra9b92ccd2011-08-19 10:59:57 -0700390 long result = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700391 unsigned int ofs = PACKETSIZE_STATESTREAM * sizeof(unsigned int);
392 unsigned int cnt = 5;
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600393 unsigned int old_timestamp = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700394 unsigned int nextcnt = Z180_STREAM_END_CMD | 5;
Jeremy Gebbend27b09f2012-04-06 16:09:13 -0600395 struct kgsl_mem_entry *entry = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700396 unsigned int cmd;
397 struct kgsl_device *device = dev_priv->device;
398 struct kgsl_pagetable *pagetable = dev_priv->process_priv->pagetable;
399 struct z180_device *z180_dev = Z180_DEVICE(device);
400 unsigned int sizedwords;
401
402 if (device->state & KGSL_STATE_HUNG) {
Carter Cooperb90880d2011-10-26 14:38:02 -0600403 result = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700404 goto error;
405 }
406 if (numibs != 1) {
407 KGSL_DRV_ERR(device, "Invalid number of ibs: %d\n", numibs);
408 result = -EINVAL;
409 goto error;
410 }
411 cmd = ibdesc[0].gpuaddr;
412 sizedwords = ibdesc[0].sizedwords;
Jeremy Gebbend27b09f2012-04-06 16:09:13 -0600413 /*
414 * Get a kernel mapping to the IB for monkey patching.
415 * See the end of this function.
416 */
417 entry = kgsl_sharedmem_find_region(dev_priv->process_priv, cmd,
418 sizedwords);
419 if (entry == NULL) {
420 KGSL_DRV_ERR(device, "Bad ibdesc: gpuaddr 0x%x size %d\n",
421 cmd, sizedwords);
422 result = -EINVAL;
423 goto error;
424 }
425 /*
426 * This will only map memory if it exists, otherwise it will reuse the
427 * mapping. And the 2d userspace reuses IBs so we likely won't create
428 * too many mappings.
429 */
430 if (kgsl_gpuaddr_to_vaddr(&entry->memdesc, cmd) == NULL) {
431 KGSL_DRV_ERR(device,
432 "Cannot make kernel mapping for gpuaddr 0x%x\n",
433 cmd);
434 result = -EINVAL;
435 goto error;
436 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700437
438 KGSL_CMD_INFO(device, "ctxt %d ibaddr 0x%08x sizedwords %d\n",
439 context->id, cmd, sizedwords);
440 /* context switch */
441 if ((context->id != (int)z180_dev->ringbuffer.prevctx) ||
442 (ctrl & KGSL_CONTEXT_CTX_SWITCH)) {
443 KGSL_CMD_INFO(device, "context switch %d -> %d\n",
444 context->id, z180_dev->ringbuffer.prevctx);
Shubhraprakash Das79447952012-04-26 18:12:23 -0600445 kgsl_mmu_setstate(&device->mmu, pagetable);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700446 cnt = PACKETSIZE_STATESTREAM;
447 ofs = 0;
448 }
Shubhraprakash Das1c528262012-04-26 17:38:13 -0600449 kgsl_setstate(&device->mmu,
450 kgsl_mmu_pt_get_flags(device->mmu.hwpagetable,
451 device->id));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700452
453 result = wait_event_interruptible_timeout(device->wait_queue,
454 room_in_rb(z180_dev),
455 msecs_to_jiffies(KGSL_TIMEOUT_DEFAULT));
456 if (result < 0) {
457 KGSL_CMD_ERR(device, "wait_event_interruptible_timeout "
Tarun Karra9b92ccd2011-08-19 10:59:57 -0700458 "failed: %ld\n", result);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700459 goto error;
460 }
461 result = 0;
462
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600463 old_timestamp = z180_dev->current_timestamp;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700464 z180_dev->current_timestamp++;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700465 *timestamp = z180_dev->current_timestamp;
466
467 z180_dev->ringbuffer.prevctx = context->id;
468
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600469 addcmd(&z180_dev->ringbuffer, old_timestamp, cmd + ofs, cnt);
Lucille Sylvester808eca22011-11-03 10:26:29 -0700470 kgsl_pwrscale_busy(device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700471
472 /* Make sure the next ringbuffer entry has a marker */
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600473 addmarker(&z180_dev->ringbuffer, z180_dev->current_timestamp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700474
Jeremy Gebbend27b09f2012-04-06 16:09:13 -0600475 /* monkey patch the IB so that it jumps back to the ringbuffer */
476 kgsl_sharedmem_writel(&entry->memdesc,
Jeremy Gebben8b253bf2012-04-23 16:02:47 -0600477 ((sizedwords + 1) * sizeof(unsigned int)),
478 rb_gpuaddr(z180_dev, z180_dev->current_timestamp));
Jeremy Gebbend27b09f2012-04-06 16:09:13 -0600479 kgsl_sharedmem_writel(&entry->memdesc,
480 ((sizedwords + 2) * sizeof(unsigned int)),
481 nextcnt);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700482
483 /* sync memory before activating the hardware for the new command*/
484 mb();
485
486 cmd = (int)(((2) & VGV3_CONTROL_MARKADD_FMASK)
487 << VGV3_CONTROL_MARKADD_FSHIFT);
488
489 z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, cmd);
490 z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, 0);
491error:
Tarun Karra9b92ccd2011-08-19 10:59:57 -0700492 return (int)result;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700493}
494
495static int z180_ringbuffer_init(struct kgsl_device *device)
496{
497 struct z180_device *z180_dev = Z180_DEVICE(device);
498 memset(&z180_dev->ringbuffer, 0, sizeof(struct z180_ringbuffer));
499 z180_dev->ringbuffer.prevctx = Z180_INVALID_CONTEXT;
500 return kgsl_allocate_contiguous(&z180_dev->ringbuffer.cmdbufdesc,
501 Z180_RB_SIZE);
502}
503
504static void z180_ringbuffer_close(struct kgsl_device *device)
505{
506 struct z180_device *z180_dev = Z180_DEVICE(device);
507 kgsl_sharedmem_free(&z180_dev->ringbuffer.cmdbufdesc);
508 memset(&z180_dev->ringbuffer, 0, sizeof(struct z180_ringbuffer));
509}
510
511static int __devinit z180_probe(struct platform_device *pdev)
512{
513 int status = -EINVAL;
514 struct kgsl_device *device = NULL;
515 struct z180_device *z180_dev;
516
517 device = (struct kgsl_device *)pdev->id_entry->driver_data;
518 device->parentdev = &pdev->dev;
519
520 z180_dev = Z180_DEVICE(device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700521
522 status = z180_ringbuffer_init(device);
523 if (status != 0)
524 goto error;
525
Jordan Crouseb368e9b2012-04-27 14:01:59 -0600526 status = kgsl_device_platform_probe(device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700527 if (status)
528 goto error_close_ringbuffer;
529
Lucille Sylvester591ea032011-07-21 16:08:37 -0600530 kgsl_pwrscale_init(device);
Lucille Sylvester808eca22011-11-03 10:26:29 -0700531 kgsl_pwrscale_attach_policy(device, Z180_DEFAULT_PWRSCALE_POLICY);
Lucille Sylvester591ea032011-07-21 16:08:37 -0600532
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700533 return status;
534
535error_close_ringbuffer:
536 z180_ringbuffer_close(device);
537error:
538 device->parentdev = NULL;
539 return status;
540}
541
542static int __devexit z180_remove(struct platform_device *pdev)
543{
544 struct kgsl_device *device = NULL;
545
546 device = (struct kgsl_device *)pdev->id_entry->driver_data;
547
Lucille Sylvester591ea032011-07-21 16:08:37 -0600548 kgsl_pwrscale_close(device);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700549 kgsl_device_platform_remove(device);
550
551 z180_ringbuffer_close(device);
552
553 return 0;
554}
555
556static int z180_start(struct kgsl_device *device, unsigned int init_ram)
557{
558 int status = 0;
559
Jeremy Gebben388c2972011-12-16 09:05:07 -0700560 kgsl_pwrctrl_set_state(device, KGSL_STATE_INIT);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700561
562 kgsl_pwrctrl_enable(device);
563
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700564 /* Set interrupts to 0 to ensure a good state */
565 z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 0x0);
566
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600567 kgsl_mh_start(device);
568
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700569 status = kgsl_mmu_start(device);
570 if (status)
571 goto error_clk_off;
572
Shubhraprakash Das8cbd2322012-03-04 14:41:39 -0700573 z180_cmdstream_start(device, init_ram);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700574
575 mod_timer(&device->idle_timer, jiffies + FIRST_TIMEOUT);
Jeremy Gebbenb46f4152011-10-14 14:27:00 -0600576 kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_ON);
Jeremy Gebbenb7bc9552012-01-09 13:32:49 -0700577 device->ftbl->irqctrl(device, 1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700578 return 0;
579
580error_clk_off:
581 z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 0);
582 kgsl_pwrctrl_disable(device);
583 return status;
584}
585
586static int z180_stop(struct kgsl_device *device)
587{
Jeremy Gebbenb7bc9552012-01-09 13:32:49 -0700588 device->ftbl->irqctrl(device, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700589 z180_idle(device, KGSL_TIMEOUT_DEFAULT);
590
Suman Tatiraju4a32c652012-02-17 11:59:05 -0800591 del_timer_sync(&device->idle_timer);
592
Shubhraprakash Das79447952012-04-26 18:12:23 -0600593 kgsl_mmu_stop(&device->mmu);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700594
595 /* Disable the clocks before the power rail. */
596 kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF);
597
598 kgsl_pwrctrl_disable(device);
599
600 return 0;
601}
602
603static int z180_getproperty(struct kgsl_device *device,
604 enum kgsl_property_type type,
605 void *value,
606 unsigned int sizebytes)
607{
608 int status = -EINVAL;
609
610 switch (type) {
611 case KGSL_PROP_DEVICE_INFO:
612 {
613 struct kgsl_devinfo devinfo;
614
615 if (sizebytes != sizeof(devinfo)) {
616 status = -EINVAL;
617 break;
618 }
619
620 memset(&devinfo, 0, sizeof(devinfo));
621 devinfo.device_id = device->id+1;
622 devinfo.chip_id = 0;
623 devinfo.mmu_enabled = kgsl_mmu_enabled();
624
625 if (copy_to_user(value, &devinfo, sizeof(devinfo)) !=
626 0) {
627 status = -EFAULT;
628 break;
629 }
630 status = 0;
631 }
632 break;
633 case KGSL_PROP_MMU_ENABLE:
634 {
Shubhraprakash Das767fdda2011-08-15 15:49:45 -0600635 int mmu_prop = kgsl_mmu_enabled();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700636 if (sizebytes != sizeof(int)) {
637 status = -EINVAL;
638 break;
639 }
Shubhraprakash Das767fdda2011-08-15 15:49:45 -0600640 if (copy_to_user(value, &mmu_prop, sizeof(mmu_prop))) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700641 status = -EFAULT;
642 break;
643 }
644 status = 0;
645 }
646 break;
647
648 default:
649 KGSL_DRV_ERR(device, "invalid property: %d\n", type);
650 status = -EINVAL;
651 }
652 return status;
653}
654
655static unsigned int z180_isidle(struct kgsl_device *device)
656{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700657 struct z180_device *z180_dev = Z180_DEVICE(device);
658
Jordan Crousee6239dd2011-11-17 13:39:21 -0700659 return (timestamp_cmp(z180_dev->timestamp,
660 z180_dev->current_timestamp) == 0) ? true : false;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700661}
662
663static int z180_suspend_context(struct kgsl_device *device)
664{
665 struct z180_device *z180_dev = Z180_DEVICE(device);
666
667 z180_dev->ringbuffer.prevctx = Z180_INVALID_CONTEXT;
668
669 return 0;
670}
671
672/* Not all Z180 registers are directly accessible.
673 * The _z180_(read|write)_simple functions below handle the ones that are.
674 */
675static void _z180_regread_simple(struct kgsl_device *device,
676 unsigned int offsetwords,
677 unsigned int *value)
678{
679 unsigned int *reg;
680
Jordan Crouse7501d452012-04-19 08:58:44 -0600681 BUG_ON(offsetwords * sizeof(uint32_t) >= device->reg_len);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700682
Jordan Crouse7501d452012-04-19 08:58:44 -0600683 reg = (unsigned int *)(device->reg_virt + (offsetwords << 2));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700684
685 /*ensure this read finishes before the next one.
686 * i.e. act like normal readl() */
687 *value = __raw_readl(reg);
688 rmb();
689
690}
691
692static void _z180_regwrite_simple(struct kgsl_device *device,
693 unsigned int offsetwords,
694 unsigned int value)
695{
696 unsigned int *reg;
697
Jordan Crouse7501d452012-04-19 08:58:44 -0600698 BUG_ON(offsetwords*sizeof(uint32_t) >= device->reg_len);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700699
Jordan Crouse7501d452012-04-19 08:58:44 -0600700 reg = (unsigned int *)(device->reg_virt + (offsetwords << 2));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700701 kgsl_cffdump_regwrite(device->id, offsetwords << 2, value);
702 /*ensure previous writes post before this one,
703 * i.e. act like normal writel() */
704 wmb();
705 __raw_writel(value, reg);
706}
707
708
709/* The MH registers must be accessed through via a 2 step write, (read|write)
710 * process. These registers may be accessed from interrupt context during
711 * the handling of MH or MMU error interrupts. Therefore a spin lock is used
712 * to ensure that the 2 step sequence is not interrupted.
713 */
714static void _z180_regread_mmu(struct kgsl_device *device,
715 unsigned int offsetwords,
716 unsigned int *value)
717{
718 struct z180_device *z180_dev = Z180_DEVICE(device);
719 unsigned long flags;
720
721 spin_lock_irqsave(&z180_dev->cmdwin_lock, flags);
722 _z180_regwrite_simple(device, (ADDR_VGC_MH_READ_ADDR >> 2),
723 offsetwords);
724 _z180_regread_simple(device, (ADDR_VGC_MH_DATA_ADDR >> 2), value);
725 spin_unlock_irqrestore(&z180_dev->cmdwin_lock, flags);
726}
727
728
729static void _z180_regwrite_mmu(struct kgsl_device *device,
730 unsigned int offsetwords,
731 unsigned int value)
732{
733 struct z180_device *z180_dev = Z180_DEVICE(device);
734 unsigned int cmdwinaddr;
735 unsigned long flags;
736
737 cmdwinaddr = ((Z180_CMDWINDOW_MMU << Z180_CMDWINDOW_TARGET_SHIFT) &
738 Z180_CMDWINDOW_TARGET_MASK);
739 cmdwinaddr |= ((offsetwords << Z180_CMDWINDOW_ADDR_SHIFT) &
740 Z180_CMDWINDOW_ADDR_MASK);
741
742 spin_lock_irqsave(&z180_dev->cmdwin_lock, flags);
743 _z180_regwrite_simple(device, ADDR_VGC_MMUCOMMANDSTREAM >> 2,
744 cmdwinaddr);
745 _z180_regwrite_simple(device, ADDR_VGC_MMUCOMMANDSTREAM >> 2, value);
746 spin_unlock_irqrestore(&z180_dev->cmdwin_lock, flags);
747}
748
749/* the rest of the code doesn't want to think about if it is writing mmu
750 * registers or normal registers so handle it here
751 */
752static void z180_regread(struct kgsl_device *device,
753 unsigned int offsetwords,
754 unsigned int *value)
755{
756 if (!in_interrupt())
757 kgsl_pre_hwaccess(device);
758
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600759 if ((offsetwords >= MH_ARBITER_CONFIG &&
760 offsetwords <= MH_AXI_HALT_CONTROL) ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700761 (offsetwords >= MH_MMU_CONFIG &&
762 offsetwords <= MH_MMU_MPU_END)) {
763 _z180_regread_mmu(device, offsetwords, value);
764 } else {
765 _z180_regread_simple(device, offsetwords, value);
766 }
767}
768
769static void z180_regwrite(struct kgsl_device *device,
770 unsigned int offsetwords,
771 unsigned int value)
772{
773 if (!in_interrupt())
774 kgsl_pre_hwaccess(device);
775
Jeremy Gebben4e8aada2011-07-12 10:07:47 -0600776 if ((offsetwords >= MH_ARBITER_CONFIG &&
777 offsetwords <= MH_CLNT_INTF_CTRL_CONFIG2) ||
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700778 (offsetwords >= MH_MMU_CONFIG &&
779 offsetwords <= MH_MMU_MPU_END)) {
780 _z180_regwrite_mmu(device, offsetwords, value);
781 } else {
782 _z180_regwrite_simple(device, offsetwords, value);
783 }
784}
785
786static void z180_cmdwindow_write(struct kgsl_device *device,
787 unsigned int addr, unsigned int data)
788{
789 unsigned int cmdwinaddr;
790
791 cmdwinaddr = ((Z180_CMDWINDOW_2D << Z180_CMDWINDOW_TARGET_SHIFT) &
792 Z180_CMDWINDOW_TARGET_MASK);
793 cmdwinaddr |= ((addr << Z180_CMDWINDOW_ADDR_SHIFT) &
794 Z180_CMDWINDOW_ADDR_MASK);
795
796 z180_regwrite(device, ADDR_VGC_COMMANDSTREAM >> 2, cmdwinaddr);
797 z180_regwrite(device, ADDR_VGC_COMMANDSTREAM >> 2, data);
798}
799
800static unsigned int z180_readtimestamp(struct kgsl_device *device,
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700801 struct kgsl_context *context, enum kgsl_timestamp_type type)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802{
803 struct z180_device *z180_dev = Z180_DEVICE(device);
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700804 (void)context;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805 /* get current EOP timestamp */
806 return z180_dev->timestamp;
807}
808
809static int z180_waittimestamp(struct kgsl_device *device,
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700810 struct kgsl_context *context,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700811 unsigned int timestamp,
812 unsigned int msecs)
813{
814 int status = -EINVAL;
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +0530815
816 /* Don't wait forever, set a max (10 sec) value for now */
817 if (msecs == -1)
818 msecs = 10 * MSEC_PER_SEC;
819
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820 mutex_unlock(&device->mutex);
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700821 status = z180_wait(device, context, timestamp, msecs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700822 mutex_lock(&device->mutex);
823
824 return status;
825}
826
827static int z180_wait(struct kgsl_device *device,
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700828 struct kgsl_context *context,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700829 unsigned int timestamp,
830 unsigned int msecs)
831{
832 int status = -EINVAL;
833 long timeout = 0;
834
835 timeout = wait_io_event_interruptible_timeout(
836 device->wait_queue,
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700837 kgsl_check_timestamp(device, context, timestamp),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700838 msecs_to_jiffies(msecs));
839
840 if (timeout > 0)
841 status = 0;
842 else if (timeout == 0) {
843 status = -ETIMEDOUT;
Jeremy Gebben388c2972011-12-16 09:05:07 -0700844 kgsl_pwrctrl_set_state(device, KGSL_STATE_HUNG);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700845 } else
846 status = timeout;
847
848 return status;
849}
850
851static void
852z180_drawctxt_destroy(struct kgsl_device *device,
853 struct kgsl_context *context)
854{
855 struct z180_device *z180_dev = Z180_DEVICE(device);
856
857 z180_idle(device, KGSL_TIMEOUT_DEFAULT);
858
859 if (z180_dev->ringbuffer.prevctx == context->id) {
860 z180_dev->ringbuffer.prevctx = Z180_INVALID_CONTEXT;
861 device->mmu.hwpagetable = device->mmu.defaultpagetable;
Shubhraprakash Das1c528262012-04-26 17:38:13 -0600862 kgsl_setstate(&device->mmu, KGSL_MMUFLAGS_PTUPDATE);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700863 }
864}
865
866static void z180_power_stats(struct kgsl_device *device,
867 struct kgsl_power_stats *stats)
868{
Lucille Sylvester591ea032011-07-21 16:08:37 -0600869 struct kgsl_pwrctrl *pwr = &device->pwrctrl;
Lucille Sylvester808eca22011-11-03 10:26:29 -0700870 s64 tmp = ktime_to_us(ktime_get());
Lucille Sylvester591ea032011-07-21 16:08:37 -0600871
872 if (pwr->time == 0) {
Lucille Sylvester808eca22011-11-03 10:26:29 -0700873 pwr->time = tmp;
Lucille Sylvester591ea032011-07-21 16:08:37 -0600874 stats->total_time = 0;
875 stats->busy_time = 0;
876 } else {
Lucille Sylvester591ea032011-07-21 16:08:37 -0600877 stats->total_time = tmp - pwr->time;
Lucille Sylvester591ea032011-07-21 16:08:37 -0600878 pwr->time = tmp;
Lucille Sylvester808eca22011-11-03 10:26:29 -0700879 stats->busy_time = tmp - device->on_time;
880 device->on_time = tmp;
Lucille Sylvester591ea032011-07-21 16:08:37 -0600881 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700882}
883
884static void z180_irqctrl(struct kgsl_device *device, int state)
885{
886 /* Control interrupts for Z180 and the Z180 MMU */
887
888 if (state) {
889 z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 3);
890 z180_regwrite(device, MH_INTERRUPT_MASK, KGSL_MMU_INT_MASK);
891 } else {
892 z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 0);
893 z180_regwrite(device, MH_INTERRUPT_MASK, 0);
894 }
895}
896
Jordan Crousea0758f22011-12-07 11:19:22 -0700897static unsigned int z180_gpuid(struct kgsl_device *device)
898{
899 /* Standard KGSL gpuid format:
900 * top word is 0x0002 for 2D or 0x0003 for 3D
901 * Bottom word is core specific identifer
902 */
903
904 return (0x0002 << 16) | 180;
905}
906
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907static const struct kgsl_functable z180_functable = {
908 /* Mandatory functions */
909 .regread = z180_regread,
910 .regwrite = z180_regwrite,
911 .idle = z180_idle,
912 .isidle = z180_isidle,
913 .suspend_context = z180_suspend_context,
914 .start = z180_start,
915 .stop = z180_stop,
916 .getproperty = z180_getproperty,
917 .waittimestamp = z180_waittimestamp,
918 .readtimestamp = z180_readtimestamp,
919 .issueibcmds = z180_cmdstream_issueibcmds,
920 .setup_pt = z180_setup_pt,
921 .cleanup_pt = z180_cleanup_pt,
922 .power_stats = z180_power_stats,
923 .irqctrl = z180_irqctrl,
Jordan Crousea0758f22011-12-07 11:19:22 -0700924 .gpuid = z180_gpuid,
Jordan Crouseb368e9b2012-04-27 14:01:59 -0600925 .irq_handler = z180_irq_handler,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700926 /* Optional functions */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700927 .drawctxt_create = NULL,
928 .drawctxt_destroy = z180_drawctxt_destroy,
929 .ioctl = NULL,
930};
931
932static struct platform_device_id z180_id_table[] = {
933 { DEVICE_2D0_NAME, (kernel_ulong_t)&device_2d0.dev, },
934 { DEVICE_2D1_NAME, (kernel_ulong_t)&device_2d1.dev, },
935 { },
936};
937MODULE_DEVICE_TABLE(platform, z180_id_table);
938
939static struct platform_driver z180_platform_driver = {
940 .probe = z180_probe,
941 .remove = __devexit_p(z180_remove),
942 .suspend = kgsl_suspend_driver,
943 .resume = kgsl_resume_driver,
944 .id_table = z180_id_table,
945 .driver = {
946 .owner = THIS_MODULE,
947 .name = DEVICE_2D_NAME,
948 .pm = &kgsl_pm_ops,
949 }
950};
951
952static int __init kgsl_2d_init(void)
953{
954 return platform_driver_register(&z180_platform_driver);
955}
956
957static void __exit kgsl_2d_exit(void)
958{
959 platform_driver_unregister(&z180_platform_driver);
960}
961
962module_init(kgsl_2d_init);
963module_exit(kgsl_2d_exit);
964
965MODULE_DESCRIPTION("2D Graphics driver");
966MODULE_VERSION("1.2");
967MODULE_LICENSE("GPL v2");
968MODULE_ALIAS("platform:kgsl_2d");