blob: 5cec194b6cc52fbaf8a4cd840434d83ce74db654 [file] [log] [blame]
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001/*
2 * Copyright (C) 2012 Samsung Electronics Co.Ltd
3 * Authors: Joonyoung Shim <jy0922.shim@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundationr
8 */
9
10#include <linux/kernel.h>
Joonyoung Shimd7f16422012-05-17 20:06:32 +090011#include <linux/clk.h>
12#include <linux/err.h>
13#include <linux/interrupt.h>
14#include <linux/io.h>
15#include <linux/platform_device.h>
16#include <linux/pm_runtime.h>
17#include <linux/slab.h>
18#include <linux/workqueue.h>
Inki Daed87342c2012-11-03 21:53:24 -070019#include <linux/dma-mapping.h>
20#include <linux/dma-attrs.h>
Ajay Kumar95fc6332013-02-06 10:59:44 +053021#include <linux/of.h>
Joonyoung Shimd7f16422012-05-17 20:06:32 +090022
David Howells760285e2012-10-02 18:01:07 +010023#include <drm/drmP.h>
24#include <drm/exynos_drm.h>
Joonyoung Shimd7f16422012-05-17 20:06:32 +090025#include "exynos_drm_drv.h"
Mark Browne30655d2013-08-13 00:46:40 +010026#include "exynos_drm_g2d.h"
Joonyoung Shimd7f16422012-05-17 20:06:32 +090027#include "exynos_drm_gem.h"
Inki Daed87342c2012-11-03 21:53:24 -070028#include "exynos_drm_iommu.h"
Joonyoung Shimd7f16422012-05-17 20:06:32 +090029
30#define G2D_HW_MAJOR_VER 4
31#define G2D_HW_MINOR_VER 1
32
33/* vaild register range set from user: 0x0104 ~ 0x0880 */
34#define G2D_VALID_START 0x0104
35#define G2D_VALID_END 0x0880
36
37/* general registers */
38#define G2D_SOFT_RESET 0x0000
39#define G2D_INTEN 0x0004
40#define G2D_INTC_PEND 0x000C
41#define G2D_DMA_SFR_BASE_ADDR 0x0080
42#define G2D_DMA_COMMAND 0x0084
43#define G2D_DMA_STATUS 0x008C
44#define G2D_DMA_HOLD_CMD 0x0090
45
46/* command registers */
47#define G2D_BITBLT_START 0x0100
48
49/* registers for base address */
50#define G2D_SRC_BASE_ADDR 0x0304
YoungJun Cho2dec17c2013-03-11 21:17:52 +090051#define G2D_SRC_COLOR_MODE 0x030C
52#define G2D_SRC_LEFT_TOP 0x0310
53#define G2D_SRC_RIGHT_BOTTOM 0x0314
Joonyoung Shimd7f16422012-05-17 20:06:32 +090054#define G2D_SRC_PLANE2_BASE_ADDR 0x0318
55#define G2D_DST_BASE_ADDR 0x0404
YoungJun Cho2dec17c2013-03-11 21:17:52 +090056#define G2D_DST_COLOR_MODE 0x040C
57#define G2D_DST_LEFT_TOP 0x0410
58#define G2D_DST_RIGHT_BOTTOM 0x0414
Joonyoung Shimd7f16422012-05-17 20:06:32 +090059#define G2D_DST_PLANE2_BASE_ADDR 0x0418
60#define G2D_PAT_BASE_ADDR 0x0500
61#define G2D_MSK_BASE_ADDR 0x0520
62
63/* G2D_SOFT_RESET */
64#define G2D_SFRCLEAR (1 << 1)
65#define G2D_R (1 << 0)
66
67/* G2D_INTEN */
68#define G2D_INTEN_ACF (1 << 3)
69#define G2D_INTEN_UCF (1 << 2)
70#define G2D_INTEN_GCF (1 << 1)
71#define G2D_INTEN_SCF (1 << 0)
72
73/* G2D_INTC_PEND */
74#define G2D_INTP_ACMD_FIN (1 << 3)
75#define G2D_INTP_UCMD_FIN (1 << 2)
76#define G2D_INTP_GCMD_FIN (1 << 1)
77#define G2D_INTP_SCMD_FIN (1 << 0)
78
79/* G2D_DMA_COMMAND */
80#define G2D_DMA_HALT (1 << 2)
81#define G2D_DMA_CONTINUE (1 << 1)
82#define G2D_DMA_START (1 << 0)
83
84/* G2D_DMA_STATUS */
85#define G2D_DMA_LIST_DONE_COUNT (0xFF << 17)
86#define G2D_DMA_BITBLT_DONE_COUNT (0xFFFF << 1)
87#define G2D_DMA_DONE (1 << 0)
88#define G2D_DMA_LIST_DONE_COUNT_OFFSET 17
89
90/* G2D_DMA_HOLD_CMD */
YoungJun Cho7ad01812013-03-13 16:44:37 +090091#define G2D_USER_HOLD (1 << 2)
Joonyoung Shimd7f16422012-05-17 20:06:32 +090092#define G2D_LIST_HOLD (1 << 1)
93#define G2D_BITBLT_HOLD (1 << 0)
94
95/* G2D_BITBLT_START */
96#define G2D_START_CASESEL (1 << 2)
97#define G2D_START_NHOLT (1 << 1)
98#define G2D_START_BITBLT (1 << 0)
99
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900100/* buffer color format */
101#define G2D_FMT_XRGB8888 0
102#define G2D_FMT_ARGB8888 1
103#define G2D_FMT_RGB565 2
104#define G2D_FMT_XRGB1555 3
105#define G2D_FMT_ARGB1555 4
106#define G2D_FMT_XRGB4444 5
107#define G2D_FMT_ARGB4444 6
108#define G2D_FMT_PACKED_RGB888 7
109#define G2D_FMT_A8 11
110#define G2D_FMT_L8 12
111
112/* buffer valid length */
113#define G2D_LEN_MIN 1
114#define G2D_LEN_MAX 8000
115
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900116#define G2D_CMDLIST_SIZE (PAGE_SIZE / 4)
117#define G2D_CMDLIST_NUM 64
118#define G2D_CMDLIST_POOL_SIZE (G2D_CMDLIST_SIZE * G2D_CMDLIST_NUM)
119#define G2D_CMDLIST_DATA_NUM (G2D_CMDLIST_SIZE / sizeof(u32) - 2)
120
Inki Dae2a3098f2012-11-04 05:48:52 -0800121/* maximum buffer pool size of userptr is 64MB as default */
122#define MAX_POOL (64 * 1024 * 1024)
123
124enum {
125 BUF_TYPE_GEM = 1,
126 BUF_TYPE_USERPTR,
127};
128
YoungJun Cho9963cb62013-03-13 17:10:08 +0900129enum g2d_reg_type {
130 REG_TYPE_NONE = -1,
131 REG_TYPE_SRC,
132 REG_TYPE_SRC_PLANE2,
133 REG_TYPE_DST,
134 REG_TYPE_DST_PLANE2,
135 REG_TYPE_PAT,
136 REG_TYPE_MSK,
137 MAX_REG_TYPE_NR
138};
139
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900140/* cmdlist data structure */
141struct g2d_cmdlist {
Inki Dae2a3098f2012-11-04 05:48:52 -0800142 u32 head;
143 unsigned long data[G2D_CMDLIST_DATA_NUM];
144 u32 last; /* last data offset */
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900145};
146
YoungJun Cho9963cb62013-03-13 17:10:08 +0900147/*
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900148 * A structure of buffer description
149 *
150 * @format: color format
151 * @left_x: the x coordinates of left top corner
152 * @top_y: the y coordinates of left top corner
153 * @right_x: the x coordinates of right bottom corner
154 * @bottom_y: the y coordinates of right bottom corner
155 *
156 */
157struct g2d_buf_desc {
158 unsigned int format;
159 unsigned int left_x;
160 unsigned int top_y;
161 unsigned int right_x;
162 unsigned int bottom_y;
163};
164
165/*
YoungJun Cho9963cb62013-03-13 17:10:08 +0900166 * A structure of buffer information
167 *
168 * @map_nr: manages the number of mapped buffers
169 * @reg_types: stores regitster type in the order of requested command
170 * @handles: stores buffer handle in its reg_type position
171 * @types: stores buffer type in its reg_type position
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900172 * @descs: stores buffer description in its reg_type position
YoungJun Cho9963cb62013-03-13 17:10:08 +0900173 *
174 */
175struct g2d_buf_info {
176 unsigned int map_nr;
177 enum g2d_reg_type reg_types[MAX_REG_TYPE_NR];
178 unsigned long handles[MAX_REG_TYPE_NR];
179 unsigned int types[MAX_REG_TYPE_NR];
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900180 struct g2d_buf_desc descs[MAX_REG_TYPE_NR];
YoungJun Cho9963cb62013-03-13 17:10:08 +0900181};
182
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900183struct drm_exynos_pending_g2d_event {
184 struct drm_pending_event base;
185 struct drm_exynos_g2d_event event;
186};
187
Inki Dae2a3098f2012-11-04 05:48:52 -0800188struct g2d_cmdlist_userptr {
189 struct list_head list;
190 dma_addr_t dma_addr;
191 unsigned long userptr;
192 unsigned long size;
193 struct page **pages;
194 unsigned int npages;
195 struct sg_table *sgt;
196 struct vm_area_struct *vma;
197 atomic_t refcount;
198 bool in_pool;
199 bool out_of_list;
200};
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900201struct g2d_cmdlist_node {
202 struct list_head list;
203 struct g2d_cmdlist *cmdlist;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900204 dma_addr_t dma_addr;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900205 struct g2d_buf_info buf_info;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900206
207 struct drm_exynos_pending_g2d_event *event;
208};
209
210struct g2d_runqueue_node {
211 struct list_head list;
212 struct list_head run_cmdlist;
213 struct list_head event_list;
Inki Daed87342c2012-11-03 21:53:24 -0700214 struct drm_file *filp;
Inki Dae6b6bae22012-09-11 10:45:36 +0900215 pid_t pid;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900216 struct completion complete;
217 int async;
218};
219
220struct g2d_data {
221 struct device *dev;
222 struct clk *gate_clk;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900223 void __iomem *regs;
224 int irq;
225 struct workqueue_struct *g2d_workq;
226 struct work_struct runqueue_work;
227 struct exynos_drm_subdrv subdrv;
228 bool suspended;
229
230 /* cmdlist */
231 struct g2d_cmdlist_node *cmdlist_node;
232 struct list_head free_cmdlist;
233 struct mutex cmdlist_mutex;
234 dma_addr_t cmdlist_pool;
235 void *cmdlist_pool_virt;
Inki Daed87342c2012-11-03 21:53:24 -0700236 struct dma_attrs cmdlist_dma_attrs;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900237
238 /* runqueue*/
239 struct g2d_runqueue_node *runqueue_node;
240 struct list_head runqueue;
241 struct mutex runqueue_mutex;
242 struct kmem_cache *runqueue_slab;
Inki Dae2a3098f2012-11-04 05:48:52 -0800243
244 unsigned long current_pool;
245 unsigned long max_pool;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900246};
247
248static int g2d_init_cmdlist(struct g2d_data *g2d)
249{
250 struct device *dev = g2d->dev;
251 struct g2d_cmdlist_node *node = g2d->cmdlist_node;
Inki Daed87342c2012-11-03 21:53:24 -0700252 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900253 int nr;
254 int ret;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900255 struct g2d_buf_info *buf_info;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900256
Inki Daed87342c2012-11-03 21:53:24 -0700257 init_dma_attrs(&g2d->cmdlist_dma_attrs);
258 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &g2d->cmdlist_dma_attrs);
259
260 g2d->cmdlist_pool_virt = dma_alloc_attrs(subdrv->drm_dev->dev,
261 G2D_CMDLIST_POOL_SIZE,
262 &g2d->cmdlist_pool, GFP_KERNEL,
263 &g2d->cmdlist_dma_attrs);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900264 if (!g2d->cmdlist_pool_virt) {
265 dev_err(dev, "failed to allocate dma memory\n");
266 return -ENOMEM;
267 }
268
Joonyoung Shimfab9f8d2012-09-27 19:26:03 +0900269 node = kcalloc(G2D_CMDLIST_NUM, sizeof(*node), GFP_KERNEL);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900270 if (!node) {
271 dev_err(dev, "failed to allocate memory\n");
272 ret = -ENOMEM;
273 goto err;
274 }
275
276 for (nr = 0; nr < G2D_CMDLIST_NUM; nr++) {
YoungJun Cho9963cb62013-03-13 17:10:08 +0900277 unsigned int i;
278
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900279 node[nr].cmdlist =
280 g2d->cmdlist_pool_virt + nr * G2D_CMDLIST_SIZE;
281 node[nr].dma_addr =
282 g2d->cmdlist_pool + nr * G2D_CMDLIST_SIZE;
283
YoungJun Cho9963cb62013-03-13 17:10:08 +0900284 buf_info = &node[nr].buf_info;
285 for (i = 0; i < MAX_REG_TYPE_NR; i++)
286 buf_info->reg_types[i] = REG_TYPE_NONE;
287
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900288 list_add_tail(&node[nr].list, &g2d->free_cmdlist);
289 }
290
291 return 0;
292
293err:
Inki Daed87342c2012-11-03 21:53:24 -0700294 dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE,
295 g2d->cmdlist_pool_virt,
296 g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900297 return ret;
298}
299
300static void g2d_fini_cmdlist(struct g2d_data *g2d)
301{
Inki Daed87342c2012-11-03 21:53:24 -0700302 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900303
304 kfree(g2d->cmdlist_node);
Inki Daed87342c2012-11-03 21:53:24 -0700305 dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE,
306 g2d->cmdlist_pool_virt,
307 g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900308}
309
310static struct g2d_cmdlist_node *g2d_get_cmdlist(struct g2d_data *g2d)
311{
312 struct device *dev = g2d->dev;
313 struct g2d_cmdlist_node *node;
314
315 mutex_lock(&g2d->cmdlist_mutex);
316 if (list_empty(&g2d->free_cmdlist)) {
317 dev_err(dev, "there is no free cmdlist\n");
318 mutex_unlock(&g2d->cmdlist_mutex);
319 return NULL;
320 }
321
322 node = list_first_entry(&g2d->free_cmdlist, struct g2d_cmdlist_node,
323 list);
324 list_del_init(&node->list);
325 mutex_unlock(&g2d->cmdlist_mutex);
326
327 return node;
328}
329
330static void g2d_put_cmdlist(struct g2d_data *g2d, struct g2d_cmdlist_node *node)
331{
332 mutex_lock(&g2d->cmdlist_mutex);
333 list_move_tail(&node->list, &g2d->free_cmdlist);
334 mutex_unlock(&g2d->cmdlist_mutex);
335}
336
337static void g2d_add_cmdlist_to_inuse(struct exynos_drm_g2d_private *g2d_priv,
338 struct g2d_cmdlist_node *node)
339{
340 struct g2d_cmdlist_node *lnode;
341
342 if (list_empty(&g2d_priv->inuse_cmdlist))
343 goto add_to_list;
344
345 /* this links to base address of new cmdlist */
346 lnode = list_entry(g2d_priv->inuse_cmdlist.prev,
347 struct g2d_cmdlist_node, list);
348 lnode->cmdlist->data[lnode->cmdlist->last] = node->dma_addr;
349
350add_to_list:
351 list_add_tail(&node->list, &g2d_priv->inuse_cmdlist);
352
353 if (node->event)
354 list_add_tail(&node->event->base.link, &g2d_priv->event_list);
355}
356
Inki Dae2a3098f2012-11-04 05:48:52 -0800357static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev,
358 unsigned long obj,
359 bool force)
360{
361 struct g2d_cmdlist_userptr *g2d_userptr =
362 (struct g2d_cmdlist_userptr *)obj;
363
364 if (!obj)
365 return;
366
367 if (force)
368 goto out;
369
370 atomic_dec(&g2d_userptr->refcount);
371
372 if (atomic_read(&g2d_userptr->refcount) > 0)
373 return;
374
375 if (g2d_userptr->in_pool)
376 return;
377
378out:
379 exynos_gem_unmap_sgt_from_dma(drm_dev, g2d_userptr->sgt,
380 DMA_BIDIRECTIONAL);
381
382 exynos_gem_put_pages_to_userptr(g2d_userptr->pages,
383 g2d_userptr->npages,
384 g2d_userptr->vma);
385
386 if (!g2d_userptr->out_of_list)
387 list_del_init(&g2d_userptr->list);
388
389 sg_free_table(g2d_userptr->sgt);
390 kfree(g2d_userptr->sgt);
Inki Dae2a3098f2012-11-04 05:48:52 -0800391
YoungJun Choaf51a5e2013-07-03 17:09:19 +0900392 drm_free_large(g2d_userptr->pages);
Sachin Kamatdf3d90e2012-11-23 09:11:59 +0530393 kfree(g2d_userptr);
Inki Dae2a3098f2012-11-04 05:48:52 -0800394}
395
Sachin Kamatb7848c72013-01-14 12:29:09 +0530396static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
Inki Dae2a3098f2012-11-04 05:48:52 -0800397 unsigned long userptr,
398 unsigned long size,
399 struct drm_file *filp,
400 unsigned long *obj)
401{
402 struct drm_exynos_file_private *file_priv = filp->driver_priv;
403 struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
404 struct g2d_cmdlist_userptr *g2d_userptr;
405 struct g2d_data *g2d;
406 struct page **pages;
407 struct sg_table *sgt;
408 struct vm_area_struct *vma;
409 unsigned long start, end;
410 unsigned int npages, offset;
411 int ret;
412
413 if (!size) {
414 DRM_ERROR("invalid userptr size.\n");
415 return ERR_PTR(-EINVAL);
416 }
417
418 g2d = dev_get_drvdata(g2d_priv->dev);
419
420 /* check if userptr already exists in userptr_list. */
421 list_for_each_entry(g2d_userptr, &g2d_priv->userptr_list, list) {
422 if (g2d_userptr->userptr == userptr) {
423 /*
424 * also check size because there could be same address
425 * and different size.
426 */
427 if (g2d_userptr->size == size) {
428 atomic_inc(&g2d_userptr->refcount);
429 *obj = (unsigned long)g2d_userptr;
430
431 return &g2d_userptr->dma_addr;
432 }
433
434 /*
435 * at this moment, maybe g2d dma is accessing this
436 * g2d_userptr memory region so just remove this
437 * g2d_userptr object from userptr_list not to be
438 * referred again and also except it the userptr
439 * pool to be released after the dma access completion.
440 */
441 g2d_userptr->out_of_list = true;
442 g2d_userptr->in_pool = false;
443 list_del_init(&g2d_userptr->list);
444
445 break;
446 }
447 }
448
449 g2d_userptr = kzalloc(sizeof(*g2d_userptr), GFP_KERNEL);
450 if (!g2d_userptr) {
451 DRM_ERROR("failed to allocate g2d_userptr.\n");
452 return ERR_PTR(-ENOMEM);
453 }
454
455 atomic_set(&g2d_userptr->refcount, 1);
456
457 start = userptr & PAGE_MASK;
458 offset = userptr & ~PAGE_MASK;
459 end = PAGE_ALIGN(userptr + size);
460 npages = (end - start) >> PAGE_SHIFT;
461 g2d_userptr->npages = npages;
462
YoungJun Choaf51a5e2013-07-03 17:09:19 +0900463 pages = drm_calloc_large(npages, sizeof(struct page *));
Inki Dae2a3098f2012-11-04 05:48:52 -0800464 if (!pages) {
465 DRM_ERROR("failed to allocate pages.\n");
Seung-Woo Kim4bb615c2013-07-03 17:09:21 +0900466 ret = -ENOMEM;
467 goto err_free;
Inki Dae2a3098f2012-11-04 05:48:52 -0800468 }
469
470 vma = find_vma(current->mm, userptr);
471 if (!vma) {
472 DRM_ERROR("failed to get vm region.\n");
473 ret = -EFAULT;
474 goto err_free_pages;
475 }
476
477 if (vma->vm_end < userptr + size) {
478 DRM_ERROR("vma is too small.\n");
479 ret = -EFAULT;
480 goto err_free_pages;
481 }
482
483 g2d_userptr->vma = exynos_gem_get_vma(vma);
484 if (!g2d_userptr->vma) {
485 DRM_ERROR("failed to copy vma.\n");
486 ret = -ENOMEM;
487 goto err_free_pages;
488 }
489
490 g2d_userptr->size = size;
491
492 ret = exynos_gem_get_pages_from_userptr(start & PAGE_MASK,
493 npages, pages, vma);
494 if (ret < 0) {
495 DRM_ERROR("failed to get user pages from userptr.\n");
496 goto err_put_vma;
497 }
498
499 g2d_userptr->pages = pages;
500
Sachin Kamate44a5c02013-01-25 14:45:42 +0530501 sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
Inki Dae2a3098f2012-11-04 05:48:52 -0800502 if (!sgt) {
503 DRM_ERROR("failed to allocate sg table.\n");
504 ret = -ENOMEM;
505 goto err_free_userptr;
506 }
507
508 ret = sg_alloc_table_from_pages(sgt, pages, npages, offset,
509 size, GFP_KERNEL);
510 if (ret < 0) {
511 DRM_ERROR("failed to get sgt from pages.\n");
512 goto err_free_sgt;
513 }
514
515 g2d_userptr->sgt = sgt;
516
517 ret = exynos_gem_map_sgt_with_dma(drm_dev, g2d_userptr->sgt,
518 DMA_BIDIRECTIONAL);
519 if (ret < 0) {
520 DRM_ERROR("failed to map sgt with dma region.\n");
YoungJun Cho067ed332013-03-11 19:48:05 +0900521 goto err_sg_free_table;
Inki Dae2a3098f2012-11-04 05:48:52 -0800522 }
523
524 g2d_userptr->dma_addr = sgt->sgl[0].dma_address;
525 g2d_userptr->userptr = userptr;
526
527 list_add_tail(&g2d_userptr->list, &g2d_priv->userptr_list);
528
529 if (g2d->current_pool + (npages << PAGE_SHIFT) < g2d->max_pool) {
530 g2d->current_pool += npages << PAGE_SHIFT;
531 g2d_userptr->in_pool = true;
532 }
533
534 *obj = (unsigned long)g2d_userptr;
535
536 return &g2d_userptr->dma_addr;
537
YoungJun Cho067ed332013-03-11 19:48:05 +0900538err_sg_free_table:
Inki Dae2a3098f2012-11-04 05:48:52 -0800539 sg_free_table(sgt);
YoungJun Cho067ed332013-03-11 19:48:05 +0900540
541err_free_sgt:
Inki Dae2a3098f2012-11-04 05:48:52 -0800542 kfree(sgt);
Inki Dae2a3098f2012-11-04 05:48:52 -0800543
544err_free_userptr:
545 exynos_gem_put_pages_to_userptr(g2d_userptr->pages,
546 g2d_userptr->npages,
547 g2d_userptr->vma);
548
549err_put_vma:
550 exynos_gem_put_vma(g2d_userptr->vma);
551
552err_free_pages:
YoungJun Choaf51a5e2013-07-03 17:09:19 +0900553 drm_free_large(pages);
Seung-Woo Kim4bb615c2013-07-03 17:09:21 +0900554
555err_free:
Inki Dae2a3098f2012-11-04 05:48:52 -0800556 kfree(g2d_userptr);
Inki Dae2a3098f2012-11-04 05:48:52 -0800557
558 return ERR_PTR(ret);
559}
560
561static void g2d_userptr_free_all(struct drm_device *drm_dev,
562 struct g2d_data *g2d,
563 struct drm_file *filp)
564{
565 struct drm_exynos_file_private *file_priv = filp->driver_priv;
566 struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
567 struct g2d_cmdlist_userptr *g2d_userptr, *n;
568
569 list_for_each_entry_safe(g2d_userptr, n, &g2d_priv->userptr_list, list)
570 if (g2d_userptr->in_pool)
571 g2d_userptr_put_dma_addr(drm_dev,
572 (unsigned long)g2d_userptr,
573 true);
574
575 g2d->current_pool = 0;
576}
577
YoungJun Cho9963cb62013-03-13 17:10:08 +0900578static enum g2d_reg_type g2d_get_reg_type(int reg_offset)
579{
580 enum g2d_reg_type reg_type;
581
582 switch (reg_offset) {
583 case G2D_SRC_BASE_ADDR:
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900584 case G2D_SRC_COLOR_MODE:
585 case G2D_SRC_LEFT_TOP:
586 case G2D_SRC_RIGHT_BOTTOM:
YoungJun Cho9963cb62013-03-13 17:10:08 +0900587 reg_type = REG_TYPE_SRC;
588 break;
589 case G2D_SRC_PLANE2_BASE_ADDR:
590 reg_type = REG_TYPE_SRC_PLANE2;
591 break;
592 case G2D_DST_BASE_ADDR:
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900593 case G2D_DST_COLOR_MODE:
594 case G2D_DST_LEFT_TOP:
595 case G2D_DST_RIGHT_BOTTOM:
YoungJun Cho9963cb62013-03-13 17:10:08 +0900596 reg_type = REG_TYPE_DST;
597 break;
598 case G2D_DST_PLANE2_BASE_ADDR:
599 reg_type = REG_TYPE_DST_PLANE2;
600 break;
601 case G2D_PAT_BASE_ADDR:
602 reg_type = REG_TYPE_PAT;
603 break;
604 case G2D_MSK_BASE_ADDR:
605 reg_type = REG_TYPE_MSK;
606 break;
607 default:
608 reg_type = REG_TYPE_NONE;
609 DRM_ERROR("Unknown register offset![%d]\n", reg_offset);
610 break;
611 };
612
613 return reg_type;
614}
615
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900616static unsigned long g2d_get_buf_bpp(unsigned int format)
617{
618 unsigned long bpp;
619
620 switch (format) {
621 case G2D_FMT_XRGB8888:
622 case G2D_FMT_ARGB8888:
623 bpp = 4;
624 break;
625 case G2D_FMT_RGB565:
626 case G2D_FMT_XRGB1555:
627 case G2D_FMT_ARGB1555:
628 case G2D_FMT_XRGB4444:
629 case G2D_FMT_ARGB4444:
630 bpp = 2;
631 break;
632 case G2D_FMT_PACKED_RGB888:
633 bpp = 3;
634 break;
635 default:
636 bpp = 1;
637 break;
638 }
639
640 return bpp;
641}
642
643static bool g2d_check_buf_desc_is_valid(struct g2d_buf_desc *buf_desc,
644 enum g2d_reg_type reg_type,
645 unsigned long size)
646{
647 unsigned int width, height;
648 unsigned long area;
649
650 /*
651 * check source and destination buffers only.
652 * so the others are always valid.
653 */
654 if (reg_type != REG_TYPE_SRC && reg_type != REG_TYPE_DST)
655 return true;
656
657 width = buf_desc->right_x - buf_desc->left_x;
658 if (width < G2D_LEN_MIN || width > G2D_LEN_MAX) {
659 DRM_ERROR("width[%u] is out of range!\n", width);
660 return false;
661 }
662
663 height = buf_desc->bottom_y - buf_desc->top_y;
664 if (height < G2D_LEN_MIN || height > G2D_LEN_MAX) {
665 DRM_ERROR("height[%u] is out of range!\n", height);
666 return false;
667 }
668
669 area = (unsigned long)width * (unsigned long)height *
670 g2d_get_buf_bpp(buf_desc->format);
671 if (area > size) {
672 DRM_ERROR("area[%lu] is out of range[%lu]!\n", area, size);
673 return false;
674 }
675
676 return true;
677}
678
Inki Daed87342c2012-11-03 21:53:24 -0700679static int g2d_map_cmdlist_gem(struct g2d_data *g2d,
680 struct g2d_cmdlist_node *node,
681 struct drm_device *drm_dev,
682 struct drm_file *file)
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900683{
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900684 struct g2d_cmdlist *cmdlist = node->cmdlist;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900685 struct g2d_buf_info *buf_info = &node->buf_info;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900686 int offset;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900687 int ret;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900688 int i;
689
YoungJun Cho9963cb62013-03-13 17:10:08 +0900690 for (i = 0; i < buf_info->map_nr; i++) {
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900691 struct g2d_buf_desc *buf_desc;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900692 enum g2d_reg_type reg_type;
693 int reg_pos;
Inki Daed87342c2012-11-03 21:53:24 -0700694 unsigned long handle;
695 dma_addr_t *addr;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900696
YoungJun Cho9963cb62013-03-13 17:10:08 +0900697 reg_pos = cmdlist->last - 2 * (i + 1);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900698
YoungJun Cho9963cb62013-03-13 17:10:08 +0900699 offset = cmdlist->data[reg_pos];
700 handle = cmdlist->data[reg_pos + 1];
701
702 reg_type = g2d_get_reg_type(offset);
703 if (reg_type == REG_TYPE_NONE) {
704 ret = -EFAULT;
705 goto err;
706 }
707
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900708 buf_desc = &buf_info->descs[reg_type];
709
YoungJun Cho9963cb62013-03-13 17:10:08 +0900710 if (buf_info->types[reg_type] == BUF_TYPE_GEM) {
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900711 unsigned long size;
712
713 size = exynos_drm_gem_get_size(drm_dev, handle, file);
714 if (!size) {
715 ret = -EFAULT;
716 goto err;
717 }
718
719 if (!g2d_check_buf_desc_is_valid(buf_desc, reg_type,
720 size)) {
721 ret = -EFAULT;
722 goto err;
723 }
724
Inki Dae2a3098f2012-11-04 05:48:52 -0800725 addr = exynos_drm_gem_get_dma_addr(drm_dev, handle,
726 file);
727 if (IS_ERR(addr)) {
YoungJun Cho9963cb62013-03-13 17:10:08 +0900728 ret = -EFAULT;
729 goto err;
Inki Dae2a3098f2012-11-04 05:48:52 -0800730 }
731 } else {
732 struct drm_exynos_g2d_userptr g2d_userptr;
733
734 if (copy_from_user(&g2d_userptr, (void __user *)handle,
735 sizeof(struct drm_exynos_g2d_userptr))) {
YoungJun Cho9963cb62013-03-13 17:10:08 +0900736 ret = -EFAULT;
737 goto err;
Inki Dae2a3098f2012-11-04 05:48:52 -0800738 }
739
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900740 if (!g2d_check_buf_desc_is_valid(buf_desc, reg_type,
741 g2d_userptr.size)) {
742 ret = -EFAULT;
743 goto err;
744 }
745
Inki Dae2a3098f2012-11-04 05:48:52 -0800746 addr = g2d_userptr_get_dma_addr(drm_dev,
747 g2d_userptr.userptr,
748 g2d_userptr.size,
749 file,
750 &handle);
751 if (IS_ERR(addr)) {
YoungJun Cho9963cb62013-03-13 17:10:08 +0900752 ret = -EFAULT;
753 goto err;
Inki Dae2a3098f2012-11-04 05:48:52 -0800754 }
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900755 }
756
YoungJun Cho9963cb62013-03-13 17:10:08 +0900757 cmdlist->data[reg_pos + 1] = *addr;
758 buf_info->reg_types[i] = reg_type;
759 buf_info->handles[reg_type] = handle;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900760 }
761
762 return 0;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900763
764err:
765 buf_info->map_nr = i;
766 return ret;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900767}
768
Inki Daed87342c2012-11-03 21:53:24 -0700769static void g2d_unmap_cmdlist_gem(struct g2d_data *g2d,
770 struct g2d_cmdlist_node *node,
771 struct drm_file *filp)
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900772{
Inki Daed87342c2012-11-03 21:53:24 -0700773 struct exynos_drm_subdrv *subdrv = &g2d->subdrv;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900774 struct g2d_buf_info *buf_info = &node->buf_info;
Inki Daed87342c2012-11-03 21:53:24 -0700775 int i;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900776
YoungJun Cho9963cb62013-03-13 17:10:08 +0900777 for (i = 0; i < buf_info->map_nr; i++) {
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900778 struct g2d_buf_desc *buf_desc;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900779 enum g2d_reg_type reg_type;
780 unsigned long handle;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900781
YoungJun Cho9963cb62013-03-13 17:10:08 +0900782 reg_type = buf_info->reg_types[i];
783
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900784 buf_desc = &buf_info->descs[reg_type];
YoungJun Cho9963cb62013-03-13 17:10:08 +0900785 handle = buf_info->handles[reg_type];
786
787 if (buf_info->types[reg_type] == BUF_TYPE_GEM)
Inki Dae2a3098f2012-11-04 05:48:52 -0800788 exynos_drm_gem_put_dma_addr(subdrv->drm_dev, handle,
789 filp);
790 else
791 g2d_userptr_put_dma_addr(subdrv->drm_dev, handle,
792 false);
Inki Daed87342c2012-11-03 21:53:24 -0700793
YoungJun Cho9963cb62013-03-13 17:10:08 +0900794 buf_info->reg_types[i] = REG_TYPE_NONE;
795 buf_info->handles[reg_type] = 0;
796 buf_info->types[reg_type] = 0;
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900797 memset(buf_desc, 0x00, sizeof(*buf_desc));
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900798 }
Inki Daed87342c2012-11-03 21:53:24 -0700799
YoungJun Cho9963cb62013-03-13 17:10:08 +0900800 buf_info->map_nr = 0;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900801}
802
803static void g2d_dma_start(struct g2d_data *g2d,
804 struct g2d_runqueue_node *runqueue_node)
805{
806 struct g2d_cmdlist_node *node =
807 list_first_entry(&runqueue_node->run_cmdlist,
808 struct g2d_cmdlist_node, list);
Inki Dae89f8b852013-07-24 13:40:12 +0900809 int ret;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900810
Inki Dae89f8b852013-07-24 13:40:12 +0900811 ret = pm_runtime_get_sync(g2d->dev);
Inki Daeb10d6352013-07-24 15:44:30 +0900812 if (ret < 0)
Inki Dae89f8b852013-07-24 13:40:12 +0900813 return;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900814
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900815 writel_relaxed(node->dma_addr, g2d->regs + G2D_DMA_SFR_BASE_ADDR);
816 writel_relaxed(G2D_DMA_START, g2d->regs + G2D_DMA_COMMAND);
817}
818
819static struct g2d_runqueue_node *g2d_get_runqueue_node(struct g2d_data *g2d)
820{
821 struct g2d_runqueue_node *runqueue_node;
822
823 if (list_empty(&g2d->runqueue))
824 return NULL;
825
826 runqueue_node = list_first_entry(&g2d->runqueue,
827 struct g2d_runqueue_node, list);
828 list_del_init(&runqueue_node->list);
829 return runqueue_node;
830}
831
832static void g2d_free_runqueue_node(struct g2d_data *g2d,
833 struct g2d_runqueue_node *runqueue_node)
834{
Inki Daed87342c2012-11-03 21:53:24 -0700835 struct g2d_cmdlist_node *node;
836
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900837 if (!runqueue_node)
838 return;
839
840 mutex_lock(&g2d->cmdlist_mutex);
Inki Daed87342c2012-11-03 21:53:24 -0700841 /*
842 * commands in run_cmdlist have been completed so unmap all gem
843 * objects in each command node so that they are unreferenced.
844 */
845 list_for_each_entry(node, &runqueue_node->run_cmdlist, list)
846 g2d_unmap_cmdlist_gem(g2d, node, runqueue_node->filp);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900847 list_splice_tail_init(&runqueue_node->run_cmdlist, &g2d->free_cmdlist);
848 mutex_unlock(&g2d->cmdlist_mutex);
849
850 kmem_cache_free(g2d->runqueue_slab, runqueue_node);
851}
852
853static void g2d_exec_runqueue(struct g2d_data *g2d)
854{
855 g2d->runqueue_node = g2d_get_runqueue_node(g2d);
856 if (g2d->runqueue_node)
857 g2d_dma_start(g2d, g2d->runqueue_node);
858}
859
860static void g2d_runqueue_worker(struct work_struct *work)
861{
862 struct g2d_data *g2d = container_of(work, struct g2d_data,
863 runqueue_work);
864
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900865 mutex_lock(&g2d->runqueue_mutex);
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900866 pm_runtime_put_sync(g2d->dev);
867
868 complete(&g2d->runqueue_node->complete);
869 if (g2d->runqueue_node->async)
870 g2d_free_runqueue_node(g2d, g2d->runqueue_node);
871
872 if (g2d->suspended)
873 g2d->runqueue_node = NULL;
874 else
875 g2d_exec_runqueue(g2d);
876 mutex_unlock(&g2d->runqueue_mutex);
877}
878
879static void g2d_finish_event(struct g2d_data *g2d, u32 cmdlist_no)
880{
881 struct drm_device *drm_dev = g2d->subdrv.drm_dev;
882 struct g2d_runqueue_node *runqueue_node = g2d->runqueue_node;
883 struct drm_exynos_pending_g2d_event *e;
884 struct timeval now;
885 unsigned long flags;
886
887 if (list_empty(&runqueue_node->event_list))
888 return;
889
890 e = list_first_entry(&runqueue_node->event_list,
891 struct drm_exynos_pending_g2d_event, base.link);
892
893 do_gettimeofday(&now);
894 e->event.tv_sec = now.tv_sec;
895 e->event.tv_usec = now.tv_usec;
896 e->event.cmdlist_no = cmdlist_no;
897
898 spin_lock_irqsave(&drm_dev->event_lock, flags);
899 list_move_tail(&e->base.link, &e->base.file_priv->event_list);
900 wake_up_interruptible(&e->base.file_priv->event_wait);
901 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
902}
903
904static irqreturn_t g2d_irq_handler(int irq, void *dev_id)
905{
906 struct g2d_data *g2d = dev_id;
907 u32 pending;
908
909 pending = readl_relaxed(g2d->regs + G2D_INTC_PEND);
910 if (pending)
911 writel_relaxed(pending, g2d->regs + G2D_INTC_PEND);
912
913 if (pending & G2D_INTP_GCMD_FIN) {
914 u32 cmdlist_no = readl_relaxed(g2d->regs + G2D_DMA_STATUS);
915
916 cmdlist_no = (cmdlist_no & G2D_DMA_LIST_DONE_COUNT) >>
917 G2D_DMA_LIST_DONE_COUNT_OFFSET;
918
919 g2d_finish_event(g2d, cmdlist_no);
920
921 writel_relaxed(0, g2d->regs + G2D_DMA_HOLD_CMD);
922 if (!(pending & G2D_INTP_ACMD_FIN)) {
923 writel_relaxed(G2D_DMA_CONTINUE,
924 g2d->regs + G2D_DMA_COMMAND);
925 }
926 }
927
928 if (pending & G2D_INTP_ACMD_FIN)
929 queue_work(g2d->g2d_workq, &g2d->runqueue_work);
930
931 return IRQ_HANDLED;
932}
933
Inki Dae2a3098f2012-11-04 05:48:52 -0800934static int g2d_check_reg_offset(struct device *dev,
935 struct g2d_cmdlist_node *node,
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900936 int nr, bool for_addr)
937{
Inki Dae2a3098f2012-11-04 05:48:52 -0800938 struct g2d_cmdlist *cmdlist = node->cmdlist;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900939 int reg_offset;
940 int index;
941 int i;
942
943 for (i = 0; i < nr; i++) {
YoungJun Cho9963cb62013-03-13 17:10:08 +0900944 struct g2d_buf_info *buf_info = &node->buf_info;
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900945 struct g2d_buf_desc *buf_desc;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900946 enum g2d_reg_type reg_type;
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900947 unsigned long value;
YoungJun Cho9963cb62013-03-13 17:10:08 +0900948
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900949 index = cmdlist->last - 2 * (i + 1);
Inki Dae2a3098f2012-11-04 05:48:52 -0800950
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900951 reg_offset = cmdlist->data[index] & ~0xfffff000;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900952 if (reg_offset < G2D_VALID_START || reg_offset > G2D_VALID_END)
953 goto err;
954 if (reg_offset % 4)
955 goto err;
956
957 switch (reg_offset) {
958 case G2D_SRC_BASE_ADDR:
959 case G2D_SRC_PLANE2_BASE_ADDR:
960 case G2D_DST_BASE_ADDR:
961 case G2D_DST_PLANE2_BASE_ADDR:
962 case G2D_PAT_BASE_ADDR:
963 case G2D_MSK_BASE_ADDR:
964 if (!for_addr)
965 goto err;
Inki Dae2a3098f2012-11-04 05:48:52 -0800966
YoungJun Cho9963cb62013-03-13 17:10:08 +0900967 reg_type = g2d_get_reg_type(reg_offset);
968 if (reg_type == REG_TYPE_NONE)
969 goto err;
970
971 /* check userptr buffer type. */
972 if ((cmdlist->data[index] & ~0x7fffffff) >> 31) {
973 buf_info->types[reg_type] = BUF_TYPE_USERPTR;
974 cmdlist->data[index] &= ~G2D_BUF_USERPTR;
975 } else
976 buf_info->types[reg_type] = BUF_TYPE_GEM;
Joonyoung Shimd7f16422012-05-17 20:06:32 +0900977 break;
YoungJun Cho2dec17c2013-03-11 21:17:52 +0900978 case G2D_SRC_COLOR_MODE:
979 case G2D_DST_COLOR_MODE:
980 if (for_addr)
981 goto err;
982
983 reg_type = g2d_get_reg_type(reg_offset);
984 if (reg_type == REG_TYPE_NONE)
985 goto err;
986
987 buf_desc = &buf_info->descs[reg_type];
988 value = cmdlist->data[index + 1];
989
990 buf_desc->format = value & 0xf;
991 break;
992 case G2D_SRC_LEFT_TOP:
993 case G2D_DST_LEFT_TOP:
994 if (for_addr)
995 goto err;
996
997 reg_type = g2d_get_reg_type(reg_offset);
998 if (reg_type == REG_TYPE_NONE)
999 goto err;
1000
1001 buf_desc = &buf_info->descs[reg_type];
1002 value = cmdlist->data[index + 1];
1003
1004 buf_desc->left_x = value & 0x1fff;
1005 buf_desc->top_y = (value & 0x1fff0000) >> 16;
1006 break;
1007 case G2D_SRC_RIGHT_BOTTOM:
1008 case G2D_DST_RIGHT_BOTTOM:
1009 if (for_addr)
1010 goto err;
1011
1012 reg_type = g2d_get_reg_type(reg_offset);
1013 if (reg_type == REG_TYPE_NONE)
1014 goto err;
1015
1016 buf_desc = &buf_info->descs[reg_type];
1017 value = cmdlist->data[index + 1];
1018
1019 buf_desc->right_x = value & 0x1fff;
1020 buf_desc->bottom_y = (value & 0x1fff0000) >> 16;
1021 break;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001022 default:
1023 if (for_addr)
1024 goto err;
1025 break;
1026 }
1027 }
1028
1029 return 0;
1030
1031err:
Inki Dae2a3098f2012-11-04 05:48:52 -08001032 dev_err(dev, "Bad register offset: 0x%lx\n", cmdlist->data[index]);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001033 return -EINVAL;
1034}
1035
1036/* ioctl functions */
1037int exynos_g2d_get_ver_ioctl(struct drm_device *drm_dev, void *data,
1038 struct drm_file *file)
1039{
1040 struct drm_exynos_g2d_get_ver *ver = data;
1041
1042 ver->major = G2D_HW_MAJOR_VER;
1043 ver->minor = G2D_HW_MINOR_VER;
1044
1045 return 0;
1046}
1047EXPORT_SYMBOL_GPL(exynos_g2d_get_ver_ioctl);
1048
1049int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
1050 struct drm_file *file)
1051{
1052 struct drm_exynos_file_private *file_priv = file->driver_priv;
1053 struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
1054 struct device *dev = g2d_priv->dev;
1055 struct g2d_data *g2d;
1056 struct drm_exynos_g2d_set_cmdlist *req = data;
1057 struct drm_exynos_g2d_cmd *cmd;
1058 struct drm_exynos_pending_g2d_event *e;
1059 struct g2d_cmdlist_node *node;
1060 struct g2d_cmdlist *cmdlist;
1061 unsigned long flags;
1062 int size;
1063 int ret;
1064
1065 if (!dev)
1066 return -ENODEV;
1067
1068 g2d = dev_get_drvdata(dev);
1069 if (!g2d)
1070 return -EFAULT;
1071
1072 node = g2d_get_cmdlist(g2d);
1073 if (!node)
1074 return -ENOMEM;
1075
1076 node->event = NULL;
1077
1078 if (req->event_type != G2D_EVENT_NOT) {
1079 spin_lock_irqsave(&drm_dev->event_lock, flags);
1080 if (file->event_space < sizeof(e->event)) {
1081 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
1082 ret = -ENOMEM;
1083 goto err;
1084 }
1085 file->event_space -= sizeof(e->event);
1086 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
1087
1088 e = kzalloc(sizeof(*node->event), GFP_KERNEL);
1089 if (!e) {
1090 dev_err(dev, "failed to allocate event\n");
1091
1092 spin_lock_irqsave(&drm_dev->event_lock, flags);
1093 file->event_space += sizeof(e->event);
1094 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
1095
1096 ret = -ENOMEM;
1097 goto err;
1098 }
1099
1100 e->event.base.type = DRM_EXYNOS_G2D_EVENT;
1101 e->event.base.length = sizeof(e->event);
1102 e->event.user_data = req->user_data;
1103 e->base.event = &e->event.base;
1104 e->base.file_priv = file;
1105 e->base.destroy = (void (*) (struct drm_pending_event *)) kfree;
1106
1107 node->event = e;
1108 }
1109
1110 cmdlist = node->cmdlist;
1111
1112 cmdlist->last = 0;
1113
1114 /*
1115 * If don't clear SFR registers, the cmdlist is affected by register
1116 * values of previous cmdlist. G2D hw executes SFR clear command and
1117 * a next command at the same time then the next command is ignored and
1118 * is executed rightly from next next command, so needs a dummy command
1119 * to next command of SFR clear command.
1120 */
1121 cmdlist->data[cmdlist->last++] = G2D_SOFT_RESET;
1122 cmdlist->data[cmdlist->last++] = G2D_SFRCLEAR;
1123 cmdlist->data[cmdlist->last++] = G2D_SRC_BASE_ADDR;
1124 cmdlist->data[cmdlist->last++] = 0;
1125
YoungJun Cho7ad01812013-03-13 16:44:37 +09001126 /*
1127 * 'LIST_HOLD' command should be set to the DMA_HOLD_CMD_REG
1128 * and GCF bit should be set to INTEN register if user wants
1129 * G2D interrupt event once current command list execution is
1130 * finished.
1131 * Otherwise only ACF bit should be set to INTEN register so
1132 * that one interrupt is occured after all command lists
1133 * have been completed.
1134 */
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001135 if (node->event) {
YoungJun Cho7ad01812013-03-13 16:44:37 +09001136 cmdlist->data[cmdlist->last++] = G2D_INTEN;
1137 cmdlist->data[cmdlist->last++] = G2D_INTEN_ACF | G2D_INTEN_GCF;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001138 cmdlist->data[cmdlist->last++] = G2D_DMA_HOLD_CMD;
1139 cmdlist->data[cmdlist->last++] = G2D_LIST_HOLD;
YoungJun Cho7ad01812013-03-13 16:44:37 +09001140 } else {
1141 cmdlist->data[cmdlist->last++] = G2D_INTEN;
1142 cmdlist->data[cmdlist->last++] = G2D_INTEN_ACF;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001143 }
1144
1145 /* Check size of cmdlist: last 2 is about G2D_BITBLT_START */
Inki Dae2a3098f2012-11-04 05:48:52 -08001146 size = cmdlist->last + req->cmd_nr * 2 + req->cmd_buf_nr * 2 + 2;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001147 if (size > G2D_CMDLIST_DATA_NUM) {
1148 dev_err(dev, "cmdlist size is too big\n");
1149 ret = -EINVAL;
1150 goto err_free_event;
1151 }
1152
1153 cmd = (struct drm_exynos_g2d_cmd *)(uint32_t)req->cmd;
1154
1155 if (copy_from_user(cmdlist->data + cmdlist->last,
1156 (void __user *)cmd,
1157 sizeof(*cmd) * req->cmd_nr)) {
1158 ret = -EFAULT;
1159 goto err_free_event;
1160 }
1161 cmdlist->last += req->cmd_nr * 2;
1162
Inki Dae2a3098f2012-11-04 05:48:52 -08001163 ret = g2d_check_reg_offset(dev, node, req->cmd_nr, false);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001164 if (ret < 0)
1165 goto err_free_event;
1166
YoungJun Cho9963cb62013-03-13 17:10:08 +09001167 node->buf_info.map_nr = req->cmd_buf_nr;
Inki Dae2a3098f2012-11-04 05:48:52 -08001168 if (req->cmd_buf_nr) {
1169 struct drm_exynos_g2d_cmd *cmd_buf;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001170
Inki Dae2a3098f2012-11-04 05:48:52 -08001171 cmd_buf = (struct drm_exynos_g2d_cmd *)(uint32_t)req->cmd_buf;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001172
1173 if (copy_from_user(cmdlist->data + cmdlist->last,
Inki Dae2a3098f2012-11-04 05:48:52 -08001174 (void __user *)cmd_buf,
1175 sizeof(*cmd_buf) * req->cmd_buf_nr)) {
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001176 ret = -EFAULT;
1177 goto err_free_event;
1178 }
Inki Dae2a3098f2012-11-04 05:48:52 -08001179 cmdlist->last += req->cmd_buf_nr * 2;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001180
Inki Dae2a3098f2012-11-04 05:48:52 -08001181 ret = g2d_check_reg_offset(dev, node, req->cmd_buf_nr, true);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001182 if (ret < 0)
1183 goto err_free_event;
1184
Inki Daed87342c2012-11-03 21:53:24 -07001185 ret = g2d_map_cmdlist_gem(g2d, node, drm_dev, file);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001186 if (ret < 0)
1187 goto err_unmap;
1188 }
1189
1190 cmdlist->data[cmdlist->last++] = G2D_BITBLT_START;
1191 cmdlist->data[cmdlist->last++] = G2D_START_BITBLT;
1192
1193 /* head */
1194 cmdlist->head = cmdlist->last / 2;
1195
1196 /* tail */
1197 cmdlist->data[cmdlist->last] = 0;
1198
1199 g2d_add_cmdlist_to_inuse(g2d_priv, node);
1200
1201 return 0;
1202
1203err_unmap:
Inki Daed87342c2012-11-03 21:53:24 -07001204 g2d_unmap_cmdlist_gem(g2d, node, file);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001205err_free_event:
1206 if (node->event) {
1207 spin_lock_irqsave(&drm_dev->event_lock, flags);
1208 file->event_space += sizeof(e->event);
1209 spin_unlock_irqrestore(&drm_dev->event_lock, flags);
1210 kfree(node->event);
1211 }
1212err:
1213 g2d_put_cmdlist(g2d, node);
1214 return ret;
1215}
1216EXPORT_SYMBOL_GPL(exynos_g2d_set_cmdlist_ioctl);
1217
1218int exynos_g2d_exec_ioctl(struct drm_device *drm_dev, void *data,
1219 struct drm_file *file)
1220{
1221 struct drm_exynos_file_private *file_priv = file->driver_priv;
1222 struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
1223 struct device *dev = g2d_priv->dev;
1224 struct g2d_data *g2d;
1225 struct drm_exynos_g2d_exec *req = data;
1226 struct g2d_runqueue_node *runqueue_node;
1227 struct list_head *run_cmdlist;
1228 struct list_head *event_list;
1229
1230 if (!dev)
1231 return -ENODEV;
1232
1233 g2d = dev_get_drvdata(dev);
1234 if (!g2d)
1235 return -EFAULT;
1236
1237 runqueue_node = kmem_cache_alloc(g2d->runqueue_slab, GFP_KERNEL);
1238 if (!runqueue_node) {
1239 dev_err(dev, "failed to allocate memory\n");
1240 return -ENOMEM;
1241 }
1242 run_cmdlist = &runqueue_node->run_cmdlist;
1243 event_list = &runqueue_node->event_list;
1244 INIT_LIST_HEAD(run_cmdlist);
1245 INIT_LIST_HEAD(event_list);
1246 init_completion(&runqueue_node->complete);
1247 runqueue_node->async = req->async;
1248
1249 list_splice_init(&g2d_priv->inuse_cmdlist, run_cmdlist);
1250 list_splice_init(&g2d_priv->event_list, event_list);
1251
1252 if (list_empty(run_cmdlist)) {
1253 dev_err(dev, "there is no inuse cmdlist\n");
1254 kmem_cache_free(g2d->runqueue_slab, runqueue_node);
1255 return -EPERM;
1256 }
1257
1258 mutex_lock(&g2d->runqueue_mutex);
Inki Dae6b6bae22012-09-11 10:45:36 +09001259 runqueue_node->pid = current->pid;
Inki Daed87342c2012-11-03 21:53:24 -07001260 runqueue_node->filp = file;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001261 list_add_tail(&runqueue_node->list, &g2d->runqueue);
1262 if (!g2d->runqueue_node)
1263 g2d_exec_runqueue(g2d);
1264 mutex_unlock(&g2d->runqueue_mutex);
1265
1266 if (runqueue_node->async)
1267 goto out;
1268
1269 wait_for_completion(&runqueue_node->complete);
1270 g2d_free_runqueue_node(g2d, runqueue_node);
1271
1272out:
1273 return 0;
1274}
1275EXPORT_SYMBOL_GPL(exynos_g2d_exec_ioctl);
1276
Inki Daed87342c2012-11-03 21:53:24 -07001277static int g2d_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
1278{
1279 struct g2d_data *g2d;
1280 int ret;
1281
1282 g2d = dev_get_drvdata(dev);
1283 if (!g2d)
1284 return -EFAULT;
1285
1286 /* allocate dma-aware cmdlist buffer. */
1287 ret = g2d_init_cmdlist(g2d);
1288 if (ret < 0) {
1289 dev_err(dev, "cmdlist init failed\n");
1290 return ret;
1291 }
1292
1293 if (!is_drm_iommu_supported(drm_dev))
1294 return 0;
1295
1296 ret = drm_iommu_attach_device(drm_dev, dev);
1297 if (ret < 0) {
1298 dev_err(dev, "failed to enable iommu.\n");
1299 g2d_fini_cmdlist(g2d);
1300 }
1301
1302 return ret;
1303
1304}
1305
1306static void g2d_subdrv_remove(struct drm_device *drm_dev, struct device *dev)
1307{
1308 if (!is_drm_iommu_supported(drm_dev))
1309 return;
1310
1311 drm_iommu_detach_device(drm_dev, dev);
1312}
1313
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001314static int g2d_open(struct drm_device *drm_dev, struct device *dev,
1315 struct drm_file *file)
1316{
1317 struct drm_exynos_file_private *file_priv = file->driver_priv;
1318 struct exynos_drm_g2d_private *g2d_priv;
1319
1320 g2d_priv = kzalloc(sizeof(*g2d_priv), GFP_KERNEL);
1321 if (!g2d_priv) {
1322 dev_err(dev, "failed to allocate g2d private data\n");
1323 return -ENOMEM;
1324 }
1325
1326 g2d_priv->dev = dev;
1327 file_priv->g2d_priv = g2d_priv;
1328
1329 INIT_LIST_HEAD(&g2d_priv->inuse_cmdlist);
1330 INIT_LIST_HEAD(&g2d_priv->event_list);
Inki Dae2a3098f2012-11-04 05:48:52 -08001331 INIT_LIST_HEAD(&g2d_priv->userptr_list);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001332
1333 return 0;
1334}
1335
1336static void g2d_close(struct drm_device *drm_dev, struct device *dev,
1337 struct drm_file *file)
1338{
1339 struct drm_exynos_file_private *file_priv = file->driver_priv;
1340 struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
1341 struct g2d_data *g2d;
1342 struct g2d_cmdlist_node *node, *n;
1343
1344 if (!dev)
1345 return;
1346
1347 g2d = dev_get_drvdata(dev);
1348 if (!g2d)
1349 return;
1350
1351 mutex_lock(&g2d->cmdlist_mutex);
Inki Daed87342c2012-11-03 21:53:24 -07001352 list_for_each_entry_safe(node, n, &g2d_priv->inuse_cmdlist, list) {
1353 /*
1354 * unmap all gem objects not completed.
1355 *
1356 * P.S. if current process was terminated forcely then
1357 * there may be some commands in inuse_cmdlist so unmap
1358 * them.
1359 */
1360 g2d_unmap_cmdlist_gem(g2d, node, file);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001361 list_move_tail(&node->list, &g2d->free_cmdlist);
Inki Daed87342c2012-11-03 21:53:24 -07001362 }
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001363 mutex_unlock(&g2d->cmdlist_mutex);
1364
Inki Dae2a3098f2012-11-04 05:48:52 -08001365 /* release all g2d_userptr in pool. */
1366 g2d_userptr_free_all(drm_dev, g2d, file);
1367
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001368 kfree(file_priv->g2d_priv);
1369}
1370
Greg Kroah-Hartman56550d92012-12-21 15:09:25 -08001371static int g2d_probe(struct platform_device *pdev)
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001372{
1373 struct device *dev = &pdev->dev;
1374 struct resource *res;
1375 struct g2d_data *g2d;
1376 struct exynos_drm_subdrv *subdrv;
1377 int ret;
1378
Seung-Woo Kimd873ab92013-05-22 21:14:14 +09001379 g2d = devm_kzalloc(dev, sizeof(*g2d), GFP_KERNEL);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001380 if (!g2d) {
1381 dev_err(dev, "failed to allocate driver data\n");
1382 return -ENOMEM;
1383 }
1384
1385 g2d->runqueue_slab = kmem_cache_create("g2d_runqueue_slab",
1386 sizeof(struct g2d_runqueue_node), 0, 0, NULL);
Sachin Kamatb7675932012-08-06 12:16:20 +05301387 if (!g2d->runqueue_slab)
1388 return -ENOMEM;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001389
1390 g2d->dev = dev;
1391
1392 g2d->g2d_workq = create_singlethread_workqueue("g2d");
1393 if (!g2d->g2d_workq) {
1394 dev_err(dev, "failed to create workqueue\n");
1395 ret = -EINVAL;
1396 goto err_destroy_slab;
1397 }
1398
1399 INIT_WORK(&g2d->runqueue_work, g2d_runqueue_worker);
1400 INIT_LIST_HEAD(&g2d->free_cmdlist);
1401 INIT_LIST_HEAD(&g2d->runqueue);
1402
1403 mutex_init(&g2d->cmdlist_mutex);
1404 mutex_init(&g2d->runqueue_mutex);
1405
Sachin Kamatdc625532012-11-23 09:11:58 +05301406 g2d->gate_clk = devm_clk_get(dev, "fimg2d");
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001407 if (IS_ERR(g2d->gate_clk)) {
1408 dev_err(dev, "failed to get gate clock\n");
1409 ret = PTR_ERR(g2d->gate_clk);
Inki Daed87342c2012-11-03 21:53:24 -07001410 goto err_destroy_workqueue;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001411 }
1412
1413 pm_runtime_enable(dev);
1414
1415 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001416
Seung-Woo Kimd873ab92013-05-22 21:14:14 +09001417 g2d->regs = devm_ioremap_resource(dev, res);
Thierry Redingd4ed6022013-01-21 11:09:02 +01001418 if (IS_ERR(g2d->regs)) {
1419 ret = PTR_ERR(g2d->regs);
Sachin Kamatb7675932012-08-06 12:16:20 +05301420 goto err_put_clk;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001421 }
1422
1423 g2d->irq = platform_get_irq(pdev, 0);
1424 if (g2d->irq < 0) {
1425 dev_err(dev, "failed to get irq\n");
1426 ret = g2d->irq;
Sachin Kamatb7675932012-08-06 12:16:20 +05301427 goto err_put_clk;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001428 }
1429
Seung-Woo Kimd873ab92013-05-22 21:14:14 +09001430 ret = devm_request_irq(dev, g2d->irq, g2d_irq_handler, 0,
Sachin Kamatb7675932012-08-06 12:16:20 +05301431 "drm_g2d", g2d);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001432 if (ret < 0) {
1433 dev_err(dev, "irq request failed\n");
Sachin Kamatb7675932012-08-06 12:16:20 +05301434 goto err_put_clk;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001435 }
1436
Inki Dae2a3098f2012-11-04 05:48:52 -08001437 g2d->max_pool = MAX_POOL;
1438
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001439 platform_set_drvdata(pdev, g2d);
1440
1441 subdrv = &g2d->subdrv;
1442 subdrv->dev = dev;
Inki Daed87342c2012-11-03 21:53:24 -07001443 subdrv->probe = g2d_subdrv_probe;
1444 subdrv->remove = g2d_subdrv_remove;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001445 subdrv->open = g2d_open;
1446 subdrv->close = g2d_close;
1447
1448 ret = exynos_drm_subdrv_register(subdrv);
1449 if (ret < 0) {
1450 dev_err(dev, "failed to register drm g2d device\n");
Sachin Kamatb7675932012-08-06 12:16:20 +05301451 goto err_put_clk;
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001452 }
1453
1454 dev_info(dev, "The exynos g2d(ver %d.%d) successfully probed\n",
1455 G2D_HW_MAJOR_VER, G2D_HW_MINOR_VER);
1456
1457 return 0;
1458
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001459err_put_clk:
1460 pm_runtime_disable(dev);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001461err_destroy_workqueue:
1462 destroy_workqueue(g2d->g2d_workq);
1463err_destroy_slab:
1464 kmem_cache_destroy(g2d->runqueue_slab);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001465 return ret;
1466}
1467
Greg Kroah-Hartman56550d92012-12-21 15:09:25 -08001468static int g2d_remove(struct platform_device *pdev)
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001469{
1470 struct g2d_data *g2d = platform_get_drvdata(pdev);
1471
1472 cancel_work_sync(&g2d->runqueue_work);
1473 exynos_drm_subdrv_unregister(&g2d->subdrv);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001474
1475 while (g2d->runqueue_node) {
1476 g2d_free_runqueue_node(g2d, g2d->runqueue_node);
1477 g2d->runqueue_node = g2d_get_runqueue_node(g2d);
1478 }
1479
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001480 pm_runtime_disable(&pdev->dev);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001481
1482 g2d_fini_cmdlist(g2d);
1483 destroy_workqueue(g2d->g2d_workq);
1484 kmem_cache_destroy(g2d->runqueue_slab);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001485
1486 return 0;
1487}
1488
1489#ifdef CONFIG_PM_SLEEP
1490static int g2d_suspend(struct device *dev)
1491{
1492 struct g2d_data *g2d = dev_get_drvdata(dev);
1493
1494 mutex_lock(&g2d->runqueue_mutex);
1495 g2d->suspended = true;
1496 mutex_unlock(&g2d->runqueue_mutex);
1497
1498 while (g2d->runqueue_node)
1499 /* FIXME: good range? */
1500 usleep_range(500, 1000);
1501
Tejun Heo43829732012-08-20 14:51:24 -07001502 flush_work(&g2d->runqueue_work);
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001503
1504 return 0;
1505}
1506
1507static int g2d_resume(struct device *dev)
1508{
1509 struct g2d_data *g2d = dev_get_drvdata(dev);
1510
1511 g2d->suspended = false;
1512 g2d_exec_runqueue(g2d);
1513
1514 return 0;
1515}
1516#endif
1517
Inki Daeb10d6352013-07-24 15:44:30 +09001518#ifdef CONFIG_PM_RUNTIME
1519static int g2d_runtime_suspend(struct device *dev)
1520{
1521 struct g2d_data *g2d = dev_get_drvdata(dev);
1522
1523 clk_disable_unprepare(g2d->gate_clk);
1524
1525 return 0;
1526}
1527
1528static int g2d_runtime_resume(struct device *dev)
1529{
1530 struct g2d_data *g2d = dev_get_drvdata(dev);
1531 int ret;
1532
1533 ret = clk_prepare_enable(g2d->gate_clk);
1534 if (ret < 0)
1535 dev_warn(dev, "failed to enable clock.\n");
1536
1537 return ret;
1538}
1539#endif
1540
1541static const struct dev_pm_ops g2d_pm_ops = {
1542 SET_SYSTEM_SLEEP_PM_OPS(g2d_suspend, g2d_resume)
1543 SET_RUNTIME_PM_OPS(g2d_runtime_suspend, g2d_runtime_resume, NULL)
1544};
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001545
Ajay Kumar95fc6332013-02-06 10:59:44 +05301546#ifdef CONFIG_OF
1547static const struct of_device_id exynos_g2d_match[] = {
1548 { .compatible = "samsung,exynos5250-g2d" },
1549 {},
1550};
Ajay Kumar95fc6332013-02-06 10:59:44 +05301551#endif
1552
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001553struct platform_driver g2d_driver = {
1554 .probe = g2d_probe,
Greg Kroah-Hartman56550d92012-12-21 15:09:25 -08001555 .remove = g2d_remove,
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001556 .driver = {
1557 .name = "s5p-g2d",
1558 .owner = THIS_MODULE,
1559 .pm = &g2d_pm_ops,
Ajay Kumar95fc6332013-02-06 10:59:44 +05301560 .of_match_table = of_match_ptr(exynos_g2d_match),
Joonyoung Shimd7f16422012-05-17 20:06:32 +09001561 },
1562};