nouveau_platform.c revision 1.2 1 /* $NetBSD: nouveau_platform.c,v 1.2 2018/08/27 04:58:24 riastradh Exp $ */
2
3 /*
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24 #include <sys/cdefs.h>
25 __KERNEL_RCSID(0, "$NetBSD: nouveau_platform.c,v 1.2 2018/08/27 04:58:24 riastradh Exp $");
26
27 #include "nouveau_platform.h"
28
29 static int nouveau_platform_probe(struct platform_device *pdev)
30 {
31 const struct nvkm_device_tegra_func *func;
32 struct nvkm_device *device = NULL;
33 struct drm_device *drm;
34 int ret;
35
36 func = of_device_get_match_data(&pdev->dev);
37
38 drm = nouveau_platform_device_create(func, pdev, &device);
39 if (IS_ERR(drm))
40 return PTR_ERR(drm);
41
42 ret = drm_dev_register(drm, 0);
43 if (ret < 0) {
44 drm_dev_unref(drm);
45 return ret;
46 }
47
48 return 0;
49 }
50
51 static int nouveau_platform_remove(struct platform_device *pdev)
52 {
53 struct drm_device *dev = platform_get_drvdata(pdev);
54 nouveau_drm_device_remove(dev);
55 return 0;
56 }
57
58 #if IS_ENABLED(CONFIG_OF)
59 static const struct nvkm_device_tegra_func gk20a_platform_data = {
60 .iommu_bit = 34,
61 };
62
63 static const struct of_device_id nouveau_platform_match[] = {
64 {
65 .compatible = "nvidia,gk20a",
66 .data = &gk20a_platform_data,
67 },
68 {
69 .compatible = "nvidia,gm20b",
70 .data = &gk20a_platform_data,
71 },
72 { }
73 };
74
75 MODULE_DEVICE_TABLE(of, nouveau_platform_match);
76 #endif
77
78 struct platform_driver nouveau_platform_driver = {
79 .driver = {
80 .name = "nouveau",
81 .of_match_table = of_match_ptr(nouveau_platform_match),
82 },
83 .probe = nouveau_platform_probe,
84 .remove = nouveau_platform_remove,
85 };
86