From c7069d551c0d1e4495bc7aea90dd4337bc6ad9b4 Mon Sep 17 00:00:00 2001
From: "deepak.s" <deepak.s@adlinktech.com>
Date: Fri, 17 Oct 2025 10:40:40 +0530
Subject: [PATCH 4/9] LECMTKI1200: Enable dp support

Signed-off-by: deepak.s <deepak.s@adlinktech.com>
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 246 ++++++++++++++++--------------
 1 file changed, 134 insertions(+), 112 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index b820bce36990..3a73516e7c59 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -189,10 +189,8 @@ struct mtk_dp {
 	u8 connector_eld[MAX_ELD_BYTES];
 	bool need_debounce;
 	struct timer_list debounce_timer;
-
 };
 
-
 enum mtk_dp_sdp_type {
 	MTK_DP_SDP_NONE = 0x00,
 	MTK_DP_SDP_ACM = 0x01,
@@ -238,6 +236,7 @@ union mtk_dp_audio_channel_status {
 
 	u8 buf[MTK_DP_IEC_CHANNEL_STATUS_LEN];
 };
+
 static struct regmap_config mtk_dp_regmap_config = {
 	.reg_bits = 32,
 	.val_bits = 32,
@@ -249,7 +248,6 @@ static struct regmap_config mtk_dp_regmap_config = {
 static bool mtk_dp_is_edp(struct mtk_dp *mtk_dp)
 {
 	return mtk_dp->next_bridge != NULL;
-
 }
 
 static struct mtk_dp *mtk_dp_from_bridge(struct drm_bridge *b)
@@ -553,7 +551,7 @@ static void mtk_dp_audio_setup_channels(struct mtk_dp *mtk_dp,
 		AUDIO_2CH_SEL_DP_ENC0_P0_MASK | AUDIO_2CH_EN_DP_ENC0_P0_MASK |
 			AUDIO_8CH_SEL_DP_ENC0_P0_MASK |
 			AUDIO_8CH_EN_DP_ENC0_P0_MASK | AU_EN_DP_ENC0_P0_MASK);
- 
+
 	//audio channel count change reset
 	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC1_P0_33F4, 0, BIT(9));
 
@@ -602,7 +600,6 @@ static void mtk_dp_audio_channel_status_set(struct mtk_dp *mtk_dp,
 	case 24:
 		channel_status.iec.word_len = 0x0B;
 		break;
-
 	}
 
 	// IEC 60958 consumer channel status bits
@@ -627,10 +624,8 @@ static void mtk_dp_audio_sdp_asp_set_channels(struct mtk_dp *mtk_dp,
 			   ASP_HB2_DP_ENC0_P0_MASK | ASP_HB3_DP_ENC0_P0_MASK);
 }
 
-
 static void mtk_dp_audio_set_divider(struct mtk_dp *mtk_dp)
 {
-
 	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_30BC,
 			   AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_DIV_2,
 			   AUDIO_M_CODE_MULT_DIV_SEL_DP_ENC0_P0_MASK);
@@ -902,6 +897,7 @@ static int mtk_dp_aux_do_transfer(struct mtk_dp *mtk_dp, bool is_read, u8 cmd,
 {
 	int ret;
 	u32 reply_cmd;
+
 	dev_dbg(mtk_dp->dev, "AUX transfer is_read(%d) cmd(%d) addr(0x%x) length(%zu)\n",
 		is_read, cmd, addr, length);
 	if (is_read && (length > DP_AUX_MAX_PAYLOAD_BYTES ||
@@ -926,6 +922,7 @@ static int mtk_dp_aux_do_transfer(struct mtk_dp *mtk_dp, bool is_read, u8 cmd,
 	if (!is_read) {
 		if (length)
 			mtk_dp_aux_fill_write_fifo(mtk_dp, buf, length);
+
 		mtk_dp_update_bits(
 			mtk_dp, MTK_DP_AUX_P0_3704,
 			AUX_TX_FIFO_WRITE_DATA_NEW_MODE_TOGGLE_AUX_TX_P0_MASK,
@@ -953,6 +950,7 @@ static int mtk_dp_aux_do_transfer(struct mtk_dp *mtk_dp, bool is_read, u8 cmd,
 
 		usleep_range(MTK_DP_AUX_WRITE_READ_WAIT_TIME_US,
 			     MTK_DP_AUX_WRITE_READ_WAIT_TIME_US * 2);
+		//dev_err(mtk_dp->dev, "AUX err: wait completion timeout\n");
 		return -ETIMEDOUT;
 	}
 
@@ -1035,7 +1033,6 @@ static u32 mtk_dp_swirq_get_clear(struct mtk_dp *mtk_dp)
 	return irq_status;
 }
 
-
 static u32 mtk_dp_hwirq_get_clear(struct mtk_dp *mtk_dp)
 {
 	u8 irq_status = (mtk_dp_read(mtk_dp, MTK_DP_TRANS_P0_3418) &
@@ -1063,6 +1060,7 @@ static void mtk_dp_hwirq_enable(struct mtk_dp *mtk_dp, bool enable)
 	mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_3418, val,
 			   IRQ_MASK_DP_TRANS_P0_MASK);
 }
+
 static void mtk_dp_initialize_settings(struct mtk_dp *mtk_dp)
 {
 	mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_342C,
@@ -1378,7 +1376,6 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable)
 			   VIDEO_MUTE_SEL_DP_ENC0_P0_MASK |
 				   VIDEO_MUTE_SW_DP_ENC0_P0_MASK);
 
-
 	if (mtk_dp_is_edp(mtk_dp))
 		mtk_dp_sip_atf_call(MTK_DP_SIP_ATF_EDP_VIDEO_UNMUTE, enable);
 	else
@@ -1701,6 +1698,7 @@ static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, int target_link_rate,
 	u8 prev_lane_adjust;
 	u8 val;
 
+	pr_notice("xinlei: %s enter", __func__);
 	drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LINK_BW_SET, target_link_rate);
 	drm_dp_dpcd_writeb(&mtk_dp->aux, DP_LANE_COUNT_SET,
 			   target_lane_count | DP_LANE_COUNT_ENHANCED_FRAME_EN);
@@ -1749,6 +1747,7 @@ static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, int target_link_rate,
 						 lane_adjust,
 						 sizeof(lane_adjust));
 				iteration_count++;
+
 				mtk_dp_train_update_swing_pre(
 					mtk_dp, target_lane_count, lane_adjust);
 			}
@@ -1820,6 +1819,7 @@ static int mtk_dp_train_flow(struct mtk_dp *mtk_dp, int target_link_rate,
 						 target_lane_count)) {
 				mtk_dp->train_info.eq_done = true;
 				pass_tps2_3 = true;
+				pr_notice("xinlei: %s training pass", __func__);
 				dev_dbg(mtk_dp->dev, "Link train EQ pass\n");
 				break;
 			}
@@ -1867,8 +1867,6 @@ static bool mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)
 	if (!mtk_dp_plug_state(mtk_dp))
 		return false;
 
-//	if (!mtk_dp_plug_state(mtk_dp))
-//		return false;
 	drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
 	usleep_range(2000, 5000);
 
@@ -1907,7 +1905,7 @@ static bool mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)
 static int mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp,
 						struct mtk_dp_audio_cfg *cfg)
 {
-	+	struct cea_sad *sads;
+	struct cea_sad *sads;
 	int sad_count;
 	int i;
 	int ret = 0;
@@ -1925,6 +1923,7 @@ static int mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp,
 		drm_info(mtk_dp->drm_dev, "The SADs is NULL\n");
 		return 0;
 	}
