2012-07-11 10:44:20 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright 2012 Red Hat Inc.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
* Authors: Ben Skeggs
|
|
|
|
|
*/
|
2015-01-14 14:48:16 +10:00
|
|
|
#include "priv.h"
|
2012-07-11 10:44:20 +10:00
|
|
|
|
2015-01-14 14:48:16 +10:00
|
|
|
#include <core/device.h>
|
2012-07-11 10:44:20 +10:00
|
|
|
#include <core/option.h>
|
2014-01-19 04:18:15 -05:00
|
|
|
#include <subdev/vga.h>
|
2012-07-11 10:44:20 +10:00
|
|
|
|
|
|
|
|
int
|
2015-01-14 14:48:16 +10:00
|
|
|
_nvkm_devinit_fini(struct nvkm_object *object, bool suspend)
|
2012-07-11 10:44:20 +10:00
|
|
|
{
|
2015-01-14 14:48:16 +10:00
|
|
|
struct nvkm_devinit *devinit = (void *)object;
|
2012-07-11 10:44:20 +10:00
|
|
|
|
|
|
|
|
/* force full reinit on resume */
|
|
|
|
|
if (suspend)
|
|
|
|
|
devinit->post = true;
|
|
|
|
|
|
2014-01-19 04:18:15 -05:00
|
|
|
/* unlock the extended vga crtc regs */
|
|
|
|
|
nv_lockvgac(devinit, false);
|
|
|
|
|
|
2015-01-14 14:48:16 +10:00
|
|
|
return nvkm_subdev_fini(&devinit->base, suspend);
|
2012-07-11 10:44:20 +10:00
|
|
|
}
|
|
|
|
|
|
2013-03-05 10:53:54 +10:00
|
|
|
int
|
2015-01-14 14:48:16 +10:00
|
|
|
_nvkm_devinit_init(struct nvkm_object *object)
|
2013-03-05 10:53:54 +10:00
|
|
|
{
|
2015-01-14 14:48:16 +10:00
|
|
|
struct nvkm_devinit_impl *impl = (void *)object->oclass;
|
|
|
|
|
struct nvkm_devinit *devinit = (void *)object;
|
2014-01-14 16:29:06 +10:00
|
|
|
int ret;
|
|
|
|
|
|
2015-01-14 14:48:16 +10:00
|
|
|
ret = nvkm_subdev_init(&devinit->base);
|
2014-01-14 16:29:06 +10:00
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
2014-09-23 15:39:26 +10:00
|
|
|
ret = impl->post(&devinit->base, devinit->post);
|
2013-03-05 10:53:54 +10:00
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
2014-01-14 16:29:06 +10:00
|
|
|
if (impl->disable)
|
|
|
|
|
nv_device(devinit)->disable_mask |= impl->disable(devinit);
|
|
|
|
|
return 0;
|
2013-03-05 10:53:54 +10:00
|
|
|
}
|
|
|
|
|
|
2014-01-19 04:18:15 -05:00
|
|
|
void
|
2015-01-14 14:48:16 +10:00
|
|
|
_nvkm_devinit_dtor(struct nvkm_object *object)
|
2014-01-19 04:18:15 -05:00
|
|
|
{
|
2015-01-14 14:48:16 +10:00
|
|
|
struct nvkm_devinit *devinit = (void *)object;
|
2014-01-19 04:18:15 -05:00
|
|
|
|
|
|
|
|
/* lock crtc regs */
|
|
|
|
|
nv_lockvgac(devinit, true);
|
|
|
|
|
|
2015-01-14 14:48:16 +10:00
|
|
|
nvkm_subdev_destroy(&devinit->base);
|
2014-01-19 04:18:15 -05:00
|
|
|
}
|
|
|
|
|
|
2012-07-11 10:44:20 +10:00
|
|
|
int
|
2015-01-14 14:48:16 +10:00
|
|
|
nvkm_devinit_create_(struct nvkm_object *parent, struct nvkm_object *engine,
|
|
|
|
|
struct nvkm_oclass *oclass, int size, void **pobject)
|
2012-07-11 10:44:20 +10:00
|
|
|
{
|
2015-01-14 14:48:16 +10:00
|
|
|
struct nvkm_devinit_impl *impl = (void *)oclass;
|
|
|
|
|
struct nvkm_device *device = nv_device(parent);
|
|
|
|
|
struct nvkm_devinit *devinit;
|
2012-07-11 10:44:20 +10:00
|
|
|
int ret;
|
|
|
|
|
|
2015-01-14 14:48:16 +10:00
|
|
|
ret = nvkm_subdev_create_(parent, engine, oclass, 0, "DEVINIT",
|
|
|
|
|
"init", size, pobject);
|
2012-07-11 10:44:20 +10:00
|
|
|
devinit = *pobject;
|
|
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
|
|
|
|
|
2015-01-14 14:48:16 +10:00
|
|
|
devinit->post = nvkm_boolopt(device->cfgopt, "NvForcePost", false);
|
2014-01-14 15:55:38 +10:00
|
|
|
devinit->meminit = impl->meminit;
|
|
|
|
|
devinit->pll_set = impl->pll_set;
|
2014-03-19 02:56:29 +10:00
|
|
|
devinit->mmio = impl->mmio;
|
2012-07-11 10:44:20 +10:00
|
|
|
return 0;
|
|
|
|
|
}
|