1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev * Copyright 2018 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev *
4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev *
11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev *
14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev *
22*b843c749SSergey Zigachev * Authors: AMD
23*b843c749SSergey Zigachev *
24*b843c749SSergey Zigachev */
25*b843c749SSergey Zigachev
26*b843c749SSergey Zigachev #include <linux/debugfs.h>
27*b843c749SSergey Zigachev
28*b843c749SSergey Zigachev #include "dc.h"
29*b843c749SSergey Zigachev #include "amdgpu.h"
30*b843c749SSergey Zigachev #include "amdgpu_dm.h"
31*b843c749SSergey Zigachev #include "amdgpu_dm_debugfs.h"
32*b843c749SSergey Zigachev
33*b843c749SSergey Zigachev /* function description
34*b843c749SSergey Zigachev * get/ set DP configuration: lane_count, link_rate, spread_spectrum
35*b843c749SSergey Zigachev *
36*b843c749SSergey Zigachev * valid lane count value: 1, 2, 4
37*b843c749SSergey Zigachev * valid link rate value:
38*b843c749SSergey Zigachev * 06h = 1.62Gbps per lane
39*b843c749SSergey Zigachev * 0Ah = 2.7Gbps per lane
40*b843c749SSergey Zigachev * 0Ch = 3.24Gbps per lane
41*b843c749SSergey Zigachev * 14h = 5.4Gbps per lane
42*b843c749SSergey Zigachev * 1Eh = 8.1Gbps per lane
43*b843c749SSergey Zigachev *
44*b843c749SSergey Zigachev * debugfs is located at /sys/kernel/debug/dri/0/DP-x/link_settings
45*b843c749SSergey Zigachev *
46*b843c749SSergey Zigachev * --- to get dp configuration
47*b843c749SSergey Zigachev *
48*b843c749SSergey Zigachev * cat link_settings
49*b843c749SSergey Zigachev *
50*b843c749SSergey Zigachev * It will list current, verified, reported, preferred dp configuration.
51*b843c749SSergey Zigachev * current -- for current video mode
52*b843c749SSergey Zigachev * verified --- maximum configuration which pass link training
53*b843c749SSergey Zigachev * reported --- DP rx report caps (DPCD register offset 0, 1 2)
54*b843c749SSergey Zigachev * preferred --- user force settings
55*b843c749SSergey Zigachev *
56*b843c749SSergey Zigachev * --- set (or force) dp configuration
57*b843c749SSergey Zigachev *
58*b843c749SSergey Zigachev * echo <lane_count> <link_rate> > link_settings
59*b843c749SSergey Zigachev *
60*b843c749SSergey Zigachev * for example, to force to 2 lane, 2.7GHz,
61*b843c749SSergey Zigachev * echo 4 0xa > link_settings
62*b843c749SSergey Zigachev *
63*b843c749SSergey Zigachev * spread_spectrum could not be changed dynamically.
64*b843c749SSergey Zigachev *
65*b843c749SSergey Zigachev * in case invalid lane count, link rate are force, no hw programming will be
66*b843c749SSergey Zigachev * done. please check link settings after force operation to see if HW get
67*b843c749SSergey Zigachev * programming.
68*b843c749SSergey Zigachev *
69*b843c749SSergey Zigachev * cat link_settings
70*b843c749SSergey Zigachev *
71*b843c749SSergey Zigachev * check current and preferred settings.
72*b843c749SSergey Zigachev *
73*b843c749SSergey Zigachev */
dp_link_settings_read(struct file * f,char __user * buf,size_t size,loff_t * pos)74*b843c749SSergey Zigachev static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
75*b843c749SSergey Zigachev size_t size, loff_t *pos)
76*b843c749SSergey Zigachev {
77*b843c749SSergey Zigachev struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
78*b843c749SSergey Zigachev struct dc_link *link = connector->dc_link;
79*b843c749SSergey Zigachev char *rd_buf = NULL;
80*b843c749SSergey Zigachev char *rd_buf_ptr = NULL;
81*b843c749SSergey Zigachev const uint32_t rd_buf_size = 100;
82*b843c749SSergey Zigachev uint32_t result = 0;
83*b843c749SSergey Zigachev uint8_t str_len = 0;
84*b843c749SSergey Zigachev int r;
85*b843c749SSergey Zigachev
86*b843c749SSergey Zigachev if (*pos & 3 || size & 3)
87*b843c749SSergey Zigachev return -EINVAL;
88*b843c749SSergey Zigachev
89*b843c749SSergey Zigachev rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
90*b843c749SSergey Zigachev if (!rd_buf)
91*b843c749SSergey Zigachev return 0;
92*b843c749SSergey Zigachev
93*b843c749SSergey Zigachev rd_buf_ptr = rd_buf;
94*b843c749SSergey Zigachev
95*b843c749SSergey Zigachev str_len = strlen("Current: %d 0x%x %d ");
96*b843c749SSergey Zigachev snprintf(rd_buf_ptr, str_len, "Current: %d 0x%x %d ",
97*b843c749SSergey Zigachev link->cur_link_settings.lane_count,
98*b843c749SSergey Zigachev link->cur_link_settings.link_rate,
99*b843c749SSergey Zigachev link->cur_link_settings.link_spread);
100*b843c749SSergey Zigachev rd_buf_ptr += str_len;
101*b843c749SSergey Zigachev
102*b843c749SSergey Zigachev str_len = strlen("Verified: %d 0x%x %d ");
103*b843c749SSergey Zigachev snprintf(rd_buf_ptr, str_len, "Verified: %d 0x%x %d ",
104*b843c749SSergey Zigachev link->verified_link_cap.lane_count,
105*b843c749SSergey Zigachev link->verified_link_cap.link_rate,
106*b843c749SSergey Zigachev link->verified_link_cap.link_spread);
107*b843c749SSergey Zigachev rd_buf_ptr += str_len;
108*b843c749SSergey Zigachev
109*b843c749SSergey Zigachev str_len = strlen("Reported: %d 0x%x %d ");
110*b843c749SSergey Zigachev snprintf(rd_buf_ptr, str_len, "Reported: %d 0x%x %d ",
111*b843c749SSergey Zigachev link->reported_link_cap.lane_count,
112*b843c749SSergey Zigachev link->reported_link_cap.link_rate,
113*b843c749SSergey Zigachev link->reported_link_cap.link_spread);
114*b843c749SSergey Zigachev rd_buf_ptr += str_len;
115*b843c749SSergey Zigachev
116*b843c749SSergey Zigachev str_len = strlen("Preferred: %d 0x%x %d ");
117*b843c749SSergey Zigachev snprintf(rd_buf_ptr, str_len, "Preferred: %d 0x%x %d\n",
118*b843c749SSergey Zigachev link->preferred_link_setting.lane_count,
119*b843c749SSergey Zigachev link->preferred_link_setting.link_rate,
120*b843c749SSergey Zigachev link->preferred_link_setting.link_spread);
121*b843c749SSergey Zigachev
122*b843c749SSergey Zigachev while (size) {
123*b843c749SSergey Zigachev if (*pos >= rd_buf_size)
124*b843c749SSergey Zigachev break;
125*b843c749SSergey Zigachev
126*b843c749SSergey Zigachev r = put_user(*(rd_buf + result), buf);
127*b843c749SSergey Zigachev if (r)
128*b843c749SSergey Zigachev return r; /* r = -EFAULT */
129*b843c749SSergey Zigachev
130*b843c749SSergey Zigachev buf += 1;
131*b843c749SSergey Zigachev size -= 1;
132*b843c749SSergey Zigachev *pos += 1;
133*b843c749SSergey Zigachev result += 1;
134*b843c749SSergey Zigachev }
135*b843c749SSergey Zigachev
136*b843c749SSergey Zigachev kfree(rd_buf);
137*b843c749SSergey Zigachev return result;
138*b843c749SSergey Zigachev }
139*b843c749SSergey Zigachev
dp_link_settings_write(struct file * f,const char __user * buf,size_t size,loff_t * pos)140*b843c749SSergey Zigachev static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
141*b843c749SSergey Zigachev size_t size, loff_t *pos)
142*b843c749SSergey Zigachev {
143*b843c749SSergey Zigachev struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
144*b843c749SSergey Zigachev struct dc_link *link = connector->dc_link;
145*b843c749SSergey Zigachev struct dc *dc = (struct dc *)link->dc;
146*b843c749SSergey Zigachev struct dc_link_settings prefer_link_settings;
147*b843c749SSergey Zigachev char *wr_buf = NULL;
148*b843c749SSergey Zigachev char *wr_buf_ptr = NULL;
149*b843c749SSergey Zigachev const uint32_t wr_buf_size = 40;
150*b843c749SSergey Zigachev int r;
151*b843c749SSergey Zigachev int bytes_from_user;
152*b843c749SSergey Zigachev char *sub_str;
153*b843c749SSergey Zigachev /* 0: lane_count; 1: link_rate */
154*b843c749SSergey Zigachev uint8_t param_index = 0;
155*b843c749SSergey Zigachev long param[2];
156*b843c749SSergey Zigachev const char delimiter[3] = {' ', '\n', '\0'};
157*b843c749SSergey Zigachev bool valid_input = false;
158*b843c749SSergey Zigachev
159*b843c749SSergey Zigachev if (size == 0)
160*b843c749SSergey Zigachev return -EINVAL;
161*b843c749SSergey Zigachev
162*b843c749SSergey Zigachev wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
163*b843c749SSergey Zigachev if (!wr_buf)
164*b843c749SSergey Zigachev return -EINVAL;
165*b843c749SSergey Zigachev wr_buf_ptr = wr_buf;
166*b843c749SSergey Zigachev
167*b843c749SSergey Zigachev r = copy_from_user(wr_buf_ptr, buf, wr_buf_size);
168*b843c749SSergey Zigachev
169*b843c749SSergey Zigachev /* r is bytes not be copied */
170*b843c749SSergey Zigachev if (r >= wr_buf_size) {
171*b843c749SSergey Zigachev kfree(wr_buf);
172*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("user data not read\n");
173*b843c749SSergey Zigachev return -EINVAL;
174*b843c749SSergey Zigachev }
175*b843c749SSergey Zigachev
176*b843c749SSergey Zigachev bytes_from_user = wr_buf_size - r;
177*b843c749SSergey Zigachev
178*b843c749SSergey Zigachev while (isspace(*wr_buf_ptr))
179*b843c749SSergey Zigachev wr_buf_ptr++;
180*b843c749SSergey Zigachev
181*b843c749SSergey Zigachev while ((*wr_buf_ptr != '\0') && (param_index < 2)) {
182*b843c749SSergey Zigachev
183*b843c749SSergey Zigachev sub_str = strsep(&wr_buf_ptr, delimiter);
184*b843c749SSergey Zigachev
185*b843c749SSergey Zigachev r = kstrtol(sub_str, 16, ¶m[param_index]);
186*b843c749SSergey Zigachev
187*b843c749SSergey Zigachev if (r)
188*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("string to int convert error code: %d\n", r);
189*b843c749SSergey Zigachev
190*b843c749SSergey Zigachev param_index++;
191*b843c749SSergey Zigachev while (isspace(*wr_buf_ptr))
192*b843c749SSergey Zigachev wr_buf_ptr++;
193*b843c749SSergey Zigachev }
194*b843c749SSergey Zigachev
195*b843c749SSergey Zigachev switch (param[0]) {
196*b843c749SSergey Zigachev case LANE_COUNT_ONE:
197*b843c749SSergey Zigachev case LANE_COUNT_TWO:
198*b843c749SSergey Zigachev case LANE_COUNT_FOUR:
199*b843c749SSergey Zigachev valid_input = true;
200*b843c749SSergey Zigachev break;
201*b843c749SSergey Zigachev default:
202*b843c749SSergey Zigachev break;
203*b843c749SSergey Zigachev }
204*b843c749SSergey Zigachev
205*b843c749SSergey Zigachev switch (param[1]) {
206*b843c749SSergey Zigachev case LINK_RATE_LOW:
207*b843c749SSergey Zigachev case LINK_RATE_HIGH:
208*b843c749SSergey Zigachev case LINK_RATE_RBR2:
209*b843c749SSergey Zigachev case LINK_RATE_HIGH2:
210*b843c749SSergey Zigachev case LINK_RATE_HIGH3:
211*b843c749SSergey Zigachev valid_input = true;
212*b843c749SSergey Zigachev break;
213*b843c749SSergey Zigachev default:
214*b843c749SSergey Zigachev break;
215*b843c749SSergey Zigachev }
216*b843c749SSergey Zigachev
217*b843c749SSergey Zigachev if (!valid_input) {
218*b843c749SSergey Zigachev kfree(wr_buf);
219*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("Invalid Input value No HW will be programmed\n");
220*b843c749SSergey Zigachev return bytes_from_user;
221*b843c749SSergey Zigachev }
222*b843c749SSergey Zigachev
223*b843c749SSergey Zigachev /* save user force lane_count, link_rate to preferred settings
224*b843c749SSergey Zigachev * spread spectrum will not be changed
225*b843c749SSergey Zigachev */
226*b843c749SSergey Zigachev prefer_link_settings.link_spread = link->cur_link_settings.link_spread;
227*b843c749SSergey Zigachev prefer_link_settings.lane_count = param[0];
228*b843c749SSergey Zigachev prefer_link_settings.link_rate = param[1];
229*b843c749SSergey Zigachev
230*b843c749SSergey Zigachev dc_link_set_preferred_link_settings(dc, &prefer_link_settings, link);
231*b843c749SSergey Zigachev
232*b843c749SSergey Zigachev kfree(wr_buf);
233*b843c749SSergey Zigachev return bytes_from_user;
234*b843c749SSergey Zigachev }
235*b843c749SSergey Zigachev
236*b843c749SSergey Zigachev /* function: get current DP PHY settings: voltage swing, pre-emphasis,
237*b843c749SSergey Zigachev * post-cursor2 (defined by VESA DP specification)
238*b843c749SSergey Zigachev *
239*b843c749SSergey Zigachev * valid values
240*b843c749SSergey Zigachev * voltage swing: 0,1,2,3
241*b843c749SSergey Zigachev * pre-emphasis : 0,1,2,3
242*b843c749SSergey Zigachev * post cursor2 : 0,1,2,3
243*b843c749SSergey Zigachev *
244*b843c749SSergey Zigachev *
245*b843c749SSergey Zigachev * how to use this debugfs
246*b843c749SSergey Zigachev *
247*b843c749SSergey Zigachev * debugfs is located at /sys/kernel/debug/dri/0/DP-x
248*b843c749SSergey Zigachev *
249*b843c749SSergey Zigachev * there will be directories, like DP-1, DP-2,DP-3, etc. for DP display
250*b843c749SSergey Zigachev *
251*b843c749SSergey Zigachev * To figure out which DP-x is the display for DP to be check,
252*b843c749SSergey Zigachev * cd DP-x
253*b843c749SSergey Zigachev * ls -ll
254*b843c749SSergey Zigachev * There should be debugfs file, like link_settings, phy_settings.
255*b843c749SSergey Zigachev * cat link_settings
256*b843c749SSergey Zigachev * from lane_count, link_rate to figure which DP-x is for display to be worked
257*b843c749SSergey Zigachev * on
258*b843c749SSergey Zigachev *
259*b843c749SSergey Zigachev * To get current DP PHY settings,
260*b843c749SSergey Zigachev * cat phy_settings
261*b843c749SSergey Zigachev *
262*b843c749SSergey Zigachev * To change DP PHY settings,
263*b843c749SSergey Zigachev * echo <voltage_swing> <pre-emphasis> <post_cursor2> > phy_settings
264*b843c749SSergey Zigachev * for examle, to change voltage swing to 2, pre-emphasis to 3, post_cursor2 to
265*b843c749SSergey Zigachev * 0,
266*b843c749SSergey Zigachev * echo 2 3 0 > phy_settings
267*b843c749SSergey Zigachev *
268*b843c749SSergey Zigachev * To check if change be applied, get current phy settings by
269*b843c749SSergey Zigachev * cat phy_settings
270*b843c749SSergey Zigachev *
271*b843c749SSergey Zigachev * In case invalid values are set by user, like
272*b843c749SSergey Zigachev * echo 1 4 0 > phy_settings
273*b843c749SSergey Zigachev *
274*b843c749SSergey Zigachev * HW will NOT be programmed by these settings.
275*b843c749SSergey Zigachev * cat phy_settings will show the previous valid settings.
276*b843c749SSergey Zigachev */
dp_phy_settings_read(struct file * f,char __user * buf,size_t size,loff_t * pos)277*b843c749SSergey Zigachev static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
278*b843c749SSergey Zigachev size_t size, loff_t *pos)
279*b843c749SSergey Zigachev {
280*b843c749SSergey Zigachev struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
281*b843c749SSergey Zigachev struct dc_link *link = connector->dc_link;
282*b843c749SSergey Zigachev char *rd_buf = NULL;
283*b843c749SSergey Zigachev const uint32_t rd_buf_size = 20;
284*b843c749SSergey Zigachev uint32_t result = 0;
285*b843c749SSergey Zigachev int r;
286*b843c749SSergey Zigachev
287*b843c749SSergey Zigachev if (*pos & 3 || size & 3)
288*b843c749SSergey Zigachev return -EINVAL;
289*b843c749SSergey Zigachev
290*b843c749SSergey Zigachev rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);
291*b843c749SSergey Zigachev if (!rd_buf)
292*b843c749SSergey Zigachev return -EINVAL;
293*b843c749SSergey Zigachev
294*b843c749SSergey Zigachev snprintf(rd_buf, rd_buf_size, " %d %d %d ",
295*b843c749SSergey Zigachev link->cur_lane_setting.VOLTAGE_SWING,
296*b843c749SSergey Zigachev link->cur_lane_setting.PRE_EMPHASIS,
297*b843c749SSergey Zigachev link->cur_lane_setting.POST_CURSOR2);
298*b843c749SSergey Zigachev
299*b843c749SSergey Zigachev while (size) {
300*b843c749SSergey Zigachev if (*pos >= rd_buf_size)
301*b843c749SSergey Zigachev break;
302*b843c749SSergey Zigachev
303*b843c749SSergey Zigachev r = put_user((*(rd_buf + result)), buf);
304*b843c749SSergey Zigachev if (r)
305*b843c749SSergey Zigachev return r; /* r = -EFAULT */
306*b843c749SSergey Zigachev
307*b843c749SSergey Zigachev buf += 1;
308*b843c749SSergey Zigachev size -= 1;
309*b843c749SSergey Zigachev *pos += 1;
310*b843c749SSergey Zigachev result += 1;
311*b843c749SSergey Zigachev }
312*b843c749SSergey Zigachev
313*b843c749SSergey Zigachev kfree(rd_buf);
314*b843c749SSergey Zigachev return result;
315*b843c749SSergey Zigachev }
316*b843c749SSergey Zigachev
dp_phy_settings_write(struct file * f,const char __user * buf,size_t size,loff_t * pos)317*b843c749SSergey Zigachev static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
318*b843c749SSergey Zigachev size_t size, loff_t *pos)
319*b843c749SSergey Zigachev {
320*b843c749SSergey Zigachev struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
321*b843c749SSergey Zigachev struct dc_link *link = connector->dc_link;
322*b843c749SSergey Zigachev struct dc *dc = (struct dc *)link->dc;
323*b843c749SSergey Zigachev char *wr_buf = NULL;
324*b843c749SSergey Zigachev char *wr_buf_ptr = NULL;
325*b843c749SSergey Zigachev uint32_t wr_buf_size = 40;
326*b843c749SSergey Zigachev int r;
327*b843c749SSergey Zigachev int bytes_from_user;
328*b843c749SSergey Zigachev char *sub_str;
329*b843c749SSergey Zigachev uint8_t param_index = 0;
330*b843c749SSergey Zigachev long param[3];
331*b843c749SSergey Zigachev const char delimiter[3] = {' ', '\n', '\0'};
332*b843c749SSergey Zigachev bool use_prefer_link_setting;
333*b843c749SSergey Zigachev struct link_training_settings link_lane_settings;
334*b843c749SSergey Zigachev
335*b843c749SSergey Zigachev if (size == 0)
336*b843c749SSergey Zigachev return 0;
337*b843c749SSergey Zigachev
338*b843c749SSergey Zigachev wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
339*b843c749SSergey Zigachev if (!wr_buf)
340*b843c749SSergey Zigachev return 0;
341*b843c749SSergey Zigachev wr_buf_ptr = wr_buf;
342*b843c749SSergey Zigachev
343*b843c749SSergey Zigachev r = copy_from_user(wr_buf_ptr, buf, wr_buf_size);
344*b843c749SSergey Zigachev
345*b843c749SSergey Zigachev /* r is bytes not be copied */
346*b843c749SSergey Zigachev if (r >= wr_buf_size) {
347*b843c749SSergey Zigachev kfree(wr_buf);
348*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("user data not be read\n");
349*b843c749SSergey Zigachev return 0;
350*b843c749SSergey Zigachev }
351*b843c749SSergey Zigachev
352*b843c749SSergey Zigachev bytes_from_user = wr_buf_size - r;
353*b843c749SSergey Zigachev
354*b843c749SSergey Zigachev while (isspace(*wr_buf_ptr))
355*b843c749SSergey Zigachev wr_buf_ptr++;
356*b843c749SSergey Zigachev
357*b843c749SSergey Zigachev while ((*wr_buf_ptr != '\0') && (param_index < 3)) {
358*b843c749SSergey Zigachev
359*b843c749SSergey Zigachev sub_str = strsep(&wr_buf_ptr, delimiter);
360*b843c749SSergey Zigachev
361*b843c749SSergey Zigachev r = kstrtol(sub_str, 16, ¶m[param_index]);
362*b843c749SSergey Zigachev
363*b843c749SSergey Zigachev if (r)
364*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("string to int convert error code: %d\n", r);
365*b843c749SSergey Zigachev
366*b843c749SSergey Zigachev param_index++;
367*b843c749SSergey Zigachev while (isspace(*wr_buf_ptr))
368*b843c749SSergey Zigachev wr_buf_ptr++;
369*b843c749SSergey Zigachev }
370*b843c749SSergey Zigachev
371*b843c749SSergey Zigachev if ((param[0] > VOLTAGE_SWING_MAX_LEVEL) ||
372*b843c749SSergey Zigachev (param[1] > PRE_EMPHASIS_MAX_LEVEL) ||
373*b843c749SSergey Zigachev (param[2] > POST_CURSOR2_MAX_LEVEL)) {
374*b843c749SSergey Zigachev kfree(wr_buf);
375*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("Invalid Input No HW will be programmed\n");
376*b843c749SSergey Zigachev return bytes_from_user;
377*b843c749SSergey Zigachev }
378*b843c749SSergey Zigachev
379*b843c749SSergey Zigachev /* get link settings: lane count, link rate */
380*b843c749SSergey Zigachev use_prefer_link_setting =
381*b843c749SSergey Zigachev ((link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN) &&
382*b843c749SSergey Zigachev (link->test_pattern_enabled));
383*b843c749SSergey Zigachev
384*b843c749SSergey Zigachev memset(&link_lane_settings, 0, sizeof(link_lane_settings));
385*b843c749SSergey Zigachev
386*b843c749SSergey Zigachev if (use_prefer_link_setting) {
387*b843c749SSergey Zigachev link_lane_settings.link_settings.lane_count =
388*b843c749SSergey Zigachev link->preferred_link_setting.lane_count;
389*b843c749SSergey Zigachev link_lane_settings.link_settings.link_rate =
390*b843c749SSergey Zigachev link->preferred_link_setting.link_rate;
391*b843c749SSergey Zigachev link_lane_settings.link_settings.link_spread =
392*b843c749SSergey Zigachev link->preferred_link_setting.link_spread;
393*b843c749SSergey Zigachev } else {
394*b843c749SSergey Zigachev link_lane_settings.link_settings.lane_count =
395*b843c749SSergey Zigachev link->cur_link_settings.lane_count;
396*b843c749SSergey Zigachev link_lane_settings.link_settings.link_rate =
397*b843c749SSergey Zigachev link->cur_link_settings.link_rate;
398*b843c749SSergey Zigachev link_lane_settings.link_settings.link_spread =
399*b843c749SSergey Zigachev link->cur_link_settings.link_spread;
400*b843c749SSergey Zigachev }
401*b843c749SSergey Zigachev
402*b843c749SSergey Zigachev /* apply phy settings from user */
403*b843c749SSergey Zigachev for (r = 0; r < link_lane_settings.link_settings.lane_count; r++) {
404*b843c749SSergey Zigachev link_lane_settings.lane_settings[r].VOLTAGE_SWING =
405*b843c749SSergey Zigachev (enum dc_voltage_swing) (param[0]);
406*b843c749SSergey Zigachev link_lane_settings.lane_settings[r].PRE_EMPHASIS =
407*b843c749SSergey Zigachev (enum dc_pre_emphasis) (param[1]);
408*b843c749SSergey Zigachev link_lane_settings.lane_settings[r].POST_CURSOR2 =
409*b843c749SSergey Zigachev (enum dc_post_cursor2) (param[2]);
410*b843c749SSergey Zigachev }
411*b843c749SSergey Zigachev
412*b843c749SSergey Zigachev /* program ASIC registers and DPCD registers */
413*b843c749SSergey Zigachev dc_link_set_drive_settings(dc, &link_lane_settings, link);
414*b843c749SSergey Zigachev
415*b843c749SSergey Zigachev kfree(wr_buf);
416*b843c749SSergey Zigachev return bytes_from_user;
417*b843c749SSergey Zigachev }
418*b843c749SSergey Zigachev
419*b843c749SSergey Zigachev /* function description
420*b843c749SSergey Zigachev *
421*b843c749SSergey Zigachev * set PHY layer or Link layer test pattern
422*b843c749SSergey Zigachev * PHY test pattern is used for PHY SI check.
423*b843c749SSergey Zigachev * Link layer test will not affect PHY SI.
424*b843c749SSergey Zigachev *
425*b843c749SSergey Zigachev * Reset Test Pattern:
426*b843c749SSergey Zigachev * 0 = DP_TEST_PATTERN_VIDEO_MODE
427*b843c749SSergey Zigachev *
428*b843c749SSergey Zigachev * PHY test pattern supported:
429*b843c749SSergey Zigachev * 1 = DP_TEST_PATTERN_D102
430*b843c749SSergey Zigachev * 2 = DP_TEST_PATTERN_SYMBOL_ERROR
431*b843c749SSergey Zigachev * 3 = DP_TEST_PATTERN_PRBS7
432*b843c749SSergey Zigachev * 4 = DP_TEST_PATTERN_80BIT_CUSTOM
433*b843c749SSergey Zigachev * 5 = DP_TEST_PATTERN_CP2520_1
434*b843c749SSergey Zigachev * 6 = DP_TEST_PATTERN_CP2520_2 = DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE
435*b843c749SSergey Zigachev * 7 = DP_TEST_PATTERN_CP2520_3
436*b843c749SSergey Zigachev *
437*b843c749SSergey Zigachev * DP PHY Link Training Patterns
438*b843c749SSergey Zigachev * 8 = DP_TEST_PATTERN_TRAINING_PATTERN1
439*b843c749SSergey Zigachev * 9 = DP_TEST_PATTERN_TRAINING_PATTERN2
440*b843c749SSergey Zigachev * a = DP_TEST_PATTERN_TRAINING_PATTERN3
441*b843c749SSergey Zigachev * b = DP_TEST_PATTERN_TRAINING_PATTERN4
442*b843c749SSergey Zigachev *
443*b843c749SSergey Zigachev * DP Link Layer Test pattern
444*b843c749SSergey Zigachev * c = DP_TEST_PATTERN_COLOR_SQUARES
445*b843c749SSergey Zigachev * d = DP_TEST_PATTERN_COLOR_SQUARES_CEA
446*b843c749SSergey Zigachev * e = DP_TEST_PATTERN_VERTICAL_BARS
447*b843c749SSergey Zigachev * f = DP_TEST_PATTERN_HORIZONTAL_BARS
448*b843c749SSergey Zigachev * 10= DP_TEST_PATTERN_COLOR_RAMP
449*b843c749SSergey Zigachev *
450*b843c749SSergey Zigachev * debugfs phy_test_pattern is located at /syskernel/debug/dri/0/DP-x
451*b843c749SSergey Zigachev *
452*b843c749SSergey Zigachev * --- set test pattern
453*b843c749SSergey Zigachev * echo <test pattern #> > test_pattern
454*b843c749SSergey Zigachev *
455*b843c749SSergey Zigachev * If test pattern # is not supported, NO HW programming will be done.
456*b843c749SSergey Zigachev * for DP_TEST_PATTERN_80BIT_CUSTOM, it needs extra 10 bytes of data
457*b843c749SSergey Zigachev * for the user pattern. input 10 bytes data are separated by space
458*b843c749SSergey Zigachev *
459*b843c749SSergey Zigachev * echo 0x4 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 0x99 0xaa > test_pattern
460*b843c749SSergey Zigachev *
461*b843c749SSergey Zigachev * --- reset test pattern
462*b843c749SSergey Zigachev * echo 0 > test_pattern
463*b843c749SSergey Zigachev *
464*b843c749SSergey Zigachev * --- HPD detection is disabled when set PHY test pattern
465*b843c749SSergey Zigachev *
466*b843c749SSergey Zigachev * when PHY test pattern (pattern # within [1,7]) is set, HPD pin of HW ASIC
467*b843c749SSergey Zigachev * is disable. User could unplug DP display from DP connected and plug scope to
468*b843c749SSergey Zigachev * check test pattern PHY SI.
469*b843c749SSergey Zigachev * If there is need unplug scope and plug DP display back, do steps below:
470*b843c749SSergey Zigachev * echo 0 > phy_test_pattern
471*b843c749SSergey Zigachev * unplug scope
472*b843c749SSergey Zigachev * plug DP display.
473*b843c749SSergey Zigachev *
474*b843c749SSergey Zigachev * "echo 0 > phy_test_pattern" will re-enable HPD pin again so that video sw
475*b843c749SSergey Zigachev * driver could detect "unplug scope" and "plug DP display"
476*b843c749SSergey Zigachev */
dp_phy_test_pattern_debugfs_write(struct file * f,const char __user * buf,size_t size,loff_t * pos)477*b843c749SSergey Zigachev static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __user *buf,
478*b843c749SSergey Zigachev size_t size, loff_t *pos)
479*b843c749SSergey Zigachev {
480*b843c749SSergey Zigachev struct amdgpu_dm_connector *connector = file_inode(f)->i_private;
481*b843c749SSergey Zigachev struct dc_link *link = connector->dc_link;
482*b843c749SSergey Zigachev char *wr_buf = NULL;
483*b843c749SSergey Zigachev char *wr_buf_ptr = NULL;
484*b843c749SSergey Zigachev uint32_t wr_buf_size = 100;
485*b843c749SSergey Zigachev uint32_t wr_buf_count = 0;
486*b843c749SSergey Zigachev int r;
487*b843c749SSergey Zigachev int bytes_from_user;
488*b843c749SSergey Zigachev char *sub_str = NULL;
489*b843c749SSergey Zigachev uint8_t param_index = 0;
490*b843c749SSergey Zigachev uint8_t param_nums = 0;
491*b843c749SSergey Zigachev long param[11] = {0x0};
492*b843c749SSergey Zigachev const char delimiter[3] = {' ', '\n', '\0'};
493*b843c749SSergey Zigachev enum dp_test_pattern test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
494*b843c749SSergey Zigachev bool disable_hpd = false;
495*b843c749SSergey Zigachev bool valid_test_pattern = false;
496*b843c749SSergey Zigachev /* init with defalut 80bit custom pattern */
497*b843c749SSergey Zigachev uint8_t custom_pattern[10] = {
498*b843c749SSergey Zigachev 0x1f, 0x7c, 0xf0, 0xc1, 0x07,
499*b843c749SSergey Zigachev 0x1f, 0x7c, 0xf0, 0xc1, 0x07
500*b843c749SSergey Zigachev };
501*b843c749SSergey Zigachev struct dc_link_settings prefer_link_settings = {LANE_COUNT_UNKNOWN,
502*b843c749SSergey Zigachev LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
503*b843c749SSergey Zigachev struct dc_link_settings cur_link_settings = {LANE_COUNT_UNKNOWN,
504*b843c749SSergey Zigachev LINK_RATE_UNKNOWN, LINK_SPREAD_DISABLED};
505*b843c749SSergey Zigachev struct link_training_settings link_training_settings;
506*b843c749SSergey Zigachev int i;
507*b843c749SSergey Zigachev
508*b843c749SSergey Zigachev if (size == 0)
509*b843c749SSergey Zigachev return 0;
510*b843c749SSergey Zigachev
511*b843c749SSergey Zigachev wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
512*b843c749SSergey Zigachev if (!wr_buf)
513*b843c749SSergey Zigachev return 0;
514*b843c749SSergey Zigachev wr_buf_ptr = wr_buf;
515*b843c749SSergey Zigachev
516*b843c749SSergey Zigachev r = copy_from_user(wr_buf_ptr, buf, wr_buf_size);
517*b843c749SSergey Zigachev
518*b843c749SSergey Zigachev /* r is bytes not be copied */
519*b843c749SSergey Zigachev if (r >= wr_buf_size) {
520*b843c749SSergey Zigachev kfree(wr_buf);
521*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("user data not be read\n");
522*b843c749SSergey Zigachev return 0;
523*b843c749SSergey Zigachev }
524*b843c749SSergey Zigachev
525*b843c749SSergey Zigachev bytes_from_user = wr_buf_size - r;
526*b843c749SSergey Zigachev
527*b843c749SSergey Zigachev /* check number of parameters. isspace could not differ space and \n */
528*b843c749SSergey Zigachev while ((*wr_buf_ptr != 0xa) && (wr_buf_count < wr_buf_size)) {
529*b843c749SSergey Zigachev /* skip space*/
530*b843c749SSergey Zigachev while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
531*b843c749SSergey Zigachev wr_buf_ptr++;
532*b843c749SSergey Zigachev wr_buf_count++;
533*b843c749SSergey Zigachev }
534*b843c749SSergey Zigachev
535*b843c749SSergey Zigachev if (wr_buf_count == wr_buf_size)
536*b843c749SSergey Zigachev break;
537*b843c749SSergey Zigachev
538*b843c749SSergey Zigachev /* skip non-space*/
539*b843c749SSergey Zigachev while ((!isspace(*wr_buf_ptr)) && (wr_buf_count < wr_buf_size)) {
540*b843c749SSergey Zigachev wr_buf_ptr++;
541*b843c749SSergey Zigachev wr_buf_count++;
542*b843c749SSergey Zigachev }
543*b843c749SSergey Zigachev
544*b843c749SSergey Zigachev param_nums++;
545*b843c749SSergey Zigachev
546*b843c749SSergey Zigachev if (wr_buf_count == wr_buf_size)
547*b843c749SSergey Zigachev break;
548*b843c749SSergey Zigachev }
549*b843c749SSergey Zigachev
550*b843c749SSergey Zigachev /* max 11 parameters */
551*b843c749SSergey Zigachev if (param_nums > 11)
552*b843c749SSergey Zigachev param_nums = 11;
553*b843c749SSergey Zigachev
554*b843c749SSergey Zigachev wr_buf_ptr = wr_buf; /* reset buf pinter */
555*b843c749SSergey Zigachev wr_buf_count = 0; /* number of char already checked */
556*b843c749SSergey Zigachev
557*b843c749SSergey Zigachev while (isspace(*wr_buf_ptr) && (wr_buf_count < wr_buf_size)) {
558*b843c749SSergey Zigachev wr_buf_ptr++;
559*b843c749SSergey Zigachev wr_buf_count++;
560*b843c749SSergey Zigachev }
561*b843c749SSergey Zigachev
562*b843c749SSergey Zigachev while (param_index < param_nums) {
563*b843c749SSergey Zigachev /* after strsep, wr_buf_ptr will be moved to after space */
564*b843c749SSergey Zigachev sub_str = strsep(&wr_buf_ptr, delimiter);
565*b843c749SSergey Zigachev
566*b843c749SSergey Zigachev r = kstrtol(sub_str, 16, ¶m[param_index]);
567*b843c749SSergey Zigachev
568*b843c749SSergey Zigachev if (r)
569*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("string to int convert error code: %d\n", r);
570*b843c749SSergey Zigachev
571*b843c749SSergey Zigachev param_index++;
572*b843c749SSergey Zigachev }
573*b843c749SSergey Zigachev
574*b843c749SSergey Zigachev test_pattern = param[0];
575*b843c749SSergey Zigachev
576*b843c749SSergey Zigachev switch (test_pattern) {
577*b843c749SSergey Zigachev case DP_TEST_PATTERN_VIDEO_MODE:
578*b843c749SSergey Zigachev case DP_TEST_PATTERN_COLOR_SQUARES:
579*b843c749SSergey Zigachev case DP_TEST_PATTERN_COLOR_SQUARES_CEA:
580*b843c749SSergey Zigachev case DP_TEST_PATTERN_VERTICAL_BARS:
581*b843c749SSergey Zigachev case DP_TEST_PATTERN_HORIZONTAL_BARS:
582*b843c749SSergey Zigachev case DP_TEST_PATTERN_COLOR_RAMP:
583*b843c749SSergey Zigachev valid_test_pattern = true;
584*b843c749SSergey Zigachev break;
585*b843c749SSergey Zigachev
586*b843c749SSergey Zigachev case DP_TEST_PATTERN_D102:
587*b843c749SSergey Zigachev case DP_TEST_PATTERN_SYMBOL_ERROR:
588*b843c749SSergey Zigachev case DP_TEST_PATTERN_PRBS7:
589*b843c749SSergey Zigachev case DP_TEST_PATTERN_80BIT_CUSTOM:
590*b843c749SSergey Zigachev case DP_TEST_PATTERN_HBR2_COMPLIANCE_EYE:
591*b843c749SSergey Zigachev case DP_TEST_PATTERN_TRAINING_PATTERN4:
592*b843c749SSergey Zigachev disable_hpd = true;
593*b843c749SSergey Zigachev valid_test_pattern = true;
594*b843c749SSergey Zigachev break;
595*b843c749SSergey Zigachev
596*b843c749SSergey Zigachev default:
597*b843c749SSergey Zigachev valid_test_pattern = false;
598*b843c749SSergey Zigachev test_pattern = DP_TEST_PATTERN_UNSUPPORTED;
599*b843c749SSergey Zigachev break;
600*b843c749SSergey Zigachev }
601*b843c749SSergey Zigachev
602*b843c749SSergey Zigachev if (!valid_test_pattern) {
603*b843c749SSergey Zigachev kfree(wr_buf);
604*b843c749SSergey Zigachev DRM_DEBUG_DRIVER("Invalid Test Pattern Parameters\n");
605*b843c749SSergey Zigachev return bytes_from_user;
606*b843c749SSergey Zigachev }
607*b843c749SSergey Zigachev
608*b843c749SSergey Zigachev if (test_pattern == DP_TEST_PATTERN_80BIT_CUSTOM) {
609*b843c749SSergey Zigachev for (i = 0; i < 10; i++) {
610*b843c749SSergey Zigachev if ((uint8_t) param[i + 1] != 0x0)
611*b843c749SSergey Zigachev break;
612*b843c749SSergey Zigachev }
613*b843c749SSergey Zigachev
614*b843c749SSergey Zigachev if (i < 10) {
615*b843c749SSergey Zigachev /* not use default value */
616*b843c749SSergey Zigachev for (i = 0; i < 10; i++)
617*b843c749SSergey Zigachev custom_pattern[i] = (uint8_t) param[i + 1];
618*b843c749SSergey Zigachev }
619*b843c749SSergey Zigachev }
620*b843c749SSergey Zigachev
621*b843c749SSergey Zigachev /* Usage: set DP physical test pattern using debugfs with normal DP
622*b843c749SSergey Zigachev * panel. Then plug out DP panel and connect a scope to measure
623*b843c749SSergey Zigachev * For normal video mode and test pattern generated from CRCT,
624*b843c749SSergey Zigachev * they are visibile to user. So do not disable HPD.
625*b843c749SSergey Zigachev * Video Mode is also set to clear the test pattern, so enable HPD
626*b843c749SSergey Zigachev * because it might have been disabled after a test pattern was set.
627*b843c749SSergey Zigachev * AUX depends on HPD * sequence dependent, do not move!
628*b843c749SSergey Zigachev */
629*b843c749SSergey Zigachev if (!disable_hpd)
630*b843c749SSergey Zigachev dc_link_enable_hpd(link);
631*b843c749SSergey Zigachev
632*b843c749SSergey Zigachev prefer_link_settings.lane_count = link->verified_link_cap.lane_count;
633*b843c749SSergey Zigachev prefer_link_settings.link_rate = link->verified_link_cap.link_rate;
634*b843c749SSergey Zigachev prefer_link_settings.link_spread = link->verified_link_cap.link_spread;
635*b843c749SSergey Zigachev
636*b843c749SSergey Zigachev cur_link_settings.lane_count = link->cur_link_settings.lane_count;
637*b843c749SSergey Zigachev cur_link_settings.link_rate = link->cur_link_settings.link_rate;
638*b843c749SSergey Zigachev cur_link_settings.link_spread = link->cur_link_settings.link_spread;
639*b843c749SSergey Zigachev
640*b843c749SSergey Zigachev link_training_settings.link_settings = cur_link_settings;
641*b843c749SSergey Zigachev
642*b843c749SSergey Zigachev
643*b843c749SSergey Zigachev if (test_pattern != DP_TEST_PATTERN_VIDEO_MODE) {
644*b843c749SSergey Zigachev if (prefer_link_settings.lane_count != LANE_COUNT_UNKNOWN &&
645*b843c749SSergey Zigachev prefer_link_settings.link_rate != LINK_RATE_UNKNOWN &&
646*b843c749SSergey Zigachev (prefer_link_settings.lane_count != cur_link_settings.lane_count ||
647*b843c749SSergey Zigachev prefer_link_settings.link_rate != cur_link_settings.link_rate))
648*b843c749SSergey Zigachev link_training_settings.link_settings = prefer_link_settings;
649*b843c749SSergey Zigachev }
650*b843c749SSergey Zigachev
651*b843c749SSergey Zigachev for (i = 0; i < (unsigned int)(link_training_settings.link_settings.lane_count); i++)
652*b843c749SSergey Zigachev link_training_settings.lane_settings[i] = link->cur_lane_setting;
653*b843c749SSergey Zigachev
654*b843c749SSergey Zigachev dc_link_set_test_pattern(
655*b843c749SSergey Zigachev link,
656*b843c749SSergey Zigachev test_pattern,
657*b843c749SSergey Zigachev &link_training_settings,
658*b843c749SSergey Zigachev custom_pattern,
659*b843c749SSergey Zigachev 10);
660*b843c749SSergey Zigachev
661*b843c749SSergey Zigachev /* Usage: Set DP physical test pattern using AMDDP with normal DP panel
662*b843c749SSergey Zigachev * Then plug out DP panel and connect a scope to measure DP PHY signal.
663*b843c749SSergey Zigachev * Need disable interrupt to avoid SW driver disable DP output. This is
664*b843c749SSergey Zigachev * done after the test pattern is set.
665*b843c749SSergey Zigachev */
666*b843c749SSergey Zigachev if (valid_test_pattern && disable_hpd)
667*b843c749SSergey Zigachev dc_link_disable_hpd(link);
668*b843c749SSergey Zigachev
669*b843c749SSergey Zigachev kfree(wr_buf);
670*b843c749SSergey Zigachev
671*b843c749SSergey Zigachev return bytes_from_user;
672*b843c749SSergey Zigachev }
673*b843c749SSergey Zigachev
674*b843c749SSergey Zigachev static const struct file_operations dp_link_settings_debugfs_fops = {
675*b843c749SSergey Zigachev .owner = THIS_MODULE,
676*b843c749SSergey Zigachev .read = dp_link_settings_read,
677*b843c749SSergey Zigachev .write = dp_link_settings_write,
678*b843c749SSergey Zigachev .llseek = default_llseek
679*b843c749SSergey Zigachev };
680*b843c749SSergey Zigachev
681*b843c749SSergey Zigachev static const struct file_operations dp_phy_settings_debugfs_fop = {
682*b843c749SSergey Zigachev .owner = THIS_MODULE,
683*b843c749SSergey Zigachev .read = dp_phy_settings_read,
684*b843c749SSergey Zigachev .write = dp_phy_settings_write,
685*b843c749SSergey Zigachev .llseek = default_llseek
686*b843c749SSergey Zigachev };
687*b843c749SSergey Zigachev
688*b843c749SSergey Zigachev static const struct file_operations dp_phy_test_pattern_fops = {
689*b843c749SSergey Zigachev .owner = THIS_MODULE,
690*b843c749SSergey Zigachev .write = dp_phy_test_pattern_debugfs_write,
691*b843c749SSergey Zigachev .llseek = default_llseek
692*b843c749SSergey Zigachev };
693*b843c749SSergey Zigachev
694*b843c749SSergey Zigachev static const struct {
695*b843c749SSergey Zigachev char *name;
696*b843c749SSergey Zigachev const struct file_operations *fops;
697*b843c749SSergey Zigachev } dp_debugfs_entries[] = {
698*b843c749SSergey Zigachev {"link_settings", &dp_link_settings_debugfs_fops},
699*b843c749SSergey Zigachev {"phy_settings", &dp_phy_settings_debugfs_fop},
700*b843c749SSergey Zigachev {"test_pattern", &dp_phy_test_pattern_fops}
701*b843c749SSergey Zigachev };
702*b843c749SSergey Zigachev
connector_debugfs_init(struct amdgpu_dm_connector * connector)703*b843c749SSergey Zigachev int connector_debugfs_init(struct amdgpu_dm_connector *connector)
704*b843c749SSergey Zigachev {
705*b843c749SSergey Zigachev int i;
706*b843c749SSergey Zigachev struct dentry *ent, *dir = connector->base.debugfs_entry;
707*b843c749SSergey Zigachev
708*b843c749SSergey Zigachev if (connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
709*b843c749SSergey Zigachev for (i = 0; i < ARRAY_SIZE(dp_debugfs_entries); i++) {
710*b843c749SSergey Zigachev ent = debugfs_create_file(dp_debugfs_entries[i].name,
711*b843c749SSergey Zigachev 0644,
712*b843c749SSergey Zigachev dir,
713*b843c749SSergey Zigachev connector,
714*b843c749SSergey Zigachev dp_debugfs_entries[i].fops);
715*b843c749SSergey Zigachev if (IS_ERR(ent))
716*b843c749SSergey Zigachev return PTR_ERR(ent);
717*b843c749SSergey Zigachev }
718*b843c749SSergey Zigachev }
719*b843c749SSergey Zigachev
720*b843c749SSergey Zigachev return 0;
721*b843c749SSergey Zigachev }
722*b843c749SSergey Zigachev
723