1 // SPDX-License-Identifier: MIT
2 #include "ram.h"
3 
4 #include <subdev/bios.h>
5 
6 static const struct nvkm_ram_func
7 gp102_ram = {
8 	.init = gp100_ram_init,
9 };
10 
11 int
gp102_ram_new(struct nvkm_fb * fb,struct nvkm_ram ** pram)12 gp102_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
13 {
14 	enum nvkm_ram_type type = nvkm_fb_bios_memtype(fb->subdev.device->bios);
15 	const u32 rsvd_head = ( 256 * 1024); /* vga memory */
16 	const u32 rsvd_tail = (1024 * 1024); /* vbios etc */
17 	u64 size = fb->func->vidmem.size(fb);
18 	int ret;
19 
20 	ret = nvkm_ram_new_(&gp102_ram, fb, type, size, pram);
21 	if (ret)
22 		return ret;
23 
24 	nvkm_mm_fini(&(*pram)->vram);
25 
26 	return nvkm_mm_init(&(*pram)->vram, NVKM_RAM_MM_NORMAL,
27 			    rsvd_head >> NVKM_RAM_MM_SHIFT,
28 			    (size - rsvd_head - rsvd_tail) >> NVKM_RAM_MM_SHIFT,
29 			    1);
30 
31 }
32