diff options
Diffstat (limited to 'drivers/gpu/drm/tegra/drm.c')
| -rw-r--r-- | drivers/gpu/drm/tegra/drm.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c new file mode 100644 index 000000000000..3a503c9e4686 --- /dev/null +++ b/drivers/gpu/drm/tegra/drm.c | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2012 Avionic Design GmbH | ||
| 3 | * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. | ||
| 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 Foundation. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include <linux/module.h> | ||
| 11 | #include <linux/of_address.h> | ||
| 12 | #include <linux/of_platform.h> | ||
| 13 | |||
| 14 | #include <mach/clk.h> | ||
| 15 | #include <linux/dma-mapping.h> | ||
| 16 | #include <asm/dma-iommu.h> | ||
| 17 | |||
| 18 | #include "drm.h" | ||
| 19 | |||
| 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 | ||
| 26 | |||
| 27 | static int tegra_drm_load(struct drm_device *drm, unsigned long flags) | ||
| 28 | { | ||
| 29 | struct device *dev = drm->dev; | ||
| 30 | struct host1x *host1x; | ||
| 31 | int err; | ||
| 32 | |||
| 33 | host1x = dev_get_drvdata(dev); | ||
| 34 | drm->dev_private = host1x; | ||
| 35 | host1x->drm = drm; | ||
| 36 | |||
| 37 | drm_mode_config_init(drm); | ||
| 38 | |||
| 39 | err = host1x_drm_init(host1x, drm); | ||
| 40 | if (err < 0) | ||
| 41 | return err; | ||
| 42 | |||
| 43 | err = tegra_drm_fb_init(drm); | ||
| 44 | if (err < 0) | ||
| 45 | return err; | ||
| 46 | |||
| 47 | drm_kms_helper_poll_init(drm); | ||
| 48 | |||
| 49 | return 0; | ||
| 50 | } | ||
| 51 | |||
| 52 | static int tegra_drm_unload(struct drm_device *drm) | ||
| 53 | { | ||
| 54 | drm_kms_helper_poll_fini(drm); | ||
| 55 | tegra_drm_fb_exit(drm); | ||
| 56 | |||
| 57 | drm_mode_config_cleanup(drm); | ||
| 58 | |||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | |||
| 62 | static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp) | ||
| 63 | { | ||
| 64 | return 0; | ||
| 65 | } | ||
| 66 | |||
| 67 | static void tegra_drm_lastclose(struct drm_device *drm) | ||
| 68 | { | ||
| 69 | struct host1x *host1x = drm->dev_private; | ||
| 70 | |||
| 71 | drm_fbdev_cma_restore_mode(host1x->fbdev); | ||
| 72 | } | ||
| 73 | |||
| 74 | static struct drm_ioctl_desc tegra_drm_ioctls[] = { | ||
| 75 | }; | ||
| 76 | |||
| 77 | static const struct file_operations tegra_drm_fops = { | ||
| 78 | .owner = THIS_MODULE, | ||
| 79 | .open = drm_open, | ||
| 80 | .release = drm_release, | ||
| 81 | .unlocked_ioctl = drm_ioctl, | ||
| 82 | .mmap = drm_gem_cma_mmap, | ||
| 83 | .poll = drm_poll, | ||
| 84 | .fasync = drm_fasync, | ||
| 85 | .read = drm_read, | ||
| 86 | #ifdef CONFIG_COMPAT | ||
| 87 | .compat_ioctl = drm_compat_ioctl, | ||
| 88 | #endif | ||
| 89 | .llseek = noop_llseek, | ||
| 90 | }; | ||
| 91 | |||
| 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, | ||
| 98 | |||
| 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, | ||
| 104 | |||
| 105 | .ioctls = tegra_drm_ioctls, | ||
| 106 | .num_ioctls = ARRAY_SIZE(tegra_drm_ioctls), | ||
| 107 | .fops = &tegra_drm_fops, | ||
| 108 | |||
| 109 | .name = DRIVER_NAME, | ||
| 110 | .desc = DRIVER_DESC, | ||
| 111 | .date = DRIVER_DATE, | ||
| 112 | .major = DRIVER_MAJOR, | ||
| 113 | .minor = DRIVER_MINOR, | ||
| 114 | .patchlevel = DRIVER_PATCHLEVEL, | ||
| 115 | }; | ||
