]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
drm/nouveau/disp: introduce input/output resource abstraction
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / nvkm / engine / disp / piornv50.c
1 /*
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  */
24 #include "ior.h"
25 #include "nv50.h"
26
27 #include <core/client.h>
28 #include <subdev/i2c.h>
29 #include <subdev/timer.h>
30
31 #include <nvif/cl5070.h>
32 #include <nvif/unpack.h>
33
34 /******************************************************************************
35  * TMDS
36  *****************************************************************************/
37 static const struct nvkm_output_func
38 nv50_pior_output_func = {
39 };
40
41 int
42 nv50_pior_output_new(struct nvkm_disp *disp, int index,
43                      struct dcb_output *dcbE, struct nvkm_output **poutp)
44 {
45         return nvkm_output_new_(&nv50_pior_output_func, disp,
46                                 index, dcbE, poutp);
47 }
48
49 /******************************************************************************
50  * DisplayPort
51  *****************************************************************************/
52 static int
53 nv50_pior_output_dp_pattern(struct nvkm_output_dp *outp, int pattern)
54 {
55         return 0;
56 }
57
58 static int
59 nv50_pior_output_dp_lnk_pwr(struct nvkm_output_dp *outp, int nr)
60 {
61         return 0;
62 }
63
64 static int
65 nv50_pior_output_dp_lnk_ctl(struct nvkm_output_dp *outp,
66                             int nr, int bw, bool ef)
67 {
68         int ret = nvkm_i2c_aux_lnk_ctl(outp->aux, nr, bw, ef);
69         if (ret)
70                 return ret;
71         return 1;
72 }
73
74 static const struct nvkm_output_dp_func
75 nv50_pior_output_dp_func = {
76         .pattern = nv50_pior_output_dp_pattern,
77         .lnk_pwr = nv50_pior_output_dp_lnk_pwr,
78         .lnk_ctl = nv50_pior_output_dp_lnk_ctl,
79 };
80
81 int
82 nv50_pior_dp_new(struct nvkm_disp *disp, int index, struct dcb_output *dcbE,
83                  struct nvkm_output **poutp)
84 {
85         return nvkm_output_dp_new_(&nv50_pior_output_dp_func, disp,
86                                    index, dcbE, poutp);
87 }
88
89 int
90 nv50_pior_power(NV50_DISP_MTHD_V1)
91 {
92         struct nvkm_device *device = disp->base.engine.subdev.device;
93         const u32 soff = outp->or * 0x800;
94         union {
95                 struct nv50_disp_pior_pwr_v0 v0;
96         } *args = data;
97         u32 ctrl, type;
98         int ret = -ENOSYS;
99
100         nvif_ioctl(object, "disp pior pwr size %d\n", size);
101         if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
102                 nvif_ioctl(object, "disp pior pwr vers %d state %d type %x\n",
103                            args->v0.version, args->v0.state, args->v0.type);
104                 if (args->v0.type > 0x0f)
105                         return -EINVAL;
106                 ctrl = !!args->v0.state;
107                 type = args->v0.type;
108         } else
109                 return ret;
110
111         nvkm_msec(device, 2000,
112                 if (!(nvkm_rd32(device, 0x61e004 + soff) & 0x80000000))
113                         break;
114         );
115         nvkm_mask(device, 0x61e004 + soff, 0x80000101, 0x80000000 | ctrl);
116         nvkm_msec(device, 2000,
117                 if (!(nvkm_rd32(device, 0x61e004 + soff) & 0x80000000))
118                         break;
119         );
120         disp->pior.type[outp->or] = type;
121         return 0;
122 }
123
124 static const struct nvkm_ior_func
125 nv50_pior = {
126 };
127
128 int
129 nv50_pior_new(struct nvkm_disp *disp, int id)
130 {
131         return nvkm_ior_new_(&nv50_pior, disp, PIOR, id);
132 }