+
 	for (i = 0; i < sad_count; i++) {
 		int sample_rate;
 		int word_length;
@@ -1947,7 +1946,6 @@ static int mtk_dp_edid_parse_audio_capabilities(struct mtk_dp *mtk_dp,
 	kfree(sads);
 
 	return ret;
-
 }
 
 static void mtk_dp_train_change_mode(struct mtk_dp *mtk_dp)
@@ -1957,79 +1955,7 @@ static void mtk_dp_train_change_mode(struct mtk_dp *mtk_dp)
 
 	usleep_range(2000, 5000);
 }
-static int mtk_dp_train_handler(struct mtk_dp *mtk_dp)
-{
-	int ret = 0;
-
-	if (mtk_dp->train_state == MTK_DP_TRAIN_STATE_NORMAL)
-		return ret;
-
-	switch (mtk_dp->train_state) {
-	case MTK_DP_TRAIN_STATE_STARTUP:
-		mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKCAP;
-		break;
-
-	case MTK_DP_TRAIN_STATE_CHECKCAP:
-		if (mtk_dp_parse_capabilities(mtk_dp)) {
-			mtk_dp->train_info.check_cap_count = 0;
-			mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKEDID;
-		} else {
-			mtk_dp->train_info.check_cap_count++;
-
-			if (mtk_dp->train_info.check_cap_count >
-			    MTK_DP_CHECK_SINK_CAP_TIMEOUT_COUNT) {
-				mtk_dp->train_info.check_cap_count = 0;
-				mtk_dp->train_state = MTK_DP_TRAIN_STATE_DPIDLE;
-				ret = -ETIMEDOUT;
-			}
-		}
-		break;
-
-	case MTK_DP_TRAIN_STATE_CHECKEDID: {
-		int caps_found = mtk_dp_edid_parse_audio_capabilities(
-			mtk_dp, &mtk_dp->info.audio_caps);
-		mtk_dp->audio_enable = caps_found > 0;
-		if (!mtk_dp->audio_enable)
-			memset(&mtk_dp->info.audio_caps, 0,
-			       sizeof(mtk_dp->info.audio_caps));
-	}
-
-		mtk_dp->train_state = MTK_DP_TRAIN_STATE_TRAINING_PRE;
-		break;
-
-	case MTK_DP_TRAIN_STATE_TRAINING_PRE:
-		mtk_dp->train_state = MTK_DP_TRAIN_STATE_TRAINING;
-		break;
-
-	case MTK_DP_TRAIN_STATE_TRAINING:
-		ret = mtk_dp_train_start(mtk_dp);
-		if (!ret) {
-			mtk_dp_video_mute(mtk_dp, true);
-			mtk_dp_audio_mute(mtk_dp, true);
-			mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKTIMING;
-			mtk_dp_fec_enable(mtk_dp, mtk_dp->has_fec);
-		} else if (ret != -EAGAIN) {
-			mtk_dp->train_state = MTK_DP_TRAIN_STATE_DPIDLE;
-		}
-
-		ret = 0;
-		break;
-
-	case MTK_DP_TRAIN_STATE_CHECKTIMING:
-		mtk_dp->train_state = MTK_DP_TRAIN_STATE_NORMAL;
-		break;
-	case MTK_DP_TRAIN_STATE_NORMAL:
-		break;
-	case MTK_DP_TRAIN_STATE_POWERSAVE:
-		break;
-	case MTK_DP_TRAIN_STATE_DPIDLE:
-		break;
-	default:
-		break;
-	}
 
-	return ret;
-}
 static int mtk_dp_train_start(struct mtk_dp *mtk_dp)
 {
 	int ret = 0;
@@ -2112,6 +2038,80 @@ static int mtk_dp_train_start(struct mtk_dp *mtk_dp)
 	return -ETIMEDOUT;
 }
 
