2 * Copyright (C) 2012 Avionic Design GmbH
3 * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
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 Foundation.
10 #include <linux/module.h>
11 #include <linux/of_address.h>
12 #include <linux/of_platform.h>
15 #include <linux/dma-mapping.h>
16 #include <asm/dma-iommu.h>
20 #define DRIVER_NAME "tegra"
21 #define DRIVER_DESC "NVIDIA Tegra graphics"
22 #define DRIVER_DATE "20120330"
23 #define DRIVER_MAJOR 0
24 #define DRIVER_MINOR 0
25 #define DRIVER_PATCHLEVEL 0
27 static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
29 struct device *dev = drm->dev;
30 struct host1x *host1x;
33 host1x = dev_get_drvdata(dev);
34 drm->dev_private = host1x;
37 drm_mode_config_init(drm);
39 err = host1x_drm_init(host1x, drm);
43 err = tegra_drm_fb_init(drm);
47 drm_kms_helper_poll_init(drm);
52 static int tegra_drm_unload(struct drm_device *drm)
54 drm_kms_helper_poll_fini(drm);
55 tegra_drm_fb_exit(drm);
57 drm_mode_config_cleanup(drm);
62 static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
67 static void tegra_drm_lastclose(struct drm_device *drm)
69 struct host1x *host1x = drm->dev_private;
71 drm_fbdev_cma_restore_mode(host1x->fbdev);
74 static struct drm_ioctl_desc tegra_drm_ioctls[] = {
77 static const struct file_operations tegra_drm_fops = {
80 .release = drm_release,
81 .unlocked_ioctl = drm_ioctl,
82 .mmap = drm_gem_cma_mmap,
87 .compat_ioctl = drm_compat_ioctl,
89 .llseek = noop_llseek,
92 struct drm_driver tegra_drm_driver = {
93 .driver_features = DRIVER_BUS_PLATFORM | DRIVER_MODESET | DRIVER_GEM,
94 .load = tegra_drm_load,
95 .unload = tegra_drm_unload,
96 .open = tegra_drm_open,
97 .lastclose = tegra_drm_lastclose,
99 .gem_free_object = drm_gem_cma_free_object,
100 .gem_vm_ops = &drm_gem_cma_vm_ops,
101 .dumb_create = drm_gem_cma_dumb_create,
102 .dumb_map_offset = drm_gem_cma_dumb_map_offset,
103 .dumb_destroy = drm_gem_cma_dumb_destroy,
105 .ioctls = tegra_drm_ioctls,
106 .num_ioctls = ARRAY_SIZE(tegra_drm_ioctls),
107 .fops = &tegra_drm_fops,
112 .major = DRIVER_MAJOR,
113 .minor = DRIVER_MINOR,
114 .patchlevel = DRIVER_PATCHLEVEL,