2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include <core/option.h>
27 #include <subdev/vga.h>
30 nvkm_devinit_mmio(struct nvkm_devinit *init, u32 addr)
33 addr = init->func->mmio(init, addr);
38 nvkm_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 khz)
40 return init->func->pll_set(init, type, khz);
44 nvkm_devinit_meminit(struct nvkm_devinit *init)
46 if (init->func->meminit)
47 init->func->meminit(init);
51 nvkm_devinit_disable(struct nvkm_devinit *init)
53 if (init->func->disable)
54 return init->func->disable(init);
59 nvkm_devinit_fini(struct nvkm_subdev *subdev, bool suspend)
61 struct nvkm_devinit *init = nvkm_devinit(subdev);
62 /* force full reinit on resume */
69 nvkm_devinit_preinit(struct nvkm_subdev *subdev)
71 struct nvkm_devinit *init = nvkm_devinit(subdev);
73 if (init->func->preinit)
74 init->func->preinit(init);
76 /* unlock the extended vga crtc regs */
77 nvkm_lockvgac(subdev->device, false);
82 nvkm_devinit_init(struct nvkm_subdev *subdev)
84 struct nvkm_devinit *init = nvkm_devinit(subdev);
87 ret = init->func->post(init, init->post);
92 init->func->init(init);
94 if (init->func->disable)
95 subdev->device->disable_mask |= init->func->disable(init);
100 nvkm_devinit_dtor(struct nvkm_subdev *subdev)
102 struct nvkm_devinit *init = nvkm_devinit(subdev);
105 if (init->func->dtor)
106 data = init->func->dtor(init);
109 nvkm_lockvgac(subdev->device, true);
113 static const struct nvkm_subdev_func
115 .dtor = nvkm_devinit_dtor,
116 .preinit = nvkm_devinit_preinit,
117 .init = nvkm_devinit_init,
118 .fini = nvkm_devinit_fini,
122 nvkm_devinit_ctor(const struct nvkm_devinit_func *func,
123 struct nvkm_device *device, int index,
124 struct nvkm_devinit *init)
126 nvkm_subdev_ctor(&nvkm_devinit, device, index, 0, &init->subdev);
128 init->post = nvkm_boolopt(device->cfgopt, "NvForcePost", false);