1c39f472eSBen Skeggs /*
2c39f472eSBen Skeggs  * Copyright 2012 Red Hat Inc.
3c39f472eSBen Skeggs  *
4c39f472eSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5c39f472eSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6c39f472eSBen Skeggs  * to deal in the Software without restriction, including without limitation
7c39f472eSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8c39f472eSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9c39f472eSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10c39f472eSBen Skeggs  *
11c39f472eSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12c39f472eSBen Skeggs  * all copies or substantial portions of the Software.
13c39f472eSBen Skeggs  *
14c39f472eSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c39f472eSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c39f472eSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17c39f472eSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18c39f472eSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19c39f472eSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20c39f472eSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21c39f472eSBen Skeggs  *
22c39f472eSBen Skeggs  * Authors: Ben Skeggs
23c39f472eSBen Skeggs  */
2403c8952fSBen Skeggs #include "priv.h"
25d36a99d2SBen Skeggs #include "ram.h"
26639c308eSBen Skeggs #include "regsnv04.h"
27c39f472eSBen Skeggs 
28c39f472eSBen Skeggs bool
29b1e4553cSBen Skeggs nv04_fb_memtype_valid(struct nvkm_fb *fb, u32 tile_flags)
30c39f472eSBen Skeggs {
31c39f472eSBen Skeggs 	if (!(tile_flags & 0xff00))
32c39f472eSBen Skeggs 		return true;
33c39f472eSBen Skeggs 	return false;
34c39f472eSBen Skeggs }
35c39f472eSBen Skeggs 
3603c8952fSBen Skeggs static void
3703c8952fSBen Skeggs nv04_fb_init(struct nvkm_fb *fb)
38c39f472eSBen Skeggs {
396758745bSBen Skeggs 	struct nvkm_device *device = fb->subdev.device;
40c39f472eSBen Skeggs 
41c39f472eSBen Skeggs 	/* This is what the DDX did for NV_ARCH_04, but a mmio-trace shows
42c39f472eSBen Skeggs 	 * nvidia reading PFB_CFG_0, then writing back its original value.
43c39f472eSBen Skeggs 	 * (which was 0x701114 in this case)
44c39f472eSBen Skeggs 	 */
456758745bSBen Skeggs 	nvkm_wr32(device, NV04_PFB_CFG0, 0x1114);
46c39f472eSBen Skeggs }
47c39f472eSBen Skeggs 
4803c8952fSBen Skeggs static const struct nvkm_fb_func
4903c8952fSBen Skeggs nv04_fb = {
5003c8952fSBen Skeggs 	.init = nv04_fb_init,
5103c8952fSBen Skeggs 	.ram_new = nv04_ram_new,
5203c8952fSBen Skeggs 	.memtype_valid = nv04_fb_memtype_valid,
5303c8952fSBen Skeggs };
5403c8952fSBen Skeggs 
55c39f472eSBen Skeggs int
5603c8952fSBen Skeggs nv04_fb_new(struct nvkm_device *device, int index, struct nvkm_fb **pfb)
57c39f472eSBen Skeggs {
5803c8952fSBen Skeggs 	return nvkm_fb_new_(&nv04_fb, device, index, pfb);
59c39f472eSBen Skeggs }
60