1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "nv50.h"
25
26struct mcp77_ram_priv {
27 struct nvkm_ram base;
28 u64 poller_base;
29};
30
31static int
32mcp77_ram_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
33 struct nvkm_oclass *oclass, void *data, u32 datasize,
34 struct nvkm_object **pobject)
35{
36 u32 rsvd_head = ( 256 * 1024);
37 u32 rsvd_tail = (1024 * 1024);
38 struct nvkm_fb *pfb = nvkm_fb(parent);
39 struct mcp77_ram_priv *priv;
40 int ret;
41
42 ret = nvkm_ram_create(parent, engine, oclass, &priv);
43 *pobject = nv_object(priv);
44 if (ret)
45 return ret;
46
47 priv->base.type = NV_MEM_TYPE_STOLEN;
48 priv->base.stolen = (u64)nv_rd32(pfb, 0x100e10) << 12;
49 priv->base.size = (u64)nv_rd32(pfb, 0x100e14) << 12;
50
51 rsvd_tail += 0x1000;
52 priv->poller_base = priv->base.size - rsvd_tail;
53
54 ret = nvkm_mm_init(&pfb->vram, rsvd_head >> 12,
55 (priv->base.size - (rsvd_head + rsvd_tail)) >> 12,
56 1);
57 if (ret)
58 return ret;
59
60 priv->base.get = nv50_ram_get;
61 priv->base.put = nv50_ram_put;
62 return 0;
63}
64
65static int
66mcp77_ram_init(struct nvkm_object *object)
67{
68 struct nvkm_fb *pfb = nvkm_fb(object);
69 struct mcp77_ram_priv *priv = (void *)object;
70 int ret;
71 u64 dniso, hostnb, flush;
72
73 ret = nvkm_ram_init(&priv->base);
74 if (ret)
75 return ret;
76
77 dniso = ((priv->base.size - (priv->poller_base + 0x00)) >> 5) - 1;
78 hostnb = ((priv->base.size - (priv->poller_base + 0x20)) >> 5) - 1;
79 flush = ((priv->base.size - (priv->poller_base + 0x40)) >> 5) - 1;
80
81
82
83
84 nv_wr32(pfb, 0x100c18, dniso);
85 nv_mask(pfb, 0x100c14, 0x00000000, 0x00000001);
86 nv_wr32(pfb, 0x100c1c, hostnb);
87 nv_mask(pfb, 0x100c14, 0x00000000, 0x00000002);
88 nv_wr32(pfb, 0x100c24, flush);
89 nv_mask(pfb, 0x100c14, 0x00000000, 0x00010000);
90 return 0;
91}
92
93struct nvkm_oclass
94mcp77_ram_oclass = {
95 .ofuncs = &(struct nvkm_ofuncs) {
96 .ctor = mcp77_ram_ctor,
97 .dtor = _nvkm_ram_dtor,
98 .init = mcp77_ram_init,
99 .fini = _nvkm_ram_fini,
100 },
101};
102