+static int mtk_dp_train_handler(struct mtk_dp *mtk_dp)
+{
+	int ret = 0;
+
+	if (mtk_dp->train_state == MTK_DP_TRAIN_STATE_NORMAL)
+		return ret;
+
+	switch (mtk_dp->train_state) {
+	case MTK_DP_TRAIN_STATE_STARTUP:
+		mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKCAP;
+		break;
+
+	case MTK_DP_TRAIN_STATE_CHECKCAP:
+		if (mtk_dp_parse_capabilities(mtk_dp)) {
+			mtk_dp->train_info.check_cap_count = 0;
+			mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKEDID;
+		} else {
+			mtk_dp->train_info.check_cap_count++;
+
+			if (mtk_dp->train_info.check_cap_count >
+			    MTK_DP_CHECK_SINK_CAP_TIMEOUT_COUNT) {
+				mtk_dp->train_info.check_cap_count = 0;
+				mtk_dp->train_state = MTK_DP_TRAIN_STATE_DPIDLE;
+				ret = -ETIMEDOUT;
+			}
+		}
+		break;
+
+	case MTK_DP_TRAIN_STATE_CHECKEDID: {
+		int caps_found = mtk_dp_edid_parse_audio_capabilities(
+			mtk_dp, &mtk_dp->info.audio_caps);
+		mtk_dp->audio_enable = caps_found > 0;
+		if (!mtk_dp->audio_enable)
+			memset(&mtk_dp->info.audio_caps, 0,
+			       sizeof(mtk_dp->info.audio_caps));
+	}
+
+		mtk_dp->train_state = MTK_DP_TRAIN_STATE_TRAINING_PRE;
+		break;
+
+	case MTK_DP_TRAIN_STATE_TRAINING_PRE:
+		mtk_dp->train_state = MTK_DP_TRAIN_STATE_TRAINING;
+		break;
+
+	case MTK_DP_TRAIN_STATE_TRAINING:
+		ret = mtk_dp_train_start(mtk_dp);
+		if (!ret) {
+			mtk_dp_video_mute(mtk_dp, true);
+			mtk_dp_audio_mute(mtk_dp, true);
+			mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKTIMING;
+			mtk_dp_fec_enable(mtk_dp, mtk_dp->has_fec);
+		} else if (ret != -EAGAIN) {
+			mtk_dp->train_state = MTK_DP_TRAIN_STATE_DPIDLE;
+		}
+
+		ret = 0;
+		break;
+
+	case MTK_DP_TRAIN_STATE_CHECKTIMING:
+		mtk_dp->train_state = MTK_DP_TRAIN_STATE_NORMAL;
+		break;
+	case MTK_DP_TRAIN_STATE_NORMAL:
+		break;
+	case MTK_DP_TRAIN_STATE_POWERSAVE:
+		break;
+	case MTK_DP_TRAIN_STATE_DPIDLE:
+		break;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
 static void mtk_dp_video_enable(struct mtk_dp *mtk_dp, bool enable)
 {
 	if (enable) {
@@ -2173,6 +2173,7 @@ static void mtk_dp_video_config(struct mtk_dp *mtk_dp)
 	mtk_dp_set_color_depth(mtk_dp, mtk_dp->info.depth);
 	mtk_dp_set_color_format(mtk_dp, mtk_dp->info.format);
 }
+
 static int mtk_dp_state_handler(struct mtk_dp *mtk_dp)
 {
 	int ret = 0;
@@ -2188,9 +2189,11 @@ static int mtk_dp_state_handler(struct mtk_dp *mtk_dp)
 		if (mtk_dp->train_state == MTK_DP_TRAIN_STATE_NORMAL)
 			mtk_dp->state = MTK_DP_STATE_PREPARE;
 		break;
+
 	case MTK_DP_STATE_PREPARE:
 		mtk_dp_video_config(mtk_dp);
 		mtk_dp_video_enable(mtk_dp, true);
+
 		if (mtk_dp->audio_enable) {
 			mtk_dp_audio_setup(mtk_dp, &mtk_dp->info.audio_caps);
 			mtk_dp_audio_mute(mtk_dp, false);
@@ -2211,6 +2214,7 @@ static int mtk_dp_state_handler(struct mtk_dp *mtk_dp)
 	default:
 		break;
 	}
+
 	return ret;
 }
 
@@ -2235,6 +2239,7 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)
 	struct mtk_dp *mtk_dp = dev;
 	int event;
 	u8 buf[DP_RECEIVER_CAP_SIZE] = {};
+
 	pr_notice("xinlei: %s enter", __func__);
 	event = mtk_dp_plug_state(mtk_dp) ? connector_status_connected :
 						  connector_status_disconnected;
@@ -2249,6 +2254,7 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)
 		dev_info(mtk_dp->dev, "drm_helper_hpd_irq_event\n");
 		drm_helper_hpd_irq_event(mtk_dp->bridge.dev);
 	}
