2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
22 static void msm_fb_output_poll_changed(struct drm_device *dev)
24 struct msm_drm_private *priv = dev->dev_private;
26 drm_fb_helper_hotplug_event(priv->fbdev);
29 static const struct drm_mode_config_funcs mode_config_funcs = {
30 .fb_create = msm_framebuffer_create,
31 .output_poll_changed = msm_fb_output_poll_changed,
34 int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu)
36 struct msm_drm_private *priv = dev->dev_private;
37 int idx = priv->num_mmus++;
39 if (WARN_ON(idx >= ARRAY_SIZE(priv->mmus)))
42 priv->mmus[idx] = mmu;
47 #ifdef CONFIG_DRM_MSM_REGISTER_LOGGING
48 static bool reglog = false;
49 MODULE_PARM_DESC(reglog, "Enable register read/write logging");
50 module_param(reglog, bool, 0600);
56 MODULE_PARM_DESC(vram, "Configure VRAM size (for devices without IOMMU/GPUMMU");
57 module_param(vram, charp, 0);
63 void __iomem *msm_ioremap(struct platform_device *pdev, const char *name,
71 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
73 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
76 dev_err(&pdev->dev, "failed to get memory resource: %s\n", name);
77 return ERR_PTR(-EINVAL);
80 size = resource_size(res);
82 ptr = devm_ioremap_nocache(&pdev->dev, res->start, size);
84 dev_err(&pdev->dev, "failed to ioremap: %s\n", name);
85 return ERR_PTR(-ENOMEM);
89 printk(KERN_DEBUG "IO:region %s %08x %08lx\n", dbgname, (u32)ptr, size);
94 void msm_writel(u32 data, void __iomem *addr)
97 printk(KERN_DEBUG "IO:W %08x %08x\n", (u32)addr, data);
101 u32 msm_readl(const void __iomem *addr)
103 u32 val = readl(addr);
105 printk(KERN_ERR "IO:R %08x %08x\n", (u32)addr, val);
113 static int msm_unload(struct drm_device *dev)
115 struct msm_drm_private *priv = dev->dev_private;
116 struct msm_kms *kms = priv->kms;
117 struct msm_gpu *gpu = priv->gpu;
119 drm_kms_helper_poll_fini(dev);
120 drm_mode_config_cleanup(dev);
121 drm_vblank_cleanup(dev);
123 pm_runtime_get_sync(dev->dev);
124 drm_irq_uninstall(dev);
125 pm_runtime_put_sync(dev->dev);
127 flush_workqueue(priv->wq);
128 destroy_workqueue(priv->wq);
131 pm_runtime_disable(dev->dev);
132 kms->funcs->destroy(kms);
136 mutex_lock(&dev->struct_mutex);
137 gpu->funcs->pm_suspend(gpu);
138 gpu->funcs->destroy(gpu);
139 mutex_unlock(&dev->struct_mutex);
142 if (priv->vram.paddr) {
143 DEFINE_DMA_ATTRS(attrs);
144 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
145 drm_mm_takedown(&priv->vram.mm);
146 dma_free_attrs(dev->dev, priv->vram.size, NULL,
147 priv->vram.paddr, &attrs);
150 component_unbind_all(dev->dev, dev);
152 dev->dev_private = NULL;
159 static int get_mdp_ver(struct platform_device *pdev)
162 const static struct of_device_id match_types[] = { {
163 .compatible = "qcom,mdss_mdp",
168 struct device *dev = &pdev->dev;
169 const struct of_device_id *match;
170 match = of_match_node(match_types, dev->of_node);
172 return (int)match->data;
177 static int msm_load(struct drm_device *dev, unsigned long flags)
179 struct platform_device *pdev = dev->platformdev;
180 struct msm_drm_private *priv;
185 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
187 dev_err(dev->dev, "failed to allocate private data\n");
191 dev->dev_private = priv;
193 priv->wq = alloc_ordered_workqueue("msm", 0);
194 init_waitqueue_head(&priv->fence_event);
196 INIT_LIST_HEAD(&priv->inactive_list);
197 INIT_LIST_HEAD(&priv->fence_cbs);
199 drm_mode_config_init(dev);
201 /* if we have no IOMMU, then we need to use carveout allocator.
202 * Grab the entire CMA chunk carved out in early startup in
205 if (!iommu_present(&platform_bus_type)) {
206 DEFINE_DMA_ATTRS(attrs);
210 DBG("using %s VRAM carveout", vram);
211 size = memparse(vram, NULL);
212 priv->vram.size = size;
214 drm_mm_init(&priv->vram.mm, 0, (size >> PAGE_SHIFT) - 1);
216 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
217 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
219 /* note that for no-kernel-mapping, the vaddr returned
220 * is bogus, but non-null if allocation succeeded:
222 p = dma_alloc_attrs(dev->dev, size,
223 &priv->vram.paddr, GFP_KERNEL, &attrs);
225 dev_err(dev->dev, "failed to allocate VRAM\n");
226 priv->vram.paddr = 0;
231 dev_info(dev->dev, "VRAM: %08x->%08x\n",
232 (uint32_t)priv->vram.paddr,
233 (uint32_t)(priv->vram.paddr + size));
236 platform_set_drvdata(pdev, dev);
238 /* Bind all our sub-components: */
239 ret = component_bind_all(dev->dev, dev);
243 switch (get_mdp_ver(pdev)) {
245 kms = mdp4_kms_init(dev);
248 kms = mdp5_kms_init(dev);
251 kms = ERR_PTR(-ENODEV);
257 * NOTE: once we have GPU support, having no kms should not
258 * be considered fatal.. ideally we would still support gpu
259 * and (for example) use dmabuf/prime to share buffers with
260 * imx drm driver on iMX5
262 dev_err(dev->dev, "failed to load kms\n");
270 pm_runtime_enable(dev->dev);
271 ret = kms->funcs->hw_init(kms);
273 dev_err(dev->dev, "kms hw init failed: %d\n", ret);
278 dev->mode_config.min_width = 0;
279 dev->mode_config.min_height = 0;
280 dev->mode_config.max_width = 2048;
281 dev->mode_config.max_height = 2048;
282 dev->mode_config.funcs = &mode_config_funcs;
284 ret = drm_vblank_init(dev, 1);
286 dev_err(dev->dev, "failed to initialize vblank\n");
290 pm_runtime_get_sync(dev->dev);
291 ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
292 pm_runtime_put_sync(dev->dev);
294 dev_err(dev->dev, "failed to install IRQ handler\n");
298 #ifdef CONFIG_DRM_MSM_FBDEV
299 priv->fbdev = msm_fbdev_init(dev);
302 ret = msm_debugfs_late_init(dev);
306 drm_kms_helper_poll_init(dev);
315 static void load_gpu(struct drm_device *dev)
317 struct msm_drm_private *priv = dev->dev_private;
323 mutex_lock(&dev->struct_mutex);
324 gpu = a3xx_gpu_init(dev);
326 dev_warn(dev->dev, "failed to load a3xx gpu\n");
333 gpu->funcs->pm_resume(gpu);
334 ret = gpu->funcs->hw_init(gpu);
336 dev_err(dev->dev, "gpu hw init failed: %d\n", ret);
337 gpu->funcs->destroy(gpu);
340 /* give inactive pm a chance to kick in: */
348 mutex_unlock(&dev->struct_mutex);
351 static int msm_open(struct drm_device *dev, struct drm_file *file)
353 struct msm_file_private *ctx;
355 /* For now, load gpu on open.. to avoid the requirement of having
356 * firmware in the initrd.
360 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
364 file->driver_priv = ctx;
369 static void msm_preclose(struct drm_device *dev, struct drm_file *file)
371 struct msm_drm_private *priv = dev->dev_private;
372 struct msm_file_private *ctx = file->driver_priv;
373 struct msm_kms *kms = priv->kms;
376 kms->funcs->preclose(kms, file);
378 mutex_lock(&dev->struct_mutex);
379 if (ctx == priv->lastctx)
380 priv->lastctx = NULL;
381 mutex_unlock(&dev->struct_mutex);
386 static void msm_lastclose(struct drm_device *dev)
388 struct msm_drm_private *priv = dev->dev_private;
390 drm_modeset_lock_all(dev);
391 drm_fb_helper_restore_fbdev_mode(priv->fbdev);
392 drm_modeset_unlock_all(dev);
396 static irqreturn_t msm_irq(int irq, void *arg)
398 struct drm_device *dev = arg;
399 struct msm_drm_private *priv = dev->dev_private;
400 struct msm_kms *kms = priv->kms;
402 return kms->funcs->irq(kms);
405 static void msm_irq_preinstall(struct drm_device *dev)
407 struct msm_drm_private *priv = dev->dev_private;
408 struct msm_kms *kms = priv->kms;
410 kms->funcs->irq_preinstall(kms);
413 static int msm_irq_postinstall(struct drm_device *dev)
415 struct msm_drm_private *priv = dev->dev_private;
416 struct msm_kms *kms = priv->kms;
418 return kms->funcs->irq_postinstall(kms);
421 static void msm_irq_uninstall(struct drm_device *dev)
423 struct msm_drm_private *priv = dev->dev_private;
424 struct msm_kms *kms = priv->kms;
426 kms->funcs->irq_uninstall(kms);
429 static int msm_enable_vblank(struct drm_device *dev, int crtc_id)
431 struct msm_drm_private *priv = dev->dev_private;
432 struct msm_kms *kms = priv->kms;
435 DBG("dev=%p, crtc=%d", dev, crtc_id);
436 return kms->funcs->enable_vblank(kms, priv->crtcs[crtc_id]);
439 static void msm_disable_vblank(struct drm_device *dev, int crtc_id)
441 struct msm_drm_private *priv = dev->dev_private;
442 struct msm_kms *kms = priv->kms;
445 DBG("dev=%p, crtc=%d", dev, crtc_id);
446 kms->funcs->disable_vblank(kms, priv->crtcs[crtc_id]);
453 #ifdef CONFIG_DEBUG_FS
454 static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)
456 struct msm_drm_private *priv = dev->dev_private;
457 struct msm_gpu *gpu = priv->gpu;
460 seq_printf(m, "%s Status:\n", gpu->name);
461 gpu->funcs->show(gpu, m);
467 static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
469 struct msm_drm_private *priv = dev->dev_private;
470 struct msm_gpu *gpu = priv->gpu;
473 seq_printf(m, "Active Objects (%s):\n", gpu->name);
474 msm_gem_describe_objects(&gpu->active_list, m);
477 seq_printf(m, "Inactive Objects:\n");
478 msm_gem_describe_objects(&priv->inactive_list, m);
483 static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
485 return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
488 static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
490 struct msm_drm_private *priv = dev->dev_private;
491 struct drm_framebuffer *fb, *fbdev_fb = NULL;
494 seq_printf(m, "fbcon ");
495 fbdev_fb = priv->fbdev->fb;
496 msm_framebuffer_describe(fbdev_fb, m);
499 mutex_lock(&dev->mode_config.fb_lock);
500 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
504 seq_printf(m, "user ");
505 msm_framebuffer_describe(fb, m);
507 mutex_unlock(&dev->mode_config.fb_lock);
512 static int show_locked(struct seq_file *m, void *arg)
514 struct drm_info_node *node = (struct drm_info_node *) m->private;
515 struct drm_device *dev = node->minor->dev;
516 int (*show)(struct drm_device *dev, struct seq_file *m) =
517 node->info_ent->data;
520 ret = mutex_lock_interruptible(&dev->struct_mutex);
526 mutex_unlock(&dev->struct_mutex);
531 static struct drm_info_list msm_debugfs_list[] = {
532 {"gpu", show_locked, 0, msm_gpu_show},
533 {"gem", show_locked, 0, msm_gem_show},
534 { "mm", show_locked, 0, msm_mm_show },
535 { "fb", show_locked, 0, msm_fb_show },
538 static int late_init_minor(struct drm_minor *minor)
545 ret = msm_rd_debugfs_init(minor);
547 dev_err(minor->dev->dev, "could not install rd debugfs\n");
551 ret = msm_perf_debugfs_init(minor);
553 dev_err(minor->dev->dev, "could not install perf debugfs\n");
560 int msm_debugfs_late_init(struct drm_device *dev)
563 ret = late_init_minor(dev->primary);
566 ret = late_init_minor(dev->render);
569 ret = late_init_minor(dev->control);
573 static int msm_debugfs_init(struct drm_minor *minor)
575 struct drm_device *dev = minor->dev;
578 ret = drm_debugfs_create_files(msm_debugfs_list,
579 ARRAY_SIZE(msm_debugfs_list),
580 minor->debugfs_root, minor);
583 dev_err(dev->dev, "could not install msm_debugfs_list\n");
590 static void msm_debugfs_cleanup(struct drm_minor *minor)
592 drm_debugfs_remove_files(msm_debugfs_list,
593 ARRAY_SIZE(msm_debugfs_list), minor);
594 if (!minor->dev->dev_private)
596 msm_rd_debugfs_cleanup(minor);
597 msm_perf_debugfs_cleanup(minor);
605 int msm_wait_fence_interruptable(struct drm_device *dev, uint32_t fence,
606 struct timespec *timeout)
608 struct msm_drm_private *priv = dev->dev_private;
614 if (fence > priv->gpu->submitted_fence) {
615 DRM_ERROR("waiting on invalid fence: %u (of %u)\n",
616 fence, priv->gpu->submitted_fence);
622 ret = fence_completed(dev, fence) ? 0 : -EBUSY;
624 unsigned long timeout_jiffies = timespec_to_jiffies(timeout);
625 unsigned long start_jiffies = jiffies;
626 unsigned long remaining_jiffies;
628 if (time_after(start_jiffies, timeout_jiffies))
629 remaining_jiffies = 0;
631 remaining_jiffies = timeout_jiffies - start_jiffies;
633 ret = wait_event_interruptible_timeout(priv->fence_event,
634 fence_completed(dev, fence),
638 DBG("timeout waiting for fence: %u (completed: %u)",
639 fence, priv->completed_fence);
641 } else if (ret != -ERESTARTSYS) {
649 /* called from workqueue */
650 void msm_update_fence(struct drm_device *dev, uint32_t fence)
652 struct msm_drm_private *priv = dev->dev_private;
654 mutex_lock(&dev->struct_mutex);
655 priv->completed_fence = max(fence, priv->completed_fence);
657 while (!list_empty(&priv->fence_cbs)) {
658 struct msm_fence_cb *cb;
660 cb = list_first_entry(&priv->fence_cbs,
661 struct msm_fence_cb, work.entry);
663 if (cb->fence > priv->completed_fence)
666 list_del_init(&cb->work.entry);
667 queue_work(priv->wq, &cb->work);
670 mutex_unlock(&dev->struct_mutex);
672 wake_up_all(&priv->fence_event);
675 void __msm_fence_worker(struct work_struct *work)
677 struct msm_fence_cb *cb = container_of(work, struct msm_fence_cb, work);
685 static int msm_ioctl_get_param(struct drm_device *dev, void *data,
686 struct drm_file *file)
688 struct msm_drm_private *priv = dev->dev_private;
689 struct drm_msm_param *args = data;
692 /* for now, we just have 3d pipe.. eventually this would need to
693 * be more clever to dispatch to appropriate gpu module:
695 if (args->pipe != MSM_PIPE_3D0)
703 return gpu->funcs->get_param(gpu, args->param, &args->value);
706 static int msm_ioctl_gem_new(struct drm_device *dev, void *data,
707 struct drm_file *file)
709 struct drm_msm_gem_new *args = data;
711 if (args->flags & ~MSM_BO_FLAGS) {
712 DRM_ERROR("invalid flags: %08x\n", args->flags);
716 return msm_gem_new_handle(dev, file, args->size,
717 args->flags, &args->handle);
720 #define TS(t) ((struct timespec){ .tv_sec = (t).tv_sec, .tv_nsec = (t).tv_nsec })
722 static int msm_ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
723 struct drm_file *file)
725 struct drm_msm_gem_cpu_prep *args = data;
726 struct drm_gem_object *obj;
729 if (args->op & ~MSM_PREP_FLAGS) {
730 DRM_ERROR("invalid op: %08x\n", args->op);
734 obj = drm_gem_object_lookup(dev, file, args->handle);
738 ret = msm_gem_cpu_prep(obj, args->op, &TS(args->timeout));
740 drm_gem_object_unreference_unlocked(obj);
745 static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
746 struct drm_file *file)
748 struct drm_msm_gem_cpu_fini *args = data;
749 struct drm_gem_object *obj;
752 obj = drm_gem_object_lookup(dev, file, args->handle);
756 ret = msm_gem_cpu_fini(obj);
758 drm_gem_object_unreference_unlocked(obj);
763 static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
764 struct drm_file *file)
766 struct drm_msm_gem_info *args = data;
767 struct drm_gem_object *obj;
773 obj = drm_gem_object_lookup(dev, file, args->handle);
777 args->offset = msm_gem_mmap_offset(obj);
779 drm_gem_object_unreference_unlocked(obj);
784 static int msm_ioctl_wait_fence(struct drm_device *dev, void *data,
785 struct drm_file *file)
787 struct drm_msm_wait_fence *args = data;
790 DRM_ERROR("invalid pad: %08x\n", args->pad);
794 return msm_wait_fence_interruptable(dev, args->fence,
798 static const struct drm_ioctl_desc msm_ioctls[] = {
799 DRM_IOCTL_DEF_DRV(MSM_GET_PARAM, msm_ioctl_get_param, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
800 DRM_IOCTL_DEF_DRV(MSM_GEM_NEW, msm_ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
801 DRM_IOCTL_DEF_DRV(MSM_GEM_INFO, msm_ioctl_gem_info, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
802 DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_PREP, msm_ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
803 DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_FINI, msm_ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
804 DRM_IOCTL_DEF_DRV(MSM_GEM_SUBMIT, msm_ioctl_gem_submit, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
805 DRM_IOCTL_DEF_DRV(MSM_WAIT_FENCE, msm_ioctl_wait_fence, DRM_UNLOCKED|DRM_AUTH|DRM_RENDER_ALLOW),
808 static const struct vm_operations_struct vm_ops = {
809 .fault = msm_gem_fault,
810 .open = drm_gem_vm_open,
811 .close = drm_gem_vm_close,
814 static const struct file_operations fops = {
815 .owner = THIS_MODULE,
817 .release = drm_release,
818 .unlocked_ioctl = drm_ioctl,
820 .compat_ioctl = drm_compat_ioctl,
825 .mmap = msm_gem_mmap,
828 static struct drm_driver msm_driver = {
829 .driver_features = DRIVER_HAVE_IRQ |
835 .unload = msm_unload,
837 .preclose = msm_preclose,
838 .lastclose = msm_lastclose,
839 .irq_handler = msm_irq,
840 .irq_preinstall = msm_irq_preinstall,
841 .irq_postinstall = msm_irq_postinstall,
842 .irq_uninstall = msm_irq_uninstall,
843 .get_vblank_counter = drm_vblank_count,
844 .enable_vblank = msm_enable_vblank,
845 .disable_vblank = msm_disable_vblank,
846 .gem_free_object = msm_gem_free_object,
847 .gem_vm_ops = &vm_ops,
848 .dumb_create = msm_gem_dumb_create,
849 .dumb_map_offset = msm_gem_dumb_map_offset,
850 .dumb_destroy = drm_gem_dumb_destroy,
851 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
852 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
853 .gem_prime_export = drm_gem_prime_export,
854 .gem_prime_import = drm_gem_prime_import,
855 .gem_prime_pin = msm_gem_prime_pin,
856 .gem_prime_unpin = msm_gem_prime_unpin,
857 .gem_prime_get_sg_table = msm_gem_prime_get_sg_table,
858 .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
859 .gem_prime_vmap = msm_gem_prime_vmap,
860 .gem_prime_vunmap = msm_gem_prime_vunmap,
861 #ifdef CONFIG_DEBUG_FS
862 .debugfs_init = msm_debugfs_init,
863 .debugfs_cleanup = msm_debugfs_cleanup,
865 .ioctls = msm_ioctls,
866 .num_ioctls = DRM_MSM_NUM_IOCTLS,
869 .desc = "MSM Snapdragon DRM",
875 #ifdef CONFIG_PM_SLEEP
876 static int msm_pm_suspend(struct device *dev)
878 struct drm_device *ddev = dev_get_drvdata(dev);
880 drm_kms_helper_poll_disable(ddev);
885 static int msm_pm_resume(struct device *dev)
887 struct drm_device *ddev = dev_get_drvdata(dev);
889 drm_kms_helper_poll_enable(ddev);
895 static const struct dev_pm_ops msm_pm_ops = {
896 SET_SYSTEM_SLEEP_PM_OPS(msm_pm_suspend, msm_pm_resume)
900 * Componentized driver support:
904 /* NOTE: the CONFIG_OF case duplicates the same code as exynos or imx
905 * (or probably any other).. so probably some room for some helpers
907 static int compare_of(struct device *dev, void *data)
909 return dev->of_node == data;
912 static int msm_drm_add_components(struct device *master, struct master *m)
914 struct device_node *np = master->of_node;
919 struct device_node *node;
921 node = of_parse_phandle(np, "connectors", i);
925 ret = component_master_add_child(m, compare_of, node);
934 static int compare_dev(struct device *dev, void *data)
939 static int msm_drm_add_components(struct device *master, struct master *m)
941 /* For non-DT case, it kinda sucks. We don't actually have a way
942 * to know whether or not we are waiting for certain devices (or if
943 * they are simply not present). But for non-DT we only need to
944 * care about apq8064/apq8060/etc (all mdp4/a3xx):
946 static const char *devnames[] = {
947 "hdmi_msm.0", "kgsl-3d0.0",
951 DBG("Adding components..");
953 for (i = 0; i < ARRAY_SIZE(devnames); i++) {
957 dev = bus_find_device_by_name(&platform_bus_type,
960 dev_info(master, "still waiting for %s\n", devnames[i]);
961 return -EPROBE_DEFER;
964 ret = component_master_add_child(m, compare_dev, dev);
966 DBG("could not add child: %d", ret);
975 static int msm_drm_bind(struct device *dev)
977 return drm_platform_init(&msm_driver, to_platform_device(dev));
980 static void msm_drm_unbind(struct device *dev)
982 drm_put_dev(platform_get_drvdata(to_platform_device(dev)));
985 static const struct component_master_ops msm_drm_ops = {
986 .add_components = msm_drm_add_components,
987 .bind = msm_drm_bind,
988 .unbind = msm_drm_unbind,
995 static int msm_pdev_probe(struct platform_device *pdev)
997 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
998 return component_master_add(&pdev->dev, &msm_drm_ops);
1001 static int msm_pdev_remove(struct platform_device *pdev)
1003 component_master_del(&pdev->dev, &msm_drm_ops);
1008 static const struct platform_device_id msm_id[] = {
1013 static const struct of_device_id dt_match[] = {
1014 { .compatible = "qcom,mdss_mdp" },
1017 MODULE_DEVICE_TABLE(of, dt_match);
1019 static struct platform_driver msm_platform_driver = {
1020 .probe = msm_pdev_probe,
1021 .remove = msm_pdev_remove,
1023 .owner = THIS_MODULE,
1025 .of_match_table = dt_match,
1031 static int __init msm_drm_register(void)
1036 return platform_driver_register(&msm_platform_driver);
1039 static void __exit msm_drm_unregister(void)
1042 platform_driver_unregister(&msm_platform_driver);
1047 module_init(msm_drm_register);
1048 module_exit(msm_drm_unregister);
1050 MODULE_AUTHOR("Rob Clark <robdclark@gmail.com");
1051 MODULE_DESCRIPTION("MSM DRM Driver");
1052 MODULE_LICENSE("GPL");