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 #include "ramfuc.h" 25 #include "gf100.h" 26 27 #include <core/option.h> 28 #include <subdev/bios.h> 29 #include <subdev/bios/init.h> 30 #include <subdev/bios/M0205.h> 31 #include <subdev/bios/M0209.h> 32 #include <subdev/bios/pll.h> 33 #include <subdev/bios/rammap.h> 34 #include <subdev/bios/timing.h> 35 #include <subdev/clk.h> 36 #include <subdev/clk/pll.h> 37 #include <subdev/gpio.h> 38 39 struct gk104_ramfuc { 40 struct ramfuc base; 41 42 struct nvbios_pll refpll; 43 struct nvbios_pll mempll; 44 45 struct ramfuc_reg r_gpioMV; 46 u32 r_funcMV[2]; 47 struct ramfuc_reg r_gpio2E; 48 u32 r_func2E[2]; 49 struct ramfuc_reg r_gpiotrig; 50 51 struct ramfuc_reg r_0x132020; 52 struct ramfuc_reg r_0x132028; 53 struct ramfuc_reg r_0x132024; 54 struct ramfuc_reg r_0x132030; 55 struct ramfuc_reg r_0x132034; 56 struct ramfuc_reg r_0x132000; 57 struct ramfuc_reg r_0x132004; 58 struct ramfuc_reg r_0x132040; 59 60 struct ramfuc_reg r_0x10f248; 61 struct ramfuc_reg r_0x10f290; 62 struct ramfuc_reg r_0x10f294; 63 struct ramfuc_reg r_0x10f298; 64 struct ramfuc_reg r_0x10f29c; 65 struct ramfuc_reg r_0x10f2a0; 66 struct ramfuc_reg r_0x10f2a4; 67 struct ramfuc_reg r_0x10f2a8; 68 struct ramfuc_reg r_0x10f2ac; 69 struct ramfuc_reg r_0x10f2cc; 70 struct ramfuc_reg r_0x10f2e8; 71 struct ramfuc_reg r_0x10f250; 72 struct ramfuc_reg r_0x10f24c; 73 struct ramfuc_reg r_0x10fec4; 74 struct ramfuc_reg r_0x10fec8; 75 struct ramfuc_reg r_0x10f604; 76 struct ramfuc_reg r_0x10f614; 77 struct ramfuc_reg r_0x10f610; 78 struct ramfuc_reg r_0x100770; 79 struct ramfuc_reg r_0x100778; 80 struct ramfuc_reg r_0x10f224; 81 82 struct ramfuc_reg r_0x10f870; 83 struct ramfuc_reg r_0x10f698; 84 struct ramfuc_reg r_0x10f694; 85 struct ramfuc_reg r_0x10f6b8; 86 struct ramfuc_reg r_0x10f808; 87 struct ramfuc_reg r_0x10f670; 88 struct ramfuc_reg r_0x10f60c; 89 struct ramfuc_reg r_0x10f830; 90 struct ramfuc_reg r_0x1373ec; 91 struct ramfuc_reg r_0x10f800; 92 struct ramfuc_reg r_0x10f82c; 93 94 struct ramfuc_reg r_0x10f978; 95 struct ramfuc_reg r_0x10f910; 96 struct ramfuc_reg r_0x10f914; 97 98 struct ramfuc_reg r_mr[16]; /* MR0 - MR8, MR15 */ 99 100 struct ramfuc_reg r_0x62c000; 101 102 struct ramfuc_reg r_0x10f200; 103 104 struct ramfuc_reg r_0x10f210; 105 struct ramfuc_reg r_0x10f310; 106 struct ramfuc_reg r_0x10f314; 107 struct ramfuc_reg r_0x10f318; 108 struct ramfuc_reg r_0x10f090; 109 struct ramfuc_reg r_0x10f69c; 110 struct ramfuc_reg r_0x10f824; 111 struct ramfuc_reg r_0x1373f0; 112 struct ramfuc_reg r_0x1373f4; 113 struct ramfuc_reg r_0x137320; 114 struct ramfuc_reg r_0x10f65c; 115 struct ramfuc_reg r_0x10f6bc; 116 struct ramfuc_reg r_0x100710; 117 struct ramfuc_reg r_0x100750; 118 }; 119 120 struct gk104_ram { 121 struct nvkm_ram base; 122 struct gk104_ramfuc fuc; 123 124 struct list_head cfg; 125 u32 parts; 126 u32 pmask; 127 u32 pnuts; 128 129 struct nvbios_ramcfg diff; 130 int from; 131 int mode; 132 int N1, fN1, M1, P1; 133 int N2, M2, P2; 134 }; 135 136 /******************************************************************************* 137 * GDDR5 138 ******************************************************************************/ 139 static void 140 gk104_ram_train(struct gk104_ramfuc *fuc, u32 mask, u32 data) 141 { 142 struct gk104_ram *ram = container_of(fuc, typeof(*ram), fuc); 143 u32 addr = 0x110974, i; 144 145 ram_mask(fuc, 0x10f910, mask, data); 146 ram_mask(fuc, 0x10f914, mask, data); 147 148 for (i = 0; (data & 0x80000000) && i < ram->parts; addr += 0x1000, i++) { 149 if (ram->pmask & (1 << i)) 150 continue; 151 ram_wait(fuc, addr, 0x0000000f, 0x00000000, 500000); 152 } 153 } 154 155 static void 156 r1373f4_init(struct gk104_ramfuc *fuc) 157 { 158 struct gk104_ram *ram = container_of(fuc, typeof(*ram), fuc); 159 const u32 mcoef = ((--ram->P2 << 28) | (ram->N2 << 8) | ram->M2); 160 const u32 rcoef = (( ram->P1 << 16) | (ram->N1 << 8) | ram->M1); 161 const u32 runk0 = ram->fN1 << 16; 162 const u32 runk1 = ram->fN1; 163 164 if (ram->from == 2) { 165 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00001100); 166 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00000010); 167 } else { 168 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010010); 169 } 170 171 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000000); 172 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000000); 173 174 /* (re)program refpll, if required */ 175 if ((ram_rd32(fuc, 0x132024) & 0xffffffff) != rcoef || 176 (ram_rd32(fuc, 0x132034) & 0x0000ffff) != runk1) { 177 ram_mask(fuc, 0x132000, 0x00000001, 0x00000000); 178 ram_mask(fuc, 0x132020, 0x00000001, 0x00000000); 179 ram_wr32(fuc, 0x137320, 0x00000000); 180 ram_mask(fuc, 0x132030, 0xffff0000, runk0); 181 ram_mask(fuc, 0x132034, 0x0000ffff, runk1); 182 ram_wr32(fuc, 0x132024, rcoef); 183 ram_mask(fuc, 0x132028, 0x00080000, 0x00080000); 184 ram_mask(fuc, 0x132020, 0x00000001, 0x00000001); 185 ram_wait(fuc, 0x137390, 0x00020000, 0x00020000, 64000); 186 ram_mask(fuc, 0x132028, 0x00080000, 0x00000000); 187 } 188 189 /* (re)program mempll, if required */ 190 if (ram->mode == 2) { 191 ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000); 192 ram_mask(fuc, 0x132000, 0x80000000, 0x80000000); 193 ram_mask(fuc, 0x132000, 0x00000001, 0x00000000); 194 ram_mask(fuc, 0x132004, 0x103fffff, mcoef); 195 ram_mask(fuc, 0x132000, 0x00000001, 0x00000001); 196 ram_wait(fuc, 0x137390, 0x00000002, 0x00000002, 64000); 197 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00001100); 198 } else { 199 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010100); 200 } 201 202 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00000010); 203 } 204 205 static void 206 r1373f4_fini(struct gk104_ramfuc *fuc) 207 { 208 struct gk104_ram *ram = container_of(fuc, typeof(*ram), fuc); 209 struct nvkm_ram_data *next = ram->base.next; 210 u8 v0 = next->bios.ramcfg_11_03_c0; 211 u8 v1 = next->bios.ramcfg_11_03_30; 212 u32 tmp; 213 214 tmp = ram_rd32(fuc, 0x1373ec) & ~0x00030000; 215 ram_wr32(fuc, 0x1373ec, tmp | (v1 << 16)); 216 ram_mask(fuc, 0x1373f0, (~ram->mode & 3), 0x00000000); 217 if (ram->mode == 2) { 218 ram_mask(fuc, 0x1373f4, 0x00000003, 0x000000002); 219 ram_mask(fuc, 0x1373f4, 0x00001100, 0x000000000); 220 } else { 221 ram_mask(fuc, 0x1373f4, 0x00000003, 0x000000001); 222 ram_mask(fuc, 0x1373f4, 0x00010000, 0x000000000); 223 } 224 ram_mask(fuc, 0x10f800, 0x00000030, (v0 ^ v1) << 4); 225 } 226 227 static void 228 gk104_ram_nuts(struct gk104_ram *ram, struct ramfuc_reg *reg, 229 u32 _mask, u32 _data, u32 _copy) 230 { 231 struct nvkm_fb *fb = nvkm_fb(ram); 232 struct ramfuc *fuc = &ram->fuc.base; 233 struct nvkm_device *device = fb->subdev.device; 234 u32 addr = 0x110000 + (reg->addr & 0xfff); 235 u32 mask = _mask | _copy; 236 u32 data = (_data & _mask) | (reg->data & _copy); 237 u32 i; 238 239 for (i = 0; i < 16; i++, addr += 0x1000) { 240 if (ram->pnuts & (1 << i)) { 241 u32 prev = nvkm_rd32(device, addr); 242 u32 next = (prev & ~mask) | data; 243 nvkm_memx_wr32(fuc->memx, addr, next); 244 } 245 } 246 } 247 #define ram_nuts(s,r,m,d,c) \ 248 gk104_ram_nuts((s), &(s)->fuc.r_##r, (m), (d), (c)) 249 250 static int 251 gk104_ram_calc_gddr5(struct nvkm_fb *fb, u32 freq) 252 { 253 struct gk104_ram *ram = (void *)fb->ram; 254 struct gk104_ramfuc *fuc = &ram->fuc; 255 struct nvkm_ram_data *next = ram->base.next; 256 int vc = !next->bios.ramcfg_11_02_08; 257 int mv = !next->bios.ramcfg_11_02_04; 258 u32 mask, data; 259 260 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000); 261 ram_block(fuc); 262 ram_wr32(fuc, 0x62c000, 0x0f0f0000); 263 264 /* MR1: turn termination on early, for some reason.. */ 265 if ((ram->base.mr[1] & 0x03c) != 0x030) { 266 ram_mask(fuc, mr[1], 0x03c, ram->base.mr[1] & 0x03c); 267 ram_nuts(ram, mr[1], 0x03c, ram->base.mr1_nuts & 0x03c, 0x000); 268 } 269 270 if (vc == 1 && ram_have(fuc, gpio2E)) { 271 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[1]); 272 if (temp != ram_rd32(fuc, gpio2E)) { 273 ram_wr32(fuc, gpiotrig, 1); 274 ram_nsec(fuc, 20000); 275 } 276 } 277 278 ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000); 279 280 gk104_ram_train(fuc, 0x01020000, 0x000c0000); 281 282 ram_wr32(fuc, 0x10f210, 0x00000000); /* REFRESH_AUTO = 0 */ 283 ram_nsec(fuc, 1000); 284 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */ 285 ram_nsec(fuc, 1000); 286 287 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000); 288 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */ 289 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000); 290 ram_wr32(fuc, 0x10f090, 0x00000061); 291 ram_wr32(fuc, 0x10f090, 0xc000007f); 292 ram_nsec(fuc, 1000); 293 294 ram_wr32(fuc, 0x10f698, 0x00000000); 295 ram_wr32(fuc, 0x10f69c, 0x00000000); 296 297 /*XXX: there does appear to be some kind of condition here, simply 298 * modifying these bits in the vbios from the default pl0 299 * entries shows no change. however, the data does appear to 300 * be correct and may be required for the transition back 301 */ 302 mask = 0x800f07e0; 303 data = 0x00030000; 304 if (ram_rd32(fuc, 0x10f978) & 0x00800000) 305 data |= 0x00040000; 306 307 if (1) { 308 data |= 0x800807e0; 309 switch (next->bios.ramcfg_11_03_c0) { 310 case 3: data &= ~0x00000040; break; 311 case 2: data &= ~0x00000100; break; 312 case 1: data &= ~0x80000000; break; 313 case 0: data &= ~0x00000400; break; 314 } 315 316 switch (next->bios.ramcfg_11_03_30) { 317 case 3: data &= ~0x00000020; break; 318 case 2: data &= ~0x00000080; break; 319 case 1: data &= ~0x00080000; break; 320 case 0: data &= ~0x00000200; break; 321 } 322 } 323 324 if (next->bios.ramcfg_11_02_80) 325 mask |= 0x03000000; 326 if (next->bios.ramcfg_11_02_40) 327 mask |= 0x00002000; 328 if (next->bios.ramcfg_11_07_10) 329 mask |= 0x00004000; 330 if (next->bios.ramcfg_11_07_08) 331 mask |= 0x00000003; 332 else { 333 mask |= 0x34000000; 334 if (ram_rd32(fuc, 0x10f978) & 0x00800000) 335 mask |= 0x40000000; 336 } 337 ram_mask(fuc, 0x10f824, mask, data); 338 339 ram_mask(fuc, 0x132040, 0x00010000, 0x00000000); 340 341 if (ram->from == 2 && ram->mode != 2) { 342 ram_mask(fuc, 0x10f808, 0x00080000, 0x00000000); 343 ram_mask(fuc, 0x10f200, 0x18008000, 0x00008000); 344 ram_mask(fuc, 0x10f800, 0x00000000, 0x00000004); 345 ram_mask(fuc, 0x10f830, 0x00008000, 0x01040010); 346 ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000); 347 r1373f4_init(fuc); 348 ram_mask(fuc, 0x1373f0, 0x00000002, 0x00000001); 349 r1373f4_fini(fuc); 350 ram_mask(fuc, 0x10f830, 0x00c00000, 0x00240001); 351 } else 352 if (ram->from != 2 && ram->mode != 2) { 353 r1373f4_init(fuc); 354 r1373f4_fini(fuc); 355 } 356 357 if (ram_have(fuc, gpioMV)) { 358 u32 temp = ram_mask(fuc, gpioMV, 0x3000, fuc->r_funcMV[mv]); 359 if (temp != ram_rd32(fuc, gpioMV)) { 360 ram_wr32(fuc, gpiotrig, 1); 361 ram_nsec(fuc, 64000); 362 } 363 } 364 365 if (next->bios.ramcfg_11_02_40 || 366 next->bios.ramcfg_11_07_10) { 367 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000); 368 ram_nsec(fuc, 20000); 369 } 370 371 if (ram->from != 2 && ram->mode == 2) { 372 if (0 /*XXX: Titan */) 373 ram_mask(fuc, 0x10f200, 0x18000000, 0x18000000); 374 ram_mask(fuc, 0x10f800, 0x00000004, 0x00000000); 375 ram_mask(fuc, 0x1373f0, 0x00000000, 0x00000002); 376 ram_mask(fuc, 0x10f830, 0x00800001, 0x00408010); 377 r1373f4_init(fuc); 378 r1373f4_fini(fuc); 379 ram_mask(fuc, 0x10f808, 0x00000000, 0x00080000); 380 ram_mask(fuc, 0x10f200, 0x00808000, 0x00800000); 381 } else 382 if (ram->from == 2 && ram->mode == 2) { 383 ram_mask(fuc, 0x10f800, 0x00000004, 0x00000000); 384 r1373f4_init(fuc); 385 r1373f4_fini(fuc); 386 } 387 388 if (ram->mode != 2) /*XXX*/ { 389 if (next->bios.ramcfg_11_07_40) 390 ram_mask(fuc, 0x10f670, 0x80000000, 0x80000000); 391 } 392 393 ram_wr32(fuc, 0x10f65c, 0x00000011 * next->bios.rammap_11_11_0c); 394 ram_wr32(fuc, 0x10f6b8, 0x01010101 * next->bios.ramcfg_11_09); 395 ram_wr32(fuc, 0x10f6bc, 0x01010101 * next->bios.ramcfg_11_09); 396 397 if (!next->bios.ramcfg_11_07_08 && !next->bios.ramcfg_11_07_04) { 398 ram_wr32(fuc, 0x10f698, 0x01010101 * next->bios.ramcfg_11_04); 399 ram_wr32(fuc, 0x10f69c, 0x01010101 * next->bios.ramcfg_11_04); 400 } else 401 if (!next->bios.ramcfg_11_07_08) { 402 ram_wr32(fuc, 0x10f698, 0x00000000); 403 ram_wr32(fuc, 0x10f69c, 0x00000000); 404 } 405 406 if (ram->mode != 2) { 407 u32 data = 0x01000100 * next->bios.ramcfg_11_04; 408 ram_nuke(fuc, 0x10f694); 409 ram_mask(fuc, 0x10f694, 0xff00ff00, data); 410 } 411 412 if (ram->mode == 2 && next->bios.ramcfg_11_08_10) 413 data = 0x00000080; 414 else 415 data = 0x00000000; 416 ram_mask(fuc, 0x10f60c, 0x00000080, data); 417 418 mask = 0x00070000; 419 data = 0x00000000; 420 if (!next->bios.ramcfg_11_02_80) 421 data |= 0x03000000; 422 if (!next->bios.ramcfg_11_02_40) 423 data |= 0x00002000; 424 if (!next->bios.ramcfg_11_07_10) 425 data |= 0x00004000; 426 if (!next->bios.ramcfg_11_07_08) 427 data |= 0x00000003; 428 else 429 data |= 0x74000000; 430 ram_mask(fuc, 0x10f824, mask, data); 431 432 if (next->bios.ramcfg_11_01_08) 433 data = 0x00000000; 434 else 435 data = 0x00001000; 436 ram_mask(fuc, 0x10f200, 0x00001000, data); 437 438 if (ram_rd32(fuc, 0x10f670) & 0x80000000) { 439 ram_nsec(fuc, 10000); 440 ram_mask(fuc, 0x10f670, 0x80000000, 0x00000000); 441 } 442 443 if (next->bios.ramcfg_11_08_01) 444 data = 0x00100000; 445 else 446 data = 0x00000000; 447 ram_mask(fuc, 0x10f82c, 0x00100000, data); 448 449 data = 0x00000000; 450 if (next->bios.ramcfg_11_08_08) 451 data |= 0x00002000; 452 if (next->bios.ramcfg_11_08_04) 453 data |= 0x00001000; 454 if (next->bios.ramcfg_11_08_02) 455 data |= 0x00004000; 456 ram_mask(fuc, 0x10f830, 0x00007000, data); 457 458 /* PFB timing */ 459 ram_mask(fuc, 0x10f248, 0xffffffff, next->bios.timing[10]); 460 ram_mask(fuc, 0x10f290, 0xffffffff, next->bios.timing[0]); 461 ram_mask(fuc, 0x10f294, 0xffffffff, next->bios.timing[1]); 462 ram_mask(fuc, 0x10f298, 0xffffffff, next->bios.timing[2]); 463 ram_mask(fuc, 0x10f29c, 0xffffffff, next->bios.timing[3]); 464 ram_mask(fuc, 0x10f2a0, 0xffffffff, next->bios.timing[4]); 465 ram_mask(fuc, 0x10f2a4, 0xffffffff, next->bios.timing[5]); 466 ram_mask(fuc, 0x10f2a8, 0xffffffff, next->bios.timing[6]); 467 ram_mask(fuc, 0x10f2ac, 0xffffffff, next->bios.timing[7]); 468 ram_mask(fuc, 0x10f2cc, 0xffffffff, next->bios.timing[8]); 469 ram_mask(fuc, 0x10f2e8, 0xffffffff, next->bios.timing[9]); 470 471 data = mask = 0x00000000; 472 if (ram->diff.ramcfg_11_08_20) { 473 if (next->bios.ramcfg_11_08_20) 474 data |= 0x01000000; 475 mask |= 0x01000000; 476 } 477 ram_mask(fuc, 0x10f200, mask, data); 478 479 data = mask = 0x00000000; 480 if (ram->diff.ramcfg_11_02_03) { 481 data |= next->bios.ramcfg_11_02_03 << 8; 482 mask |= 0x00000300; 483 } 484 if (ram->diff.ramcfg_11_01_10) { 485 if (next->bios.ramcfg_11_01_10) 486 data |= 0x70000000; 487 mask |= 0x70000000; 488 } 489 ram_mask(fuc, 0x10f604, mask, data); 490 491 data = mask = 0x00000000; 492 if (ram->diff.timing_20_30_07) { 493 data |= next->bios.timing_20_30_07 << 28; 494 mask |= 0x70000000; 495 } 496 if (ram->diff.ramcfg_11_01_01) { 497 if (next->bios.ramcfg_11_01_01) 498 data |= 0x00000100; 499 mask |= 0x00000100; 500 } 501 ram_mask(fuc, 0x10f614, mask, data); 502 503 data = mask = 0x00000000; 504 if (ram->diff.timing_20_30_07) { 505 data |= next->bios.timing_20_30_07 << 28; 506 mask |= 0x70000000; 507 } 508 if (ram->diff.ramcfg_11_01_02) { 509 if (next->bios.ramcfg_11_01_02) 510 data |= 0x00000100; 511 mask |= 0x00000100; 512 } 513 ram_mask(fuc, 0x10f610, mask, data); 514 515 mask = 0x33f00000; 516 data = 0x00000000; 517 if (!next->bios.ramcfg_11_01_04) 518 data |= 0x20200000; 519 if (!next->bios.ramcfg_11_07_80) 520 data |= 0x12800000; 521 /*XXX: see note above about there probably being some condition 522 * for the 10f824 stuff that uses ramcfg 3... 523 */ 524 if (next->bios.ramcfg_11_03_f0) { 525 if (next->bios.rammap_11_08_0c) { 526 if (!next->bios.ramcfg_11_07_80) 527 mask |= 0x00000020; 528 else 529 data |= 0x00000020; 530 mask |= 0x00000004; 531 } 532 } else { 533 mask |= 0x40000020; 534 data |= 0x00000004; 535 } 536 537 ram_mask(fuc, 0x10f808, mask, data); 538 539 ram_wr32(fuc, 0x10f870, 0x11111111 * next->bios.ramcfg_11_03_0f); 540 541 data = mask = 0x00000000; 542 if (ram->diff.ramcfg_11_02_03) { 543 data |= next->bios.ramcfg_11_02_03; 544 mask |= 0x00000003; 545 } 546 if (ram->diff.ramcfg_11_01_10) { 547 if (next->bios.ramcfg_11_01_10) 548 data |= 0x00000004; 549 mask |= 0x00000004; 550 } 551 552 if ((ram_mask(fuc, 0x100770, mask, data) & mask & 4) != (data & 4)) { 553 ram_mask(fuc, 0x100750, 0x00000008, 0x00000008); 554 ram_wr32(fuc, 0x100710, 0x00000000); 555 ram_wait(fuc, 0x100710, 0x80000000, 0x80000000, 200000); 556 } 557 558 data = next->bios.timing_20_30_07 << 8; 559 if (next->bios.ramcfg_11_01_01) 560 data |= 0x80000000; 561 ram_mask(fuc, 0x100778, 0x00000700, data); 562 563 ram_mask(fuc, 0x10f250, 0x000003f0, next->bios.timing_20_2c_003f << 4); 564 data = (next->bios.timing[10] & 0x7f000000) >> 24; 565 if (data < next->bios.timing_20_2c_1fc0) 566 data = next->bios.timing_20_2c_1fc0; 567 ram_mask(fuc, 0x10f24c, 0x7f000000, data << 24); 568 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8 << 16); 569 570 ram_mask(fuc, 0x10fec4, 0x041e0f07, next->bios.timing_20_31_0800 << 26 | 571 next->bios.timing_20_31_0780 << 17 | 572 next->bios.timing_20_31_0078 << 8 | 573 next->bios.timing_20_31_0007); 574 ram_mask(fuc, 0x10fec8, 0x00000027, next->bios.timing_20_31_8000 << 5 | 575 next->bios.timing_20_31_7000); 576 577 ram_wr32(fuc, 0x10f090, 0x4000007e); 578 ram_nsec(fuc, 2000); 579 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */ 580 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */ 581 ram_wr32(fuc, 0x10f210, 0x80000000); /* REFRESH_AUTO = 1 */ 582 583 if (next->bios.ramcfg_11_08_10 && (ram->mode == 2) /*XXX*/) { 584 u32 temp = ram_mask(fuc, 0x10f294, 0xff000000, 0x24000000); 585 gk104_ram_train(fuc, 0xbc0e0000, 0xa4010000); /*XXX*/ 586 ram_nsec(fuc, 1000); 587 ram_wr32(fuc, 0x10f294, temp); 588 } 589 590 ram_mask(fuc, mr[3], 0xfff, ram->base.mr[3]); 591 ram_wr32(fuc, mr[0], ram->base.mr[0]); 592 ram_mask(fuc, mr[8], 0xfff, ram->base.mr[8]); 593 ram_nsec(fuc, 1000); 594 ram_mask(fuc, mr[1], 0xfff, ram->base.mr[1]); 595 ram_mask(fuc, mr[5], 0xfff, ram->base.mr[5] & ~0x004); /* LP3 later */ 596 ram_mask(fuc, mr[6], 0xfff, ram->base.mr[6]); 597 ram_mask(fuc, mr[7], 0xfff, ram->base.mr[7]); 598 599 if (vc == 0 && ram_have(fuc, gpio2E)) { 600 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[0]); 601 if (temp != ram_rd32(fuc, gpio2E)) { 602 ram_wr32(fuc, gpiotrig, 1); 603 ram_nsec(fuc, 20000); 604 } 605 } 606 607 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000); 608 ram_wr32(fuc, 0x10f318, 0x00000001); /* NOP? */ 609 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000); 610 ram_nsec(fuc, 1000); 611 ram_nuts(ram, 0x10f200, 0x18808800, 0x00000000, 0x18808800); 612 613 data = ram_rd32(fuc, 0x10f978); 614 data &= ~0x00046144; 615 data |= 0x0000000b; 616 if (!next->bios.ramcfg_11_07_08) { 617 if (!next->bios.ramcfg_11_07_04) 618 data |= 0x0000200c; 619 else 620 data |= 0x00000000; 621 } else { 622 data |= 0x00040044; 623 } 624 ram_wr32(fuc, 0x10f978, data); 625 626 if (ram->mode == 1) { 627 data = ram_rd32(fuc, 0x10f830) | 0x00000001; 628 ram_wr32(fuc, 0x10f830, data); 629 } 630 631 if (!next->bios.ramcfg_11_07_08) { 632 data = 0x88020000; 633 if ( next->bios.ramcfg_11_07_04) 634 data |= 0x10000000; 635 if (!next->bios.rammap_11_08_10) 636 data |= 0x00080000; 637 } else { 638 data = 0xa40e0000; 639 } 640 gk104_ram_train(fuc, 0xbc0f0000, data); 641 if (1) /* XXX: not always? */ 642 ram_nsec(fuc, 1000); 643 644 if (ram->mode == 2) { /*XXX*/ 645 ram_mask(fuc, 0x10f800, 0x00000004, 0x00000004); 646 } 647 648 /* LP3 */ 649 if (ram_mask(fuc, mr[5], 0x004, ram->base.mr[5]) != ram->base.mr[5]) 650 ram_nsec(fuc, 1000); 651 652 if (ram->mode != 2) { 653 ram_mask(fuc, 0x10f830, 0x01000000, 0x01000000); 654 ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000); 655 } 656 657 if (next->bios.ramcfg_11_07_02) 658 gk104_ram_train(fuc, 0x80020000, 0x01000000); 659 660 ram_unblock(fuc); 661 ram_wr32(fuc, 0x62c000, 0x0f0f0f00); 662 663 if (next->bios.rammap_11_08_01) 664 data = 0x00000800; 665 else 666 data = 0x00000000; 667 ram_mask(fuc, 0x10f200, 0x00000800, data); 668 ram_nuts(ram, 0x10f200, 0x18808800, data, 0x18808800); 669 return 0; 670 } 671 672 /******************************************************************************* 673 * DDR3 674 ******************************************************************************/ 675 676 static int 677 gk104_ram_calc_sddr3(struct nvkm_fb *fb, u32 freq) 678 { 679 struct gk104_ram *ram = (void *)fb->ram; 680 struct gk104_ramfuc *fuc = &ram->fuc; 681 const u32 rcoef = (( ram->P1 << 16) | (ram->N1 << 8) | ram->M1); 682 const u32 runk0 = ram->fN1 << 16; 683 const u32 runk1 = ram->fN1; 684 struct nvkm_ram_data *next = ram->base.next; 685 int vc = !next->bios.ramcfg_11_02_08; 686 int mv = !next->bios.ramcfg_11_02_04; 687 u32 mask, data; 688 689 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000); 690 ram_block(fuc); 691 ram_wr32(fuc, 0x62c000, 0x0f0f0000); 692 693 if (vc == 1 && ram_have(fuc, gpio2E)) { 694 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[1]); 695 if (temp != ram_rd32(fuc, gpio2E)) { 696 ram_wr32(fuc, gpiotrig, 1); 697 ram_nsec(fuc, 20000); 698 } 699 } 700 701 ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000); 702 if (next->bios.ramcfg_11_03_f0) 703 ram_mask(fuc, 0x10f808, 0x04000000, 0x04000000); 704 705 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */ 706 ram_wr32(fuc, 0x10f210, 0x00000000); /* REFRESH_AUTO = 0 */ 707 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */ 708 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000); 709 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */ 710 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000); 711 ram_nsec(fuc, 1000); 712 713 ram_wr32(fuc, 0x10f090, 0x00000060); 714 ram_wr32(fuc, 0x10f090, 0xc000007e); 715 716 /*XXX: there does appear to be some kind of condition here, simply 717 * modifying these bits in the vbios from the default pl0 718 * entries shows no change. however, the data does appear to 719 * be correct and may be required for the transition back 720 */ 721 mask = 0x00010000; 722 data = 0x00010000; 723 724 if (1) { 725 mask |= 0x800807e0; 726 data |= 0x800807e0; 727 switch (next->bios.ramcfg_11_03_c0) { 728 case 3: data &= ~0x00000040; break; 729 case 2: data &= ~0x00000100; break; 730 case 1: data &= ~0x80000000; break; 731 case 0: data &= ~0x00000400; break; 732 } 733 734 switch (next->bios.ramcfg_11_03_30) { 735 case 3: data &= ~0x00000020; break; 736 case 2: data &= ~0x00000080; break; 737 case 1: data &= ~0x00080000; break; 738 case 0: data &= ~0x00000200; break; 739 } 740 } 741 742 if (next->bios.ramcfg_11_02_80) 743 mask |= 0x03000000; 744 if (next->bios.ramcfg_11_02_40) 745 mask |= 0x00002000; 746 if (next->bios.ramcfg_11_07_10) 747 mask |= 0x00004000; 748 if (next->bios.ramcfg_11_07_08) 749 mask |= 0x00000003; 750 else 751 mask |= 0x14000000; 752 ram_mask(fuc, 0x10f824, mask, data); 753 754 ram_mask(fuc, 0x132040, 0x00010000, 0x00000000); 755 756 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010010); 757 data = ram_rd32(fuc, 0x1373ec) & ~0x00030000; 758 data |= next->bios.ramcfg_11_03_30 << 16; 759 ram_wr32(fuc, 0x1373ec, data); 760 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000000); 761 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000000); 762 763 /* (re)program refpll, if required */ 764 if ((ram_rd32(fuc, 0x132024) & 0xffffffff) != rcoef || 765 (ram_rd32(fuc, 0x132034) & 0x0000ffff) != runk1) { 766 ram_mask(fuc, 0x132000, 0x00000001, 0x00000000); 767 ram_mask(fuc, 0x132020, 0x00000001, 0x00000000); 768 ram_wr32(fuc, 0x137320, 0x00000000); 769 ram_mask(fuc, 0x132030, 0xffff0000, runk0); 770 ram_mask(fuc, 0x132034, 0x0000ffff, runk1); 771 ram_wr32(fuc, 0x132024, rcoef); 772 ram_mask(fuc, 0x132028, 0x00080000, 0x00080000); 773 ram_mask(fuc, 0x132020, 0x00000001, 0x00000001); 774 ram_wait(fuc, 0x137390, 0x00020000, 0x00020000, 64000); 775 ram_mask(fuc, 0x132028, 0x00080000, 0x00000000); 776 } 777 778 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000010); 779 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000001); 780 ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000); 781 782 if (ram_have(fuc, gpioMV)) { 783 u32 temp = ram_mask(fuc, gpioMV, 0x3000, fuc->r_funcMV[mv]); 784 if (temp != ram_rd32(fuc, gpioMV)) { 785 ram_wr32(fuc, gpiotrig, 1); 786 ram_nsec(fuc, 64000); 787 } 788 } 789 790 if (next->bios.ramcfg_11_02_40 || 791 next->bios.ramcfg_11_07_10) { 792 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000); 793 ram_nsec(fuc, 20000); 794 } 795 796 if (ram->mode != 2) /*XXX*/ { 797 if (next->bios.ramcfg_11_07_40) 798 ram_mask(fuc, 0x10f670, 0x80000000, 0x80000000); 799 } 800 801 ram_wr32(fuc, 0x10f65c, 0x00000011 * next->bios.rammap_11_11_0c); 802 ram_wr32(fuc, 0x10f6b8, 0x01010101 * next->bios.ramcfg_11_09); 803 ram_wr32(fuc, 0x10f6bc, 0x01010101 * next->bios.ramcfg_11_09); 804 805 mask = 0x00010000; 806 data = 0x00000000; 807 if (!next->bios.ramcfg_11_02_80) 808 data |= 0x03000000; 809 if (!next->bios.ramcfg_11_02_40) 810 data |= 0x00002000; 811 if (!next->bios.ramcfg_11_07_10) 812 data |= 0x00004000; 813 if (!next->bios.ramcfg_11_07_08) 814 data |= 0x00000003; 815 else 816 data |= 0x14000000; 817 ram_mask(fuc, 0x10f824, mask, data); 818 ram_nsec(fuc, 1000); 819 820 if (next->bios.ramcfg_11_08_01) 821 data = 0x00100000; 822 else 823 data = 0x00000000; 824 ram_mask(fuc, 0x10f82c, 0x00100000, data); 825 826 /* PFB timing */ 827 ram_mask(fuc, 0x10f248, 0xffffffff, next->bios.timing[10]); 828 ram_mask(fuc, 0x10f290, 0xffffffff, next->bios.timing[0]); 829 ram_mask(fuc, 0x10f294, 0xffffffff, next->bios.timing[1]); 830 ram_mask(fuc, 0x10f298, 0xffffffff, next->bios.timing[2]); 831 ram_mask(fuc, 0x10f29c, 0xffffffff, next->bios.timing[3]); 832 ram_mask(fuc, 0x10f2a0, 0xffffffff, next->bios.timing[4]); 833 ram_mask(fuc, 0x10f2a4, 0xffffffff, next->bios.timing[5]); 834 ram_mask(fuc, 0x10f2a8, 0xffffffff, next->bios.timing[6]); 835 ram_mask(fuc, 0x10f2ac, 0xffffffff, next->bios.timing[7]); 836 ram_mask(fuc, 0x10f2cc, 0xffffffff, next->bios.timing[8]); 837 ram_mask(fuc, 0x10f2e8, 0xffffffff, next->bios.timing[9]); 838 839 mask = 0x33f00000; 840 data = 0x00000000; 841 if (!next->bios.ramcfg_11_01_04) 842 data |= 0x20200000; 843 if (!next->bios.ramcfg_11_07_80) 844 data |= 0x12800000; 845 /*XXX: see note above about there probably being some condition 846 * for the 10f824 stuff that uses ramcfg 3... 847 */ 848 if (next->bios.ramcfg_11_03_f0) { 849 if (next->bios.rammap_11_08_0c) { 850 if (!next->bios.ramcfg_11_07_80) 851 mask |= 0x00000020; 852 else 853 data |= 0x00000020; 854 mask |= 0x08000004; 855 } 856 data |= 0x04000000; 857 } else { 858 mask |= 0x44000020; 859 data |= 0x08000004; 860 } 861 862 ram_mask(fuc, 0x10f808, mask, data); 863 864 ram_wr32(fuc, 0x10f870, 0x11111111 * next->bios.ramcfg_11_03_0f); 865 866 ram_mask(fuc, 0x10f250, 0x000003f0, next->bios.timing_20_2c_003f << 4); 867 868 data = (next->bios.timing[10] & 0x7f000000) >> 24; 869 if (data < next->bios.timing_20_2c_1fc0) 870 data = next->bios.timing_20_2c_1fc0; 871 ram_mask(fuc, 0x10f24c, 0x7f000000, data << 24); 872 873 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8 << 16); 874 875 ram_wr32(fuc, 0x10f090, 0x4000007f); 876 ram_nsec(fuc, 1000); 877 878 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */ 879 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */ 880 ram_wr32(fuc, 0x10f210, 0x80000000); /* REFRESH_AUTO = 1 */ 881 ram_nsec(fuc, 1000); 882 883 ram_nuke(fuc, mr[0]); 884 ram_mask(fuc, mr[0], 0x100, 0x100); 885 ram_mask(fuc, mr[0], 0x100, 0x000); 886 887 ram_mask(fuc, mr[2], 0xfff, ram->base.mr[2]); 888 ram_wr32(fuc, mr[0], ram->base.mr[0]); 889 ram_nsec(fuc, 1000); 890 891 ram_nuke(fuc, mr[0]); 892 ram_mask(fuc, mr[0], 0x100, 0x100); 893 ram_mask(fuc, mr[0], 0x100, 0x000); 894 895 if (vc == 0 && ram_have(fuc, gpio2E)) { 896 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[0]); 897 if (temp != ram_rd32(fuc, gpio2E)) { 898 ram_wr32(fuc, gpiotrig, 1); 899 ram_nsec(fuc, 20000); 900 } 901 } 902 903 if (ram->mode != 2) { 904 ram_mask(fuc, 0x10f830, 0x01000000, 0x01000000); 905 ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000); 906 } 907 908 ram_mask(fuc, 0x10f200, 0x80000000, 0x80000000); 909 ram_wr32(fuc, 0x10f318, 0x00000001); /* NOP? */ 910 ram_mask(fuc, 0x10f200, 0x80000000, 0x00000000); 911 ram_nsec(fuc, 1000); 912 913 ram_unblock(fuc); 914 ram_wr32(fuc, 0x62c000, 0x0f0f0f00); 915 916 if (next->bios.rammap_11_08_01) 917 data = 0x00000800; 918 else 919 data = 0x00000000; 920 ram_mask(fuc, 0x10f200, 0x00000800, data); 921 return 0; 922 } 923 924 /******************************************************************************* 925 * main hooks 926 ******************************************************************************/ 927 928 static int 929 gk104_ram_calc_data(struct nvkm_fb *fb, u32 khz, struct nvkm_ram_data *data) 930 { 931 struct gk104_ram *ram = (void *)fb->ram; 932 struct nvkm_ram_data *cfg; 933 u32 mhz = khz / 1000; 934 935 list_for_each_entry(cfg, &ram->cfg, head) { 936 if (mhz >= cfg->bios.rammap_min && 937 mhz <= cfg->bios.rammap_max) { 938 *data = *cfg; 939 data->freq = khz; 940 return 0; 941 } 942 } 943 944 nvkm_error(&fb->subdev, "ramcfg data for %dMHz not found\n", mhz); 945 return -EINVAL; 946 } 947 948 static int 949 gk104_ram_calc_xits(struct nvkm_fb *fb, struct nvkm_ram_data *next) 950 { 951 struct gk104_ram *ram = (void *)fb->ram; 952 struct gk104_ramfuc *fuc = &ram->fuc; 953 struct nvkm_subdev *subdev = &fb->subdev; 954 int refclk, i; 955 int ret; 956 957 ret = ram_init(fuc, fb); 958 if (ret) 959 return ret; 960 961 ram->mode = (next->freq > fuc->refpll.vco1.max_freq) ? 2 : 1; 962 ram->from = ram_rd32(fuc, 0x1373f4) & 0x0000000f; 963 964 /* XXX: this is *not* what nvidia do. on fermi nvidia generally 965 * select, based on some unknown condition, one of the two possible 966 * reference frequencies listed in the vbios table for mempll and 967 * program refpll to that frequency. 968 * 969 * so far, i've seen very weird values being chosen by nvidia on 970 * kepler boards, no idea how/why they're chosen. 971 */ 972 refclk = next->freq; 973 if (ram->mode == 2) 974 refclk = fuc->mempll.refclk; 975 976 /* calculate refpll coefficients */ 977 ret = gt215_pll_calc(nv_subdev(fb), &fuc->refpll, refclk, &ram->N1, 978 &ram->fN1, &ram->M1, &ram->P1); 979 fuc->mempll.refclk = ret; 980 if (ret <= 0) { 981 nvkm_error(subdev, "unable to calc refpll\n"); 982 return -EINVAL; 983 } 984 985 /* calculate mempll coefficients, if we're using it */ 986 if (ram->mode == 2) { 987 /* post-divider doesn't work... the reg takes the values but 988 * appears to completely ignore it. there *is* a bit at 989 * bit 28 that appears to divide the clock by 2 if set. 990 */ 991 fuc->mempll.min_p = 1; 992 fuc->mempll.max_p = 2; 993 994 ret = gt215_pll_calc(nv_subdev(fb), &fuc->mempll, next->freq, 995 &ram->N2, NULL, &ram->M2, &ram->P2); 996 if (ret <= 0) { 997 nvkm_error(subdev, "unable to calc mempll\n"); 998 return -EINVAL; 999 } 1000 } 1001 1002 for (i = 0; i < ARRAY_SIZE(fuc->r_mr); i++) { 1003 if (ram_have(fuc, mr[i])) 1004 ram->base.mr[i] = ram_rd32(fuc, mr[i]); 1005 } 1006 ram->base.freq = next->freq; 1007 1008 switch (ram->base.type) { 1009 case NV_MEM_TYPE_DDR3: 1010 ret = nvkm_sddr3_calc(&ram->base); 1011 if (ret == 0) 1012 ret = gk104_ram_calc_sddr3(fb, next->freq); 1013 break; 1014 case NV_MEM_TYPE_GDDR5: 1015 ret = nvkm_gddr5_calc(&ram->base, ram->pnuts != 0); 1016 if (ret == 0) 1017 ret = gk104_ram_calc_gddr5(fb, next->freq); 1018 break; 1019 default: 1020 ret = -ENOSYS; 1021 break; 1022 } 1023 1024 return ret; 1025 } 1026 1027 static int 1028 gk104_ram_calc(struct nvkm_fb *fb, u32 freq) 1029 { 1030 struct nvkm_clk *clk = nvkm_clk(fb); 1031 struct gk104_ram *ram = (void *)fb->ram; 1032 struct nvkm_ram_data *xits = &ram->base.xition; 1033 struct nvkm_ram_data *copy; 1034 int ret; 1035 1036 if (ram->base.next == NULL) { 1037 ret = gk104_ram_calc_data(fb, clk->read(clk, nv_clk_src_mem), 1038 &ram->base.former); 1039 if (ret) 1040 return ret; 1041 1042 ret = gk104_ram_calc_data(fb, freq, &ram->base.target); 1043 if (ret) 1044 return ret; 1045 1046 if (ram->base.target.freq < ram->base.former.freq) { 1047 *xits = ram->base.target; 1048 copy = &ram->base.former; 1049 } else { 1050 *xits = ram->base.former; 1051 copy = &ram->base.target; 1052 } 1053 1054 xits->bios.ramcfg_11_02_04 = copy->bios.ramcfg_11_02_04; 1055 xits->bios.ramcfg_11_02_03 = copy->bios.ramcfg_11_02_03; 1056 xits->bios.timing_20_30_07 = copy->bios.timing_20_30_07; 1057 1058 ram->base.next = &ram->base.target; 1059 if (memcmp(xits, &ram->base.former, sizeof(xits->bios))) 1060 ram->base.next = &ram->base.xition; 1061 } else { 1062 BUG_ON(ram->base.next != &ram->base.xition); 1063 ram->base.next = &ram->base.target; 1064 } 1065 1066 return gk104_ram_calc_xits(fb, ram->base.next); 1067 } 1068 1069 static void 1070 gk104_ram_prog_0(struct nvkm_fb *fb, u32 freq) 1071 { 1072 struct nvkm_device *device = fb->subdev.device; 1073 struct gk104_ram *ram = (void *)fb->ram; 1074 struct nvkm_ram_data *cfg; 1075 u32 mhz = freq / 1000; 1076 u32 mask, data; 1077 1078 list_for_each_entry(cfg, &ram->cfg, head) { 1079 if (mhz >= cfg->bios.rammap_min && 1080 mhz <= cfg->bios.rammap_max) 1081 break; 1082 } 1083 1084 if (&cfg->head == &ram->cfg) 1085 return; 1086 1087 if (mask = 0, data = 0, ram->diff.rammap_11_0a_03fe) { 1088 data |= cfg->bios.rammap_11_0a_03fe << 12; 1089 mask |= 0x001ff000; 1090 } 1091 if (ram->diff.rammap_11_09_01ff) { 1092 data |= cfg->bios.rammap_11_09_01ff; 1093 mask |= 0x000001ff; 1094 } 1095 nvkm_mask(device, 0x10f468, mask, data); 1096 1097 if (mask = 0, data = 0, ram->diff.rammap_11_0a_0400) { 1098 data |= cfg->bios.rammap_11_0a_0400; 1099 mask |= 0x00000001; 1100 } 1101 nvkm_mask(device, 0x10f420, mask, data); 1102 1103 if (mask = 0, data = 0, ram->diff.rammap_11_0a_0800) { 1104 data |= cfg->bios.rammap_11_0a_0800; 1105 mask |= 0x00000001; 1106 } 1107 nvkm_mask(device, 0x10f430, mask, data); 1108 1109 if (mask = 0, data = 0, ram->diff.rammap_11_0b_01f0) { 1110 data |= cfg->bios.rammap_11_0b_01f0; 1111 mask |= 0x0000001f; 1112 } 1113 nvkm_mask(device, 0x10f400, mask, data); 1114 1115 if (mask = 0, data = 0, ram->diff.rammap_11_0b_0200) { 1116 data |= cfg->bios.rammap_11_0b_0200 << 9; 1117 mask |= 0x00000200; 1118 } 1119 nvkm_mask(device, 0x10f410, mask, data); 1120 1121 if (mask = 0, data = 0, ram->diff.rammap_11_0d) { 1122 data |= cfg->bios.rammap_11_0d << 16; 1123 mask |= 0x00ff0000; 1124 } 1125 if (ram->diff.rammap_11_0f) { 1126 data |= cfg->bios.rammap_11_0f << 8; 1127 mask |= 0x0000ff00; 1128 } 1129 nvkm_mask(device, 0x10f440, mask, data); 1130 1131 if (mask = 0, data = 0, ram->diff.rammap_11_0e) { 1132 data |= cfg->bios.rammap_11_0e << 8; 1133 mask |= 0x0000ff00; 1134 } 1135 if (ram->diff.rammap_11_0b_0800) { 1136 data |= cfg->bios.rammap_11_0b_0800 << 7; 1137 mask |= 0x00000080; 1138 } 1139 if (ram->diff.rammap_11_0b_0400) { 1140 data |= cfg->bios.rammap_11_0b_0400 << 5; 1141 mask |= 0x00000020; 1142 } 1143 nvkm_mask(device, 0x10f444, mask, data); 1144 } 1145 1146 static int 1147 gk104_ram_prog(struct nvkm_fb *fb) 1148 { 1149 struct nvkm_device *device = nv_device(fb); 1150 struct gk104_ram *ram = (void *)fb->ram; 1151 struct gk104_ramfuc *fuc = &ram->fuc; 1152 struct nvkm_ram_data *next = ram->base.next; 1153 1154 if (!nvkm_boolopt(device->cfgopt, "NvMemExec", true)) { 1155 ram_exec(fuc, false); 1156 return (ram->base.next == &ram->base.xition); 1157 } 1158 1159 gk104_ram_prog_0(fb, 1000); 1160 ram_exec(fuc, true); 1161 gk104_ram_prog_0(fb, next->freq); 1162 1163 return (ram->base.next == &ram->base.xition); 1164 } 1165 1166 static void 1167 gk104_ram_tidy(struct nvkm_fb *fb) 1168 { 1169 struct gk104_ram *ram = (void *)fb->ram; 1170 struct gk104_ramfuc *fuc = &ram->fuc; 1171 ram->base.next = NULL; 1172 ram_exec(fuc, false); 1173 } 1174 1175 struct gk104_ram_train { 1176 u16 mask; 1177 struct nvbios_M0209S remap; 1178 struct nvbios_M0209S type00; 1179 struct nvbios_M0209S type01; 1180 struct nvbios_M0209S type04; 1181 struct nvbios_M0209S type06; 1182 struct nvbios_M0209S type07; 1183 struct nvbios_M0209S type08; 1184 struct nvbios_M0209S type09; 1185 }; 1186 1187 static int 1188 gk104_ram_train_type(struct nvkm_fb *fb, int i, u8 ramcfg, 1189 struct gk104_ram_train *train) 1190 { 1191 struct nvkm_bios *bios = nvkm_bios(fb); 1192 struct nvbios_M0205E M0205E; 1193 struct nvbios_M0205S M0205S; 1194 struct nvbios_M0209E M0209E; 1195 struct nvbios_M0209S *remap = &train->remap; 1196 struct nvbios_M0209S *value; 1197 u8 ver, hdr, cnt, len; 1198 u32 data; 1199 1200 /* determine type of data for this index */ 1201 if (!(data = nvbios_M0205Ep(bios, i, &ver, &hdr, &cnt, &len, &M0205E))) 1202 return -ENOENT; 1203 1204 switch (M0205E.type) { 1205 case 0x00: value = &train->type00; break; 1206 case 0x01: value = &train->type01; break; 1207 case 0x04: value = &train->type04; break; 1208 case 0x06: value = &train->type06; break; 1209 case 0x07: value = &train->type07; break; 1210 case 0x08: value = &train->type08; break; 1211 case 0x09: value = &train->type09; break; 1212 default: 1213 return 0; 1214 } 1215 1216 /* training data index determined by ramcfg strap */ 1217 if (!(data = nvbios_M0205Sp(bios, i, ramcfg, &ver, &hdr, &M0205S))) 1218 return -EINVAL; 1219 i = M0205S.data; 1220 1221 /* training data format information */ 1222 if (!(data = nvbios_M0209Ep(bios, i, &ver, &hdr, &cnt, &len, &M0209E))) 1223 return -EINVAL; 1224 1225 /* ... and the raw data */ 1226 if (!(data = nvbios_M0209Sp(bios, i, 0, &ver, &hdr, value))) 1227 return -EINVAL; 1228 1229 if (M0209E.v02_07 == 2) { 1230 /* of course! why wouldn't we have a pointer to another entry 1231 * in the same table, and use the first one as an array of 1232 * remap indices... 1233 */ 1234 if (!(data = nvbios_M0209Sp(bios, M0209E.v03, 0, &ver, &hdr, 1235 remap))) 1236 return -EINVAL; 1237 1238 for (i = 0; i < ARRAY_SIZE(value->data); i++) 1239 value->data[i] = remap->data[value->data[i]]; 1240 } else 1241 if (M0209E.v02_07 != 1) 1242 return -EINVAL; 1243 1244 train->mask |= 1 << M0205E.type; 1245 return 0; 1246 } 1247 1248 static int 1249 gk104_ram_train_init_0(struct nvkm_fb *fb, struct gk104_ram_train *train) 1250 { 1251 struct nvkm_subdev *subdev = &fb->subdev; 1252 struct nvkm_device *device = subdev->device; 1253 int i, j; 1254 1255 if ((train->mask & 0x03d3) != 0x03d3) { 1256 nvkm_warn(subdev, "missing link training data\n"); 1257 return -EINVAL; 1258 } 1259 1260 for (i = 0; i < 0x30; i++) { 1261 for (j = 0; j < 8; j += 4) { 1262 nvkm_wr32(device, 0x10f968 + j, 0x00000000 | (i << 8)); 1263 nvkm_wr32(device, 0x10f920 + j, 0x00000000 | 1264 train->type08.data[i] << 4 | 1265 train->type06.data[i]); 1266 nvkm_wr32(device, 0x10f918 + j, train->type00.data[i]); 1267 nvkm_wr32(device, 0x10f920 + j, 0x00000100 | 1268 train->type09.data[i] << 4 | 1269 train->type07.data[i]); 1270 nvkm_wr32(device, 0x10f918 + j, train->type01.data[i]); 1271 } 1272 } 1273 1274 for (j = 0; j < 8; j += 4) { 1275 for (i = 0; i < 0x100; i++) { 1276 nvkm_wr32(device, 0x10f968 + j, i); 1277 nvkm_wr32(device, 0x10f900 + j, train->type04.data[i]); 1278 } 1279 } 1280 1281 return 0; 1282 } 1283 1284 static int 1285 gk104_ram_train_init(struct nvkm_fb *fb) 1286 { 1287 u8 ramcfg = nvbios_ramcfg_index(nv_subdev(fb)); 1288 struct gk104_ram_train *train; 1289 int ret, i; 1290 1291 if (!(train = kzalloc(sizeof(*train), GFP_KERNEL))) 1292 return -ENOMEM; 1293 1294 for (i = 0; i < 0x100; i++) { 1295 ret = gk104_ram_train_type(fb, i, ramcfg, train); 1296 if (ret && ret != -ENOENT) 1297 break; 1298 } 1299 1300 switch (fb->ram->type) { 1301 case NV_MEM_TYPE_GDDR5: 1302 ret = gk104_ram_train_init_0(fb, train); 1303 break; 1304 default: 1305 ret = 0; 1306 break; 1307 } 1308 1309 kfree(train); 1310 return ret; 1311 } 1312 1313 int 1314 gk104_ram_init(struct nvkm_object *object) 1315 { 1316 struct nvkm_fb *fb = (void *)object->parent; 1317 struct gk104_ram *ram = (void *)object; 1318 struct nvkm_device *device = fb->subdev.device; 1319 struct nvkm_bios *bios = device->bios; 1320 u8 ver, hdr, cnt, len, snr, ssz; 1321 u32 data, save; 1322 int ret, i; 1323 1324 ret = nvkm_ram_init(&ram->base); 1325 if (ret) 1326 return ret; 1327 1328 /* run a bunch of tables from rammap table. there's actually 1329 * individual pointers for each rammap entry too, but, nvidia 1330 * seem to just run the last two entries' scripts early on in 1331 * their init, and never again.. we'll just run 'em all once 1332 * for now. 1333 * 1334 * i strongly suspect that each script is for a separate mode 1335 * (likely selected by 0x10f65c's lower bits?), and the 1336 * binary driver skips the one that's already been setup by 1337 * the init tables. 1338 */ 1339 data = nvbios_rammapTe(bios, &ver, &hdr, &cnt, &len, &snr, &ssz); 1340 if (!data || hdr < 0x15) 1341 return -EINVAL; 1342 1343 cnt = nvbios_rd08(bios, data + 0x14); /* guess at count */ 1344 data = nvbios_rd32(bios, data + 0x10); /* guess u32... */ 1345 save = nvkm_rd32(device, 0x10f65c) & 0x000000f0; 1346 for (i = 0; i < cnt; i++, data += 4) { 1347 if (i != save >> 4) { 1348 nvkm_mask(device, 0x10f65c, 0x000000f0, i << 4); 1349 nvbios_exec(&(struct nvbios_init) { 1350 .subdev = nv_subdev(fb), 1351 .bios = bios, 1352 .offset = nvbios_rd32(bios, data), 1353 .execute = 1, 1354 }); 1355 } 1356 } 1357 nvkm_mask(device, 0x10f65c, 0x000000f0, save); 1358 nvkm_mask(device, 0x10f584, 0x11000000, 0x00000000); 1359 nvkm_wr32(device, 0x10ecc0, 0xffffffff); 1360 nvkm_mask(device, 0x10f160, 0x00000010, 0x00000010); 1361 1362 return gk104_ram_train_init(fb); 1363 } 1364 1365 static int 1366 gk104_ram_ctor_data(struct gk104_ram *ram, u8 ramcfg, int i) 1367 { 1368 struct nvkm_fb *fb = (void *)nv_object(ram)->parent; 1369 struct nvkm_bios *bios = nvkm_bios(fb); 1370 struct nvkm_ram_data *cfg; 1371 struct nvbios_ramcfg *d = &ram->diff; 1372 struct nvbios_ramcfg *p, *n; 1373 u8 ver, hdr, cnt, len; 1374 u32 data; 1375 int ret; 1376 1377 if (!(cfg = kmalloc(sizeof(*cfg), GFP_KERNEL))) 1378 return -ENOMEM; 1379 p = &list_last_entry(&ram->cfg, typeof(*cfg), head)->bios; 1380 n = &cfg->bios; 1381 1382 /* memory config data for a range of target frequencies */ 1383 data = nvbios_rammapEp(bios, i, &ver, &hdr, &cnt, &len, &cfg->bios); 1384 if (ret = -ENOENT, !data) 1385 goto done; 1386 if (ret = -ENOSYS, ver != 0x11 || hdr < 0x12) 1387 goto done; 1388 1389 /* ... and a portion specific to the attached memory */ 1390 data = nvbios_rammapSp(bios, data, ver, hdr, cnt, len, ramcfg, 1391 &ver, &hdr, &cfg->bios); 1392 if (ret = -EINVAL, !data) 1393 goto done; 1394 if (ret = -ENOSYS, ver != 0x11 || hdr < 0x0a) 1395 goto done; 1396 1397 /* lookup memory timings, if bios says they're present */ 1398 if (cfg->bios.ramcfg_timing != 0xff) { 1399 data = nvbios_timingEp(bios, cfg->bios.ramcfg_timing, 1400 &ver, &hdr, &cnt, &len, 1401 &cfg->bios); 1402 if (ret = -EINVAL, !data) 1403 goto done; 1404 if (ret = -ENOSYS, ver != 0x20 || hdr < 0x33) 1405 goto done; 1406 } 1407 1408 list_add_tail(&cfg->head, &ram->cfg); 1409 if (ret = 0, i == 0) 1410 goto done; 1411 1412 d->rammap_11_0a_03fe |= p->rammap_11_0a_03fe != n->rammap_11_0a_03fe; 1413 d->rammap_11_09_01ff |= p->rammap_11_09_01ff != n->rammap_11_09_01ff; 1414 d->rammap_11_0a_0400 |= p->rammap_11_0a_0400 != n->rammap_11_0a_0400; 1415 d->rammap_11_0a_0800 |= p->rammap_11_0a_0800 != n->rammap_11_0a_0800; 1416 d->rammap_11_0b_01f0 |= p->rammap_11_0b_01f0 != n->rammap_11_0b_01f0; 1417 d->rammap_11_0b_0200 |= p->rammap_11_0b_0200 != n->rammap_11_0b_0200; 1418 d->rammap_11_0d |= p->rammap_11_0d != n->rammap_11_0d; 1419 d->rammap_11_0f |= p->rammap_11_0f != n->rammap_11_0f; 1420 d->rammap_11_0e |= p->rammap_11_0e != n->rammap_11_0e; 1421 d->rammap_11_0b_0800 |= p->rammap_11_0b_0800 != n->rammap_11_0b_0800; 1422 d->rammap_11_0b_0400 |= p->rammap_11_0b_0400 != n->rammap_11_0b_0400; 1423 d->ramcfg_11_01_01 |= p->ramcfg_11_01_01 != n->ramcfg_11_01_01; 1424 d->ramcfg_11_01_02 |= p->ramcfg_11_01_02 != n->ramcfg_11_01_02; 1425 d->ramcfg_11_01_10 |= p->ramcfg_11_01_10 != n->ramcfg_11_01_10; 1426 d->ramcfg_11_02_03 |= p->ramcfg_11_02_03 != n->ramcfg_11_02_03; 1427 d->ramcfg_11_08_20 |= p->ramcfg_11_08_20 != n->ramcfg_11_08_20; 1428 d->timing_20_30_07 |= p->timing_20_30_07 != n->timing_20_30_07; 1429 done: 1430 if (ret) 1431 kfree(cfg); 1432 return ret; 1433 } 1434 1435 static void 1436 gk104_ram_dtor(struct nvkm_object *object) 1437 { 1438 struct gk104_ram *ram = (void *)object; 1439 struct nvkm_ram_data *cfg, *tmp; 1440 1441 list_for_each_entry_safe(cfg, tmp, &ram->cfg, head) { 1442 kfree(cfg); 1443 } 1444 1445 nvkm_ram_destroy(&ram->base); 1446 } 1447 1448 static int 1449 gk104_ram_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 1450 struct nvkm_oclass *oclass, void *data, u32 size, 1451 struct nvkm_object **pobject) 1452 { 1453 struct nvkm_fb *fb = nvkm_fb(parent); 1454 struct nvkm_subdev *subdev = &fb->subdev; 1455 struct nvkm_device *device = subdev->device; 1456 struct nvkm_bios *bios = device->bios; 1457 struct nvkm_gpio *gpio = device->gpio; 1458 struct dcb_gpio_func func; 1459 struct gk104_ram *ram; 1460 int ret, i; 1461 u8 ramcfg = nvbios_ramcfg_index(nv_subdev(fb)); 1462 u32 tmp; 1463 1464 ret = gf100_ram_create(parent, engine, oclass, 0x022554, &ram); 1465 *pobject = nv_object(ram); 1466 if (ret) 1467 return ret; 1468 1469 INIT_LIST_HEAD(&ram->cfg); 1470 1471 switch (ram->base.type) { 1472 case NV_MEM_TYPE_DDR3: 1473 case NV_MEM_TYPE_GDDR5: 1474 ram->base.calc = gk104_ram_calc; 1475 ram->base.prog = gk104_ram_prog; 1476 ram->base.tidy = gk104_ram_tidy; 1477 break; 1478 default: 1479 nvkm_warn(subdev, "reclocking of this RAM type is unsupported\n"); 1480 break; 1481 } 1482 1483 /* calculate a mask of differently configured memory partitions, 1484 * because, of course reclocking wasn't complicated enough 1485 * already without having to treat some of them differently to 1486 * the others.... 1487 */ 1488 ram->parts = nvkm_rd32(device, 0x022438); 1489 ram->pmask = nvkm_rd32(device, 0x022554); 1490 ram->pnuts = 0; 1491 for (i = 0, tmp = 0; i < ram->parts; i++) { 1492 if (!(ram->pmask & (1 << i))) { 1493 u32 cfg1 = nvkm_rd32(device, 0x110204 + (i * 0x1000)); 1494 if (tmp && tmp != cfg1) { 1495 ram->pnuts |= (1 << i); 1496 continue; 1497 } 1498 tmp = cfg1; 1499 } 1500 } 1501 1502 /* parse bios data for all rammap table entries up-front, and 1503 * build information on whether certain fields differ between 1504 * any of the entries. 1505 * 1506 * the binary driver appears to completely ignore some fields 1507 * when all entries contain the same value. at first, it was 1508 * hoped that these were mere optimisations and the bios init 1509 * tables had configured as per the values here, but there is 1510 * evidence now to suggest that this isn't the case and we do 1511 * need to treat this condition as a "don't touch" indicator. 1512 */ 1513 for (i = 0; !ret; i++) { 1514 ret = gk104_ram_ctor_data(ram, ramcfg, i); 1515 if (ret && ret != -ENOENT) { 1516 nvkm_error(subdev, "failed to parse ramcfg data\n"); 1517 return ret; 1518 } 1519 } 1520 1521 /* parse bios data for both pll's */ 1522 ret = nvbios_pll_parse(bios, 0x0c, &ram->fuc.refpll); 1523 if (ret) { 1524 nvkm_error(subdev, "mclk refpll data not found\n"); 1525 return ret; 1526 } 1527 1528 ret = nvbios_pll_parse(bios, 0x04, &ram->fuc.mempll); 1529 if (ret) { 1530 nvkm_error(subdev, "mclk pll data not found\n"); 1531 return ret; 1532 } 1533 1534 /* lookup memory voltage gpios */ 1535 ret = gpio->find(gpio, 0, 0x18, DCB_GPIO_UNUSED, &func); 1536 if (ret == 0) { 1537 ram->fuc.r_gpioMV = ramfuc_reg(0x00d610 + (func.line * 0x04)); 1538 ram->fuc.r_funcMV[0] = (func.log[0] ^ 2) << 12; 1539 ram->fuc.r_funcMV[1] = (func.log[1] ^ 2) << 12; 1540 } 1541 1542 ret = gpio->find(gpio, 0, 0x2e, DCB_GPIO_UNUSED, &func); 1543 if (ret == 0) { 1544 ram->fuc.r_gpio2E = ramfuc_reg(0x00d610 + (func.line * 0x04)); 1545 ram->fuc.r_func2E[0] = (func.log[0] ^ 2) << 12; 1546 ram->fuc.r_func2E[1] = (func.log[1] ^ 2) << 12; 1547 } 1548 1549 ram->fuc.r_gpiotrig = ramfuc_reg(0x00d604); 1550 1551 ram->fuc.r_0x132020 = ramfuc_reg(0x132020); 1552 ram->fuc.r_0x132028 = ramfuc_reg(0x132028); 1553 ram->fuc.r_0x132024 = ramfuc_reg(0x132024); 1554 ram->fuc.r_0x132030 = ramfuc_reg(0x132030); 1555 ram->fuc.r_0x132034 = ramfuc_reg(0x132034); 1556 ram->fuc.r_0x132000 = ramfuc_reg(0x132000); 1557 ram->fuc.r_0x132004 = ramfuc_reg(0x132004); 1558 ram->fuc.r_0x132040 = ramfuc_reg(0x132040); 1559 1560 ram->fuc.r_0x10f248 = ramfuc_reg(0x10f248); 1561 ram->fuc.r_0x10f290 = ramfuc_reg(0x10f290); 1562 ram->fuc.r_0x10f294 = ramfuc_reg(0x10f294); 1563 ram->fuc.r_0x10f298 = ramfuc_reg(0x10f298); 1564 ram->fuc.r_0x10f29c = ramfuc_reg(0x10f29c); 1565 ram->fuc.r_0x10f2a0 = ramfuc_reg(0x10f2a0); 1566 ram->fuc.r_0x10f2a4 = ramfuc_reg(0x10f2a4); 1567 ram->fuc.r_0x10f2a8 = ramfuc_reg(0x10f2a8); 1568 ram->fuc.r_0x10f2ac = ramfuc_reg(0x10f2ac); 1569 ram->fuc.r_0x10f2cc = ramfuc_reg(0x10f2cc); 1570 ram->fuc.r_0x10f2e8 = ramfuc_reg(0x10f2e8); 1571 ram->fuc.r_0x10f250 = ramfuc_reg(0x10f250); 1572 ram->fuc.r_0x10f24c = ramfuc_reg(0x10f24c); 1573 ram->fuc.r_0x10fec4 = ramfuc_reg(0x10fec4); 1574 ram->fuc.r_0x10fec8 = ramfuc_reg(0x10fec8); 1575 ram->fuc.r_0x10f604 = ramfuc_reg(0x10f604); 1576 ram->fuc.r_0x10f614 = ramfuc_reg(0x10f614); 1577 ram->fuc.r_0x10f610 = ramfuc_reg(0x10f610); 1578 ram->fuc.r_0x100770 = ramfuc_reg(0x100770); 1579 ram->fuc.r_0x100778 = ramfuc_reg(0x100778); 1580 ram->fuc.r_0x10f224 = ramfuc_reg(0x10f224); 1581 1582 ram->fuc.r_0x10f870 = ramfuc_reg(0x10f870); 1583 ram->fuc.r_0x10f698 = ramfuc_reg(0x10f698); 1584 ram->fuc.r_0x10f694 = ramfuc_reg(0x10f694); 1585 ram->fuc.r_0x10f6b8 = ramfuc_reg(0x10f6b8); 1586 ram->fuc.r_0x10f808 = ramfuc_reg(0x10f808); 1587 ram->fuc.r_0x10f670 = ramfuc_reg(0x10f670); 1588 ram->fuc.r_0x10f60c = ramfuc_reg(0x10f60c); 1589 ram->fuc.r_0x10f830 = ramfuc_reg(0x10f830); 1590 ram->fuc.r_0x1373ec = ramfuc_reg(0x1373ec); 1591 ram->fuc.r_0x10f800 = ramfuc_reg(0x10f800); 1592 ram->fuc.r_0x10f82c = ramfuc_reg(0x10f82c); 1593 1594 ram->fuc.r_0x10f978 = ramfuc_reg(0x10f978); 1595 ram->fuc.r_0x10f910 = ramfuc_reg(0x10f910); 1596 ram->fuc.r_0x10f914 = ramfuc_reg(0x10f914); 1597 1598 switch (ram->base.type) { 1599 case NV_MEM_TYPE_GDDR5: 1600 ram->fuc.r_mr[0] = ramfuc_reg(0x10f300); 1601 ram->fuc.r_mr[1] = ramfuc_reg(0x10f330); 1602 ram->fuc.r_mr[2] = ramfuc_reg(0x10f334); 1603 ram->fuc.r_mr[3] = ramfuc_reg(0x10f338); 1604 ram->fuc.r_mr[4] = ramfuc_reg(0x10f33c); 1605 ram->fuc.r_mr[5] = ramfuc_reg(0x10f340); 1606 ram->fuc.r_mr[6] = ramfuc_reg(0x10f344); 1607 ram->fuc.r_mr[7] = ramfuc_reg(0x10f348); 1608 ram->fuc.r_mr[8] = ramfuc_reg(0x10f354); 1609 ram->fuc.r_mr[15] = ramfuc_reg(0x10f34c); 1610 break; 1611 case NV_MEM_TYPE_DDR3: 1612 ram->fuc.r_mr[0] = ramfuc_reg(0x10f300); 1613 ram->fuc.r_mr[2] = ramfuc_reg(0x10f320); 1614 break; 1615 default: 1616 break; 1617 } 1618 1619 ram->fuc.r_0x62c000 = ramfuc_reg(0x62c000); 1620 ram->fuc.r_0x10f200 = ramfuc_reg(0x10f200); 1621 ram->fuc.r_0x10f210 = ramfuc_reg(0x10f210); 1622 ram->fuc.r_0x10f310 = ramfuc_reg(0x10f310); 1623 ram->fuc.r_0x10f314 = ramfuc_reg(0x10f314); 1624 ram->fuc.r_0x10f318 = ramfuc_reg(0x10f318); 1625 ram->fuc.r_0x10f090 = ramfuc_reg(0x10f090); 1626 ram->fuc.r_0x10f69c = ramfuc_reg(0x10f69c); 1627 ram->fuc.r_0x10f824 = ramfuc_reg(0x10f824); 1628 ram->fuc.r_0x1373f0 = ramfuc_reg(0x1373f0); 1629 ram->fuc.r_0x1373f4 = ramfuc_reg(0x1373f4); 1630 ram->fuc.r_0x137320 = ramfuc_reg(0x137320); 1631 ram->fuc.r_0x10f65c = ramfuc_reg(0x10f65c); 1632 ram->fuc.r_0x10f6bc = ramfuc_reg(0x10f6bc); 1633 ram->fuc.r_0x100710 = ramfuc_reg(0x100710); 1634 ram->fuc.r_0x100750 = ramfuc_reg(0x100750); 1635 return 0; 1636 } 1637 1638 struct nvkm_oclass 1639 gk104_ram_oclass = { 1640 .handle = 0, 1641 .ofuncs = &(struct nvkm_ofuncs) { 1642 .ctor = gk104_ram_ctor, 1643 .dtor = gk104_ram_dtor, 1644 .init = gk104_ram_init, 1645 .fini = _nvkm_ram_fini, 1646 } 1647 }; 1648