142594600SBen Skeggs /*
242594600SBen Skeggs  * Copyright 2010 Red Hat Inc.
342594600SBen Skeggs  *
442594600SBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
542594600SBen Skeggs  * copy of this software and associated documentation files (the "Software"),
642594600SBen Skeggs  * to deal in the Software without restriction, including without limitation
742594600SBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
842594600SBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
942594600SBen Skeggs  * Software is furnished to do so, subject to the following conditions:
1042594600SBen Skeggs  *
1142594600SBen Skeggs  * The above copyright notice and this permission notice shall be included in
1242594600SBen Skeggs  * all copies or substantial portions of the Software.
1342594600SBen Skeggs  *
1442594600SBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1542594600SBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1642594600SBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1742594600SBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1842594600SBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1942594600SBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2042594600SBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
2142594600SBen Skeggs  *
2242594600SBen Skeggs  * Authors: Ben Skeggs
2342594600SBen Skeggs  */
2468af607dSBen Skeggs #include "mem.h"
25540a1ddeSBen Skeggs #include "vmm.h"
26c9582455SBen Skeggs 
27540a1ddeSBen Skeggs #include <nvif/class.h>
2842594600SBen Skeggs 
2942594600SBen Skeggs /* Map from compressed to corresponding uncompressed storage type.
3042594600SBen Skeggs  * The value 0xff represents an invalid storage type.
3142594600SBen Skeggs  */
32632b740cSBen Skeggs const u8 *
gf100_mmu_kind(struct nvkm_mmu * mmu,int * count,u8 * invalid)33176ada03SJames Jones gf100_mmu_kind(struct nvkm_mmu *mmu, int *count, u8 *invalid)
3442594600SBen Skeggs {
35632b740cSBen Skeggs 	static const u8
36632b740cSBen Skeggs 	kind[256] = {
3742594600SBen Skeggs 		0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x01, /* 0x00 */
3842594600SBen Skeggs 		0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff,
3942594600SBen Skeggs 		0xff, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, /* 0x10 */
4042594600SBen Skeggs 		0x11, 0x11, 0x11, 0xff, 0xff, 0xff, 0xff, 0xff,
4142594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x26, 0x27, /* 0x20 */
4242594600SBen Skeggs 		0x28, 0x29, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4342594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x30 */
4442594600SBen Skeggs 		0xff, 0xff, 0x26, 0x27, 0x28, 0x29, 0x26, 0x27,
4542594600SBen Skeggs 		0x28, 0x29, 0xff, 0xff, 0xff, 0xff, 0x46, 0xff, /* 0x40 */
4642594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4742594600SBen Skeggs 		0xff, 0x46, 0x46, 0x46, 0x46, 0xff, 0xff, 0xff, /* 0x50 */
4842594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4942594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x60 */
5042594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5142594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x70 */
5242594600SBen Skeggs 		0xff, 0xff, 0xff, 0x7b, 0xff, 0xff, 0xff, 0xff,
5342594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7b, 0x7b, /* 0x80 */
5442594600SBen Skeggs 		0x7b, 0x7b, 0xff, 0x8b, 0x8c, 0x8d, 0x8e, 0xff,
5542594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0x90 */
5642594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5742594600SBen Skeggs 		0xff, 0xff, 0xff, 0x8b, 0x8c, 0x8d, 0x8e, 0xa7, /* 0xa0 */
5842594600SBen Skeggs 		0xa8, 0xa9, 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff,
5942594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0 */
6042594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa7,
6142594600SBen Skeggs 		0xa8, 0xa9, 0xaa, 0xc3, 0xff, 0xff, 0xff, 0xff, /* 0xc0 */
6242594600SBen Skeggs 		0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xc3, 0xc3,
6342594600SBen Skeggs 		0xc3, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xd0 */
6442594600SBen Skeggs 		0xfe, 0xff, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
6542594600SBen Skeggs 		0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, /* 0xe0 */
6642594600SBen Skeggs 		0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xfe, 0xff,
6742594600SBen Skeggs 		0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, /* 0xf0 */
6842594600SBen Skeggs 		0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xfd, 0xfe, 0xff
6942594600SBen Skeggs 	};
7042594600SBen Skeggs 
71632b740cSBen Skeggs 	*count = ARRAY_SIZE(kind);
72176ada03SJames Jones 	*invalid = 0xff;
73632b740cSBen Skeggs 	return kind;
74b77791daSBen Skeggs }
7542594600SBen Skeggs 
76c9582455SBen Skeggs static const struct nvkm_mmu_func
77c9582455SBen Skeggs gf100_mmu = {
78c9582455SBen Skeggs 	.dma_bits = 40,
79eea5cf0fSBen Skeggs 	.mmu = {{ -1, -1, NVIF_CLASS_MMU_GF100}},
8068af607dSBen Skeggs 	.mem = {{ -1,  0, NVIF_CLASS_MEM_GF100}, gf100_mem_new, gf100_mem_map },
81540a1ddeSBen Skeggs 	.vmm = {{ -1, -1, NVIF_CLASS_VMM_GF100}, gf100_vmm_new },
82b77791daSBen Skeggs 	.kind = gf100_mmu_kind,
8351645eb7SBen Skeggs 	.kind_sys = true,
8442594600SBen Skeggs };
85c9582455SBen Skeggs 
86c9582455SBen Skeggs int
gf100_mmu_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_mmu ** pmmu)87*6dd123baSBen Skeggs gf100_mmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
88*6dd123baSBen Skeggs 	      struct nvkm_mmu **pmmu)
89c9582455SBen Skeggs {
90*6dd123baSBen Skeggs 	return nvkm_mmu_new_(&gf100_mmu, device, type, inst, pmmu);
91c9582455SBen Skeggs }
92