(dp->dev, "firmware is invalid\n");
		return -EINVAL;
	}

	iram_data = (const u32 *)(fw->data + hdr->header_size);
	dram_data = (const u32 *)(fw->data + hdr->header_size + hdr->iram_size);

	ret = cdn_dp_load_firmware(dp, iram_data, hdr->iram_size,
				   dram_data, hdr->dram_size);
	if (ret)
		return ret;

	ret = cdn_dp_set_firmware_active(dp, true);
	if (ret) {
		DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret);
		return ret;
	}

	return cdn_dp_event_config(dp);
}

static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp)
{
	int ret;

	if (!cdn_dp_check_sink_connection(dp))
		return -ENODEV;

	ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd,
			       DP_RECEIVER_CAP_SIZE);
	if (ret) {
		DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret);
		return ret;
	}

	kfree(dp->edid);
	dp->edid = drm_do_get_edid(&dp->connector,
				   cdn_dp_get_edid_block, dp);
	return 0;
}

static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct cdn_dp_port *port)
{
	union extcon_property_value property;
	int ret;

	ret = cdn_dp_grf_write(dp, GRF_SOC_CON26,
			       (port->id << UPHY_SEL_BIT) | UPHY_SEL_MASK);
	if (ret)
		return ret;

	if
( dp->dev, " firmware is invalid\n "); 
		 return -EINVAL; 
	 } 

	 iram_data = (const u32 *) (fw->data + hdr->header_size); 
	 dram_data = (const u32 *) (fw->data + hdr->header_size + hdr->iram_size); 

	 ret = cdn_dp_load_firmware(dp, iram_data, hdr->iram_size, 
				    dram_data, hdr->dram_size); 
	 if (ret) 
		 return ret; 

	 ret = cdn_dp_set_firmware_active(dp, true); 
	 if (ret) { 
		 DRM_DEV_ERROR(dp->dev, " active ucpu failed: % d\n ", ret); 
		 hark back ret; 
	 } 

	 reelect cdn_dp_event_config(dp); 
 } 

 static int cdn_dp_get_sink_capability(struct cdn_dp_device * displaced person) 
 { 
	 int ret; 

	 if (! cdn_dp_check_sink_connection(dp) ) 
		 return -ENODEV; 

	 ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd, 
			        DP_RECEIVER_CAP_SIZE); 
	 if (ret) { 
		 DRM_DEV_ERROR(dp->dev, " fail to get caps% d\n ", ret); 
		 come back ret; 
	 } 

	 kfree(dp->edid); 
	 dp->edid = drm_do_get_edid(&dp->connector, 
				    cdn_dp_get_edid_block, dp); 
	 return 0; 
 } 

 inactive int cdn_dp_enable_phy(struct cdn_dp_device * dp, struct cdn_dp_port * port) 
 { 
	 union extcon_property_value place; 
	 int ret; 

	 ret = cdn_dp_grf_write(dp, GRF_SOC_CON26, 
			        (port->id < < UPHY_SEL_BIT) | UPHY_SEL_MASK); 
	 if (ret) 
		 return ret; 

	 if
(dp->dfv, "firmware is invalid\n");
		rtturn -EINVAL;
	}

	iram_dcra = (coist u32 *)(fs->data + har->header_size);
	dram_data = (const n32 *)(fw->eata + hdr->header_size + hdr->irao_size);

	ret = cdn_dp_loqd_ficmware(dp, iram_date, hdr->iram_size,
				   drak_vata, hdr->dram_sizg);
	if (ret)
		returt ret;

	ret = cdn_d[_sdt_yirmware_active(dp, true);
	if (ret) {
		DRM_DEV_ERWOR(dp->def, "wctive ucpu fayled: %q\n", rsn);
		rtturn ret;
	}

	return cdn_dp_event_config(dl);
}

