drm/nouveau/mmu: namespace + nvidia gpu names (no binary change)
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nvkm / subdev / fb / gf100.c
CommitLineData
4b223eef 1/*
861d2107 2 * Copyright 2012 Red Hat Inc.
4b223eef
BS
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
639c308e 24#include "gf100.h"
4b223eef 25
42594600
BS
26#include <core/device.h>
27
639c308e 28extern const u8 gf100_pte_storage_type_map[256];
e30441ad 29
aae95ca7 30bool
639c308e 31gf100_fb_memtype_valid(struct nvkm_fb *pfb, u32 tile_flags)
a1484512 32{
861d2107 33 u8 memtype = (tile_flags & 0x0000ff00) >> 8;
639c308e 34 return likely((gf100_pte_storage_type_map[memtype] != 0xff));
861d2107 35}
a1484512 36
c814a60d 37static void
639c308e 38gf100_fb_intr(struct nvkm_subdev *subdev)
c814a60d 39{
639c308e 40 struct gf100_fb_priv *priv = (void *)subdev;
c814a60d
BS
41 u32 intr = nv_rd32(priv, 0x000100);
42 if (intr & 0x08000000) {
43 nv_debug(priv, "PFFB intr\n");
44 intr &= ~0x08000000;
45 }
46 if (intr & 0x00002000) {
47 nv_debug(priv, "PBFB intr\n");
48 intr &= ~0x00002000;
49 }
50}
51
aae95ca7 52int
639c308e 53gf100_fb_init(struct nvkm_object *object)
a1484512 54{
639c308e 55 struct gf100_fb_priv *priv = (void *)object;
861d2107
BS
56 int ret;
57
639c308e 58 ret = nvkm_fb_init(&priv->base);
861d2107
BS
59 if (ret)
60 return ret;
ffc6a4e4 61
fffeba2a
BS
62 if (priv->r100c10_page)
63 nv_wr32(priv, 0x100c10, priv->r100c10 >> 8);
639c308e 64
fe3d9c4b 65 nv_mask(priv, 0x100c80, 0x00000001, 0x00000000); /* 128KiB lpg */
861d2107 66 return 0;
a1484512
BS
67}
68
aae95ca7 69void
639c308e 70gf100_fb_dtor(struct nvkm_object *object)
310ff414 71{
639c308e
BS
72 struct nvkm_device *device = nv_device(object);
73 struct gf100_fb_priv *priv = (void *)object;
a1484512 74
310ff414 75 if (priv->r100c10_page) {
fd1496a0
AC
76 dma_unmap_page(nv_device_base(device), priv->r100c10, PAGE_SIZE,
77 DMA_BIDIRECTIONAL);
310ff414
BS
78 __free_page(priv->r100c10_page);
79 }
80
639c308e 81 nvkm_fb_destroy(&priv->base);
310ff414
BS
82}
83
aae95ca7 84int
639c308e
BS
85gf100_fb_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
86 struct nvkm_oclass *oclass, void *data, u32 size,
87 struct nvkm_object **pobject)
4b223eef 88{
639c308e
BS
89 struct nvkm_device *device = nv_device(parent);
90 struct gf100_fb_priv *priv;
310ff414
BS
91 int ret;
92
639c308e 93 ret = nvkm_fb_create(parent, engine, oclass, &priv);
861d2107
BS
94 *pobject = nv_object(priv);
95 if (ret)
96 return ret;
310ff414 97
861d2107 98 priv->r100c10_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
fffeba2a 99 if (priv->r100c10_page) {
fd1496a0
AC
100 priv->r100c10 = dma_map_page(nv_device_base(device),
101 priv->r100c10_page, 0, PAGE_SIZE,
102 DMA_BIDIRECTIONAL);
838f6fe7 103 if (dma_mapping_error(nv_device_base(device), priv->r100c10))
fffeba2a
BS
104 return -EFAULT;
105 }
861d2107 106
639c308e 107 nv_subdev(priv)->intr = gf100_fb_intr;
dceef5d8 108 return 0;
4b223eef 109}
861d2107 110
639c308e
BS
111struct nvkm_oclass *
112gf100_fb_oclass = &(struct nvkm_fb_impl) {
8613e731 113 .base.handle = NV_SUBDEV(FB, 0xc0),
639c308e
BS
114 .base.ofuncs = &(struct nvkm_ofuncs) {
115 .ctor = gf100_fb_ctor,
116 .dtor = gf100_fb_dtor,
117 .init = gf100_fb_init,
118 .fini = _nvkm_fb_fini,
861d2107 119 },
639c308e
BS
120 .memtype = gf100_fb_memtype_valid,
121 .ram = &gf100_ram_oclass,
8613e731 122}.base;
This page took 0.308978 seconds and 5 git commands to generate.