drm/gk104/pwr: implement PGOB disable method
[linux-2.6-microblaze.git] / drivers / gpu / drm / nouveau / core / subdev / pwr / gk104.c
1 /*
2  * Copyright 2013 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 "priv.h"
26
27 #define nvd0_pwr_code gk104_pwr_code
28 #define nvd0_pwr_data gk104_pwr_data
29 #include "fuc/nvd0.fuc.h"
30
31 static void
32 gk104_pwr_pgob(struct nouveau_pwr *ppwr, bool enable)
33 {
34         nv_mask(ppwr, 0x000200, 0x00001000, 0x00000000);
35         nv_rd32(ppwr, 0x000200);
36         nv_mask(ppwr, 0x000200, 0x08000000, 0x08000000);
37         msleep(50);
38
39         nv_mask(ppwr, 0x10a78c, 0x00000002, 0x00000002);
40         nv_mask(ppwr, 0x10a78c, 0x00000001, 0x00000001);
41         nv_mask(ppwr, 0x10a78c, 0x00000001, 0x00000000);
42
43         nv_mask(ppwr, 0x020004, 0xc0000000, enable ? 0xc0000000 : 0x40000000);
44         msleep(50);
45
46         nv_mask(ppwr, 0x10a78c, 0x00000002, 0x00000000);
47         nv_mask(ppwr, 0x10a78c, 0x00000001, 0x00000001);
48         nv_mask(ppwr, 0x10a78c, 0x00000001, 0x00000000);
49
50         nv_mask(ppwr, 0x000200, 0x08000000, 0x00000000);
51         nv_mask(ppwr, 0x000200, 0x00001000, 0x00001000);
52         nv_rd32(ppwr, 0x000200);
53 }
54
55 struct nouveau_oclass *
56 gk104_pwr_oclass = &(struct nvkm_pwr_impl) {
57         .base.handle = NV_SUBDEV(PWR, 0xe4),
58         .base.ofuncs = &(struct nouveau_ofuncs) {
59                 .ctor = _nouveau_pwr_ctor,
60                 .dtor = _nouveau_pwr_dtor,
61                 .init = _nouveau_pwr_init,
62                 .fini = _nouveau_pwr_fini,
63         },
64         .code.data = gk104_pwr_code,
65         .code.size = sizeof(gk104_pwr_code),
66         .data.data = gk104_pwr_data,
67         .data.size = sizeof(gk104_pwr_data),
68         .pgob = gk104_pwr_pgob,
69 }.base;