+
 	if (mtk_dp->train_info.cable_state_change) {
 		mtk_dp->train_info.cable_state_change = false;
 
@@ -2283,10 +2289,13 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)
 		}
 	}
 
-	if (!train_info->cable_plugged_in) {
-		mod_timer(&mtk_dp->debounce_timer, jiffies + msecs_to_jiffies(100) - 1);
-		mtk_dp->need_debounce = fals
+	if (mtk_dp->train_info.irq_status & MTK_DP_HPD_INTERRUPT) {
+		dev_info(mtk_dp->dev, "MTK_DP_HPD_INTERRUPT\n");
+		mtk_dp->train_info.irq_status &= ~MTK_DP_HPD_INTERRUPT;
+		mtk_dp_hpd_sink_event(mtk_dp);
+	}
 
+	pr_notice("xinlei: %s exit", __func__);
 	return IRQ_HANDLED;
 }
 
@@ -2297,8 +2306,11 @@ static irqreturn_t mtk_dp_hpd_isr_handler(struct mtk_dp *mtk_dp)
 	u8 hwirq_status = mtk_dp_hwirq_get_clear(mtk_dp);
 	struct mtk_dp_train_info *train_info = &mtk_dp->train_info;
 
+	pr_notice("xinlei: %s enter", __func__);
 	train_info->irq_status |= hwirq_status | swirq_status;
 
