Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2014 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 <bskeggs@redhat.com>
0023  */
0024 #include <subdev/bios.h>
0025 #include <subdev/bios/npde.h>
0026 #include <subdev/bios/pcir.h>
0027 
0028 u32
0029 nvbios_npdeTe(struct nvkm_bios *bios, u32 base)
0030 {
0031     struct nvbios_pcirT pcir;
0032     u8  ver; u16 hdr;
0033     u32 data = nvbios_pcirTp(bios, base, &ver, &hdr, &pcir);
0034     if (data = (data + hdr + 0x0f) & ~0x0f, data) {
0035         switch (nvbios_rd32(bios, data + 0x00)) {
0036         case 0x4544504e: /* NPDE */
0037             break;
0038         default:
0039             nvkm_debug(&bios->subdev,
0040                    "%08x: NPDE signature (%08x) unknown\n",
0041                    data, nvbios_rd32(bios, data + 0x00));
0042             data = 0;
0043             break;
0044         }
0045     }
0046     return data;
0047 }
0048 
0049 u32
0050 nvbios_npdeTp(struct nvkm_bios *bios, u32 base, struct nvbios_npdeT *info)
0051 {
0052     u32 data = nvbios_npdeTe(bios, base);
0053     memset(info, 0x00, sizeof(*info));
0054     if (data) {
0055         info->image_size = nvbios_rd16(bios, data + 0x08) * 512;
0056         info->last = nvbios_rd08(bios, data + 0x0a) & 0x80;
0057     }
0058     return data;
0059 }