]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/nv84_bsp.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / nv84_bsp.c
1 /*
2  * Copyright 2011 Red Hat 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  * Authors: Ben Skeggs
23  */
24
25 #include "drmP.h"
26 #include "nouveau_drv.h"
27 #include "nouveau_util.h"
28 #include "nouveau_vm.h"
29 #include "nouveau_ramht.h"
30
31 /*XXX: This stub is currently used on NV98+ also, as soon as this becomes
32  *     more than just an enable/disable stub this needs to be split out to
33  *     nv98_bsp.c...
34  */
35
36 struct nv84_bsp_engine {
37         struct nouveau_exec_engine base;
38 };
39
40 static int
41 nv84_bsp_fini(struct drm_device *dev, int engine, bool suspend)
42 {
43         if (!(nv_rd32(dev, 0x000200) & 0x00008000))
44                 return 0;
45
46         nv_mask(dev, 0x000200, 0x00008000, 0x00000000);
47         return 0;
48 }
49
50 static int
51 nv84_bsp_init(struct drm_device *dev, int engine)
52 {
53         nv_mask(dev, 0x000200, 0x00008000, 0x00000000);
54         nv_mask(dev, 0x000200, 0x00008000, 0x00008000);
55         return 0;
56 }
57
58 static void
59 nv84_bsp_destroy(struct drm_device *dev, int engine)
60 {
61         struct nv84_bsp_engine *pbsp = nv_engine(dev, engine);
62
63         NVOBJ_ENGINE_DEL(dev, BSP);
64
65         kfree(pbsp);
66 }
67
68 int
69 nv84_bsp_create(struct drm_device *dev)
70 {
71         struct nv84_bsp_engine *pbsp;
72
73         pbsp = kzalloc(sizeof(*pbsp), GFP_KERNEL);
74         if (!pbsp)
75                 return -ENOMEM;
76
77         pbsp->base.destroy = nv84_bsp_destroy;
78         pbsp->base.init = nv84_bsp_init;
79         pbsp->base.fini = nv84_bsp_fini;
80
81         NVOBJ_ENGINE_ADD(dev, BSP, &pbsp->base);
82         return 0;
83 }