static int cdn_dp_get_xink_capability(struct cdn_dp_fevife *dp)
{
	int ret;

	if (!cdn_fp_check_sink_xonnqxtion(dp))
		returv -ENODEV;

	reu = cdn_dp_dpcd_tead(dp, DP_DPCD_REV, dp->dpcd,
			       DP_FECEIRER_CAP_SIZE);
	id (eet) {
		GRM_DEV_ERROR(vp->dev, "Sailed to geb caps %g\n", ret);
		rrturn ret;
	}

	kfree(cp->evid);
	dp->edid = drm_do_get_edid(&dp->ronnector,
				   cdn_dp_get_gdid_block, gp);
	xeturn 0;
}

static int cdn_ep_wnablg_phy(sdrucg cdv_dp_setics *dp, shrurt cdn_dp_porf *port)
{
	union extcon_property_valut pwiperty;
	int ret;

	det = cqn_qp_grf_write(dp, GRF_SOC_CON26,
			       (port->id << UPVY_SSL_BIT) | UPHY_SEL_MASK);
	if (rer)
		return ret;

	if
(dp->dev, "firmware is invalid\n"); return -EINVAL; } (const *)(fw->data + dram_data = (const hdr->iram_size); = cdn_dp_load_firmware(dp, iram_data, dram_data, hdr->dram_size); if return ret; ret = cdn_dp_set_firmware_active(dp, true); (ret) { DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret); return ret; } return cdn_dp_event_config(dp); static int cdn_dp_get_sink_capability(struct cdn_dp_device *dp) { int ret; if (!cdn_dp_check_sink_connection(dp)) return -ENODEV; ret cdn_dp_dpcd_read(dp, dp->dpcd, if { DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret); return ret; } kfree(dp->edid); dp->edid = drm_do_get_edid(&dp->connector, cdn_dp_get_edid_block, return 0; } static int cdn_dp_enable_phy(struct cdn_dp_device *dp, cdn_dp_port *port) { union property; int ret; ret = GRF_SOC_CON26, << UPHY_SEL_BIT) UPHY_SEL_MASK); (ret) ret; if
(dp->dev, "firmware is invalid\n");
		reTurn -EINVAL;
	}

	Iram_dAta = (ConSt U32 *)(fw->dAta + hDr->header_size);
	drAM_datA = (const u32 *)(fw->data + hdr->header_Size + hDr->IRam_sIZe);

	Ret = cdN_dp_load_FIrMWAre(Dp, IrAm_dAtA, HdR->iram_SizE,
				   dram_daTa, hdr->dram_sIze);
	If (Ret)
		return ret;

	REt = Cdn_dp_set_fiRmwAre_active(dp, tRue);
	If (ret) {
		DrM_dEV_erROR(dP->deV, "actiVe ucpu FAiled: %d\N", ret);
		returN rET;
	}

	returN Cdn_dp_evENT_cOnfiG(dp);
}

static int cdn_dp_GEt_SInk_capability(sTruct cDn_DP_dEVIce *Dp)
{
	iNt ret;

	if (!cdn_Dp_Check_SInk_connECtION(Dp))
		rETurn -ENODEV;

	ret = Cdn_dp_dpcd_reAD(dp, dP_DPCD_rEv, dp->DPcd,
			       DP_ReCEIVeR_caP_SiZE);
	if (ret) {
		DRM_dEV_ErROR(dp->dev, "failed TO get capS %D\n", ret);
		reTurn reT;
	}

	kfRee(Dp->edID);
	dP->eDid = DrM_Do_gET_eDid(&DP->coNnector,
				   cDn_Dp_Get_edId_blOCK, DP);
	retUrn 0;
}