+	dev_dbg(mtk_dp->dev, "hpd isr HWIRQ status(0x%x) SWIRQ status(0x%x)\n",
+		hwirq_status, swirq_status);
 	if (!train_info->irq_status)
 		return IRQ_HANDLED;
 
@@ -2315,18 +2327,18 @@ static irqreturn_t mtk_dp_hpd_isr_handler(struct mtk_dp *mtk_dp)
 	if (train_info->irq_status & MTK_DP_HPD_CONNECT) {
 		train_info->irq_status &= ~MTK_DP_HPD_CONNECT;
 		train_info->cable_plugged_in = true;
+		pr_notice("xinlei: %s cable_plugged_in = true", __func__);
 	} else {
 		train_info->irq_status &= ~MTK_DP_HPD_DISCONNECT;
 		train_info->cable_plugged_in = false;
 		mtk_dp->train_state = MTK_DP_TRAIN_STATE_STARTUP;
+		pr_notice("xinlei: %s cable_plugged_in = false", __func__);
 	}
 	train_info->cable_state_change = true;
 
-	if (train_info->cable_state_change) {
-		if (!train_info->cable_plugged_in) {
-			mod_timer(&mtk_dp->debounce_timer, jiffies + msecs_to_jiffies(100) - 1);
-			mtk_dp->need_debounce = false;
-		}
+	if (!train_info->cable_plugged_in) {
+		mod_timer(&mtk_dp->debounce_timer, jiffies + msecs_to_jiffies(100) - 1);
+		mtk_dp->need_debounce = false;
 	}
 
 	return IRQ_WAKE_THREAD;
@@ -2363,10 +2375,10 @@ static int mtk_dp_dt_parse_pdata(struct mtk_dp *mtk_dp,
 	if (IS_ERR(mtk_dp->regs))
 		return PTR_ERR(mtk_dp->regs);
 
-	mtk_dp->dp_tx_clk = devm_clk_get_optional(dev, "faxi");
+	mtk_dp->dp_tx_clk = devm_clk_get(dev, "faxi");
 	if (IS_ERR(mtk_dp->dp_tx_clk)) {
 		ret = PTR_ERR(mtk_dp->dp_tx_clk);
-		dev_info(dev, "Failed to get dptx clock: %d\n", ret);
+		dev_err(dev, "Failed to get dptx clock: %d\n", ret);
 		mtk_dp->dp_tx_clk = NULL;
 	}
 
@@ -2391,16 +2403,20 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
 	enum drm_connector_status ret = connector_status_disconnected;
 	u8 sink_count = 0;
 
+	pr_notice("xinlei: %s enter", __func__);
 	if (mtk_dp_is_edp(mtk_dp))
 		return connector_status_connected;
 
 	if (mtk_dp_plug_state(mtk_dp)) {
 		drm_dp_dpcd_readb(&mtk_dp->aux, DP_SINK_COUNT, &sink_count);
-		if (DP_GET_SINK_COUNT(sink_count))
+		if (DP_GET_SINK_COUNT(sink_count)) {
 			ret = connector_status_connected;
+			pr_notice("xinlei: %s mid, ret = %d", __func__, ret);
+		}
 	}
 
 	mtk_dp_update_plugged_status(mtk_dp);
+	pr_notice("xinlei: %s exit, ret = %d", __func__, ret);
 	return ret;
 }
 
@@ -2420,7 +2436,6 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,
 	if (mtk_dp_plug_state(mtk_dp))
 		new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc);
 
-
 	if (!enabled)
 		drm_bridge_chain_post_disable(bridge);
 
@@ -2454,6 +2469,7 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux,
 	if (!mtk_dp->train_info.cable_plugged_in ||
 	    mtk_dp->train_info.irq_status & MTK_DP_HPD_DISCONNECT) {
 		mtk_dp->train_state = MTK_DP_TRAIN_STATE_CHECKCAP;
+		dev_err(mtk_dp->dev, "AUX err: DP noconnected\n");
 		err = -EAGAIN;
 		goto err;
 	}
