Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2010 Francisco Jerez.
0003  * All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining
0006  * a copy of this software and associated documentation files (the
0007  * "Software"), to deal in the Software without restriction, including
0008  * without limitation the rights to use, copy, modify, merge, publish,
0009  * distribute, sublicense, and/or sell copies of the Software, and to
0010  * permit persons to whom the Software is furnished to do so, subject to
0011  * the following conditions:
0012  *
0013  * The above copyright notice and this permission notice (including the
0014  * next paragraph) shall be included in all copies or substantial
0015  * portions of the Software.
0016  *
0017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0018  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
0020  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
0021  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0022  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0023  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0024  *
0025  */
0026 #include "nv04.h"
0027 #include "fbmem.h"
0028 
0029 #include <subdev/bios.h>
0030 #include <subdev/bios/init.h>
0031 
0032 static void
0033 nv20_devinit_meminit(struct nvkm_devinit *init)
0034 {
0035     struct nvkm_subdev *subdev = &init->subdev;
0036     struct nvkm_device *device = subdev->device;
0037     uint32_t mask = (device->chipset >= 0x25 ? 0x300 : 0x900);
0038     uint32_t amount, off;
0039     struct io_mapping *fb;
0040 
0041     /* Map the framebuffer aperture */
0042     fb = fbmem_init(device);
0043     if (!fb) {
0044         nvkm_error(subdev, "failed to map fb\n");
0045         return;
0046     }
0047 
0048     nvkm_wr32(device, NV10_PFB_REFCTRL, NV10_PFB_REFCTRL_VALID_1);
0049 
0050     /* Allow full addressing */
0051     nvkm_mask(device, NV04_PFB_CFG0, 0, mask);
0052 
0053     amount = nvkm_rd32(device, 0x10020c);
0054     for (off = amount; off > 0x2000000; off -= 0x2000000)
0055         fbmem_poke(fb, off - 4, off);
0056 
0057     amount = nvkm_rd32(device, 0x10020c);
0058     if (amount != fbmem_peek(fb, amount - 4))
0059         /* IC missing - disable the upper half memory space. */
0060         nvkm_mask(device, NV04_PFB_CFG0, mask, 0);
0061 
0062     fbmem_fini(fb);
0063 }
0064 
0065 static const struct nvkm_devinit_func
0066 nv20_devinit = {
0067     .dtor = nv04_devinit_dtor,
0068     .preinit = nv04_devinit_preinit,
0069     .post = nv04_devinit_post,
0070     .meminit = nv20_devinit_meminit,
0071     .pll_set = nv04_devinit_pll_set,
0072 };
0073 
0074 int
0075 nv20_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
0076          struct nvkm_devinit **pinit)
0077 {
0078     return nv04_devinit_new_(&nv20_devinit, device, type, inst, pinit);
0079 }