2 * Copyright 2013 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <subdev/bios.h>
26 #include <subdev/bios/bit.h>
27 #include <subdev/bios/ramcfg.h>
28 #include <subdev/bios/P0260.h>
31 nvbios_P0260Te(struct nouveau_bios *bios,
32 u8 *ver, u8 *hdr, u8 *cnt, u8 *len, u8 *xnr, u8 *xsz)
34 struct bit_entry bit_P;
35 u32 data = 0x00000000;
37 if (!bit_entry(bios, 'P', &bit_P)) {
38 if (bit_P.version == 2 && bit_P.length > 0x63)
39 data = nv_ro32(bios, bit_P.offset + 0x60);
41 *ver = nv_ro08(bios, data + 0);
44 *hdr = nv_ro08(bios, data + 1);
45 *cnt = nv_ro08(bios, data + 2);
47 *xnr = nv_ro08(bios, data + 3);
60 nvbios_P0260Ee(struct nouveau_bios *bios, int idx, u8 *ver, u8 *len)
62 u8 hdr, cnt, xnr, xsz;
63 u32 data = nvbios_P0260Te(bios, ver, &hdr, &cnt, len, &xnr, &xsz);
64 if (data && idx < cnt)
65 return data + hdr + (idx * *len);
70 nvbios_P0260Ep(struct nouveau_bios *bios, int idx, u8 *ver, u8 *len,
71 struct nvbios_P0260E *info)
73 u32 data = nvbios_P0260Ee(bios, idx, ver, len);
74 memset(info, 0x00, sizeof(*info));
75 switch (!!data * *ver) {
77 info->data = nv_ro32(bios, data);
86 nvbios_P0260Xe(struct nouveau_bios *bios, int idx, u8 *ver, u8 *xsz)
88 u8 hdr, cnt, len, xnr;
89 u32 data = nvbios_P0260Te(bios, ver, &hdr, &cnt, &len, &xnr, xsz);
90 if (data && idx < xnr)
91 return data + hdr + (cnt * len) + (idx * *xsz);
96 nvbios_P0260Xp(struct nouveau_bios *bios, int idx, u8 *ver, u8 *hdr,
97 struct nvbios_P0260X *info)
99 u32 data = nvbios_P0260Xe(bios, idx, ver, hdr);
100 memset(info, 0x00, sizeof(*info));
101 switch (!!data * *ver) {
103 info->data = nv_ro32(bios, data);