blob: dcd1836800bff58b19f061da8b0eda535d533fd4 [file] [log] [blame]
Ben Skeggsa2bc2832013-02-11 09:11:08 +10001/*
2 * Copyright 2012 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 */
Ben Skeggs878da152015-01-14 15:24:57 +100024#include "outpdp.h"
Ben Skeggsf2c906f2015-08-20 14:54:15 +100025#include "nv50.h"
Ben Skeggsa2bc2832013-02-11 09:11:08 +100026
Ben Skeggs67cb49c2014-08-10 04:10:27 +100027#include <core/client.h>
Ben Skeggsa2bc2832013-02-11 09:11:08 +100028#include <subdev/i2c.h>
Ben Skeggs878da152015-01-14 15:24:57 +100029#include <subdev/timer.h>
Ben Skeggsa2bc2832013-02-11 09:11:08 +100030
Ben Skeggs7568b102015-11-08 10:44:19 +100031#include <nvif/cl5070.h>
Ben Skeggs878da152015-01-14 15:24:57 +100032#include <nvif/unpack.h>
Ben Skeggsa2bc2832013-02-11 09:11:08 +100033
Ben Skeggsa2bc2832013-02-11 09:11:08 +100034int
Ben Skeggs67cb49c2014-08-10 04:10:27 +100035nv50_pior_power(NV50_DISP_MTHD_V1)
Ben Skeggsa2bc2832013-02-11 09:11:08 +100036{
Ben Skeggs2fde1f12015-08-20 14:54:10 +100037 struct nvkm_device *device = disp->base.engine.subdev.device;
Ben Skeggs67cb49c2014-08-10 04:10:27 +100038 const u32 soff = outp->or * 0x800;
39 union {
40 struct nv50_disp_pior_pwr_v0 v0;
41 } *args = data;
42 u32 ctrl, type;
Ben Skeggsa2bc2832013-02-11 09:11:08 +100043 int ret;
44
Ben Skeggs53003942015-08-20 14:54:13 +100045 nvif_ioctl(object, "disp pior pwr size %d\n", size);
Ben Skeggs67cb49c2014-08-10 04:10:27 +100046 if (nvif_unpack(args->v0, 0, 0, false)) {
Ben Skeggs53003942015-08-20 14:54:13 +100047 nvif_ioctl(object, "disp pior pwr vers %d state %d type %x\n",
48 args->v0.version, args->v0.state, args->v0.type);
Ben Skeggs67cb49c2014-08-10 04:10:27 +100049 if (args->v0.type > 0x0f)
50 return -EINVAL;
51 ctrl = !!args->v0.state;
52 type = args->v0.type;
53 } else
54 return ret;
Ben Skeggsa2bc2832013-02-11 09:11:08 +100055
Ben Skeggs3a020b42015-08-20 14:54:11 +100056 nvkm_msec(device, 2000,
57 if (!(nvkm_rd32(device, 0x61e004 + soff) & 0x80000000))
58 break;
59 );
Ben Skeggs2fde1f12015-08-20 14:54:10 +100060 nvkm_mask(device, 0x61e004 + soff, 0x80000101, 0x80000000 | ctrl);
Ben Skeggs3a020b42015-08-20 14:54:11 +100061 nvkm_msec(device, 2000,
62 if (!(nvkm_rd32(device, 0x61e004 + soff) & 0x80000000))
63 break;
64 );
Ben Skeggsfd166a12015-08-20 14:54:07 +100065 disp->pior.type[outp->or] = type;
Ben Skeggs67cb49c2014-08-10 04:10:27 +100066 return 0;
Ben Skeggsa2bc2832013-02-11 09:11:08 +100067}
Ben Skeggsf2c906f2015-08-20 14:54:15 +100068
69/******************************************************************************
70 * TMDS
71 *****************************************************************************/
72static const struct nvkm_output_func
73nv50_pior_output_func = {
74};
75
76int
77nv50_pior_output_new(struct nvkm_disp *disp, int index,
78 struct dcb_output *dcbE, struct nvkm_output **poutp)
79{
80 return nvkm_output_new_(&nv50_pior_output_func, disp,
81 index, dcbE, poutp);
82}
83
84/******************************************************************************
85 * DisplayPort
86 *****************************************************************************/
87static int
88nv50_pior_output_dp_pattern(struct nvkm_output_dp *outp, int pattern)
89{
90 return 0;
91}
92
93static int
94nv50_pior_output_dp_lnk_pwr(struct nvkm_output_dp *outp, int nr)
95{
96 return 0;
97}
98
99static int
100nv50_pior_output_dp_lnk_ctl(struct nvkm_output_dp *outp,
101 int nr, int bw, bool ef)
102{
103 int ret = nvkm_i2c_aux_lnk_ctl(outp->aux, nr, bw, ef);
104 if (ret)
105 return ret;
106 return 1;
107}
108
109static const struct nvkm_output_dp_func
110nv50_pior_output_dp_func = {
111 .pattern = nv50_pior_output_dp_pattern,
112 .lnk_pwr = nv50_pior_output_dp_lnk_pwr,
113 .lnk_ctl = nv50_pior_output_dp_lnk_ctl,
114};
115
116int
117nv50_pior_dp_new(struct nvkm_disp *disp, int index, struct dcb_output *dcbE,
118 struct nvkm_output **poutp)
119{
120 struct nvkm_i2c *i2c = disp->engine.subdev.device->i2c;
121 struct nvkm_i2c_aux *aux =
122 nvkm_i2c_aux_find(i2c, NVKM_I2C_AUX_EXT(dcbE->extdev));
123 struct nvkm_output_dp *outp;
124
125 if (!(outp = kzalloc(sizeof(*outp), GFP_KERNEL)))
126 return -ENOMEM;
127 *poutp = &outp->base;
128
129 return nvkm_output_dp_ctor(&nv50_pior_output_dp_func, disp,
130 index, dcbE, aux, outp);
131}