This source file includes following definitions.
- nv05_devinit_meminit
- nv05_devinit_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
25
26 #include "nv04.h"
27 #include "fbmem.h"
28
29 #include <subdev/bios.h>
30 #include <subdev/bios/bmp.h>
31 #include <subdev/bios/init.h>
32 #include <subdev/vga.h>
33
34 static void
35 nv05_devinit_meminit(struct nvkm_devinit *init)
36 {
37 static const u8 default_config_tab[][2] = {
38 { 0x24, 0x00 },
39 { 0x28, 0x00 },
40 { 0x24, 0x01 },
41 { 0x1f, 0x00 },
42 { 0x0f, 0x00 },
43 { 0x17, 0x00 },
44 { 0x06, 0x00 },
45 { 0x00, 0x00 }
46 };
47 struct nvkm_subdev *subdev = &init->subdev;
48 struct nvkm_device *device = subdev->device;
49 struct nvkm_bios *bios = device->bios;
50 struct io_mapping *fb;
51 u32 patt = 0xdeadbeef;
52 u16 data;
53 u8 strap, ramcfg[2];
54 int i, v;
55
56
57 fb = fbmem_init(device);
58 if (!fb) {
59 nvkm_error(subdev, "failed to map fb\n");
60 return;
61 }
62
63 strap = (nvkm_rd32(device, 0x101000) & 0x0000003c) >> 2;
64 if ((data = bmp_mem_init_table(bios))) {
65 ramcfg[0] = nvbios_rd08(bios, data + 2 * strap + 0);
66 ramcfg[1] = nvbios_rd08(bios, data + 2 * strap + 1);
67 } else {
68 ramcfg[0] = default_config_tab[strap][0];
69 ramcfg[1] = default_config_tab[strap][1];
70 }
71
72
73 nvkm_wrvgas(device, 0, 1, nvkm_rdvgas(device, 0, 1) | 0x20);
74
75 if (nvkm_rd32(device, NV04_PFB_BOOT_0) & NV04_PFB_BOOT_0_UMA_ENABLE)
76 goto out;
77
78 nvkm_mask(device, NV04_PFB_DEBUG_0, NV04_PFB_DEBUG_0_REFRESH_OFF, 0);
79
80
81 if (data) {
82 for (i = 0, data += 0x10; i < 8; i++, data += 4) {
83 u32 scramble = nvbios_rd32(bios, data);
84 nvkm_wr32(device, NV04_PFB_SCRAMBLE(i), scramble);
85 }
86 }
87
88
89 nvkm_mask(device, NV04_PFB_BOOT_0, 0x3f, ramcfg[0]);
90
91 if (ramcfg[1] & 0x80)
92 nvkm_mask(device, NV04_PFB_CFG0, 0, NV04_PFB_CFG0_SCRAMBLE);
93
94 nvkm_mask(device, NV04_PFB_CFG1, 0x700001, (ramcfg[1] & 1) << 20);
95 nvkm_mask(device, NV04_PFB_CFG1, 0, 1);
96
97
98 for (i = 0; i < 4; i++)
99 fbmem_poke(fb, 4 * i, patt);
100
101 if (fbmem_peek(fb, 0xc) != patt)
102 nvkm_mask(device, NV04_PFB_BOOT_0,
103 NV04_PFB_BOOT_0_RAM_WIDTH_128, 0);
104
105
106 v = nvkm_rd32(device, NV04_PFB_BOOT_0) & NV04_PFB_BOOT_0_RAM_AMOUNT;
107
108 if (v == NV04_PFB_BOOT_0_RAM_AMOUNT_32MB &&
109 (!fbmem_readback(fb, 0x1000000, ++patt) ||
110 !fbmem_readback(fb, 0, ++patt)))
111 nvkm_mask(device, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT,
112 NV04_PFB_BOOT_0_RAM_AMOUNT_16MB);
113
114 if (v == NV04_PFB_BOOT_0_RAM_AMOUNT_16MB &&
115 !fbmem_readback(fb, 0x800000, ++patt))
116 nvkm_mask(device, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT,
117 NV04_PFB_BOOT_0_RAM_AMOUNT_8MB);
118
119 if (!fbmem_readback(fb, 0x400000, ++patt))
120 nvkm_mask(device, NV04_PFB_BOOT_0, NV04_PFB_BOOT_0_RAM_AMOUNT,
121 NV04_PFB_BOOT_0_RAM_AMOUNT_4MB);
122
123 out:
124
125 nvkm_wrvgas(device, 0, 1, nvkm_rdvgas(device, 0, 1) & ~0x20);
126 fbmem_fini(fb);
127 }
128
129 static const struct nvkm_devinit_func
130 nv05_devinit = {
131 .dtor = nv04_devinit_dtor,
132 .preinit = nv04_devinit_preinit,
133 .post = nv04_devinit_post,
134 .meminit = nv05_devinit_meminit,
135 .pll_set = nv04_devinit_pll_set,
136 };
137
138 int
139 nv05_devinit_new(struct nvkm_device *device, int index,
140 struct nvkm_devinit **pinit)
141 {
142 return nv04_devinit_new_(&nv05_devinit, device, index, pinit);
143 }