This source file includes following definitions.
- mcp77_ram_init
- mcp77_ram_new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #define mcp77_ram(p) container_of((p), struct mcp77_ram, base)
25 #include "ram.h"
26
27 struct mcp77_ram {
28 struct nvkm_ram base;
29 u64 poller_base;
30 };
31
32 static int
33 mcp77_ram_init(struct nvkm_ram *base)
34 {
35 struct mcp77_ram *ram = mcp77_ram(base);
36 struct nvkm_device *device = ram->base.fb->subdev.device;
37 u32 dniso = ((ram->base.size - (ram->poller_base + 0x00)) >> 5) - 1;
38 u32 hostnb = ((ram->base.size - (ram->poller_base + 0x20)) >> 5) - 1;
39 u32 flush = ((ram->base.size - (ram->poller_base + 0x40)) >> 5) - 1;
40
41
42
43
44 nvkm_wr32(device, 0x100c18, dniso);
45 nvkm_mask(device, 0x100c14, 0x00000000, 0x00000001);
46 nvkm_wr32(device, 0x100c1c, hostnb);
47 nvkm_mask(device, 0x100c14, 0x00000000, 0x00000002);
48 nvkm_wr32(device, 0x100c24, flush);
49 nvkm_mask(device, 0x100c14, 0x00000000, 0x00010000);
50 return 0;
51 }
52
53 static const struct nvkm_ram_func
54 mcp77_ram_func = {
55 .init = mcp77_ram_init,
56 };
57
58 int
59 mcp77_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
60 {
61 struct nvkm_device *device = fb->subdev.device;
62 u32 rsvd_head = ( 256 * 1024);
63 u32 rsvd_tail = (1024 * 1024) + 0x1000;
64 u64 base = (u64)nvkm_rd32(device, 0x100e10) << 12;
65 u64 size = (u64)nvkm_rd32(device, 0x100e14) << 12;
66 struct mcp77_ram *ram;
67 int ret;
68
69 if (!(ram = kzalloc(sizeof(*ram), GFP_KERNEL)))
70 return -ENOMEM;
71 *pram = &ram->base;
72
73 ret = nvkm_ram_ctor(&mcp77_ram_func, fb, NVKM_RAM_TYPE_STOLEN,
74 size, &ram->base);
75 if (ret)
76 return ret;
77
78 ram->poller_base = size - rsvd_tail;
79 ram->base.stolen = base;
80 nvkm_mm_fini(&ram->base.vram);
81
82 return nvkm_mm_init(&ram->base.vram, NVKM_RAM_MM_NORMAL,
83 rsvd_head >> NVKM_RAM_MM_SHIFT,
84 (size - rsvd_head - rsvd_tail) >>
85 NVKM_RAM_MM_SHIFT, 1);
86 }