]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/core/subdev/bios/P0260.c
drm/nouveau/bios: parsing of some random table needed to bring up gr
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / core / subdev / bios / P0260.c
1 /*
2  * Copyright 2013 Red Hat Inc.
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  *
22  * Authors: Ben Skeggs
23  */
24
25 #include <subdev/bios.h>
26 #include <subdev/bios/bit.h>
27 #include <subdev/bios/ramcfg.h>
28 #include <subdev/bios/P0260.h>
29
30 u32
31 nvbios_P0260Te(struct nouveau_bios *bios,
32                u8 *ver, u8 *hdr, u8 *cnt, u8 *len, u8 *xnr, u8 *xsz)
33 {
34         struct bit_entry bit_P;
35         u32 data = 0x00000000;
36
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);
40                 if (data) {
41                         *ver = nv_ro08(bios, data + 0);
42                         switch (*ver) {
43                         case 0x10:
44                                 *hdr = nv_ro08(bios, data + 1);
45                                 *cnt = nv_ro08(bios, data + 2);
46                                 *len = 4;
47                                 *xnr = nv_ro08(bios, data + 3);
48                                 *xsz = 4;
49                                 return data;
50                         default:
51                                 break;
52                         }
53                 }
54         }
55
56         return 0x00000000;
57 }
58
59 u32
60 nvbios_P0260Ee(struct nouveau_bios *bios, int idx, u8 *ver, u8 *len)
61 {
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);
66         return 0x00000000;
67 }
68
69 u32
70 nvbios_P0260Ep(struct nouveau_bios *bios, int idx, u8 *ver, u8 *len,
71                struct nvbios_P0260E *info)
72 {
73         u32 data = nvbios_P0260Ee(bios, idx, ver, len);
74         memset(info, 0x00, sizeof(*info));
75         switch (!!data * *ver) {
76         case 0x10:
77                 info->data = nv_ro32(bios, data);
78                 return data;
79         default:
80                 break;
81         }
82         return 0x00000000;
83 }
84
85 u32
86 nvbios_P0260Xe(struct nouveau_bios *bios, int idx, u8 *ver, u8 *xsz)
87 {
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);
92         return 0x00000000;
93 }
94
95 u32
96 nvbios_P0260Xp(struct nouveau_bios *bios, int idx, u8 *ver, u8 *hdr,
97                struct nvbios_P0260X *info)
98 {
99         u32 data = nvbios_P0260Xe(bios, idx, ver, hdr);
100         memset(info, 0x00, sizeof(*info));
101         switch (!!data * *ver) {
102         case 0x10:
103                 info->data = nv_ro32(bios, data);
104                 return data;
105         default:
106                 break;
107         }
108         return 0x00000000;
109 }