aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-09-23 01:42:45 -0400
committerBen Skeggs <bskeggs@redhat.com>2014-12-02 00:43:43 -0500
commitba6e34e612718b81744dfb1acb408cfb0043d6e4 (patch)
tree3b44230815ed5f719240e3b7d63a9cc7440d02e2
parente21fd7c4d3f86621a3d57131f4216c6d21c71106 (diff)
drm/gm204/devinit: initial implementation
Starting from GM204, certain registers are no longer accessible by the host (or unsigned PMU firmware). This commit implements devinit on PMU, using a signed microcode image, and devinit data, from the VBIOS. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/Makefile1
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/devinit.h1
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/devinit/gm107.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/devinit/gm204.c173
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/devinit/nv50.h2
5 files changed, 178 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index bb32d0ee0a0b..fe0f7705eefd 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -96,6 +96,7 @@ nouveau-y += core/subdev/devinit/nva3.o
96nouveau-y += core/subdev/devinit/nvaf.o 96nouveau-y += core/subdev/devinit/nvaf.o
97nouveau-y += core/subdev/devinit/nvc0.o 97nouveau-y += core/subdev/devinit/nvc0.o
98nouveau-y += core/subdev/devinit/gm107.o 98nouveau-y += core/subdev/devinit/gm107.o
99nouveau-y += core/subdev/devinit/gm204.o
99nouveau-y += core/subdev/fb/base.o 100nouveau-y += core/subdev/fb/base.o
100nouveau-y += core/subdev/fb/nv04.o 101nouveau-y += core/subdev/fb/nv04.o
101nouveau-y += core/subdev/fb/nv10.o 102nouveau-y += core/subdev/fb/nv10.o
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/devinit.h b/drivers/gpu/drm/nouveau/core/include/subdev/devinit.h
index e292271a84e4..e007a9d44683 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/devinit.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/devinit.h
@@ -30,5 +30,6 @@ extern struct nouveau_oclass *nva3_devinit_oclass;
30extern struct nouveau_oclass *nvaf_devinit_oclass; 30extern struct nouveau_oclass *nvaf_devinit_oclass;
31extern struct nouveau_oclass *nvc0_devinit_oclass; 31extern struct nouveau_oclass *nvc0_devinit_oclass;
32extern struct nouveau_oclass *gm107_devinit_oclass; 32extern struct nouveau_oclass *gm107_devinit_oclass;
33extern struct nouveau_oclass *gm204_devinit_oclass;
33 34
34#endif 35#endif
diff --git a/drivers/gpu/drm/nouveau/core/subdev/devinit/gm107.c b/drivers/gpu/drm/nouveau/core/subdev/devinit/gm107.c
index bc2b2a9aadfe..4ba43d6a1ec8 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/devinit/gm107.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/devinit/gm107.c
@@ -24,7 +24,7 @@
24 24
25#include "nv50.h" 25#include "nv50.h"
26 26
27static u64 27u64
28gm107_devinit_disable(struct nouveau_devinit *devinit) 28gm107_devinit_disable(struct nouveau_devinit *devinit)
29{ 29{
30 struct nv50_devinit_priv *priv = (void *)devinit; 30 struct nv50_devinit_priv *priv = (void *)devinit;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/devinit/gm204.c b/drivers/gpu/drm/nouveau/core/subdev/devinit/gm204.c
new file mode 100644
index 000000000000..e44a86662a2a
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/core/subdev/devinit/gm204.c
@@ -0,0 +1,173 @@
1/*
2 * Copyright 2013 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#include <subdev/bios.h>
26#include <subdev/bios/bit.h>
27#include <subdev/bios/pmu.h>
28
29#include "nv50.h"
30
31static void
32pmu_code(struct nv50_devinit_priv *priv, u32 pmu, u32 img, u32 len, bool sec)
33{
34 struct nouveau_bios *bios = nouveau_bios(priv);
35 int i;
36
37 nv_wr32(priv, 0x10a180, 0x01000000 | (sec ? 0x10000000 : 0) | pmu);
38 for (i = 0; i < len; i += 4) {
39 if ((i & 0xff) == 0)
40 nv_wr32(priv, 0x10a188, (pmu + i) >> 8);
41 nv_wr32(priv, 0x10a184, nv_ro32(bios, img + i));
42 }
43
44 while (i & 0xff) {
45 nv_wr32(priv, 0x10a184, 0x00000000);
46 i += 4;
47 }
48}
49
50static void
51pmu_data(struct nv50_devinit_priv *priv, u32 pmu, u32 img, u32 len)
52{
53 struct nouveau_bios *bios = nouveau_bios(priv);
54 int i;
55
56 nv_wr32(priv, 0x10a1c0, 0x01000000 | pmu);
57 for (i = 0; i < len; i += 4)
58 nv_wr32(priv, 0x10a1c4, nv_ro32(bios, img + i));
59}
60
61static u32
62pmu_args(struct nv50_devinit_priv *priv, u32 argp, u32 argi)
63{
64 nv_wr32(priv, 0x10a1c0, argp);
65 nv_wr32(priv, 0x10a1c0, nv_rd32(priv, 0x10a1c4) + argi);
66 return nv_rd32(priv, 0x10a1c4);
67}
68
69static void
70pmu_exec(struct nv50_devinit_priv *priv, u32 init_addr)
71{
72 nv_wr32(priv, 0x10a104, init_addr);
73 nv_wr32(priv, 0x10a10c, 0x00000000);
74 nv_wr32(priv, 0x10a100, 0x00000002);
75}
76
77static int
78pmu_load(struct nv50_devinit_priv *priv, u8 type, bool post,
79 u32 *init_addr_pmu, u32 *args_addr_pmu)
80{
81 struct nouveau_bios *bios = nouveau_bios(priv);
82 struct nvbios_pmuR pmu;
83
84 if (!nvbios_pmuRm(bios, type, &pmu)) {
85 nv_error(priv, "VBIOS PMU fuc %02x not found\n", type);
86 return -EINVAL;
87 }
88
89 if (!post)
90 return 0;
91
92 pmu_code(priv, pmu.boot_addr_pmu, pmu.boot_addr, pmu.boot_size, false);
93 pmu_code(priv, pmu.code_addr_pmu, pmu.code_addr, pmu.code_size, true);
94 pmu_data(priv, pmu.data_addr_pmu, pmu.data_addr, pmu.data_size);
95
96 if (init_addr_pmu) {
97 *init_addr_pmu = pmu.init_addr_pmu;
98 *args_addr_pmu = pmu.args_addr_pmu;
99 return 0;
100 }
101
102 return pmu_exec(priv, pmu.init_addr_pmu), 0;
103}
104
105static int
106gm204_devinit_post(struct nouveau_subdev *subdev, bool post)
107{
108 struct nv50_devinit_priv *priv = (void *)nouveau_devinit(subdev);
109 struct nouveau_bios *bios = nouveau_bios(priv);
110 struct bit_entry bit_I;
111 u32 init, args;
112 int ret;
113
114 if (bit_entry(bios, 'I', &bit_I) || bit_I.version != 1 ||
115 bit_I.length < 0x1c) {
116 nv_error(priv, "VBIOS PMU init data not found\n");
117 return -EINVAL;
118 }
119
120 /* reset PMU and load init table parser ucode */
121 if (post) {
122 nv_mask(priv, 0x000200, 0x00002000, 0x00000000);
123 nv_mask(priv, 0x000200, 0x00002000, 0x00002000);
124 nv_rd32(priv, 0x000200);
125 while (nv_rd32(priv, 0x10a10c) & 0x00000006) {
126 }
127 }
128
129 ret = pmu_load(priv, 0x04, post, &init, &args);
130 if (ret)
131 return ret;
132
133 /* upload first chunk of init data */
134 if (post) {
135 u32 pmu = pmu_args(priv, args + 0x08, 0x08);
136 u32 img = nv_ro16(bios, bit_I.offset + 0x14);
137 u32 len = nv_ro16(bios, bit_I.offset + 0x16);
138 pmu_data(priv, pmu, img, len);
139 }
140
141 /* upload second chunk of init data */
142 if (post) {
143 u32 pmu = pmu_args(priv, args + 0x08, 0x10);
144 u32 img = nv_ro16(bios, bit_I.offset + 0x18);
145 u32 len = nv_ro16(bios, bit_I.offset + 0x1a);
146 pmu_data(priv, pmu, img, len);
147 }
148
149 /* execute init tables */
150 if (post) {
151 nv_wr32(priv, 0x10a040, 0x00005000);
152 pmu_exec(priv, init);
153 while (!(nv_rd32(priv, 0x10a040) & 0x00002000)) {
154 }
155 }
156
157 /* load and execute some other ucode image (bios therm?) */
158 return pmu_load(priv, 0x01, post, NULL, NULL);
159}
160
161struct nouveau_oclass *
162gm204_devinit_oclass = &(struct nouveau_devinit_impl) {
163 .base.handle = NV_SUBDEV(DEVINIT, 0x07),
164 .base.ofuncs = &(struct nouveau_ofuncs) {
165 .ctor = nv50_devinit_ctor,
166 .dtor = _nouveau_devinit_dtor,
167 .init = nv50_devinit_init,
168 .fini = _nouveau_devinit_fini,
169 },
170 .pll_set = nvc0_devinit_pll_set,
171 .disable = gm107_devinit_disable,
172 .post = gm204_devinit_post,
173}.base;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/devinit/nv50.h b/drivers/gpu/drm/nouveau/core/subdev/devinit/nv50.h
index 51d5076333ec..f412bb7f780e 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/devinit/nv50.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/devinit/nv50.h
@@ -18,4 +18,6 @@ int nva3_devinit_pll_set(struct nouveau_devinit *, u32, u32);
18 18
19int nvc0_devinit_pll_set(struct nouveau_devinit *, u32, u32); 19int nvc0_devinit_pll_set(struct nouveau_devinit *, u32, u32);
20 20
21u64 gm107_devinit_disable(struct nouveau_devinit *);
22
21#endif 23#endif