drm/msm/hdmi: Enable HPD after HDMI IRQ is set up
[linux/fpc-iii.git] / drivers / gpu / drm / ttm / ttm_module.c
blob6ff40c041d799d2bb8c24eb42b5a6a513926caad
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /**************************************************************************
4 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
5 * All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
30 * Jerome Glisse
32 #include <linux/module.h>
33 #include <linux/device.h>
34 #include <linux/sched.h>
35 #include <drm/ttm/ttm_module.h>
36 #include <drm/drm_sysfs.h>
38 static DECLARE_WAIT_QUEUE_HEAD(exit_q);
39 static atomic_t device_released;
41 static struct device_type ttm_drm_class_type = {
42 .name = "ttm",
43 /**
44 * Add pm ops here.
48 static void ttm_drm_class_device_release(struct device *dev)
50 atomic_set(&device_released, 1);
51 wake_up_all(&exit_q);
54 static struct device ttm_drm_class_device = {
55 .type = &ttm_drm_class_type,
56 .release = &ttm_drm_class_device_release
59 struct kobject *ttm_get_kobj(void)
61 struct kobject *kobj = &ttm_drm_class_device.kobj;
62 BUG_ON(kobj == NULL);
63 return kobj;
66 static int __init ttm_init(void)
68 int ret;
70 ret = dev_set_name(&ttm_drm_class_device, "ttm");
71 if (unlikely(ret != 0))
72 return ret;
74 atomic_set(&device_released, 0);
75 ret = drm_class_device_register(&ttm_drm_class_device);
76 if (unlikely(ret != 0))
77 goto out_no_dev_reg;
79 return 0;
80 out_no_dev_reg:
81 atomic_set(&device_released, 1);
82 wake_up_all(&exit_q);
83 return ret;
86 static void __exit ttm_exit(void)
88 drm_class_device_unregister(&ttm_drm_class_device);
90 /**
91 * Refuse to unload until the TTM device is released.
92 * Not sure this is 100% needed.
95 wait_event(exit_q, atomic_read(&device_released) == 1);
98 module_init(ttm_init);
99 module_exit(ttm_exit);
101 MODULE_AUTHOR("Thomas Hellstrom, Jerome Glisse");
102 MODULE_DESCRIPTION("TTM memory manager subsystem (for DRM device)");
103 MODULE_LICENSE("GPL and additional rights");