Lines Matching full:dp

25 #include "cdn-dp-core.h"
26 #include "cdn-dp-reg.h"
62 { .compatible = "rockchip,rk3399-cdn-dp",
69 static int cdn_dp_grf_write(struct cdn_dp_device *dp, in cdn_dp_grf_write() argument
74 ret = clk_prepare_enable(dp->grf_clk); in cdn_dp_grf_write()
76 DRM_DEV_ERROR(dp->dev, "Failed to prepare_enable grf clock\n"); in cdn_dp_grf_write()
80 ret = regmap_write(dp->grf, reg, val); in cdn_dp_grf_write()
82 DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret); in cdn_dp_grf_write()
83 clk_disable_unprepare(dp->grf_clk); in cdn_dp_grf_write()
87 clk_disable_unprepare(dp->grf_clk); in cdn_dp_grf_write()
92 static int cdn_dp_clk_enable(struct cdn_dp_device *dp) in cdn_dp_clk_enable() argument
97 ret = clk_prepare_enable(dp->pclk); in cdn_dp_clk_enable()
99 DRM_DEV_ERROR(dp->dev, "cannot enable dp pclk %d\n", ret); in cdn_dp_clk_enable()
103 ret = clk_prepare_enable(dp->core_clk); in cdn_dp_clk_enable()
105 DRM_DEV_ERROR(dp->dev, "cannot enable core_clk %d\n", ret); in cdn_dp_clk_enable()
109 ret = pm_runtime_get_sync(dp->dev); in cdn_dp_clk_enable()
111 DRM_DEV_ERROR(dp->dev, "cannot get pm runtime %d\n", ret); in cdn_dp_clk_enable()
115 reset_control_assert(dp->core_rst); in cdn_dp_clk_enable()
116 reset_control_assert(dp->dptx_rst); in cdn_dp_clk_enable()
117 reset_control_assert(dp->apb_rst); in cdn_dp_clk_enable()
118 reset_control_deassert(dp->core_rst); in cdn_dp_clk_enable()
119 reset_control_deassert(dp->dptx_rst); in cdn_dp_clk_enable()
120 reset_control_deassert(dp->apb_rst); in cdn_dp_clk_enable()
122 rate = clk_get_rate(dp->core_clk); in cdn_dp_clk_enable()
124 DRM_DEV_ERROR(dp->dev, "get clk rate failed\n"); in cdn_dp_clk_enable()
129 cdn_dp_set_fw_clk(dp, rate); in cdn_dp_clk_enable()
130 cdn_dp_clock_reset(dp); in cdn_dp_clk_enable()
135 pm_runtime_put(dp->dev); in cdn_dp_clk_enable()
137 clk_disable_unprepare(dp->core_clk); in cdn_dp_clk_enable()
139 clk_disable_unprepare(dp->pclk); in cdn_dp_clk_enable()
144 static void cdn_dp_clk_disable(struct cdn_dp_device *dp) in cdn_dp_clk_disable() argument
146 pm_runtime_put_sync(dp->dev); in cdn_dp_clk_disable()
147 clk_disable_unprepare(dp->pclk); in cdn_dp_clk_disable()
148 clk_disable_unprepare(dp->core_clk); in cdn_dp_clk_disable()
173 static int cdn_dp_get_sink_count(struct cdn_dp_device *dp, u8 *sink_count) in cdn_dp_get_sink_count() argument
179 ret = cdn_dp_dpcd_read(dp, DP_SINK_COUNT, &value, 1); in cdn_dp_get_sink_count()
187 static struct cdn_dp_port *cdn_dp_connected_port(struct cdn_dp_device *dp) in cdn_dp_connected_port() argument
192 for (i = 0; i < dp->ports; i++) { in cdn_dp_connected_port()
193 port = dp->port[i]; in cdn_dp_connected_port()
201 static bool cdn_dp_check_sink_connection(struct cdn_dp_device *dp) in cdn_dp_check_sink_connection() argument
207 if (dp->active_port < 0 || dp->active_port >= dp->ports) { in cdn_dp_check_sink_connection()
208 DRM_DEV_ERROR(dp->dev, "active_port is wrong!\n"); in cdn_dp_check_sink_connection()
212 port = dp->port[dp->active_port]; in cdn_dp_check_sink_connection()
224 if (!cdn_dp_get_sink_count(dp, &sink_count)) in cdn_dp_check_sink_connection()
230 DRM_DEV_ERROR(dp->dev, "Get sink capability timed out\n"); in cdn_dp_check_sink_connection()
237 struct cdn_dp_device *dp = connector_to_dp(connector); in cdn_dp_connector_detect() local
240 mutex_lock(&dp->lock); in cdn_dp_connector_detect()
241 if (dp->connected) in cdn_dp_connector_detect()
243 mutex_unlock(&dp->lock); in cdn_dp_connector_detect()
265 struct cdn_dp_device *dp = connector_to_dp(connector); in cdn_dp_connector_get_modes() local
269 mutex_lock(&dp->lock); in cdn_dp_connector_get_modes()
270 edid = dp->edid; in cdn_dp_connector_get_modes()
272 DRM_DEV_DEBUG_KMS(dp->dev, "got edid: width[%d] x height[%d]\n", in cdn_dp_connector_get_modes()
275 dp->sink_has_audio = drm_detect_monitor_audio(edid); in cdn_dp_connector_get_modes()
281 mutex_unlock(&dp->lock); in cdn_dp_connector_get_modes()
290 struct cdn_dp_device *dp = connector_to_dp(connector); in cdn_dp_connector_mode_valid() local
291 struct drm_display_info *display_info = &dp->connector.display_info; in cdn_dp_connector_mode_valid()
295 /* If DP is disconnected, every mode is invalid */ in cdn_dp_connector_mode_valid()
296 if (!dp->connected) in cdn_dp_connector_mode_valid()
313 source_max = dp->lanes; in cdn_dp_connector_mode_valid()
314 sink_max = drm_dp_max_lane_count(dp->dpcd); in cdn_dp_connector_mode_valid()
318 sink_max = drm_dp_max_link_rate(dp->dpcd); in cdn_dp_connector_mode_valid()
327 DRM_DEV_DEBUG_KMS(dp->dev, in cdn_dp_connector_mode_valid()
341 static int cdn_dp_firmware_init(struct cdn_dp_device *dp) in cdn_dp_firmware_init() argument
345 const struct firmware *fw = dp->fw; in cdn_dp_firmware_init()
350 DRM_DEV_ERROR(dp->dev, "firmware is invalid\n"); in cdn_dp_firmware_init()
357 ret = cdn_dp_load_firmware(dp, iram_data, hdr->iram_size, in cdn_dp_firmware_init()
362 ret = cdn_dp_set_firmware_active(dp, true); in cdn_dp_firmware_init()
364 DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret); in cdn_dp_firmware_init()
368 return cdn_dp_event_config(dp); in cdn_dp_firmware_init()
371 static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp) in cdn_dp_get_sink_capability() argument
375 if (!cdn_dp_check_sink_connection(dp)) in cdn_dp_get_sink_capability()
378 ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd, in cdn_dp_get_sink_capability()
381 DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret); in cdn_dp_get_sink_capability()
385 kfree(dp->edid); in cdn_dp_get_sink_capability()
386 dp->edid = drm_do_get_edid(&dp->connector, in cdn_dp_get_sink_capability()
387 cdn_dp_get_edid_block, dp); in cdn_dp_get_sink_capability()
391 static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port) in cdn_dp_enable_phy() argument
399 DRM_DEV_ERROR(dp->dev, "phy power on failed: %d\n", in cdn_dp_enable_phy()
406 ret = cdn_dp_grf_write(dp, GRF_SOC_CON26, in cdn_dp_enable_phy()
409 DRM_DEV_ERROR(dp->dev, "Failed to write HPD_SEL %d\n", ret); in cdn_dp_enable_phy()
413 ret = cdn_dp_get_hpd_status(dp); in cdn_dp_enable_phy()
416 DRM_DEV_ERROR(dp->dev, "hpd does not exist\n"); in cdn_dp_enable_phy()
423 DRM_DEV_ERROR(dp->dev, "get property failed\n"); in cdn_dp_enable_phy()
428 ret = cdn_dp_set_host_cap(dp, port->lanes, property.intval); in cdn_dp_enable_phy()
430 DRM_DEV_ERROR(dp->dev, "set host capabilities failed: %d\n", in cdn_dp_enable_phy()
435 dp->active_port = port->id; in cdn_dp_enable_phy()
440 DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret); in cdn_dp_enable_phy()
445 cdn_dp_grf_write(dp, GRF_SOC_CON26, in cdn_dp_enable_phy()
450 static int cdn_dp_disable_phy(struct cdn_dp_device *dp, in cdn_dp_disable_phy() argument
458 DRM_DEV_ERROR(dp->dev, "phy power off failed: %d", ret); in cdn_dp_disable_phy()
465 dp->active_port = -1; in cdn_dp_disable_phy()
469 static int cdn_dp_disable(struct cdn_dp_device *dp) in cdn_dp_disable() argument
473 if (!dp->active) in cdn_dp_disable()
476 for (i = 0; i < dp->ports; i++) in cdn_dp_disable()
477 cdn_dp_disable_phy(dp, dp->port[i]); in cdn_dp_disable()
479 ret = cdn_dp_grf_write(dp, GRF_SOC_CON26, in cdn_dp_disable()
482 DRM_DEV_ERROR(dp->dev, "Failed to clear hpd sel %d\n", in cdn_dp_disable()
487 cdn_dp_set_firmware_active(dp, false); in cdn_dp_disable()
488 cdn_dp_clk_disable(dp); in cdn_dp_disable()
489 dp->active = false; in cdn_dp_disable()
490 dp->max_lanes = 0; in cdn_dp_disable()
491 dp->max_rate = 0; in cdn_dp_disable()
492 if (!dp->connected) { in cdn_dp_disable()
493 kfree(dp->edid); in cdn_dp_disable()
494 dp->edid = NULL; in cdn_dp_disable()
500 static int cdn_dp_enable(struct cdn_dp_device *dp) in cdn_dp_enable() argument
505 port = cdn_dp_connected_port(dp); in cdn_dp_enable()
507 DRM_DEV_ERROR(dp->dev, in cdn_dp_enable()
512 if (dp->active) in cdn_dp_enable()
515 ret = cdn_dp_clk_enable(dp); in cdn_dp_enable()
519 ret = cdn_dp_firmware_init(dp); in cdn_dp_enable()
521 DRM_DEV_ERROR(dp->dev, "firmware init failed: %d", ret); in cdn_dp_enable()
526 for (i = port->id; i < dp->ports; i++) { in cdn_dp_enable()
527 port = dp->port[i]; in cdn_dp_enable()
530 ret = cdn_dp_enable_phy(dp, port); in cdn_dp_enable()
534 ret = cdn_dp_get_sink_capability(dp); in cdn_dp_enable()
536 cdn_dp_disable_phy(dp, port); in cdn_dp_enable()
538 dp->active = true; in cdn_dp_enable()
539 dp->lanes = port->lanes; in cdn_dp_enable()
546 cdn_dp_clk_disable(dp); in cdn_dp_enable()
554 struct cdn_dp_device *dp = encoder_to_dp(encoder); in cdn_dp_encoder_mode_set() local
555 struct drm_display_info *display_info = &dp->connector.display_info; in cdn_dp_encoder_mode_set()
556 struct video_info *video = &dp->video_info; in cdn_dp_encoder_mode_set()
574 memcpy(&dp->mode, adjusted, sizeof(*mode)); in cdn_dp_encoder_mode_set()
577 static bool cdn_dp_check_link_status(struct cdn_dp_device *dp) in cdn_dp_check_link_status() argument
580 struct cdn_dp_port *port = cdn_dp_connected_port(dp); in cdn_dp_check_link_status()
581 u8 sink_lanes = drm_dp_max_lane_count(dp->dpcd); in cdn_dp_check_link_status()
583 if (!port || !dp->max_rate || !dp->max_lanes) in cdn_dp_check_link_status()
586 if (cdn_dp_dpcd_read(dp, DP_LANE0_1_STATUS, link_status, in cdn_dp_check_link_status()
596 static void cdn_dp_audio_handle_plugged_change(struct cdn_dp_device *dp, in cdn_dp_audio_handle_plugged_change() argument
599 if (dp->codec_dev) in cdn_dp_audio_handle_plugged_change()
600 dp->plugged_cb(dp->codec_dev, plugged); in cdn_dp_audio_handle_plugged_change()
605 struct cdn_dp_device *dp = encoder_to_dp(encoder); in cdn_dp_encoder_enable() local
608 ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder); in cdn_dp_encoder_enable()
610 DRM_DEV_ERROR(dp->dev, "Could not get vop id, %d", ret); in cdn_dp_encoder_enable()
614 DRM_DEV_DEBUG_KMS(dp->dev, "vop %s output to cdn-dp\n", in cdn_dp_encoder_enable()
621 ret = cdn_dp_grf_write(dp, GRF_SOC_CON9, val); in cdn_dp_encoder_enable()
625 mutex_lock(&dp->lock); in cdn_dp_encoder_enable()
627 ret = cdn_dp_enable(dp); in cdn_dp_encoder_enable()
629 DRM_DEV_ERROR(dp->dev, "Failed to enable encoder %d\n", in cdn_dp_encoder_enable()
633 if (!cdn_dp_check_link_status(dp)) { in cdn_dp_encoder_enable()
634 ret = cdn_dp_train_link(dp); in cdn_dp_encoder_enable()
636 DRM_DEV_ERROR(dp->dev, "Failed link train %d\n", ret); in cdn_dp_encoder_enable()
641 ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_IDLE); in cdn_dp_encoder_enable()
643 DRM_DEV_ERROR(dp->dev, "Failed to idle video %d\n", ret); in cdn_dp_encoder_enable()
647 ret = cdn_dp_config_video(dp); in cdn_dp_encoder_enable()
649 DRM_DEV_ERROR(dp->dev, "Failed to config video %d\n", ret); in cdn_dp_encoder_enable()
653 ret = cdn_dp_set_video_status(dp, CONTROL_VIDEO_VALID); in cdn_dp_encoder_enable()
655 DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret); in cdn_dp_encoder_enable()
659 cdn_dp_audio_handle_plugged_change(dp, true); in cdn_dp_encoder_enable()
662 mutex_unlock(&dp->lock); in cdn_dp_encoder_enable()
667 struct cdn_dp_device *dp = encoder_to_dp(encoder); in cdn_dp_encoder_disable() local
670 mutex_lock(&dp->lock); in cdn_dp_encoder_disable()
671 cdn_dp_audio_handle_plugged_change(dp, false); in cdn_dp_encoder_disable()
673 if (dp->active) { in cdn_dp_encoder_disable()
674 ret = cdn_dp_disable(dp); in cdn_dp_encoder_disable()
676 DRM_DEV_ERROR(dp->dev, "Failed to disable encoder %d\n", in cdn_dp_encoder_disable()
680 mutex_unlock(&dp->lock); in cdn_dp_encoder_disable()
684 * the DP: in cdn_dp_encoder_disable()
686 * device from a port, the DP will be disabled here, at this case, in cdn_dp_encoder_disable()
687 * run the event_work to re-open DP for the other port. in cdn_dp_encoder_disable()
688 * 2. If re-training or re-config failed, the DP will be disabled here. in cdn_dp_encoder_disable()
691 if (!dp->connected && cdn_dp_connected_port(dp)) in cdn_dp_encoder_disable()
692 schedule_work(&dp->event_work); in cdn_dp_encoder_disable()
714 static int cdn_dp_parse_dt(struct cdn_dp_device *dp) in cdn_dp_parse_dt() argument
716 struct device *dev = dp->dev; in cdn_dp_parse_dt()
720 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in cdn_dp_parse_dt()
721 if (IS_ERR(dp->grf)) { in cdn_dp_parse_dt()
722 DRM_DEV_ERROR(dev, "cdn-dp needs rockchip,grf property\n"); in cdn_dp_parse_dt()
723 return PTR_ERR(dp->grf); in cdn_dp_parse_dt()
726 dp->regs = devm_platform_ioremap_resource(pdev, 0); in cdn_dp_parse_dt()
727 if (IS_ERR(dp->regs)) { in cdn_dp_parse_dt()
729 return PTR_ERR(dp->regs); in cdn_dp_parse_dt()
732 dp->core_clk = devm_clk_get(dev, "core-clk"); in cdn_dp_parse_dt()
733 if (IS_ERR(dp->core_clk)) { in cdn_dp_parse_dt()
735 return PTR_ERR(dp->core_clk); in cdn_dp_parse_dt()
738 dp->pclk = devm_clk_get(dev, "pclk"); in cdn_dp_parse_dt()
739 if (IS_ERR(dp->pclk)) { in cdn_dp_parse_dt()
741 return PTR_ERR(dp->pclk); in cdn_dp_parse_dt()
744 dp->spdif_clk = devm_clk_get(dev, "spdif"); in cdn_dp_parse_dt()
745 if (IS_ERR(dp->spdif_clk)) { in cdn_dp_parse_dt()
747 return PTR_ERR(dp->spdif_clk); in cdn_dp_parse_dt()
750 dp->grf_clk = devm_clk_get(dev, "grf"); in cdn_dp_parse_dt()
751 if (IS_ERR(dp->grf_clk)) { in cdn_dp_parse_dt()
753 return PTR_ERR(dp->grf_clk); in cdn_dp_parse_dt()
756 dp->spdif_rst = devm_reset_control_get(dev, "spdif"); in cdn_dp_parse_dt()
757 if (IS_ERR(dp->spdif_rst)) { in cdn_dp_parse_dt()
759 return PTR_ERR(dp->spdif_rst); in cdn_dp_parse_dt()
762 dp->dptx_rst = devm_reset_control_get(dev, "dptx"); in cdn_dp_parse_dt()
763 if (IS_ERR(dp->dptx_rst)) { in cdn_dp_parse_dt()
765 return PTR_ERR(dp->dptx_rst); in cdn_dp_parse_dt()
768 dp->core_rst = devm_reset_control_get(dev, "core"); in cdn_dp_parse_dt()
769 if (IS_ERR(dp->core_rst)) { in cdn_dp_parse_dt()
771 return PTR_ERR(dp->core_rst); in cdn_dp_parse_dt()
774 dp->apb_rst = devm_reset_control_get(dev, "apb"); in cdn_dp_parse_dt()
775 if (IS_ERR(dp->apb_rst)) { in cdn_dp_parse_dt()
777 return PTR_ERR(dp->apb_rst); in cdn_dp_parse_dt()
787 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_audio_hw_params() local
795 mutex_lock(&dp->lock); in cdn_dp_audio_hw_params()
796 if (!dp->active) { in cdn_dp_audio_hw_params()
814 ret = cdn_dp_audio_config(dp, &audio); in cdn_dp_audio_hw_params()
816 dp->audio_info = audio; in cdn_dp_audio_hw_params()
819 mutex_unlock(&dp->lock); in cdn_dp_audio_hw_params()
825 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_audio_shutdown() local
828 mutex_lock(&dp->lock); in cdn_dp_audio_shutdown()
829 if (!dp->active) in cdn_dp_audio_shutdown()
832 ret = cdn_dp_audio_stop(dp, &dp->audio_info); in cdn_dp_audio_shutdown()
834 dp->audio_info.format = AFMT_UNUSED; in cdn_dp_audio_shutdown()
836 mutex_unlock(&dp->lock); in cdn_dp_audio_shutdown()
842 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_audio_mute_stream() local
845 mutex_lock(&dp->lock); in cdn_dp_audio_mute_stream()
846 if (!dp->active) { in cdn_dp_audio_mute_stream()
851 ret = cdn_dp_audio_mute(dp, enable); in cdn_dp_audio_mute_stream()
854 mutex_unlock(&dp->lock); in cdn_dp_audio_mute_stream()
861 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_audio_get_eld() local
863 memcpy(buf, dp->connector.eld, min(sizeof(dp->connector.eld), len)); in cdn_dp_audio_get_eld()
872 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_audio_hook_plugged_cb() local
874 mutex_lock(&dp->lock); in cdn_dp_audio_hook_plugged_cb()
875 dp->plugged_cb = fn; in cdn_dp_audio_hook_plugged_cb()
876 dp->codec_dev = codec_dev; in cdn_dp_audio_hook_plugged_cb()
877 cdn_dp_audio_handle_plugged_change(dp, dp->connected); in cdn_dp_audio_hook_plugged_cb()
878 mutex_unlock(&dp->lock); in cdn_dp_audio_hook_plugged_cb()
892 static int cdn_dp_audio_codec_init(struct cdn_dp_device *dp, in cdn_dp_audio_codec_init() argument
902 dp->audio_pdev = platform_device_register_data( in cdn_dp_audio_codec_init()
906 return PTR_ERR_OR_ZERO(dp->audio_pdev); in cdn_dp_audio_codec_init()
909 static int cdn_dp_request_firmware(struct cdn_dp_device *dp) in cdn_dp_request_firmware() argument
915 WARN_ON(!mutex_is_locked(&dp->lock)); in cdn_dp_request_firmware()
917 if (dp->fw_loaded) in cdn_dp_request_firmware()
921 mutex_unlock(&dp->lock); in cdn_dp_request_firmware()
924 ret = request_firmware(&dp->fw, CDN_DP_FIRMWARE, dp->dev); in cdn_dp_request_firmware()
930 DRM_DEV_ERROR(dp->dev, in cdn_dp_request_firmware()
935 dp->fw_loaded = true; in cdn_dp_request_firmware()
940 DRM_DEV_ERROR(dp->dev, "Timed out trying to load firmware\n"); in cdn_dp_request_firmware()
943 mutex_lock(&dp->lock); in cdn_dp_request_firmware()
949 struct cdn_dp_device *dp = container_of(work, struct cdn_dp_device, in cdn_dp_pd_event_work() local
951 struct drm_connector *connector = &dp->connector; in cdn_dp_pd_event_work()
956 mutex_lock(&dp->lock); in cdn_dp_pd_event_work()
958 if (dp->suspended) in cdn_dp_pd_event_work()
961 ret = cdn_dp_request_firmware(dp); in cdn_dp_pd_event_work()
965 dp->connected = true; in cdn_dp_pd_event_work()
968 if (!cdn_dp_connected_port(dp)) { in cdn_dp_pd_event_work()
969 DRM_DEV_INFO(dp->dev, "Not connected. Disabling cdn\n"); in cdn_dp_pd_event_work()
970 dp->connected = false; in cdn_dp_pd_event_work()
973 } else if (!dp->active) { in cdn_dp_pd_event_work()
974 DRM_DEV_INFO(dp->dev, "Connected, not enabled. Enabling cdn\n"); in cdn_dp_pd_event_work()
975 ret = cdn_dp_enable(dp); in cdn_dp_pd_event_work()
977 DRM_DEV_ERROR(dp->dev, "Enable dp failed %d\n", ret); in cdn_dp_pd_event_work()
978 dp->connected = false; in cdn_dp_pd_event_work()
982 } else if (!cdn_dp_check_sink_connection(dp)) { in cdn_dp_pd_event_work()
983 DRM_DEV_INFO(dp->dev, "Connected without sink. Assert hpd\n"); in cdn_dp_pd_event_work()
984 dp->connected = false; in cdn_dp_pd_event_work()
987 } else if (!cdn_dp_check_link_status(dp)) { in cdn_dp_pd_event_work()
988 unsigned int rate = dp->max_rate; in cdn_dp_pd_event_work()
989 unsigned int lanes = dp->max_lanes; in cdn_dp_pd_event_work()
990 struct drm_display_mode *mode = &dp->mode; in cdn_dp_pd_event_work()
992 DRM_DEV_INFO(dp->dev, "Connected with sink. Re-train link\n"); in cdn_dp_pd_event_work()
993 ret = cdn_dp_train_link(dp); in cdn_dp_pd_event_work()
995 dp->connected = false; in cdn_dp_pd_event_work()
996 DRM_DEV_ERROR(dp->dev, "Train link failed %d\n", ret); in cdn_dp_pd_event_work()
1002 (rate != dp->max_rate || lanes != dp->max_lanes)) { in cdn_dp_pd_event_work()
1003 ret = cdn_dp_config_video(dp); in cdn_dp_pd_event_work()
1005 dp->connected = false; in cdn_dp_pd_event_work()
1006 DRM_DEV_ERROR(dp->dev, in cdn_dp_pd_event_work()
1014 mutex_unlock(&dp->lock); in cdn_dp_pd_event_work()
1019 drm_kms_helper_hotplug_event(dp->drm_dev); in cdn_dp_pd_event_work()
1027 struct cdn_dp_device *dp = port->dp; in cdn_dp_pd_event() local
1034 schedule_work(&dp->event_work); in cdn_dp_pd_event()
1041 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_bind() local
1048 ret = cdn_dp_parse_dt(dp); in cdn_dp_bind()
1052 dp->drm_dev = drm_dev; in cdn_dp_bind()
1053 dp->connected = false; in cdn_dp_bind()
1054 dp->active = false; in cdn_dp_bind()
1055 dp->active_port = -1; in cdn_dp_bind()
1056 dp->fw_loaded = false; in cdn_dp_bind()
1058 INIT_WORK(&dp->event_work, cdn_dp_pd_event_work); in cdn_dp_bind()
1060 encoder = &dp->encoder.encoder; in cdn_dp_bind()
1075 connector = &dp->connector; in cdn_dp_bind()
1095 for (i = 0; i < dp->ports; i++) { in cdn_dp_bind()
1096 port = dp->port[i]; in cdn_dp_bind()
1099 ret = devm_extcon_register_notifier(dp->dev, port->extcon, in cdn_dp_bind()
1111 schedule_work(&dp->event_work); in cdn_dp_bind()
1124 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_unbind() local
1125 struct drm_encoder *encoder = &dp->encoder.encoder; in cdn_dp_unbind()
1126 struct drm_connector *connector = &dp->connector; in cdn_dp_unbind()
1128 cancel_work_sync(&dp->event_work); in cdn_dp_unbind()
1134 if (dp->fw_loaded) in cdn_dp_unbind()
1135 release_firmware(dp->fw); in cdn_dp_unbind()
1136 kfree(dp->edid); in cdn_dp_unbind()
1137 dp->edid = NULL; in cdn_dp_unbind()
1147 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_suspend() local
1150 mutex_lock(&dp->lock); in cdn_dp_suspend()
1151 if (dp->active) in cdn_dp_suspend()
1152 ret = cdn_dp_disable(dp); in cdn_dp_suspend()
1153 dp->suspended = true; in cdn_dp_suspend()
1154 mutex_unlock(&dp->lock); in cdn_dp_suspend()
1161 struct cdn_dp_device *dp = dev_get_drvdata(dev); in cdn_dp_resume() local
1163 mutex_lock(&dp->lock); in cdn_dp_resume()
1164 dp->suspended = false; in cdn_dp_resume()
1165 if (dp->fw_loaded) in cdn_dp_resume()
1166 schedule_work(&dp->event_work); in cdn_dp_resume()
1167 mutex_unlock(&dp->lock); in cdn_dp_resume()
1178 struct cdn_dp_device *dp; in cdn_dp_probe() local
1183 dp = devm_kzalloc(dev, sizeof(*dp), GFP_KERNEL); in cdn_dp_probe()
1184 if (!dp) in cdn_dp_probe()
1186 dp->dev = dev; in cdn_dp_probe()
1208 port->dp = dp; in cdn_dp_probe()
1210 dp->port[dp->ports++] = port; in cdn_dp_probe()
1213 if (!dp->ports) { in cdn_dp_probe()
1218 mutex_init(&dp->lock); in cdn_dp_probe()
1219 dev_set_drvdata(dev, dp); in cdn_dp_probe()
1221 cdn_dp_audio_codec_init(dp, dev); in cdn_dp_probe()
1228 struct cdn_dp_device *dp = platform_get_drvdata(pdev); in cdn_dp_remove() local
1230 platform_device_unregister(dp->audio_pdev); in cdn_dp_remove()
1231 cdn_dp_suspend(dp->dev); in cdn_dp_remove()
1239 struct cdn_dp_device *dp = platform_get_drvdata(pdev); in cdn_dp_shutdown() local
1241 cdn_dp_suspend(dp->dev); in cdn_dp_shutdown()
1254 .name = "cdn-dp",