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/gpio.h>
27 #include <subdev/bios.h>
28 #include <subdev/bios/pll.h>
29 #include <subdev/bios/init.h>
30 #include <subdev/bios/rammap.h>
31 #include <subdev/bios/timing.h>
33 #include <subdev/clock.h>
34 #include <subdev/clock/pll.h>
36 #include <subdev/timer.h>
38 #include <core/option.h>
44 /* binary driver only executes this path if the condition (a) is true
45 * for any configuration (combination of rammap+ramcfg+timing) that
46 * can be reached on a given card. for now, we will execute the branch
47 * unconditionally in the hope that a "false everywhere" in the bios
48 * tables doesn't actually mean "don't touch this".
55 struct nvbios_pll refpll;
56 struct nvbios_pll mempll;
58 struct ramfuc_reg r_gpioMV;
60 struct ramfuc_reg r_gpio2E;
62 struct ramfuc_reg r_gpiotrig;
64 struct ramfuc_reg r_0x132020;
65 struct ramfuc_reg r_0x132028;
66 struct ramfuc_reg r_0x132024;
67 struct ramfuc_reg r_0x132030;
68 struct ramfuc_reg r_0x132034;
69 struct ramfuc_reg r_0x132000;
70 struct ramfuc_reg r_0x132004;
71 struct ramfuc_reg r_0x132040;
73 struct ramfuc_reg r_0x10f248;
74 struct ramfuc_reg r_0x10f290;
75 struct ramfuc_reg r_0x10f294;
76 struct ramfuc_reg r_0x10f298;
77 struct ramfuc_reg r_0x10f29c;
78 struct ramfuc_reg r_0x10f2a0;
79 struct ramfuc_reg r_0x10f2a4;
80 struct ramfuc_reg r_0x10f2a8;
81 struct ramfuc_reg r_0x10f2ac;
82 struct ramfuc_reg r_0x10f2cc;
83 struct ramfuc_reg r_0x10f2e8;
84 struct ramfuc_reg r_0x10f250;
85 struct ramfuc_reg r_0x10f24c;
86 struct ramfuc_reg r_0x10fec4;
87 struct ramfuc_reg r_0x10fec8;
88 struct ramfuc_reg r_0x10f604;
89 struct ramfuc_reg r_0x10f614;
90 struct ramfuc_reg r_0x10f610;
91 struct ramfuc_reg r_0x100770;
92 struct ramfuc_reg r_0x100778;
93 struct ramfuc_reg r_0x10f224;
95 struct ramfuc_reg r_0x10f870;
96 struct ramfuc_reg r_0x10f698;
97 struct ramfuc_reg r_0x10f694;
98 struct ramfuc_reg r_0x10f6b8;
99 struct ramfuc_reg r_0x10f808;
100 struct ramfuc_reg r_0x10f670;
101 struct ramfuc_reg r_0x10f60c;
102 struct ramfuc_reg r_0x10f830;
103 struct ramfuc_reg r_0x1373ec;
104 struct ramfuc_reg r_0x10f800;
105 struct ramfuc_reg r_0x10f82c;
107 struct ramfuc_reg r_0x10f978;
108 struct ramfuc_reg r_0x10f910;
109 struct ramfuc_reg r_0x10f914;
111 struct ramfuc_reg r_mr[16]; /* MR0 - MR8, MR15 */
113 struct ramfuc_reg r_0x62c000;
115 struct ramfuc_reg r_0x10f200;
117 struct ramfuc_reg r_0x10f210;
118 struct ramfuc_reg r_0x10f310;
119 struct ramfuc_reg r_0x10f314;
120 struct ramfuc_reg r_0x10f318;
121 struct ramfuc_reg r_0x10f090;
122 struct ramfuc_reg r_0x10f69c;
123 struct ramfuc_reg r_0x10f824;
124 struct ramfuc_reg r_0x1373f0;
125 struct ramfuc_reg r_0x1373f4;
126 struct ramfuc_reg r_0x137320;
127 struct ramfuc_reg r_0x10f65c;
128 struct ramfuc_reg r_0x10f6bc;
129 struct ramfuc_reg r_0x100710;
130 struct ramfuc_reg r_0x100750;
134 struct nouveau_ram base;
135 struct nve0_ramfuc fuc;
147 /*******************************************************************************
149 ******************************************************************************/
151 nve0_ram_train(struct nve0_ramfuc *fuc, u32 mask, u32 data)
153 struct nve0_ram *ram = container_of(fuc, typeof(*ram), fuc);
154 u32 addr = 0x110974, i;
156 ram_mask(fuc, 0x10f910, mask, data);
157 ram_mask(fuc, 0x10f914, mask, data);
159 for (i = 0; (data & 0x80000000) && i < ram->parts; addr += 0x1000, i++) {
160 if (ram->pmask & (1 << i))
162 ram_wait(fuc, addr, 0x0000000f, 0x00000000, 500000);
167 r1373f4_init(struct nve0_ramfuc *fuc)
169 struct nve0_ram *ram = container_of(fuc, typeof(*ram), fuc);
170 const u32 mcoef = ((--ram->P2 << 28) | (ram->N2 << 8) | ram->M2);
171 const u32 rcoef = (( ram->P1 << 16) | (ram->N1 << 8) | ram->M1);
172 const u32 runk0 = ram->fN1 << 16;
173 const u32 runk1 = ram->fN1;
175 if (ram->from == 2) {
176 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00001100);
177 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00000010);
179 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010010);
182 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000000);
183 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000000);
185 /* (re)program refpll, if required */
186 if ((ram_rd32(fuc, 0x132024) & 0xffffffff) != rcoef ||
187 (ram_rd32(fuc, 0x132034) & 0x0000ffff) != runk1) {
188 ram_mask(fuc, 0x132000, 0x00000001, 0x00000000);
189 ram_mask(fuc, 0x132020, 0x00000001, 0x00000000);
190 ram_wr32(fuc, 0x137320, 0x00000000);
191 ram_mask(fuc, 0x132030, 0xffff0000, runk0);
192 ram_mask(fuc, 0x132034, 0x0000ffff, runk1);
193 ram_wr32(fuc, 0x132024, rcoef);
194 ram_mask(fuc, 0x132028, 0x00080000, 0x00080000);
195 ram_mask(fuc, 0x132020, 0x00000001, 0x00000001);
196 ram_wait(fuc, 0x137390, 0x00020000, 0x00020000, 64000);
197 ram_mask(fuc, 0x132028, 0x00080000, 0x00000000);
200 /* (re)program mempll, if required */
201 if (ram->mode == 2) {
202 ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000);
203 ram_mask(fuc, 0x132000, 0x00000001, 0x00000000);
204 ram_mask(fuc, 0x132004, 0x103fffff, mcoef);
205 ram_mask(fuc, 0x132000, 0x00000001, 0x00000001);
206 ram_wait(fuc, 0x137390, 0x00000002, 0x00000002, 64000);
207 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00001100);
209 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010100);
212 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00000010);
216 r1373f4_fini(struct nve0_ramfuc *fuc)
218 struct nve0_ram *ram = container_of(fuc, typeof(*ram), fuc);
219 struct nouveau_ram_data *next = ram->base.next;
220 u8 v0 = next->bios.ramcfg_11_03_c0;
221 u8 v1 = next->bios.ramcfg_11_03_30;
224 tmp = ram_rd32(fuc, 0x1373ec) & ~0x00030000;
225 ram_wr32(fuc, 0x1373ec, tmp | (v1 << 16));
226 ram_mask(fuc, 0x1373f0, (~ram->mode & 3), 0x00000000);
227 if (ram->mode == 2) {
228 ram_mask(fuc, 0x1373f4, 0x00000003, 0x000000002);
229 ram_mask(fuc, 0x1373f4, 0x00001100, 0x000000000);
231 ram_mask(fuc, 0x1373f4, 0x00000003, 0x000000001);
232 ram_mask(fuc, 0x1373f4, 0x00010000, 0x000000000);
234 ram_mask(fuc, 0x10f800, 0x00000030, (v0 ^ v1) << 4);
238 nve0_ram_nuts(struct nve0_ram *ram, struct ramfuc_reg *reg,
239 u32 _mask, u32 _data, u32 _copy)
241 struct nve0_fb_priv *priv = (void *)nouveau_fb(ram);
242 struct ramfuc *fuc = &ram->fuc.base;
243 u32 addr = 0x110000 + (reg->addr[0] & 0xfff);
244 u32 mask = _mask | _copy;
245 u32 data = (_data & _mask) | (reg->data & _copy);
248 for (i = 0; i < 16; i++, addr += 0x1000) {
249 if (ram->pnuts & (1 << i)) {
250 u32 prev = nv_rd32(priv, addr);
251 u32 next = (prev & ~mask) | data;
252 nouveau_memx_wr32(fuc->memx, addr, next);
256 #define ram_nuts(s,r,m,d,c) \
257 nve0_ram_nuts((s), &(s)->fuc.r_##r, (m), (d), (c))
260 nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
262 struct nve0_ram *ram = (void *)pfb->ram;
263 struct nve0_ramfuc *fuc = &ram->fuc;
264 struct nouveau_ram_data *next = ram->base.next;
265 int vc = !(next->bios.ramcfg_11_02_08);
266 int mv = 1; /*XXX: !(next->bios.ramcfg_11_02_04); */
269 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000);
270 ram_wr32(fuc, 0x62c000, 0x0f0f0000);
272 /* MR1: turn termination on early, for some reason.. */
273 if ((ram->base.mr[1] & 0x03c) != 0x030) {
274 ram_mask(fuc, mr[1], 0x03c, ram->base.mr[1] & 0x03c);
275 ram_nuts(ram, mr[1], 0x03c, ram->base.mr1_nuts & 0x03c, 0x000);
278 if (vc == 1 && ram_have(fuc, gpio2E)) {
279 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[1]);
280 if (temp != ram_rd32(fuc, gpio2E)) {
281 ram_wr32(fuc, gpiotrig, 1);
282 ram_nsec(fuc, 20000);
286 ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000);
288 nve0_ram_train(fuc, 0x01020000, 0x000c0000);
290 ram_wr32(fuc, 0x10f210, 0x00000000); /* REFRESH_AUTO = 0 */
292 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */
295 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000);
296 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */
297 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000);
298 ram_wr32(fuc, 0x10f090, 0x00000061);
299 ram_wr32(fuc, 0x10f090, 0xc000007f);
302 ram_wr32(fuc, 0x10f698, 0x00000000);
303 ram_wr32(fuc, 0x10f69c, 0x00000000);
305 /*XXX: there does appear to be some kind of condition here, simply
306 * modifying these bits in the vbios from the default pl0
307 * entries shows no change. however, the data does appear to
308 * be correct and may be required for the transition back
312 if (ram_rd32(fuc, 0x10f978) & 0x00800000)
317 switch (next->bios.ramcfg_11_03_c0) {
318 case 3: data &= ~0x00000040; break;
319 case 2: data &= ~0x00000100; break;
320 case 1: data &= ~0x80000000; break;
321 case 0: data &= ~0x00000400; break;
324 switch (next->bios.ramcfg_11_03_30) {
325 case 3: data &= ~0x00000020; break;
326 case 2: data &= ~0x00000080; break;
327 case 1: data &= ~0x00080000; break;
328 case 0: data &= ~0x00000200; break;
332 if (next->bios.ramcfg_11_02_80)
334 if (next->bios.ramcfg_11_02_40)
336 if (next->bios.ramcfg_11_07_10)
338 if (next->bios.ramcfg_11_07_08)
342 if (ram_rd32(fuc, 0x10f978) & 0x00800000)
345 ram_mask(fuc, 0x10f824, mask, data);
347 ram_mask(fuc, 0x132040, 0x00010000, 0x00000000);
349 if (ram->from == 2 && ram->mode != 2) {
350 ram_mask(fuc, 0x10f808, 0x00080000, 0x00000000);
351 ram_mask(fuc, 0x10f200, 0x00008000, 0x00008000);
352 ram_mask(fuc, 0x10f800, 0x00000000, 0x00000004);
353 ram_mask(fuc, 0x10f830, 0x00008000, 0x01040010);
354 ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000);
356 ram_mask(fuc, 0x1373f0, 0x00000002, 0x00000001);
358 ram_mask(fuc, 0x10f830, 0x00c00000, 0x00240001);
360 if (ram->from != 2 && ram->mode != 2) {
365 if (ram_have(fuc, gpioMV)) {
366 u32 temp = ram_mask(fuc, gpioMV, 0x3000, fuc->r_funcMV[mv]);
367 if (temp != ram_rd32(fuc, gpioMV)) {
368 ram_wr32(fuc, gpiotrig, 1);
369 ram_nsec(fuc, 64000);
373 if ( (next->bios.ramcfg_11_02_40) ||
374 (next->bios.ramcfg_11_07_10)) {
375 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000);
376 ram_nsec(fuc, 20000);
379 if (ram->from != 2 && ram->mode == 2) {
380 ram_mask(fuc, 0x10f800, 0x00000004, 0x00000000);
381 ram_mask(fuc, 0x1373f0, 0x00000000, 0x00000002);
382 ram_mask(fuc, 0x10f830, 0x00800001, 0x00408010);
385 ram_mask(fuc, 0x10f808, 0x00000000, 0x00080000);
386 ram_mask(fuc, 0x10f200, 0x00808000, 0x00800000);
388 if (ram->from == 2 && ram->mode == 2) {
389 ram_mask(fuc, 0x10f800, 0x00000004, 0x00000000);
394 if (ram->mode != 2) /*XXX*/ {
395 if (next->bios.ramcfg_11_07_40)
396 ram_mask(fuc, 0x10f670, 0x80000000, 0x80000000);
399 ram_wr32(fuc, 0x10f65c, 0x00000011 * next->bios.rammap_11_11_0c);
400 ram_wr32(fuc, 0x10f6b8, 0x01010101 * next->bios.ramcfg_11_09);
401 ram_wr32(fuc, 0x10f6bc, 0x01010101 * next->bios.ramcfg_11_09);
403 if (!next->bios.ramcfg_11_07_08) {
404 ram_wr32(fuc, 0x10f698, 0x01010101 * next->bios.ramcfg_11_04);
405 ram_wr32(fuc, 0x10f69c, 0x01010101 * next->bios.ramcfg_11_04);
408 if (ram->mode != 2) {
409 u32 data = 0x01000100 * next->bios.ramcfg_11_04;
410 ram_nuke(fuc, 0x10f694);
411 ram_mask(fuc, 0x10f694, 0xff00ff00, data);
414 if (ram->mode == 2 && (next->bios.ramcfg_11_08_10))
418 ram_mask(fuc, 0x10f60c, 0x00000080, data);
422 if (!(next->bios.ramcfg_11_02_80))
424 if (!(next->bios.ramcfg_11_02_40))
426 if (!(next->bios.ramcfg_11_07_10))
428 if (!(next->bios.ramcfg_11_07_08))
432 ram_mask(fuc, 0x10f824, mask, data);
434 if (next->bios.ramcfg_11_01_08)
438 ram_mask(fuc, 0x10f200, 0x00001000, data);
440 if (ram_rd32(fuc, 0x10f670) & 0x80000000) {
441 ram_nsec(fuc, 10000);
442 ram_mask(fuc, 0x10f670, 0x80000000, 0x00000000);
445 if (next->bios.ramcfg_11_08_01)
449 ram_mask(fuc, 0x10f82c, 0x00100000, data);
452 if (next->bios.ramcfg_11_08_08)
454 if (next->bios.ramcfg_11_08_04)
456 if (next->bios.ramcfg_11_08_02)
458 ram_mask(fuc, 0x10f830, 0x00007000, data);
461 ram_mask(fuc, 0x10f248, 0xffffffff, next->bios.timing[10]);
462 ram_mask(fuc, 0x10f290, 0xffffffff, next->bios.timing[0]);
463 ram_mask(fuc, 0x10f294, 0xffffffff, next->bios.timing[1]);
464 ram_mask(fuc, 0x10f298, 0xffffffff, next->bios.timing[2]);
465 ram_mask(fuc, 0x10f29c, 0xffffffff, next->bios.timing[3]);
466 ram_mask(fuc, 0x10f2a0, 0xffffffff, next->bios.timing[4]);
467 ram_mask(fuc, 0x10f2a4, 0xffffffff, next->bios.timing[5]);
468 ram_mask(fuc, 0x10f2a8, 0xffffffff, next->bios.timing[6]);
469 ram_mask(fuc, 0x10f2ac, 0xffffffff, next->bios.timing[7]);
470 ram_mask(fuc, 0x10f2cc, 0xffffffff, next->bios.timing[8]);
471 ram_mask(fuc, 0x10f2e8, 0xffffffff, next->bios.timing[9]);
473 data = mask = 0x00000000;
474 if (NOTE00(ramcfg_02_03 != 0)) {
475 data |= (next->bios.ramcfg_11_02_03) << 8;
478 if (NOTE00(ramcfg_01_10)) {
479 if (next->bios.ramcfg_11_01_10)
483 ram_mask(fuc, 0x10f604, mask, data);
485 data = mask = 0x00000000;
486 if (NOTE00(timing_30_07 != 0)) {
487 data |= (next->bios.timing_20_30_07) << 28;
490 if (NOTE00(ramcfg_01_01)) {
491 if (next->bios.ramcfg_11_01_01)
495 ram_mask(fuc, 0x10f614, mask, data);
497 data = mask = 0x00000000;
498 if (NOTE00(timing_30_07 != 0)) {
499 data |= (next->bios.timing_20_30_07) << 28;
502 if (NOTE00(ramcfg_01_02)) {
503 if (next->bios.ramcfg_11_01_02)
507 ram_mask(fuc, 0x10f610, mask, data);
511 if (!(next->bios.ramcfg_11_01_04))
513 if (!(next->bios.ramcfg_11_07_80))
515 /*XXX: see note above about there probably being some condition
516 * for the 10f824 stuff that uses ramcfg 3...
518 if ( (next->bios.ramcfg_11_03_f0)) {
519 if (next->bios.rammap_11_08_0c) {
520 if (!(next->bios.ramcfg_11_07_80))
531 ram_mask(fuc, 0x10f808, mask, data);
533 ram_wr32(fuc, 0x10f870, 0x11111111 * next->bios.ramcfg_11_03_0f);
535 data = mask = 0x00000000;
536 if (NOTE00(ramcfg_02_03 != 0)) {
537 data |= next->bios.ramcfg_11_02_03;
540 if (NOTE00(ramcfg_01_10)) {
541 if (next->bios.ramcfg_11_01_10)
546 if ((ram_mask(fuc, 0x100770, mask, data) & mask & 4) != (data & 4)) {
547 ram_mask(fuc, 0x100750, 0x00000008, 0x00000008);
548 ram_wr32(fuc, 0x100710, 0x00000000);
549 ram_wait(fuc, 0x100710, 0x80000000, 0x80000000, 200000);
552 data = (next->bios.timing_20_30_07) << 8;
553 if (next->bios.ramcfg_11_01_01)
555 ram_mask(fuc, 0x100778, 0x00000700, data);
557 ram_mask(fuc, 0x10f250, 0x000003f0, next->bios.timing_20_2c_003f << 4);
558 ram_mask(fuc, 0x10f24c, 0x7f000000, next->bios.timing_20_2c_1fc0 << 24);
559 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8 << 16);
561 ram_mask(fuc, 0x10fec4, 0x041e0f07, next->bios.timing_20_31_0800 << 26 |
562 next->bios.timing_20_31_0780 << 17 |
563 next->bios.timing_20_31_0078 << 8 |
564 next->bios.timing_20_31_0007);
565 ram_mask(fuc, 0x10fec8, 0x00000027, next->bios.timing_20_31_8000 << 5 |
566 next->bios.timing_20_31_7000);
568 ram_wr32(fuc, 0x10f090, 0x4000007e);
570 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */
571 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */
572 ram_wr32(fuc, 0x10f210, 0x80000000); /* REFRESH_AUTO = 1 */
574 if ((next->bios.ramcfg_11_08_10) && (ram->mode == 2) /*XXX*/) {
575 u32 temp = ram_mask(fuc, 0x10f294, 0xff000000, 0x24000000);
576 nve0_ram_train(fuc, 0xbc0e0000, 0xa4010000); /*XXX*/
578 ram_wr32(fuc, 0x10f294, temp);
581 ram_mask(fuc, mr[3], 0xfff, ram->base.mr[3]);
582 ram_wr32(fuc, mr[0], ram->base.mr[0]);
583 ram_mask(fuc, mr[8], 0xfff, ram->base.mr[8]);
585 ram_mask(fuc, mr[1], 0xfff, ram->base.mr[1]);
586 ram_mask(fuc, mr[5], 0xfff, ram->base.mr[5] & ~0x004); /* LP3 later */
587 ram_mask(fuc, mr[6], 0xfff, ram->base.mr[6]);
588 ram_mask(fuc, mr[7], 0xfff, ram->base.mr[7]);
590 if (vc == 0 && ram_have(fuc, gpio2E)) {
591 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[0]);
592 if (temp != ram_rd32(fuc, gpio2E)) {
593 ram_wr32(fuc, gpiotrig, 1);
594 ram_nsec(fuc, 20000);
598 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000);
599 ram_wr32(fuc, 0x10f318, 0x00000001); /* NOP? */
600 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000);
602 ram_nuts(ram, 0x10f200, 0x00808800, 0x00000000, 0x00808800);
604 data = ram_rd32(fuc, 0x10f978);
607 if (!(next->bios.ramcfg_11_07_08)) {
608 if (!(next->bios.ramcfg_11_07_04))
615 ram_wr32(fuc, 0x10f978, data);
617 if (ram->mode == 1) {
618 data = ram_rd32(fuc, 0x10f830) | 0x00000001;
619 ram_wr32(fuc, 0x10f830, data);
622 if (!(next->bios.ramcfg_11_07_08)) {
624 if ( (next->bios.ramcfg_11_07_04))
626 if (!(next->bios.rammap_11_08_10))
631 nve0_ram_train(fuc, 0xbc0f0000, data);
632 if (1) /* XXX: not always? */
635 if (ram->mode == 2) { /*XXX*/
636 ram_mask(fuc, 0x10f800, 0x00000004, 0x00000004);
640 if (ram_mask(fuc, mr[5], 0x004, ram->base.mr[5]) != ram->base.mr[5])
643 if (ram->mode != 2) {
644 ram_mask(fuc, 0x10f830, 0x01000000, 0x01000000);
645 ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000);
648 if (next->bios.ramcfg_11_07_02)
649 nve0_ram_train(fuc, 0x80020000, 0x01000000);
651 ram_wr32(fuc, 0x62c000, 0x0f0f0f00);
653 if (next->bios.rammap_11_08_01)
657 ram_mask(fuc, 0x10f200, 0x00000800, data);
658 ram_nuts(ram, 0x10f200, 0x00808800, data, 0x00808800);
662 /*******************************************************************************
664 ******************************************************************************/
667 nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
669 struct nve0_ram *ram = (void *)pfb->ram;
670 struct nve0_ramfuc *fuc = &ram->fuc;
671 const u32 rcoef = (( ram->P1 << 16) | (ram->N1 << 8) | ram->M1);
672 const u32 runk0 = ram->fN1 << 16;
673 const u32 runk1 = ram->fN1;
674 struct nouveau_ram_data *next = ram->base.next;
675 int vc = !(next->bios.ramcfg_11_02_08);
676 int mv = 1; /*XXX: !(next->bios.ramcfg_11_02_04); */
679 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000);
680 ram_wr32(fuc, 0x62c000, 0x0f0f0000);
682 if (vc == 1 && ram_have(fuc, gpio2E)) {
683 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[1]);
684 if (temp != ram_rd32(fuc, gpio2E)) {
685 ram_wr32(fuc, gpiotrig, 1);
686 ram_nsec(fuc, 20000);
690 ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000);
691 if ((next->bios.ramcfg_11_03_f0))
692 ram_mask(fuc, 0x10f808, 0x04000000, 0x04000000);
694 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */
695 ram_wr32(fuc, 0x10f210, 0x00000000); /* REFRESH_AUTO = 0 */
696 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */
697 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000);
698 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */
699 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000);
702 ram_wr32(fuc, 0x10f090, 0x00000060);
703 ram_wr32(fuc, 0x10f090, 0xc000007e);
705 /*XXX: there does appear to be some kind of condition here, simply
706 * modifying these bits in the vbios from the default pl0
707 * entries shows no change. however, the data does appear to
708 * be correct and may be required for the transition back
716 switch (next->bios.ramcfg_11_03_c0) {
717 case 3: data &= ~0x00000040; break;
718 case 2: data &= ~0x00000100; break;
719 case 1: data &= ~0x80000000; break;
720 case 0: data &= ~0x00000400; break;
723 switch (next->bios.ramcfg_11_03_30) {
724 case 3: data &= ~0x00000020; break;
725 case 2: data &= ~0x00000080; break;
726 case 1: data &= ~0x00080000; break;
727 case 0: data &= ~0x00000200; break;
731 if (next->bios.ramcfg_11_02_80)
733 if (next->bios.ramcfg_11_02_40)
735 if (next->bios.ramcfg_11_07_10)
737 if (next->bios.ramcfg_11_07_08)
741 ram_mask(fuc, 0x10f824, mask, data);
743 ram_mask(fuc, 0x132040, 0x00010000, 0x00000000);
745 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010010);
746 data = ram_rd32(fuc, 0x1373ec) & ~0x00030000;
747 data |= (next->bios.ramcfg_11_03_30) << 12;
748 ram_wr32(fuc, 0x1373ec, data);
749 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000000);
750 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000000);
752 /* (re)program refpll, if required */
753 if ((ram_rd32(fuc, 0x132024) & 0xffffffff) != rcoef ||
754 (ram_rd32(fuc, 0x132034) & 0x0000ffff) != runk1) {
755 ram_mask(fuc, 0x132000, 0x00000001, 0x00000000);
756 ram_mask(fuc, 0x132020, 0x00000001, 0x00000000);
757 ram_wr32(fuc, 0x137320, 0x00000000);
758 ram_mask(fuc, 0x132030, 0xffff0000, runk0);
759 ram_mask(fuc, 0x132034, 0x0000ffff, runk1);
760 ram_wr32(fuc, 0x132024, rcoef);
761 ram_mask(fuc, 0x132028, 0x00080000, 0x00080000);
762 ram_mask(fuc, 0x132020, 0x00000001, 0x00000001);
763 ram_wait(fuc, 0x137390, 0x00020000, 0x00020000, 64000);
764 ram_mask(fuc, 0x132028, 0x00080000, 0x00000000);
767 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000010);
768 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000001);
769 ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000);
771 if (ram_have(fuc, gpioMV)) {
772 u32 temp = ram_mask(fuc, gpioMV, 0x3000, fuc->r_funcMV[mv]);
773 if (temp != ram_rd32(fuc, gpioMV)) {
774 ram_wr32(fuc, gpiotrig, 1);
775 ram_nsec(fuc, 64000);
779 if ( (next->bios.ramcfg_11_02_40) ||
780 (next->bios.ramcfg_11_07_10)) {
781 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000);
782 ram_nsec(fuc, 20000);
785 if (ram->mode != 2) /*XXX*/ {
786 if (next->bios.ramcfg_11_07_40)
787 ram_mask(fuc, 0x10f670, 0x80000000, 0x80000000);
790 ram_wr32(fuc, 0x10f65c, 0x00000011 * next->bios.rammap_11_11_0c);
791 ram_wr32(fuc, 0x10f6b8, 0x01010101 * next->bios.ramcfg_11_09);
792 ram_wr32(fuc, 0x10f6bc, 0x01010101 * next->bios.ramcfg_11_09);
796 if (!(next->bios.ramcfg_11_02_80))
798 if (!(next->bios.ramcfg_11_02_40))
800 if (!(next->bios.ramcfg_11_07_10))
802 if (!(next->bios.ramcfg_11_07_08))
806 ram_mask(fuc, 0x10f824, mask, data);
809 if (next->bios.ramcfg_11_08_01)
813 ram_mask(fuc, 0x10f82c, 0x00100000, data);
816 ram_mask(fuc, 0x10f248, 0xffffffff, next->bios.timing[10]);
817 ram_mask(fuc, 0x10f290, 0xffffffff, next->bios.timing[0]);
818 ram_mask(fuc, 0x10f294, 0xffffffff, next->bios.timing[1]);
819 ram_mask(fuc, 0x10f298, 0xffffffff, next->bios.timing[2]);
820 ram_mask(fuc, 0x10f29c, 0xffffffff, next->bios.timing[3]);
821 ram_mask(fuc, 0x10f2a0, 0xffffffff, next->bios.timing[4]);
822 ram_mask(fuc, 0x10f2a4, 0xffffffff, next->bios.timing[5]);
823 ram_mask(fuc, 0x10f2a8, 0xffffffff, next->bios.timing[6]);
824 ram_mask(fuc, 0x10f2ac, 0xffffffff, next->bios.timing[7]);
825 ram_mask(fuc, 0x10f2cc, 0xffffffff, next->bios.timing[8]);
826 ram_mask(fuc, 0x10f2e8, 0xffffffff, next->bios.timing[9]);
830 if (!(next->bios.ramcfg_11_01_04))
832 if (!(next->bios.ramcfg_11_07_80))
834 /*XXX: see note above about there probably being some condition
835 * for the 10f824 stuff that uses ramcfg 3...
837 if ( (next->bios.ramcfg_11_03_f0)) {
838 if (next->bios.rammap_11_08_0c) {
839 if (!(next->bios.ramcfg_11_07_80))
851 ram_mask(fuc, 0x10f808, mask, data);
853 ram_wr32(fuc, 0x10f870, 0x11111111 * next->bios.ramcfg_11_03_0f);
855 ram_mask(fuc, 0x10f250, 0x000003f0, next->bios.timing_20_2c_003f << 4);
857 data = (next->bios.timing[10] & 0x7f000000) >> 24;
858 if ( next->bios.timing_20_2c_1fc0 > data)
859 data = next->bios.timing_20_2c_1fc0;
860 ram_mask(fuc, 0x10f24c, 0x7f000000, data << 24);
862 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8);
864 ram_wr32(fuc, 0x10f090, 0x4000007f);
867 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */
868 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */
869 ram_wr32(fuc, 0x10f210, 0x80000000); /* REFRESH_AUTO = 1 */
872 ram_nuke(fuc, mr[0]);
873 ram_mask(fuc, mr[0], 0x100, 0x100);
874 ram_mask(fuc, mr[0], 0x100, 0x000);
876 ram_mask(fuc, mr[2], 0xfff, ram->base.mr[2]);
877 ram_wr32(fuc, mr[0], ram->base.mr[0]);
880 ram_nuke(fuc, mr[0]);
881 ram_mask(fuc, mr[0], 0x100, 0x100);
882 ram_mask(fuc, mr[0], 0x100, 0x000);
884 if (vc == 0 && ram_have(fuc, gpio2E)) {
885 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[0]);
886 if (temp != ram_rd32(fuc, gpio2E)) {
887 ram_wr32(fuc, gpiotrig, 1);
888 ram_nsec(fuc, 20000);
892 if (ram->mode != 2) {
893 ram_mask(fuc, 0x10f830, 0x01000000, 0x01000000);
894 ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000);
897 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000);
898 ram_wr32(fuc, 0x10f318, 0x00000001); /* NOP? */
899 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000);
902 ram_wr32(fuc, 0x62c000, 0x0f0f0f00);
904 if (next->bios.rammap_11_08_01)
908 ram_mask(fuc, 0x10f200, 0x00000800, data);
912 /*******************************************************************************
914 ******************************************************************************/
917 nve0_ram_calc(struct nouveau_fb *pfb, u32 freq)
919 struct nouveau_bios *bios = nouveau_bios(pfb);
920 struct nve0_ram *ram = (void *)pfb->ram;
921 struct nve0_ramfuc *fuc = &ram->fuc;
922 int ret, refclk, strap, i;
925 /* lookup memory config data relevant to the target frequency */
926 ram->base.rammap.data = nvbios_rammapEp(bios, freq / 1000,
927 &ram->base.rammap.version,
928 &ram->base.rammap.size,
930 &ram->base.target.bios);
931 if (!ram->base.rammap.data || ram->base.rammap.version != 0x11 ||
932 ram->base.rammap.size < 0x09) {
933 nv_error(pfb, "invalid/missing rammap entry\n");
937 /* locate specific data set for the attached memory */
938 ram->base.ramcfg.data = nvbios_rammapSp(bios, ram->base.rammap.data,
939 ram->base.rammap.version,
940 ram->base.rammap.size, cnt, len,
941 nvbios_ramcfg_index(bios),
942 &ram->base.ramcfg.version,
943 &ram->base.ramcfg.size,
944 &ram->base.target.bios);
945 if (!ram->base.ramcfg.data || ram->base.ramcfg.version != 0x11 ||
946 ram->base.ramcfg.size < 0x08) {
947 nv_error(pfb, "invalid/missing ramcfg entry\n");
951 /* lookup memory timings, if bios says they're present */
952 strap = nv_ro08(bios, ram->base.ramcfg.data + 0x00);
954 ram->base.timing.data =
955 nvbios_timingEp(bios, strap, &ram->base.timing.version,
956 &ram->base.timing.size, &cnt, &len,
957 &ram->base.target.bios);
958 if (!ram->base.timing.data ||
959 ram->base.timing.version != 0x20 ||
960 ram->base.timing.size < 0x33) {
961 nv_error(pfb, "invalid/missing timing entry\n");
965 ram->base.timing.data = 0;
968 ram->base.next = &ram->base.target;
970 ret = ram_init(fuc, pfb);
974 ram->mode = (freq > fuc->refpll.vco1.max_freq) ? 2 : 1;
975 ram->from = ram_rd32(fuc, 0x1373f4) & 0x0000000f;
977 /* XXX: this is *not* what nvidia do. on fermi nvidia generally
978 * select, based on some unknown condition, one of the two possible
979 * reference frequencies listed in the vbios table for mempll and
980 * program refpll to that frequency.
982 * so far, i've seen very weird values being chosen by nvidia on
983 * kepler boards, no idea how/why they're chosen.
987 refclk = fuc->mempll.refclk;
989 /* calculate refpll coefficients */
990 ret = nva3_pll_calc(nv_subdev(pfb), &fuc->refpll, refclk, &ram->N1,
991 &ram->fN1, &ram->M1, &ram->P1);
992 fuc->mempll.refclk = ret;
994 nv_error(pfb, "unable to calc refpll\n");
998 /* calculate mempll coefficients, if we're using it */
999 if (ram->mode == 2) {
1000 /* post-divider doesn't work... the reg takes the values but
1001 * appears to completely ignore it. there *is* a bit at
1002 * bit 28 that appears to divide the clock by 2 if set.
1004 fuc->mempll.min_p = 1;
1005 fuc->mempll.max_p = 2;
1007 ret = nva3_pll_calc(nv_subdev(pfb), &fuc->mempll, freq,
1008 &ram->N2, NULL, &ram->M2, &ram->P2);
1010 nv_error(pfb, "unable to calc mempll\n");
1015 for (i = 0; i < ARRAY_SIZE(fuc->r_mr); i++) {
1016 if (ram_have(fuc, mr[i]))
1017 ram->base.mr[i] = ram_rd32(fuc, mr[i]);
1019 ram->base.freq = freq;
1021 switch (ram->base.type) {
1022 case NV_MEM_TYPE_DDR3:
1023 ret = nouveau_sddr3_calc(&ram->base);
1025 ret = nve0_ram_calc_sddr3(pfb, freq);
1027 case NV_MEM_TYPE_GDDR5:
1028 ret = nouveau_gddr5_calc(&ram->base, ram->pnuts != 0);
1030 ret = nve0_ram_calc_gddr5(pfb, freq);
1041 nve0_ram_prog(struct nouveau_fb *pfb)
1043 struct nouveau_device *device = nv_device(pfb);
1044 struct nve0_ram *ram = (void *)pfb->ram;
1045 struct nve0_ramfuc *fuc = &ram->fuc;
1046 ram_exec(fuc, nouveau_boolopt(device->cfgopt, "NvMemExec", false));
1051 nve0_ram_tidy(struct nouveau_fb *pfb)
1053 struct nve0_ram *ram = (void *)pfb->ram;
1054 struct nve0_ramfuc *fuc = &ram->fuc;
1055 ram_exec(fuc, false);
1059 nve0_ram_init(struct nouveau_object *object)
1061 struct nouveau_fb *pfb = (void *)object->parent;
1062 struct nve0_ram *ram = (void *)object;
1063 struct nouveau_bios *bios = nouveau_bios(pfb);
1064 static const u8 train0[] = {
1065 0x00, 0xff, 0xff, 0x00, 0xff, 0x00,
1066 0x00, 0xff, 0xff, 0x00, 0xff, 0x00,
1068 static const u32 train1[] = {
1069 0x00000000, 0xffffffff,
1070 0x55555555, 0xaaaaaaaa,
1071 0x33333333, 0xcccccccc,
1072 0xf0f0f0f0, 0x0f0f0f0f,
1073 0x00ff00ff, 0xff00ff00,
1074 0x0000ffff, 0xffff0000,
1076 u8 ver, hdr, cnt, len, snr, ssz;
1080 ret = nouveau_ram_init(&ram->base);
1084 /* run a bunch of tables from rammap table. there's actually
1085 * individual pointers for each rammap entry too, but, nvidia
1086 * seem to just run the last two entries' scripts early on in
1087 * their init, and never again.. we'll just run 'em all once
1090 * i strongly suspect that each script is for a separate mode
1091 * (likely selected by 0x10f65c's lower bits?), and the
1092 * binary driver skips the one that's already been setup by
1095 data = nvbios_rammapTe(bios, &ver, &hdr, &cnt, &len, &snr, &ssz);
1096 if (!data || hdr < 0x15)
1099 cnt = nv_ro08(bios, data + 0x14); /* guess at count */
1100 data = nv_ro32(bios, data + 0x10); /* guess u32... */
1101 save = nv_rd32(pfb, 0x10f65c);
1102 for (i = 0; i < cnt; i++) {
1103 nv_mask(pfb, 0x10f65c, 0x000000f0, i << 4);
1104 nvbios_exec(&(struct nvbios_init) {
1105 .subdev = nv_subdev(pfb),
1107 .offset = nv_ro32(bios, data), /* guess u32 */
1112 nv_wr32(pfb, 0x10f65c, save);
1114 switch (ram->base.type) {
1115 case NV_MEM_TYPE_GDDR5:
1116 for (i = 0; i < 0x30; i++) {
1117 nv_wr32(pfb, 0x10f968, 0x00000000 | (i << 8));
1118 nv_wr32(pfb, 0x10f920, 0x00000000 | train0[i % 12]);
1119 nv_wr32(pfb, 0x10f918, train1[i % 12]);
1120 nv_wr32(pfb, 0x10f920, 0x00000100 | train0[i % 12]);
1121 nv_wr32(pfb, 0x10f918, train1[i % 12]);
1123 nv_wr32(pfb, 0x10f96c, 0x00000000 | (i << 8));
1124 nv_wr32(pfb, 0x10f924, 0x00000000 | train0[i % 12]);
1125 nv_wr32(pfb, 0x10f91c, train1[i % 12]);
1126 nv_wr32(pfb, 0x10f924, 0x00000100 | train0[i % 12]);
1127 nv_wr32(pfb, 0x10f91c, train1[i % 12]);
1130 for (i = 0; i < 0x100; i++) {
1131 nv_wr32(pfb, 0x10f968, i);
1132 nv_wr32(pfb, 0x10f900, train1[2 + (i & 1)]);
1135 for (i = 0; i < 0x100; i++) {
1136 nv_wr32(pfb, 0x10f96c, i);
1137 nv_wr32(pfb, 0x10f900, train1[2 + (i & 1)]);
1148 nve0_ram_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
1149 struct nouveau_oclass *oclass, void *data, u32 size,
1150 struct nouveau_object **pobject)
1152 struct nouveau_fb *pfb = nouveau_fb(parent);
1153 struct nouveau_bios *bios = nouveau_bios(pfb);
1154 struct nouveau_gpio *gpio = nouveau_gpio(pfb);
1155 struct dcb_gpio_func func;
1156 struct nve0_ram *ram;
1160 ret = nvc0_ram_create(parent, engine, oclass, &ram);
1161 *pobject = nv_object(ram);
1165 switch (ram->base.type) {
1166 case NV_MEM_TYPE_DDR3:
1167 case NV_MEM_TYPE_GDDR5:
1168 ram->base.calc = nve0_ram_calc;
1169 ram->base.prog = nve0_ram_prog;
1170 ram->base.tidy = nve0_ram_tidy;
1173 nv_warn(pfb, "reclocking of this RAM type is unsupported\n");
1177 /* calculate a mask of differently configured memory partitions,
1178 * because, of course reclocking wasn't complicated enough
1179 * already without having to treat some of them differently to
1182 ram->parts = nv_rd32(pfb, 0x022438);
1183 ram->pmask = nv_rd32(pfb, 0x022554);
1185 for (i = 0, tmp = 0; i < ram->parts; i++) {
1186 if (!(ram->pmask & (1 << i))) {
1187 u32 cfg1 = nv_rd32(pfb, 0x110204 + (i * 0x1000));
1188 if (tmp && tmp != cfg1) {
1189 ram->pnuts |= (1 << i);
1196 // parse bios data for both pll's
1197 ret = nvbios_pll_parse(bios, 0x0c, &ram->fuc.refpll);
1199 nv_error(pfb, "mclk refpll data not found\n");
1203 ret = nvbios_pll_parse(bios, 0x04, &ram->fuc.mempll);
1205 nv_error(pfb, "mclk pll data not found\n");
1209 ret = gpio->find(gpio, 0, 0x18, DCB_GPIO_UNUSED, &func);
1211 ram->fuc.r_gpioMV = ramfuc_reg(0x00d610 + (func.line * 0x04));
1212 ram->fuc.r_funcMV[0] = (func.log[0] ^ 2) << 12;
1213 ram->fuc.r_funcMV[1] = (func.log[1] ^ 2) << 12;
1216 ret = gpio->find(gpio, 0, 0x2e, DCB_GPIO_UNUSED, &func);
1218 ram->fuc.r_gpio2E = ramfuc_reg(0x00d610 + (func.line * 0x04));
1219 ram->fuc.r_func2E[0] = (func.log[0] ^ 2) << 12;
1220 ram->fuc.r_func2E[1] = (func.log[1] ^ 2) << 12;
1223 ram->fuc.r_gpiotrig = ramfuc_reg(0x00d604);
1225 ram->fuc.r_0x132020 = ramfuc_reg(0x132020);
1226 ram->fuc.r_0x132028 = ramfuc_reg(0x132028);
1227 ram->fuc.r_0x132024 = ramfuc_reg(0x132024);
1228 ram->fuc.r_0x132030 = ramfuc_reg(0x132030);
1229 ram->fuc.r_0x132034 = ramfuc_reg(0x132034);
1230 ram->fuc.r_0x132000 = ramfuc_reg(0x132000);
1231 ram->fuc.r_0x132004 = ramfuc_reg(0x132004);
1232 ram->fuc.r_0x132040 = ramfuc_reg(0x132040);
1234 ram->fuc.r_0x10f248 = ramfuc_reg(0x10f248);
1235 ram->fuc.r_0x10f290 = ramfuc_reg(0x10f290);
1236 ram->fuc.r_0x10f294 = ramfuc_reg(0x10f294);
1237 ram->fuc.r_0x10f298 = ramfuc_reg(0x10f298);
1238 ram->fuc.r_0x10f29c = ramfuc_reg(0x10f29c);
1239 ram->fuc.r_0x10f2a0 = ramfuc_reg(0x10f2a0);
1240 ram->fuc.r_0x10f2a4 = ramfuc_reg(0x10f2a4);
1241 ram->fuc.r_0x10f2a8 = ramfuc_reg(0x10f2a8);
1242 ram->fuc.r_0x10f2ac = ramfuc_reg(0x10f2ac);
1243 ram->fuc.r_0x10f2cc = ramfuc_reg(0x10f2cc);
1244 ram->fuc.r_0x10f2e8 = ramfuc_reg(0x10f2e8);
1245 ram->fuc.r_0x10f250 = ramfuc_reg(0x10f250);
1246 ram->fuc.r_0x10f24c = ramfuc_reg(0x10f24c);
1247 ram->fuc.r_0x10fec4 = ramfuc_reg(0x10fec4);
1248 ram->fuc.r_0x10fec8 = ramfuc_reg(0x10fec8);
1249 ram->fuc.r_0x10f604 = ramfuc_reg(0x10f604);
1250 ram->fuc.r_0x10f614 = ramfuc_reg(0x10f614);
1251 ram->fuc.r_0x10f610 = ramfuc_reg(0x10f610);
1252 ram->fuc.r_0x100770 = ramfuc_reg(0x100770);
1253 ram->fuc.r_0x100778 = ramfuc_reg(0x100778);
1254 ram->fuc.r_0x10f224 = ramfuc_reg(0x10f224);
1256 ram->fuc.r_0x10f870 = ramfuc_reg(0x10f870);
1257 ram->fuc.r_0x10f698 = ramfuc_reg(0x10f698);
1258 ram->fuc.r_0x10f694 = ramfuc_reg(0x10f694);
1259 ram->fuc.r_0x10f6b8 = ramfuc_reg(0x10f6b8);
1260 ram->fuc.r_0x10f808 = ramfuc_reg(0x10f808);
1261 ram->fuc.r_0x10f670 = ramfuc_reg(0x10f670);
1262 ram->fuc.r_0x10f60c = ramfuc_reg(0x10f60c);
1263 ram->fuc.r_0x10f830 = ramfuc_reg(0x10f830);
1264 ram->fuc.r_0x1373ec = ramfuc_reg(0x1373ec);
1265 ram->fuc.r_0x10f800 = ramfuc_reg(0x10f800);
1266 ram->fuc.r_0x10f82c = ramfuc_reg(0x10f82c);
1268 ram->fuc.r_0x10f978 = ramfuc_reg(0x10f978);
1269 ram->fuc.r_0x10f910 = ramfuc_reg(0x10f910);
1270 ram->fuc.r_0x10f914 = ramfuc_reg(0x10f914);
1272 switch (ram->base.type) {
1273 case NV_MEM_TYPE_GDDR5:
1274 ram->fuc.r_mr[0] = ramfuc_reg(0x10f300);
1275 ram->fuc.r_mr[1] = ramfuc_reg(0x10f330);
1276 ram->fuc.r_mr[2] = ramfuc_reg(0x10f334);
1277 ram->fuc.r_mr[3] = ramfuc_reg(0x10f338);
1278 ram->fuc.r_mr[4] = ramfuc_reg(0x10f33c);
1279 ram->fuc.r_mr[5] = ramfuc_reg(0x10f340);
1280 ram->fuc.r_mr[6] = ramfuc_reg(0x10f344);
1281 ram->fuc.r_mr[7] = ramfuc_reg(0x10f348);
1282 ram->fuc.r_mr[8] = ramfuc_reg(0x10f354);
1283 ram->fuc.r_mr[15] = ramfuc_reg(0x10f34c);
1285 case NV_MEM_TYPE_DDR3:
1286 ram->fuc.r_mr[0] = ramfuc_reg(0x10f300);
1287 ram->fuc.r_mr[2] = ramfuc_reg(0x10f320);
1293 ram->fuc.r_0x62c000 = ramfuc_reg(0x62c000);
1294 ram->fuc.r_0x10f200 = ramfuc_reg(0x10f200);
1295 ram->fuc.r_0x10f210 = ramfuc_reg(0x10f210);
1296 ram->fuc.r_0x10f310 = ramfuc_reg(0x10f310);
1297 ram->fuc.r_0x10f314 = ramfuc_reg(0x10f314);
1298 ram->fuc.r_0x10f318 = ramfuc_reg(0x10f318);
1299 ram->fuc.r_0x10f090 = ramfuc_reg(0x10f090);
1300 ram->fuc.r_0x10f69c = ramfuc_reg(0x10f69c);
1301 ram->fuc.r_0x10f824 = ramfuc_reg(0x10f824);
1302 ram->fuc.r_0x1373f0 = ramfuc_reg(0x1373f0);
1303 ram->fuc.r_0x1373f4 = ramfuc_reg(0x1373f4);
1304 ram->fuc.r_0x137320 = ramfuc_reg(0x137320);
1305 ram->fuc.r_0x10f65c = ramfuc_reg(0x10f65c);
1306 ram->fuc.r_0x10f6bc = ramfuc_reg(0x10f6bc);
1307 ram->fuc.r_0x100710 = ramfuc_reg(0x100710);
1308 ram->fuc.r_0x100750 = ramfuc_reg(0x100750);
1312 struct nouveau_oclass
1315 .ofuncs = &(struct nouveau_ofuncs) {
1316 .ctor = nve0_ram_ctor,
1317 .dtor = _nouveau_ram_dtor,
1318 .init = nve0_ram_init,
1319 .fini = _nouveau_ram_fini,