@@ -2489,7 +2505,6 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux,
 			if (ret == 0)
 				break;
 			usleep_range(500, 600);
-
 		}
 	} else {
 		while (accessed_bytes < msg->size) {
@@ -2529,7 +2544,6 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux,
 	return msg->size;
 }
 
-
 static void mtk_dp_aux_init(struct mtk_dp *mtk_dp)
 {
 	drm_dp_aux_init(&mtk_dp->aux);
@@ -2537,7 +2551,6 @@ static void mtk_dp_aux_init(struct mtk_dp *mtk_dp)
 	mtk_dp->aux.transfer = mtk_dp_aux_transfer;
 }
 
-
 static void mtk_dp_poweroff(struct mtk_dp *mtk_dp)
 {
 	mutex_lock(&mtk_dp->dp_lock);
@@ -2566,6 +2579,7 @@ static int mtk_dp_poweron(struct mtk_dp *mtk_dp)
 		dev_err(mtk_dp->dev, "Failed to initialize phy: %d\n", ret);
 		goto err_phy_init;
 	}
+
 	mtk_dp_init_port(mtk_dp);
 	mtk_dp_power_enable(mtk_dp);
 	mtk_dp_hwirq_enable(mtk_dp, true);
@@ -2585,7 +2599,7 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge,
 	struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
 	int ret;
 
-
+	pr_notice("xinlei: %s enter", __func__);
 	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
 		dev_err(mtk_dp->dev, "Driver does not provide a connector!");
 		return -EINVAL;
@@ -2607,6 +2621,7 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge,
 
 	mtk_dp->drm_dev = bridge->dev;
 
+	pr_notice("xinlei: %s exit", __func__);
 	return 0;
 
 err_bridge_attach:
@@ -2619,6 +2634,7 @@ static void mtk_dp_bridge_detach(struct drm_bridge *bridge)
 	struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
 
 	mtk_dp->drm_dev = NULL;
+
 	mtk_dp_poweroff(mtk_dp);
 }
 
