xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gk20a.c (revision e7d65181045898a6da80add0392765e253b0023c)
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 	int ret;
29 
30 	ret = nvkm_fb_init(fb);
31 	if (ret)
32 		return ret;
33 
34 	nv_mask(fb, 0x100c80, 0x00000001, 0x00000000); /* 128KiB lpg */
35 	return 0;
36 }
37 
38 static int
39 gk20a_fb_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
40 	      struct nvkm_oclass *oclass, void *data, u32 size,
41 	      struct nvkm_object **pobject)
42 {
43 	struct nvkm_fb *fb;
44 	int ret;
45 
46 	ret = nvkm_fb_create(parent, engine, oclass, &fb);
47 	*pobject = nv_object(fb);
48 	if (ret)
49 		return ret;
50 
51 	return 0;
52 }
53 
54 struct nvkm_oclass *
55 gk20a_fb_oclass = &(struct nvkm_fb_impl) {
56 	.base.handle = NV_SUBDEV(FB, 0xea),
57 	.base.ofuncs = &(struct nvkm_ofuncs) {
58 		.ctor = gk20a_fb_ctor,
59 		.dtor = _nvkm_fb_dtor,
60 		.init = gk20a_fb_init,
61 		.fini = _nvkm_fb_fini,
62 	},
63 	.memtype = gf100_fb_memtype_valid,
64 }.base;
65