This source file includes following definitions.
- nvkm_devinit_mmio
- nvkm_devinit_pll_set
- nvkm_devinit_meminit
- nvkm_devinit_disable
- nvkm_devinit_post
- nvkm_devinit_fini
- nvkm_devinit_preinit
- nvkm_devinit_init
- nvkm_devinit_dtor
- nvkm_devinit_ctor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "priv.h"
25
26 #include <core/option.h>
27 #include <subdev/vga.h>
28
29 u32
30 nvkm_devinit_mmio(struct nvkm_devinit *init, u32 addr)
31 {
32 if (init->func->mmio)
33 addr = init->func->mmio(init, addr);
34 return addr;
35 }
36
37 int
38 nvkm_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 khz)
39 {
40 return init->func->pll_set(init, type, khz);
41 }
42
43 void
44 nvkm_devinit_meminit(struct nvkm_devinit *init)
45 {
46 if (init->func->meminit)
47 init->func->meminit(init);
48 }
49
50 u64
51 nvkm_devinit_disable(struct nvkm_devinit *init)
52 {
53 if (init && init->func->disable)
54 return init->func->disable(init);
55 return 0;
56 }
57
58 int
59 nvkm_devinit_post(struct nvkm_devinit *init, u64 *disable)
60 {
61 int ret = 0;
62 if (init && init->func->post)
63 ret = init->func->post(init, init->post);
64 *disable = nvkm_devinit_disable(init);
65 return ret;
66 }
67
68 static int
69 nvkm_devinit_fini(struct nvkm_subdev *subdev, bool suspend)
70 {
71 struct nvkm_devinit *init = nvkm_devinit(subdev);
72
73 if (suspend)
74 init->post = true;
75 return 0;
76 }
77
78 static int
79 nvkm_devinit_preinit(struct nvkm_subdev *subdev)
80 {
81 struct nvkm_devinit *init = nvkm_devinit(subdev);
82
83 if (init->func->preinit)
84 init->func->preinit(init);
85
86
87 if (init->force_post) {
88 init->post = init->force_post;
89 init->force_post = false;
90 }
91
92
93 nvkm_lockvgac(subdev->device, false);
94 return 0;
95 }
96
97 static int
98 nvkm_devinit_init(struct nvkm_subdev *subdev)
99 {
100 struct nvkm_devinit *init = nvkm_devinit(subdev);
101 if (init->func->init)
102 init->func->init(init);
103 return 0;
104 }
105
106 static void *
107 nvkm_devinit_dtor(struct nvkm_subdev *subdev)
108 {
109 struct nvkm_devinit *init = nvkm_devinit(subdev);
110 void *data = init;
111
112 if (init->func->dtor)
113 data = init->func->dtor(init);
114
115
116 nvkm_lockvgac(subdev->device, true);
117 return data;
118 }
119
120 static const struct nvkm_subdev_func
121 nvkm_devinit = {
122 .dtor = nvkm_devinit_dtor,
123 .preinit = nvkm_devinit_preinit,
124 .init = nvkm_devinit_init,
125 .fini = nvkm_devinit_fini,
126 };
127
128 void
129 nvkm_devinit_ctor(const struct nvkm_devinit_func *func,
130 struct nvkm_device *device, int index,
131 struct nvkm_devinit *init)
132 {
133 nvkm_subdev_ctor(&nvkm_devinit, device, index, &init->subdev);
134 init->func = func;
135 init->force_post = nvkm_boolopt(device->cfgopt, "NvForcePost", false);
136 }