Lines Matching +full:m1 +full:- +full:gpios

99 	struct ramfuc_reg r_mr[16]; /* MR0 - MR8, MR15 */
133 int N1, fN1, M1, P1; member
149 for (i = 0; (data & 0x80000000) && i < ram->parts; addr += 0x1000, i++) { in gk104_ram_train()
150 if (ram->pmask & (1 << i)) in gk104_ram_train()
160 const u32 mcoef = ((--ram->P2 << 28) | (ram->N2 << 8) | ram->M2); in r1373f4_init()
161 const u32 rcoef = (( ram->P1 << 16) | (ram->N1 << 8) | ram->M1); in r1373f4_init()
162 const u32 runk0 = ram->fN1 << 16; in r1373f4_init()
163 const u32 runk1 = ram->fN1; in r1373f4_init()
165 if (ram->from == 2) { in r1373f4_init()
191 if (ram->mode == 2) { in r1373f4_init()
210 struct nvkm_ram_data *next = ram->base.next; in r1373f4_fini()
211 u8 v0 = next->bios.ramcfg_11_03_c0; in r1373f4_fini()
212 u8 v1 = next->bios.ramcfg_11_03_30; in r1373f4_fini()
217 ram_mask(fuc, 0x1373f0, (~ram->mode & 3), 0x00000000); in r1373f4_fini()
218 if (ram->mode == 2) { in r1373f4_fini()
232 struct nvkm_fb *fb = ram->base.fb; in gk104_ram_nuts()
233 struct ramfuc *fuc = &ram->fuc.base; in gk104_ram_nuts()
234 struct nvkm_device *device = fb->subdev.device; in gk104_ram_nuts()
235 u32 addr = 0x110000 + (reg->addr & 0xfff); in gk104_ram_nuts()
237 u32 data = (_data & _mask) | (reg->data & _copy); in gk104_ram_nuts()
241 if (ram->pnuts & (1 << i)) { in gk104_ram_nuts()
244 nvkm_memx_wr32(fuc->memx, addr, next); in gk104_ram_nuts()
249 gk104_ram_nuts((s), &(s)->fuc.r_##r, (m), (d), (c))
254 struct gk104_ramfuc *fuc = &ram->fuc; in gk104_ram_calc_gddr5()
255 struct nvkm_ram_data *next = ram->base.next; in gk104_ram_calc_gddr5()
256 int vc = !next->bios.ramcfg_11_02_08; in gk104_ram_calc_gddr5()
257 int mv = !next->bios.ramcfg_11_02_04; in gk104_ram_calc_gddr5()
263 if (ram->base.fb->subdev.device->disp) in gk104_ram_calc_gddr5()
267 if ((ram->base.mr[1] & 0x03c) != 0x030) { in gk104_ram_calc_gddr5()
268 ram_mask(fuc, mr[1], 0x03c, ram->base.mr[1] & 0x03c); in gk104_ram_calc_gddr5()
269 ram_nuts(ram, mr[1], 0x03c, ram->base.mr1_nuts & 0x03c, 0x000); in gk104_ram_calc_gddr5()
273 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[1]); in gk104_ram_calc_gddr5()
311 switch (next->bios.ramcfg_11_03_c0) { in gk104_ram_calc_gddr5()
318 switch (next->bios.ramcfg_11_03_30) { in gk104_ram_calc_gddr5()
326 if (next->bios.ramcfg_11_02_80) in gk104_ram_calc_gddr5()
328 if (next->bios.ramcfg_11_02_40) in gk104_ram_calc_gddr5()
330 if (next->bios.ramcfg_11_07_10) in gk104_ram_calc_gddr5()
332 if (next->bios.ramcfg_11_07_08) in gk104_ram_calc_gddr5()
343 if (ram->from == 2 && ram->mode != 2) { in gk104_ram_calc_gddr5()
354 if (ram->from != 2 && ram->mode != 2) { in gk104_ram_calc_gddr5()
360 u32 temp = ram_mask(fuc, gpioMV, 0x3000, fuc->r_funcMV[mv]); in gk104_ram_calc_gddr5()
367 if (next->bios.ramcfg_11_02_40 || in gk104_ram_calc_gddr5()
368 next->bios.ramcfg_11_07_10) { in gk104_ram_calc_gddr5()
373 if (ram->from != 2 && ram->mode == 2) { in gk104_ram_calc_gddr5()
384 if (ram->from == 2 && ram->mode == 2) { in gk104_ram_calc_gddr5()
390 if (ram->mode != 2) /*XXX*/ { in gk104_ram_calc_gddr5()
391 if (next->bios.ramcfg_11_07_40) in gk104_ram_calc_gddr5()
395 ram_wr32(fuc, 0x10f65c, 0x00000011 * next->bios.rammap_11_11_0c); in gk104_ram_calc_gddr5()
396 ram_wr32(fuc, 0x10f6b8, 0x01010101 * next->bios.ramcfg_11_09); in gk104_ram_calc_gddr5()
397 ram_wr32(fuc, 0x10f6bc, 0x01010101 * next->bios.ramcfg_11_09); in gk104_ram_calc_gddr5()
399 if (!next->bios.ramcfg_11_07_08 && !next->bios.ramcfg_11_07_04) { in gk104_ram_calc_gddr5()
400 ram_wr32(fuc, 0x10f698, 0x01010101 * next->bios.ramcfg_11_04); in gk104_ram_calc_gddr5()
401 ram_wr32(fuc, 0x10f69c, 0x01010101 * next->bios.ramcfg_11_04); in gk104_ram_calc_gddr5()
403 if (!next->bios.ramcfg_11_07_08) { in gk104_ram_calc_gddr5()
408 if (ram->mode != 2) { in gk104_ram_calc_gddr5()
409 u32 data = 0x01000100 * next->bios.ramcfg_11_04; in gk104_ram_calc_gddr5()
414 if (ram->mode == 2 && next->bios.ramcfg_11_08_10) in gk104_ram_calc_gddr5()
422 if (!next->bios.ramcfg_11_02_80) in gk104_ram_calc_gddr5()
424 if (!next->bios.ramcfg_11_02_40) in gk104_ram_calc_gddr5()
426 if (!next->bios.ramcfg_11_07_10) in gk104_ram_calc_gddr5()
428 if (!next->bios.ramcfg_11_07_08) in gk104_ram_calc_gddr5()
434 if (next->bios.ramcfg_11_01_08) in gk104_ram_calc_gddr5()
445 if (next->bios.ramcfg_11_08_01) in gk104_ram_calc_gddr5()
452 if (next->bios.ramcfg_11_08_08) in gk104_ram_calc_gddr5()
454 if (next->bios.ramcfg_11_08_04) in gk104_ram_calc_gddr5()
456 if (next->bios.ramcfg_11_08_02) in gk104_ram_calc_gddr5()
461 ram_mask(fuc, 0x10f248, 0xffffffff, next->bios.timing[10]); in gk104_ram_calc_gddr5()
462 ram_mask(fuc, 0x10f290, 0xffffffff, next->bios.timing[0]); in gk104_ram_calc_gddr5()
463 ram_mask(fuc, 0x10f294, 0xffffffff, next->bios.timing[1]); in gk104_ram_calc_gddr5()
464 ram_mask(fuc, 0x10f298, 0xffffffff, next->bios.timing[2]); in gk104_ram_calc_gddr5()
465 ram_mask(fuc, 0x10f29c, 0xffffffff, next->bios.timing[3]); in gk104_ram_calc_gddr5()
466 ram_mask(fuc, 0x10f2a0, 0xffffffff, next->bios.timing[4]); in gk104_ram_calc_gddr5()
467 ram_mask(fuc, 0x10f2a4, 0xffffffff, next->bios.timing[5]); in gk104_ram_calc_gddr5()
468 ram_mask(fuc, 0x10f2a8, 0xffffffff, next->bios.timing[6]); in gk104_ram_calc_gddr5()
469 ram_mask(fuc, 0x10f2ac, 0xffffffff, next->bios.timing[7]); in gk104_ram_calc_gddr5()
470 ram_mask(fuc, 0x10f2cc, 0xffffffff, next->bios.timing[8]); in gk104_ram_calc_gddr5()
471 ram_mask(fuc, 0x10f2e8, 0xffffffff, next->bios.timing[9]); in gk104_ram_calc_gddr5()
474 if (ram->diff.ramcfg_11_08_20) { in gk104_ram_calc_gddr5()
475 if (next->bios.ramcfg_11_08_20) in gk104_ram_calc_gddr5()
482 if (ram->diff.ramcfg_11_02_03) { in gk104_ram_calc_gddr5()
483 data |= next->bios.ramcfg_11_02_03 << 8; in gk104_ram_calc_gddr5()
486 if (ram->diff.ramcfg_11_01_10) { in gk104_ram_calc_gddr5()
487 if (next->bios.ramcfg_11_01_10) in gk104_ram_calc_gddr5()
494 if (ram->diff.timing_20_30_07) { in gk104_ram_calc_gddr5()
495 data |= next->bios.timing_20_30_07 << 28; in gk104_ram_calc_gddr5()
498 if (ram->diff.ramcfg_11_01_01) { in gk104_ram_calc_gddr5()
499 if (next->bios.ramcfg_11_01_01) in gk104_ram_calc_gddr5()
506 if (ram->diff.timing_20_30_07) { in gk104_ram_calc_gddr5()
507 data |= next->bios.timing_20_30_07 << 28; in gk104_ram_calc_gddr5()
510 if (ram->diff.ramcfg_11_01_02) { in gk104_ram_calc_gddr5()
511 if (next->bios.ramcfg_11_01_02) in gk104_ram_calc_gddr5()
519 if (!next->bios.ramcfg_11_01_04) in gk104_ram_calc_gddr5()
521 if (!next->bios.ramcfg_11_07_80) in gk104_ram_calc_gddr5()
526 if (next->bios.ramcfg_11_03_f0) { in gk104_ram_calc_gddr5()
527 if (next->bios.rammap_11_08_0c) { in gk104_ram_calc_gddr5()
528 if (!next->bios.ramcfg_11_07_80) in gk104_ram_calc_gddr5()
541 ram_wr32(fuc, 0x10f870, 0x11111111 * next->bios.ramcfg_11_03_0f); in gk104_ram_calc_gddr5()
544 if (ram->diff.ramcfg_11_02_03) { in gk104_ram_calc_gddr5()
545 data |= next->bios.ramcfg_11_02_03; in gk104_ram_calc_gddr5()
548 if (ram->diff.ramcfg_11_01_10) { in gk104_ram_calc_gddr5()
549 if (next->bios.ramcfg_11_01_10) in gk104_ram_calc_gddr5()
560 data = next->bios.timing_20_30_07 << 8; in gk104_ram_calc_gddr5()
561 if (next->bios.ramcfg_11_01_01) in gk104_ram_calc_gddr5()
565 ram_mask(fuc, 0x10f250, 0x000003f0, next->bios.timing_20_2c_003f << 4); in gk104_ram_calc_gddr5()
566 data = (next->bios.timing[10] & 0x7f000000) >> 24; in gk104_ram_calc_gddr5()
567 if (data < next->bios.timing_20_2c_1fc0) in gk104_ram_calc_gddr5()
568 data = next->bios.timing_20_2c_1fc0; in gk104_ram_calc_gddr5()
570 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8 << 16); in gk104_ram_calc_gddr5()
572 ram_mask(fuc, 0x10fec4, 0x041e0f07, next->bios.timing_20_31_0800 << 26 | in gk104_ram_calc_gddr5()
573 next->bios.timing_20_31_0780 << 17 | in gk104_ram_calc_gddr5()
574 next->bios.timing_20_31_0078 << 8 | in gk104_ram_calc_gddr5()
575 next->bios.timing_20_31_0007); in gk104_ram_calc_gddr5()
576 ram_mask(fuc, 0x10fec8, 0x00000027, next->bios.timing_20_31_8000 << 5 | in gk104_ram_calc_gddr5()
577 next->bios.timing_20_31_7000); in gk104_ram_calc_gddr5()
585 if (next->bios.ramcfg_11_08_10 && (ram->mode == 2) /*XXX*/) { in gk104_ram_calc_gddr5()
592 ram_mask(fuc, mr[3], 0xfff, ram->base.mr[3]); in gk104_ram_calc_gddr5()
593 ram_wr32(fuc, mr[0], ram->base.mr[0]); in gk104_ram_calc_gddr5()
594 ram_mask(fuc, mr[8], 0xfff, ram->base.mr[8]); in gk104_ram_calc_gddr5()
596 ram_mask(fuc, mr[1], 0xfff, ram->base.mr[1]); in gk104_ram_calc_gddr5()
597 ram_mask(fuc, mr[5], 0xfff, ram->base.mr[5] & ~0x004); /* LP3 later */ in gk104_ram_calc_gddr5()
598 ram_mask(fuc, mr[6], 0xfff, ram->base.mr[6]); in gk104_ram_calc_gddr5()
599 ram_mask(fuc, mr[7], 0xfff, ram->base.mr[7]); in gk104_ram_calc_gddr5()
602 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[0]); in gk104_ram_calc_gddr5()
618 if (!next->bios.ramcfg_11_07_08) { in gk104_ram_calc_gddr5()
619 if (!next->bios.ramcfg_11_07_04) in gk104_ram_calc_gddr5()
628 if (ram->mode == 1) { in gk104_ram_calc_gddr5()
633 if (!next->bios.ramcfg_11_07_08) { in gk104_ram_calc_gddr5()
635 if ( next->bios.ramcfg_11_07_04) in gk104_ram_calc_gddr5()
637 if (!next->bios.rammap_11_08_10) in gk104_ram_calc_gddr5()
646 if (ram->mode == 2) { /*XXX*/ in gk104_ram_calc_gddr5()
651 if (ram_mask(fuc, mr[5], 0x004, ram->base.mr[5]) != ram->base.mr[5]) in gk104_ram_calc_gddr5()
654 if (ram->mode != 2) { in gk104_ram_calc_gddr5()
659 if (next->bios.ramcfg_11_07_02) in gk104_ram_calc_gddr5()
664 if (ram->base.fb->subdev.device->disp) in gk104_ram_calc_gddr5()
667 if (next->bios.rammap_11_08_01) in gk104_ram_calc_gddr5()
702 struct gk104_ramfuc *fuc = &ram->fuc; in gk104_ram_calc_sddr3()
703 const u32 rcoef = (( ram->P1 << 16) | (ram->N1 << 8) | ram->M1); in gk104_ram_calc_sddr3()
704 const u32 runk0 = ram->fN1 << 16; in gk104_ram_calc_sddr3()
705 const u32 runk1 = ram->fN1; in gk104_ram_calc_sddr3()
706 struct nvkm_ram_data *next = ram->base.next; in gk104_ram_calc_sddr3()
707 int vc = !next->bios.ramcfg_11_02_08; in gk104_ram_calc_sddr3()
708 int mv = !next->bios.ramcfg_11_02_04; in gk104_ram_calc_sddr3()
714 if (ram->base.fb->subdev.device->disp) in gk104_ram_calc_sddr3()
718 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[1]); in gk104_ram_calc_sddr3()
726 if (next->bios.ramcfg_11_03_f0) in gk104_ram_calc_sddr3()
731 if (next->bios.ramcfg_DLLoff) in gk104_ram_calc_sddr3()
755 switch (next->bios.ramcfg_11_03_c0) { in gk104_ram_calc_sddr3()
762 switch (next->bios.ramcfg_11_03_30) { in gk104_ram_calc_sddr3()
770 if (next->bios.ramcfg_11_02_80) in gk104_ram_calc_sddr3()
772 if (next->bios.ramcfg_11_02_40) in gk104_ram_calc_sddr3()
774 if (next->bios.ramcfg_11_07_10) in gk104_ram_calc_sddr3()
776 if (next->bios.ramcfg_11_07_08) in gk104_ram_calc_sddr3()
786 data |= next->bios.ramcfg_11_03_30 << 16; in gk104_ram_calc_sddr3()
811 u32 temp = ram_mask(fuc, gpioMV, 0x3000, fuc->r_funcMV[mv]); in gk104_ram_calc_sddr3()
818 if (next->bios.ramcfg_11_02_40 || in gk104_ram_calc_sddr3()
819 next->bios.ramcfg_11_07_10) { in gk104_ram_calc_sddr3()
824 if (ram->mode != 2) /*XXX*/ { in gk104_ram_calc_sddr3()
825 if (next->bios.ramcfg_11_07_40) in gk104_ram_calc_sddr3()
829 ram_wr32(fuc, 0x10f65c, 0x00000011 * next->bios.rammap_11_11_0c); in gk104_ram_calc_sddr3()
830 ram_wr32(fuc, 0x10f6b8, 0x01010101 * next->bios.ramcfg_11_09); in gk104_ram_calc_sddr3()
831 ram_wr32(fuc, 0x10f6bc, 0x01010101 * next->bios.ramcfg_11_09); in gk104_ram_calc_sddr3()
835 if (!next->bios.ramcfg_11_02_80) in gk104_ram_calc_sddr3()
837 if (!next->bios.ramcfg_11_02_40) in gk104_ram_calc_sddr3()
839 if (!next->bios.ramcfg_11_07_10) in gk104_ram_calc_sddr3()
841 if (!next->bios.ramcfg_11_07_08) in gk104_ram_calc_sddr3()
848 if (next->bios.ramcfg_11_08_01) in gk104_ram_calc_sddr3()
855 ram_mask(fuc, 0x10f248, 0xffffffff, next->bios.timing[10]); in gk104_ram_calc_sddr3()
856 ram_mask(fuc, 0x10f290, 0xffffffff, next->bios.timing[0]); in gk104_ram_calc_sddr3()
857 ram_mask(fuc, 0x10f294, 0xffffffff, next->bios.timing[1]); in gk104_ram_calc_sddr3()
858 ram_mask(fuc, 0x10f298, 0xffffffff, next->bios.timing[2]); in gk104_ram_calc_sddr3()
859 ram_mask(fuc, 0x10f29c, 0xffffffff, next->bios.timing[3]); in gk104_ram_calc_sddr3()
860 ram_mask(fuc, 0x10f2a0, 0xffffffff, next->bios.timing[4]); in gk104_ram_calc_sddr3()
861 ram_mask(fuc, 0x10f2a4, 0xffffffff, next->bios.timing[5]); in gk104_ram_calc_sddr3()
862 ram_mask(fuc, 0x10f2a8, 0xffffffff, next->bios.timing[6]); in gk104_ram_calc_sddr3()
863 ram_mask(fuc, 0x10f2ac, 0xffffffff, next->bios.timing[7]); in gk104_ram_calc_sddr3()
864 ram_mask(fuc, 0x10f2cc, 0xffffffff, next->bios.timing[8]); in gk104_ram_calc_sddr3()
865 ram_mask(fuc, 0x10f2e8, 0xffffffff, next->bios.timing[9]); in gk104_ram_calc_sddr3()
869 if (!next->bios.ramcfg_11_01_04) in gk104_ram_calc_sddr3()
871 if (!next->bios.ramcfg_11_07_80) in gk104_ram_calc_sddr3()
876 if (next->bios.ramcfg_11_03_f0) { in gk104_ram_calc_sddr3()
877 if (next->bios.rammap_11_08_0c) { in gk104_ram_calc_sddr3()
878 if (!next->bios.ramcfg_11_07_80) in gk104_ram_calc_sddr3()
892 ram_wr32(fuc, 0x10f870, 0x11111111 * next->bios.ramcfg_11_03_0f); in gk104_ram_calc_sddr3()
894 ram_mask(fuc, 0x10f250, 0x000003f0, next->bios.timing_20_2c_003f << 4); in gk104_ram_calc_sddr3()
896 data = (next->bios.timing[10] & 0x7f000000) >> 24; in gk104_ram_calc_sddr3()
897 if (data < next->bios.timing_20_2c_1fc0) in gk104_ram_calc_sddr3()
898 data = next->bios.timing_20_2c_1fc0; in gk104_ram_calc_sddr3()
901 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8 << 16); in gk104_ram_calc_sddr3()
911 if (!next->bios.ramcfg_DLLoff) { in gk104_ram_calc_sddr3()
916 ram_mask(fuc, mr[2], 0x00000fff, ram->base.mr[2]); in gk104_ram_calc_sddr3()
917 ram_mask(fuc, mr[1], 0xffffffff, ram->base.mr[1]); in gk104_ram_calc_sddr3()
918 ram_wr32(fuc, mr[0], ram->base.mr[0]); in gk104_ram_calc_sddr3()
921 if (!next->bios.ramcfg_DLLoff) { in gk104_ram_calc_sddr3()
927 u32 temp = ram_mask(fuc, gpio2E, 0x3000, fuc->r_func2E[0]); in gk104_ram_calc_sddr3()
934 if (ram->mode != 2) { in gk104_ram_calc_sddr3()
946 if (ram->base.fb->subdev.device->disp) in gk104_ram_calc_sddr3()
949 if (next->bios.rammap_11_08_01) in gk104_ram_calc_sddr3()
964 struct nvkm_subdev *subdev = &ram->base.fb->subdev; in gk104_ram_calc_data()
968 list_for_each_entry(cfg, &ram->cfg, head) { in gk104_ram_calc_data()
969 if (mhz >= cfg->bios.rammap_min && in gk104_ram_calc_data()
970 mhz <= cfg->bios.rammap_max) { in gk104_ram_calc_data()
972 data->freq = khz; in gk104_ram_calc_data()
978 return -EINVAL; in gk104_ram_calc_data()
989 int *N1, int *fN1, int *M1, int *P1, in gk104_pll_calc_hiclk() argument
995 *M1 = 1; in gk104_pll_calc_hiclk()
1001 for (p_ref = 0x7; p_ref >= 0x5; --p_ref) { in gk104_pll_calc_hiclk()
1008 - gk104_calc_pll_output(0xf000, 1, cur_N, 1, cur_clk); in gk104_pll_calc_hiclk()
1021 - target_khz; in gk104_pll_calc_hiclk()
1033 *fN1 = (u16)((((best_err / *N2 * *P2) * (*P1 * *M1)) << 13) / crystal); in gk104_pll_calc_hiclk()
1035 *fN1 = (u16)(1 - *fN1); in gk104_pll_calc_hiclk()
1043 struct gk104_ramfuc *fuc = &ram->fuc; in gk104_ram_calc_xits()
1044 struct nvkm_subdev *subdev = &ram->base.fb->subdev; in gk104_ram_calc_xits()
1048 ret = ram_init(fuc, ram->base.fb); in gk104_ram_calc_xits()
1052 ram->mode = (next->freq > fuc->refpll.vco1.max_freq) ? 2 : 1; in gk104_ram_calc_xits()
1053 ram->from = ram_rd32(fuc, 0x1373f4) & 0x0000000f; in gk104_ram_calc_xits()
1063 refclk = next->freq; in gk104_ram_calc_xits()
1064 if (ram->mode == 2) { in gk104_ram_calc_xits()
1065 ret = gk104_pll_calc_hiclk(next->freq, subdev->device->crystal, in gk104_ram_calc_xits()
1066 &ram->N1, &ram->fN1, &ram->M1, &ram->P1, in gk104_ram_calc_xits()
1067 &ram->N2, &ram->M2, &ram->P2); in gk104_ram_calc_xits()
1068 fuc->mempll.refclk = ret; in gk104_ram_calc_xits()
1071 return -EINVAL; in gk104_ram_calc_xits()
1074 " (refclock: %i kHz)\n", next->freq, ret); in gk104_ram_calc_xits()
1077 ret = gt215_pll_calc(subdev, &fuc->refpll, refclk, &ram->N1, in gk104_ram_calc_xits()
1078 &ram->fN1, &ram->M1, &ram->P1); in gk104_ram_calc_xits()
1079 fuc->mempll.refclk = ret; in gk104_ram_calc_xits()
1082 return -EINVAL; in gk104_ram_calc_xits()
1086 for (i = 0; i < ARRAY_SIZE(fuc->r_mr); i++) { in gk104_ram_calc_xits()
1088 ram->base.mr[i] = ram_rd32(fuc, mr[i]); in gk104_ram_calc_xits()
1090 ram->base.freq = next->freq; in gk104_ram_calc_xits()
1092 switch (ram->base.type) { in gk104_ram_calc_xits()
1094 ret = nvkm_sddr3_calc(&ram->base); in gk104_ram_calc_xits()
1096 ret = gk104_ram_calc_sddr3(ram, next->freq); in gk104_ram_calc_xits()
1099 ret = nvkm_gddr5_calc(&ram->base, ram->pnuts != 0); in gk104_ram_calc_xits()
1101 ret = gk104_ram_calc_gddr5(ram, next->freq); in gk104_ram_calc_xits()
1104 ret = -ENOSYS; in gk104_ram_calc_xits()
1115 struct nvkm_clk *clk = ram->base.fb->subdev.device->clk; in gk104_ram_calc()
1116 struct nvkm_ram_data *xits = &ram->base.xition; in gk104_ram_calc()
1120 if (ram->base.next == NULL) { in gk104_ram_calc()
1123 &ram->base.former); in gk104_ram_calc()
1127 ret = gk104_ram_calc_data(ram, freq, &ram->base.target); in gk104_ram_calc()
1131 if (ram->base.target.freq < ram->base.former.freq) { in gk104_ram_calc()
1132 *xits = ram->base.target; in gk104_ram_calc()
1133 copy = &ram->base.former; in gk104_ram_calc()
1135 *xits = ram->base.former; in gk104_ram_calc()
1136 copy = &ram->base.target; in gk104_ram_calc()
1139 xits->bios.ramcfg_11_02_04 = copy->bios.ramcfg_11_02_04; in gk104_ram_calc()
1140 xits->bios.ramcfg_11_02_03 = copy->bios.ramcfg_11_02_03; in gk104_ram_calc()
1141 xits->bios.timing_20_30_07 = copy->bios.timing_20_30_07; in gk104_ram_calc()
1143 ram->base.next = &ram->base.target; in gk104_ram_calc()
1144 if (memcmp(xits, &ram->base.former, sizeof(xits->bios))) in gk104_ram_calc()
1145 ram->base.next = &ram->base.xition; in gk104_ram_calc()
1147 BUG_ON(ram->base.next != &ram->base.xition); in gk104_ram_calc()
1148 ram->base.next = &ram->base.target; in gk104_ram_calc()
1151 return gk104_ram_calc_xits(ram, ram->base.next); in gk104_ram_calc()
1157 struct nvkm_device *device = ram->base.fb->subdev.device; in gk104_ram_prog_0()
1162 list_for_each_entry(cfg, &ram->cfg, head) { in gk104_ram_prog_0()
1163 if (mhz >= cfg->bios.rammap_min && in gk104_ram_prog_0()
1164 mhz <= cfg->bios.rammap_max) in gk104_ram_prog_0()
1168 if (&cfg->head == &ram->cfg) in gk104_ram_prog_0()
1171 if (mask = 0, data = 0, ram->diff.rammap_11_0a_03fe) { in gk104_ram_prog_0()
1172 data |= cfg->bios.rammap_11_0a_03fe << 12; in gk104_ram_prog_0()
1175 if (ram->diff.rammap_11_09_01ff) { in gk104_ram_prog_0()
1176 data |= cfg->bios.rammap_11_09_01ff; in gk104_ram_prog_0()
1181 if (mask = 0, data = 0, ram->diff.rammap_11_0a_0400) { in gk104_ram_prog_0()
1182 data |= cfg->bios.rammap_11_0a_0400; in gk104_ram_prog_0()
1187 if (mask = 0, data = 0, ram->diff.rammap_11_0a_0800) { in gk104_ram_prog_0()
1188 data |= cfg->bios.rammap_11_0a_0800; in gk104_ram_prog_0()
1193 if (mask = 0, data = 0, ram->diff.rammap_11_0b_01f0) { in gk104_ram_prog_0()
1194 data |= cfg->bios.rammap_11_0b_01f0; in gk104_ram_prog_0()
1199 if (mask = 0, data = 0, ram->diff.rammap_11_0b_0200) { in gk104_ram_prog_0()
1200 data |= cfg->bios.rammap_11_0b_0200 << 9; in gk104_ram_prog_0()
1205 if (mask = 0, data = 0, ram->diff.rammap_11_0d) { in gk104_ram_prog_0()
1206 data |= cfg->bios.rammap_11_0d << 16; in gk104_ram_prog_0()
1209 if (ram->diff.rammap_11_0f) { in gk104_ram_prog_0()
1210 data |= cfg->bios.rammap_11_0f << 8; in gk104_ram_prog_0()
1215 if (mask = 0, data = 0, ram->diff.rammap_11_0e) { in gk104_ram_prog_0()
1216 data |= cfg->bios.rammap_11_0e << 8; in gk104_ram_prog_0()
1219 if (ram->diff.rammap_11_0b_0800) { in gk104_ram_prog_0()
1220 data |= cfg->bios.rammap_11_0b_0800 << 7; in gk104_ram_prog_0()
1223 if (ram->diff.rammap_11_0b_0400) { in gk104_ram_prog_0()
1224 data |= cfg->bios.rammap_11_0b_0400 << 5; in gk104_ram_prog_0()
1234 struct gk104_ramfuc *fuc = &ram->fuc; in gk104_ram_prog()
1235 struct nvkm_device *device = ram->base.fb->subdev.device; in gk104_ram_prog()
1236 struct nvkm_ram_data *next = ram->base.next; in gk104_ram_prog()
1238 if (!nvkm_boolopt(device->cfgopt, "NvMemExec", true)) { in gk104_ram_prog()
1240 return (ram->base.next == &ram->base.xition); in gk104_ram_prog()
1245 gk104_ram_prog_0(ram, next->freq); in gk104_ram_prog()
1247 return (ram->base.next == &ram->base.xition); in gk104_ram_prog()
1254 ram->base.next = NULL; in gk104_ram_tidy()
1255 ram_exec(&ram->fuc, false); in gk104_ram_tidy()
1274 struct nvkm_bios *bios = ram->fb->subdev.device->bios; in gk104_ram_train_type()
1278 struct nvbios_M0209S *remap = &train->remap; in gk104_ram_train_type()
1285 return -ENOENT; in gk104_ram_train_type()
1288 case 0x00: value = &train->type00; break; in gk104_ram_train_type()
1289 case 0x01: value = &train->type01; break; in gk104_ram_train_type()
1290 case 0x04: value = &train->type04; break; in gk104_ram_train_type()
1291 case 0x06: value = &train->type06; break; in gk104_ram_train_type()
1292 case 0x07: value = &train->type07; break; in gk104_ram_train_type()
1293 case 0x08: value = &train->type08; break; in gk104_ram_train_type()
1294 case 0x09: value = &train->type09; break; in gk104_ram_train_type()
1301 return -EINVAL; in gk104_ram_train_type()
1306 return -EINVAL; in gk104_ram_train_type()
1310 return -EINVAL; in gk104_ram_train_type()
1319 return -EINVAL; in gk104_ram_train_type()
1321 for (i = 0; i < ARRAY_SIZE(value->data); i++) in gk104_ram_train_type()
1322 value->data[i] = remap->data[value->data[i]]; in gk104_ram_train_type()
1325 return -EINVAL; in gk104_ram_train_type()
1327 train->mask |= 1 << M0205E.type; in gk104_ram_train_type()
1334 struct nvkm_subdev *subdev = &ram->fb->subdev; in gk104_ram_train_init_0()
1335 struct nvkm_device *device = subdev->device; in gk104_ram_train_init_0()
1338 if ((train->mask & 0x03d3) != 0x03d3) { in gk104_ram_train_init_0()
1340 return -EINVAL; in gk104_ram_train_init_0()
1347 train->type08.data[i] << 4 | in gk104_ram_train_init_0()
1348 train->type06.data[i]); in gk104_ram_train_init_0()
1349 nvkm_wr32(device, 0x10f918 + j, train->type00.data[i]); in gk104_ram_train_init_0()
1351 train->type09.data[i] << 4 | in gk104_ram_train_init_0()
1352 train->type07.data[i]); in gk104_ram_train_init_0()
1353 nvkm_wr32(device, 0x10f918 + j, train->type01.data[i]); in gk104_ram_train_init_0()
1360 nvkm_wr32(device, 0x10f900 + j, train->type04.data[i]); in gk104_ram_train_init_0()
1370 u8 ramcfg = nvbios_ramcfg_index(&ram->fb->subdev); in gk104_ram_train_init()
1375 return -ENOMEM; in gk104_ram_train_init()
1379 if (ret && ret != -ENOENT) in gk104_ram_train_init()
1383 switch (ram->type) { in gk104_ram_train_init()
1399 struct nvkm_subdev *subdev = &ram->fb->subdev; in gk104_ram_init()
1400 struct nvkm_device *device = subdev->device; in gk104_ram_init()
1401 struct nvkm_bios *bios = device->bios; in gk104_ram_init()
1419 return -EINVAL; in gk104_ram_init()
1441 struct nvkm_bios *bios = ram->base.fb->subdev.device->bios; in gk104_ram_ctor_data()
1443 struct nvbios_ramcfg *d = &ram->diff; in gk104_ram_ctor_data()
1450 return -ENOMEM; in gk104_ram_ctor_data()
1451 p = &list_last_entry(&ram->cfg, typeof(*cfg), head)->bios; in gk104_ram_ctor_data()
1452 n = &cfg->bios; in gk104_ram_ctor_data()
1455 data = nvbios_rammapEp(bios, i, &ver, &hdr, &cnt, &len, &cfg->bios); in gk104_ram_ctor_data()
1456 if (ret = -ENOENT, !data) in gk104_ram_ctor_data()
1458 if (ret = -ENOSYS, ver != 0x11 || hdr < 0x12) in gk104_ram_ctor_data()
1463 &ver, &hdr, &cfg->bios); in gk104_ram_ctor_data()
1464 if (ret = -EINVAL, !data) in gk104_ram_ctor_data()
1466 if (ret = -ENOSYS, ver != 0x11 || hdr < 0x0a) in gk104_ram_ctor_data()
1470 if (cfg->bios.ramcfg_timing != 0xff) { in gk104_ram_ctor_data()
1471 data = nvbios_timingEp(bios, cfg->bios.ramcfg_timing, in gk104_ram_ctor_data()
1473 &cfg->bios); in gk104_ram_ctor_data()
1474 if (ret = -EINVAL, !data) in gk104_ram_ctor_data()
1476 if (ret = -ENOSYS, ver != 0x20 || hdr < 0x33) in gk104_ram_ctor_data()
1480 list_add_tail(&cfg->head, &ram->cfg); in gk104_ram_ctor_data()
1484 d->rammap_11_0a_03fe |= p->rammap_11_0a_03fe != n->rammap_11_0a_03fe; in gk104_ram_ctor_data()
1485 d->rammap_11_09_01ff |= p->rammap_11_09_01ff != n->rammap_11_09_01ff; in gk104_ram_ctor_data()
1486 d->rammap_11_0a_0400 |= p->rammap_11_0a_0400 != n->rammap_11_0a_0400; in gk104_ram_ctor_data()
1487 d->rammap_11_0a_0800 |= p->rammap_11_0a_0800 != n->rammap_11_0a_0800; in gk104_ram_ctor_data()
1488 d->rammap_11_0b_01f0 |= p->rammap_11_0b_01f0 != n->rammap_11_0b_01f0; in gk104_ram_ctor_data()
1489 d->rammap_11_0b_0200 |= p->rammap_11_0b_0200 != n->rammap_11_0b_0200; in gk104_ram_ctor_data()
1490 d->rammap_11_0d |= p->rammap_11_0d != n->rammap_11_0d; in gk104_ram_ctor_data()
1491 d->rammap_11_0f |= p->rammap_11_0f != n->rammap_11_0f; in gk104_ram_ctor_data()
1492 d->rammap_11_0e |= p->rammap_11_0e != n->rammap_11_0e; in gk104_ram_ctor_data()
1493 d->rammap_11_0b_0800 |= p->rammap_11_0b_0800 != n->rammap_11_0b_0800; in gk104_ram_ctor_data()
1494 d->rammap_11_0b_0400 |= p->rammap_11_0b_0400 != n->rammap_11_0b_0400; in gk104_ram_ctor_data()
1495 d->ramcfg_11_01_01 |= p->ramcfg_11_01_01 != n->ramcfg_11_01_01; in gk104_ram_ctor_data()
1496 d->ramcfg_11_01_02 |= p->ramcfg_11_01_02 != n->ramcfg_11_01_02; in gk104_ram_ctor_data()
1497 d->ramcfg_11_01_10 |= p->ramcfg_11_01_10 != n->ramcfg_11_01_10; in gk104_ram_ctor_data()
1498 d->ramcfg_11_02_03 |= p->ramcfg_11_02_03 != n->ramcfg_11_02_03; in gk104_ram_ctor_data()
1499 d->ramcfg_11_08_20 |= p->ramcfg_11_08_20 != n->ramcfg_11_08_20; in gk104_ram_ctor_data()
1500 d->timing_20_30_07 |= p->timing_20_30_07 != n->timing_20_30_07; in gk104_ram_ctor_data()
1513 list_for_each_entry_safe(cfg, tmp, &ram->cfg, head) { in gk104_ram_dtor()
1524 struct nvkm_subdev *subdev = &fb->subdev; in gk104_ram_new_()
1525 struct nvkm_device *device = subdev->device; in gk104_ram_new_()
1526 struct nvkm_bios *bios = device->bios; in gk104_ram_new_()
1534 return -ENOMEM; in gk104_ram_new_()
1535 *pram = &ram->base; in gk104_ram_new_()
1537 ret = gf100_ram_ctor(func, fb, &ram->base); in gk104_ram_new_()
1541 INIT_LIST_HEAD(&ram->cfg); in gk104_ram_new_()
1548 ram->parts = nvkm_rd32(device, 0x022438); in gk104_ram_new_()
1549 ram->pmask = nvkm_rd32(device, 0x022554); in gk104_ram_new_()
1550 ram->pnuts = 0; in gk104_ram_new_()
1551 for (i = 0, tmp = 0; i < ram->parts; i++) { in gk104_ram_new_()
1552 if (!(ram->pmask & (1 << i))) { in gk104_ram_new_()
1555 ram->pnuts |= (1 << i); in gk104_ram_new_()
1562 /* parse bios data for all rammap table entries up-front, and in gk104_ram_new_()
1575 if (ret && ret != -ENOENT) { in gk104_ram_new_()
1582 ret = nvbios_pll_parse(bios, 0x0c, &ram->fuc.refpll); in gk104_ram_new_()
1588 ret = nvbios_pll_parse(bios, 0x04, &ram->fuc.mempll); in gk104_ram_new_()
1594 /* lookup memory voltage gpios */ in gk104_ram_new_()
1595 ret = nvkm_gpio_find(device->gpio, 0, 0x18, DCB_GPIO_UNUSED, &gpio); in gk104_ram_new_()
1597 ram->fuc.r_gpioMV = ramfuc_reg(0x00d610 + (gpio.line * 0x04)); in gk104_ram_new_()
1598 ram->fuc.r_funcMV[0] = (gpio.log[0] ^ 2) << 12; in gk104_ram_new_()
1599 ram->fuc.r_funcMV[1] = (gpio.log[1] ^ 2) << 12; in gk104_ram_new_()
1602 ret = nvkm_gpio_find(device->gpio, 0, 0x2e, DCB_GPIO_UNUSED, &gpio); in gk104_ram_new_()
1604 ram->fuc.r_gpio2E = ramfuc_reg(0x00d610 + (gpio.line * 0x04)); in gk104_ram_new_()
1605 ram->fuc.r_func2E[0] = (gpio.log[0] ^ 2) << 12; in gk104_ram_new_()
1606 ram->fuc.r_func2E[1] = (gpio.log[1] ^ 2) << 12; in gk104_ram_new_()
1609 ram->fuc.r_gpiotrig = ramfuc_reg(0x00d604); in gk104_ram_new_()
1611 ram->fuc.r_0x132020 = ramfuc_reg(0x132020); in gk104_ram_new_()
1612 ram->fuc.r_0x132028 = ramfuc_reg(0x132028); in gk104_ram_new_()
1613 ram->fuc.r_0x132024 = ramfuc_reg(0x132024); in gk104_ram_new_()
1614 ram->fuc.r_0x132030 = ramfuc_reg(0x132030); in gk104_ram_new_()
1615 ram->fuc.r_0x132034 = ramfuc_reg(0x132034); in gk104_ram_new_()
1616 ram->fuc.r_0x132000 = ramfuc_reg(0x132000); in gk104_ram_new_()
1617 ram->fuc.r_0x132004 = ramfuc_reg(0x132004); in gk104_ram_new_()
1618 ram->fuc.r_0x132040 = ramfuc_reg(0x132040); in gk104_ram_new_()
1620 ram->fuc.r_0x10f248 = ramfuc_reg(0x10f248); in gk104_ram_new_()
1621 ram->fuc.r_0x10f290 = ramfuc_reg(0x10f290); in gk104_ram_new_()
1622 ram->fuc.r_0x10f294 = ramfuc_reg(0x10f294); in gk104_ram_new_()
1623 ram->fuc.r_0x10f298 = ramfuc_reg(0x10f298); in gk104_ram_new_()
1624 ram->fuc.r_0x10f29c = ramfuc_reg(0x10f29c); in gk104_ram_new_()
1625 ram->fuc.r_0x10f2a0 = ramfuc_reg(0x10f2a0); in gk104_ram_new_()
1626 ram->fuc.r_0x10f2a4 = ramfuc_reg(0x10f2a4); in gk104_ram_new_()
1627 ram->fuc.r_0x10f2a8 = ramfuc_reg(0x10f2a8); in gk104_ram_new_()
1628 ram->fuc.r_0x10f2ac = ramfuc_reg(0x10f2ac); in gk104_ram_new_()
1629 ram->fuc.r_0x10f2cc = ramfuc_reg(0x10f2cc); in gk104_ram_new_()
1630 ram->fuc.r_0x10f2e8 = ramfuc_reg(0x10f2e8); in gk104_ram_new_()
1631 ram->fuc.r_0x10f250 = ramfuc_reg(0x10f250); in gk104_ram_new_()
1632 ram->fuc.r_0x10f24c = ramfuc_reg(0x10f24c); in gk104_ram_new_()
1633 ram->fuc.r_0x10fec4 = ramfuc_reg(0x10fec4); in gk104_ram_new_()
1634 ram->fuc.r_0x10fec8 = ramfuc_reg(0x10fec8); in gk104_ram_new_()
1635 ram->fuc.r_0x10f604 = ramfuc_reg(0x10f604); in gk104_ram_new_()
1636 ram->fuc.r_0x10f614 = ramfuc_reg(0x10f614); in gk104_ram_new_()
1637 ram->fuc.r_0x10f610 = ramfuc_reg(0x10f610); in gk104_ram_new_()
1638 ram->fuc.r_0x100770 = ramfuc_reg(0x100770); in gk104_ram_new_()
1639 ram->fuc.r_0x100778 = ramfuc_reg(0x100778); in gk104_ram_new_()
1640 ram->fuc.r_0x10f224 = ramfuc_reg(0x10f224); in gk104_ram_new_()
1642 ram->fuc.r_0x10f870 = ramfuc_reg(0x10f870); in gk104_ram_new_()
1643 ram->fuc.r_0x10f698 = ramfuc_reg(0x10f698); in gk104_ram_new_()
1644 ram->fuc.r_0x10f694 = ramfuc_reg(0x10f694); in gk104_ram_new_()
1645 ram->fuc.r_0x10f6b8 = ramfuc_reg(0x10f6b8); in gk104_ram_new_()
1646 ram->fuc.r_0x10f808 = ramfuc_reg(0x10f808); in gk104_ram_new_()
1647 ram->fuc.r_0x10f670 = ramfuc_reg(0x10f670); in gk104_ram_new_()
1648 ram->fuc.r_0x10f60c = ramfuc_reg(0x10f60c); in gk104_ram_new_()
1649 ram->fuc.r_0x10f830 = ramfuc_reg(0x10f830); in gk104_ram_new_()
1650 ram->fuc.r_0x1373ec = ramfuc_reg(0x1373ec); in gk104_ram_new_()
1651 ram->fuc.r_0x10f800 = ramfuc_reg(0x10f800); in gk104_ram_new_()
1652 ram->fuc.r_0x10f82c = ramfuc_reg(0x10f82c); in gk104_ram_new_()
1654 ram->fuc.r_0x10f978 = ramfuc_reg(0x10f978); in gk104_ram_new_()
1655 ram->fuc.r_0x10f910 = ramfuc_reg(0x10f910); in gk104_ram_new_()
1656 ram->fuc.r_0x10f914 = ramfuc_reg(0x10f914); in gk104_ram_new_()
1658 switch (ram->base.type) { in gk104_ram_new_()
1660 ram->fuc.r_mr[0] = ramfuc_reg(0x10f300); in gk104_ram_new_()
1661 ram->fuc.r_mr[1] = ramfuc_reg(0x10f330); in gk104_ram_new_()
1662 ram->fuc.r_mr[2] = ramfuc_reg(0x10f334); in gk104_ram_new_()
1663 ram->fuc.r_mr[3] = ramfuc_reg(0x10f338); in gk104_ram_new_()
1664 ram->fuc.r_mr[4] = ramfuc_reg(0x10f33c); in gk104_ram_new_()
1665 ram->fuc.r_mr[5] = ramfuc_reg(0x10f340); in gk104_ram_new_()
1666 ram->fuc.r_mr[6] = ramfuc_reg(0x10f344); in gk104_ram_new_()
1667 ram->fuc.r_mr[7] = ramfuc_reg(0x10f348); in gk104_ram_new_()
1668 ram->fuc.r_mr[8] = ramfuc_reg(0x10f354); in gk104_ram_new_()
1669 ram->fuc.r_mr[15] = ramfuc_reg(0x10f34c); in gk104_ram_new_()
1672 ram->fuc.r_mr[0] = ramfuc_reg(0x10f300); in gk104_ram_new_()
1673 ram->fuc.r_mr[1] = ramfuc_reg(0x10f304); in gk104_ram_new_()
1674 ram->fuc.r_mr[2] = ramfuc_reg(0x10f320); in gk104_ram_new_()
1680 ram->fuc.r_0x62c000 = ramfuc_reg(0x62c000); in gk104_ram_new_()
1681 ram->fuc.r_0x10f200 = ramfuc_reg(0x10f200); in gk104_ram_new_()
1682 ram->fuc.r_0x10f210 = ramfuc_reg(0x10f210); in gk104_ram_new_()
1683 ram->fuc.r_0x10f310 = ramfuc_reg(0x10f310); in gk104_ram_new_()
1684 ram->fuc.r_0x10f314 = ramfuc_reg(0x10f314); in gk104_ram_new_()
1685 ram->fuc.r_0x10f318 = ramfuc_reg(0x10f318); in gk104_ram_new_()
1686 ram->fuc.r_0x10f090 = ramfuc_reg(0x10f090); in gk104_ram_new_()
1687 ram->fuc.r_0x10f69c = ramfuc_reg(0x10f69c); in gk104_ram_new_()
1688 ram->fuc.r_0x10f824 = ramfuc_reg(0x10f824); in gk104_ram_new_()
1689 ram->fuc.r_0x1373f0 = ramfuc_reg(0x1373f0); in gk104_ram_new_()
1690 ram->fuc.r_0x1373f4 = ramfuc_reg(0x1373f4); in gk104_ram_new_()
1691 ram->fuc.r_0x137320 = ramfuc_reg(0x137320); in gk104_ram_new_()
1692 ram->fuc.r_0x10f65c = ramfuc_reg(0x10f65c); in gk104_ram_new_()
1693 ram->fuc.r_0x10f6bc = ramfuc_reg(0x10f6bc); in gk104_ram_new_()
1694 ram->fuc.r_0x100710 = ramfuc_reg(0x100710); in gk104_ram_new_()
1695 ram->fuc.r_0x100750 = ramfuc_reg(0x100750); in gk104_ram_new_()