This source file includes following definitions.
- nvbios_M0203Te
- nvbios_M0203Tp
- nvbios_M0203Ee
- nvbios_M0203Ep
- nvbios_M0203Em
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include <subdev/bios.h>
25 #include <subdev/bios/bit.h>
26 #include <subdev/bios/M0203.h>
27
28 u32
29 nvbios_M0203Te(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
30 {
31 struct bit_entry bit_M;
32 u32 data = 0x00000000;
33
34 if (!bit_entry(bios, 'M', &bit_M)) {
35 if (bit_M.version == 2 && bit_M.length > 0x04)
36 data = nvbios_rd16(bios, bit_M.offset + 0x03);
37 if (data) {
38 *ver = nvbios_rd08(bios, data + 0x00);
39 switch (*ver) {
40 case 0x10:
41 *hdr = nvbios_rd08(bios, data + 0x01);
42 *len = nvbios_rd08(bios, data + 0x02);
43 *cnt = nvbios_rd08(bios, data + 0x03);
44 return data;
45 default:
46 break;
47 }
48 }
49 }
50
51 return 0x00000000;
52 }
53
54 u32
55 nvbios_M0203Tp(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
56 struct nvbios_M0203T *info)
57 {
58 u32 data = nvbios_M0203Te(bios, ver, hdr, cnt, len);
59 memset(info, 0x00, sizeof(*info));
60 switch (!!data * *ver) {
61 case 0x10:
62 info->type = nvbios_rd08(bios, data + 0x04);
63 info->pointer = nvbios_rd16(bios, data + 0x05);
64 break;
65 default:
66 break;
67 }
68 return data;
69 }
70
71 u32
72 nvbios_M0203Ee(struct nvkm_bios *bios, int idx, u8 *ver, u8 *hdr)
73 {
74 u8 cnt, len;
75 u32 data = nvbios_M0203Te(bios, ver, hdr, &cnt, &len);
76 if (data && idx < cnt) {
77 data = data + *hdr + idx * len;
78 *hdr = len;
79 return data;
80 }
81 return 0x00000000;
82 }
83
84 u32
85 nvbios_M0203Ep(struct nvkm_bios *bios, int idx, u8 *ver, u8 *hdr,
86 struct nvbios_M0203E *info)
87 {
88 u32 data = nvbios_M0203Ee(bios, idx, ver, hdr);
89 memset(info, 0x00, sizeof(*info));
90 switch (!!data * *ver) {
91 case 0x10:
92 info->type = (nvbios_rd08(bios, data + 0x00) & 0x0f) >> 0;
93 info->strap = (nvbios_rd08(bios, data + 0x00) & 0xf0) >> 4;
94 info->group = (nvbios_rd08(bios, data + 0x01) & 0x0f) >> 0;
95 return data;
96 default:
97 break;
98 }
99 return 0x00000000;
100 }
101
102 u32
103 nvbios_M0203Em(struct nvkm_bios *bios, u8 ramcfg, u8 *ver, u8 *hdr,
104 struct nvbios_M0203E *info)
105 {
106 struct nvkm_subdev *subdev = &bios->subdev;
107 struct nvbios_M0203T M0203T;
108 u8 cnt, len, idx = 0xff;
109 u32 data;
110
111 if (!nvbios_M0203Tp(bios, ver, hdr, &cnt, &len, &M0203T)) {
112 nvkm_warn(subdev, "M0203T not found\n");
113 return 0x00000000;
114 }
115
116 while ((data = nvbios_M0203Ep(bios, ++idx, ver, hdr, info))) {
117 switch (M0203T.type) {
118 case M0203T_TYPE_RAMCFG:
119 if (info->strap != ramcfg)
120 continue;
121 return data;
122 default:
123 nvkm_warn(subdev, "M0203T type %02x\n", M0203T.type);
124 return 0x00000000;
125 }
126 }
127
128 return data;
129 }