]> git.karo-electronics.de Git - linux-beck.git/blob - drivers/gpu/drm/exynos/exynos_drm_drv.c
drm/exynos: remove ifdeferry from initialization code
[linux-beck.git] / drivers / gpu / drm / exynos / exynos_drm_drv.c
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  *
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.
12  */
13
14 #include <linux/pm_runtime.h>
15 #include <drm/drmP.h>
16 #include <drm/drm_crtc_helper.h>
17
18 #include <linux/component.h>
19
20 #include <drm/exynos_drm.h>
21
22 #include "exynos_drm_drv.h"
23 #include "exynos_drm_crtc.h"
24 #include "exynos_drm_encoder.h"
25 #include "exynos_drm_fbdev.h"
26 #include "exynos_drm_fb.h"
27 #include "exynos_drm_gem.h"
28 #include "exynos_drm_plane.h"
29 #include "exynos_drm_vidi.h"
30 #include "exynos_drm_dmabuf.h"
31 #include "exynos_drm_g2d.h"
32 #include "exynos_drm_ipp.h"
33 #include "exynos_drm_iommu.h"
34
35 #define DRIVER_NAME     "exynos"
36 #define DRIVER_DESC     "Samsung SoC DRM"
37 #define DRIVER_DATE     "20110530"
38 #define DRIVER_MAJOR    1
39 #define DRIVER_MINOR    0
40
41 static struct platform_device *exynos_drm_pdev;
42
43 static DEFINE_MUTEX(drm_component_lock);
44 static LIST_HEAD(drm_component_list);
45
46 struct component_dev {
47         struct list_head list;
48         struct device *crtc_dev;
49         struct device *conn_dev;
50         enum exynos_drm_output_type out_type;
51         unsigned int dev_type_flag;
52 };
53
54 static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
55 {
56         struct exynos_drm_private *private;
57         int ret;
58         int nr;
59
60         private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL);
61         if (!private)
62                 return -ENOMEM;
63
64         INIT_LIST_HEAD(&private->pageflip_event_list);
65         dev_set_drvdata(dev->dev, dev);
66         dev->dev_private = (void *)private;
67
68         /*
69          * create mapping to manage iommu table and set a pointer to iommu
70          * mapping structure to iommu_mapping of private data.
71          * also this iommu_mapping can be used to check if iommu is supported
72          * or not.
73          */
74         ret = drm_create_iommu_mapping(dev);
75         if (ret < 0) {
76                 DRM_ERROR("failed to create iommu mapping.\n");
77                 goto err_free_private;
78         }
79
80         drm_mode_config_init(dev);
81
82         exynos_drm_mode_config_init(dev);
83
84         for (nr = 0; nr < MAX_PLANE; nr++) {
85                 struct drm_plane *plane;
86                 unsigned long possible_crtcs = (1 << MAX_CRTC) - 1;
87
88                 plane = exynos_plane_init(dev, possible_crtcs,
89                                           DRM_PLANE_TYPE_OVERLAY);
90                 if (!IS_ERR(plane))
91                         continue;
92
93                 ret = PTR_ERR(plane);
94                 goto err_mode_config_cleanup;
95         }
96
97         /* setup possible_clones. */
98         exynos_drm_encoder_setup(dev);
99
100         platform_set_drvdata(dev->platformdev, dev);
101
102         /* Try to bind all sub drivers. */
103         ret = component_bind_all(dev->dev, dev);
104         if (ret)
105                 goto err_mode_config_cleanup;
106
107         ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
108         if (ret)
109                 goto err_unbind_all;
110
111         /*
112          * enable drm irq mode.
113          * - with irq_enabled = true, we can use the vblank feature.
114          *
115          * P.S. note that we wouldn't use drm irq handler but
116          *      just specific driver own one instead because
117          *      drm framework supports only one irq handler.
118          */
119         dev->irq_enabled = true;
120
121         /*
122          * with vblank_disable_allowed = true, vblank interrupt will be disabled
123          * by drm timer once a current process gives up ownership of
124          * vblank event.(after drm_vblank_put function is called)
125          */
126         dev->vblank_disable_allowed = true;
127
128         /* init kms poll for handling hpd */
129         drm_kms_helper_poll_init(dev);
130
131         /* force connectors detection */
132         drm_helper_hpd_irq_event(dev);
133
134         return 0;
135
136 err_unbind_all:
137         component_unbind_all(dev->dev, dev);
138 err_mode_config_cleanup:
139         drm_mode_config_cleanup(dev);
140         drm_release_iommu_mapping(dev);
141 err_free_private:
142         kfree(private);
143
144         return ret;
145 }
146
147 static int exynos_drm_unload(struct drm_device *dev)
148 {
149         exynos_drm_fbdev_fini(dev);
150         drm_kms_helper_poll_fini(dev);
151
152         drm_vblank_cleanup(dev);
153         component_unbind_all(dev->dev, dev);
154         drm_mode_config_cleanup(dev);
155         drm_release_iommu_mapping(dev);
156
157         kfree(dev->dev_private);
158         dev->dev_private = NULL;
159
160         return 0;
161 }
162
163 static int exynos_drm_suspend(struct drm_device *dev, pm_message_t state)
164 {
165         struct drm_connector *connector;
166
167         drm_modeset_lock_all(dev);
168         list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
169                 int old_dpms = connector->dpms;
170
171                 if (connector->funcs->dpms)
172                         connector->funcs->dpms(connector, DRM_MODE_DPMS_OFF);
173
174                 /* Set the old mode back to the connector for resume */
175                 connector->dpms = old_dpms;
176         }
177         drm_modeset_unlock_all(dev);
178
179         return 0;
180 }
181
182 static int exynos_drm_resume(struct drm_device *dev)
183 {
184         struct drm_connector *connector;
185
186         drm_modeset_lock_all(dev);
187         list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
188                 if (connector->funcs->dpms) {
189                         int dpms = connector->dpms;
190
191                         connector->dpms = DRM_MODE_DPMS_OFF;
192                         connector->funcs->dpms(connector, dpms);
193                 }
194         }
195         drm_modeset_unlock_all(dev);
196
197         drm_helper_resume_force_mode(dev);
198
199         return 0;
200 }
201
202 static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
203 {
204         struct drm_exynos_file_private *file_priv;
205         int ret;
206
207         file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
208         if (!file_priv)
209                 return -ENOMEM;
210
211         file->driver_priv = file_priv;
212
213         ret = exynos_drm_subdrv_open(dev, file);
214         if (ret)
215                 goto err_file_priv_free;
216
217         return ret;
218
219 err_file_priv_free:
220         kfree(file_priv);
221         file->driver_priv = NULL;
222         return ret;
223 }
224
225 static void exynos_drm_preclose(struct drm_device *dev,
226                                         struct drm_file *file)
227 {
228         exynos_drm_subdrv_close(dev, file);
229 }
230
231 static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
232 {
233         struct exynos_drm_private *private = dev->dev_private;
234         struct drm_pending_vblank_event *v, *vt;
235         struct drm_pending_event *e, *et;
236         unsigned long flags;
237
238         if (!file->driver_priv)
239                 return;
240
241         /* Release all events not unhandled by page flip handler. */
242         spin_lock_irqsave(&dev->event_lock, flags);
243         list_for_each_entry_safe(v, vt, &private->pageflip_event_list,
244                         base.link) {
245                 if (v->base.file_priv == file) {
246                         list_del(&v->base.link);
247                         drm_vblank_put(dev, v->pipe);
248                         v->base.destroy(&v->base);
249                 }
250         }
251
252         /* Release all events handled by page flip handler but not freed. */
253         list_for_each_entry_safe(e, et, &file->event_list, link) {
254                 list_del(&e->link);
255                 e->destroy(e);
256         }
257         spin_unlock_irqrestore(&dev->event_lock, flags);
258
259         kfree(file->driver_priv);
260         file->driver_priv = NULL;
261 }
262
263 static void exynos_drm_lastclose(struct drm_device *dev)
264 {
265         exynos_drm_fbdev_restore_mode(dev);
266 }
267
268 static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
269         .fault = exynos_drm_gem_fault,
270         .open = drm_gem_vm_open,
271         .close = drm_gem_vm_close,
272 };
273
274 static const struct drm_ioctl_desc exynos_ioctls[] = {
275         DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
276                         DRM_UNLOCKED | DRM_AUTH),
277         DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET,
278                         exynos_drm_gem_get_ioctl, DRM_UNLOCKED),
279         DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION,
280                         vidi_connection_ioctl, DRM_UNLOCKED | DRM_AUTH),
281         DRM_IOCTL_DEF_DRV(EXYNOS_G2D_GET_VER,
282                         exynos_g2d_get_ver_ioctl, DRM_UNLOCKED | DRM_AUTH),
283         DRM_IOCTL_DEF_DRV(EXYNOS_G2D_SET_CMDLIST,
284                         exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED | DRM_AUTH),
285         DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC,
286                         exynos_g2d_exec_ioctl, DRM_UNLOCKED | DRM_AUTH),
287         DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY,
288                         exynos_drm_ipp_get_property, DRM_UNLOCKED | DRM_AUTH),
289         DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY,
290                         exynos_drm_ipp_set_property, DRM_UNLOCKED | DRM_AUTH),
291         DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF,
292                         exynos_drm_ipp_queue_buf, DRM_UNLOCKED | DRM_AUTH),
293         DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL,
294                         exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH),
295 };
296
297 static const struct file_operations exynos_drm_driver_fops = {
298         .owner          = THIS_MODULE,
299         .open           = drm_open,
300         .mmap           = exynos_drm_gem_mmap,
301         .poll           = drm_poll,
302         .read           = drm_read,
303         .unlocked_ioctl = drm_ioctl,
304 #ifdef CONFIG_COMPAT
305         .compat_ioctl = drm_compat_ioctl,
306 #endif
307         .release        = drm_release,
308 };
309
310 static struct drm_driver exynos_drm_driver = {
311         .driver_features        = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
312         .load                   = exynos_drm_load,
313         .unload                 = exynos_drm_unload,
314         .suspend                = exynos_drm_suspend,
315         .resume                 = exynos_drm_resume,
316         .open                   = exynos_drm_open,
317         .preclose               = exynos_drm_preclose,
318         .lastclose              = exynos_drm_lastclose,
319         .postclose              = exynos_drm_postclose,
320         .set_busid              = drm_platform_set_busid,
321         .get_vblank_counter     = drm_vblank_count,
322         .enable_vblank          = exynos_drm_crtc_enable_vblank,
323         .disable_vblank         = exynos_drm_crtc_disable_vblank,
324         .gem_free_object        = exynos_drm_gem_free_object,
325         .gem_vm_ops             = &exynos_drm_gem_vm_ops,
326         .dumb_create            = exynos_drm_gem_dumb_create,
327         .dumb_map_offset        = exynos_drm_gem_dumb_map_offset,
328         .dumb_destroy           = drm_gem_dumb_destroy,
329         .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
330         .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
331         .gem_prime_export       = exynos_dmabuf_prime_export,
332         .gem_prime_import       = exynos_dmabuf_prime_import,
333         .ioctls                 = exynos_ioctls,
334         .num_ioctls             = ARRAY_SIZE(exynos_ioctls),
335         .fops                   = &exynos_drm_driver_fops,
336         .name   = DRIVER_NAME,
337         .desc   = DRIVER_DESC,
338         .date   = DRIVER_DATE,
339         .major  = DRIVER_MAJOR,
340         .minor  = DRIVER_MINOR,
341 };
342
343 #ifdef CONFIG_PM_SLEEP
344 static int exynos_drm_sys_suspend(struct device *dev)
345 {
346         struct drm_device *drm_dev = dev_get_drvdata(dev);
347         pm_message_t message;
348
349         if (pm_runtime_suspended(dev) || !drm_dev)
350                 return 0;
351
352         message.event = PM_EVENT_SUSPEND;
353         return exynos_drm_suspend(drm_dev, message);
354 }
355
356 static int exynos_drm_sys_resume(struct device *dev)
357 {
358         struct drm_device *drm_dev = dev_get_drvdata(dev);
359
360         if (pm_runtime_suspended(dev) || !drm_dev)
361                 return 0;
362
363         return exynos_drm_resume(drm_dev);
364 }
365 #endif
366
367 static const struct dev_pm_ops exynos_drm_pm_ops = {
368         SET_SYSTEM_SLEEP_PM_OPS(exynos_drm_sys_suspend, exynos_drm_sys_resume)
369 };
370
371 int exynos_drm_component_add(struct device *dev,
372                                 enum exynos_drm_device_type dev_type,
373                                 enum exynos_drm_output_type out_type)
374 {
375         struct component_dev *cdev;
376
377         if (dev_type != EXYNOS_DEVICE_TYPE_CRTC &&
378                         dev_type != EXYNOS_DEVICE_TYPE_CONNECTOR) {
379                 DRM_ERROR("invalid device type.\n");
380                 return -EINVAL;
381         }
382
383         mutex_lock(&drm_component_lock);
384
385         /*
386          * Make sure to check if there is a component which has two device
387          * objects, for connector and for encoder/connector.
388          * It should make sure that crtc and encoder/connector drivers are
389          * ready before exynos drm core binds them.
390          */
391         list_for_each_entry(cdev, &drm_component_list, list) {
392                 if (cdev->out_type == out_type) {
393                         /*
394                          * If crtc and encoder/connector device objects are
395                          * added already just return.
396                          */
397                         if (cdev->dev_type_flag == (EXYNOS_DEVICE_TYPE_CRTC |
398                                                 EXYNOS_DEVICE_TYPE_CONNECTOR)) {
399                                 mutex_unlock(&drm_component_lock);
400                                 return 0;
401                         }
402
403                         if (dev_type == EXYNOS_DEVICE_TYPE_CRTC) {
404                                 cdev->crtc_dev = dev;
405                                 cdev->dev_type_flag |= dev_type;
406                         }
407
408                         if (dev_type == EXYNOS_DEVICE_TYPE_CONNECTOR) {
409                                 cdev->conn_dev = dev;
410                                 cdev->dev_type_flag |= dev_type;
411                         }
412
413                         mutex_unlock(&drm_component_lock);
414                         return 0;
415                 }
416         }
417
418         mutex_unlock(&drm_component_lock);
419
420         cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
421         if (!cdev)
422                 return -ENOMEM;
423
424         if (dev_type == EXYNOS_DEVICE_TYPE_CRTC)
425                 cdev->crtc_dev = dev;
426         if (dev_type == EXYNOS_DEVICE_TYPE_CONNECTOR)
427                 cdev->conn_dev = dev;
428
429         cdev->out_type = out_type;
430         cdev->dev_type_flag = dev_type;
431
432         mutex_lock(&drm_component_lock);
433         list_add_tail(&cdev->list, &drm_component_list);
434         mutex_unlock(&drm_component_lock);
435
436         return 0;
437 }
438
439 void exynos_drm_component_del(struct device *dev,
440                                 enum exynos_drm_device_type dev_type)
441 {
442         struct component_dev *cdev, *next;
443
444         mutex_lock(&drm_component_lock);
445
446         list_for_each_entry_safe(cdev, next, &drm_component_list, list) {
447                 if (dev_type == EXYNOS_DEVICE_TYPE_CRTC) {
448                         if (cdev->crtc_dev == dev) {
449                                 cdev->crtc_dev = NULL;
450                                 cdev->dev_type_flag &= ~dev_type;
451                         }
452                 }
453
454                 if (dev_type == EXYNOS_DEVICE_TYPE_CONNECTOR) {
455                         if (cdev->conn_dev == dev) {
456                                 cdev->conn_dev = NULL;
457                                 cdev->dev_type_flag &= ~dev_type;
458                         }
459                 }
460
461                 /*
462                  * Release cdev object only in case that both of crtc and
463                  * encoder/connector device objects are NULL.
464                  */
465                 if (!cdev->crtc_dev && !cdev->conn_dev) {
466                         list_del(&cdev->list);
467                         kfree(cdev);
468                 }
469
470                 break;
471         }
472
473         mutex_unlock(&drm_component_lock);
474 }
475
476 static int compare_dev(struct device *dev, void *data)
477 {
478         return dev == (struct device *)data;
479 }
480
481 static struct component_match *exynos_drm_match_add(struct device *dev)
482 {
483         struct component_match *match = NULL;
484         struct component_dev *cdev;
485         unsigned int attach_cnt = 0;
486
487         mutex_lock(&drm_component_lock);
488
489         /* Do not retry to probe if there is no any kms driver regitered. */
490         if (list_empty(&drm_component_list)) {
491                 mutex_unlock(&drm_component_lock);
492                 return ERR_PTR(-ENODEV);
493         }
494
495         list_for_each_entry(cdev, &drm_component_list, list) {
496                 /*
497                  * Add components to master only in case that crtc and
498                  * encoder/connector device objects exist.
499                  */
500                 if (!cdev->crtc_dev || !cdev->conn_dev)
501                         continue;
502
503                 attach_cnt++;
504
505                 mutex_unlock(&drm_component_lock);
506
507                 /*
508                  * fimd and dpi modules have same device object so add
509                  * only crtc device object in this case.
510                  */
511                 if (cdev->crtc_dev == cdev->conn_dev) {
512                         component_match_add(dev, &match, compare_dev,
513                                                 cdev->crtc_dev);
514                         goto out_lock;
515                 }
516
517                 /*
518                  * Do not chage below call order.
519                  * crtc device first should be added to master because
520                  * connector/encoder need pipe number of crtc when they
521                  * are created.
522                  */
523                 component_match_add(dev, &match, compare_dev, cdev->crtc_dev);
524                 component_match_add(dev, &match, compare_dev, cdev->conn_dev);
525
526 out_lock:
527                 mutex_lock(&drm_component_lock);
528         }
529
530         mutex_unlock(&drm_component_lock);
531
532         return attach_cnt ? match : ERR_PTR(-EPROBE_DEFER);
533 }
534
535 static int exynos_drm_bind(struct device *dev)
536 {
537         return drm_platform_init(&exynos_drm_driver, to_platform_device(dev));
538 }
539
540 static void exynos_drm_unbind(struct device *dev)
541 {
542         drm_put_dev(dev_get_drvdata(dev));
543 }
544
545 static const struct component_master_ops exynos_drm_ops = {
546         .bind           = exynos_drm_bind,
547         .unbind         = exynos_drm_unbind,
548 };
549
550 static struct platform_driver *const exynos_drm_kms_drivers[] = {
551 #ifdef CONFIG_DRM_EXYNOS_FIMD
552         &fimd_driver,
553 #endif
554 #ifdef CONFIG_DRM_EXYNOS_DP
555         &dp_driver,
556 #endif
557 #ifdef CONFIG_DRM_EXYNOS_DSI
558         &dsi_driver,
559 #endif
560 #ifdef CONFIG_DRM_EXYNOS_HDMI
561         &mixer_driver,
562         &hdmi_driver,
563 #endif
564 };
565
566 static struct platform_driver *const exynos_drm_non_kms_drivers[] = {
567 #ifdef CONFIG_DRM_EXYNOS_G2D
568         &g2d_driver,
569 #endif
570 #ifdef CONFIG_DRM_EXYNOS_FIMC
571         &fimc_driver,
572 #endif
573 #ifdef CONFIG_DRM_EXYNOS_ROTATOR
574         &rotator_driver,
575 #endif
576 #ifdef CONFIG_DRM_EXYNOS_GSC
577         &gsc_driver,
578 #endif
579 #ifdef CONFIG_DRM_EXYNOS_IPP
580         &ipp_driver,
581 #endif
582 };
583
584 static int exynos_drm_platform_probe(struct platform_device *pdev)
585 {
586         struct component_match *match;
587         int ret, i, j;
588
589         pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
590         exynos_drm_driver.num_ioctls = ARRAY_SIZE(exynos_ioctls);
591
592         for (i = 0; i < ARRAY_SIZE(exynos_drm_kms_drivers); ++i) {
593                 ret = platform_driver_register(exynos_drm_kms_drivers[i]);
594                 if (ret < 0)
595                         goto err_unregister_kms_drivers;
596         }
597
598         match = exynos_drm_match_add(&pdev->dev);
599         if (IS_ERR(match)) {
600                 ret = PTR_ERR(match);
601                 goto err_unregister_kms_drivers;
602         }
603
604         ret = component_master_add_with_match(&pdev->dev, &exynos_drm_ops,
605                                                 match);
606         if (ret < 0)
607                 goto err_unregister_kms_drivers;
608
609         for (j = 0; j < ARRAY_SIZE(exynos_drm_non_kms_drivers); ++j) {
610                 ret = platform_driver_register(exynos_drm_non_kms_drivers[j]);
611                 if (ret < 0)
612                         goto err_del_component_master;
613         }
614
615         ret = exynos_platform_device_ipp_register();
616         if (ret < 0)
617                 goto err_unregister_non_kms_drivers;
618
619         /* Probe non kms sub drivers and virtual display driver. */
620         ret = exynos_drm_device_subdrv_probe(platform_get_drvdata(pdev));
621         if (ret)
622                 goto err_unregister_resources;
623
624         return ret;
625
626 err_unregister_resources:
627 #ifdef CONFIG_DRM_EXYNOS_IPP
628         exynos_platform_device_ipp_unregister();
629 #endif
630 err_unregister_non_kms_drivers:
631         while (--j >= 0)
632                 platform_driver_unregister(exynos_drm_non_kms_drivers[j]);
633
634 err_del_component_master:
635         component_master_del(&pdev->dev, &exynos_drm_ops);
636
637 err_unregister_kms_drivers:
638         while (--i >= 0)
639                 platform_driver_unregister(exynos_drm_kms_drivers[i]);
640
641         return ret;
642 }
643
644 static int exynos_drm_platform_remove(struct platform_device *pdev)
645 {
646         int i;
647
648         exynos_drm_device_subdrv_remove(platform_get_drvdata(pdev));
649
650 #ifdef CONFIG_DRM_EXYNOS_IPP
651         exynos_platform_device_ipp_unregister();
652 #endif
653
654         for (i = ARRAY_SIZE(exynos_drm_non_kms_drivers) - 1; i >= 0; --i)
655                 platform_driver_unregister(exynos_drm_non_kms_drivers[i]);
656
657         component_master_del(&pdev->dev, &exynos_drm_ops);
658
659         for (i = ARRAY_SIZE(exynos_drm_kms_drivers) - 1; i >= 0; --i)
660                 platform_driver_unregister(exynos_drm_kms_drivers[i]);
661
662         return 0;
663 }
664
665 static struct platform_driver exynos_drm_platform_driver = {
666         .probe  = exynos_drm_platform_probe,
667         .remove = exynos_drm_platform_remove,
668         .driver = {
669                 .owner  = THIS_MODULE,
670                 .name   = "exynos-drm",
671                 .pm     = &exynos_drm_pm_ops,
672         },
673 };
674
675 static int exynos_drm_init(void)
676 {
677         int ret;
678
679         /*
680          * Register device object only in case of Exynos SoC.
681          *
682          * Below codes resolves temporarily infinite loop issue incurred
683          * by Exynos drm driver when using multi-platform kernel.
684          * So these codes will be replaced with more generic way later.
685          */
686         if (!of_machine_is_compatible("samsung,exynos3") &&
687                         !of_machine_is_compatible("samsung,exynos4") &&
688                         !of_machine_is_compatible("samsung,exynos5"))
689                 return -ENODEV;
690
691         exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1,
692                                                                 NULL, 0);
693         if (IS_ERR(exynos_drm_pdev))
694                 return PTR_ERR(exynos_drm_pdev);
695
696         ret = exynos_drm_probe_vidi();
697         if (ret < 0)
698                 goto err_unregister_pd;
699
700         ret = platform_driver_register(&exynos_drm_platform_driver);
701         if (ret)
702                 goto err_remove_vidi;
703
704         return 0;
705
706 err_remove_vidi:
707         exynos_drm_remove_vidi();
708
709 err_unregister_pd:
710         platform_device_unregister(exynos_drm_pdev);
711
712         return ret;
713 }
714
715 static void exynos_drm_exit(void)
716 {
717         platform_driver_unregister(&exynos_drm_platform_driver);
718
719         exynos_drm_remove_vidi();
720
721         platform_device_unregister(exynos_drm_pdev);
722 }
723
724 module_init(exynos_drm_init);
725 module_exit(exynos_drm_exit);
726
727 MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>");
728 MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
729 MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>");
730 MODULE_DESCRIPTION("Samsung SoC DRM Driver");
731 MODULE_LICENSE("GPL");