Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2012 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 "gf100.h"
0025 #include "ram.h"
0026 
0027 #include <core/memory.h>
0028 
0029 int
0030 gm200_fb_init_page(struct nvkm_fb *fb)
0031 {
0032     struct nvkm_device *device = fb->subdev.device;
0033     switch (fb->page) {
0034     case 16: nvkm_mask(device, 0x100c80, 0x00001801, 0x00001001); break;
0035     case 17: nvkm_mask(device, 0x100c80, 0x00001801, 0x00000000); break;
0036     case  0: nvkm_mask(device, 0x100c80, 0x00001800, 0x00001800); break;
0037     default:
0038         return -EINVAL;
0039     }
0040     return 0;
0041 }
0042 
0043 void
0044 gm200_fb_init(struct nvkm_fb *base)
0045 {
0046     struct gf100_fb *fb = gf100_fb(base);
0047     struct nvkm_device *device = fb->base.subdev.device;
0048 
0049     if (fb->r100c10_page)
0050         nvkm_wr32(device, 0x100c10, fb->r100c10 >> 8);
0051 
0052     nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(fb->base.mmu_wr) >> 8);
0053     nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(fb->base.mmu_rd) >> 8);
0054     nvkm_mask(device, 0x100cc4, 0x00060000,
0055           min(nvkm_memory_size(fb->base.mmu_rd) >> 16, (u64)2) << 17);
0056 }
0057 
0058 static const struct nvkm_fb_func
0059 gm200_fb = {
0060     .dtor = gf100_fb_dtor,
0061     .oneinit = gf100_fb_oneinit,
0062     .init = gm200_fb_init,
0063     .init_page = gm200_fb_init_page,
0064     .intr = gf100_fb_intr,
0065     .ram_new = gm200_ram_new,
0066     .default_bigpage = 0 /* per-instance. */,
0067 };
0068 
0069 int
0070 gm200_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
0071 {
0072     return gf100_fb_new_(&gm200_fb, device, type, inst, pfb);
0073 }