@@ -2626,6 +2642,7 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,
 					 struct drm_bridge_state *old_state)
 {
 	struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
+
 	if (mtk_dp_plug_state(mtk_dp)) {
 		drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
 		usleep_range(2000, 3000);
@@ -2659,7 +2676,7 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,
 	struct drm_connector_state *conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
-	int ret=0;
+	int ret = 0;
 	int i;
 
 	pr_notice("xinlei: %s enter", __func__);
@@ -2721,6 +2738,7 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,
 
 	mtk_dp->enabled = true;
 	mtk_dp_update_plugged_status(mtk_dp);
+
 	dev_dbg(mtk_dp->dev, "DPTX calc pixel clock = %d MHz\n",
 		mtk_dp_read(mtk_dp, 0x33c8) * mtk_dp->train_info.link_rate * 27 / 0x8000);
 	pr_notice("xinlei: %s exit", __func__);
@@ -2748,6 +2766,7 @@ mtk_dp_bridge_mode_valid(struct drm_bridge *bridge,
 
 	return MODE_OK;
 }
+
 static u32 *mtk_dp_bridge_atomic_get_output_bus_fmts(
 	struct drm_bridge *bridge, struct drm_bridge_state *bridge_state,
 	struct drm_crtc_state *crtc_state,
@@ -2769,6 +2788,7 @@ static const u32 mt8195_input_fmts[] = {
 	MEDIA_BUS_FMT_YUV8_1X24,
 	MEDIA_BUS_FMT_YUYV8_1X16,
 };
+
 static u32 *mtk_dp_bridge_atomic_get_input_bus_fmts(
 	struct drm_bridge *bridge, struct drm_bridge_state *bridge_state,
 	struct drm_crtc_state *crtc_state,
@@ -2781,7 +2801,7 @@ static u32 *mtk_dp_bridge_atomic_get_input_bus_fmts(
 	struct drm_display_info *display_info =
 		&conn_state->connector->display_info;
 	u32 rx_linkrate;
-	
+
 	rx_linkrate = (u32)mtk_dp->train_info.link_rate * 27000;
 	*num_input_fmts = 0;
 	input_fmts = kcalloc(ARRAY_SIZE(mt8195_input_fmts), sizeof(*input_fmts),
@@ -2818,9 +2838,9 @@ static int mtk_dp_bridge_atomic_check(struct drm_bridge *bridge,
 
 	input_bus_format = bridge_state->input_bus_cfg.format;
 
-	dev_dbg(mtk_dp->dev, "input format 0x%04x, output format 0x%04x\n",
-		bridge_state->input_bus_cfg.format,
-		bridge_state->output_bus_cfg.format);
+	dev_info(mtk_dp->dev, "input format 0x%04x, output format 0x%04x\n",
+		 bridge_state->input_bus_cfg.format,
+		 bridge_state->output_bus_cfg.format);
 
 	mtk_dp->input_fmt = input_bus_format;
 	if (mtk_dp->input_fmt == MEDIA_BUS_FMT_YUYV8_1X16)
@@ -2867,6 +2887,7 @@ static int mtk_dp_audio_hw_params(struct device *dev, void *data,
 	cfg.channels = params->cea.channels;
 	cfg.sample_rate = params->sample_rate;
 	cfg.word_length_bits = 24;
+
 	mtk_dp_audio_setup(mtk_dp, &cfg);
 
 	return 0;
@@ -2898,6 +2919,8 @@ static int mtk_dp_audio_get_eld(struct device *dev, void *data, uint8_t *buf,
 	else
 		memset(buf, 0, len);
 
+	dev_dbg(mtk_dp->dev, "get eld: %*ph\n", (int)len, buf);
+
 	return 0;
 }
 
@@ -2954,16 +2977,19 @@ static int mtk_dp_probe(struct platform_device *pdev)
 	int irq_num = 0;
 	struct drm_panel *panel = NULL;
 
+	pr_notice("xinlei: %s enter", __func__);
 	mtk_dp = devm_kzalloc(dev, sizeof(*mtk_dp), GFP_KERNEL);
 	if (!mtk_dp)
 		return -ENOMEM;
 
 	mtk_dp->dev = dev;
+
 	irq_num = platform_get_irq(pdev, 0);
 	if (irq_num < 0) {
 		dev_err(dev, "failed to request dp irq resource\n");
 		return -EPROBE_DEFER;
 	}
+
 	ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel,
 					  &mtk_dp->next_bridge);
 	if (ret == -ENODEV) {
@@ -2985,8 +3011,8 @@ static int mtk_dp_probe(struct platform_device *pdev)
 			return -EPROBE_DEFER;
 		}
 	}
-	ret = mtk_dp_dt_parse_pdata(mtk_dp, pdev);
 
+	ret = mtk_dp_dt_parse_pdata(mtk_dp, pdev);
 	if (ret)
 		return ret;
 
@@ -3020,7 +3046,6 @@ static int mtk_dp_probe(struct platform_device *pdev)
 							PLATFORM_DEVID_AUTO,
 							&mtk_dp->regs,
 							sizeof(&mtk_dp->regs));
-
 	if (IS_ERR(mtk_dp->phy_dev)) {
 		dev_err(dev, "Failed to create device mediatek-dp-phy: %ld\n",
 			PTR_ERR(mtk_dp->phy_dev));
@@ -3038,13 +3063,11 @@ static int mtk_dp_probe(struct platform_device *pdev)
 
 	mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs;
 	mtk_dp->bridge.of_node = dev->of_node;
-
 	if (mtk_dp_is_edp(mtk_dp))
 		mtk_dp->bridge.type = DRM_MODE_CONNECTOR_eDP;
 	else
 		mtk_dp->bridge.type = DRM_MODE_CONNECTOR_DisplayPort;
 
-
 	mtk_dp->need_debounce = true;
 	timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
 
@@ -3055,6 +3078,7 @@ static int mtk_dp_probe(struct platform_device *pdev)
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
 
+	pr_notice("xinlei: %s exit", __func__);
 	return 0;
 }
 
@@ -3083,7 +3107,6 @@ static int mtk_dp_suspend(struct device *dev)
 		usleep_range(2000, 3000);
 	}
 
-
 	mtk_dp_power_disable(mtk_dp);
 	mtk_dp_hwirq_enable(mtk_dp, false);
 
@@ -3100,7 +3123,6 @@ static int mtk_dp_resume(struct device *dev)
 
 	mtk_dp_init_port(mtk_dp);
 	mtk_dp_power_enable(mtk_dp);
-
 	mtk_dp_hwirq_enable(mtk_dp, true);
 
 	return 0;
-- 
2.43.0