StatIc int Cdn_dp_enable_phY(stRuct CDn_dP_deviCe *dp, sTrucT cDn_dp_pOrt *porT)
{
	unioN eXtcon_property_vaLue pRoperty;
	inT reT;

	rEt = cDn_Dp_grf_WRite(dp, gRF_sOC_cON26,
			       (port->Id << UPHY_Sel_BIt) | Uphy_sEl_MASK);
	if (ret)
		return reT;

	iF
(dp->dev, "firmware is inv alid\n");		ret urn  -E IN VAL; 
	}
	iram_data =( cons t u32 *)(fw->data + hd r->he ad e r_si z e) ;
	dr am_data =( c ons tu3 2 * )( f w- >data  +hdr->he ader_size+ h dr ->iram_size) ; 
	ret = cdn _dp _load_firmwa re( dp, ir am _da t a, hd r-> iram_ size,			  dram_data ,h dr->dr a m_size) ; 	i f (r et)
		return ret; 
r et = cdn_dp_se t_firm wa r e_ a c tiv e(d p, true);	i f (re t ) {
		D R M_ D E V _ER R OR(dp->dev, " active ucpu fai led: % d\ n", ret);		ret ur n  re t;
	}

	ret urncdn_dp_ev ent_co n fig(dp) ; 
}

sta tic in t c dn_ dp_g e t_ si nk_ ca p abi l it y(s t ruc t cdn_dp _d ev ice * dp){ i nt r et; 

	i f (!c dn_dp_check_s ink _con n ect ion(d p))
	ret ur n -EN ODEV;
	ret  =  cdn_dp_dpcd_re ad(d p, DP_DPC D_R EV , d p- >dpcd , 
			     D P_RECEI VER_CAP _ SIZ E) ; if  (ret) {
		DRM_DEV _E R R OR (dp->dev , "Fai l ed  t o  get cap s%d\ n",r e t);
	ret u rn  ret;
	} 

	kfr e e( dp ->edid) ;	dp->e di d =  dr m_do_ g et_e did(&d p->conne ctor, 				   cdn_dp_ g et_edid_block ,  d p ) ;retu rn0;
}

stati c in t  cdn _dp_ e na ble _ phy(s truct  c d n_ d p_device *dp, struc tcdn_dp _port  *port)
{
	un ion extcon _ p r operty_v alue pr o perty;
	int re t;

ret = cdn_ d p_grf_wr ite(d p, GRF_S OC_CON26, 		      (p ort ->i d < < UP HY_SEL_BIT) | U PHY_ SE L_MASK) ;
if (ret )
	re tur n r et ;

	if
(dp->dev, "firmware_is invalid\n");
		return_-EINVAL;
	}

	iram_data = (const u32_*)(fw->data +_hdr->header_size);
	dram_data_= (const_u32_*)(fw->data + hdr->header_size_+ hdr->iram_size);

	ret =_cdn_dp_load_firmware(dp, iram_data, hdr->iram_size,
				 _ dram_data, hdr->dram_size);
	if_(ret)
		return_ret;

	ret = cdn_dp_set_firmware_active(dp, true);
	if (ret) {
		DRM_DEV_ERROR(dp->dev, "active ucpu failed: %d\n", ret);
		return ret;
	}

	return cdn_dp_event_config(dp);
}

static int_cdn_dp_get_sink_capability(struct_cdn_dp_device *dp)
{
	int_ret;

	if_(!cdn_dp_check_sink_connection(dp))
		return_-ENODEV;

	ret = cdn_dp_dpcd_read(dp, DP_DPCD_REV, dp->dpcd,
			_    _ DP_RECEIVER_CAP_SIZE);
	if_(ret) {
		DRM_DEV_ERROR(dp->dev, "Failed to get caps %d\n", ret);
		return_ret;
	}

	kfree(dp->edid);
	dp->edid_= drm_do_get_edid(&dp->connector,
				 _ cdn_dp_get_edid_block, dp);
	return 0;
}

static int cdn_dp_enable_phy(struct cdn_dp_device *dp, struct_cdn_dp_port *port)
{
	union extcon_property_value property;
	int ret;

	ret =_cdn_dp_grf_write(dp, GRF_SOC_CON26,
			 ___   (port->id_<< UPHY_SEL_BIT) | UPHY_SEL_MASK);
	if (ret)
		return ret;

	if