1a8c4362bSBen Skeggs /*
2a8c4362bSBen Skeggs  * Copyright 2013 Red Hat Inc.
3a8c4362bSBen Skeggs  *
4a8c4362bSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5a8c4362bSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6a8c4362bSBen Skeggs  * to deal in the Software without restriction, including without limitation
7a8c4362bSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8a8c4362bSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9a8c4362bSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10a8c4362bSBen Skeggs  *
11a8c4362bSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12a8c4362bSBen Skeggs  * all copies or substantial portions of the Software.
13a8c4362bSBen Skeggs  *
14a8c4362bSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15a8c4362bSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16a8c4362bSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17a8c4362bSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18a8c4362bSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19a8c4362bSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20a8c4362bSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21a8c4362bSBen Skeggs  *
22a8c4362bSBen Skeggs  * Authors: Ben Skeggs
23a8c4362bSBen Skeggs  */
24a8c4362bSBen Skeggs #include "nv50.h"
25a8c4362bSBen Skeggs 
26a8c4362bSBen Skeggs #include <subdev/bios.h>
27a8c4362bSBen Skeggs #include <subdev/bios/init.h>
28a8c4362bSBen Skeggs 
29a8c4362bSBen Skeggs static u64
308ac3f64fSBen Skeggs mcp89_devinit_disable(struct nvkm_devinit *init)
31a8c4362bSBen Skeggs {
328ac3f64fSBen Skeggs 	struct nvkm_device *device = init->subdev.device;
338ac3f64fSBen Skeggs 	u32 r001540 = nvkm_rd32(device, 0x001540);
348ac3f64fSBen Skeggs 	u32 r00154c = nvkm_rd32(device, 0x00154c);
35a8c4362bSBen Skeggs 	u64 disable = 0;
36a8c4362bSBen Skeggs 
37a8c4362bSBen Skeggs 	if (!(r001540 & 0x40000000)) {
3896321606SBen Skeggs 		nvkm_subdev_disable(device, NVKM_ENGINE_MSPDEC, 0);
3907a356bbSBen Skeggs 		nvkm_subdev_disable(device, NVKM_ENGINE_MSPPP, 0);
40a8c4362bSBen Skeggs 	}
41a8c4362bSBen Skeggs 
42a8c4362bSBen Skeggs 	if (!(r00154c & 0x00000004))
43a7f000ecSBen Skeggs 		nvkm_subdev_disable(device, NVKM_ENGINE_DISP, 0);
44a8c4362bSBen Skeggs 	if (!(r00154c & 0x00000020))
45b15147bdSBen Skeggs 		nvkm_subdev_disable(device, NVKM_ENGINE_MSVLD, 0);
46a8c4362bSBen Skeggs 	if (!(r00154c & 0x00000040))
47*0fa5680cSBen Skeggs 		nvkm_subdev_disable(device, NVKM_ENGINE_VIC, 0);
48a8c4362bSBen Skeggs 	if (!(r00154c & 0x00000200))
4950551b15SBen Skeggs 		nvkm_subdev_disable(device, NVKM_ENGINE_CE, 0);
50a8c4362bSBen Skeggs 
51a8c4362bSBen Skeggs 	return disable;
52a8c4362bSBen Skeggs }
53a8c4362bSBen Skeggs 
54151abd44SBen Skeggs static const struct nvkm_devinit_func
55151abd44SBen Skeggs mcp89_devinit = {
56151abd44SBen Skeggs 	.preinit = nv50_devinit_preinit,
57a8c4362bSBen Skeggs 	.init = nv50_devinit_init,
58151abd44SBen Skeggs 	.post = nv04_devinit_post,
59a8c4362bSBen Skeggs 	.pll_set = gt215_devinit_pll_set,
60a8c4362bSBen Skeggs 	.disable = mcp89_devinit_disable,
61151abd44SBen Skeggs };
62151abd44SBen Skeggs 
63151abd44SBen Skeggs int
644a34fd0eSBen Skeggs mcp89_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
65151abd44SBen Skeggs 		  struct nvkm_devinit **pinit)
66151abd44SBen Skeggs {
674a34fd0eSBen Skeggs 	return nv50_devinit_new_(&mcp89_devinit, device, type, inst, pinit);
68151abd44SBen Skeggs }
69