Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2010 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs
0023  */
0024 #include "mem.h"
0025 #include "vmm.h"
0026 
0027 #include <nvif/class.h>
0028 
0029 const u8 *
0030 nv50_mmu_kind(struct nvkm_mmu *base, int *count, u8 *invalid)
0031 {
0032     /* 0x01: no bank swizzle
0033      * 0x02: bank swizzled
0034      * 0x7f: invalid
0035      *
0036      * 0x01/0x02 are values understood by the VRAM allocator,
0037      * and are required to avoid mixing the two types within
0038      * a certain range.
0039      */
0040     static const u8
0041     kind[128] = {
0042         0x01, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x00 */
0043         0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0044         0x01, 0x01, 0x01, 0x01, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x10 */
0045         0x02, 0x02, 0x02, 0x02, 0x7f, 0x7f, 0x7f, 0x7f,
0046         0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, /* 0x20 */
0047         0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7f,
0048         0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, /* 0x30 */
0049         0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0050         0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, /* 0x40 */
0051         0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7f, 0x7f,
0052         0x7f, 0x7f, 0x7f, 0x7f, 0x01, 0x01, 0x01, 0x7f, /* 0x50 */
0053         0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0054         0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x7f, /* 0x60 */
0055         0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
0056         0x01, 0x7f, 0x02, 0x7f, 0x01, 0x7f, 0x02, 0x7f, /* 0x70 */
0057         0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x7f, 0x7f
0058     };
0059     *count = ARRAY_SIZE(kind);
0060     *invalid = 0x7f;
0061     return kind;
0062 }
0063 
0064 static const struct nvkm_mmu_func
0065 nv50_mmu = {
0066     .dma_bits = 40,
0067     .mmu = {{ -1, -1, NVIF_CLASS_MMU_NV50}},
0068     .mem = {{ -1,  0, NVIF_CLASS_MEM_NV50}, nv50_mem_new, nv50_mem_map },
0069     .vmm = {{ -1, -1, NVIF_CLASS_VMM_NV50}, nv50_vmm_new, false, 0x1400 },
0070     .kind = nv50_mmu_kind,
0071 };
0072 
0073 int
0074 nv50_mmu_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0075          struct nvkm_mmu **pmmu)
0076 {
0077     return nvkm_mmu_new_(&nv50_mmu, device, type, inst, pmmu);
0078 }