xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c (revision 4de93a086eb0315f0bd8e1d6da40186842670b57)
1 /*
2  * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 #include "gf100.h"
23 
24 static int
25 gk20a_fb_init(struct nvkm_object *object)
26 {
27 	struct nvkm_fb *fb = (void *)object;
28 	struct nvkm_device *device = fb->subdev.device;
29 	int ret;
30 
31 	ret = nvkm_fb_init(fb);
32 	if (ret)
33 		return ret;
34 
35 	nvkm_mask(device, 0x100c80, 0x00000001, 0x00000000); /* 128KiB lpg */
36 	return 0;
37 }
38 
39 static int
40 gk20a_fb_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
41 	      struct nvkm_oclass *oclass, void *data, u32 size,
42 	      struct nvkm_object **pobject)
43 {
44 	struct nvkm_fb *fb;
45 	int ret;
46 
47 	ret = nvkm_fb_create(parent, engine, oclass, &fb);
48 	*pobject = nv_object(fb);
49 	if (ret)
50 		return ret;
51 
52 	return 0;
53 }
54 
55 struct nvkm_oclass *
56 gk20a_fb_oclass = &(struct nvkm_fb_impl) {
57 	.base.handle = NV_SUBDEV(FB, 0xea),
58 	.base.ofuncs = &(struct nvkm_ofuncs) {
59 		.ctor = gk20a_fb_ctor,
60 		.dtor = _nvkm_fb_dtor,
61 		.init = gk20a_fb_init,
62 		.fini = _nvkm_fb_fini,
63 	},
64 	.memtype = gf100_fb_memtype_valid,
65 }.base;
66