]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/gpu/drm/nouveau/nvkm/engine/disp/sorg94.c
2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
27 #include <subdev/timer.h>
30 g94_sor_soff(struct nvkm_output_dp
*outp
)
32 return (ffs(outp
->base
.info
.or) - 1) * 0x800;
36 g94_sor_loff(struct nvkm_output_dp
*outp
)
38 return g94_sor_soff(outp
) + !(outp
->base
.info
.sorconf
.link
& 1) * 0x80;
41 /*******************************************************************************
43 ******************************************************************************/
45 g94_sor_dp_lane_map(struct nvkm_device
*device
, u8 lane
)
47 static const u8 gm100
[] = { 0, 8, 16, 24 };
48 static const u8 mcp89
[] = { 24, 16, 8, 0 }; /* thanks, apple.. */
49 static const u8 g94
[] = { 16, 8, 0, 24 };
50 if (device
->chipset
>= 0x110)
52 if (device
->chipset
== 0xaf)
58 g94_sor_dp_drv_ctl(struct nvkm_output_dp
*outp
, int ln
, int vs
, int pe
, int pc
)
60 struct nvkm_device
*device
= outp
->base
.disp
->engine
.subdev
.device
;
61 struct nvkm_bios
*bios
= device
->bios
;
62 const u32 shift
= g94_sor_dp_lane_map(device
, ln
);
63 const u32 loff
= g94_sor_loff(outp
);
65 u8 ver
, hdr
, cnt
, len
;
66 struct nvbios_dpout info
;
67 struct nvbios_dpcfg ocfg
;
69 addr
= nvbios_dpout_match(bios
, outp
->base
.info
.hasht
,
70 outp
->base
.info
.hashm
,
71 &ver
, &hdr
, &cnt
, &len
, &info
);
75 addr
= nvbios_dpcfg_match(bios
, addr
, 0, vs
, pe
,
76 &ver
, &hdr
, &cnt
, &len
, &ocfg
);
80 data
[0] = nvkm_rd32(device
, 0x61c118 + loff
) & ~(0x000000ff << shift
);
81 data
[1] = nvkm_rd32(device
, 0x61c120 + loff
) & ~(0x000000ff << shift
);
82 data
[2] = nvkm_rd32(device
, 0x61c130 + loff
);
83 if ((data
[2] & 0x0000ff00) < (ocfg
.tx_pu
<< 8) || ln
== 0)
84 data
[2] = (data
[2] & ~0x0000ff00) | (ocfg
.tx_pu
<< 8);
85 nvkm_wr32(device
, 0x61c118 + loff
, data
[0] | (ocfg
.dc
<< shift
));
86 nvkm_wr32(device
, 0x61c120 + loff
, data
[1] | (ocfg
.pe
<< shift
));
87 nvkm_wr32(device
, 0x61c130 + loff
, data
[2]);
92 g94_sor_dp_pattern(struct nvkm_output_dp
*outp
, int pattern
)
94 struct nvkm_device
*device
= outp
->base
.disp
->engine
.subdev
.device
;
95 const u32 loff
= g94_sor_loff(outp
);
96 nvkm_mask(device
, 0x61c10c + loff
, 0x0f000000, pattern
<< 24);
101 g94_sor_dp_lnk_pwr(struct nvkm_output_dp
*outp
, int nr
)
103 struct nvkm_device
*device
= outp
->base
.disp
->engine
.subdev
.device
;
104 const u32 soff
= g94_sor_soff(outp
);
105 const u32 loff
= g94_sor_loff(outp
);
108 for (i
= 0; i
< nr
; i
++)
109 mask
|= 1 << (g94_sor_dp_lane_map(device
, i
) >> 3);
111 nvkm_mask(device
, 0x61c130 + loff
, 0x0000000f, mask
);
112 nvkm_mask(device
, 0x61c034 + soff
, 0x80000000, 0x80000000);
113 nvkm_msec(device
, 2000,
114 if (!(nvkm_rd32(device
, 0x61c034 + soff
) & 0x80000000))
121 g94_sor_dp_lnk_ctl(struct nvkm_output_dp
*outp
, int nr
, int bw
, bool ef
)
123 struct nvkm_device
*device
= outp
->base
.disp
->engine
.subdev
.device
;
124 const u32 soff
= g94_sor_soff(outp
);
125 const u32 loff
= g94_sor_loff(outp
);
126 u32 dpctrl
= 0x00000000;
127 u32 clksor
= 0x00000000;
129 dpctrl
|= ((1 << nr
) - 1) << 16;
131 dpctrl
|= 0x00004000;
133 clksor
|= 0x00040000;
135 nvkm_mask(device
, 0x614300 + soff
, 0x000c0000, clksor
);
136 nvkm_mask(device
, 0x61c10c + loff
, 0x001f4000, dpctrl
);
140 static const struct nvkm_output_dp_func
142 .pattern
= g94_sor_dp_pattern
,
143 .lnk_pwr
= g94_sor_dp_lnk_pwr
,
144 .lnk_ctl
= g94_sor_dp_lnk_ctl
,
145 .drv_ctl
= g94_sor_dp_drv_ctl
,
149 g94_sor_dp_new(struct nvkm_disp
*disp
, int index
, struct dcb_output
*dcbE
,
150 struct nvkm_output
**poutp
)
152 return nvkm_output_dp_new_(&g94_sor_dp_func
, disp
, index
, dcbE
, poutp
);
156 nv50_disp_dptmds_war(struct nvkm_device
*device
)
158 switch (device
->chipset
) {
170 nv50_disp_dptmds_war_needed(struct nv50_disp
*disp
, struct dcb_output
*outp
)
172 struct nvkm_device
*device
= disp
->base
.engine
.subdev
.device
;
173 const u32 soff
= __ffs(outp
->or) * 0x800;
174 if (nv50_disp_dptmds_war(device
) && outp
->type
== DCB_OUTPUT_TMDS
) {
175 switch (nvkm_rd32(device
, 0x614300 + soff
) & 0x00030000) {
188 nv50_disp_update_sppll1(struct nv50_disp
*disp
)
190 struct nvkm_device
*device
= disp
->base
.engine
.subdev
.device
;
194 if (!nv50_disp_dptmds_war(device
))
197 for (sor
= 0; sor
< disp
->func
->sor
.nr
; sor
++) {
198 u32 clksor
= nvkm_rd32(device
, 0x614300 + (sor
* 0x800));
199 switch (clksor
& 0x03000000) {
212 nvkm_mask(device
, 0x00e840, 0x80000000, 0x00000000);
216 nv50_disp_dptmds_war_3(struct nv50_disp
*disp
, struct dcb_output
*outp
)
218 struct nvkm_device
*device
= disp
->base
.engine
.subdev
.device
;
219 const u32 soff
= __ffs(outp
->or) * 0x800;
222 if (!nv50_disp_dptmds_war_needed(disp
, outp
))
225 sorpwr
= nvkm_rd32(device
, 0x61c004 + soff
);
226 if (sorpwr
& 0x00000001) {
227 u32 seqctl
= nvkm_rd32(device
, 0x61c030 + soff
);
228 u32 pd_pc
= (seqctl
& 0x00000f00) >> 8;
229 u32 pu_pc
= seqctl
& 0x0000000f;
231 nvkm_wr32(device
, 0x61c040 + soff
+ pd_pc
* 4, 0x1f008000);
233 nvkm_msec(device
, 2000,
234 if (!(nvkm_rd32(device
, 0x61c030 + soff
) & 0x10000000))
237 nvkm_mask(device
, 0x61c004 + soff
, 0x80000001, 0x80000000);
238 nvkm_msec(device
, 2000,
239 if (!(nvkm_rd32(device
, 0x61c030 + soff
) & 0x10000000))
243 nvkm_wr32(device
, 0x61c040 + soff
+ pd_pc
* 4, 0x00002000);
244 nvkm_wr32(device
, 0x61c040 + soff
+ pu_pc
* 4, 0x1f000000);
247 nvkm_mask(device
, 0x61c10c + soff
, 0x00000001, 0x00000000);
248 nvkm_mask(device
, 0x614300 + soff
, 0x03000000, 0x00000000);
250 if (sorpwr
& 0x00000001) {
251 nvkm_mask(device
, 0x61c004 + soff
, 0x80000001, 0x80000001);
256 nv50_disp_dptmds_war_2(struct nv50_disp
*disp
, struct dcb_output
*outp
)
258 struct nvkm_device
*device
= disp
->base
.engine
.subdev
.device
;
259 const u32 soff
= __ffs(outp
->or) * 0x800;
261 if (!nv50_disp_dptmds_war_needed(disp
, outp
))
264 nvkm_mask(device
, 0x00e840, 0x80000000, 0x80000000);
265 nvkm_mask(device
, 0x614300 + soff
, 0x03000000, 0x03000000);
266 nvkm_mask(device
, 0x61c10c + soff
, 0x00000001, 0x00000001);
268 nvkm_mask(device
, 0x61c00c + soff
, 0x0f000000, 0x00000000);
269 nvkm_mask(device
, 0x61c008 + soff
, 0xff000000, 0x14000000);
270 nvkm_usec(device
, 400, NVKM_DELAY
);
271 nvkm_mask(device
, 0x61c008 + soff
, 0xff000000, 0x00000000);
272 nvkm_mask(device
, 0x61c00c + soff
, 0x0f000000, 0x01000000);
274 if (nvkm_rd32(device
, 0x61c004 + soff
) & 0x00000001) {
275 u32 seqctl
= nvkm_rd32(device
, 0x61c030 + soff
);
276 u32 pu_pc
= seqctl
& 0x0000000f;
277 nvkm_wr32(device
, 0x61c040 + soff
+ pu_pc
* 4, 0x1f008000);
282 g94_sor_state(struct nvkm_ior
*sor
, struct nvkm_ior_state
*state
)
284 struct nvkm_device
*device
= sor
->disp
->engine
.subdev
.device
;
285 const u32 coff
= sor
->id
* 8 + (state
== &sor
->arm
) * 4;
286 u32 ctrl
= nvkm_rd32(device
, 0x610794 + coff
);
288 state
->proto_evo
= (ctrl
& 0x00000f00) >> 8;
289 switch (state
->proto_evo
) {
290 case 0: state
->proto
= LVDS
; state
->link
= 1; break;
291 case 1: state
->proto
= TMDS
; state
->link
= 1; break;
292 case 2: state
->proto
= TMDS
; state
->link
= 2; break;
293 case 5: state
->proto
= TMDS
; state
->link
= 3; break;
294 case 8: state
->proto
= DP
; state
->link
= 1; break;
295 case 9: state
->proto
= DP
; state
->link
= 2; break;
297 state
->proto
= UNKNOWN
;
301 state
->head
= ctrl
& 0x00000003;
304 static const struct nvkm_ior_func
306 .state
= g94_sor_state
,
307 .power
= nv50_sor_power
,
311 g94_sor_new(struct nvkm_disp
*disp
, int id
)
313 return nvkm_ior_new_(&g94_sor
, disp
, SOR
, id
);