xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgf100.c (revision 8dd06ef34b6e2f41b29fbf5fc1663780f2524285)
1639c308eSBen Skeggs /*
2639c308eSBen Skeggs  * Copyright 2013 Red Hat Inc.
3639c308eSBen Skeggs  *
4639c308eSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5639c308eSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6639c308eSBen Skeggs  * to deal in the Software without restriction, including without limitation
7639c308eSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8639c308eSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9639c308eSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10639c308eSBen Skeggs  *
11639c308eSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12639c308eSBen Skeggs  * all copies or substantial portions of the Software.
13639c308eSBen Skeggs  *
14639c308eSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15639c308eSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16639c308eSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17639c308eSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18639c308eSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19639c308eSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20639c308eSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21639c308eSBen Skeggs  *
22639c308eSBen Skeggs  * Authors: Ben Skeggs
23639c308eSBen Skeggs  */
24d36a99d2SBen Skeggs #define gf100_ram(p) container_of((p), struct gf100_ram, base)
25d36a99d2SBen Skeggs #include "ram.h"
26639c308eSBen Skeggs #include "ramfuc.h"
27639c308eSBen Skeggs 
28639c308eSBen Skeggs #include <core/option.h>
29639c308eSBen Skeggs #include <subdev/bios.h>
30639c308eSBen Skeggs #include <subdev/bios/pll.h>
31639c308eSBen Skeggs #include <subdev/bios/rammap.h>
32639c308eSBen Skeggs #include <subdev/bios/timing.h>
33639c308eSBen Skeggs #include <subdev/clk.h>
34639c308eSBen Skeggs #include <subdev/clk/pll.h>
35639c308eSBen Skeggs 
36639c308eSBen Skeggs struct gf100_ramfuc {
37639c308eSBen Skeggs 	struct ramfuc base;
38639c308eSBen Skeggs 
39639c308eSBen Skeggs 	struct ramfuc_reg r_0x10fe20;
40639c308eSBen Skeggs 	struct ramfuc_reg r_0x10fe24;
41639c308eSBen Skeggs 	struct ramfuc_reg r_0x137320;
42639c308eSBen Skeggs 	struct ramfuc_reg r_0x137330;
43639c308eSBen Skeggs 
44639c308eSBen Skeggs 	struct ramfuc_reg r_0x132000;
45639c308eSBen Skeggs 	struct ramfuc_reg r_0x132004;
46639c308eSBen Skeggs 	struct ramfuc_reg r_0x132100;
47639c308eSBen Skeggs 
48639c308eSBen Skeggs 	struct ramfuc_reg r_0x137390;
49639c308eSBen Skeggs 
50639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f290;
51639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f294;
52639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f298;
53639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f29c;
54639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f2a0;
55639c308eSBen Skeggs 
56639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f300;
57639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f338;
58639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f340;
59639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f344;
60639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f348;
61639c308eSBen Skeggs 
62639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f910;
63639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f914;
64639c308eSBen Skeggs 
65639c308eSBen Skeggs 	struct ramfuc_reg r_0x100b0c;
66639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f050;
67639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f090;
68639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f200;
69639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f210;
70639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f310;
71639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f314;
72639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f610;
73639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f614;
74639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f800;
75639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f808;
76639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f824;
77639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f830;
78639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f988;
79639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f98c;
80639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f990;
81639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f998;
82639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f9b0;
83639c308eSBen Skeggs 	struct ramfuc_reg r_0x10f9b4;
84639c308eSBen Skeggs 	struct ramfuc_reg r_0x10fb04;
85639c308eSBen Skeggs 	struct ramfuc_reg r_0x10fb08;
86639c308eSBen Skeggs 	struct ramfuc_reg r_0x137300;
87639c308eSBen Skeggs 	struct ramfuc_reg r_0x137310;
88639c308eSBen Skeggs 	struct ramfuc_reg r_0x137360;
89639c308eSBen Skeggs 	struct ramfuc_reg r_0x1373ec;
90639c308eSBen Skeggs 	struct ramfuc_reg r_0x1373f0;
91639c308eSBen Skeggs 	struct ramfuc_reg r_0x1373f8;
92639c308eSBen Skeggs 
93639c308eSBen Skeggs 	struct ramfuc_reg r_0x61c140;
94639c308eSBen Skeggs 	struct ramfuc_reg r_0x611200;
95639c308eSBen Skeggs 
96639c308eSBen Skeggs 	struct ramfuc_reg r_0x13d8f4;
97639c308eSBen Skeggs };
98639c308eSBen Skeggs 
99639c308eSBen Skeggs struct gf100_ram {
100639c308eSBen Skeggs 	struct nvkm_ram base;
101639c308eSBen Skeggs 	struct gf100_ramfuc fuc;
102639c308eSBen Skeggs 	struct nvbios_pll refpll;
103639c308eSBen Skeggs 	struct nvbios_pll mempll;
104639c308eSBen Skeggs };
105639c308eSBen Skeggs 
106639c308eSBen Skeggs static void
gf100_ram_train(struct gf100_ramfuc * fuc,u32 magic)107639c308eSBen Skeggs gf100_ram_train(struct gf100_ramfuc *fuc, u32 magic)
108639c308eSBen Skeggs {
109639c308eSBen Skeggs 	struct gf100_ram *ram = container_of(fuc, typeof(*ram), fuc);
110d36a99d2SBen Skeggs 	struct nvkm_fb *fb = ram->base.fb;
1116758745bSBen Skeggs 	struct nvkm_device *device = fb->subdev.device;
1126758745bSBen Skeggs 	u32 part = nvkm_rd32(device, 0x022438), i;
1136758745bSBen Skeggs 	u32 mask = nvkm_rd32(device, 0x022554);
114639c308eSBen Skeggs 	u32 addr = 0x110974;
115639c308eSBen Skeggs 
116639c308eSBen Skeggs 	ram_wr32(fuc, 0x10f910, magic);
117639c308eSBen Skeggs 	ram_wr32(fuc, 0x10f914, magic);
118639c308eSBen Skeggs 
119639c308eSBen Skeggs 	for (i = 0; (magic & 0x80000000) && i < part; addr += 0x1000, i++) {
120639c308eSBen Skeggs 		if (mask & (1 << i))
121639c308eSBen Skeggs 			continue;
122639c308eSBen Skeggs 		ram_wait(fuc, addr, 0x0000000f, 0x00000000, 500000);
123639c308eSBen Skeggs 	}
124639c308eSBen Skeggs }
125639c308eSBen Skeggs 
126fcb371a1SBen Skeggs int
gf100_ram_calc(struct nvkm_ram * base,u32 freq)127d36a99d2SBen Skeggs gf100_ram_calc(struct nvkm_ram *base, u32 freq)
128639c308eSBen Skeggs {
129d36a99d2SBen Skeggs 	struct gf100_ram *ram = gf100_ram(base);
130d36a99d2SBen Skeggs 	struct gf100_ramfuc *fuc = &ram->fuc;
131d36a99d2SBen Skeggs 	struct nvkm_subdev *subdev = &ram->base.fb->subdev;
1323ecd329bSBen Skeggs 	struct nvkm_device *device = subdev->device;
1333ecd329bSBen Skeggs 	struct nvkm_clk *clk = device->clk;
1343ecd329bSBen Skeggs 	struct nvkm_bios *bios = device->bios;
135639c308eSBen Skeggs 	struct nvbios_ramcfg cfg;
136639c308eSBen Skeggs 	u8  ver, cnt, len, strap;
137639c308eSBen Skeggs 	struct {
138639c308eSBen Skeggs 		u32 data;
139639c308eSBen Skeggs 		u8  size;
140639c308eSBen Skeggs 	} rammap, ramcfg, timing;
141639c308eSBen Skeggs 	int ref, div, out;
142639c308eSBen Skeggs 	int from, mode;
143639c308eSBen Skeggs 	int N1, M1, P;
144639c308eSBen Skeggs 	int ret;
145639c308eSBen Skeggs 
146639c308eSBen Skeggs 	/* lookup memory config data relevant to the target frequency */
147639c308eSBen Skeggs 	rammap.data = nvbios_rammapEm(bios, freq / 1000, &ver, &rammap.size,
148639c308eSBen Skeggs 				      &cnt, &ramcfg.size, &cfg);
149639c308eSBen Skeggs 	if (!rammap.data || ver != 0x10 || rammap.size < 0x0e) {
1503ecd329bSBen Skeggs 		nvkm_error(subdev, "invalid/missing rammap entry\n");
151639c308eSBen Skeggs 		return -EINVAL;
152639c308eSBen Skeggs 	}
153639c308eSBen Skeggs 
154639c308eSBen Skeggs 	/* locate specific data set for the attached memory */
155d36a99d2SBen Skeggs 	strap = nvbios_ramcfg_index(subdev);
156639c308eSBen Skeggs 	if (strap >= cnt) {
1573ecd329bSBen Skeggs 		nvkm_error(subdev, "invalid ramcfg strap\n");
158639c308eSBen Skeggs 		return -EINVAL;
159639c308eSBen Skeggs 	}
160639c308eSBen Skeggs 
161639c308eSBen Skeggs 	ramcfg.data = rammap.data + rammap.size + (strap * ramcfg.size);
162639c308eSBen Skeggs 	if (!ramcfg.data || ver != 0x10 || ramcfg.size < 0x0e) {
1633ecd329bSBen Skeggs 		nvkm_error(subdev, "invalid/missing ramcfg entry\n");
164639c308eSBen Skeggs 		return -EINVAL;
165639c308eSBen Skeggs 	}
166639c308eSBen Skeggs 
167639c308eSBen Skeggs 	/* lookup memory timings, if bios says they're present */
1687f5f518fSBen Skeggs 	strap = nvbios_rd08(bios, ramcfg.data + 0x01);
169639c308eSBen Skeggs 	if (strap != 0xff) {
170639c308eSBen Skeggs 		timing.data = nvbios_timingEe(bios, strap, &ver, &timing.size,
171639c308eSBen Skeggs 					      &cnt, &len);
172639c308eSBen Skeggs 		if (!timing.data || ver != 0x10 || timing.size < 0x19) {
1733ecd329bSBen Skeggs 			nvkm_error(subdev, "invalid/missing timing entry\n");
174639c308eSBen Skeggs 			return -EINVAL;
175639c308eSBen Skeggs 		}
176639c308eSBen Skeggs 	} else {
177639c308eSBen Skeggs 		timing.data = 0;
178639c308eSBen Skeggs 	}
179639c308eSBen Skeggs 
180d36a99d2SBen Skeggs 	ret = ram_init(fuc, ram->base.fb);
181639c308eSBen Skeggs 	if (ret)
182639c308eSBen Skeggs 		return ret;
183639c308eSBen Skeggs 
184639c308eSBen Skeggs 	/* determine current mclk configuration */
185639c308eSBen Skeggs 	from = !!(ram_rd32(fuc, 0x1373f0) & 0x00000002); /*XXX: ok? */
186639c308eSBen Skeggs 
187639c308eSBen Skeggs 	/* determine target mclk configuration */
188639c308eSBen Skeggs 	if (!(ram_rd32(fuc, 0x137300) & 0x00000100))
1896625f55cSBen Skeggs 		ref = nvkm_clk_read(clk, nv_clk_src_sppll0);
190639c308eSBen Skeggs 	else
1916625f55cSBen Skeggs 		ref = nvkm_clk_read(clk, nv_clk_src_sppll1);
192639c308eSBen Skeggs 	div = max(min((ref * 2) / freq, (u32)65), (u32)2) - 2;
193639c308eSBen Skeggs 	out = (ref * 2) / (div + 2);
194639c308eSBen Skeggs 	mode = freq != out;
195639c308eSBen Skeggs 
196639c308eSBen Skeggs 	ram_mask(fuc, 0x137360, 0x00000002, 0x00000000);
197639c308eSBen Skeggs 
198639c308eSBen Skeggs 	if ((ram_rd32(fuc, 0x132000) & 0x00000002) || 0 /*XXX*/) {
199639c308eSBen Skeggs 		ram_nuke(fuc, 0x132000);
200639c308eSBen Skeggs 		ram_mask(fuc, 0x132000, 0x00000002, 0x00000002);
201639c308eSBen Skeggs 		ram_mask(fuc, 0x132000, 0x00000002, 0x00000000);
202639c308eSBen Skeggs 	}
203639c308eSBen Skeggs 
204639c308eSBen Skeggs 	if (mode == 1) {
205639c308eSBen Skeggs 		ram_nuke(fuc, 0x10fe20);
206639c308eSBen Skeggs 		ram_mask(fuc, 0x10fe20, 0x00000002, 0x00000002);
207639c308eSBen Skeggs 		ram_mask(fuc, 0x10fe20, 0x00000002, 0x00000000);
208639c308eSBen Skeggs 	}
209639c308eSBen Skeggs 
210639c308eSBen Skeggs // 0x00020034 // 0x0000000a
211639c308eSBen Skeggs 	ram_wr32(fuc, 0x132100, 0x00000001);
212639c308eSBen Skeggs 
213639c308eSBen Skeggs 	if (mode == 1 && from == 0) {
214639c308eSBen Skeggs 		/* calculate refpll */
215d36a99d2SBen Skeggs 		ret = gt215_pll_calc(subdev, &ram->refpll, ram->mempll.refclk,
216d36a99d2SBen Skeggs 				     &N1, NULL, &M1, &P);
217639c308eSBen Skeggs 		if (ret <= 0) {
2183ecd329bSBen Skeggs 			nvkm_error(subdev, "unable to calc refpll\n");
219639c308eSBen Skeggs 			return ret ? ret : -ERANGE;
220639c308eSBen Skeggs 		}
221639c308eSBen Skeggs 
222639c308eSBen Skeggs 		ram_wr32(fuc, 0x10fe20, 0x20010000);
223639c308eSBen Skeggs 		ram_wr32(fuc, 0x137320, 0x00000003);
224639c308eSBen Skeggs 		ram_wr32(fuc, 0x137330, 0x81200006);
225639c308eSBen Skeggs 		ram_wr32(fuc, 0x10fe24, (P << 16) | (N1 << 8) | M1);
226639c308eSBen Skeggs 		ram_wr32(fuc, 0x10fe20, 0x20010001);
227639c308eSBen Skeggs 		ram_wait(fuc, 0x137390, 0x00020000, 0x00020000, 64000);
228639c308eSBen Skeggs 
229639c308eSBen Skeggs 		/* calculate mempll */
230d36a99d2SBen Skeggs 		ret = gt215_pll_calc(subdev, &ram->mempll, freq,
231639c308eSBen Skeggs 				     &N1, NULL, &M1, &P);
232639c308eSBen Skeggs 		if (ret <= 0) {
2333ecd329bSBen Skeggs 			nvkm_error(subdev, "unable to calc refpll\n");
234639c308eSBen Skeggs 			return ret ? ret : -ERANGE;
235639c308eSBen Skeggs 		}
236639c308eSBen Skeggs 
237639c308eSBen Skeggs 		ram_wr32(fuc, 0x10fe20, 0x20010005);
238639c308eSBen Skeggs 		ram_wr32(fuc, 0x132004, (P << 16) | (N1 << 8) | M1);
239639c308eSBen Skeggs 		ram_wr32(fuc, 0x132000, 0x18010101);
240639c308eSBen Skeggs 		ram_wait(fuc, 0x137390, 0x00000002, 0x00000002, 64000);
241639c308eSBen Skeggs 	} else
242639c308eSBen Skeggs 	if (mode == 0) {
243639c308eSBen Skeggs 		ram_wr32(fuc, 0x137300, 0x00000003);
244639c308eSBen Skeggs 	}
245639c308eSBen Skeggs 
246639c308eSBen Skeggs 	if (from == 0) {
247639c308eSBen Skeggs 		ram_nuke(fuc, 0x10fb04);
248639c308eSBen Skeggs 		ram_mask(fuc, 0x10fb04, 0x0000ffff, 0x00000000);
249639c308eSBen Skeggs 		ram_nuke(fuc, 0x10fb08);
250639c308eSBen Skeggs 		ram_mask(fuc, 0x10fb08, 0x0000ffff, 0x00000000);
251639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f988, 0x2004ff00);
252639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f98c, 0x003fc040);
253639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f990, 0x20012001);
254639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f998, 0x00011a00);
255639c308eSBen Skeggs 		ram_wr32(fuc, 0x13d8f4, 0x00000000);
256639c308eSBen Skeggs 	} else {
257639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f988, 0x20010000);
258639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f98c, 0x00000000);
259639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f990, 0x20012001);
260639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f998, 0x00010a00);
261639c308eSBen Skeggs 	}
262639c308eSBen Skeggs 
263639c308eSBen Skeggs 	if (from == 0) {
264639c308eSBen Skeggs // 0x00020039 // 0x000000ba
265639c308eSBen Skeggs 	}
266639c308eSBen Skeggs 
267639c308eSBen Skeggs // 0x0002003a // 0x00000002
268639c308eSBen Skeggs 	ram_wr32(fuc, 0x100b0c, 0x00080012);
269639c308eSBen Skeggs // 0x00030014 // 0x00000000 // 0x02b5f070
270639c308eSBen Skeggs // 0x00030014 // 0x00010000 // 0x02b5f070
271639c308eSBen Skeggs 	ram_wr32(fuc, 0x611200, 0x00003300);
272639c308eSBen Skeggs // 0x00020034 // 0x0000000a
273639c308eSBen Skeggs // 0x00030020 // 0x00000001 // 0x00000000
274639c308eSBen Skeggs 
275639c308eSBen Skeggs 	ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000);
276639c308eSBen Skeggs 	ram_wr32(fuc, 0x10f210, 0x00000000);
277639c308eSBen Skeggs 	ram_nsec(fuc, 1000);
278639c308eSBen Skeggs 	if (mode == 0)
279639c308eSBen Skeggs 		gf100_ram_train(fuc, 0x000c1001);
280639c308eSBen Skeggs 	ram_wr32(fuc, 0x10f310, 0x00000001);
281639c308eSBen Skeggs 	ram_nsec(fuc, 1000);
282639c308eSBen Skeggs 	ram_wr32(fuc, 0x10f090, 0x00000061);
283639c308eSBen Skeggs 	ram_wr32(fuc, 0x10f090, 0xc000007f);
284639c308eSBen Skeggs 	ram_nsec(fuc, 1000);
285639c308eSBen Skeggs 
286639c308eSBen Skeggs 	if (from == 0) {
287639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f824, 0x00007fd4);
288639c308eSBen Skeggs 	} else {
289639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373ec, 0x00020404);
290639c308eSBen Skeggs 	}
291639c308eSBen Skeggs 
292639c308eSBen Skeggs 	if (mode == 0) {
293639c308eSBen Skeggs 		ram_mask(fuc, 0x10f808, 0x00080000, 0x00000000);
294639c308eSBen Skeggs 		ram_mask(fuc, 0x10f200, 0x00008000, 0x00008000);
295639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x41500010);
296639c308eSBen Skeggs 		ram_mask(fuc, 0x10f830, 0x01000000, 0x00000000);
297639c308eSBen Skeggs 		ram_mask(fuc, 0x132100, 0x00000100, 0x00000100);
298639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f050, 0xff000090);
299639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373ec, 0x00020f0f);
300639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373f0, 0x00000003);
301639c308eSBen Skeggs 		ram_wr32(fuc, 0x137310, 0x81201616);
302639c308eSBen Skeggs 		ram_wr32(fuc, 0x132100, 0x00000001);
303639c308eSBen Skeggs // 0x00020039 // 0x000000ba
304639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x00300017);
305639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373f0, 0x00000001);
306639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f824, 0x00007e77);
307639c308eSBen Skeggs 		ram_wr32(fuc, 0x132000, 0x18030001);
308639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f090, 0x4000007e);
309639c308eSBen Skeggs 		ram_nsec(fuc, 2000);
310639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f314, 0x00000001);
311639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f210, 0x80000000);
312639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f338, 0x00300220);
313639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f300, 0x0000011d);
314639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
315639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f290, 0x02060505);
316639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f294, 0x34208288);
317639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f298, 0x44050411);
318639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f29c, 0x0000114c);
319639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f2a0, 0x42e10069);
320639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f614, 0x40044f77);
321639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f610, 0x40044f77);
322639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f344, 0x00600009);
323639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
324639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f348, 0x00700008);
325639c308eSBen Skeggs 		ram_wr32(fuc, 0x61c140, 0x19240000);
326639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x00300017);
327639c308eSBen Skeggs 		gf100_ram_train(fuc, 0x80021001);
328639c308eSBen Skeggs 		gf100_ram_train(fuc, 0x80081001);
329639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f340, 0x00500004);
330639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
331639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x01300017);
332639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x00300017);
333639c308eSBen Skeggs // 0x00030020 // 0x00000000 // 0x00000000
334639c308eSBen Skeggs // 0x00020034 // 0x0000000b
335639c308eSBen Skeggs 		ram_wr32(fuc, 0x100b0c, 0x00080028);
336639c308eSBen Skeggs 		ram_wr32(fuc, 0x611200, 0x00003330);
337639c308eSBen Skeggs 	} else {
338639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f800, 0x00001800);
339639c308eSBen Skeggs 		ram_wr32(fuc, 0x13d8f4, 0x00000000);
340639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373ec, 0x00020404);
341639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373f0, 0x00000003);
342639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x40700010);
343639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x40500010);
344639c308eSBen Skeggs 		ram_wr32(fuc, 0x13d8f4, 0x00000000);
345639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373f8, 0x00000000);
346639c308eSBen Skeggs 		ram_wr32(fuc, 0x132100, 0x00000101);
347639c308eSBen Skeggs 		ram_wr32(fuc, 0x137310, 0x89201616);
348639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f050, 0xff000090);
349639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373ec, 0x00030404);
350639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373f0, 0x00000002);
351639c308eSBen Skeggs 	// 0x00020039 // 0x00000011
352639c308eSBen Skeggs 		ram_wr32(fuc, 0x132100, 0x00000001);
353639c308eSBen Skeggs 		ram_wr32(fuc, 0x1373f8, 0x00002000);
354639c308eSBen Skeggs 		ram_nsec(fuc, 2000);
355639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f808, 0x7aaa0050);
356639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f830, 0x00500010);
357639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f200, 0x00ce1000);
358639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f090, 0x4000007e);
359639c308eSBen Skeggs 		ram_nsec(fuc, 2000);
360639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f314, 0x00000001);
361639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f210, 0x80000000);
362639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f338, 0x00300200);
363639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f300, 0x0000084d);
364639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
365639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f290, 0x0b343825);
366639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f294, 0x3483028e);
367639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f298, 0x440c0600);
368639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f29c, 0x0000214c);
369639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f2a0, 0x42e20069);
370639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f200, 0x00ce0000);
371639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f614, 0x60044e77);
372639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f610, 0x60044e77);
373639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f340, 0x00500000);
374639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
375639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f344, 0x00600228);
376639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
377639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f348, 0x00700000);
378639c308eSBen Skeggs 		ram_wr32(fuc, 0x13d8f4, 0x00000000);
379639c308eSBen Skeggs 		ram_wr32(fuc, 0x61c140, 0x09a40000);
380639c308eSBen Skeggs 
381639c308eSBen Skeggs 		gf100_ram_train(fuc, 0x800e1008);
382639c308eSBen Skeggs 
383639c308eSBen Skeggs 		ram_nsec(fuc, 1000);
384639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f800, 0x00001804);
385639c308eSBen Skeggs 	// 0x00030020 // 0x00000000 // 0x00000000
386639c308eSBen Skeggs 	// 0x00020034 // 0x0000000b
387639c308eSBen Skeggs 		ram_wr32(fuc, 0x13d8f4, 0x00000000);
388639c308eSBen Skeggs 		ram_wr32(fuc, 0x100b0c, 0x00080028);
389639c308eSBen Skeggs 		ram_wr32(fuc, 0x611200, 0x00003330);
390639c308eSBen Skeggs 		ram_nsec(fuc, 100000);
391639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f9b0, 0x05313f41);
392639c308eSBen Skeggs 		ram_wr32(fuc, 0x10f9b4, 0x00002f50);
393639c308eSBen Skeggs 
394639c308eSBen Skeggs 		gf100_ram_train(fuc, 0x010c1001);
395639c308eSBen Skeggs 	}
396639c308eSBen Skeggs 
397639c308eSBen Skeggs 	ram_mask(fuc, 0x10f200, 0x00000800, 0x00000800);
398639c308eSBen Skeggs // 0x00020016 // 0x00000000
399639c308eSBen Skeggs 
400639c308eSBen Skeggs 	if (mode == 0)
401639c308eSBen Skeggs 		ram_mask(fuc, 0x132000, 0x00000001, 0x00000000);
402639c308eSBen Skeggs 
403639c308eSBen Skeggs 	return 0;
404639c308eSBen Skeggs }
405639c308eSBen Skeggs 
406fcb371a1SBen Skeggs int
gf100_ram_prog(struct nvkm_ram * base)407d36a99d2SBen Skeggs gf100_ram_prog(struct nvkm_ram *base)
408639c308eSBen Skeggs {
409d36a99d2SBen Skeggs 	struct gf100_ram *ram = gf100_ram(base);
410d36a99d2SBen Skeggs 	struct nvkm_device *device = ram->base.fb->subdev.device;
411d36a99d2SBen Skeggs 	ram_exec(&ram->fuc, nvkm_boolopt(device->cfgopt, "NvMemExec", true));
412639c308eSBen Skeggs 	return 0;
413639c308eSBen Skeggs }
414639c308eSBen Skeggs 
415fcb371a1SBen Skeggs void
gf100_ram_tidy(struct nvkm_ram * base)416d36a99d2SBen Skeggs gf100_ram_tidy(struct nvkm_ram *base)
417639c308eSBen Skeggs {
418d36a99d2SBen Skeggs 	struct gf100_ram *ram = gf100_ram(base);
419d36a99d2SBen Skeggs 	ram_exec(&ram->fuc, false);
420639c308eSBen Skeggs }
421639c308eSBen Skeggs 
422fcb371a1SBen Skeggs int
gf100_ram_init(struct nvkm_ram * base)423d36a99d2SBen Skeggs gf100_ram_init(struct nvkm_ram *base)
424639c308eSBen Skeggs {
425639c308eSBen Skeggs 	static const u8  train0[] = {
426639c308eSBen Skeggs 		0x00, 0xff, 0x55, 0xaa, 0x33, 0xcc,
427639c308eSBen Skeggs 		0x00, 0xff, 0xff, 0x00, 0xff, 0x00,
428639c308eSBen Skeggs 	};
429639c308eSBen Skeggs 	static const u32 train1[] = {
430639c308eSBen Skeggs 		0x00000000, 0xffffffff,
431639c308eSBen Skeggs 		0x55555555, 0xaaaaaaaa,
432639c308eSBen Skeggs 		0x33333333, 0xcccccccc,
433639c308eSBen Skeggs 		0xf0f0f0f0, 0x0f0f0f0f,
434639c308eSBen Skeggs 		0x00ff00ff, 0xff00ff00,
435639c308eSBen Skeggs 		0x0000ffff, 0xffff0000,
436639c308eSBen Skeggs 	};
437d36a99d2SBen Skeggs 	struct gf100_ram *ram = gf100_ram(base);
438d36a99d2SBen Skeggs 	struct nvkm_device *device = ram->base.fb->subdev.device;
439d36a99d2SBen Skeggs 	int i;
440639c308eSBen Skeggs 
441d36a99d2SBen Skeggs 	switch (ram->base.type) {
442d36a99d2SBen Skeggs 	case NVKM_RAM_TYPE_GDDR5:
443d36a99d2SBen Skeggs 		break;
444d36a99d2SBen Skeggs 	default:
445d36a99d2SBen Skeggs 		return 0;
446d36a99d2SBen Skeggs 	}
447d36a99d2SBen Skeggs 
448d36a99d2SBen Skeggs 	/* prepare for ddr link training, and load training patterns */
449639c308eSBen Skeggs 	for (i = 0; i < 0x30; i++) {
4506758745bSBen Skeggs 		nvkm_wr32(device, 0x10f968, 0x00000000 | (i << 8));
4516758745bSBen Skeggs 		nvkm_wr32(device, 0x10f96c, 0x00000000 | (i << 8));
4526758745bSBen Skeggs 		nvkm_wr32(device, 0x10f920, 0x00000100 | train0[i % 12]);
4536758745bSBen Skeggs 		nvkm_wr32(device, 0x10f924, 0x00000100 | train0[i % 12]);
4546758745bSBen Skeggs 		nvkm_wr32(device, 0x10f918,              train1[i % 12]);
4556758745bSBen Skeggs 		nvkm_wr32(device, 0x10f91c,              train1[i % 12]);
4566758745bSBen Skeggs 		nvkm_wr32(device, 0x10f920, 0x00000000 | train0[i % 12]);
4576758745bSBen Skeggs 		nvkm_wr32(device, 0x10f924, 0x00000000 | train0[i % 12]);
4586758745bSBen Skeggs 		nvkm_wr32(device, 0x10f918,              train1[i % 12]);
4596758745bSBen Skeggs 		nvkm_wr32(device, 0x10f91c,              train1[i % 12]);
460639c308eSBen Skeggs 	}
461639c308eSBen Skeggs 
462639c308eSBen Skeggs 	return 0;
463639c308eSBen Skeggs }
464639c308eSBen Skeggs 
46597e5268dSBen Skeggs u32
gf100_ram_probe_fbpa_amount(struct nvkm_device * device,int fbpa)46697e5268dSBen Skeggs gf100_ram_probe_fbpa_amount(struct nvkm_device *device, int fbpa)
46797e5268dSBen Skeggs {
46897e5268dSBen Skeggs 	return nvkm_rd32(device, 0x11020c + (fbpa * 0x1000));
46997e5268dSBen Skeggs }
47097e5268dSBen Skeggs 
47197e5268dSBen Skeggs u32
gf100_ram_probe_fbp_amount(const struct nvkm_ram_func * func,u32 fbpao,struct nvkm_device * device,int fbp,int * pltcs)47297e5268dSBen Skeggs gf100_ram_probe_fbp_amount(const struct nvkm_ram_func *func, u32 fbpao,
47397e5268dSBen Skeggs 			   struct nvkm_device *device, int fbp, int *pltcs)
47497e5268dSBen Skeggs {
47597e5268dSBen Skeggs 	if (!(fbpao & BIT(fbp))) {
47697e5268dSBen Skeggs 		*pltcs = 1;
47797e5268dSBen Skeggs 		return func->probe_fbpa_amount(device, fbp);
47897e5268dSBen Skeggs 	}
47997e5268dSBen Skeggs 	return 0;
48097e5268dSBen Skeggs }
48197e5268dSBen Skeggs 
48297e5268dSBen Skeggs u32
gf100_ram_probe_fbp(const struct nvkm_ram_func * func,struct nvkm_device * device,int fbp,int * pltcs)48397e5268dSBen Skeggs gf100_ram_probe_fbp(const struct nvkm_ram_func *func,
48497e5268dSBen Skeggs 		    struct nvkm_device *device, int fbp, int *pltcs)
48597e5268dSBen Skeggs {
48697e5268dSBen Skeggs 	u32 fbpao = nvkm_rd32(device, 0x022554);
48797e5268dSBen Skeggs 	return func->probe_fbp_amount(func, fbpao, device, fbp, pltcs);
48897e5268dSBen Skeggs }
48997e5268dSBen Skeggs 
490d36a99d2SBen Skeggs int
gf100_ram_ctor(const struct nvkm_ram_func * func,struct nvkm_fb * fb,struct nvkm_ram * ram)491d36a99d2SBen Skeggs gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
49297e5268dSBen Skeggs 	       struct nvkm_ram *ram)
493639c308eSBen Skeggs {
494d36a99d2SBen Skeggs 	struct nvkm_subdev *subdev = &fb->subdev;
495d36a99d2SBen Skeggs 	struct nvkm_device *device = subdev->device;
496d36a99d2SBen Skeggs 	struct nvkm_bios *bios = device->bios;
497d36a99d2SBen Skeggs 	const u32 rsvd_head = ( 256 * 1024); /* vga memory */
498d36a99d2SBen Skeggs 	const u32 rsvd_tail = (1024 * 1024); /* vbios etc */
499d36a99d2SBen Skeggs 	enum nvkm_ram_type type = nvkm_fb_bios_memtype(bios);
50097e5268dSBen Skeggs 	u32 fbps = nvkm_rd32(device, 0x022438);
50197e5268dSBen Skeggs 	u64 total = 0, lcomm = ~0, lower, ubase, usize;
50297e5268dSBen Skeggs 	int ret, fbp, ltcs, ltcn = 0;
503d36a99d2SBen Skeggs 
50497e5268dSBen Skeggs 	nvkm_debug(subdev, "%d FBP(s)\n", fbps);
50597e5268dSBen Skeggs 	for (fbp = 0; fbp < fbps; fbp++) {
50697e5268dSBen Skeggs 		u32 size = func->probe_fbp(func, device, fbp, &ltcs);
50797e5268dSBen Skeggs 		if (size) {
50897e5268dSBen Skeggs 			nvkm_debug(subdev, "FBP %d: %4d MiB, %d LTC(s)\n",
50997e5268dSBen Skeggs 				   fbp, size, ltcs);
51097e5268dSBen Skeggs 			lcomm  = min(lcomm, (u64)(size / ltcs) << 20);
511271393baSMario Kleiner 			total += (u64) size << 20;
51297e5268dSBen Skeggs 			ltcn  += ltcs;
51397e5268dSBen Skeggs 		} else {
51497e5268dSBen Skeggs 			nvkm_debug(subdev, "FBP %d: disabled\n", fbp);
51597e5268dSBen Skeggs 		}
516d36a99d2SBen Skeggs 	}
517d36a99d2SBen Skeggs 
51897e5268dSBen Skeggs 	lower = lcomm * ltcn;
51997e5268dSBen Skeggs 	ubase = lcomm + func->upper;
52097e5268dSBen Skeggs 	usize = total - lower;
521d36a99d2SBen Skeggs 
52297e5268dSBen Skeggs 	nvkm_debug(subdev, "Lower: %4lld MiB @ %010llx\n", lower >> 20, 0ULL);
52397e5268dSBen Skeggs 	nvkm_debug(subdev, "Upper: %4lld MiB @ %010llx\n", usize >> 20, ubase);
52497e5268dSBen Skeggs 	nvkm_debug(subdev, "Total: %4lld MiB\n", total >> 20);
52597e5268dSBen Skeggs 
526af793b8cSBen Skeggs 	ret = nvkm_ram_ctor(func, fb, type, total, ram);
527d36a99d2SBen Skeggs 	if (ret)
528d36a99d2SBen Skeggs 		return ret;
529d36a99d2SBen Skeggs 
530d36a99d2SBen Skeggs 	nvkm_mm_fini(&ram->vram);
531d36a99d2SBen Skeggs 
53297e5268dSBen Skeggs 	/* Some GPUs are in what's known as a "mixed memory" configuration.
53397e5268dSBen Skeggs 	 *
53497e5268dSBen Skeggs 	 * This is either where some FBPs have more memory than the others,
53597e5268dSBen Skeggs 	 * or where LTCs have been disabled on a FBP.
53697e5268dSBen Skeggs 	 */
53797e5268dSBen Skeggs 	if (lower != total) {
53897e5268dSBen Skeggs 		/* The common memory amount is addressed normally. */
5394d058fabSBen Skeggs 		ret = nvkm_mm_init(&ram->vram, NVKM_RAM_MM_NORMAL,
5404d058fabSBen Skeggs 				   rsvd_head >> NVKM_RAM_MM_SHIFT,
54197e5268dSBen Skeggs 				   (lower - rsvd_head) >> NVKM_RAM_MM_SHIFT, 1);
542d36a99d2SBen Skeggs 		if (ret)
543d36a99d2SBen Skeggs 			return ret;
544d36a99d2SBen Skeggs 
54597e5268dSBen Skeggs 		/* And the rest is much higher in the physical address
54697e5268dSBen Skeggs 		 * space, and may not be usable for certain operations.
54797e5268dSBen Skeggs 		 */
5484d058fabSBen Skeggs 		ret = nvkm_mm_init(&ram->vram, NVKM_RAM_MM_MIXED,
5494d058fabSBen Skeggs 				   ubase >> NVKM_RAM_MM_SHIFT,
55097e5268dSBen Skeggs 				   (usize - rsvd_tail) >> NVKM_RAM_MM_SHIFT, 1);
55197e5268dSBen Skeggs 		if (ret)
55297e5268dSBen Skeggs 			return ret;
55397e5268dSBen Skeggs 	} else {
55497e5268dSBen Skeggs 		/* GPUs without mixed-memory are a lot nicer... */
5554d058fabSBen Skeggs 		ret = nvkm_mm_init(&ram->vram, NVKM_RAM_MM_NORMAL,
5564d058fabSBen Skeggs 				   rsvd_head >> NVKM_RAM_MM_SHIFT,
55797e5268dSBen Skeggs 				   (total - rsvd_head - rsvd_tail) >>
558d36a99d2SBen Skeggs 				   NVKM_RAM_MM_SHIFT, 1);
559d36a99d2SBen Skeggs 		if (ret)
560d36a99d2SBen Skeggs 			return ret;
561d36a99d2SBen Skeggs 	}
562d36a99d2SBen Skeggs 
563d36a99d2SBen Skeggs 	return 0;
564d36a99d2SBen Skeggs }
565d36a99d2SBen Skeggs 
566d36a99d2SBen Skeggs int
gf100_ram_new_(const struct nvkm_ram_func * func,struct nvkm_fb * fb,struct nvkm_ram ** pram)567fcb371a1SBen Skeggs gf100_ram_new_(const struct nvkm_ram_func *func,
568fcb371a1SBen Skeggs 	       struct nvkm_fb *fb, struct nvkm_ram **pram)
569d36a99d2SBen Skeggs {
5703ecd329bSBen Skeggs 	struct nvkm_subdev *subdev = &fb->subdev;
5713ecd329bSBen Skeggs 	struct nvkm_bios *bios = subdev->device->bios;
572639c308eSBen Skeggs 	struct gf100_ram *ram;
573639c308eSBen Skeggs 	int ret;
574639c308eSBen Skeggs 
575d36a99d2SBen Skeggs 	if (!(ram = kzalloc(sizeof(*ram), GFP_KERNEL)))
576d36a99d2SBen Skeggs 		return -ENOMEM;
577d36a99d2SBen Skeggs 	*pram = &ram->base;
578d36a99d2SBen Skeggs 
57997e5268dSBen Skeggs 	ret = gf100_ram_ctor(func, fb, &ram->base);
580639c308eSBen Skeggs 	if (ret)
581639c308eSBen Skeggs 		return ret;
582639c308eSBen Skeggs 
583639c308eSBen Skeggs 	ret = nvbios_pll_parse(bios, 0x0c, &ram->refpll);
584639c308eSBen Skeggs 	if (ret) {
5853ecd329bSBen Skeggs 		nvkm_error(subdev, "mclk refpll data not found\n");
586639c308eSBen Skeggs 		return ret;
587639c308eSBen Skeggs 	}
588639c308eSBen Skeggs 
589639c308eSBen Skeggs 	ret = nvbios_pll_parse(bios, 0x04, &ram->mempll);
590639c308eSBen Skeggs 	if (ret) {
5913ecd329bSBen Skeggs 		nvkm_error(subdev, "mclk pll data not found\n");
592639c308eSBen Skeggs 		return ret;
593639c308eSBen Skeggs 	}
594639c308eSBen Skeggs 
595639c308eSBen Skeggs 	ram->fuc.r_0x10fe20 = ramfuc_reg(0x10fe20);
596639c308eSBen Skeggs 	ram->fuc.r_0x10fe24 = ramfuc_reg(0x10fe24);
597639c308eSBen Skeggs 	ram->fuc.r_0x137320 = ramfuc_reg(0x137320);
598639c308eSBen Skeggs 	ram->fuc.r_0x137330 = ramfuc_reg(0x137330);
599639c308eSBen Skeggs 
600639c308eSBen Skeggs 	ram->fuc.r_0x132000 = ramfuc_reg(0x132000);
601639c308eSBen Skeggs 	ram->fuc.r_0x132004 = ramfuc_reg(0x132004);
602639c308eSBen Skeggs 	ram->fuc.r_0x132100 = ramfuc_reg(0x132100);
603639c308eSBen Skeggs 
604639c308eSBen Skeggs 	ram->fuc.r_0x137390 = ramfuc_reg(0x137390);
605639c308eSBen Skeggs 
606639c308eSBen Skeggs 	ram->fuc.r_0x10f290 = ramfuc_reg(0x10f290);
607639c308eSBen Skeggs 	ram->fuc.r_0x10f294 = ramfuc_reg(0x10f294);
608639c308eSBen Skeggs 	ram->fuc.r_0x10f298 = ramfuc_reg(0x10f298);
609639c308eSBen Skeggs 	ram->fuc.r_0x10f29c = ramfuc_reg(0x10f29c);
610639c308eSBen Skeggs 	ram->fuc.r_0x10f2a0 = ramfuc_reg(0x10f2a0);
611639c308eSBen Skeggs 
612639c308eSBen Skeggs 	ram->fuc.r_0x10f300 = ramfuc_reg(0x10f300);
613639c308eSBen Skeggs 	ram->fuc.r_0x10f338 = ramfuc_reg(0x10f338);
614639c308eSBen Skeggs 	ram->fuc.r_0x10f340 = ramfuc_reg(0x10f340);
615639c308eSBen Skeggs 	ram->fuc.r_0x10f344 = ramfuc_reg(0x10f344);
616639c308eSBen Skeggs 	ram->fuc.r_0x10f348 = ramfuc_reg(0x10f348);
617639c308eSBen Skeggs 
618639c308eSBen Skeggs 	ram->fuc.r_0x10f910 = ramfuc_reg(0x10f910);
619639c308eSBen Skeggs 	ram->fuc.r_0x10f914 = ramfuc_reg(0x10f914);
620639c308eSBen Skeggs 
621639c308eSBen Skeggs 	ram->fuc.r_0x100b0c = ramfuc_reg(0x100b0c);
622639c308eSBen Skeggs 	ram->fuc.r_0x10f050 = ramfuc_reg(0x10f050);
623639c308eSBen Skeggs 	ram->fuc.r_0x10f090 = ramfuc_reg(0x10f090);
624639c308eSBen Skeggs 	ram->fuc.r_0x10f200 = ramfuc_reg(0x10f200);
625639c308eSBen Skeggs 	ram->fuc.r_0x10f210 = ramfuc_reg(0x10f210);
626639c308eSBen Skeggs 	ram->fuc.r_0x10f310 = ramfuc_reg(0x10f310);
627639c308eSBen Skeggs 	ram->fuc.r_0x10f314 = ramfuc_reg(0x10f314);
628639c308eSBen Skeggs 	ram->fuc.r_0x10f610 = ramfuc_reg(0x10f610);
629639c308eSBen Skeggs 	ram->fuc.r_0x10f614 = ramfuc_reg(0x10f614);
630639c308eSBen Skeggs 	ram->fuc.r_0x10f800 = ramfuc_reg(0x10f800);
631639c308eSBen Skeggs 	ram->fuc.r_0x10f808 = ramfuc_reg(0x10f808);
632639c308eSBen Skeggs 	ram->fuc.r_0x10f824 = ramfuc_reg(0x10f824);
633639c308eSBen Skeggs 	ram->fuc.r_0x10f830 = ramfuc_reg(0x10f830);
634639c308eSBen Skeggs 	ram->fuc.r_0x10f988 = ramfuc_reg(0x10f988);
635639c308eSBen Skeggs 	ram->fuc.r_0x10f98c = ramfuc_reg(0x10f98c);
636639c308eSBen Skeggs 	ram->fuc.r_0x10f990 = ramfuc_reg(0x10f990);
637639c308eSBen Skeggs 	ram->fuc.r_0x10f998 = ramfuc_reg(0x10f998);
638639c308eSBen Skeggs 	ram->fuc.r_0x10f9b0 = ramfuc_reg(0x10f9b0);
639639c308eSBen Skeggs 	ram->fuc.r_0x10f9b4 = ramfuc_reg(0x10f9b4);
640639c308eSBen Skeggs 	ram->fuc.r_0x10fb04 = ramfuc_reg(0x10fb04);
641639c308eSBen Skeggs 	ram->fuc.r_0x10fb08 = ramfuc_reg(0x10fb08);
642639c308eSBen Skeggs 	ram->fuc.r_0x137310 = ramfuc_reg(0x137300);
643639c308eSBen Skeggs 	ram->fuc.r_0x137310 = ramfuc_reg(0x137310);
644639c308eSBen Skeggs 	ram->fuc.r_0x137360 = ramfuc_reg(0x137360);
645639c308eSBen Skeggs 	ram->fuc.r_0x1373ec = ramfuc_reg(0x1373ec);
646639c308eSBen Skeggs 	ram->fuc.r_0x1373f0 = ramfuc_reg(0x1373f0);
647639c308eSBen Skeggs 	ram->fuc.r_0x1373f8 = ramfuc_reg(0x1373f8);
648639c308eSBen Skeggs 
649639c308eSBen Skeggs 	ram->fuc.r_0x61c140 = ramfuc_reg(0x61c140);
650639c308eSBen Skeggs 	ram->fuc.r_0x611200 = ramfuc_reg(0x611200);
651639c308eSBen Skeggs 
652639c308eSBen Skeggs 	ram->fuc.r_0x13d8f4 = ramfuc_reg(0x13d8f4);
653639c308eSBen Skeggs 	return 0;
654639c308eSBen Skeggs }
655fcb371a1SBen Skeggs 
656fcb371a1SBen Skeggs static const struct nvkm_ram_func
657fcb371a1SBen Skeggs gf100_ram = {
658*2cf3c8bcSWambui Karuga 	.upper = 0x0200000000ULL,
65997e5268dSBen Skeggs 	.probe_fbp = gf100_ram_probe_fbp,
66097e5268dSBen Skeggs 	.probe_fbp_amount = gf100_ram_probe_fbp_amount,
66197e5268dSBen Skeggs 	.probe_fbpa_amount = gf100_ram_probe_fbpa_amount,
662fcb371a1SBen Skeggs 	.init = gf100_ram_init,
663fcb371a1SBen Skeggs 	.calc = gf100_ram_calc,
664fcb371a1SBen Skeggs 	.prog = gf100_ram_prog,
665fcb371a1SBen Skeggs 	.tidy = gf100_ram_tidy,
666fcb371a1SBen Skeggs };
667fcb371a1SBen Skeggs 
668fcb371a1SBen Skeggs int
gf100_ram_new(struct nvkm_fb * fb,struct nvkm_ram ** pram)669fcb371a1SBen Skeggs gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
670fcb371a1SBen Skeggs {
671fcb371a1SBen Skeggs 	return gf100_ram_new_(&gf100_ram, fb, pram);
672fcb371a1SBen Skeggs }
673