]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/gpu/drm/exynos/exynos_drm_drv.c
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / exynos / exynos_drm_drv.c
CommitLineData
1c248b7d
ID
1/*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
3 * Authors:
4 * Inki Dae <inki.dae@samsung.com>
5 * Joonyoung Shim <jy0922.shim@samsung.com>
6 * Seung-Woo Kim <sw0312.kim@samsung.com>
7 *
d81aecb5
ID
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
1c248b7d
ID
12 */
13
af65c804 14#include <linux/pm_runtime.h>
760285e7 15#include <drm/drmP.h>
a379df19
GP
16#include <drm/drm_atomic.h>
17#include <drm/drm_atomic_helper.h>
760285e7 18#include <drm/drm_crtc_helper.h>
1c248b7d 19
f37cd5e8 20#include <linux/component.h>
96f54215 21
1c248b7d
ID
22#include <drm/exynos_drm.h>
23
24#include "exynos_drm_drv.h"
1c248b7d
ID
25#include "exynos_drm_fbdev.h"
26#include "exynos_drm_fb.h"
27#include "exynos_drm_gem.h"
864ee9e6 28#include "exynos_drm_plane.h"
b73d1230 29#include "exynos_drm_vidi.h"
d7f1642c 30#include "exynos_drm_g2d.h"
cb471f14 31#include "exynos_drm_ipp.h"
0519f9a1 32#include "exynos_drm_iommu.h"
1c248b7d 33
0edf9936 34#define DRIVER_NAME "exynos"
1c248b7d
ID
35#define DRIVER_DESC "Samsung SoC DRM"
36#define DRIVER_DATE "20110530"
37#define DRIVER_MAJOR 1
38#define DRIVER_MINOR 0
39
38d868e4
VS
40int exynos_atomic_check(struct drm_device *dev,
41 struct drm_atomic_state *state)
42{
43 int ret;
44
45 ret = drm_atomic_helper_check_modeset(dev, state);
46 if (ret)
47 return ret;
48
49 ret = drm_atomic_normalize_zpos(dev, state);
50 if (ret)
51 return ret;
52
53 ret = drm_atomic_helper_check_planes(dev, state);
54 if (ret)
55 return ret;
56
57 return ret;
58}
59
9084f7b8
JS
60static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
61{
d7f1642c 62 struct drm_exynos_file_private *file_priv;
ba3706c0 63 int ret;
d7f1642c 64
d7f1642c
JS
65 file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
66 if (!file_priv)
67 return -ENOMEM;
68
d7f1642c 69 file->driver_priv = file_priv;
b2df26c1 70
ba3706c0 71 ret = exynos_drm_subdrv_open(dev, file);
6ca605f7 72 if (ret)
307ceaff 73 goto err_file_priv_free;
ba3706c0 74
6ca605f7 75 return ret;
307ceaff 76
307ceaff 77err_file_priv_free:
6ca605f7
SK
78 kfree(file_priv);
79 file->driver_priv = NULL;
ba3706c0 80 return ret;
9084f7b8
JS
81}
82
0cbc330e 83static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
ccf4d883 84{
b13b4d1b 85 exynos_drm_subdrv_close(dev, file);
53ef299f
ID
86 kfree(file->driver_priv);
87 file->driver_priv = NULL;
88}
89
1c248b7d
ID
90static void exynos_drm_lastclose(struct drm_device *dev)
91{
1c248b7d
ID
92 exynos_drm_fbdev_restore_mode(dev);
93}
94
78b68556 95static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
1c248b7d
ID
96 .fault = exynos_drm_gem_fault,
97 .open = drm_gem_vm_open,
98 .close = drm_gem_vm_close,
99};
100
baa70943 101static const struct drm_ioctl_desc exynos_ioctls[] = {
1c248b7d 102 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
f8c47144 103 DRM_AUTH | DRM_RENDER_ALLOW),
6564c65f
JS
104 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
105 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 106 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
f8c47144 107 DRM_RENDER_ALLOW),
74f230d2 108 DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
f8c47144 109 DRM_AUTH),
74f230d2 110 DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER, exynos_g2d_get_ver_ioctl,
f8c47144 111 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 112 DRM_IOCTL_DEF_DRV(EXYNOS_G2D_SET_CMDLIST, exynos_g2d_set_cmdlist_ioctl,
f8c47144 113 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 114 DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC, exynos_g2d_exec_ioctl,
f8c47144 115 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 116 DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY, exynos_drm_ipp_get_property,
f8c47144 117 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 118 DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY, exynos_drm_ipp_set_property,
f8c47144 119 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 120 DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF, exynos_drm_ipp_queue_buf,
f8c47144 121 DRM_AUTH | DRM_RENDER_ALLOW),
74f230d2 122 DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL, exynos_drm_ipp_cmd_ctrl,
f8c47144 123 DRM_AUTH | DRM_RENDER_ALLOW),
1c248b7d
ID
124};
125
ac2bdf73
JS
126static const struct file_operations exynos_drm_driver_fops = {
127 .owner = THIS_MODULE,
128 .open = drm_open,
129 .mmap = exynos_drm_gem_mmap,
130 .poll = drm_poll,
131 .read = drm_read,
132 .unlocked_ioctl = drm_ioctl,
804d74ab 133 .compat_ioctl = drm_compat_ioctl,
ac2bdf73
JS
134 .release = drm_release,
135};
136
1c248b7d 137static struct drm_driver exynos_drm_driver = {
c8c38ccf 138 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME
74f230d2 139 | DRIVER_ATOMIC | DRIVER_RENDER,
9084f7b8 140 .open = exynos_drm_open,
1c248b7d 141 .lastclose = exynos_drm_lastclose,
53ef299f 142 .postclose = exynos_drm_postclose,
201f9b97 143 .gem_free_object_unlocked = exynos_drm_gem_free_object,
1c248b7d
ID
144 .gem_vm_ops = &exynos_drm_gem_vm_ops,
145 .dumb_create = exynos_drm_gem_dumb_create,
b2df26c1
ID
146 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
147 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
01ed50dd 148 .gem_prime_export = drm_gem_prime_export,
89452d4a 149 .gem_prime_import = exynos_drm_gem_prime_import,
01ed50dd
JS
150 .gem_prime_get_sg_table = exynos_drm_gem_prime_get_sg_table,
151 .gem_prime_import_sg_table = exynos_drm_gem_prime_import_sg_table,
152 .gem_prime_vmap = exynos_drm_gem_prime_vmap,
153 .gem_prime_vunmap = exynos_drm_gem_prime_vunmap,
5a0202f7 154 .gem_prime_mmap = exynos_drm_gem_prime_mmap,
1c248b7d 155 .ioctls = exynos_ioctls,
baa70943 156 .num_ioctls = ARRAY_SIZE(exynos_ioctls),
ac2bdf73 157 .fops = &exynos_drm_driver_fops,
1c248b7d
ID
158 .name = DRIVER_NAME,
159 .desc = DRIVER_DESC,
160 .date = DRIVER_DATE,
161 .major = DRIVER_MAJOR,
162 .minor = DRIVER_MINOR,
163};
164
af65c804 165#ifdef CONFIG_PM_SLEEP
082ca313 166static int exynos_drm_suspend(struct device *dev)
af65c804
SP
167{
168 struct drm_device *drm_dev = dev_get_drvdata(dev);
0a51897b 169 struct exynos_drm_private *private;
af65c804 170
d50a1907 171 if (pm_runtime_suspended(dev) || !drm_dev)
af65c804
SP
172 return 0;
173
0a51897b
MS
174 private = drm_dev->dev_private;
175
6e8edf8a
MS
176 drm_kms_helper_poll_disable(drm_dev);
177 exynos_drm_fbdev_suspend(drm_dev);
178 private->suspend_state = drm_atomic_helper_suspend(drm_dev);
179 if (IS_ERR(private->suspend_state)) {
180 exynos_drm_fbdev_resume(drm_dev);
181 drm_kms_helper_poll_enable(drm_dev);
182 return PTR_ERR(private->suspend_state);
082ca313 183 }
082ca313
AH
184
185 return 0;
af65c804
SP
186}
187
082ca313 188static int exynos_drm_resume(struct device *dev)
af65c804
SP
189{
190 struct drm_device *drm_dev = dev_get_drvdata(dev);
0a51897b 191 struct exynos_drm_private *private;
af65c804 192
d50a1907 193 if (pm_runtime_suspended(dev) || !drm_dev)
af65c804
SP
194 return 0;
195
0a51897b 196 private = drm_dev->dev_private;
6e8edf8a
MS
197 drm_atomic_helper_resume(drm_dev, private->suspend_state);
198 exynos_drm_fbdev_resume(drm_dev);
199 drm_kms_helper_poll_enable(drm_dev);
082ca313
AH
200
201 return 0;
af65c804
SP
202}
203#endif
204
af65c804 205static const struct dev_pm_ops exynos_drm_pm_ops = {
082ca313 206 SET_SYSTEM_SLEEP_PM_OPS(exynos_drm_suspend, exynos_drm_resume)
af65c804
SP
207};
208
86650408
AH
209/* forward declaration */
210static struct platform_driver exynos_drm_platform_driver;
f37cd5e8 211
a5fb26cd
MS
212struct exynos_drm_driver_info {
213 struct platform_driver *driver;
214 unsigned int flags;
215};
216
217#define DRM_COMPONENT_DRIVER BIT(0) /* supports component framework */
218#define DRM_VIRTUAL_DEVICE BIT(1) /* create virtual platform device */
f43c3596 219#define DRM_DMA_DEVICE BIT(2) /* can be used for dma allocations */
a5fb26cd
MS
220
221#define DRV_PTR(drv, cond) (IS_ENABLED(cond) ? &drv : NULL)
222
86650408
AH
223/*
224 * Connector drivers should not be placed before associated crtc drivers,
225 * because connector requires pipe number of its crtc during initialization.
226 */
a5fb26cd
MS
227static struct exynos_drm_driver_info exynos_drm_drivers[] = {
228 {
229 DRV_PTR(fimd_driver, CONFIG_DRM_EXYNOS_FIMD),
f43c3596 230 DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
a5fb26cd
MS
231 }, {
232 DRV_PTR(exynos5433_decon_driver, CONFIG_DRM_EXYNOS5433_DECON),
f43c3596 233 DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
a5fb26cd
MS
234 }, {
235 DRV_PTR(decon_driver, CONFIG_DRM_EXYNOS7_DECON),
f43c3596 236 DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
a5fb26cd
MS
237 }, {
238 DRV_PTR(mixer_driver, CONFIG_DRM_EXYNOS_MIXER),
f43c3596 239 DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
a5fb26cd
MS
240 }, {
241 DRV_PTR(mic_driver, CONFIG_DRM_EXYNOS_MIC),
242 DRM_COMPONENT_DRIVER
243 }, {
244 DRV_PTR(dp_driver, CONFIG_DRM_EXYNOS_DP),
245 DRM_COMPONENT_DRIVER
246 }, {
247 DRV_PTR(dsi_driver, CONFIG_DRM_EXYNOS_DSI),
248 DRM_COMPONENT_DRIVER
249 }, {
250 DRV_PTR(hdmi_driver, CONFIG_DRM_EXYNOS_HDMI),
251 DRM_COMPONENT_DRIVER
252 }, {
253 DRV_PTR(vidi_driver, CONFIG_DRM_EXYNOS_VIDI),
254 DRM_COMPONENT_DRIVER | DRM_VIRTUAL_DEVICE
255 }, {
256 DRV_PTR(g2d_driver, CONFIG_DRM_EXYNOS_G2D),
257 }, {
258 DRV_PTR(fimc_driver, CONFIG_DRM_EXYNOS_FIMC),
259 }, {
260 DRV_PTR(rotator_driver, CONFIG_DRM_EXYNOS_ROTATOR),
261 }, {
262 DRV_PTR(gsc_driver, CONFIG_DRM_EXYNOS_GSC),
263 }, {
264 DRV_PTR(ipp_driver, CONFIG_DRM_EXYNOS_IPP),
265 DRM_VIRTUAL_DEVICE
266 }, {
267 &exynos_drm_platform_driver,
268 DRM_VIRTUAL_DEVICE
269 }
86650408 270};
f37cd5e8 271
53c5558d 272static int compare_dev(struct device *dev, void *data)
f37cd5e8
ID
273{
274 return dev == (struct device *)data;
275}
276
53c5558d 277static struct component_match *exynos_drm_match_add(struct device *dev)
f37cd5e8 278{
53c5558d 279 struct component_match *match = NULL;
86650408 280 int i;
f37cd5e8 281
a5fb26cd
MS
282 for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
283 struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
86650408 284 struct device *p = NULL, *d;
f7c2f36f 285
a5fb26cd
MS
286 if (!info->driver || !(info->flags & DRM_COMPONENT_DRIVER))
287 continue;
288
289 while ((d = bus_find_device(&platform_bus_type, p,
290 &info->driver->driver,
86650408
AH
291 (void *)platform_bus_type.match))) {
292 put_device(p);
293 component_match_add(dev, &match, compare_dev, d);
294 p = d;
df5225bc 295 }
86650408 296 put_device(p);
f37cd5e8
ID
297 }
298
86650408 299 return match ?: ERR_PTR(-ENODEV);
f37cd5e8
ID
300}
301
1cd6ae35
ID
302static struct device *exynos_drm_get_dma_device(void)
303{
304 int i;
305
306 for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
307 struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
308 struct device *dev;
309
310 if (!info->driver || !(info->flags & DRM_DMA_DEVICE))
311 continue;
312
313 while ((dev = bus_find_device(&platform_bus_type, NULL,
314 &info->driver->driver,
315 (void *)platform_bus_type.match))) {
316 put_device(dev);
317 return dev;
318 }
319 }
320 return NULL;
321}
322
f37cd5e8
ID
323static int exynos_drm_bind(struct device *dev)
324{
896bbc3e
LP
325 struct exynos_drm_private *private;
326 struct drm_encoder *encoder;
327 struct drm_device *drm;
328 unsigned int clone_mask;
329 int cnt, ret;
330
331 drm = drm_dev_alloc(&exynos_drm_driver, dev);
332 if (IS_ERR(drm))
333 return PTR_ERR(drm);
334
335 private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL);
336 if (!private) {
337 ret = -ENOMEM;
338 goto err_free_drm;
339 }
340
341 init_waitqueue_head(&private->wait);
342 spin_lock_init(&private->lock);
343
344 dev_set_drvdata(dev, drm);
345 drm->dev_private = (void *)private;
346
347 /* the first real CRTC device is used for all dma mapping operations */
348 private->dma_dev = exynos_drm_get_dma_device();
349 if (!private->dma_dev) {
350 DRM_ERROR("no device found for DMA mapping operations.\n");
351 ret = -ENODEV;
352 goto err_free_private;
353 }
354 DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n",
355 dev_name(private->dma_dev));
356
357 /* create common IOMMU mapping for all devices attached to Exynos DRM */
358 ret = drm_create_iommu_mapping(drm);
359 if (ret < 0) {
360 DRM_ERROR("failed to create iommu mapping.\n");
361 goto err_free_private;
362 }
363
364 drm_mode_config_init(drm);
365
366 exynos_drm_mode_config_init(drm);
367
368 /* setup possible_clones. */
369 cnt = 0;
370 clone_mask = 0;
371 list_for_each_entry(encoder, &drm->mode_config.encoder_list, head)
372 clone_mask |= (1 << (cnt++));
373
374 list_for_each_entry(encoder, &drm->mode_config.encoder_list, head)
375 encoder->possible_clones = clone_mask;
376
377 /* Try to bind all sub drivers. */
378 ret = component_bind_all(drm->dev, drm);
379 if (ret)
380 goto err_mode_config_cleanup;
381
382 ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
383 if (ret)
384 goto err_unbind_all;
385
386 /* Probe non kms sub drivers and virtual display driver. */
387 ret = exynos_drm_device_subdrv_probe(drm);
388 if (ret)
991dca01 389 goto err_unbind_all;
896bbc3e
LP
390
391 drm_mode_config_reset(drm);
392
393 /*
394 * enable drm irq mode.
395 * - with irq_enabled = true, we can use the vblank feature.
396 *
397 * P.S. note that we wouldn't use drm irq handler but
398 * just specific driver own one instead because
399 * drm framework supports only one irq handler.
400 */
401 drm->irq_enabled = true;
402
403 /* init kms poll for handling hpd */
404 drm_kms_helper_poll_init(drm);
405
812fc6f2
TR
406 ret = exynos_drm_fbdev_init(drm);
407 if (ret)
408 goto err_cleanup_poll;
896bbc3e
LP
409
410 /* register the DRM device */
411 ret = drm_dev_register(drm, 0);
412 if (ret < 0)
413 goto err_cleanup_fbdev;
414
415 return 0;
416
417err_cleanup_fbdev:
418 exynos_drm_fbdev_fini(drm);
812fc6f2 419err_cleanup_poll:
896bbc3e
LP
420 drm_kms_helper_poll_fini(drm);
421 exynos_drm_device_subdrv_remove(drm);
896bbc3e
LP
422err_unbind_all:
423 component_unbind_all(drm->dev, drm);
424err_mode_config_cleanup:
425 drm_mode_config_cleanup(drm);
426 drm_release_iommu_mapping(drm);
427err_free_private:
428 kfree(private);
429err_free_drm:
430 drm_dev_unref(drm);
431
432 return ret;
f37cd5e8
ID
433}
434
435static void exynos_drm_unbind(struct device *dev)
436{
896bbc3e
LP
437 struct drm_device *drm = dev_get_drvdata(dev);
438
439 drm_dev_unregister(drm);
440
441 exynos_drm_device_subdrv_remove(drm);
442
443 exynos_drm_fbdev_fini(drm);
444 drm_kms_helper_poll_fini(drm);
445
446 component_unbind_all(drm->dev, drm);
447 drm_mode_config_cleanup(drm);
448 drm_release_iommu_mapping(drm);
449
450 kfree(drm->dev_private);
451 drm->dev_private = NULL;
238604ca 452 dev_set_drvdata(dev, NULL);
896bbc3e
LP
453
454 drm_dev_unref(drm);
f37cd5e8
ID
455}
456
457static const struct component_master_ops exynos_drm_ops = {
f37cd5e8
ID
458 .bind = exynos_drm_bind,
459 .unbind = exynos_drm_unbind,
1c248b7d
ID
460};
461
417133e4
AH
462static int exynos_drm_platform_probe(struct platform_device *pdev)
463{
464 struct component_match *match;
465
466 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
417133e4
AH
467
468 match = exynos_drm_match_add(&pdev->dev);
469 if (IS_ERR(match))
470 return PTR_ERR(match);
471
472 return component_master_add_with_match(&pdev->dev, &exynos_drm_ops,
473 match);
474}
475
476static int exynos_drm_platform_remove(struct platform_device *pdev)
477{
478 component_master_del(&pdev->dev, &exynos_drm_ops);
479 return 0;
480}
481
482static struct platform_driver exynos_drm_platform_driver = {
483 .probe = exynos_drm_platform_probe,
484 .remove = exynos_drm_platform_remove,
485 .driver = {
486 .name = "exynos-drm",
487 .pm = &exynos_drm_pm_ops,
488 },
489};
490
417133e4 491static void exynos_drm_unregister_devices(void)
72390677 492{
a5fb26cd
MS
493 int i;
494
495 for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i) {
496 struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
497 struct device *dev;
25928a39 498
a5fb26cd
MS
499 if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE))
500 continue;
501
502 while ((dev = bus_find_device(&platform_bus_type, NULL,
503 &info->driver->driver,
504 (void *)platform_bus_type.match))) {
505 put_device(dev);
506 platform_device_unregister(to_platform_device(dev));
507 }
417133e4
AH
508 }
509}
7eb8f069 510
417133e4
AH
511static int exynos_drm_register_devices(void)
512{
a5fb26cd 513 struct platform_device *pdev;
417133e4
AH
514 int i;
515
a5fb26cd
MS
516 for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
517 struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
417133e4 518
a5fb26cd 519 if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE))
417133e4 520 continue;
417133e4 521
a5fb26cd
MS
522 pdev = platform_device_register_simple(
523 info->driver->driver.name, -1, NULL, 0);
524 if (IS_ERR(pdev))
525 goto fail;
72390677 526 }
f37cd5e8 527
417133e4 528 return 0;
a5fb26cd
MS
529fail:
530 exynos_drm_unregister_devices();
531 return PTR_ERR(pdev);
1c248b7d
ID
532}
533
a5fb26cd 534static void exynos_drm_unregister_drivers(void)
1c248b7d 535{
a5fb26cd 536 int i;
417133e4 537
a5fb26cd
MS
538 for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i) {
539 struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
417133e4 540
a5fb26cd 541 if (!info->driver)
417133e4
AH
542 continue;
543
a5fb26cd 544 platform_driver_unregister(info->driver);
417133e4 545 }
f37cd5e8
ID
546}
547
a5fb26cd 548static int exynos_drm_register_drivers(void)
417133e4 549{
a5fb26cd 550 int i, ret;
417133e4 551
a5fb26cd
MS
552 for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
553 struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
417133e4 554
a5fb26cd
MS
555 if (!info->driver)
556 continue;
417133e4 557
a5fb26cd
MS
558 ret = platform_driver_register(info->driver);
559 if (ret)
560 goto fail;
561 }
562 return 0;
563fail:
564 exynos_drm_unregister_drivers();
565 return ret;
417133e4
AH
566}
567
f37cd5e8
ID
568static int exynos_drm_init(void)
569{
e3b9e460 570 int ret;
f37cd5e8 571
417133e4
AH
572 ret = exynos_drm_register_devices();
573 if (ret)
574 return ret;
820687be 575
a5fb26cd 576 ret = exynos_drm_register_drivers();
417133e4
AH
577 if (ret)
578 goto err_unregister_pdevs;
f37cd5e8 579
f37cd5e8
ID
580 return 0;
581
417133e4
AH
582err_unregister_pdevs:
583 exynos_drm_unregister_devices();
f37cd5e8
ID
584
585 return ret;
586}
587
588static void exynos_drm_exit(void)
589{
a5fb26cd 590 exynos_drm_unregister_drivers();
417133e4 591 exynos_drm_unregister_devices();
1c248b7d
ID
592}
593
594module_init(exynos_drm_init);
595module_exit(exynos_drm_exit);
596
597MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>");
598MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
599MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>");
600MODULE_DESCRIPTION("Samsung SoC DRM Driver");
601MODULE_LICENSE("GPL");