15ce3bf3cSBen Skeggs /*
25ce3bf3cSBen Skeggs * Copyright 2010 Red Hat Inc.
35ce3bf3cSBen Skeggs *
45ce3bf3cSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
55ce3bf3cSBen Skeggs * copy of this software and associated documentation files (the "Software"),
65ce3bf3cSBen Skeggs * to deal in the Software without restriction, including without limitation
75ce3bf3cSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
85ce3bf3cSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
95ce3bf3cSBen Skeggs * Software is furnished to do so, subject to the following conditions:
105ce3bf3cSBen Skeggs *
115ce3bf3cSBen Skeggs * The above copyright notice and this permission notice shall be included in
125ce3bf3cSBen Skeggs * all copies or substantial portions of the Software.
135ce3bf3cSBen Skeggs *
145ce3bf3cSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155ce3bf3cSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165ce3bf3cSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
175ce3bf3cSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
185ce3bf3cSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
195ce3bf3cSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
205ce3bf3cSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
215ce3bf3cSBen Skeggs *
225ce3bf3cSBen Skeggs * Authors: Ben Skeggs
235ce3bf3cSBen Skeggs */
2407661161SBen Skeggs #include "mem.h"
259f6219fdSBen Skeggs #include "vmm.h"
26c9582455SBen Skeggs
279f6219fdSBen Skeggs #include <nvif/class.h>
289f6219fdSBen Skeggs
29fd542a3eSBen Skeggs const u8 *
nv50_mmu_kind(struct nvkm_mmu * base,int * count,u8 * invalid)30176ada03SJames Jones nv50_mmu_kind(struct nvkm_mmu *base, int *count, u8 *invalid)
315ce3bf3cSBen Skeggs {
32fd542a3eSBen Skeggs /* 0x01: no bank swizzle
33fd542a3eSBen Skeggs * 0x02: bank swizzled
34fd542a3eSBen Skeggs * 0x7f: invalid
35fd542a3eSBen Skeggs *
36fd542a3eSBen Skeggs * 0x01/0x02 are values understood by the VRAM allocator,
37fd542a3eSBen Skeggs * and are required to avoid mixing the two types within
38fd542a3eSBen Skeggs * a certain range.
39fd542a3eSBen Skeggs */
40fd542a3eSBen Skeggs static const u8
41fd542a3eSBen Skeggs kind[128] = {
42fd542a3eSBen Skeggs 0x01, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x00 */
43fd542a3eSBen Skeggs 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
44fd542a3eSBen Skeggs 0x01, 0x01, 0x01, 0x01, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x10 */
45fd542a3eSBen Skeggs 0x02, 0x02, 0x02, 0x02, 0x7f, 0x7f, 0x7f, 0x7f,
46fd542a3eSBen Skeggs 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, /* 0x20 */
47fd542a3eSBen Skeggs 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7f,
48fd542a3eSBen Skeggs 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x30 */
49fd542a3eSBen Skeggs 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
50fd542a3eSBen Skeggs 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, /* 0x40 */
51fd542a3eSBen Skeggs 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7f, 0x7f,
52fd542a3eSBen Skeggs 0x7f, 0x7f, 0x7f, 0x7f, 0x01, 0x01, 0x01, 0x7f, /* 0x50 */
53fd542a3eSBen Skeggs 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
54fd542a3eSBen Skeggs 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, /* 0x60 */
55fd542a3eSBen Skeggs 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
56fd542a3eSBen Skeggs 0x01, 0x7f, 0x02, 0x7f, 0x01, 0x7f, 0x02, 0x7f, /* 0x70 */
57fd542a3eSBen Skeggs 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x7f, 0x7f
58fd542a3eSBen Skeggs };
59fd542a3eSBen Skeggs *count = ARRAY_SIZE(kind);
60176ada03SJames Jones *invalid = 0x7f;
61fd542a3eSBen Skeggs return kind;
625ce3bf3cSBen Skeggs }
635ce3bf3cSBen Skeggs
64c9582455SBen Skeggs static const struct nvkm_mmu_func
65c9582455SBen Skeggs nv50_mmu = {
66c9582455SBen Skeggs .dma_bits = 40,
67eea5cf0fSBen Skeggs .mmu = {{ -1, -1, NVIF_CLASS_MMU_NV50}},
6807661161SBen Skeggs .mem = {{ -1, 0, NVIF_CLASS_MEM_NV50}, nv50_mem_new, nv50_mem_map },
699f6219fdSBen Skeggs .vmm = {{ -1, -1, NVIF_CLASS_VMM_NV50}, nv50_vmm_new, false, 0x1400 },
70fd542a3eSBen Skeggs .kind = nv50_mmu_kind,
715ce3bf3cSBen Skeggs };
72c9582455SBen Skeggs
73c9582455SBen Skeggs int
nv50_mmu_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_mmu ** pmmu)74*6dd123baSBen Skeggs nv50_mmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
75*6dd123baSBen Skeggs struct nvkm_mmu **pmmu)
76c9582455SBen Skeggs {
77*6dd123baSBen Skeggs return nvkm_mmu_new_(&nv50_mmu, device, type, inst, pmmu);
78c9582455SBen Skeggs }
79