This source file includes following definitions.
- nvbios_cstepTe
- nvbios_cstepEe
- nvbios_cstepEp
- nvbios_cstepEm
- nvbios_cstepXe
- nvbios_cstepXp
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/cstep.h>
27
28 u32
29 nvbios_cstepTe(struct nvkm_bios *bios,
30 u8 *ver, u8 *hdr, u8 *cnt, u8 *len, u8 *xnr, u8 *xsz)
31 {
32 struct bit_entry bit_P;
33 u32 cstep = 0;
34
35 if (!bit_entry(bios, 'P', &bit_P)) {
36 if (bit_P.version == 2 && bit_P.length >= 0x38)
37 cstep = nvbios_rd32(bios, bit_P.offset + 0x34);
38
39 if (cstep) {
40 *ver = nvbios_rd08(bios, cstep + 0);
41 switch (*ver) {
42 case 0x10:
43 *hdr = nvbios_rd08(bios, cstep + 1);
44 *cnt = nvbios_rd08(bios, cstep + 3);
45 *len = nvbios_rd08(bios, cstep + 2);
46 *xnr = nvbios_rd08(bios, cstep + 5);
47 *xsz = nvbios_rd08(bios, cstep + 4);
48 return cstep;
49 default:
50 break;
51 }
52 }
53 }
54
55 return 0;
56 }
57
58 u32
59 nvbios_cstepEe(struct nvkm_bios *bios, int idx, u8 *ver, u8 *hdr)
60 {
61 u8 cnt, len, xnr, xsz;
62 u32 data = nvbios_cstepTe(bios, ver, hdr, &cnt, &len, &xnr, &xsz);
63 if (data && idx < cnt) {
64 data = data + *hdr + (idx * len);
65 *hdr = len;
66 return data;
67 }
68 return 0;
69 }
70
71 u32
72 nvbios_cstepEp(struct nvkm_bios *bios, int idx, u8 *ver, u8 *hdr,
73 struct nvbios_cstepE *info)
74 {
75 u32 data = nvbios_cstepEe(bios, idx, ver, hdr);
76 memset(info, 0x00, sizeof(*info));
77 if (data) {
78 info->pstate = (nvbios_rd16(bios, data + 0x00) & 0x01e0) >> 5;
79 info->index = nvbios_rd08(bios, data + 0x03);
80 }
81 return data;
82 }
83
84 u32
85 nvbios_cstepEm(struct nvkm_bios *bios, u8 pstate, u8 *ver, u8 *hdr,
86 struct nvbios_cstepE *info)
87 {
88 u32 data, idx = 0;
89 while ((data = nvbios_cstepEp(bios, idx++, ver, hdr, info))) {
90 if (info->pstate == pstate)
91 break;
92 }
93 return data;
94 }
95
96 u32
97 nvbios_cstepXe(struct nvkm_bios *bios, int idx, u8 *ver, u8 *hdr)
98 {
99 u8 cnt, len, xnr, xsz;
100 u32 data = nvbios_cstepTe(bios, ver, hdr, &cnt, &len, &xnr, &xsz);
101 if (data && idx < xnr) {
102 data = data + *hdr + (cnt * len) + (idx * xsz);
103 *hdr = xsz;
104 return data;
105 }
106 return 0;
107 }
108
109 u32
110 nvbios_cstepXp(struct nvkm_bios *bios, int idx, u8 *ver, u8 *hdr,
111 struct nvbios_cstepX *info)
112 {
113 u32 data = nvbios_cstepXe(bios, idx, ver, hdr);
114 memset(info, 0x00, sizeof(*info));
115 if (data) {
116 info->freq = nvbios_rd16(bios, data + 0x00) * 1000;
117 info->unkn[0] = nvbios_rd08(bios, data + 0x02);
118 info->unkn[1] = nvbios_rd08(bios, data + 0x03);
119 info->voltage = nvbios_rd08(bios, data + 0x04);
120 }
121 return data;
122 }