1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <core/os.h>
26#include <core/class.h>
27
28#include <subdev/bios.h>
29#include <subdev/bios/dcb.h>
30#include <subdev/timer.h>
31#include <subdev/i2c.h>
32
33#include "nv50.h"
34
35
36
37
38static struct nouveau_i2c_port *
39nv50_pior_dp_find(struct nouveau_disp *disp, struct dcb_output *outp)
40{
41 struct nouveau_i2c *i2c = nouveau_i2c(disp);
42 return i2c->find_type(i2c, NV_I2C_TYPE_EXTAUX(outp->extdev));
43}
44
45static int
46nv50_pior_dp_pattern(struct nouveau_disp *disp, struct dcb_output *outp,
47 int head, int pattern)
48{
49 struct nouveau_i2c_port *port;
50 int ret = -EINVAL;
51
52 port = nv50_pior_dp_find(disp, outp);
53 if (port) {
54 if (port->func->pattern)
55 ret = port->func->pattern(port, pattern);
56 else
57 ret = 0;
58 }
59
60 return ret;
61}
62
63static int
64nv50_pior_dp_lnk_ctl(struct nouveau_disp *disp, struct dcb_output *outp,
65 int head, int lane_nr, int link_bw, bool enh)
66{
67 struct nouveau_i2c_port *port;
68 int ret = -EINVAL;
69
70 port = nv50_pior_dp_find(disp, outp);
71 if (port && port->func->lnk_ctl)
72 ret = port->func->lnk_ctl(port, lane_nr, link_bw, enh);
73
74 return ret;
75}
76
77static int
78nv50_pior_dp_drv_ctl(struct nouveau_disp *disp, struct dcb_output *outp,
79 int head, int lane, int vsw, int pre)
80{
81 struct nouveau_i2c_port *port;
82 int ret = -EINVAL;
83
84 port = nv50_pior_dp_find(disp, outp);
85 if (port) {
86 if (port->func->drv_ctl)
87 ret = port->func->drv_ctl(port, lane, vsw, pre);
88 else
89 ret = 0;
90 }
91
92 return ret;
93}
94
95const struct nouveau_dp_func
96nv50_pior_dp_func = {
97 .pattern = nv50_pior_dp_pattern,
98 .lnk_ctl = nv50_pior_dp_lnk_ctl,
99 .drv_ctl = nv50_pior_dp_drv_ctl,
100};
101
102
103
104
105int
106nv50_pior_power(struct nv50_disp_priv *priv, int or, u32 data)
107{
108 const u32 stat = data & NV50_DISP_PIOR_PWR_STATE;
109 const u32 soff = (or * 0x800);
110 nv_wait(priv, 0x61e004 + soff, 0x80000000, 0x00000000);
111 nv_mask(priv, 0x61e004 + soff, 0x80000101, 0x80000000 | stat);
112 nv_wait(priv, 0x61e004 + soff, 0x80000000, 0x00000000);
113 return 0;
114}
115
116int
117nv50_pior_mthd(struct nouveau_object *object, u32 mthd, void *args, u32 size)
118{
119 struct nv50_disp_priv *priv = (void *)object->engine;
120 const u8 type = (mthd & NV50_DISP_PIOR_MTHD_TYPE) >> 12;
121 const u8 or = (mthd & NV50_DISP_PIOR_MTHD_OR);
122 u32 *data = args;
123 int ret;
124
125 if (size < sizeof(u32))
126 return -EINVAL;
127
128 mthd &= ~NV50_DISP_PIOR_MTHD_TYPE;
129 mthd &= ~NV50_DISP_PIOR_MTHD_OR;
130 switch (mthd) {
131 case NV50_DISP_PIOR_PWR:
132 ret = priv->pior.power(priv, or, data[0]);
133 priv->pior.type[or] = type;
134 break;
135 default:
136 return -EINVAL;
137 }
138
139 return ret;
140}
141