amdkfd: Add amdkfd skeleton driver
[pandora-kernel.git] / drivers / gpu / drm / amd / amdkfd / kfd_module.c
1 /*
2  * Copyright 2014 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  */
22
23 #include <linux/module.h>
24 #include <linux/sched.h>
25 #include <linux/notifier.h>
26 #include <linux/moduleparam.h>
27 #include <linux/device.h>
28 #include "kfd_priv.h"
29
30 #define KFD_DRIVER_AUTHOR       "AMD Inc. and others"
31
32 #define KFD_DRIVER_DESC         "Standalone HSA driver for AMD's GPUs"
33 #define KFD_DRIVER_DATE         "20141113"
34 #define KFD_DRIVER_MAJOR        0
35 #define KFD_DRIVER_MINOR        7
36 #define KFD_DRIVER_PATCHLEVEL   0
37
38 const struct kfd2kgd_calls *kfd2kgd;
39 static const struct kgd2kfd_calls kgd2kfd = {
40         .exit           = kgd2kfd_exit,
41         .probe          = kgd2kfd_probe,
42         .device_init    = kgd2kfd_device_init,
43         .device_exit    = kgd2kfd_device_exit,
44         .interrupt      = kgd2kfd_interrupt,
45         .suspend        = kgd2kfd_suspend,
46         .resume         = kgd2kfd_resume,
47 };
48
49 bool kgd2kfd_init(unsigned interface_version,
50                   const struct kfd2kgd_calls *f2g,
51                   const struct kgd2kfd_calls **g2f)
52 {
53         /*
54          * Only one interface version is supported,
55          * no kfd/kgd version skew allowed.
56          */
57         if (interface_version != KFD_INTERFACE_VERSION)
58                 return false;
59
60         kfd2kgd = f2g;
61         *g2f = &kgd2kfd;
62
63         return true;
64 }
65 EXPORT_SYMBOL(kgd2kfd_init);
66
67 void kgd2kfd_exit(void)
68 {
69 }
70
71 static int __init kfd_module_init(void)
72 {
73         int err;
74
75         err = kfd_chardev_init();
76         if (err < 0)
77                 goto err_ioctl;
78
79         dev_info(kfd_device, "Initialized module\n");
80
81         return 0;
82
83 err_ioctl:
84         return err;
85 }
86
87 static void __exit kfd_module_exit(void)
88 {
89         kfd_chardev_exit();
90         dev_info(kfd_device, "Removed module\n");
91 }
92
93 module_init(kfd_module_init);
94 module_exit(kfd_module_exit);
95
96 MODULE_AUTHOR(KFD_DRIVER_AUTHOR);
97 MODULE_DESCRIPTION(KFD_DRIVER_DESC);
98 MODULE_LICENSE("GPL and additional rights");
99 MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "."
100                __stringify(KFD_DRIVER_MINOR) "."
101                __stringify(KFD_DRIVER_PATCHLEVEL));