1e976278aSBen Skeggs /* 2e976278aSBen Skeggs * Copyright 2012 Red Hat Inc. 3e976278aSBen Skeggs * 4e976278aSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 5e976278aSBen Skeggs * copy of this software and associated documentation files (the "Software"), 6e976278aSBen Skeggs * to deal in the Software without restriction, including without limitation 7e976278aSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8e976278aSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 9e976278aSBen Skeggs * Software is furnished to do so, subject to the following conditions: 10e976278aSBen Skeggs * 11e976278aSBen Skeggs * The above copyright notice and this permission notice shall be included in 12e976278aSBen Skeggs * all copies or substantial portions of the Software. 13e976278aSBen Skeggs * 14e976278aSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15e976278aSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16e976278aSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17e976278aSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18e976278aSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19e976278aSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20e976278aSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 21e976278aSBen Skeggs * 22e976278aSBen Skeggs * Authors: Ben Skeggs 23e976278aSBen Skeggs */ 24e976278aSBen Skeggs #include "gf100.h" 25e976278aSBen Skeggs #include "ram.h" 26e976278aSBen Skeggs 27e976278aSBen Skeggs #include <core/memory.h> 28e976278aSBen Skeggs 292854ab8dSBen Skeggs int 30c73baa83SBen Skeggs gm200_fb_init_page(struct nvkm_fb *fb) 31c73baa83SBen Skeggs { 32c73baa83SBen Skeggs struct nvkm_device *device = fb->subdev.device; 33c73baa83SBen Skeggs switch (fb->page) { 342854ab8dSBen Skeggs case 16: nvkm_mask(device, 0x100c80, 0x00000801, 0x00000001); break; 352854ab8dSBen Skeggs case 17: nvkm_mask(device, 0x100c80, 0x00000801, 0x00000000); break; 362854ab8dSBen Skeggs case 0: nvkm_mask(device, 0x100c80, 0x00000800, 0x00000800); break; 37c73baa83SBen Skeggs default: 382854ab8dSBen Skeggs return -EINVAL; 39c73baa83SBen Skeggs } 402854ab8dSBen Skeggs return 0; 41c73baa83SBen Skeggs } 42c73baa83SBen Skeggs 43770b06e8SAlexandre Courbot void 44e976278aSBen Skeggs gm200_fb_init(struct nvkm_fb *base) 45e976278aSBen Skeggs { 46e976278aSBen Skeggs struct gf100_fb *fb = gf100_fb(base); 47e976278aSBen Skeggs struct nvkm_device *device = fb->base.subdev.device; 48e976278aSBen Skeggs 49e976278aSBen Skeggs if (fb->r100c10_page) 50e976278aSBen Skeggs nvkm_wr32(device, 0x100c10, fb->r100c10 >> 8); 51e976278aSBen Skeggs 52e976278aSBen Skeggs nvkm_mask(device, 0x100c80, 0x00000001, 0x00000000); /* 128KiB lpg */ 53e976278aSBen Skeggs 54e976278aSBen Skeggs nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(fb->base.mmu_wr) >> 8); 55e976278aSBen Skeggs nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(fb->base.mmu_rd) >> 8); 56e976278aSBen Skeggs nvkm_mask(device, 0x100cc4, 0x00060000, 57e976278aSBen Skeggs min(nvkm_memory_size(fb->base.mmu_rd) >> 16, (u64)2) << 17); 58e976278aSBen Skeggs } 59e976278aSBen Skeggs 60e976278aSBen Skeggs static const struct nvkm_fb_func 61e976278aSBen Skeggs gm200_fb = { 62e976278aSBen Skeggs .dtor = gf100_fb_dtor, 63e976278aSBen Skeggs .oneinit = gf100_fb_oneinit, 64e976278aSBen Skeggs .init = gm200_fb_init, 65c73baa83SBen Skeggs .init_page = gm200_fb_init_page, 66e976278aSBen Skeggs .intr = gf100_fb_intr, 67ba4c063dSBen Skeggs .ram_new = gm200_ram_new, 68e976278aSBen Skeggs .memtype_valid = gf100_fb_memtype_valid, 692854ab8dSBen Skeggs .default_bigpage = 0 /* per-instance. */, 70e976278aSBen Skeggs }; 71e976278aSBen Skeggs 72e976278aSBen Skeggs int 73e976278aSBen Skeggs gm200_fb_new(struct nvkm_device *device, int index, struct nvkm_fb **pfb) 74e976278aSBen Skeggs { 75e976278aSBen Skeggs return gf100_fb_new_(&gm200_fb, device, index, pfb); 76e976278aSBen Skeggs } 77