1 | /* $NetBSD: nouveau_subdev_devinit_base.c,v 1.1.1.1 2014/08/06 12:36:29 riastradh Exp $ */ |
2 | |
3 | /* |
4 | * Copyright 2012 Red Hat Inc. |
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
22 | * OTHER DEALINGS IN THE SOFTWARE. |
23 | * |
24 | * Authors: Ben Skeggs |
25 | */ |
26 | |
27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_devinit_base.c,v 1.1.1.1 2014/08/06 12:36:29 riastradh Exp $" ); |
29 | |
30 | #include <core/option.h> |
31 | |
32 | #include <subdev/bios.h> |
33 | #include <subdev/bios/init.h> |
34 | #include <subdev/vga.h> |
35 | |
36 | #include "priv.h" |
37 | |
38 | int |
39 | _nouveau_devinit_fini(struct nouveau_object *object, bool suspend) |
40 | { |
41 | struct nouveau_devinit *devinit = (void *)object; |
42 | |
43 | /* force full reinit on resume */ |
44 | if (suspend) |
45 | devinit->post = true; |
46 | |
47 | /* unlock the extended vga crtc regs */ |
48 | nv_lockvgac(devinit, false); |
49 | |
50 | return nouveau_subdev_fini(&devinit->base, suspend); |
51 | } |
52 | |
53 | int |
54 | _nouveau_devinit_init(struct nouveau_object *object) |
55 | { |
56 | struct nouveau_devinit_impl *impl = (void *)object->oclass; |
57 | struct nouveau_devinit *devinit = (void *)object; |
58 | int ret; |
59 | |
60 | ret = nouveau_subdev_init(&devinit->base); |
61 | if (ret) |
62 | return ret; |
63 | |
64 | ret = nvbios_init(&devinit->base, devinit->post); |
65 | if (ret) |
66 | return ret; |
67 | |
68 | if (impl->disable) |
69 | nv_device(devinit)->disable_mask |= impl->disable(devinit); |
70 | return 0; |
71 | } |
72 | |
73 | void |
74 | _nouveau_devinit_dtor(struct nouveau_object *object) |
75 | { |
76 | struct nouveau_devinit *devinit = (void *)object; |
77 | |
78 | /* lock crtc regs */ |
79 | nv_lockvgac(devinit, true); |
80 | |
81 | nouveau_subdev_destroy(&devinit->base); |
82 | } |
83 | |
84 | int |
85 | nouveau_devinit_create_(struct nouveau_object *parent, |
86 | struct nouveau_object *engine, |
87 | struct nouveau_oclass *oclass, |
88 | int size, void **pobject) |
89 | { |
90 | struct nouveau_devinit_impl *impl = (void *)oclass; |
91 | struct nouveau_device *device = nv_device(parent); |
92 | struct nouveau_devinit *devinit; |
93 | int ret; |
94 | |
95 | ret = nouveau_subdev_create_(parent, engine, oclass, 0, "DEVINIT" , |
96 | "init" , size, pobject); |
97 | devinit = *pobject; |
98 | if (ret) |
99 | return ret; |
100 | |
101 | devinit->post = nouveau_boolopt(device->cfgopt, "NvForcePost" , false); |
102 | devinit->meminit = impl->meminit; |
103 | devinit->pll_set = impl->pll_set; |
104 | devinit->mmio = impl->mmio; |
105 | return 0; |
106 | } |
107 | |