xref: /openbmc/linux/drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c (revision 3fb5a6562adef115d8a8c3e19cc9d5fae32e93c8)
1878da15aSBen Skeggs /*
2878da15aSBen Skeggs  * Copyright 2012 Red Hat Inc.
3878da15aSBen Skeggs  *
4878da15aSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
5878da15aSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
6878da15aSBen Skeggs  * to deal in the Software without restriction, including without limitation
7878da15aSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8878da15aSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
9878da15aSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
10878da15aSBen Skeggs  *
11878da15aSBen Skeggs  * The above copyright notice and this permission notice shall be included in
12878da15aSBen Skeggs  * all copies or substantial portions of the Software.
13878da15aSBen Skeggs  *
14878da15aSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15878da15aSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16878da15aSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17878da15aSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18878da15aSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19878da15aSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20878da15aSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
21878da15aSBen Skeggs  *
22878da15aSBen Skeggs  * Authors: Ben Skeggs
23878da15aSBen Skeggs  */
2492fba5d3SBen Skeggs #include "priv.h"
25acbe9ecfSBen Skeggs #include "chan.h"
26a1c93078SBen Skeggs #include "head.h"
2778f1ad6fSBen Skeggs #include "ior.h"
28acbe9ecfSBen Skeggs 
29acbe9ecfSBen Skeggs #include <subdev/timer.h>
30168c0299SBen Skeggs 
31168c0299SBen Skeggs #include <nvif/class.h>
32878da15aSBen Skeggs 
33acbe9ecfSBen Skeggs void
g94_sor_dp_watermark(struct nvkm_ior * sor,int head,u8 watermark)34acbe9ecfSBen Skeggs g94_sor_dp_watermark(struct nvkm_ior *sor, int head, u8 watermark)
35acbe9ecfSBen Skeggs {
36acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
37acbe9ecfSBen Skeggs 	const u32 loff = nv50_sor_link(sor);
38acbe9ecfSBen Skeggs 
39acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c128 + loff, 0x0000003f, watermark);
40acbe9ecfSBen Skeggs }
41acbe9ecfSBen Skeggs 
42acbe9ecfSBen Skeggs void
g94_sor_dp_activesym(struct nvkm_ior * sor,int head,u8 TU,u8 VTUa,u8 VTUf,u8 VTUi)43acbe9ecfSBen Skeggs g94_sor_dp_activesym(struct nvkm_ior *sor, int head,
44acbe9ecfSBen Skeggs 		     u8 TU, u8 VTUa, u8 VTUf, u8 VTUi)
45acbe9ecfSBen Skeggs {
46acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
47acbe9ecfSBen Skeggs 	const u32 loff = nv50_sor_link(sor);
48acbe9ecfSBen Skeggs 
49acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c10c + loff, 0x000001fc, TU << 2);
50acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c128 + loff, 0x010f7f00, VTUa << 24 | VTUf << 16 | VTUi << 8);
51acbe9ecfSBen Skeggs }
52acbe9ecfSBen Skeggs 
53acbe9ecfSBen Skeggs void
g94_sor_dp_audio_sym(struct nvkm_ior * sor,int head,u16 h,u32 v)54acbe9ecfSBen Skeggs g94_sor_dp_audio_sym(struct nvkm_ior *sor, int head, u16 h, u32 v)
55acbe9ecfSBen Skeggs {
56acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
57acbe9ecfSBen Skeggs 	const u32 soff = nv50_ior_base(sor);
58acbe9ecfSBen Skeggs 
59acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c1e8 + soff, 0x0000ffff, h);
60acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c1ec + soff, 0x00ffffff, v);
61acbe9ecfSBen Skeggs }
62acbe9ecfSBen Skeggs 
63acbe9ecfSBen Skeggs void
g94_sor_dp_drive(struct nvkm_ior * sor,int ln,int pc,int dc,int pe,int pu)64acbe9ecfSBen Skeggs g94_sor_dp_drive(struct nvkm_ior *sor, int ln, int pc, int dc, int pe, int pu)
65acbe9ecfSBen Skeggs {
66acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
67acbe9ecfSBen Skeggs 	const u32  loff = nv50_sor_link(sor);
689a4514fbSBen Skeggs 	const u32 shift = sor->func->dp->lanes[ln] * 8;
69acbe9ecfSBen Skeggs 	u32 data[3];
70acbe9ecfSBen Skeggs 
71acbe9ecfSBen Skeggs 	data[0] = nvkm_rd32(device, 0x61c118 + loff) & ~(0x000000ff << shift);
72acbe9ecfSBen Skeggs 	data[1] = nvkm_rd32(device, 0x61c120 + loff) & ~(0x000000ff << shift);
73acbe9ecfSBen Skeggs 	data[2] = nvkm_rd32(device, 0x61c130 + loff);
74acbe9ecfSBen Skeggs 	if ((data[2] & 0x0000ff00) < (pu << 8) || ln == 0)
75acbe9ecfSBen Skeggs 		data[2] = (data[2] & ~0x0000ff00) | (pu << 8);
76acbe9ecfSBen Skeggs 
77acbe9ecfSBen Skeggs 	nvkm_wr32(device, 0x61c118 + loff, data[0] | (dc << shift));
78acbe9ecfSBen Skeggs 	nvkm_wr32(device, 0x61c120 + loff, data[1] | (pe << shift));
79acbe9ecfSBen Skeggs 	nvkm_wr32(device, 0x61c130 + loff, data[2]);
80acbe9ecfSBen Skeggs }
81acbe9ecfSBen Skeggs 
82acbe9ecfSBen Skeggs void
g94_sor_dp_pattern(struct nvkm_ior * sor,int pattern)83acbe9ecfSBen Skeggs g94_sor_dp_pattern(struct nvkm_ior *sor, int pattern)
84acbe9ecfSBen Skeggs {
85acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
86acbe9ecfSBen Skeggs 	const u32 loff = nv50_sor_link(sor);
87acbe9ecfSBen Skeggs 	u32 data;
88acbe9ecfSBen Skeggs 
89acbe9ecfSBen Skeggs 	switch (pattern) {
90acbe9ecfSBen Skeggs 	case 0: data = 0x00001000; break;
91acbe9ecfSBen Skeggs 	case 1: data = 0x01000000; break;
92acbe9ecfSBen Skeggs 	case 2: data = 0x02000000; break;
93acbe9ecfSBen Skeggs 	default:
94acbe9ecfSBen Skeggs 		WARN_ON(1);
95acbe9ecfSBen Skeggs 		return;
96acbe9ecfSBen Skeggs 	}
97acbe9ecfSBen Skeggs 
98acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c10c + loff, 0x0f001000, data);
99acbe9ecfSBen Skeggs }
100acbe9ecfSBen Skeggs 
101acbe9ecfSBen Skeggs void
g94_sor_dp_power(struct nvkm_ior * sor,int nr)102acbe9ecfSBen Skeggs g94_sor_dp_power(struct nvkm_ior *sor, int nr)
103acbe9ecfSBen Skeggs {
104acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
105acbe9ecfSBen Skeggs 	const u32 soff = nv50_ior_base(sor);
106acbe9ecfSBen Skeggs 	const u32 loff = nv50_sor_link(sor);
107acbe9ecfSBen Skeggs 	u32 mask = 0, i;
108acbe9ecfSBen Skeggs 
109acbe9ecfSBen Skeggs 	for (i = 0; i < nr; i++)
1109a4514fbSBen Skeggs 		mask |= 1 << sor->func->dp->lanes[i];
111acbe9ecfSBen Skeggs 
112acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c130 + loff, 0x0000000f, mask);
113acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c034 + soff, 0x80000000, 0x80000000);
114acbe9ecfSBen Skeggs 	nvkm_msec(device, 2000,
115acbe9ecfSBen Skeggs 		if (!(nvkm_rd32(device, 0x61c034 + soff) & 0x80000000))
116acbe9ecfSBen Skeggs 			break;
117acbe9ecfSBen Skeggs 	);
118acbe9ecfSBen Skeggs }
119acbe9ecfSBen Skeggs 
120acbe9ecfSBen Skeggs int
g94_sor_dp_links(struct nvkm_ior * sor,struct nvkm_i2c_aux * aux)121acbe9ecfSBen Skeggs g94_sor_dp_links(struct nvkm_ior *sor, struct nvkm_i2c_aux *aux)
122acbe9ecfSBen Skeggs {
123acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
124acbe9ecfSBen Skeggs 	const u32 soff = nv50_ior_base(sor);
125acbe9ecfSBen Skeggs 	const u32 loff = nv50_sor_link(sor);
126acbe9ecfSBen Skeggs 	u32 dpctrl = 0x00000000;
127acbe9ecfSBen Skeggs 	u32 clksor = 0x00000000;
128acbe9ecfSBen Skeggs 
129acbe9ecfSBen Skeggs 	dpctrl |= ((1 << sor->dp.nr) - 1) << 16;
130acbe9ecfSBen Skeggs 	if (sor->dp.ef)
131acbe9ecfSBen Skeggs 		dpctrl |= 0x00004000;
132acbe9ecfSBen Skeggs 	if (sor->dp.bw > 0x06)
133acbe9ecfSBen Skeggs 		clksor |= 0x00040000;
134acbe9ecfSBen Skeggs 
135acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x614300 + soff, 0x000c0000, clksor);
136acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c10c + loff, 0x001f4000, dpctrl);
137acbe9ecfSBen Skeggs 	return 0;
138acbe9ecfSBen Skeggs }
139acbe9ecfSBen Skeggs 
1409a4514fbSBen Skeggs const struct nvkm_ior_func_dp
1419a4514fbSBen Skeggs g94_sor_dp = {
1429a4514fbSBen Skeggs 	.lanes = { 2, 1, 0, 3},
1439a4514fbSBen Skeggs 	.links = g94_sor_dp_links,
1449a4514fbSBen Skeggs 	.power = g94_sor_dp_power,
1459a4514fbSBen Skeggs 	.pattern = g94_sor_dp_pattern,
1469a4514fbSBen Skeggs 	.drive = g94_sor_dp_drive,
1479a4514fbSBen Skeggs 	.audio_sym = g94_sor_dp_audio_sym,
1489a4514fbSBen Skeggs 	.activesym = g94_sor_dp_activesym,
1499a4514fbSBen Skeggs 	.watermark = g94_sor_dp_watermark,
1509a4514fbSBen Skeggs };
1519a4514fbSBen Skeggs 
152acbe9ecfSBen Skeggs static bool
g94_sor_war_needed(struct nvkm_ior * sor)153acbe9ecfSBen Skeggs g94_sor_war_needed(struct nvkm_ior *sor)
154acbe9ecfSBen Skeggs {
155acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
156acbe9ecfSBen Skeggs 	const u32 soff = nv50_ior_base(sor);
157acbe9ecfSBen Skeggs 
158acbe9ecfSBen Skeggs 	if (sor->asy.proto == TMDS) {
159acbe9ecfSBen Skeggs 		switch (nvkm_rd32(device, 0x614300 + soff) & 0x00030000) {
160acbe9ecfSBen Skeggs 		case 0x00000000:
161acbe9ecfSBen Skeggs 		case 0x00030000:
162acbe9ecfSBen Skeggs 			return true;
163acbe9ecfSBen Skeggs 		default:
164acbe9ecfSBen Skeggs 			break;
165acbe9ecfSBen Skeggs 		}
166acbe9ecfSBen Skeggs 	}
167acbe9ecfSBen Skeggs 
168acbe9ecfSBen Skeggs 	return false;
169acbe9ecfSBen Skeggs }
170acbe9ecfSBen Skeggs 
171acbe9ecfSBen Skeggs static void
g94_sor_war_update_sppll1(struct nvkm_disp * disp)172acbe9ecfSBen Skeggs g94_sor_war_update_sppll1(struct nvkm_disp *disp)
173acbe9ecfSBen Skeggs {
174acbe9ecfSBen Skeggs 	struct nvkm_device *device = disp->engine.subdev.device;
175acbe9ecfSBen Skeggs 	struct nvkm_ior *ior;
176acbe9ecfSBen Skeggs 	bool used = false;
177acbe9ecfSBen Skeggs 	u32 clksor;
178acbe9ecfSBen Skeggs 
179acbe9ecfSBen Skeggs 	list_for_each_entry(ior, &disp->iors, head) {
180acbe9ecfSBen Skeggs 		if (ior->type != SOR)
181acbe9ecfSBen Skeggs 			continue;
182acbe9ecfSBen Skeggs 
183acbe9ecfSBen Skeggs 		clksor = nvkm_rd32(device, 0x614300 + nv50_ior_base(ior));
184acbe9ecfSBen Skeggs 		switch (clksor & 0x03000000) {
185acbe9ecfSBen Skeggs 		case 0x02000000:
186acbe9ecfSBen Skeggs 		case 0x03000000:
187acbe9ecfSBen Skeggs 			used = true;
188acbe9ecfSBen Skeggs 			break;
189acbe9ecfSBen Skeggs 		default:
190acbe9ecfSBen Skeggs 			break;
191acbe9ecfSBen Skeggs 		}
192acbe9ecfSBen Skeggs 	}
193acbe9ecfSBen Skeggs 
194acbe9ecfSBen Skeggs 	if (used)
195acbe9ecfSBen Skeggs 		return;
196acbe9ecfSBen Skeggs 
197acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x00e840, 0x80000000, 0x00000000);
198acbe9ecfSBen Skeggs }
199acbe9ecfSBen Skeggs 
200acbe9ecfSBen Skeggs static void
g94_sor_war_3(struct nvkm_ior * sor)201acbe9ecfSBen Skeggs g94_sor_war_3(struct nvkm_ior *sor)
202acbe9ecfSBen Skeggs {
203acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
204acbe9ecfSBen Skeggs 	const u32 soff = nv50_ior_base(sor);
205acbe9ecfSBen Skeggs 	u32 sorpwr;
206acbe9ecfSBen Skeggs 
207acbe9ecfSBen Skeggs 	if (!g94_sor_war_needed(sor))
208acbe9ecfSBen Skeggs 		return;
209acbe9ecfSBen Skeggs 
210acbe9ecfSBen Skeggs 	sorpwr = nvkm_rd32(device, 0x61c004 + soff);
211acbe9ecfSBen Skeggs 	if (sorpwr & 0x00000001) {
212acbe9ecfSBen Skeggs 		u32 seqctl = nvkm_rd32(device, 0x61c030 + soff);
213acbe9ecfSBen Skeggs 		u32  pd_pc = (seqctl & 0x00000f00) >> 8;
214acbe9ecfSBen Skeggs 		u32  pu_pc =  seqctl & 0x0000000f;
215acbe9ecfSBen Skeggs 
216acbe9ecfSBen Skeggs 		nvkm_wr32(device, 0x61c040 + soff + pd_pc * 4, 0x1f008000);
217acbe9ecfSBen Skeggs 
218acbe9ecfSBen Skeggs 		nvkm_msec(device, 2000,
219acbe9ecfSBen Skeggs 			if (!(nvkm_rd32(device, 0x61c030 + soff) & 0x10000000))
220acbe9ecfSBen Skeggs 				break;
221acbe9ecfSBen Skeggs 		);
222acbe9ecfSBen Skeggs 		nvkm_mask(device, 0x61c004 + soff, 0x80000001, 0x80000000);
223acbe9ecfSBen Skeggs 		nvkm_msec(device, 2000,
224acbe9ecfSBen Skeggs 			if (!(nvkm_rd32(device, 0x61c030 + soff) & 0x10000000))
225acbe9ecfSBen Skeggs 				break;
226acbe9ecfSBen Skeggs 		);
227acbe9ecfSBen Skeggs 
228acbe9ecfSBen Skeggs 		nvkm_wr32(device, 0x61c040 + soff + pd_pc * 4, 0x00002000);
229acbe9ecfSBen Skeggs 		nvkm_wr32(device, 0x61c040 + soff + pu_pc * 4, 0x1f000000);
230acbe9ecfSBen Skeggs 	}
231acbe9ecfSBen Skeggs 
232acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c10c + soff, 0x00000001, 0x00000000);
233acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x614300 + soff, 0x03000000, 0x00000000);
234acbe9ecfSBen Skeggs 
235acbe9ecfSBen Skeggs 	if (sorpwr & 0x00000001)
236acbe9ecfSBen Skeggs 		nvkm_mask(device, 0x61c004 + soff, 0x80000001, 0x80000001);
237acbe9ecfSBen Skeggs 
238acbe9ecfSBen Skeggs 	g94_sor_war_update_sppll1(sor->disp);
239acbe9ecfSBen Skeggs }
240acbe9ecfSBen Skeggs 
241acbe9ecfSBen Skeggs static void
g94_sor_war_2(struct nvkm_ior * sor)242acbe9ecfSBen Skeggs g94_sor_war_2(struct nvkm_ior *sor)
243acbe9ecfSBen Skeggs {
244acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
245acbe9ecfSBen Skeggs 	const u32 soff = nv50_ior_base(sor);
246acbe9ecfSBen Skeggs 
247acbe9ecfSBen Skeggs 	if (!g94_sor_war_needed(sor))
248acbe9ecfSBen Skeggs 		return;
249acbe9ecfSBen Skeggs 
250acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x00e840, 0x80000000, 0x80000000);
251acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x614300 + soff, 0x03000000, 0x03000000);
252acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c10c + soff, 0x00000001, 0x00000001);
253acbe9ecfSBen Skeggs 
254acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c00c + soff, 0x0f000000, 0x00000000);
255acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c008 + soff, 0xff000000, 0x14000000);
256acbe9ecfSBen Skeggs 	nvkm_usec(device, 400, NVKM_DELAY);
257acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c008 + soff, 0xff000000, 0x00000000);
258acbe9ecfSBen Skeggs 	nvkm_mask(device, 0x61c00c + soff, 0x0f000000, 0x01000000);
259acbe9ecfSBen Skeggs 
260acbe9ecfSBen Skeggs 	if (nvkm_rd32(device, 0x61c004 + soff) & 0x00000001) {
261acbe9ecfSBen Skeggs 		u32 seqctl = nvkm_rd32(device, 0x61c030 + soff);
262acbe9ecfSBen Skeggs 		u32  pu_pc = seqctl & 0x0000000f;
263acbe9ecfSBen Skeggs 		nvkm_wr32(device, 0x61c040 + soff + pu_pc * 4, 0x1f008000);
264acbe9ecfSBen Skeggs 	}
265acbe9ecfSBen Skeggs }
266acbe9ecfSBen Skeggs 
267acbe9ecfSBen Skeggs void
g94_sor_state(struct nvkm_ior * sor,struct nvkm_ior_state * state)268acbe9ecfSBen Skeggs g94_sor_state(struct nvkm_ior *sor, struct nvkm_ior_state *state)
269acbe9ecfSBen Skeggs {
270acbe9ecfSBen Skeggs 	struct nvkm_device *device = sor->disp->engine.subdev.device;
271acbe9ecfSBen Skeggs 	const u32 coff = sor->id * 8 + (state == &sor->arm) * 4;
272acbe9ecfSBen Skeggs 	u32 ctrl = nvkm_rd32(device, 0x610794 + coff);
273acbe9ecfSBen Skeggs 
274acbe9ecfSBen Skeggs 	state->proto_evo = (ctrl & 0x00000f00) >> 8;
275acbe9ecfSBen Skeggs 	switch (state->proto_evo) {
276acbe9ecfSBen Skeggs 	case 0: state->proto = LVDS; state->link = 1; break;
277acbe9ecfSBen Skeggs 	case 1: state->proto = TMDS; state->link = 1; break;
278acbe9ecfSBen Skeggs 	case 2: state->proto = TMDS; state->link = 2; break;
279acbe9ecfSBen Skeggs 	case 5: state->proto = TMDS; state->link = 3; break;
280acbe9ecfSBen Skeggs 	case 8: state->proto =   DP; state->link = 1; break;
281acbe9ecfSBen Skeggs 	case 9: state->proto =   DP; state->link = 2; break;
282acbe9ecfSBen Skeggs 	default:
283acbe9ecfSBen Skeggs 		state->proto = UNKNOWN;
284acbe9ecfSBen Skeggs 		break;
285acbe9ecfSBen Skeggs 	}
286acbe9ecfSBen Skeggs 
287acbe9ecfSBen Skeggs 	state->head = ctrl & 0x00000003;
288acbe9ecfSBen Skeggs 	nv50_pior_depth(sor, state, ctrl);
289acbe9ecfSBen Skeggs }
290acbe9ecfSBen Skeggs 
291acbe9ecfSBen Skeggs static const struct nvkm_ior_func
292acbe9ecfSBen Skeggs g94_sor = {
293acbe9ecfSBen Skeggs 	.state = g94_sor_state,
294acbe9ecfSBen Skeggs 	.power = nv50_sor_power,
295acbe9ecfSBen Skeggs 	.clock = nv50_sor_clock,
296acbe9ecfSBen Skeggs 	.war_2 = g94_sor_war_2,
297acbe9ecfSBen Skeggs 	.war_3 = g94_sor_war_3,
298*c177872cSKarol Herbst 	.hdmi = &g84_sor_hdmi,
2999a4514fbSBen Skeggs 	.dp = &g94_sor_dp,
300acbe9ecfSBen Skeggs };
301acbe9ecfSBen Skeggs 
302acbe9ecfSBen Skeggs static int
g94_sor_new(struct nvkm_disp * disp,int id)303acbe9ecfSBen Skeggs g94_sor_new(struct nvkm_disp *disp, int id)
304acbe9ecfSBen Skeggs {
30579c453afSBen Skeggs 	return nvkm_ior_new_(&g94_sor, disp, SOR, id, false);
306acbe9ecfSBen Skeggs }
307acbe9ecfSBen Skeggs 
308acbe9ecfSBen Skeggs int
g94_sor_cnt(struct nvkm_disp * disp,unsigned long * pmask)309acbe9ecfSBen Skeggs g94_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask)
310acbe9ecfSBen Skeggs {
311acbe9ecfSBen Skeggs 	struct nvkm_device *device = disp->engine.subdev.device;
312acbe9ecfSBen Skeggs 
313acbe9ecfSBen Skeggs 	*pmask = (nvkm_rd32(device, 0x610184) & 0x0f000000) >> 24;
314acbe9ecfSBen Skeggs 	return 4;
315acbe9ecfSBen Skeggs }
316acbe9ecfSBen Skeggs 
317acbe9ecfSBen Skeggs static const struct nvkm_disp_mthd_list
318acbe9ecfSBen Skeggs g94_disp_core_mthd_sor = {
319acbe9ecfSBen Skeggs 	.mthd = 0x0040,
320acbe9ecfSBen Skeggs 	.addr = 0x000008,
321acbe9ecfSBen Skeggs 	.data = {
322acbe9ecfSBen Skeggs 		{ 0x0600, 0x610794 },
323acbe9ecfSBen Skeggs 		{}
324acbe9ecfSBen Skeggs 	}
325acbe9ecfSBen Skeggs };
326acbe9ecfSBen Skeggs 
327acbe9ecfSBen Skeggs const struct nvkm_disp_chan_mthd
328acbe9ecfSBen Skeggs g94_disp_core_mthd = {
329acbe9ecfSBen Skeggs 	.name = "Core",
330acbe9ecfSBen Skeggs 	.addr = 0x000000,
331acbe9ecfSBen Skeggs 	.prev = 0x000004,
332acbe9ecfSBen Skeggs 	.data = {
333acbe9ecfSBen Skeggs 		{ "Global", 1, &nv50_disp_core_mthd_base },
334acbe9ecfSBen Skeggs 		{    "DAC", 3, &g84_disp_core_mthd_dac },
335acbe9ecfSBen Skeggs 		{    "SOR", 4, &g94_disp_core_mthd_sor },
336acbe9ecfSBen Skeggs 		{   "PIOR", 3, &nv50_disp_core_mthd_pior },
337acbe9ecfSBen Skeggs 		{   "HEAD", 2, &g84_disp_core_mthd_head },
338acbe9ecfSBen Skeggs 		{}
339acbe9ecfSBen Skeggs 	}
340acbe9ecfSBen Skeggs };
341acbe9ecfSBen Skeggs 
342889fcbe9SBen Skeggs const struct nvkm_disp_chan_user
343889fcbe9SBen Skeggs g94_disp_core = {
344889fcbe9SBen Skeggs 	.func = &nv50_disp_core_func,
345889fcbe9SBen Skeggs 	.ctrl = 0,
346889fcbe9SBen Skeggs 	.user = 0,
347889fcbe9SBen Skeggs 	.mthd = &g94_disp_core_mthd,
348889fcbe9SBen Skeggs };
349acbe9ecfSBen Skeggs 
3500407b33fSBen Skeggs static const struct nvkm_disp_func
3510ce41e3cSBen Skeggs g94_disp = {
352acbe9ecfSBen Skeggs 	.oneinit = nv50_disp_oneinit,
35392fba5d3SBen Skeggs 	.init = nv50_disp_init,
35492fba5d3SBen Skeggs 	.fini = nv50_disp_fini,
35592fba5d3SBen Skeggs 	.intr = nv50_disp_intr,
356af85389cSBen Skeggs 	.super = nv50_disp_super,
35792fba5d3SBen Skeggs 	.uevent = &nv50_disp_chan_uevent,
358f7b2ece3SBen Skeggs 	.head = { .cnt = nv50_head_cnt, .new = nv50_head_new },
359bf5d1a6bSBen Skeggs 	.dac = { .cnt = nv50_dac_cnt, .new = nv50_dac_new },
3609fe4e177SBen Skeggs 	.sor = { .cnt = g94_sor_cnt, .new = g94_sor_new },
361f5e088d6SBen Skeggs 	.pior = { .cnt = nv50_pior_cnt, .new = nv50_pior_new },
362168c0299SBen Skeggs 	.root = { 0,0,GT206_DISP },
363168c0299SBen Skeggs 	.user = {
364889fcbe9SBen Skeggs 		{{0,0,  G82_DISP_CURSOR             }, nvkm_disp_chan_new, & nv50_disp_curs },
365889fcbe9SBen Skeggs 		{{0,0,  G82_DISP_OVERLAY            }, nvkm_disp_chan_new, & nv50_disp_oimm },
366889fcbe9SBen Skeggs 		{{0,0,GT200_DISP_BASE_CHANNEL_DMA   }, nvkm_disp_chan_new, &  g84_disp_base },
367889fcbe9SBen Skeggs 		{{0,0,GT206_DISP_CORE_CHANNEL_DMA   }, nvkm_disp_core_new, &  g94_disp_core },
368889fcbe9SBen Skeggs 		{{0,0,GT200_DISP_OVERLAY_CHANNEL_DMA}, nvkm_disp_chan_new, &gt200_disp_ovly },
369168c0299SBen Skeggs 		{}
370168c0299SBen Skeggs 	},
3710ce41e3cSBen Skeggs };
3720ce41e3cSBen Skeggs 
37370aa8670SBen Skeggs int
g94_disp_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_disp ** pdisp)374a7f000ecSBen Skeggs g94_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
375a7f000ecSBen Skeggs 	     struct nvkm_disp **pdisp)
376878da15aSBen Skeggs {
3771c6aab75SBen Skeggs 	return nvkm_disp_new_(&g94_disp, device, type, inst, pdisp);
378878da15aSBen Skeggs }
379