1c011b254SBen Skeggs /*
2c011b254SBen Skeggs * Copyright 2018 Red Hat Inc.
3176ada03SJames Jones * Copyright 2019 NVIDIA Corporation.
4c011b254SBen Skeggs *
5c011b254SBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a
6c011b254SBen Skeggs * copy of this software and associated documentation files (the "Software"),
7c011b254SBen Skeggs * to deal in the Software without restriction, including without limitation
8c011b254SBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9c011b254SBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the
10c011b254SBen Skeggs * Software is furnished to do so, subject to the following conditions:
11c011b254SBen Skeggs *
12c011b254SBen Skeggs * The above copyright notice and this permission notice shall be included in
13c011b254SBen Skeggs * all copies or substantial portions of the Software.
14c011b254SBen Skeggs *
15c011b254SBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16c011b254SBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17c011b254SBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18c011b254SBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19c011b254SBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20c011b254SBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21c011b254SBen Skeggs * OTHER DEALINGS IN THE SOFTWARE.
22c011b254SBen Skeggs */
23c011b254SBen Skeggs #include "mem.h"
24c011b254SBen Skeggs #include "vmm.h"
25c011b254SBen Skeggs
26c011b254SBen Skeggs #include <core/option.h>
27c011b254SBen Skeggs
28c011b254SBen Skeggs #include <nvif/class.h>
29c011b254SBen Skeggs
303b54befdSBen Skeggs static const u8 *
tu102_mmu_kind(struct nvkm_mmu * mmu,int * count,u8 * invalid)31176ada03SJames Jones tu102_mmu_kind(struct nvkm_mmu *mmu, int *count, u8 *invalid)
32176ada03SJames Jones {
33176ada03SJames Jones static const u8
34176ada03SJames Jones kind[16] = {
35176ada03SJames Jones 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 */
36176ada03SJames Jones 0x06, 0x06, 0x02, 0x01, 0x03, 0x04, 0x05, 0x07,
37176ada03SJames Jones };
38176ada03SJames Jones *count = ARRAY_SIZE(kind);
39176ada03SJames Jones *invalid = 0x07;
40176ada03SJames Jones return kind;
41176ada03SJames Jones }
42176ada03SJames Jones
43c011b254SBen Skeggs static const struct nvkm_mmu_func
44c011b254SBen Skeggs tu102_mmu = {
45c011b254SBen Skeggs .dma_bits = 47,
46c011b254SBen Skeggs .mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}},
47c011b254SBen Skeggs .mem = {{ -1, 0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map },
48c011b254SBen Skeggs .vmm = {{ -1, 0, NVIF_CLASS_VMM_GP100}, tu102_vmm_new },
49176ada03SJames Jones .kind = tu102_mmu_kind,
50c011b254SBen Skeggs .kind_sys = true,
51c011b254SBen Skeggs };
52c011b254SBen Skeggs
53c011b254SBen Skeggs int
tu102_mmu_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_mmu ** pmmu)54*6dd123baSBen Skeggs tu102_mmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
55*6dd123baSBen Skeggs struct nvkm_mmu **pmmu)
56c011b254SBen Skeggs {
57*6dd123baSBen Skeggs return nvkm_mmu_new_(&tu102_mmu, device, type, inst, pmmu);
58c011b254SBen Skeggs }
59