1 From 2a77bbf7f6494d4d618fc6ff70b1a21f04cb8a22 Mon Sep 17 00:00:00 2001
2 From: Sandor Yu <Sandor.yu@nxp.com>
3 Date: Wed, 10 Jul 2019 10:50:25 +0800
4 Subject: [PATCH] drm/rockchip: prepare common code for cdns and rk dpi/dp
7 - Extracted common fields from cdn_dp_device to a new cdns_mhdp_device
8 structure which will be used by two separate drivers later on.
9 - Moved some datatypes (audio_format, audio_info,
10 vic_pxl_encoding_format, video_info) from cdn-dp-core.c to cdn-dp-reg.h.
11 - Changed prefixes from cdn_dp to cdns_mhdp cdn -> cdns to match the other Cadence's drivers
12 dp -> mhdp to distinguish it from a "just a DP" as the IP underneath this registers map can be a HDMI (which is
13 internally different, but the interface for commands, events is pretty much the same).
14 - Modified cdn-dp-core.c to use the new driver structure and new function names.
16 Signed-off-by: Damian Kos<dkos@cadence.com>
17 Reviewed-by: Andrzej Hajda<a.hajda@samsung.com>
18 Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
20 drivers/gpu/drm/rockchip/cdn-dp-core.c | 220 +++++++++--------
21 drivers/gpu/drm/rockchip/cdn-dp-core.h | 40 +---
22 drivers/gpu/drm/rockchip/cdn-dp-reg.c | 415 +++++++++++++++++----------------
23 drivers/gpu/drm/rockchip/cdn-dp-reg.h | 114 +++++++--
24 4 files changed, 423 insertions(+), 366 deletions(-)
26 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
27 +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
29 #include <drm/drm_probe_helper.h>
31 #include "cdn-dp-core.h"
32 -#include "cdn-dp-reg.h"
33 #include "rockchip_drm_vop.h"
35 #define connector_to_dp(c) \
36 - container_of(c, struct cdn_dp_device, connector)
37 + container_of(c, struct cdn_dp_device, mhdp.connector)
39 #define encoder_to_dp(c) \
40 container_of(c, struct cdn_dp_device, encoder)
41 @@ -61,17 +60,18 @@ MODULE_DEVICE_TABLE(of, cdn_dp_dt_ids);
42 static int cdn_dp_grf_write(struct cdn_dp_device *dp,
43 unsigned int reg, unsigned int val)
45 + struct device *dev = dp->mhdp.dev;
48 ret = clk_prepare_enable(dp->grf_clk);
50 - DRM_DEV_ERROR(dp->dev, "Failed to prepare_enable grf clock\n");
51 + DRM_DEV_ERROR(dev, "Failed to prepare_enable grf clock\n");
55 ret = regmap_write(dp->grf, reg, val);
57 - DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret);
58 + DRM_DEV_ERROR(dev, "Could not write to GRF: %d\n", ret);
59 clk_disable_unprepare(dp->grf_clk);
62 @@ -83,24 +83,25 @@ static int cdn_dp_grf_write(struct cdn_d
64 static int cdn_dp_clk_enable(struct cdn_dp_device *dp)
66 + struct device *dev = dp->mhdp.dev;
70 ret = clk_prepare_enable(dp->pclk);
72 - DRM_DEV_ERROR(dp->dev, "cannot enable dp pclk %d\n", ret);
73 + DRM_DEV_ERROR(dev, "cannot enable dp pclk %d\n", ret);
77 ret = clk_prepare_enable(dp->core_clk);
79 - DRM_DEV_ERROR(dp->dev, "cannot enable core_clk %d\n", ret);
80 + DRM_DEV_ERROR(dev, "cannot enable core_clk %d\n", ret);
84 - ret = pm_runtime_get_sync(dp->dev);
85 + ret = pm_runtime_get_sync(dev);
87 - DRM_DEV_ERROR(dp->dev, "cannot get pm runtime %d\n", ret);
88 + DRM_DEV_ERROR(dev, "cannot get pm runtime %d\n", ret);
89 goto err_pm_runtime_get;
92 @@ -113,18 +114,18 @@ static int cdn_dp_clk_enable(struct cdn_
94 rate = clk_get_rate(dp->core_clk);
96 - DRM_DEV_ERROR(dp->dev, "get clk rate failed\n");
97 + DRM_DEV_ERROR(dev, "get clk rate failed\n");
102 - cdn_dp_set_fw_clk(dp, rate);
103 - cdn_dp_clock_reset(dp);
104 + cdns_mhdp_set_fw_clk(&dp->mhdp, rate);
105 + cdns_mhdp_clock_reset(&dp->mhdp);
110 - pm_runtime_put(dp->dev);
111 + pm_runtime_put(dev);
113 clk_disable_unprepare(dp->core_clk);
115 @@ -135,7 +136,7 @@ err_pclk:
117 static void cdn_dp_clk_disable(struct cdn_dp_device *dp)
119 - pm_runtime_put_sync(dp->dev);
120 + pm_runtime_put_sync(dp->mhdp.dev);
121 clk_disable_unprepare(dp->pclk);
122 clk_disable_unprepare(dp->core_clk);
124 @@ -168,7 +169,7 @@ static int cdn_dp_get_sink_count(struct
128 - ret = cdn_dp_dpcd_read(dp, DP_SINK_COUNT, &value, 1);
129 + ret = cdns_mhdp_dpcd_read(&dp->mhdp, DP_SINK_COUNT, &value, 1);
133 @@ -192,12 +193,13 @@ static struct cdn_dp_port *cdn_dp_connec
135 static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp)
137 + struct device *dev = dp->mhdp.dev;
138 unsigned long timeout = jiffies + msecs_to_jiffies(CDN_DPCD_TIMEOUT_MS);
139 struct cdn_dp_port *port;
142 if (dp->active_port < 0 || dp->active_port >= dp->ports) {
143 - DRM_DEV_ERROR(dp->dev, "active_port is wrong!\n");
144 + DRM_DEV_ERROR(dev, "active_port is wrong!\n");
148 @@ -219,7 +221,7 @@ static bool cdn_dp_check_sink_connection
149 usleep_range(5000, 10000);
152 - DRM_DEV_ERROR(dp->dev, "Get sink capability timed out\n");
153 + DRM_DEV_ERROR(dev, "Get sink capability timed out\n");
157 @@ -261,7 +263,8 @@ static int cdn_dp_connector_get_modes(st
158 mutex_lock(&dp->lock);
161 - DRM_DEV_DEBUG_KMS(dp->dev, "got edid: width[%d] x height[%d]\n",
162 + DRM_DEV_DEBUG_KMS(dp->mhdp.dev,
163 + "got edid: width[%d] x height[%d]\n",
164 edid->width_cm, edid->height_cm);
166 dp->sink_has_audio = drm_detect_monitor_audio(edid);
167 @@ -279,7 +282,8 @@ static int cdn_dp_connector_mode_valid(s
168 struct drm_display_mode *mode)
170 struct cdn_dp_device *dp = connector_to_dp(connector);
171 - struct drm_display_info *display_info = &dp->connector.display_info;
172 + struct drm_display_info *display_info =
173 + &dp->mhdp.connector.display_info;
174 u32 requested, actual, rate, sink_max, source_max = 0;
177 @@ -305,7 +309,7 @@ static int cdn_dp_connector_mode_valid(s
178 sink_max = drm_dp_max_lane_count(dp->dpcd);
179 lanes = min(source_max, sink_max);
181 - source_max = drm_dp_bw_code_to_link_rate(CDN_DP_MAX_LINK_RATE);
182 + source_max = drm_dp_bw_code_to_link_rate(CDNS_DP_MAX_LINK_RATE);
183 sink_max = drm_dp_max_link_rate(dp->dpcd);
184 rate = min(source_max, sink_max);
186 @@ -315,7 +319,7 @@ static int cdn_dp_connector_mode_valid(s
187 actual = actual * 8 / 10;
189 if (requested > actual) {
190 - DRM_DEV_DEBUG_KMS(dp->dev,
191 + DRM_DEV_DEBUG_KMS(dp->mhdp.dev,
192 "requested=%d, actual=%d, clock=%d\n",
193 requested, actual, mode->clock);
194 return MODE_CLOCK_HIGH;
195 @@ -335,28 +339,29 @@ static int cdn_dp_firmware_init(struct c
196 const u32 *iram_data, *dram_data;
197 const struct firmware *fw = dp->fw;
198 const struct cdn_firmware_header *hdr;
199 + struct device *dev = dp->mhdp.dev;
201 hdr = (struct cdn_firmware_header *)fw->data;
202 if (fw->size != le32_to_cpu(hdr->size_bytes)) {
203 - DRM_DEV_ERROR(dp->dev, "firmware is invalid\n");
204 + DRM_DEV_ERROR(dev, "firmware is invalid\n");
208 iram_data = (const u32 *)(fw->data + hdr->header_size);
209 dram_data = (const u32 *)(fw->data + hdr->header_size + hdr->iram_size);
211 - ret = cdn_dp_load_firmware(dp, iram_data, hdr->iram_size,
212 - dram_data, hdr->dram_size);
213 + ret = cdns_mhdp_load_firmware(&dp->mhdp, iram_data, hdr->iram_size,
214 + dram_data, hdr->dram_size);
218 - ret = cdn_dp_set_firmware_active(dp, true);
219 + ret = cdns_mhdp_set_firmware_active(&dp->mhdp, true);
221 - DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret);
222 + DRM_DEV_ERROR(dev, "active ucpu failed: %d\n", ret);
226 - return cdn_dp_event_config(dp);
227 + return cdns_mhdp_event_config(&dp->mhdp);
230 static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp)
231 @@ -366,28 +371,29 @@ static int cdn_dp_get_sink_capability(st
232 if (!cdn_dp_check_sink_connection(dp))
235 - ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd,
236 - DP_RECEIVER_CAP_SIZE);
237 + ret = cdns_mhdp_dpcd_read(&dp->mhdp, DP_DPCD_REV, dp->dpcd,
238 + DP_RECEIVER_CAP_SIZE);
240 - DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret);
241 + DRM_DEV_ERROR(dp->mhdp.dev, "Failed to get caps %d\n", ret);
246 - dp->edid = drm_do_get_edid(&dp->connector,
247 - cdn_dp_get_edid_block, dp);
248 + dp->edid = drm_do_get_edid(&dp->mhdp.connector,
249 + cdns_mhdp_get_edid_block, &dp->mhdp);
253 static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
255 + struct device *dev = dp->mhdp.dev;
256 union extcon_property_value property;
259 if (!port->phy_enabled) {
260 ret = phy_power_on(port->phy);
262 - DRM_DEV_ERROR(dp->dev, "phy power on failed: %d\n",
263 + DRM_DEV_ERROR(dev, "phy power on failed: %d\n",
267 @@ -397,28 +403,28 @@ static int cdn_dp_enable_phy(struct cdn_
268 ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
269 DPTX_HPD_SEL_MASK | DPTX_HPD_SEL);
271 - DRM_DEV_ERROR(dp->dev, "Failed to write HPD_SEL %d\n", ret);
272 + DRM_DEV_ERROR(dev, "Failed to write HPD_SEL %d\n", ret);
276 - ret = cdn_dp_get_hpd_status(dp);
277 + ret = cdns_mhdp_get_hpd_status(&dp->mhdp);
280 - DRM_DEV_ERROR(dp->dev, "hpd does not exist\n");
281 + DRM_DEV_ERROR(dev, "hpd does not exist\n");
285 ret = extcon_get_property(port->extcon, EXTCON_DISP_DP,
286 EXTCON_PROP_USB_TYPEC_POLARITY, &property);
288 - DRM_DEV_ERROR(dp->dev, "get property failed\n");
289 + DRM_DEV_ERROR(dev, "get property failed\n");
293 port->lanes = cdn_dp_get_port_lanes(port);
294 - ret = cdn_dp_set_host_cap(dp, port->lanes, property.intval);
295 + ret = cdns_mhdp_set_host_cap(&dp->mhdp, port->lanes, property.intval);
297 - DRM_DEV_ERROR(dp->dev, "set host capabilities failed: %d\n",
298 + DRM_DEV_ERROR(dev, "set host capabilities failed: %d\n",
302 @@ -428,7 +434,7 @@ static int cdn_dp_enable_phy(struct cdn_
305 if (phy_power_off(port->phy))
306 - DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret);
307 + DRM_DEV_ERROR(dev, "phy power off failed: %d", ret);
309 port->phy_enabled = false;
311 @@ -446,7 +452,8 @@ static int cdn_dp_disable_phy(struct cdn
312 if (port->phy_enabled) {
313 ret = phy_power_off(port->phy);
315 - DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret);
316 + DRM_DEV_ERROR(dp->mhdp.dev,
317 + "phy power off failed: %d", ret);
321 @@ -470,16 +477,16 @@ static int cdn_dp_disable(struct cdn_dp_
322 ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
323 DPTX_HPD_SEL_MASK | DPTX_HPD_DEL);
325 - DRM_DEV_ERROR(dp->dev, "Failed to clear hpd sel %d\n",
326 + DRM_DEV_ERROR(dp->mhdp.dev, "Failed to clear hpd sel %d\n",
331 - cdn_dp_set_firmware_active(dp, false);
332 + cdns_mhdp_set_firmware_active(&dp->mhdp, false);
333 cdn_dp_clk_disable(dp);
336 - dp->link.num_lanes = 0;
337 + dp->mhdp.link.rate = 0;
338 + dp->mhdp.link.num_lanes = 0;
339 if (!dp->connected) {
342 @@ -492,11 +499,11 @@ static int cdn_dp_enable(struct cdn_dp_d
345 struct cdn_dp_port *port;
346 + struct device *dev = dp->mhdp.dev;
348 port = cdn_dp_connected_port(dp);
350 - DRM_DEV_ERROR(dp->dev,
351 - "Can't enable without connection\n");
352 + DRM_DEV_ERROR(dev, "Can't enable without connection\n");
356 @@ -509,7 +516,7 @@ static int cdn_dp_enable(struct cdn_dp_d
358 ret = cdn_dp_firmware_init(dp);
360 - DRM_DEV_ERROR(dp->dev, "firmware init failed: %d", ret);
361 + DRM_DEV_ERROR(dp->mhdp.dev, "firmware init failed: %d", ret);
362 goto err_clk_disable;
365 @@ -543,8 +550,9 @@ static void cdn_dp_encoder_mode_set(stru
366 struct drm_display_mode *adjusted)
368 struct cdn_dp_device *dp = encoder_to_dp(encoder);
369 - struct drm_display_info *display_info = &dp->connector.display_info;
370 - struct video_info *video = &dp->video_info;
371 + struct drm_display_info *display_info =
372 + &dp->mhdp.connector.display_info;
373 + struct video_info *video = &dp->mhdp.video_info;
375 switch (display_info->bpc) {
377 @@ -562,7 +570,7 @@ static void cdn_dp_encoder_mode_set(stru
378 video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);
379 video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);
381 - memcpy(&dp->mode, adjusted, sizeof(*mode));
382 + memcpy(&dp->mhdp.mode, adjusted, sizeof(*mode));
385 static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
386 @@ -571,11 +579,11 @@ static bool cdn_dp_check_link_status(str
387 struct cdn_dp_port *port = cdn_dp_connected_port(dp);
388 u8 sink_lanes = drm_dp_max_lane_count(dp->dpcd);
390 - if (!port || !dp->link.rate || !dp->link.num_lanes)
391 + if (!port || !dp->mhdp.link.rate || !dp->mhdp.link.num_lanes)
394 - if (cdn_dp_dpcd_read(dp, DP_LANE0_1_STATUS, link_status,
395 - DP_LINK_STATUS_SIZE)) {
396 + if (cdns_mhdp_dpcd_read(&dp->mhdp, DP_LANE0_1_STATUS, link_status,
397 + DP_LINK_STATUS_SIZE)) {
398 DRM_ERROR("Failed to get link status\n");
401 @@ -587,15 +595,16 @@ static bool cdn_dp_check_link_status(str
402 static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
404 struct cdn_dp_device *dp = encoder_to_dp(encoder);
405 + struct device *dev = dp->mhdp.dev;
408 - ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder);
409 + ret = drm_of_encoder_active_endpoint_id(dev->of_node, encoder);
411 - DRM_DEV_ERROR(dp->dev, "Could not get vop id, %d", ret);
412 + DRM_DEV_ERROR(dev, "Could not get vop id, %d", ret);
416 - DRM_DEV_DEBUG_KMS(dp->dev, "vop %s output to cdn-dp\n",
417 + DRM_DEV_DEBUG_KMS(dev, "vop %s output to cdn-dp\n",
418 (ret) ? "LIT" : "BIG");
420 val = DP_SEL_VOP_LIT | (DP_SEL_VOP_LIT << 16);
421 @@ -610,33 +619,33 @@ static void cdn_dp_encoder_enable(struct
423 ret = cdn_dp_enable(dp);
425 - DRM_DEV_ERROR(dp->dev, "Failed to enable encoder %d\n",
426 + DRM_DEV_ERROR(dev, "Failed to enable encoder %d\n",
430 if (!cdn_dp_check_link_status(dp)) {
431 - ret = cdn_dp_train_link(dp);
432 + ret = cdns_mhdp_train_link(&dp->mhdp);
434 - DRM_DEV_ERROR(dp->dev, "Failed link train %d\n", ret);
435 + DRM_DEV_ERROR(dev, "Failed link train %d\n", ret);
440 - ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_IDLE);
441 + ret = cdns_mhdp_set_video_status(&dp->mhdp, CONTROL_VIDEO_IDLE);
443 - DRM_DEV_ERROR(dp->dev, "Failed to idle video %d\n", ret);
444 + DRM_DEV_ERROR(dev, "Failed to idle video %d\n", ret);
448 - ret = cdn_dp_config_video(dp);
449 + ret = cdns_mhdp_config_video(&dp->mhdp);
451 - DRM_DEV_ERROR(dp->dev, "Failed to config video %d\n", ret);
452 + DRM_DEV_ERROR(dev, "Failed to config video %d\n", ret);
456 - ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_VALID);
457 + ret = cdns_mhdp_set_video_status(&dp->mhdp, CONTROL_VIDEO_VALID);
459 - DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret);
460 + DRM_DEV_ERROR(dev, "Failed to valid video %d\n", ret);
464 @@ -652,7 +661,8 @@ static void cdn_dp_encoder_disable(struc
466 ret = cdn_dp_disable(dp);
468 - DRM_DEV_ERROR(dp->dev, "Failed to disable encoder %d\n",
469 + DRM_DEV_ERROR(dp->mhdp.dev,
470 + "Failed to disable encoder %d\n",
474 @@ -696,7 +706,7 @@ static const struct drm_encoder_funcs cd
476 static int cdn_dp_parse_dt(struct cdn_dp_device *dp)
478 - struct device *dev = dp->dev;
479 + struct device *dev = dp->mhdp.dev;
480 struct device_node *np = dev->of_node;
481 struct platform_device *pdev = to_platform_device(dev);
482 struct resource *res;
483 @@ -708,10 +718,10 @@ static int cdn_dp_parse_dt(struct cdn_dp
486 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
487 - dp->regs = devm_ioremap_resource(dev, res);
488 - if (IS_ERR(dp->regs)) {
489 + dp->mhdp.regs = devm_ioremap_resource(dev, res);
490 + if (IS_ERR(dp->mhdp.regs)) {
491 DRM_DEV_ERROR(dev, "ioremap reg failed\n");
492 - return PTR_ERR(dp->regs);
493 + return PTR_ERR(dp->mhdp.regs);
496 dp->core_clk = devm_clk_get(dev, "core-clk");
497 @@ -726,10 +736,10 @@ static int cdn_dp_parse_dt(struct cdn_dp
498 return PTR_ERR(dp->pclk);
501 - dp->spdif_clk = devm_clk_get(dev, "spdif");
502 - if (IS_ERR(dp->spdif_clk)) {
503 + dp->mhdp.spdif_clk = devm_clk_get(dev, "spdif");
504 + if (IS_ERR(dp->mhdp.spdif_clk)) {
505 DRM_DEV_ERROR(dev, "cannot get spdif_clk\n");
506 - return PTR_ERR(dp->spdif_clk);
507 + return PTR_ERR(dp->mhdp.spdif_clk);
510 dp->grf_clk = devm_clk_get(dev, "grf");
511 @@ -738,10 +748,10 @@ static int cdn_dp_parse_dt(struct cdn_dp
512 return PTR_ERR(dp->grf_clk);
515 - dp->spdif_rst = devm_reset_control_get(dev, "spdif");
516 - if (IS_ERR(dp->spdif_rst)) {
517 + dp->mhdp.spdif_rst = devm_reset_control_get(dev, "spdif");
518 + if (IS_ERR(dp->mhdp.spdif_rst)) {
519 DRM_DEV_ERROR(dev, "no spdif reset control found\n");
520 - return PTR_ERR(dp->spdif_rst);
521 + return PTR_ERR(dp->mhdp.spdif_rst);
524 dp->dptx_rst = devm_reset_control_get(dev, "dptx");
525 @@ -796,7 +806,7 @@ static int cdn_dp_audio_hw_params(struct
529 - ret = cdn_dp_audio_config(dp, &audio);
530 + ret = cdns_mhdp_audio_config(&dp->mhdp, &audio);
532 dp->audio_info = audio;
534 @@ -814,7 +824,7 @@ static void cdn_dp_audio_shutdown(struct
538 - ret = cdn_dp_audio_stop(dp, &dp->audio_info);
539 + ret = cdns_mhdp_audio_stop(&dp->mhdp, &dp->audio_info);
541 dp->audio_info.format = AFMT_UNUSED;
543 @@ -833,7 +843,7 @@ static int cdn_dp_audio_digital_mute(str
547 - ret = cdn_dp_audio_mute(dp, enable);
548 + ret = cdns_mhdp_audio_mute(&dp->mhdp, enable);
551 mutex_unlock(&dp->lock);
552 @@ -845,7 +855,8 @@ static int cdn_dp_audio_get_eld(struct d
554 struct cdn_dp_device *dp = dev_get_drvdata(dev);
556 - memcpy(buf, dp->connector.eld, min(sizeof(dp->connector.eld), len));
557 + memcpy(buf, dp->mhdp.connector.eld,
558 + min(sizeof(dp->mhdp.connector.eld), len));
562 @@ -879,6 +890,7 @@ static int cdn_dp_request_firmware(struc
564 unsigned long timeout = jiffies + msecs_to_jiffies(CDN_FW_TIMEOUT_MS);
565 unsigned long sleep = 1000;
566 + struct device *dev = dp->mhdp.dev;
568 WARN_ON(!mutex_is_locked(&dp->lock));
570 @@ -889,13 +901,13 @@ static int cdn_dp_request_firmware(struc
571 mutex_unlock(&dp->lock);
573 while (time_before(jiffies, timeout)) {
574 - ret = request_firmware(&dp->fw, CDN_DP_FIRMWARE, dp->dev);
575 + ret = request_firmware(&dp->fw, CDN_DP_FIRMWARE, dev);
576 if (ret == -ENOENT) {
581 - DRM_DEV_ERROR(dp->dev,
583 "failed to request firmware: %d\n", ret);
586 @@ -905,7 +917,7 @@ static int cdn_dp_request_firmware(struc
590 - DRM_DEV_ERROR(dp->dev, "Timed out trying to load firmware\n");
591 + DRM_DEV_ERROR(dev, "Timed out trying to load firmware\n");
594 mutex_lock(&dp->lock);
595 @@ -916,8 +928,9 @@ static void cdn_dp_pd_event_work(struct
597 struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device,
599 - struct drm_connector *connector = &dp->connector;
600 + struct drm_connector *connector = &dp->mhdp.connector;
601 enum drm_connector_status old_status;
602 + struct device *dev = dp->mhdp.dev;
606 @@ -934,44 +947,45 @@ static void cdn_dp_pd_event_work(struct
608 /* Not connected, notify userspace to disable the block */
609 if (!cdn_dp_connected_port(dp)) {
610 - DRM_DEV_INFO(dp->dev, "Not connected. Disabling cdn\n");
611 + DRM_DEV_INFO(dev, "Not connected. Disabling cdn\n");
612 dp->connected = false;
614 /* Connected but not enabled, enable the block */
615 } else if (!dp->active) {
616 - DRM_DEV_INFO(dp->dev, "Connected, not enabled. Enabling cdn\n");
617 + DRM_DEV_INFO(dev, "Connected, not enabled. Enabling cdn\n");
618 ret = cdn_dp_enable(dp);
620 - DRM_DEV_ERROR(dp->dev, "Enable dp failed %d\n", ret);
621 + DRM_DEV_ERROR(dev, "Enable dp failed %d\n", ret);
622 dp->connected = false;
625 /* Enabled and connected to a dongle without a sink, notify userspace */
626 } else if (!cdn_dp_check_sink_connection(dp)) {
627 - DRM_DEV_INFO(dp->dev, "Connected without sink. Assert hpd\n");
628 + DRM_DEV_INFO(dev, "Connected without sink. Assert hpd\n");
629 dp->connected = false;
631 /* Enabled and connected with a sink, re-train if requested */
632 } else if (!cdn_dp_check_link_status(dp)) {
633 - unsigned int rate = dp->link.rate;
634 - unsigned int lanes = dp->link.num_lanes;
635 - struct drm_display_mode *mode = &dp->mode;
636 + unsigned int rate = dp->mhdp.link.rate;
637 + unsigned int lanes = dp->mhdp.link.num_lanes;
638 + struct drm_display_mode *mode = &dp->mhdp.mode;
640 - DRM_DEV_INFO(dp->dev, "Connected with sink. Re-train link\n");
641 - ret = cdn_dp_train_link(dp);
642 + DRM_DEV_INFO(dev, "Connected with sink. Re-train link\n");
643 + ret = cdns_mhdp_train_link(&dp->mhdp);
645 dp->connected = false;
646 - DRM_DEV_ERROR(dp->dev, "Train link failed %d\n", ret);
647 + DRM_DEV_ERROR(dev, "Train link failed %d\n", ret);
651 /* If training result is changed, update the video config */
653 - (rate != dp->link.rate || lanes != dp->link.num_lanes)) {
654 - ret = cdn_dp_config_video(dp);
655 + (rate != dp->mhdp.link.rate ||
656 + lanes != dp->mhdp.link.num_lanes)) {
657 + ret = cdns_mhdp_config_video(&dp->mhdp);
659 dp->connected = false;
660 - DRM_DEV_ERROR(dp->dev,
662 "Failed to config video %d\n",
665 @@ -1040,7 +1054,7 @@ static int cdn_dp_bind(struct device *de
667 drm_encoder_helper_add(encoder, &cdn_dp_encoder_helper_funcs);
669 - connector = &dp->connector;
670 + connector = &dp->mhdp.connector;
671 connector->polled = DRM_CONNECTOR_POLL_HPD;
672 connector->dpms = DRM_MODE_DPMS_OFF;
674 @@ -1064,7 +1078,7 @@ static int cdn_dp_bind(struct device *de
677 port->event_nb.notifier_call = cdn_dp_pd_event;
678 - ret = devm_extcon_register_notifier(dp->dev, port->extcon,
679 + ret = devm_extcon_register_notifier(dp->mhdp.dev, port->extcon,
683 @@ -1091,7 +1105,7 @@ static void cdn_dp_unbind(struct device
685 struct cdn_dp_device *dp = dev_get_drvdata(dev);
686 struct drm_encoder *encoder = &dp->encoder;
687 - struct drm_connector *connector = &dp->connector;
688 + struct drm_connector *connector = &dp->mhdp.connector;
690 cancel_work_sync(&dp->event_work);
691 cdn_dp_encoder_disable(encoder);
692 @@ -1151,7 +1165,7 @@ static int cdn_dp_probe(struct platform_
693 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL);
697 + dp->mhdp.dev = dev;
699 match = of_match_node(cdn_dp_dt_ids, pdev->dev.of_node);
700 dp_data = (struct cdn_dp_data *)match->data;
701 @@ -1196,7 +1210,7 @@ static int cdn_dp_remove(struct platform
702 struct cdn_dp_device *dp = platform_get_drvdata(pdev);
704 platform_device_unregister(dp->audio_pdev);
705 - cdn_dp_suspend(dp->dev);
706 + cdn_dp_suspend(dp->mhdp.dev);
707 component_del(&pdev->dev, &cdn_dp_component_ops);
710 @@ -1206,7 +1220,7 @@ static void cdn_dp_shutdown(struct platf
712 struct cdn_dp_device *dp = platform_get_drvdata(pdev);
714 - cdn_dp_suspend(dp->dev);
715 + cdn_dp_suspend(dp->mhdp.dev);
718 static const struct dev_pm_ops cdn_dp_pm_ops = {
719 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.h
720 +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.h
722 #include <drm/drm_probe_helper.h>
724 #include "rockchip_drm_drv.h"
725 +#include "cdn-dp-reg.h"
736 - enum audio_format format;
742 -enum vic_pxl_encoding_format {
751 - bool h_sync_polarity;
752 - bool v_sync_polarity;
755 - enum vic_pxl_encoding_format color_fmt;
758 struct cdn_firmware_header {
759 u32 size_bytes; /* size of the entire header+image(s) in bytes */
760 u32 header_size; /* size of just the header in bytes */
761 @@ -62,11 +34,9 @@ struct cdn_dp_port {
764 struct cdn_dp_device {
765 - struct device *dev;
766 + struct cdns_mhdp_device mhdp;
767 struct drm_device *drm_dev;
768 - struct drm_connector connector;
769 struct drm_encoder encoder;
770 - struct drm_display_mode mode;
771 struct platform_device *audio_pdev;
772 struct work_struct event_work;
774 @@ -77,22 +47,16 @@ struct cdn_dp_device {
777 const struct firmware *fw; /* cdn dp firmware */
778 - unsigned int fw_version; /* cdn fw version */
781 - void __iomem *regs;
783 struct clk *core_clk;
785 - struct clk *spdif_clk;
787 - struct reset_control *spdif_rst;
788 struct reset_control *dptx_rst;
789 struct reset_control *apb_rst;
790 struct reset_control *core_rst;
791 struct audio_info audio_info;
792 - struct video_info video_info;
793 - struct drm_dp_link link;
794 struct cdn_dp_port *port[MAX_PHY];
797 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.c
798 +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.c
800 #include "cdn-dp-core.h"
801 #include "cdn-dp-reg.h"
803 -#define CDN_DP_SPDIF_CLK 200000000
804 +#define CDNS_DP_SPDIF_CLK 200000000
805 #define FW_ALIVE_TIMEOUT_US 1000000
806 #define MAILBOX_RETRY_US 1000
807 #define MAILBOX_TIMEOUT_US 5000000
808 #define LINK_TRAINING_RETRY_MS 20
809 #define LINK_TRAINING_TIMEOUT_MS 500
811 -void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk)
812 +void cdns_mhdp_set_fw_clk(struct cdns_mhdp_device *mhdp, unsigned long clk)
814 - writel(clk / 1000000, dp->regs + SW_CLK_H);
815 + writel(clk / 1000000, mhdp->regs + SW_CLK_H);
818 -void cdn_dp_clock_reset(struct cdn_dp_device *dp)
819 +void cdns_mhdp_clock_reset(struct cdns_mhdp_device *mhdp)
823 @@ -42,16 +42,16 @@ void cdn_dp_clock_reset(struct cdn_dp_de
825 CFG_DPTX_VIF_CLK_RSTN_EN |
827 - writel(val, dp->regs + SOURCE_DPTX_CAR);
828 + writel(val, mhdp->regs + SOURCE_DPTX_CAR);
830 val = SOURCE_PHY_RSTN_EN | SOURCE_PHY_CLK_EN;
831 - writel(val, dp->regs + SOURCE_PHY_CAR);
832 + writel(val, mhdp->regs + SOURCE_PHY_CAR);
834 val = SOURCE_PKT_SYS_RSTN_EN |
835 SOURCE_PKT_SYS_CLK_EN |
836 SOURCE_PKT_DATA_RSTN_EN |
837 SOURCE_PKT_DATA_CLK_EN;
838 - writel(val, dp->regs + SOURCE_PKT_CAR);
839 + writel(val, mhdp->regs + SOURCE_PKT_CAR);
841 val = SPDIF_CDR_CLK_RSTN_EN |
843 @@ -59,53 +59,53 @@ void cdn_dp_clock_reset(struct cdn_dp_de
844 SOURCE_AIF_SYS_CLK_EN |
845 SOURCE_AIF_CLK_RSTN_EN |
847 - writel(val, dp->regs + SOURCE_AIF_CAR);
848 + writel(val, mhdp->regs + SOURCE_AIF_CAR);
850 val = SOURCE_CIPHER_SYSTEM_CLK_RSTN_EN |
851 SOURCE_CIPHER_SYS_CLK_EN |
852 SOURCE_CIPHER_CHAR_CLK_RSTN_EN |
853 SOURCE_CIPHER_CHAR_CLK_EN;
854 - writel(val, dp->regs + SOURCE_CIPHER_CAR);
855 + writel(val, mhdp->regs + SOURCE_CIPHER_CAR);
857 val = SOURCE_CRYPTO_SYS_CLK_RSTN_EN |
858 SOURCE_CRYPTO_SYS_CLK_EN;
859 - writel(val, dp->regs + SOURCE_CRYPTO_CAR);
860 + writel(val, mhdp->regs + SOURCE_CRYPTO_CAR);
862 /* enable Mailbox and PIF interrupt */
863 - writel(0, dp->regs + APB_INT_MASK);
864 + writel(0, mhdp->regs + APB_INT_MASK);
867 -static int cdn_dp_mailbox_read(struct cdn_dp_device *dp)
868 +static int cdns_mhdp_mailbox_read(struct cdns_mhdp_device *mhdp)
872 - ret = readx_poll_timeout(readl, dp->regs + MAILBOX_EMPTY_ADDR,
873 + ret = readx_poll_timeout(readl, mhdp->regs + MAILBOX_EMPTY_ADDR,
874 val, !val, MAILBOX_RETRY_US,
879 - return readl(dp->regs + MAILBOX0_RD_DATA) & 0xff;
880 + return readl(mhdp->regs + MAILBOX0_RD_DATA) & 0xff;
883 -static int cdp_dp_mailbox_write(struct cdn_dp_device *dp, u8 val)
884 +static int cdp_dp_mailbox_write(struct cdns_mhdp_device *mhdp, u8 val)
888 - ret = readx_poll_timeout(readl, dp->regs + MAILBOX_FULL_ADDR,
889 + ret = readx_poll_timeout(readl, mhdp->regs + MAILBOX_FULL_ADDR,
890 full, !full, MAILBOX_RETRY_US,
895 - writel(val, dp->regs + MAILBOX0_WR_DATA);
896 + writel(val, mhdp->regs + MAILBOX0_WR_DATA);
901 -static int cdn_dp_mailbox_validate_receive(struct cdn_dp_device *dp,
902 - u8 module_id, u8 opcode,
904 +static int cdns_mhdp_mailbox_validate_receive(struct cdns_mhdp_device *mhdp,
905 + u8 module_id, u8 opcode,
910 @@ -113,7 +113,7 @@ static int cdn_dp_mailbox_validate_recei
912 /* read the header of the message */
913 for (i = 0; i < 4; i++) {
914 - ret = cdn_dp_mailbox_read(dp);
915 + ret = cdns_mhdp_mailbox_read(mhdp);
919 @@ -129,7 +129,7 @@ static int cdn_dp_mailbox_validate_recei
920 * clear the mailbox by reading its contents.
922 for (i = 0; i < mbox_size; i++)
923 - if (cdn_dp_mailbox_read(dp) < 0)
924 + if (cdns_mhdp_mailbox_read(mhdp) < 0)
928 @@ -138,14 +138,14 @@ static int cdn_dp_mailbox_validate_recei
932 -static int cdn_dp_mailbox_read_receive(struct cdn_dp_device *dp,
933 - u8 *buff, u16 buff_size)
934 +static int cdns_mhdp_mailbox_read_receive(struct cdns_mhdp_device *mhdp,
935 + u8 *buff, u16 buff_size)
940 for (i = 0; i < buff_size; i++) {
941 - ret = cdn_dp_mailbox_read(dp);
942 + ret = cdns_mhdp_mailbox_read(mhdp);
946 @@ -155,8 +155,8 @@ static int cdn_dp_mailbox_read_receive(s
950 -static int cdn_dp_mailbox_send(struct cdn_dp_device *dp, u8 module_id,
951 - u8 opcode, u16 size, u8 *message)
952 +static int cdns_mhdp_mailbox_send(struct cdns_mhdp_device *mhdp, u8 module_id,
953 + u8 opcode, u16 size, u8 *message)
957 @@ -167,13 +167,13 @@ static int cdn_dp_mailbox_send(struct cd
958 header[3] = size & 0xff;
960 for (i = 0; i < 4; i++) {
961 - ret = cdp_dp_mailbox_write(dp, header[i]);
962 + ret = cdp_dp_mailbox_write(mhdp, header[i]);
967 for (i = 0; i < size; i++) {
968 - ret = cdp_dp_mailbox_write(dp, message[i]);
969 + ret = cdp_dp_mailbox_write(mhdp, message[i]);
973 @@ -181,7 +181,7 @@ static int cdn_dp_mailbox_send(struct cd
977 -static int cdn_dp_reg_write(struct cdn_dp_device *dp, u16 addr, u32 val)
978 +static int cdns_mhdp_reg_write(struct cdns_mhdp_device *mhdp, u16 addr, u32 val)
982 @@ -191,12 +191,12 @@ static int cdn_dp_reg_write(struct cdn_d
983 msg[3] = (val >> 16) & 0xff;
984 msg[4] = (val >> 8) & 0xff;
986 - return cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_WRITE_REGISTER,
988 + return cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
989 + DPTX_WRITE_REGISTER, sizeof(msg), msg);
992 -static int cdn_dp_reg_write_bit(struct cdn_dp_device *dp, u16 addr,
993 - u8 start_bit, u8 bits_no, u32 val)
994 +static int cdns_mhdp_reg_write_bit(struct cdns_mhdp_device *mhdp, u16 addr,
995 + u8 start_bit, u8 bits_no, u32 val)
999 @@ -209,11 +209,12 @@ static int cdn_dp_reg_write_bit(struct c
1000 field[6] = (val >> 8) & 0xff;
1001 field[7] = val & 0xff;
1003 - return cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_WRITE_FIELD,
1004 - sizeof(field), field);
1005 + return cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1006 + DPTX_WRITE_FIELD, sizeof(field), field);
1009 -int cdn_dp_dpcd_read(struct cdn_dp_device *dp, u32 addr, u8 *data, u16 len)
1010 +int cdns_mhdp_dpcd_read(struct cdns_mhdp_device *mhdp,
1011 + u32 addr, u8 *data, u16 len)
1015 @@ -223,28 +224,28 @@ int cdn_dp_dpcd_read(struct cdn_dp_devic
1016 msg[2] = (addr >> 16) & 0xff;
1017 msg[3] = (addr >> 8) & 0xff;
1018 msg[4] = addr & 0xff;
1019 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_READ_DPCD,
1020 - sizeof(msg), msg);
1021 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1022 + DPTX_READ_DPCD, sizeof(msg), msg);
1026 - ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX,
1028 - sizeof(reg) + len);
1029 + ret = cdns_mhdp_mailbox_validate_receive(mhdp, MB_MODULE_ID_DP_TX,
1031 + sizeof(reg) + len);
1035 - ret = cdn_dp_mailbox_read_receive(dp, reg, sizeof(reg));
1036 + ret = cdns_mhdp_mailbox_read_receive(mhdp, reg, sizeof(reg));
1040 - ret = cdn_dp_mailbox_read_receive(dp, data, len);
1041 + ret = cdns_mhdp_mailbox_read_receive(mhdp, data, len);
1047 -int cdn_dp_dpcd_write(struct cdn_dp_device *dp, u32 addr, u8 value)
1048 +int cdns_mhdp_dpcd_write(struct cdns_mhdp_device *mhdp, u32 addr, u8 value)
1052 @@ -255,17 +256,17 @@ int cdn_dp_dpcd_write(struct cdn_dp_devi
1053 msg[3] = (addr >> 8) & 0xff;
1054 msg[4] = addr & 0xff;
1056 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_WRITE_DPCD,
1057 - sizeof(msg), msg);
1058 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1059 + DPTX_WRITE_DPCD, sizeof(msg), msg);
1061 goto err_dpcd_write;
1063 - ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX,
1064 - DPTX_WRITE_DPCD, sizeof(reg));
1065 + ret = cdns_mhdp_mailbox_validate_receive(mhdp, MB_MODULE_ID_DP_TX,
1066 + DPTX_WRITE_DPCD, sizeof(reg));
1068 goto err_dpcd_write;
1070 - ret = cdn_dp_mailbox_read_receive(dp, reg, sizeof(reg));
1071 + ret = cdns_mhdp_mailbox_read_receive(mhdp, reg, sizeof(reg));
1073 goto err_dpcd_write;
1075 @@ -274,53 +275,53 @@ int cdn_dp_dpcd_write(struct cdn_dp_devi
1079 - DRM_DEV_ERROR(dp->dev, "dpcd write failed: %d\n", ret);
1080 + DRM_DEV_ERROR(mhdp->dev, "dpcd write failed: %d\n", ret);
1084 -int cdn_dp_load_firmware(struct cdn_dp_device *dp, const u32 *i_mem,
1085 - u32 i_size, const u32 *d_mem, u32 d_size)
1086 +int cdns_mhdp_load_firmware(struct cdns_mhdp_device *mhdp, const u32 *i_mem,
1087 + u32 i_size, const u32 *d_mem, u32 d_size)
1092 /* reset ucpu before load firmware*/
1093 writel(APB_IRAM_PATH | APB_DRAM_PATH | APB_XT_RESET,
1094 - dp->regs + APB_CTRL);
1095 + mhdp->regs + APB_CTRL);
1097 for (i = 0; i < i_size; i += 4)
1098 - writel(*i_mem++, dp->regs + ADDR_IMEM + i);
1099 + writel(*i_mem++, mhdp->regs + ADDR_IMEM + i);
1101 for (i = 0; i < d_size; i += 4)
1102 - writel(*d_mem++, dp->regs + ADDR_DMEM + i);
1103 + writel(*d_mem++, mhdp->regs + ADDR_DMEM + i);
1106 - writel(0, dp->regs + APB_CTRL);
1107 + writel(0, mhdp->regs + APB_CTRL);
1109 /* check the keep alive register to make sure fw working */
1110 - ret = readx_poll_timeout(readl, dp->regs + KEEP_ALIVE,
1111 + ret = readx_poll_timeout(readl, mhdp->regs + KEEP_ALIVE,
1112 reg, reg, 2000, FW_ALIVE_TIMEOUT_US);
1114 - DRM_DEV_ERROR(dp->dev, "failed to loaded the FW reg = %x\n",
1115 + DRM_DEV_ERROR(mhdp->dev, "failed to loaded the FW reg = %x\n",
1120 - reg = readl(dp->regs + VER_L) & 0xff;
1121 - dp->fw_version = reg;
1122 - reg = readl(dp->regs + VER_H) & 0xff;
1123 - dp->fw_version |= reg << 8;
1124 - reg = readl(dp->regs + VER_LIB_L_ADDR) & 0xff;
1125 - dp->fw_version |= reg << 16;
1126 - reg = readl(dp->regs + VER_LIB_H_ADDR) & 0xff;
1127 - dp->fw_version |= reg << 24;
1128 + reg = readl(mhdp->regs + VER_L) & 0xff;
1129 + mhdp->fw_version = reg;
1130 + reg = readl(mhdp->regs + VER_H) & 0xff;
1131 + mhdp->fw_version |= reg << 8;
1132 + reg = readl(mhdp->regs + VER_LIB_L_ADDR) & 0xff;
1133 + mhdp->fw_version |= reg << 16;
1134 + reg = readl(mhdp->regs + VER_LIB_H_ADDR) & 0xff;
1135 + mhdp->fw_version |= reg << 24;
1137 - DRM_DEV_DEBUG(dp->dev, "firmware version: %x\n", dp->fw_version);
1138 + DRM_DEV_DEBUG(mhdp->dev, "firmware version: %x\n", mhdp->fw_version);
1143 -int cdn_dp_set_firmware_active(struct cdn_dp_device *dp, bool enable)
1144 +int cdns_mhdp_set_firmware_active(struct cdns_mhdp_device *mhdp, bool enable)
1148 @@ -332,14 +333,14 @@ int cdn_dp_set_firmware_active(struct cd
1149 msg[4] = enable ? FW_ACTIVE : FW_STANDBY;
1151 for (i = 0; i < sizeof(msg); i++) {
1152 - ret = cdp_dp_mailbox_write(dp, msg[i]);
1153 + ret = cdp_dp_mailbox_write(mhdp, msg[i]);
1155 goto err_set_firmware_active;
1158 /* read the firmware state */
1159 for (i = 0; i < sizeof(msg); i++) {
1160 - ret = cdn_dp_mailbox_read(dp);
1161 + ret = cdns_mhdp_mailbox_read(mhdp);
1163 goto err_set_firmware_active;
1165 @@ -350,16 +351,16 @@ int cdn_dp_set_firmware_active(struct cd
1167 err_set_firmware_active:
1169 - DRM_DEV_ERROR(dp->dev, "set firmware active failed\n");
1170 + DRM_DEV_ERROR(mhdp->dev, "set firmware active failed\n");
1174 -int cdn_dp_set_host_cap(struct cdn_dp_device *dp, u8 lanes, bool flip)
1175 +int cdns_mhdp_set_host_cap(struct cdns_mhdp_device *mhdp, u8 lanes, bool flip)
1180 - msg[0] = CDN_DP_MAX_LINK_RATE;
1181 + msg[0] = CDNS_DP_MAX_LINK_RATE;
1182 msg[1] = lanes | SCRAMBLER_EN;
1183 msg[2] = VOLTAGE_LEVEL_2;
1184 msg[3] = PRE_EMPHASIS_LEVEL_3;
1185 @@ -368,22 +369,22 @@ int cdn_dp_set_host_cap(struct cdn_dp_de
1186 msg[6] = flip ? LANE_MAPPING_FLIPPED : LANE_MAPPING_NORMAL;
1189 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX,
1190 - DPTX_SET_HOST_CAPABILITIES,
1191 - sizeof(msg), msg);
1192 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1193 + DPTX_SET_HOST_CAPABILITIES,
1194 + sizeof(msg), msg);
1196 goto err_set_host_cap;
1198 - ret = cdn_dp_reg_write(dp, DP_AUX_SWAP_INVERSION_CONTROL,
1200 + ret = cdns_mhdp_reg_write(mhdp, DP_AUX_SWAP_INVERSION_CONTROL,
1205 - DRM_DEV_ERROR(dp->dev, "set host cap failed: %d\n", ret);
1206 + DRM_DEV_ERROR(mhdp->dev, "set host cap failed: %d\n", ret);
1210 -int cdn_dp_event_config(struct cdn_dp_device *dp)
1211 +int cdns_mhdp_event_config(struct cdns_mhdp_device *mhdp)
1215 @@ -392,49 +393,50 @@ int cdn_dp_event_config(struct cdn_dp_de
1217 msg[0] = DPTX_EVENT_ENABLE_HPD | DPTX_EVENT_ENABLE_TRAINING;
1219 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_ENABLE_EVENT,
1220 - sizeof(msg), msg);
1221 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1222 + DPTX_ENABLE_EVENT, sizeof(msg), msg);
1224 - DRM_DEV_ERROR(dp->dev, "set event config failed: %d\n", ret);
1225 + DRM_DEV_ERROR(mhdp->dev, "set event config failed: %d\n", ret);
1230 -u32 cdn_dp_get_event(struct cdn_dp_device *dp)
1231 +u32 cdns_mhdp_get_event(struct cdns_mhdp_device *mhdp)
1233 - return readl(dp->regs + SW_EVENTS0);
1234 + return readl(mhdp->regs + SW_EVENTS0);
1237 -int cdn_dp_get_hpd_status(struct cdn_dp_device *dp)
1238 +int cdns_mhdp_get_hpd_status(struct cdns_mhdp_device *mhdp)
1243 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_HPD_STATE,
1245 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1246 + DPTX_HPD_STATE, 0, NULL);
1250 - ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX,
1251 - DPTX_HPD_STATE, sizeof(status));
1252 + ret = cdns_mhdp_mailbox_validate_receive(mhdp, MB_MODULE_ID_DP_TX,
1258 - ret = cdn_dp_mailbox_read_receive(dp, &status, sizeof(status));
1259 + ret = cdns_mhdp_mailbox_read_receive(mhdp, &status, sizeof(status));
1266 - DRM_DEV_ERROR(dp->dev, "get hpd status failed: %d\n", ret);
1267 + DRM_DEV_ERROR(mhdp->dev, "get hpd status failed: %d\n", ret);
1271 -int cdn_dp_get_edid_block(void *data, u8 *edid,
1272 +int cdns_mhdp_get_edid_block(void *data, u8 *edid,
1273 unsigned int block, size_t length)
1275 - struct cdn_dp_device *dp = data;
1276 + struct cdns_mhdp_device *mhdp = data;
1277 u8 msg[2], reg[2], i;
1280 @@ -442,22 +444,23 @@ int cdn_dp_get_edid_block(void *data, u8
1284 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_GET_EDID,
1285 - sizeof(msg), msg);
1286 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1287 + DPTX_GET_EDID, sizeof(msg), msg);
1291 - ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX,
1293 - sizeof(reg) + length);
1294 + ret = cdns_mhdp_mailbox_validate_receive(mhdp,
1295 + MB_MODULE_ID_DP_TX,
1297 + sizeof(reg) + length);
1301 - ret = cdn_dp_mailbox_read_receive(dp, reg, sizeof(reg));
1302 + ret = cdns_mhdp_mailbox_read_receive(mhdp, reg, sizeof(reg));
1306 - ret = cdn_dp_mailbox_read_receive(dp, edid, length);
1307 + ret = cdns_mhdp_mailbox_read_receive(mhdp, edid, length);
1311 @@ -466,13 +469,13 @@ int cdn_dp_get_edid_block(void *data, u8
1315 - DRM_DEV_ERROR(dp->dev, "get block[%d] edid failed: %d\n", block,
1317 + DRM_DEV_ERROR(mhdp->dev, "get block[%d] edid failed: %d\n",
1323 -static int cdn_dp_training_start(struct cdn_dp_device *dp)
1324 +static int cdns_mhdp_training_start(struct cdns_mhdp_device *mhdp)
1326 unsigned long timeout;
1328 @@ -481,26 +484,28 @@ static int cdn_dp_training_start(struct
1329 msg = LINK_TRAINING_RUN;
1331 /* start training */
1332 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_TRAINING_CONTROL,
1333 - sizeof(msg), &msg);
1334 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1335 + DPTX_TRAINING_CONTROL, sizeof(msg), &msg);
1337 goto err_training_start;
1339 timeout = jiffies + msecs_to_jiffies(LINK_TRAINING_TIMEOUT_MS);
1340 while (time_before(jiffies, timeout)) {
1341 msleep(LINK_TRAINING_RETRY_MS);
1342 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX,
1343 - DPTX_READ_EVENT, 0, NULL);
1344 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX,
1345 + DPTX_READ_EVENT, 0, NULL);
1347 goto err_training_start;
1349 - ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX,
1352 + ret = cdns_mhdp_mailbox_validate_receive(mhdp,
1353 + MB_MODULE_ID_DP_TX,
1357 goto err_training_start;
1359 - ret = cdn_dp_mailbox_read_receive(dp, event, sizeof(event));
1360 + ret = cdns_mhdp_mailbox_read_receive(mhdp, event,
1363 goto err_training_start;
1365 @@ -511,76 +516,76 @@ static int cdn_dp_training_start(struct
1369 - DRM_DEV_ERROR(dp->dev, "training failed: %d\n", ret);
1370 + DRM_DEV_ERROR(mhdp->dev, "training failed: %d\n", ret);
1374 -static int cdn_dp_get_training_status(struct cdn_dp_device *dp)
1375 +static int cdns_mhdp_get_training_status(struct cdns_mhdp_device *mhdp)
1380 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_READ_LINK_STAT,
1381 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, DPTX_READ_LINK_STAT,
1384 goto err_get_training_status;
1386 - ret = cdn_dp_mailbox_validate_receive(dp, MB_MODULE_ID_DP_TX,
1387 + ret = cdns_mhdp_mailbox_validate_receive(mhdp, MB_MODULE_ID_DP_TX,
1388 DPTX_READ_LINK_STAT,
1391 goto err_get_training_status;
1393 - ret = cdn_dp_mailbox_read_receive(dp, status, sizeof(status));
1394 + ret = cdns_mhdp_mailbox_read_receive(mhdp, status, sizeof(status));
1396 goto err_get_training_status;
1398 - dp->link.rate = drm_dp_bw_code_to_link_rate(status[0]);
1399 - dp->link.num_lanes = status[1];
1400 + mhdp->link.rate = drm_dp_bw_code_to_link_rate(status[0]);
1401 + mhdp->link.num_lanes = status[1];
1403 err_get_training_status:
1405 - DRM_DEV_ERROR(dp->dev, "get training status failed: %d\n", ret);
1406 + DRM_DEV_ERROR(mhdp->dev, "get training status failed: %d\n", ret);
1410 -int cdn_dp_train_link(struct cdn_dp_device *dp)
1411 +int cdns_mhdp_train_link(struct cdns_mhdp_device *mhdp)
1415 - ret = cdn_dp_training_start(dp);
1416 + ret = cdns_mhdp_training_start(mhdp);
1418 - DRM_DEV_ERROR(dp->dev, "Failed to start training %d\n", ret);
1419 + DRM_DEV_ERROR(mhdp->dev, "Failed to start training %d\n", ret);
1423 - ret = cdn_dp_get_training_status(dp);
1424 + ret = cdns_mhdp_get_training_status(mhdp);
1426 - DRM_DEV_ERROR(dp->dev, "Failed to get training stat %d\n", ret);
1427 + DRM_DEV_ERROR(mhdp->dev, "Failed to get training stat %d\n", ret);
1431 - DRM_DEV_DEBUG_KMS(dp->dev, "rate:0x%x, lanes:%d\n", dp->link.rate,
1432 - dp->link.num_lanes);
1433 + DRM_DEV_DEBUG_KMS(mhdp->dev, "rate:0x%x, lanes:%d\n", mhdp->link.rate,
1434 + mhdp->link.num_lanes);
1438 -int cdn_dp_set_video_status(struct cdn_dp_device *dp, int active)
1439 +int cdns_mhdp_set_video_status(struct cdns_mhdp_device *mhdp, int active)
1446 - ret = cdn_dp_mailbox_send(dp, MB_MODULE_ID_DP_TX, DPTX_SET_VIDEO,
1447 + ret = cdns_mhdp_mailbox_send(mhdp, MB_MODULE_ID_DP_TX, DPTX_SET_VIDEO,
1450 - DRM_DEV_ERROR(dp->dev, "set video status failed: %d\n", ret);
1451 + DRM_DEV_ERROR(mhdp->dev, "set video status failed: %d\n", ret);
1456 -static int cdn_dp_get_msa_misc(struct video_info *video,
1457 +static int cdns_mhdp_get_msa_misc(struct video_info *video,
1458 struct drm_display_mode *mode)
1461 @@ -627,10 +632,10 @@ static int cdn_dp_get_msa_misc(struct vi
1465 -int cdn_dp_config_video(struct cdn_dp_device *dp)
1466 +int cdns_mhdp_config_video(struct cdns_mhdp_device *mhdp)
1468 - struct video_info *video = &dp->video_info;
1469 - struct drm_display_mode *mode = &dp->mode;
1470 + struct video_info *video = &mhdp->video_info;
1471 + struct drm_display_mode *mode = &mhdp->mode;
1473 u32 val, link_rate, rem;
1474 u8 bit_per_pix, tu_size_reg = TU_SIZE;
1475 @@ -639,13 +644,13 @@ int cdn_dp_config_video(struct cdn_dp_de
1476 bit_per_pix = (video->color_fmt == YCBCR_4_2_2) ?
1477 (video->color_depth * 2) : (video->color_depth * 3);
1479 - link_rate = dp->link.rate / 1000;
1480 + link_rate = mhdp->link.rate / 1000;
1482 - ret = cdn_dp_reg_write(dp, BND_HSYNC2VSYNC, VIF_BYPASS_INTERLACE);
1483 + ret = cdns_mhdp_reg_write(mhdp, BND_HSYNC2VSYNC, VIF_BYPASS_INTERLACE);
1485 goto err_config_video;
1487 - ret = cdn_dp_reg_write(dp, HSYNC2VSYNC_POL_CTRL, 0);
1488 + ret = cdns_mhdp_reg_write(mhdp, HSYNC2VSYNC_POL_CTRL, 0);
1490 goto err_config_video;
1492 @@ -659,13 +664,13 @@ int cdn_dp_config_video(struct cdn_dp_de
1495 symbol = tu_size_reg * mode->clock * bit_per_pix;
1496 - do_div(symbol, dp->link.num_lanes * link_rate * 8);
1497 + do_div(symbol, mhdp->link.num_lanes * link_rate * 8);
1498 rem = do_div(symbol, 1000);
1499 if (tu_size_reg > 64) {
1501 - DRM_DEV_ERROR(dp->dev,
1502 + DRM_DEV_ERROR(mhdp->dev,
1503 "tu error, clk:%d, lanes:%d, rate:%d\n",
1504 - mode->clock, dp->link.num_lanes,
1505 + mode->clock, mhdp->link.num_lanes,
1507 goto err_config_video;
1509 @@ -674,16 +679,16 @@ int cdn_dp_config_video(struct cdn_dp_de
1511 val = symbol + (tu_size_reg << 8);
1512 val |= TU_CNT_RST_EN;
1513 - ret = cdn_dp_reg_write(dp, DP_FRAMER_TU, val);
1514 + ret = cdns_mhdp_reg_write(mhdp, DP_FRAMER_TU, val);
1516 goto err_config_video;
1518 /* set the FIFO Buffer size */
1519 val = div_u64(mode->clock * (symbol + 1), 1000) + link_rate;
1520 - val /= (dp->link.num_lanes * link_rate);
1521 + val /= (mhdp->link.num_lanes * link_rate);
1522 val = div_u64(8 * (symbol + 1), bit_per_pix) - val;
1524 - ret = cdn_dp_reg_write(dp, DP_VC_TABLE(15), val);
1525 + ret = cdns_mhdp_reg_write(mhdp, DP_VC_TABLE(15), val);
1527 switch (video->color_depth) {
1529 @@ -704,136 +709,137 @@ int cdn_dp_config_video(struct cdn_dp_de
1532 val += video->color_fmt << 8;
1533 - ret = cdn_dp_reg_write(dp, DP_FRAMER_PXL_REPR, val);
1534 + ret = cdns_mhdp_reg_write(mhdp, DP_FRAMER_PXL_REPR, val);
1536 goto err_config_video;
1538 val = video->h_sync_polarity ? DP_FRAMER_SP_HSP : 0;
1539 val |= video->v_sync_polarity ? DP_FRAMER_SP_VSP : 0;
1540 - ret = cdn_dp_reg_write(dp, DP_FRAMER_SP, val);
1541 + ret = cdns_mhdp_reg_write(mhdp, DP_FRAMER_SP, val);
1543 goto err_config_video;
1545 val = (mode->hsync_start - mode->hdisplay) << 16;
1546 val |= mode->htotal - mode->hsync_end;
1547 - ret = cdn_dp_reg_write(dp, DP_FRONT_BACK_PORCH, val);
1548 + ret = cdns_mhdp_reg_write(mhdp, DP_FRONT_BACK_PORCH, val);
1550 goto err_config_video;
1552 val = mode->hdisplay * bit_per_pix / 8;
1553 - ret = cdn_dp_reg_write(dp, DP_BYTE_COUNT, val);
1554 + ret = cdns_mhdp_reg_write(mhdp, DP_BYTE_COUNT, val);
1556 goto err_config_video;
1558 val = mode->htotal | ((mode->htotal - mode->hsync_start) << 16);
1559 - ret = cdn_dp_reg_write(dp, MSA_HORIZONTAL_0, val);
1560 + ret = cdns_mhdp_reg_write(mhdp, MSA_HORIZONTAL_0, val);
1562 goto err_config_video;
1564 val = mode->hsync_end - mode->hsync_start;
1565 val |= (mode->hdisplay << 16) | (video->h_sync_polarity << 15);
1566 - ret = cdn_dp_reg_write(dp, MSA_HORIZONTAL_1, val);
1567 + ret = cdns_mhdp_reg_write(mhdp, MSA_HORIZONTAL_1, val);
1569 goto err_config_video;
1572 val |= (mode->vtotal - mode->vsync_start) << 16;
1573 - ret = cdn_dp_reg_write(dp, MSA_VERTICAL_0, val);
1574 + ret = cdns_mhdp_reg_write(mhdp, MSA_VERTICAL_0, val);
1576 goto err_config_video;
1578 val = mode->vsync_end - mode->vsync_start;
1579 val |= (mode->vdisplay << 16) | (video->v_sync_polarity << 15);
1580 - ret = cdn_dp_reg_write(dp, MSA_VERTICAL_1, val);
1581 + ret = cdns_mhdp_reg_write(mhdp, MSA_VERTICAL_1, val);
1583 goto err_config_video;
1585 - val = cdn_dp_get_msa_misc(video, mode);
1586 - ret = cdn_dp_reg_write(dp, MSA_MISC, val);
1587 + val = cdns_mhdp_get_msa_misc(video, mode);
1588 + ret = cdns_mhdp_reg_write(mhdp, MSA_MISC, val);
1590 goto err_config_video;
1592 - ret = cdn_dp_reg_write(dp, STREAM_CONFIG, 1);
1593 + ret = cdns_mhdp_reg_write(mhdp, STREAM_CONFIG, 1);
1595 goto err_config_video;
1597 val = mode->hsync_end - mode->hsync_start;
1598 val |= mode->hdisplay << 16;
1599 - ret = cdn_dp_reg_write(dp, DP_HORIZONTAL, val);
1600 + ret = cdns_mhdp_reg_write(mhdp, DP_HORIZONTAL, val);
1602 goto err_config_video;
1604 val = mode->vdisplay;
1605 val |= (mode->vtotal - mode->vsync_start) << 16;
1606 - ret = cdn_dp_reg_write(dp, DP_VERTICAL_0, val);
1607 + ret = cdns_mhdp_reg_write(mhdp, DP_VERTICAL_0, val);
1609 goto err_config_video;
1612 - ret = cdn_dp_reg_write(dp, DP_VERTICAL_1, val);
1613 + ret = cdns_mhdp_reg_write(mhdp, DP_VERTICAL_1, val);
1615 goto err_config_video;
1617 - ret = cdn_dp_reg_write_bit(dp, DP_VB_ID, 2, 1, 0);
1618 + ret = cdns_mhdp_reg_write_bit(mhdp, DP_VB_ID, 2, 1, 0);
1622 - DRM_DEV_ERROR(dp->dev, "config video failed: %d\n", ret);
1623 + DRM_DEV_ERROR(mhdp->dev, "config video failed: %d\n", ret);
1627 -int cdn_dp_audio_stop(struct cdn_dp_device *dp, struct audio_info *audio)
1628 +int cdns_mhdp_audio_stop(struct cdns_mhdp_device *mhdp,
1629 + struct audio_info *audio)
1633 - ret = cdn_dp_reg_write(dp, AUDIO_PACK_CONTROL, 0);
1634 + ret = cdns_mhdp_reg_write(mhdp, AUDIO_PACK_CONTROL, 0);
1636 - DRM_DEV_ERROR(dp->dev, "audio stop failed: %d\n", ret);
1637 + DRM_DEV_ERROR(mhdp->dev, "audio stop failed: %d\n", ret);
1641 - writel(0, dp->regs + SPDIF_CTRL_ADDR);
1642 + writel(0, mhdp->regs + SPDIF_CTRL_ADDR);
1644 /* clearn the audio config and reset */
1645 - writel(0, dp->regs + AUDIO_SRC_CNTL);
1646 - writel(0, dp->regs + AUDIO_SRC_CNFG);
1647 - writel(AUDIO_SW_RST, dp->regs + AUDIO_SRC_CNTL);
1648 - writel(0, dp->regs + AUDIO_SRC_CNTL);
1649 + writel(0, mhdp->regs + AUDIO_SRC_CNTL);
1650 + writel(0, mhdp->regs + AUDIO_SRC_CNFG);
1651 + writel(AUDIO_SW_RST, mhdp->regs + AUDIO_SRC_CNTL);
1652 + writel(0, mhdp->regs + AUDIO_SRC_CNTL);
1654 /* reset smpl2pckt component */
1655 - writel(0, dp->regs + SMPL2PKT_CNTL);
1656 - writel(AUDIO_SW_RST, dp->regs + SMPL2PKT_CNTL);
1657 - writel(0, dp->regs + SMPL2PKT_CNTL);
1658 + writel(0, mhdp->regs + SMPL2PKT_CNTL);
1659 + writel(AUDIO_SW_RST, mhdp->regs + SMPL2PKT_CNTL);
1660 + writel(0, mhdp->regs + SMPL2PKT_CNTL);
1663 - writel(AUDIO_SW_RST, dp->regs + FIFO_CNTL);
1664 - writel(0, dp->regs + FIFO_CNTL);
1665 + writel(AUDIO_SW_RST, mhdp->regs + FIFO_CNTL);
1666 + writel(0, mhdp->regs + FIFO_CNTL);
1668 if (audio->format == AFMT_SPDIF)
1669 - clk_disable_unprepare(dp->spdif_clk);
1670 + clk_disable_unprepare(mhdp->spdif_clk);
1675 -int cdn_dp_audio_mute(struct cdn_dp_device *dp, bool enable)
1676 +int cdns_mhdp_audio_mute(struct cdns_mhdp_device *mhdp, bool enable)
1680 - ret = cdn_dp_reg_write_bit(dp, DP_VB_ID, 4, 1, enable);
1681 + ret = cdns_mhdp_reg_write_bit(mhdp, DP_VB_ID, 4, 1, enable);
1683 - DRM_DEV_ERROR(dp->dev, "audio mute failed: %d\n", ret);
1684 + DRM_DEV_ERROR(mhdp->dev, "audio mute failed: %d\n", ret);
1689 -static void cdn_dp_audio_config_i2s(struct cdn_dp_device *dp,
1690 - struct audio_info *audio)
1691 +static void cdns_mhdp_audio_config_i2s(struct cdns_mhdp_device *mhdp,
1692 + struct audio_info *audio)
1694 int sub_pckt_num = 1, i2s_port_en_val = 0xf, i;
1697 if (audio->channels == 2) {
1698 - if (dp->link.num_lanes == 1)
1699 + if (mhdp->link.num_lanes == 1)
1703 @@ -843,15 +849,15 @@ static void cdn_dp_audio_config_i2s(stru
1704 i2s_port_en_val = 3;
1707 - writel(0x0, dp->regs + SPDIF_CTRL_ADDR);
1708 + writel(0x0, mhdp->regs + SPDIF_CTRL_ADDR);
1710 - writel(SYNC_WR_TO_CH_ZERO, dp->regs + FIFO_CNTL);
1711 + writel(SYNC_WR_TO_CH_ZERO, mhdp->regs + FIFO_CNTL);
1713 val = MAX_NUM_CH(audio->channels);
1714 val |= NUM_OF_I2S_PORTS(audio->channels);
1715 val |= AUDIO_TYPE_LPCM;
1716 val |= CFG_SUB_PCKT_NUM(sub_pckt_num);
1717 - writel(val, dp->regs + SMPL2PKT_CNFG);
1718 + writel(val, mhdp->regs + SMPL2PKT_CNFG);
1720 if (audio->sample_width == 16)
1722 @@ -863,7 +869,7 @@ static void cdn_dp_audio_config_i2s(stru
1723 val |= AUDIO_CH_NUM(audio->channels);
1724 val |= I2S_DEC_PORT_EN(i2s_port_en_val);
1725 val |= TRANS_SMPL_WIDTH_32;
1726 - writel(val, dp->regs + AUDIO_SRC_CNFG);
1727 + writel(val, mhdp->regs + AUDIO_SRC_CNFG);
1729 for (i = 0; i < (audio->channels + 1) / 2; i++) {
1730 if (audio->sample_width == 16)
1731 @@ -872,7 +878,7 @@ static void cdn_dp_audio_config_i2s(stru
1732 val = (0x0b << 8) | (0x0b << 20);
1734 val |= ((2 * i) << 4) | ((2 * i + 1) << 16);
1735 - writel(val, dp->regs + STTS_BIT_CH(i));
1736 + writel(val, mhdp->regs + STTS_BIT_CH(i));
1739 switch (audio->sample_rate) {
1740 @@ -906,56 +912,57 @@ static void cdn_dp_audio_config_i2s(stru
1744 - writel(val, dp->regs + COM_CH_STTS_BITS);
1745 + writel(val, mhdp->regs + COM_CH_STTS_BITS);
1747 - writel(SMPL2PKT_EN, dp->regs + SMPL2PKT_CNTL);
1748 - writel(I2S_DEC_START, dp->regs + AUDIO_SRC_CNTL);
1749 + writel(SMPL2PKT_EN, mhdp->regs + SMPL2PKT_CNTL);
1750 + writel(I2S_DEC_START, mhdp->regs + AUDIO_SRC_CNTL);
1753 -static void cdn_dp_audio_config_spdif(struct cdn_dp_device *dp)
1754 +static void cdns_mhdp_audio_config_spdif(struct cdns_mhdp_device *mhdp)
1758 - writel(SYNC_WR_TO_CH_ZERO, dp->regs + FIFO_CNTL);
1759 + writel(SYNC_WR_TO_CH_ZERO, mhdp->regs + FIFO_CNTL);
1761 val = MAX_NUM_CH(2) | AUDIO_TYPE_LPCM | CFG_SUB_PCKT_NUM(4);
1762 - writel(val, dp->regs + SMPL2PKT_CNFG);
1763 - writel(SMPL2PKT_EN, dp->regs + SMPL2PKT_CNTL);
1764 + writel(val, mhdp->regs + SMPL2PKT_CNFG);
1765 + writel(SMPL2PKT_EN, mhdp->regs + SMPL2PKT_CNTL);
1767 val = SPDIF_ENABLE | SPDIF_AVG_SEL | SPDIF_JITTER_BYPASS;
1768 - writel(val, dp->regs + SPDIF_CTRL_ADDR);
1769 + writel(val, mhdp->regs + SPDIF_CTRL_ADDR);
1771 - clk_prepare_enable(dp->spdif_clk);
1772 - clk_set_rate(dp->spdif_clk, CDN_DP_SPDIF_CLK);
1773 + clk_prepare_enable(mhdp->spdif_clk);
1774 + clk_set_rate(mhdp->spdif_clk, CDNS_DP_SPDIF_CLK);
1777 -int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio)
1778 +int cdns_mhdp_audio_config(struct cdns_mhdp_device *mhdp,
1779 + struct audio_info *audio)
1783 /* reset the spdif clk before config */
1784 if (audio->format == AFMT_SPDIF) {
1785 - reset_control_assert(dp->spdif_rst);
1786 - reset_control_deassert(dp->spdif_rst);
1787 + reset_control_assert(mhdp->spdif_rst);
1788 + reset_control_deassert(mhdp->spdif_rst);
1791 - ret = cdn_dp_reg_write(dp, CM_LANE_CTRL, LANE_REF_CYC);
1792 + ret = cdns_mhdp_reg_write(mhdp, CM_LANE_CTRL, LANE_REF_CYC);
1794 goto err_audio_config;
1796 - ret = cdn_dp_reg_write(dp, CM_CTRL, 0);
1797 + ret = cdns_mhdp_reg_write(mhdp, CM_CTRL, 0);
1799 goto err_audio_config;
1801 if (audio->format == AFMT_I2S)
1802 - cdn_dp_audio_config_i2s(dp, audio);
1803 + cdns_mhdp_audio_config_i2s(mhdp, audio);
1804 else if (audio->format == AFMT_SPDIF)
1805 - cdn_dp_audio_config_spdif(dp);
1806 + cdns_mhdp_audio_config_spdif(mhdp);
1808 - ret = cdn_dp_reg_write(dp, AUDIO_PACK_CONTROL, AUDIO_PACK_EN);
1809 + ret = cdns_mhdp_reg_write(mhdp, AUDIO_PACK_CONTROL, AUDIO_PACK_EN);
1813 - DRM_DEV_ERROR(dp->dev, "audio config failed: %d\n", ret);
1814 + DRM_DEV_ERROR(mhdp->dev, "audio config failed: %d\n", ret);
1817 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.h
1818 +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.h
1820 #define HDCP_TX_IS_RECEIVER_ID_VALID_EVENT BIT(7)
1823 -#define CDN_DP_MAX_LINK_RATE DP_LINK_BW_5_4
1824 +#define CDNS_DP_MAX_LINK_RATE DP_LINK_BW_5_4
1827 #define AUDIO_PACK_EN BIT(8)
1828 @@ -451,24 +451,96 @@ enum vic_bt_type {
1832 -void cdn_dp_clock_reset(struct cdn_dp_device *dp);
1833 +enum audio_format {
1839 +struct audio_info {
1840 + enum audio_format format;
1846 +enum vic_pxl_encoding_format {
1848 + YCBCR_4_4_4 = 0x2,
1849 + YCBCR_4_2_2 = 0x4,
1850 + YCBCR_4_2_0 = 0x8,
1854 +struct video_info {
1855 + bool h_sync_polarity;
1856 + bool v_sync_polarity;
1859 + enum vic_pxl_encoding_format color_fmt;
1862 +struct cdns_mhdp_host {
1863 + unsigned int link_rate;
1873 +struct cdns_mhdp_sink {
1874 + unsigned int link_rate;
1881 +struct cdns_mhdp_device {
1882 + void __iomem *regs;
1884 + struct device *dev;
1886 + struct drm_dp_link link;
1887 + struct drm_connector connector;
1888 + struct clk *spdif_clk;
1889 + struct reset_control *spdif_rst;
1891 + struct drm_dp_aux aux;
1892 + struct cdns_mhdp_host host;
1893 + struct cdns_mhdp_sink sink;
1894 + struct drm_bridge bridge;
1896 + void __iomem *dbg_regs;
1898 + struct video_info video_info;
1899 + struct drm_display_mode mode;
1900 + unsigned int fw_version;
1903 -void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk);
1904 -int cdn_dp_load_firmware(struct cdn_dp_device *dp, const u32 *i_mem,
1905 - u32 i_size, const u32 *d_mem, u32 d_size);
1906 -int cdn_dp_set_firmware_active(struct cdn_dp_device *dp, bool enable);
1907 -int cdn_dp_set_host_cap(struct cdn_dp_device *dp, u8 lanes, bool flip);
1908 -int cdn_dp_event_config(struct cdn_dp_device *dp);
1909 -u32 cdn_dp_get_event(struct cdn_dp_device *dp);
1910 -int cdn_dp_get_hpd_status(struct cdn_dp_device *dp);
1911 -int cdn_dp_dpcd_write(struct cdn_dp_device *dp, u32 addr, u8 value);
1912 -int cdn_dp_dpcd_read(struct cdn_dp_device *dp, u32 addr, u8 *data, u16 len);
1913 -int cdn_dp_get_edid_block(void *dp, u8 *edid,
1914 - unsigned int block, size_t length);
1915 -int cdn_dp_train_link(struct cdn_dp_device *dp);
1916 -int cdn_dp_set_video_status(struct cdn_dp_device *dp, int active);
1917 -int cdn_dp_config_video(struct cdn_dp_device *dp);
1918 -int cdn_dp_audio_stop(struct cdn_dp_device *dp, struct audio_info *audio);
1919 -int cdn_dp_audio_mute(struct cdn_dp_device *dp, bool enable);
1920 -int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio);
1921 +void cdns_mhdp_clock_reset(struct cdns_mhdp_device *mhdp);
1922 +void cdns_mhdp_set_fw_clk(struct cdns_mhdp_device *mhdp, unsigned long clk);
1923 +int cdns_mhdp_load_firmware(struct cdns_mhdp_device *mhdp, const u32 *i_mem,
1924 + u32 i_size, const u32 *d_mem, u32 d_size);
1925 +int cdns_mhdp_set_firmware_active(struct cdns_mhdp_device *mhdp, bool enable);
1926 +int cdns_mhdp_set_host_cap(struct cdns_mhdp_device *mhdp, u8 lanes, bool flip);
1927 +int cdns_mhdp_event_config(struct cdns_mhdp_device *mhdp);
1928 +u32 cdns_mhdp_get_event(struct cdns_mhdp_device *mhdp);
1929 +int cdns_mhdp_get_hpd_status(struct cdns_mhdp_device *mhdp);
1930 +int cdns_mhdp_dpcd_write(struct cdns_mhdp_device *mhdp, u32 addr, u8 value);
1931 +int cdns_mhdp_dpcd_read(struct cdns_mhdp_device *mhdp,
1932 + u32 addr, u8 *data, u16 len);
1933 +int cdns_mhdp_get_edid_block(void *mhdp, u8 *edid,
1934 + unsigned int block, size_t length);
1935 +int cdns_mhdp_train_link(struct cdns_mhdp_device *mhdp);
1936 +int cdns_mhdp_set_video_status(struct cdns_mhdp_device *mhdp, int active);
1937 +int cdns_mhdp_config_video(struct cdns_mhdp_device *mhdp);
1938 +int cdns_mhdp_audio_stop(struct cdns_mhdp_device *mhdp,
1939 + struct audio_info *audio);
1940 +int cdns_mhdp_audio_mute(struct cdns_mhdp_device *mhdp, bool enable);
1941 +int cdns_mhdp_audio_config(struct cdns_mhdp_device *mhdp,
1942 + struct audio_info *audio);
1943 #endif /* _CDN_DP_REG_H */