Lines Matching refs:hdmi
139 int (*configure)(struct dw_hdmi *hdmi,
205 void (*enable_audio)(struct dw_hdmi *hdmi);
206 void (*disable_audio)(struct dw_hdmi *hdmi);
224 static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset) in hdmi_writeb() argument
226 regmap_write(hdmi->regm, offset << hdmi->reg_shift, val); in hdmi_writeb()
229 static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset) in hdmi_readb() argument
233 regmap_read(hdmi->regm, offset << hdmi->reg_shift, &val); in hdmi_readb()
238 static void handle_plugged_change(struct dw_hdmi *hdmi, bool plugged) in handle_plugged_change() argument
240 if (hdmi->plugged_cb && hdmi->codec_dev) in handle_plugged_change()
241 hdmi->plugged_cb(hdmi->codec_dev, plugged); in handle_plugged_change()
244 int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn, in dw_hdmi_set_plugged_cb() argument
249 mutex_lock(&hdmi->mutex); in dw_hdmi_set_plugged_cb()
250 hdmi->plugged_cb = fn; in dw_hdmi_set_plugged_cb()
251 hdmi->codec_dev = codec_dev; in dw_hdmi_set_plugged_cb()
252 plugged = hdmi->last_connector_result == connector_status_connected; in dw_hdmi_set_plugged_cb()
253 handle_plugged_change(hdmi, plugged); in dw_hdmi_set_plugged_cb()
254 mutex_unlock(&hdmi->mutex); in dw_hdmi_set_plugged_cb()
260 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg) in hdmi_modb() argument
262 regmap_update_bits(hdmi->regm, reg << hdmi->reg_shift, mask, data); in hdmi_modb()
265 static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg, in hdmi_mask_writeb() argument
268 hdmi_modb(hdmi, data << shift, mask, reg); in hdmi_mask_writeb()
271 static void dw_hdmi_i2c_init(struct dw_hdmi *hdmi) in dw_hdmi_i2c_init() argument
273 hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL, in dw_hdmi_i2c_init()
276 hdmi_writeb(hdmi, HDMI_PHY_I2CM_CTLINT_ADDR_NAC_POL | in dw_hdmi_i2c_init()
281 hdmi_writeb(hdmi, 0x00, HDMI_I2CM_SOFTRSTZ); in dw_hdmi_i2c_init()
284 hdmi_writeb(hdmi, 0x00, HDMI_I2CM_DIV); in dw_hdmi_i2c_init()
287 hdmi_writeb(hdmi, HDMI_I2CM_INT_DONE_POL, HDMI_I2CM_INT); in dw_hdmi_i2c_init()
288 hdmi_writeb(hdmi, HDMI_I2CM_CTLINT_NAC_POL | HDMI_I2CM_CTLINT_ARB_POL, in dw_hdmi_i2c_init()
292 hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE, in dw_hdmi_i2c_init()
296 hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE, in dw_hdmi_i2c_init()
300 static bool dw_hdmi_i2c_unwedge(struct dw_hdmi *hdmi) in dw_hdmi_i2c_unwedge() argument
303 if (!hdmi->unwedge_state) in dw_hdmi_i2c_unwedge()
306 dev_info(hdmi->dev, "Attempting to unwedge stuck i2c bus\n"); in dw_hdmi_i2c_unwedge()
340 pinctrl_select_state(hdmi->pinctrl, hdmi->unwedge_state); in dw_hdmi_i2c_unwedge()
342 pinctrl_select_state(hdmi->pinctrl, hdmi->default_state); in dw_hdmi_i2c_unwedge()
347 static int dw_hdmi_i2c_wait(struct dw_hdmi *hdmi) in dw_hdmi_i2c_wait() argument
349 struct dw_hdmi_i2c *i2c = hdmi->i2c; in dw_hdmi_i2c_wait()
355 if (!dw_hdmi_i2c_unwedge(hdmi)) in dw_hdmi_i2c_wait()
371 static int dw_hdmi_i2c_read(struct dw_hdmi *hdmi, in dw_hdmi_i2c_read() argument
374 struct dw_hdmi_i2c *i2c = hdmi->i2c; in dw_hdmi_i2c_read()
378 dev_dbg(hdmi->dev, "set read register address to 0\n"); in dw_hdmi_i2c_read()
386 hdmi_writeb(hdmi, i2c->slave_reg++, HDMI_I2CM_ADDRESS); in dw_hdmi_i2c_read()
388 hdmi_writeb(hdmi, HDMI_I2CM_OPERATION_READ_EXT, in dw_hdmi_i2c_read()
391 hdmi_writeb(hdmi, HDMI_I2CM_OPERATION_READ, in dw_hdmi_i2c_read()
394 ret = dw_hdmi_i2c_wait(hdmi); in dw_hdmi_i2c_read()
398 *buf++ = hdmi_readb(hdmi, HDMI_I2CM_DATAI); in dw_hdmi_i2c_read()
405 static int dw_hdmi_i2c_write(struct dw_hdmi *hdmi, in dw_hdmi_i2c_write() argument
408 struct dw_hdmi_i2c *i2c = hdmi->i2c; in dw_hdmi_i2c_write()
422 hdmi_writeb(hdmi, *buf++, HDMI_I2CM_DATAO); in dw_hdmi_i2c_write()
423 hdmi_writeb(hdmi, i2c->slave_reg++, HDMI_I2CM_ADDRESS); in dw_hdmi_i2c_write()
424 hdmi_writeb(hdmi, HDMI_I2CM_OPERATION_WRITE, in dw_hdmi_i2c_write()
427 ret = dw_hdmi_i2c_wait(hdmi); in dw_hdmi_i2c_write()
438 struct dw_hdmi *hdmi = i2c_get_adapdata(adap); in dw_hdmi_i2c_xfer() local
439 struct dw_hdmi_i2c *i2c = hdmi->i2c; in dw_hdmi_i2c_xfer()
452 dev_dbg(hdmi->dev, "xfer: num: %d, addr: %#x\n", num, addr); in dw_hdmi_i2c_xfer()
456 dev_dbg(hdmi->dev, in dw_hdmi_i2c_xfer()
466 hdmi_writeb(hdmi, 0x00, HDMI_IH_MUTE_I2CM_STAT0); in dw_hdmi_i2c_xfer()
469 hdmi_writeb(hdmi, addr, HDMI_I2CM_SLAVE); in dw_hdmi_i2c_xfer()
478 dev_dbg(hdmi->dev, "xfer: num: %d/%d, len: %d, flags: %#x\n", in dw_hdmi_i2c_xfer()
482 hdmi_writeb(hdmi, DDC_SEGMENT_ADDR, HDMI_I2CM_SEGADDR); in dw_hdmi_i2c_xfer()
483 hdmi_writeb(hdmi, *msgs[i].buf, HDMI_I2CM_SEGPTR); in dw_hdmi_i2c_xfer()
486 ret = dw_hdmi_i2c_read(hdmi, msgs[i].buf, in dw_hdmi_i2c_xfer()
489 ret = dw_hdmi_i2c_write(hdmi, msgs[i].buf, in dw_hdmi_i2c_xfer()
500 hdmi_writeb(hdmi, HDMI_IH_I2CM_STAT0_ERROR | HDMI_IH_I2CM_STAT0_DONE, in dw_hdmi_i2c_xfer()
518 static struct i2c_adapter *dw_hdmi_i2c_adapter(struct dw_hdmi *hdmi) in dw_hdmi_i2c_adapter() argument
524 i2c = devm_kzalloc(hdmi->dev, sizeof(*i2c), GFP_KERNEL); in dw_hdmi_i2c_adapter()
534 adap->dev.parent = hdmi->dev; in dw_hdmi_i2c_adapter()
537 i2c_set_adapdata(adap, hdmi); in dw_hdmi_i2c_adapter()
541 dev_warn(hdmi->dev, "cannot add %s I2C adapter\n", adap->name); in dw_hdmi_i2c_adapter()
542 devm_kfree(hdmi->dev, i2c); in dw_hdmi_i2c_adapter()
546 hdmi->i2c = i2c; in dw_hdmi_i2c_adapter()
548 dev_info(hdmi->dev, "registered %s I2C bus driver\n", adap->name); in dw_hdmi_i2c_adapter()
553 static void hdmi_set_cts_n(struct dw_hdmi *hdmi, unsigned int cts, in hdmi_set_cts_n() argument
557 hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); in hdmi_set_cts_n()
560 hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_N_SHIFT_MASK, HDMI_AUD_CTS3); in hdmi_set_cts_n()
564 hdmi_writeb(hdmi, ((cts >> 16) & in hdmi_set_cts_n()
569 hdmi_writeb(hdmi, 0, HDMI_AUD_CTS3); in hdmi_set_cts_n()
570 hdmi_writeb(hdmi, (cts >> 8) & 0xff, HDMI_AUD_CTS2); in hdmi_set_cts_n()
571 hdmi_writeb(hdmi, cts & 0xff, HDMI_AUD_CTS1); in hdmi_set_cts_n()
573 hdmi_writeb(hdmi, (n >> 16) & 0x0f, HDMI_AUD_N3); in hdmi_set_cts_n()
574 hdmi_writeb(hdmi, (n >> 8) & 0xff, HDMI_AUD_N2); in hdmi_set_cts_n()
575 hdmi_writeb(hdmi, n & 0xff, HDMI_AUD_N1); in hdmi_set_cts_n()
648 void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi, in dw_hdmi_set_channel_status() argument
655 hdmi_writeb(hdmi, channel_status[3], HDMI_FC_AUDSCHNLS7); in dw_hdmi_set_channel_status()
656 hdmi_writeb(hdmi, channel_status[4], HDMI_FC_AUDSCHNLS8); in dw_hdmi_set_channel_status()
660 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, in hdmi_set_clk_regenerator() argument
670 config3 = hdmi_readb(hdmi, HDMI_CONFIG3_ID); in hdmi_set_clk_regenerator()
685 dev_dbg(hdmi->dev, "%s: fs=%uHz ftdms=%lu.%03luMHz N=%d cts=%d\n", in hdmi_set_clk_regenerator()
693 spin_lock_irq(&hdmi->audio_lock); in hdmi_set_clk_regenerator()
694 hdmi->audio_n = n; in hdmi_set_clk_regenerator()
695 hdmi->audio_cts = cts; in hdmi_set_clk_regenerator()
696 hdmi_set_cts_n(hdmi, cts, hdmi->audio_enable ? n : 0); in hdmi_set_clk_regenerator()
697 spin_unlock_irq(&hdmi->audio_lock); in hdmi_set_clk_regenerator()
700 static void hdmi_init_clk_regenerator(struct dw_hdmi *hdmi) in hdmi_init_clk_regenerator() argument
702 mutex_lock(&hdmi->audio_mutex); in hdmi_init_clk_regenerator()
703 hdmi_set_clk_regenerator(hdmi, 74250000, hdmi->sample_rate); in hdmi_init_clk_regenerator()
704 mutex_unlock(&hdmi->audio_mutex); in hdmi_init_clk_regenerator()
707 static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi) in hdmi_clk_regenerator_update_pixel_clock() argument
709 mutex_lock(&hdmi->audio_mutex); in hdmi_clk_regenerator_update_pixel_clock()
710 hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mtmdsclock, in hdmi_clk_regenerator_update_pixel_clock()
711 hdmi->sample_rate); in hdmi_clk_regenerator_update_pixel_clock()
712 mutex_unlock(&hdmi->audio_mutex); in hdmi_clk_regenerator_update_pixel_clock()
715 void dw_hdmi_set_sample_width(struct dw_hdmi *hdmi, unsigned int width) in dw_hdmi_set_sample_width() argument
717 mutex_lock(&hdmi->audio_mutex); in dw_hdmi_set_sample_width()
718 hdmi->sample_width = width; in dw_hdmi_set_sample_width()
719 mutex_unlock(&hdmi->audio_mutex); in dw_hdmi_set_sample_width()
723 void dw_hdmi_set_sample_non_pcm(struct dw_hdmi *hdmi, unsigned int non_pcm) in dw_hdmi_set_sample_non_pcm() argument
725 mutex_lock(&hdmi->audio_mutex); in dw_hdmi_set_sample_non_pcm()
726 hdmi->sample_non_pcm = non_pcm; in dw_hdmi_set_sample_non_pcm()
727 mutex_unlock(&hdmi->audio_mutex); in dw_hdmi_set_sample_non_pcm()
731 void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate) in dw_hdmi_set_sample_rate() argument
733 mutex_lock(&hdmi->audio_mutex); in dw_hdmi_set_sample_rate()
734 hdmi->sample_rate = rate; in dw_hdmi_set_sample_rate()
735 hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mtmdsclock, in dw_hdmi_set_sample_rate()
736 hdmi->sample_rate); in dw_hdmi_set_sample_rate()
737 mutex_unlock(&hdmi->audio_mutex); in dw_hdmi_set_sample_rate()
741 void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt) in dw_hdmi_set_channel_count() argument
745 mutex_lock(&hdmi->audio_mutex); in dw_hdmi_set_channel_count()
746 hdmi->channels = cnt; in dw_hdmi_set_channel_count()
757 hdmi_modb(hdmi, layout, HDMI_FC_AUDSCONF_AUD_PACKET_LAYOUT_MASK, in dw_hdmi_set_channel_count()
761 hdmi_modb(hdmi, (cnt - 1) << HDMI_FC_AUDICONF0_CC_OFFSET, in dw_hdmi_set_channel_count()
764 mutex_unlock(&hdmi->audio_mutex); in dw_hdmi_set_channel_count()
768 void dw_hdmi_set_channel_allocation(struct dw_hdmi *hdmi, unsigned int ca) in dw_hdmi_set_channel_allocation() argument
770 mutex_lock(&hdmi->audio_mutex); in dw_hdmi_set_channel_allocation()
772 hdmi_writeb(hdmi, ca, HDMI_FC_AUDICONF2); in dw_hdmi_set_channel_allocation()
774 mutex_unlock(&hdmi->audio_mutex); in dw_hdmi_set_channel_allocation()
778 static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi, bool enable) in hdmi_enable_audio_clk() argument
781 hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_AUDCLK_DISABLE; in hdmi_enable_audio_clk()
783 hdmi->mc_clkdis |= HDMI_MC_CLKDIS_AUDCLK_DISABLE; in hdmi_enable_audio_clk()
784 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in hdmi_enable_audio_clk()
787 static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) in hdmi_audio_get_eld() argument
789 if (!hdmi->curr_conn) in hdmi_audio_get_eld()
792 return hdmi->curr_conn->eld; in hdmi_audio_get_eld()
795 static void dw_hdmi_gp_audio_enable(struct dw_hdmi *hdmi) in dw_hdmi_gp_audio_enable() argument
797 const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; in dw_hdmi_gp_audio_enable()
799 int ch_mask = BIT(hdmi->channels) - 1; in dw_hdmi_gp_audio_enable()
801 switch (hdmi->sample_rate) { in dw_hdmi_gp_audio_enable()
834 hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); in dw_hdmi_gp_audio_enable()
835 hdmi_enable_audio_clk(hdmi, true); in dw_hdmi_gp_audio_enable()
837 hdmi_writeb(hdmi, 0x1, HDMI_FC_AUDSCHNLS0); in dw_hdmi_gp_audio_enable()
838 hdmi_writeb(hdmi, hdmi->channels, HDMI_FC_AUDSCHNLS2); in dw_hdmi_gp_audio_enable()
839 hdmi_writeb(hdmi, 0x22, HDMI_FC_AUDSCHNLS3); in dw_hdmi_gp_audio_enable()
840 hdmi_writeb(hdmi, 0x22, HDMI_FC_AUDSCHNLS4); in dw_hdmi_gp_audio_enable()
841 hdmi_writeb(hdmi, 0x11, HDMI_FC_AUDSCHNLS5); in dw_hdmi_gp_audio_enable()
842 hdmi_writeb(hdmi, 0x11, HDMI_FC_AUDSCHNLS6); in dw_hdmi_gp_audio_enable()
843 hdmi_writeb(hdmi, (0x3 << 4) | sample_freq, HDMI_FC_AUDSCHNLS7); in dw_hdmi_gp_audio_enable()
844 hdmi_writeb(hdmi, (org_sample_freq << 4) | 0xb, HDMI_FC_AUDSCHNLS8); in dw_hdmi_gp_audio_enable()
846 hdmi_writeb(hdmi, ch_mask, HDMI_GP_CONF1); in dw_hdmi_gp_audio_enable()
847 hdmi_writeb(hdmi, 0x02, HDMI_GP_CONF2); in dw_hdmi_gp_audio_enable()
848 hdmi_writeb(hdmi, 0x01, HDMI_GP_CONF0); in dw_hdmi_gp_audio_enable()
850 hdmi_modb(hdmi, 0x3, 0x3, HDMI_FC_DATAUTO3); in dw_hdmi_gp_audio_enable()
853 if (hdmi->sample_rate == 192000 && hdmi->channels == 8 && in dw_hdmi_gp_audio_enable()
854 hdmi->sample_width == 32 && hdmi->sample_non_pcm) in dw_hdmi_gp_audio_enable()
855 hdmi_modb(hdmi, 0x01, 0x01, HDMI_GP_CONF2); in dw_hdmi_gp_audio_enable()
858 pdata->enable_audio(hdmi, in dw_hdmi_gp_audio_enable()
859 hdmi->channels, in dw_hdmi_gp_audio_enable()
860 hdmi->sample_width, in dw_hdmi_gp_audio_enable()
861 hdmi->sample_rate, in dw_hdmi_gp_audio_enable()
862 hdmi->sample_non_pcm); in dw_hdmi_gp_audio_enable()
865 static void dw_hdmi_gp_audio_disable(struct dw_hdmi *hdmi) in dw_hdmi_gp_audio_disable() argument
867 const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; in dw_hdmi_gp_audio_disable()
869 hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); in dw_hdmi_gp_audio_disable()
871 hdmi_modb(hdmi, 0, 0x3, HDMI_FC_DATAUTO3); in dw_hdmi_gp_audio_disable()
873 pdata->disable_audio(hdmi); in dw_hdmi_gp_audio_disable()
875 hdmi_enable_audio_clk(hdmi, false); in dw_hdmi_gp_audio_disable()
878 static void dw_hdmi_ahb_audio_enable(struct dw_hdmi *hdmi) in dw_hdmi_ahb_audio_enable() argument
880 hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); in dw_hdmi_ahb_audio_enable()
883 static void dw_hdmi_ahb_audio_disable(struct dw_hdmi *hdmi) in dw_hdmi_ahb_audio_disable() argument
885 hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); in dw_hdmi_ahb_audio_disable()
888 static void dw_hdmi_i2s_audio_enable(struct dw_hdmi *hdmi) in dw_hdmi_i2s_audio_enable() argument
890 hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); in dw_hdmi_i2s_audio_enable()
891 hdmi_enable_audio_clk(hdmi, true); in dw_hdmi_i2s_audio_enable()
894 static void dw_hdmi_i2s_audio_disable(struct dw_hdmi *hdmi) in dw_hdmi_i2s_audio_disable() argument
896 hdmi_enable_audio_clk(hdmi, false); in dw_hdmi_i2s_audio_disable()
899 void dw_hdmi_audio_enable(struct dw_hdmi *hdmi) in dw_hdmi_audio_enable() argument
903 spin_lock_irqsave(&hdmi->audio_lock, flags); in dw_hdmi_audio_enable()
904 hdmi->audio_enable = true; in dw_hdmi_audio_enable()
905 if (hdmi->enable_audio) in dw_hdmi_audio_enable()
906 hdmi->enable_audio(hdmi); in dw_hdmi_audio_enable()
907 spin_unlock_irqrestore(&hdmi->audio_lock, flags); in dw_hdmi_audio_enable()
911 void dw_hdmi_audio_disable(struct dw_hdmi *hdmi) in dw_hdmi_audio_disable() argument
915 spin_lock_irqsave(&hdmi->audio_lock, flags); in dw_hdmi_audio_disable()
916 hdmi->audio_enable = false; in dw_hdmi_audio_disable()
917 if (hdmi->disable_audio) in dw_hdmi_audio_disable()
918 hdmi->disable_audio(hdmi); in dw_hdmi_audio_disable()
919 spin_unlock_irqrestore(&hdmi->audio_lock, flags); in dw_hdmi_audio_disable()
1016 static void hdmi_video_sample(struct dw_hdmi *hdmi) in hdmi_video_sample() argument
1021 switch (hdmi->hdmi_data.enc_in_bus_format) { in hdmi_video_sample()
1069 hdmi_writeb(hdmi, val, HDMI_TX_INVID0); in hdmi_video_sample()
1075 hdmi_writeb(hdmi, val, HDMI_TX_INSTUFFING); in hdmi_video_sample()
1076 hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA0); in hdmi_video_sample()
1077 hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA1); in hdmi_video_sample()
1078 hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA0); in hdmi_video_sample()
1079 hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA1); in hdmi_video_sample()
1080 hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA0); in hdmi_video_sample()
1081 hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA1); in hdmi_video_sample()
1084 static int is_color_space_conversion(struct dw_hdmi *hdmi) in is_color_space_conversion() argument
1086 struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; in is_color_space_conversion()
1096 static int is_color_space_decimation(struct dw_hdmi *hdmi) in is_color_space_decimation() argument
1098 if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) in is_color_space_decimation()
1101 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_in_bus_format) || in is_color_space_decimation()
1102 hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_in_bus_format)) in is_color_space_decimation()
1108 static int is_color_space_interpolation(struct dw_hdmi *hdmi) in is_color_space_interpolation() argument
1110 if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_in_bus_format)) in is_color_space_interpolation()
1113 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || in is_color_space_interpolation()
1114 hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) in is_color_space_interpolation()
1120 static bool is_csc_needed(struct dw_hdmi *hdmi) in is_csc_needed() argument
1122 return is_color_space_conversion(hdmi) || in is_csc_needed()
1123 is_color_space_decimation(hdmi) || in is_csc_needed()
1124 is_color_space_interpolation(hdmi); in is_csc_needed()
1127 static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) in dw_hdmi_update_csc_coeffs() argument
1134 is_input_rgb = hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_in_bus_format); in dw_hdmi_update_csc_coeffs()
1135 is_output_rgb = hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format); in dw_hdmi_update_csc_coeffs()
1138 if (hdmi->hdmi_data.enc_out_encoding == V4L2_YCBCR_ENC_601) in dw_hdmi_update_csc_coeffs()
1143 if (hdmi->hdmi_data.enc_out_encoding == V4L2_YCBCR_ENC_601) in dw_hdmi_update_csc_coeffs()
1149 hdmi->hdmi_data.rgb_limited_range) { in dw_hdmi_update_csc_coeffs()
1159 hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2); in dw_hdmi_update_csc_coeffs()
1160 hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2); in dw_hdmi_update_csc_coeffs()
1161 hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2); in dw_hdmi_update_csc_coeffs()
1162 hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2); in dw_hdmi_update_csc_coeffs()
1163 hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2); in dw_hdmi_update_csc_coeffs()
1164 hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); in dw_hdmi_update_csc_coeffs()
1167 hdmi_modb(hdmi, csc_scale, HDMI_CSC_SCALE_CSCSCALE_MASK, in dw_hdmi_update_csc_coeffs()
1171 static void hdmi_video_csc(struct dw_hdmi *hdmi) in hdmi_video_csc() argument
1178 if (is_color_space_interpolation(hdmi)) in hdmi_video_csc()
1180 else if (is_color_space_decimation(hdmi)) in hdmi_video_csc()
1183 switch (hdmi_bus_fmt_color_depth(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_video_csc()
1202 hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG); in hdmi_video_csc()
1203 hdmi_modb(hdmi, color_depth, HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK, in hdmi_video_csc()
1206 dw_hdmi_update_csc_coeffs(hdmi); in hdmi_video_csc()
1214 static void hdmi_video_packetize(struct dw_hdmi *hdmi) in hdmi_video_packetize() argument
1219 struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; in hdmi_video_packetize()
1224 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || in hdmi_video_packetize()
1225 hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format) || in hdmi_video_packetize()
1226 hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_video_packetize()
1228 hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_video_packetize()
1246 } else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_video_packetize()
1248 hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_video_packetize()
1275 hdmi_writeb(hdmi, val, HDMI_VP_PR_CD); in hdmi_video_packetize()
1283 val = hdmi_readb(hdmi, HDMI_FC_DATAUTO3); in hdmi_video_packetize()
1288 hdmi_writeb(hdmi, val, HDMI_FC_DATAUTO3); in hdmi_video_packetize()
1290 hdmi_modb(hdmi, HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE, in hdmi_video_packetize()
1302 hdmi_modb(hdmi, vp_conf, in hdmi_video_packetize()
1306 hdmi_modb(hdmi, 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET, in hdmi_video_packetize()
1309 hdmi_writeb(hdmi, remap_size, HDMI_VP_REMAP); in hdmi_video_packetize()
1327 hdmi_modb(hdmi, vp_conf, in hdmi_video_packetize()
1331 hdmi_modb(hdmi, HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | in hdmi_video_packetize()
1336 hdmi_modb(hdmi, output_select, HDMI_VP_CONF_OUTPUT_SELECTOR_MASK, in hdmi_video_packetize()
1344 static inline void hdmi_phy_test_clear(struct dw_hdmi *hdmi, in hdmi_phy_test_clear() argument
1347 hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLR_OFFSET, in hdmi_phy_test_clear()
1351 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec) in hdmi_phy_wait_i2c_done() argument
1355 while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) { in hdmi_phy_wait_i2c_done()
1360 hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0); in hdmi_phy_wait_i2c_done()
1365 void dw_hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, in dw_hdmi_phy_i2c_write() argument
1368 hdmi_writeb(hdmi, 0xFF, HDMI_IH_I2CMPHY_STAT0); in dw_hdmi_phy_i2c_write()
1369 hdmi_writeb(hdmi, addr, HDMI_PHY_I2CM_ADDRESS_ADDR); in dw_hdmi_phy_i2c_write()
1370 hdmi_writeb(hdmi, (unsigned char)(data >> 8), in dw_hdmi_phy_i2c_write()
1372 hdmi_writeb(hdmi, (unsigned char)(data >> 0), in dw_hdmi_phy_i2c_write()
1374 hdmi_writeb(hdmi, HDMI_PHY_I2CM_OPERATION_ADDR_WRITE, in dw_hdmi_phy_i2c_write()
1376 hdmi_phy_wait_i2c_done(hdmi, 1000); in dw_hdmi_phy_i2c_write()
1381 static bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi, in dw_hdmi_support_scdc() argument
1385 if (hdmi->version < 0x200a) in dw_hdmi_support_scdc()
1389 if (!hdmi->ddc) in dw_hdmi_support_scdc()
1393 if (!display->hdmi.scdc.supported || in dw_hdmi_support_scdc()
1394 !display->hdmi.scdc.scrambling.supported) in dw_hdmi_support_scdc()
1401 if (!display->hdmi.scdc.scrambling.low_rates && in dw_hdmi_support_scdc()
1421 void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi *hdmi, in dw_hdmi_set_high_tmds_clock_ratio() argument
1424 unsigned long mtmdsclock = hdmi->hdmi_data.video_mode.mtmdsclock; in dw_hdmi_set_high_tmds_clock_ratio()
1427 if (dw_hdmi_support_scdc(hdmi, display)) { in dw_hdmi_set_high_tmds_clock_ratio()
1429 drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 1); in dw_hdmi_set_high_tmds_clock_ratio()
1431 drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 0); in dw_hdmi_set_high_tmds_clock_ratio()
1436 static void dw_hdmi_phy_enable_powerdown(struct dw_hdmi *hdmi, bool enable) in dw_hdmi_phy_enable_powerdown() argument
1438 hdmi_mask_writeb(hdmi, !enable, HDMI_PHY_CONF0, in dw_hdmi_phy_enable_powerdown()
1443 static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_enable_tmds() argument
1445 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_enable_tmds()
1450 static void dw_hdmi_phy_enable_svsret(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_enable_svsret() argument
1452 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_enable_svsret()
1457 void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_gen2_pddq() argument
1459 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_gen2_pddq()
1465 void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_gen2_txpwron() argument
1467 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_gen2_txpwron()
1473 static void dw_hdmi_phy_sel_data_en_pol(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_sel_data_en_pol() argument
1475 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_sel_data_en_pol()
1480 static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_sel_interface_control() argument
1482 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_sel_interface_control()
1487 void dw_hdmi_phy_gen1_reset(struct dw_hdmi *hdmi) in dw_hdmi_phy_gen1_reset() argument
1490 hdmi_writeb(hdmi, 0, HDMI_MC_PHYRSTZ); in dw_hdmi_phy_gen1_reset()
1491 hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_PHYRSTZ, HDMI_MC_PHYRSTZ); in dw_hdmi_phy_gen1_reset()
1495 void dw_hdmi_phy_gen2_reset(struct dw_hdmi *hdmi) in dw_hdmi_phy_gen2_reset() argument
1498 hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_PHYRSTZ, HDMI_MC_PHYRSTZ); in dw_hdmi_phy_gen2_reset()
1499 hdmi_writeb(hdmi, 0, HDMI_MC_PHYRSTZ); in dw_hdmi_phy_gen2_reset()
1503 void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address) in dw_hdmi_phy_i2c_set_addr() argument
1505 hdmi_phy_test_clear(hdmi, 1); in dw_hdmi_phy_i2c_set_addr()
1506 hdmi_writeb(hdmi, address, HDMI_PHY_I2CM_SLAVE_ADDR); in dw_hdmi_phy_i2c_set_addr()
1507 hdmi_phy_test_clear(hdmi, 0); in dw_hdmi_phy_i2c_set_addr()
1511 static void dw_hdmi_phy_power_off(struct dw_hdmi *hdmi) in dw_hdmi_phy_power_off() argument
1513 const struct dw_hdmi_phy_data *phy = hdmi->phy.data; in dw_hdmi_phy_power_off()
1518 dw_hdmi_phy_enable_tmds(hdmi, 0); in dw_hdmi_phy_power_off()
1519 dw_hdmi_phy_enable_powerdown(hdmi, true); in dw_hdmi_phy_power_off()
1523 dw_hdmi_phy_gen2_txpwron(hdmi, 0); in dw_hdmi_phy_power_off()
1530 val = hdmi_readb(hdmi, HDMI_PHY_STAT0); in dw_hdmi_phy_power_off()
1538 dev_warn(hdmi->dev, "PHY failed to power down\n"); in dw_hdmi_phy_power_off()
1540 dev_dbg(hdmi->dev, "PHY powered down in %u iterations\n", i); in dw_hdmi_phy_power_off()
1542 dw_hdmi_phy_gen2_pddq(hdmi, 1); in dw_hdmi_phy_power_off()
1545 static int dw_hdmi_phy_power_on(struct dw_hdmi *hdmi) in dw_hdmi_phy_power_on() argument
1547 const struct dw_hdmi_phy_data *phy = hdmi->phy.data; in dw_hdmi_phy_power_on()
1552 dw_hdmi_phy_enable_powerdown(hdmi, false); in dw_hdmi_phy_power_on()
1555 dw_hdmi_phy_enable_tmds(hdmi, 0); in dw_hdmi_phy_power_on()
1556 dw_hdmi_phy_enable_tmds(hdmi, 1); in dw_hdmi_phy_power_on()
1560 dw_hdmi_phy_gen2_txpwron(hdmi, 1); in dw_hdmi_phy_power_on()
1561 dw_hdmi_phy_gen2_pddq(hdmi, 0); in dw_hdmi_phy_power_on()
1565 val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK; in dw_hdmi_phy_power_on()
1573 dev_err(hdmi->dev, "PHY PLL failed to lock\n"); in dw_hdmi_phy_power_on()
1577 dev_dbg(hdmi->dev, "PHY PLL locked %u iterations\n", i); in dw_hdmi_phy_power_on()
1586 static int hdmi_phy_configure_dwc_hdmi_3d_tx(struct dw_hdmi *hdmi, in hdmi_phy_configure_dwc_hdmi_3d_tx() argument
1614 dw_hdmi_phy_i2c_write(hdmi, mpll_config->res[0].cpce, in hdmi_phy_configure_dwc_hdmi_3d_tx()
1616 dw_hdmi_phy_i2c_write(hdmi, mpll_config->res[0].gmp, in hdmi_phy_configure_dwc_hdmi_3d_tx()
1618 dw_hdmi_phy_i2c_write(hdmi, curr_ctrl->curr[0], in hdmi_phy_configure_dwc_hdmi_3d_tx()
1621 dw_hdmi_phy_i2c_write(hdmi, 0, HDMI_3D_TX_PHY_PLLPHBYCTRL); in hdmi_phy_configure_dwc_hdmi_3d_tx()
1622 dw_hdmi_phy_i2c_write(hdmi, HDMI_3D_TX_PHY_MSM_CTRL_CKO_SEL_FB_CLK, in hdmi_phy_configure_dwc_hdmi_3d_tx()
1625 dw_hdmi_phy_i2c_write(hdmi, phy_config->term, HDMI_3D_TX_PHY_TXTERM); in hdmi_phy_configure_dwc_hdmi_3d_tx()
1626 dw_hdmi_phy_i2c_write(hdmi, phy_config->sym_ctr, in hdmi_phy_configure_dwc_hdmi_3d_tx()
1628 dw_hdmi_phy_i2c_write(hdmi, phy_config->vlev_ctr, in hdmi_phy_configure_dwc_hdmi_3d_tx()
1632 dw_hdmi_phy_i2c_write(hdmi, HDMI_3D_TX_PHY_CKCALCTRL_OVERRIDE, in hdmi_phy_configure_dwc_hdmi_3d_tx()
1638 static int hdmi_phy_configure(struct dw_hdmi *hdmi, in hdmi_phy_configure() argument
1641 const struct dw_hdmi_phy_data *phy = hdmi->phy.data; in hdmi_phy_configure()
1642 const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; in hdmi_phy_configure()
1643 unsigned long mpixelclock = hdmi->hdmi_data.video_mode.mpixelclock; in hdmi_phy_configure()
1644 unsigned long mtmdsclock = hdmi->hdmi_data.video_mode.mtmdsclock; in hdmi_phy_configure()
1647 dw_hdmi_phy_power_off(hdmi); in hdmi_phy_configure()
1649 dw_hdmi_set_high_tmds_clock_ratio(hdmi, display); in hdmi_phy_configure()
1653 dw_hdmi_phy_enable_svsret(hdmi, 1); in hdmi_phy_configure()
1655 dw_hdmi_phy_gen2_reset(hdmi); in hdmi_phy_configure()
1657 hdmi_writeb(hdmi, HDMI_MC_HEACPHY_RST_ASSERT, HDMI_MC_HEACPHY_RST); in hdmi_phy_configure()
1659 dw_hdmi_phy_i2c_set_addr(hdmi, HDMI_PHY_I2CM_SLAVE_ADDR_PHY_GEN2); in hdmi_phy_configure()
1663 ret = pdata->configure_phy(hdmi, pdata->priv_data, mpixelclock); in hdmi_phy_configure()
1665 ret = phy->configure(hdmi, pdata, mpixelclock); in hdmi_phy_configure()
1667 dev_err(hdmi->dev, "PHY configuration failed (clock %lu)\n", in hdmi_phy_configure()
1676 return dw_hdmi_phy_power_on(hdmi); in hdmi_phy_configure()
1679 static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, in dw_hdmi_phy_init() argument
1687 dw_hdmi_phy_sel_data_en_pol(hdmi, 1); in dw_hdmi_phy_init()
1688 dw_hdmi_phy_sel_interface_control(hdmi, 0); in dw_hdmi_phy_init()
1690 ret = hdmi_phy_configure(hdmi, display); in dw_hdmi_phy_init()
1698 static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi, void *data) in dw_hdmi_phy_disable() argument
1700 dw_hdmi_phy_power_off(hdmi); in dw_hdmi_phy_disable()
1703 enum drm_connector_status dw_hdmi_phy_read_hpd(struct dw_hdmi *hdmi, in dw_hdmi_phy_read_hpd() argument
1706 return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ? in dw_hdmi_phy_read_hpd()
1711 void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data, in dw_hdmi_phy_update_hpd() argument
1714 u8 old_mask = hdmi->phy_mask; in dw_hdmi_phy_update_hpd()
1717 hdmi->phy_mask |= HDMI_PHY_RX_SENSE; in dw_hdmi_phy_update_hpd()
1719 hdmi->phy_mask &= ~HDMI_PHY_RX_SENSE; in dw_hdmi_phy_update_hpd()
1721 if (old_mask != hdmi->phy_mask) in dw_hdmi_phy_update_hpd()
1722 hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); in dw_hdmi_phy_update_hpd()
1726 void dw_hdmi_phy_setup_hpd(struct dw_hdmi *hdmi, void *data) in dw_hdmi_phy_setup_hpd() argument
1732 hdmi_writeb(hdmi, HDMI_PHY_HPD | HDMI_PHY_RX_SENSE, HDMI_PHY_POL0); in dw_hdmi_phy_setup_hpd()
1733 hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, in dw_hdmi_phy_setup_hpd()
1737 hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); in dw_hdmi_phy_setup_hpd()
1740 hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, in dw_hdmi_phy_setup_hpd()
1742 hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), in dw_hdmi_phy_setup_hpd()
1759 static void hdmi_tx_hdcp_config(struct dw_hdmi *hdmi) in hdmi_tx_hdcp_config() argument
1763 if (hdmi->hdmi_data.video_mode.mdataenablepolarity) in hdmi_tx_hdcp_config()
1769 hdmi_modb(hdmi, HDMI_A_HDCPCFG0_RXDETECT_DISABLE, in hdmi_tx_hdcp_config()
1772 hdmi_modb(hdmi, de, HDMI_A_VIDPOLCFG_DATAENPOL_MASK, HDMI_A_VIDPOLCFG); in hdmi_tx_hdcp_config()
1774 hdmi_modb(hdmi, HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_DISABLE, in hdmi_tx_hdcp_config()
1778 static void hdmi_config_AVI(struct dw_hdmi *hdmi, in hdmi_config_AVI() argument
1788 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_config_AVI()
1790 hdmi->hdmi_data.rgb_limited_range ? in hdmi_config_AVI()
1799 if (hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) in hdmi_config_AVI()
1801 else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) in hdmi_config_AVI()
1803 else if (hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format)) in hdmi_config_AVI()
1809 if (!hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_config_AVI()
1810 switch (hdmi->hdmi_data.enc_out_encoding) { in hdmi_config_AVI()
1812 if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV601) in hdmi_config_AVI()
1820 if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV709) in hdmi_config_AVI()
1857 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF0); in hdmi_config_AVI()
1863 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF1); in hdmi_config_AVI()
1871 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF2); in hdmi_config_AVI()
1875 hdmi_writeb(hdmi, val, HDMI_FC_AVIVID); in hdmi_config_AVI()
1878 val = (((hdmi->hdmi_data.video_mode.mpixelrepetitioninput + 1) << in hdmi_config_AVI()
1881 ((hdmi->hdmi_data.video_mode.mpixelrepetitionoutput << in hdmi_config_AVI()
1884 hdmi_writeb(hdmi, val, HDMI_FC_PRCONF); in hdmi_config_AVI()
1892 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF3); in hdmi_config_AVI()
1895 hdmi_writeb(hdmi, frame.top_bar & 0xff, HDMI_FC_AVIETB0); in hdmi_config_AVI()
1896 hdmi_writeb(hdmi, (frame.top_bar >> 8) & 0xff, HDMI_FC_AVIETB1); in hdmi_config_AVI()
1897 hdmi_writeb(hdmi, frame.bottom_bar & 0xff, HDMI_FC_AVISBB0); in hdmi_config_AVI()
1898 hdmi_writeb(hdmi, (frame.bottom_bar >> 8) & 0xff, HDMI_FC_AVISBB1); in hdmi_config_AVI()
1899 hdmi_writeb(hdmi, frame.left_bar & 0xff, HDMI_FC_AVIELB0); in hdmi_config_AVI()
1900 hdmi_writeb(hdmi, (frame.left_bar >> 8) & 0xff, HDMI_FC_AVIELB1); in hdmi_config_AVI()
1901 hdmi_writeb(hdmi, frame.right_bar & 0xff, HDMI_FC_AVISRB0); in hdmi_config_AVI()
1902 hdmi_writeb(hdmi, (frame.right_bar >> 8) & 0xff, HDMI_FC_AVISRB1); in hdmi_config_AVI()
1905 static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi, in hdmi_config_vendor_specific_infoframe() argument
1926 dev_err(hdmi->dev, "Failed to pack vendor infoframe: %zd\n", in hdmi_config_vendor_specific_infoframe()
1930 hdmi_mask_writeb(hdmi, 0, HDMI_FC_DATAUTO0, HDMI_FC_DATAUTO0_VSD_OFFSET, in hdmi_config_vendor_specific_infoframe()
1934 hdmi_writeb(hdmi, buffer[2], HDMI_FC_VSDSIZE); in hdmi_config_vendor_specific_infoframe()
1937 hdmi_writeb(hdmi, buffer[4], HDMI_FC_VSDIEEEID0); in hdmi_config_vendor_specific_infoframe()
1938 hdmi_writeb(hdmi, buffer[5], HDMI_FC_VSDIEEEID1); in hdmi_config_vendor_specific_infoframe()
1939 hdmi_writeb(hdmi, buffer[6], HDMI_FC_VSDIEEEID2); in hdmi_config_vendor_specific_infoframe()
1942 hdmi_writeb(hdmi, buffer[7], HDMI_FC_VSDPAYLOAD0); in hdmi_config_vendor_specific_infoframe()
1943 hdmi_writeb(hdmi, buffer[8], HDMI_FC_VSDPAYLOAD1); in hdmi_config_vendor_specific_infoframe()
1946 hdmi_writeb(hdmi, buffer[9], HDMI_FC_VSDPAYLOAD2); in hdmi_config_vendor_specific_infoframe()
1949 hdmi_writeb(hdmi, 1, HDMI_FC_DATAUTO1); in hdmi_config_vendor_specific_infoframe()
1952 hdmi_writeb(hdmi, 0x11, HDMI_FC_DATAUTO2); in hdmi_config_vendor_specific_infoframe()
1955 hdmi_mask_writeb(hdmi, 1, HDMI_FC_DATAUTO0, HDMI_FC_DATAUTO0_VSD_OFFSET, in hdmi_config_vendor_specific_infoframe()
1959 static void hdmi_config_drm_infoframe(struct dw_hdmi *hdmi, in hdmi_config_drm_infoframe() argument
1968 if (!hdmi->plat_data->use_drm_infoframe) in hdmi_config_drm_infoframe()
1971 hdmi_modb(hdmi, HDMI_FC_PACKET_TX_EN_DRM_DISABLE, in hdmi_config_drm_infoframe()
1980 dev_err(hdmi->dev, "Failed to pack drm infoframe: %zd\n", err); in hdmi_config_drm_infoframe()
1984 hdmi_writeb(hdmi, frame.version, HDMI_FC_DRM_HB0); in hdmi_config_drm_infoframe()
1985 hdmi_writeb(hdmi, frame.length, HDMI_FC_DRM_HB1); in hdmi_config_drm_infoframe()
1988 hdmi_writeb(hdmi, buffer[4 + i], HDMI_FC_DRM_PB0 + i); in hdmi_config_drm_infoframe()
1990 hdmi_writeb(hdmi, 1, HDMI_FC_DRM_UP); in hdmi_config_drm_infoframe()
1991 hdmi_modb(hdmi, HDMI_FC_PACKET_TX_EN_DRM_ENABLE, in hdmi_config_drm_infoframe()
1995 static void hdmi_av_composer(struct dw_hdmi *hdmi, in hdmi_av_composer() argument
2000 const struct drm_hdmi_info *hdmi_info = &display->hdmi; in hdmi_av_composer()
2001 struct hdmi_vmode *vmode = &hdmi->hdmi_data.video_mode; in hdmi_av_composer()
2007 dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock); in hdmi_av_composer()
2011 if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_av_composer()
2013 hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_av_composer()
2026 if (hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format)) in hdmi_av_composer()
2029 dev_dbg(hdmi->dev, "final tmdsclock = %d\n", vmode->mtmdsclock); in hdmi_av_composer()
2032 inv_val = (hdmi->hdmi_data.hdcp_enable || in hdmi_av_composer()
2033 (dw_hdmi_support_scdc(hdmi, display) && in hdmi_av_composer()
2051 if (hdmi->vic == 39) in hdmi_av_composer()
2062 inv_val |= hdmi->sink_is_hdmi ? in hdmi_av_composer()
2066 hdmi_writeb(hdmi, inv_val, HDMI_FC_INVIDCONF); in hdmi_av_composer()
2077 if (hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format)) { in hdmi_av_composer()
2101 if (dw_hdmi_support_scdc(hdmi, display)) { in hdmi_av_composer()
2113 drm_scdc_readb(hdmi->ddc, SCDC_SINK_VERSION, in hdmi_av_composer()
2115 drm_scdc_writeb(hdmi->ddc, SCDC_SOURCE_VERSION, in hdmi_av_composer()
2119 drm_scdc_set_scrambling(hdmi->ddc, 1); in hdmi_av_composer()
2128 hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, in hdmi_av_composer()
2130 hdmi_writeb(hdmi, 1, HDMI_FC_SCRAMBLER_CTRL); in hdmi_av_composer()
2132 hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL); in hdmi_av_composer()
2133 hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, in hdmi_av_composer()
2135 drm_scdc_set_scrambling(hdmi->ddc, 0); in hdmi_av_composer()
2140 hdmi_writeb(hdmi, hdisplay >> 8, HDMI_FC_INHACTV1); in hdmi_av_composer()
2141 hdmi_writeb(hdmi, hdisplay, HDMI_FC_INHACTV0); in hdmi_av_composer()
2144 hdmi_writeb(hdmi, vdisplay >> 8, HDMI_FC_INVACTV1); in hdmi_av_composer()
2145 hdmi_writeb(hdmi, vdisplay, HDMI_FC_INVACTV0); in hdmi_av_composer()
2148 hdmi_writeb(hdmi, hblank >> 8, HDMI_FC_INHBLANK1); in hdmi_av_composer()
2149 hdmi_writeb(hdmi, hblank, HDMI_FC_INHBLANK0); in hdmi_av_composer()
2152 hdmi_writeb(hdmi, vblank, HDMI_FC_INVBLANK); in hdmi_av_composer()
2155 hdmi_writeb(hdmi, h_de_hs >> 8, HDMI_FC_HSYNCINDELAY1); in hdmi_av_composer()
2156 hdmi_writeb(hdmi, h_de_hs, HDMI_FC_HSYNCINDELAY0); in hdmi_av_composer()
2159 hdmi_writeb(hdmi, v_de_vs, HDMI_FC_VSYNCINDELAY); in hdmi_av_composer()
2162 hdmi_writeb(hdmi, hsync_len >> 8, HDMI_FC_HSYNCINWIDTH1); in hdmi_av_composer()
2163 hdmi_writeb(hdmi, hsync_len, HDMI_FC_HSYNCINWIDTH0); in hdmi_av_composer()
2166 hdmi_writeb(hdmi, vsync_len, HDMI_FC_VSYNCINWIDTH); in hdmi_av_composer()
2170 static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi) in dw_hdmi_enable_video_path() argument
2173 hdmi_writeb(hdmi, 12, HDMI_FC_CTRLDUR); in dw_hdmi_enable_video_path()
2174 hdmi_writeb(hdmi, 32, HDMI_FC_EXCTRLDUR); in dw_hdmi_enable_video_path()
2175 hdmi_writeb(hdmi, 1, HDMI_FC_EXCTRLSPAC); in dw_hdmi_enable_video_path()
2178 hdmi_writeb(hdmi, 0x0B, HDMI_FC_CH0PREAM); in dw_hdmi_enable_video_path()
2179 hdmi_writeb(hdmi, 0x16, HDMI_FC_CH1PREAM); in dw_hdmi_enable_video_path()
2180 hdmi_writeb(hdmi, 0x21, HDMI_FC_CH2PREAM); in dw_hdmi_enable_video_path()
2183 hdmi->mc_clkdis |= HDMI_MC_CLKDIS_HDCPCLK_DISABLE | in dw_hdmi_enable_video_path()
2188 hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE; in dw_hdmi_enable_video_path()
2189 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
2191 hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE; in dw_hdmi_enable_video_path()
2192 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
2195 if (is_csc_needed(hdmi)) { in dw_hdmi_enable_video_path()
2196 hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_CSCCLK_DISABLE; in dw_hdmi_enable_video_path()
2197 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
2199 hdmi_writeb(hdmi, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_IN_PATH, in dw_hdmi_enable_video_path()
2202 hdmi->mc_clkdis |= HDMI_MC_CLKDIS_CSCCLK_DISABLE; in dw_hdmi_enable_video_path()
2203 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
2205 hdmi_writeb(hdmi, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_BYPASS, in dw_hdmi_enable_video_path()
2211 static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) in dw_hdmi_clear_overflow() argument
2232 switch (hdmi->version) { in dw_hdmi_clear_overflow()
2242 hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, HDMI_MC_SWRSTZ); in dw_hdmi_clear_overflow()
2244 val = hdmi_readb(hdmi, HDMI_FC_INVIDCONF); in dw_hdmi_clear_overflow()
2246 hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF); in dw_hdmi_clear_overflow()
2249 static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) in hdmi_disable_overflow_interrupts() argument
2251 hdmi_writeb(hdmi, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK, in hdmi_disable_overflow_interrupts()
2255 static int dw_hdmi_setup(struct dw_hdmi *hdmi, in dw_hdmi_setup() argument
2261 hdmi_disable_overflow_interrupts(hdmi); in dw_hdmi_setup()
2263 hdmi->vic = drm_match_cea_mode(mode); in dw_hdmi_setup()
2265 if (!hdmi->vic) { in dw_hdmi_setup()
2266 dev_dbg(hdmi->dev, "Non-CEA mode used in HDMI\n"); in dw_hdmi_setup()
2268 dev_dbg(hdmi->dev, "CEA mode used vic=%d\n", hdmi->vic); in dw_hdmi_setup()
2271 if ((hdmi->vic == 6) || (hdmi->vic == 7) || in dw_hdmi_setup()
2272 (hdmi->vic == 21) || (hdmi->vic == 22) || in dw_hdmi_setup()
2273 (hdmi->vic == 2) || (hdmi->vic == 3) || in dw_hdmi_setup()
2274 (hdmi->vic == 17) || (hdmi->vic == 18)) in dw_hdmi_setup()
2275 hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_601; in dw_hdmi_setup()
2277 hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_709; in dw_hdmi_setup()
2279 hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; in dw_hdmi_setup()
2280 hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; in dw_hdmi_setup()
2282 if (hdmi->hdmi_data.enc_in_bus_format == MEDIA_BUS_FMT_FIXED) in dw_hdmi_setup()
2283 hdmi->hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_RGB888_1X24; in dw_hdmi_setup()
2286 if (hdmi->plat_data->input_bus_encoding) in dw_hdmi_setup()
2287 hdmi->hdmi_data.enc_in_encoding = in dw_hdmi_setup()
2288 hdmi->plat_data->input_bus_encoding; in dw_hdmi_setup()
2290 hdmi->hdmi_data.enc_in_encoding = V4L2_YCBCR_ENC_DEFAULT; in dw_hdmi_setup()
2292 if (hdmi->hdmi_data.enc_out_bus_format == MEDIA_BUS_FMT_FIXED) in dw_hdmi_setup()
2293 hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24; in dw_hdmi_setup()
2295 hdmi->hdmi_data.rgb_limited_range = hdmi->sink_is_hdmi && in dw_hdmi_setup()
2299 hdmi->hdmi_data.pix_repet_factor = 0; in dw_hdmi_setup()
2300 hdmi->hdmi_data.hdcp_enable = 0; in dw_hdmi_setup()
2301 hdmi->hdmi_data.video_mode.mdataenablepolarity = true; in dw_hdmi_setup()
2304 hdmi_av_composer(hdmi, &connector->display_info, mode); in dw_hdmi_setup()
2307 ret = hdmi->phy.ops->init(hdmi, hdmi->phy.data, in dw_hdmi_setup()
2309 &hdmi->previous_mode); in dw_hdmi_setup()
2312 hdmi->phy.enabled = true; in dw_hdmi_setup()
2315 dw_hdmi_enable_video_path(hdmi); in dw_hdmi_setup()
2317 if (hdmi->sink_has_audio) { in dw_hdmi_setup()
2318 dev_dbg(hdmi->dev, "sink has audio support\n"); in dw_hdmi_setup()
2321 hdmi_clk_regenerator_update_pixel_clock(hdmi); in dw_hdmi_setup()
2322 hdmi_enable_audio_clk(hdmi, hdmi->audio_enable); in dw_hdmi_setup()
2326 if (hdmi->sink_is_hdmi) { in dw_hdmi_setup()
2327 dev_dbg(hdmi->dev, "%s HDMI mode\n", __func__); in dw_hdmi_setup()
2330 hdmi_config_AVI(hdmi, connector, mode); in dw_hdmi_setup()
2331 hdmi_config_vendor_specific_infoframe(hdmi, connector, mode); in dw_hdmi_setup()
2332 hdmi_config_drm_infoframe(hdmi, connector); in dw_hdmi_setup()
2334 dev_dbg(hdmi->dev, "%s DVI mode\n", __func__); in dw_hdmi_setup()
2337 hdmi_video_packetize(hdmi); in dw_hdmi_setup()
2338 hdmi_video_csc(hdmi); in dw_hdmi_setup()
2339 hdmi_video_sample(hdmi); in dw_hdmi_setup()
2340 hdmi_tx_hdcp_config(hdmi); in dw_hdmi_setup()
2342 dw_hdmi_clear_overflow(hdmi); in dw_hdmi_setup()
2347 static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi) in initialize_hdmi_ih_mutes() argument
2358 ih_mute = hdmi_readb(hdmi, HDMI_IH_MUTE) | in initialize_hdmi_ih_mutes()
2362 hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); in initialize_hdmi_ih_mutes()
2365 hdmi_writeb(hdmi, 0xff, HDMI_VP_MASK); in initialize_hdmi_ih_mutes()
2366 hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK0); in initialize_hdmi_ih_mutes()
2367 hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK1); in initialize_hdmi_ih_mutes()
2368 hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK2); in initialize_hdmi_ih_mutes()
2369 hdmi_writeb(hdmi, 0xff, HDMI_PHY_MASK0); in initialize_hdmi_ih_mutes()
2370 hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_INT_ADDR); in initialize_hdmi_ih_mutes()
2371 hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_CTLINT_ADDR); in initialize_hdmi_ih_mutes()
2372 hdmi_writeb(hdmi, 0xff, HDMI_AUD_INT); in initialize_hdmi_ih_mutes()
2373 hdmi_writeb(hdmi, 0xff, HDMI_AUD_SPDIFINT); in initialize_hdmi_ih_mutes()
2374 hdmi_writeb(hdmi, 0xff, HDMI_AUD_HBR_MASK); in initialize_hdmi_ih_mutes()
2375 hdmi_writeb(hdmi, 0xff, HDMI_GP_MASK); in initialize_hdmi_ih_mutes()
2376 hdmi_writeb(hdmi, 0xff, HDMI_A_APIINTMSK); in initialize_hdmi_ih_mutes()
2377 hdmi_writeb(hdmi, 0xff, HDMI_I2CM_INT); in initialize_hdmi_ih_mutes()
2378 hdmi_writeb(hdmi, 0xff, HDMI_I2CM_CTLINT); in initialize_hdmi_ih_mutes()
2381 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT0); in initialize_hdmi_ih_mutes()
2382 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT1); in initialize_hdmi_ih_mutes()
2383 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT2); in initialize_hdmi_ih_mutes()
2384 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AS_STAT0); in initialize_hdmi_ih_mutes()
2385 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_PHY_STAT0); in initialize_hdmi_ih_mutes()
2386 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CM_STAT0); in initialize_hdmi_ih_mutes()
2387 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_CEC_STAT0); in initialize_hdmi_ih_mutes()
2388 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_VP_STAT0); in initialize_hdmi_ih_mutes()
2389 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CMPHY_STAT0); in initialize_hdmi_ih_mutes()
2390 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AHBDMAAUD_STAT0); in initialize_hdmi_ih_mutes()
2395 hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); in initialize_hdmi_ih_mutes()
2398 static void dw_hdmi_poweron(struct dw_hdmi *hdmi) in dw_hdmi_poweron() argument
2400 hdmi->bridge_is_on = true; in dw_hdmi_poweron()
2406 dw_hdmi_setup(hdmi, hdmi->curr_conn, &hdmi->previous_mode); in dw_hdmi_poweron()
2409 static void dw_hdmi_poweroff(struct dw_hdmi *hdmi) in dw_hdmi_poweroff() argument
2411 if (hdmi->phy.enabled) { in dw_hdmi_poweroff()
2412 hdmi->phy.ops->disable(hdmi, hdmi->phy.data); in dw_hdmi_poweroff()
2413 hdmi->phy.enabled = false; in dw_hdmi_poweroff()
2416 hdmi->bridge_is_on = false; in dw_hdmi_poweroff()
2419 static void dw_hdmi_update_power(struct dw_hdmi *hdmi) in dw_hdmi_update_power() argument
2421 int force = hdmi->force; in dw_hdmi_update_power()
2423 if (hdmi->disabled) { in dw_hdmi_update_power()
2426 if (hdmi->rxsense) in dw_hdmi_update_power()
2433 if (hdmi->bridge_is_on) in dw_hdmi_update_power()
2434 dw_hdmi_poweroff(hdmi); in dw_hdmi_update_power()
2436 if (!hdmi->bridge_is_on) in dw_hdmi_update_power()
2437 dw_hdmi_poweron(hdmi); in dw_hdmi_update_power()
2453 static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi) in dw_hdmi_update_phy_mask() argument
2455 if (hdmi->phy.ops->update_hpd) in dw_hdmi_update_phy_mask()
2456 hdmi->phy.ops->update_hpd(hdmi, hdmi->phy.data, in dw_hdmi_update_phy_mask()
2457 hdmi->force, hdmi->disabled, in dw_hdmi_update_phy_mask()
2458 hdmi->rxsense); in dw_hdmi_update_phy_mask()
2461 static enum drm_connector_status dw_hdmi_detect(struct dw_hdmi *hdmi) in dw_hdmi_detect() argument
2465 result = hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data); in dw_hdmi_detect()
2467 mutex_lock(&hdmi->mutex); in dw_hdmi_detect()
2468 if (result != hdmi->last_connector_result) { in dw_hdmi_detect()
2469 dev_dbg(hdmi->dev, "read_hpd result: %d", result); in dw_hdmi_detect()
2470 handle_plugged_change(hdmi, in dw_hdmi_detect()
2472 hdmi->last_connector_result = result; in dw_hdmi_detect()
2474 mutex_unlock(&hdmi->mutex); in dw_hdmi_detect()
2479 static struct edid *dw_hdmi_get_edid(struct dw_hdmi *hdmi, in dw_hdmi_get_edid() argument
2484 if (!hdmi->ddc) in dw_hdmi_get_edid()
2487 edid = drm_get_edid(connector, hdmi->ddc); in dw_hdmi_get_edid()
2489 dev_dbg(hdmi->dev, "failed to get edid\n"); in dw_hdmi_get_edid()
2493 dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n", in dw_hdmi_get_edid()
2496 hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid); in dw_hdmi_get_edid()
2497 hdmi->sink_has_audio = drm_detect_monitor_audio(edid); in dw_hdmi_get_edid()
2509 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_detect() local
2511 return dw_hdmi_detect(hdmi); in dw_hdmi_connector_detect()
2516 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_get_modes() local
2521 edid = dw_hdmi_get_edid(hdmi, connector); in dw_hdmi_connector_get_modes()
2526 cec_notifier_set_phys_addr_from_edid(hdmi->cec_notifier, edid); in dw_hdmi_connector_get_modes()
2559 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_force() local
2562 mutex_lock(&hdmi->mutex); in dw_hdmi_connector_force()
2563 hdmi->force = connector->force; in dw_hdmi_connector_force()
2564 dw_hdmi_update_power(hdmi); in dw_hdmi_connector_force()
2565 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_connector_force()
2566 mutex_unlock(&hdmi->mutex); in dw_hdmi_connector_force()
2584 static int dw_hdmi_connector_create(struct dw_hdmi *hdmi) in dw_hdmi_connector_create() argument
2586 struct drm_connector *connector = &hdmi->connector; in dw_hdmi_connector_create()
2590 if (hdmi->version >= 0x200a) in dw_hdmi_connector_create()
2592 hdmi->plat_data->ycbcr_420_allowed; in dw_hdmi_connector_create()
2601 drm_connector_init_with_ddc(hdmi->bridge.dev, connector, in dw_hdmi_connector_create()
2604 hdmi->ddc); in dw_hdmi_connector_create()
2614 if (hdmi->version >= 0x200a && hdmi->plat_data->use_drm_infoframe) in dw_hdmi_connector_create()
2617 drm_connector_attach_encoder(connector, hdmi->bridge.encoder); in dw_hdmi_connector_create()
2621 notifier = cec_notifier_conn_register(hdmi->dev, NULL, &conn_info); in dw_hdmi_connector_create()
2625 mutex_lock(&hdmi->cec_notifier_mutex); in dw_hdmi_connector_create()
2626 hdmi->cec_notifier = notifier; in dw_hdmi_connector_create()
2627 mutex_unlock(&hdmi->cec_notifier_mutex); in dw_hdmi_connector_create()
2668 bool is_hdmi2_sink = info->hdmi.scdc.supported || in dw_hdmi_bridge_atomic_get_output_bus_fmts()
2699 (info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_48)) in dw_hdmi_bridge_atomic_get_output_bus_fmts()
2703 (info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_36)) in dw_hdmi_bridge_atomic_get_output_bus_fmts()
2707 (info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_30)) in dw_hdmi_bridge_atomic_get_output_bus_fmts()
2893 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_atomic_check() local
2895 hdmi->hdmi_data.enc_out_bus_format = in dw_hdmi_bridge_atomic_check()
2898 hdmi->hdmi_data.enc_in_bus_format = in dw_hdmi_bridge_atomic_check()
2901 dev_dbg(hdmi->dev, "input format 0x%04x, output format 0x%04x\n", in dw_hdmi_bridge_atomic_check()
2911 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_attach() local
2914 return drm_bridge_attach(bridge->encoder, hdmi->next_bridge, in dw_hdmi_bridge_attach()
2917 return dw_hdmi_connector_create(hdmi); in dw_hdmi_bridge_attach()
2922 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_detach() local
2924 mutex_lock(&hdmi->cec_notifier_mutex); in dw_hdmi_bridge_detach()
2925 cec_notifier_conn_unregister(hdmi->cec_notifier); in dw_hdmi_bridge_detach()
2926 hdmi->cec_notifier = NULL; in dw_hdmi_bridge_detach()
2927 mutex_unlock(&hdmi->cec_notifier_mutex); in dw_hdmi_bridge_detach()
2935 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_mode_valid() local
2936 const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; in dw_hdmi_bridge_mode_valid()
2944 mode_status = pdata->mode_valid(hdmi, pdata->priv_data, info, in dw_hdmi_bridge_mode_valid()
2954 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_mode_set() local
2956 mutex_lock(&hdmi->mutex); in dw_hdmi_bridge_mode_set()
2959 drm_mode_copy(&hdmi->previous_mode, mode); in dw_hdmi_bridge_mode_set()
2961 mutex_unlock(&hdmi->mutex); in dw_hdmi_bridge_mode_set()
2967 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_atomic_disable() local
2969 mutex_lock(&hdmi->mutex); in dw_hdmi_bridge_atomic_disable()
2970 hdmi->disabled = true; in dw_hdmi_bridge_atomic_disable()
2971 hdmi->curr_conn = NULL; in dw_hdmi_bridge_atomic_disable()
2972 dw_hdmi_update_power(hdmi); in dw_hdmi_bridge_atomic_disable()
2973 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_bridge_atomic_disable()
2974 mutex_unlock(&hdmi->mutex); in dw_hdmi_bridge_atomic_disable()
2980 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_atomic_enable() local
2987 mutex_lock(&hdmi->mutex); in dw_hdmi_bridge_atomic_enable()
2988 hdmi->disabled = false; in dw_hdmi_bridge_atomic_enable()
2989 hdmi->curr_conn = connector; in dw_hdmi_bridge_atomic_enable()
2990 dw_hdmi_update_power(hdmi); in dw_hdmi_bridge_atomic_enable()
2991 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_bridge_atomic_enable()
2992 mutex_unlock(&hdmi->mutex); in dw_hdmi_bridge_atomic_enable()
2997 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_detect() local
2999 return dw_hdmi_detect(hdmi); in dw_hdmi_bridge_detect()
3005 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_get_edid() local
3007 return dw_hdmi_get_edid(hdmi, connector); in dw_hdmi_bridge_get_edid()
3031 static irqreturn_t dw_hdmi_i2c_irq(struct dw_hdmi *hdmi) in dw_hdmi_i2c_irq() argument
3033 struct dw_hdmi_i2c *i2c = hdmi->i2c; in dw_hdmi_i2c_irq()
3036 stat = hdmi_readb(hdmi, HDMI_IH_I2CM_STAT0); in dw_hdmi_i2c_irq()
3040 hdmi_writeb(hdmi, stat, HDMI_IH_I2CM_STAT0); in dw_hdmi_i2c_irq()
3051 struct dw_hdmi *hdmi = dev_id; in dw_hdmi_hardirq() local
3055 if (hdmi->i2c) in dw_hdmi_hardirq()
3056 ret = dw_hdmi_i2c_irq(hdmi); in dw_hdmi_hardirq()
3058 intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); in dw_hdmi_hardirq()
3060 hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); in dw_hdmi_hardirq()
3067 void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense) in dw_hdmi_setup_rx_sense() argument
3069 mutex_lock(&hdmi->mutex); in dw_hdmi_setup_rx_sense()
3071 if (!hdmi->force) { in dw_hdmi_setup_rx_sense()
3077 hdmi->rxsense = false; in dw_hdmi_setup_rx_sense()
3086 hdmi->rxsense = true; in dw_hdmi_setup_rx_sense()
3088 dw_hdmi_update_power(hdmi); in dw_hdmi_setup_rx_sense()
3089 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_setup_rx_sense()
3091 mutex_unlock(&hdmi->mutex); in dw_hdmi_setup_rx_sense()
3097 struct dw_hdmi *hdmi = dev_id; in dw_hdmi_irq() local
3101 intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); in dw_hdmi_irq()
3102 phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0); in dw_hdmi_irq()
3103 phy_stat = hdmi_readb(hdmi, HDMI_PHY_STAT0); in dw_hdmi_irq()
3118 hdmi_modb(hdmi, ~phy_int_pol, phy_pol_mask, HDMI_PHY_POL0); in dw_hdmi_irq()
3129 dw_hdmi_setup_rx_sense(hdmi, in dw_hdmi_irq()
3134 mutex_lock(&hdmi->cec_notifier_mutex); in dw_hdmi_irq()
3135 cec_notifier_phys_addr_invalidate(hdmi->cec_notifier); in dw_hdmi_irq()
3136 mutex_unlock(&hdmi->cec_notifier_mutex); in dw_hdmi_irq()
3147 dev_dbg(hdmi->dev, "EVENT=%s\n", in dw_hdmi_irq()
3151 if (hdmi->bridge.dev) { in dw_hdmi_irq()
3152 drm_helper_hpd_irq_event(hdmi->bridge.dev); in dw_hdmi_irq()
3153 drm_bridge_hpd_notify(&hdmi->bridge, status); in dw_hdmi_irq()
3157 hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0); in dw_hdmi_irq()
3158 hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), in dw_hdmi_irq()
3203 static int dw_hdmi_detect_phy(struct dw_hdmi *hdmi) in dw_hdmi_detect_phy() argument
3208 phy_type = hdmi->plat_data->phy_force_vendor ? in dw_hdmi_detect_phy()
3210 hdmi_readb(hdmi, HDMI_CONFIG2_ID); in dw_hdmi_detect_phy()
3214 if (!hdmi->plat_data->phy_ops || !hdmi->plat_data->phy_name) { in dw_hdmi_detect_phy()
3215 dev_err(hdmi->dev, in dw_hdmi_detect_phy()
3220 hdmi->phy.ops = hdmi->plat_data->phy_ops; in dw_hdmi_detect_phy()
3221 hdmi->phy.data = hdmi->plat_data->phy_data; in dw_hdmi_detect_phy()
3222 hdmi->phy.name = hdmi->plat_data->phy_name; in dw_hdmi_detect_phy()
3229 hdmi->phy.ops = &dw_hdmi_synopsys_phy_ops; in dw_hdmi_detect_phy()
3230 hdmi->phy.name = dw_hdmi_phys[i].name; in dw_hdmi_detect_phy()
3231 hdmi->phy.data = (void *)&dw_hdmi_phys[i]; in dw_hdmi_detect_phy()
3234 !hdmi->plat_data->configure_phy) { in dw_hdmi_detect_phy()
3235 dev_err(hdmi->dev, "%s requires platform support\n", in dw_hdmi_detect_phy()
3236 hdmi->phy.name); in dw_hdmi_detect_phy()
3244 dev_err(hdmi->dev, "Unsupported HDMI PHY type (%02x)\n", phy_type); in dw_hdmi_detect_phy()
3248 static void dw_hdmi_cec_enable(struct dw_hdmi *hdmi) in dw_hdmi_cec_enable() argument
3250 mutex_lock(&hdmi->mutex); in dw_hdmi_cec_enable()
3251 hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_CECCLK_DISABLE; in dw_hdmi_cec_enable()
3252 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in dw_hdmi_cec_enable()
3253 mutex_unlock(&hdmi->mutex); in dw_hdmi_cec_enable()
3256 static void dw_hdmi_cec_disable(struct dw_hdmi *hdmi) in dw_hdmi_cec_disable() argument
3258 mutex_lock(&hdmi->mutex); in dw_hdmi_cec_disable()
3259 hdmi->mc_clkdis |= HDMI_MC_CLKDIS_CECCLK_DISABLE; in dw_hdmi_cec_disable()
3260 hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); in dw_hdmi_cec_disable()
3261 mutex_unlock(&hdmi->mutex); in dw_hdmi_cec_disable()
3285 static void dw_hdmi_init_hw(struct dw_hdmi *hdmi) in dw_hdmi_init_hw() argument
3287 initialize_hdmi_ih_mutes(hdmi); in dw_hdmi_init_hw()
3294 dw_hdmi_i2c_init(hdmi); in dw_hdmi_init_hw()
3296 if (hdmi->phy.ops->setup_hpd) in dw_hdmi_init_hw()
3297 hdmi->phy.ops->setup_hpd(hdmi, hdmi->phy.data); in dw_hdmi_init_hw()
3304 static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi) in dw_hdmi_parse_dt() argument
3309 if (!hdmi->plat_data->output_port) in dw_hdmi_parse_dt()
3312 endpoint = of_graph_get_endpoint_by_regs(hdmi->dev->of_node, in dw_hdmi_parse_dt()
3313 hdmi->plat_data->output_port, in dw_hdmi_parse_dt()
3321 dev_err(hdmi->dev, "Missing endpoint in port@%u\n", in dw_hdmi_parse_dt()
3322 hdmi->plat_data->output_port); in dw_hdmi_parse_dt()
3329 dev_err(hdmi->dev, "Endpoint in port@%u unconnected\n", in dw_hdmi_parse_dt()
3330 hdmi->plat_data->output_port); in dw_hdmi_parse_dt()
3335 dev_err(hdmi->dev, "port@%u remote device is disabled\n", in dw_hdmi_parse_dt()
3336 hdmi->plat_data->output_port); in dw_hdmi_parse_dt()
3341 hdmi->next_bridge = of_drm_find_bridge(remote); in dw_hdmi_parse_dt()
3343 if (!hdmi->next_bridge) in dw_hdmi_parse_dt()
3357 struct dw_hdmi *hdmi; in dw_hdmi_probe() local
3367 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in dw_hdmi_probe()
3368 if (!hdmi) in dw_hdmi_probe()
3371 hdmi->plat_data = plat_data; in dw_hdmi_probe()
3372 hdmi->dev = dev; in dw_hdmi_probe()
3373 hdmi->sample_rate = 48000; in dw_hdmi_probe()
3374 hdmi->channels = 2; in dw_hdmi_probe()
3375 hdmi->disabled = true; in dw_hdmi_probe()
3376 hdmi->rxsense = true; in dw_hdmi_probe()
3377 hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); in dw_hdmi_probe()
3378 hdmi->mc_clkdis = 0x7f; in dw_hdmi_probe()
3379 hdmi->last_connector_result = connector_status_disconnected; in dw_hdmi_probe()
3381 mutex_init(&hdmi->mutex); in dw_hdmi_probe()
3382 mutex_init(&hdmi->audio_mutex); in dw_hdmi_probe()
3383 mutex_init(&hdmi->cec_notifier_mutex); in dw_hdmi_probe()
3384 spin_lock_init(&hdmi->audio_lock); in dw_hdmi_probe()
3386 ret = dw_hdmi_parse_dt(hdmi); in dw_hdmi_probe()
3392 hdmi->ddc = of_get_i2c_adapter_by_node(ddc_node); in dw_hdmi_probe()
3394 if (!hdmi->ddc) { in dw_hdmi_probe()
3395 dev_dbg(hdmi->dev, "failed to read ddc node\n"); in dw_hdmi_probe()
3400 dev_dbg(hdmi->dev, "no ddc property found\n"); in dw_hdmi_probe()
3410 hdmi->reg_shift = 2; in dw_hdmi_probe()
3421 hdmi->regs = devm_ioremap_resource(dev, iores); in dw_hdmi_probe()
3422 if (IS_ERR(hdmi->regs)) { in dw_hdmi_probe()
3423 ret = PTR_ERR(hdmi->regs); in dw_hdmi_probe()
3427 hdmi->regm = devm_regmap_init_mmio(dev, hdmi->regs, reg_config); in dw_hdmi_probe()
3428 if (IS_ERR(hdmi->regm)) { in dw_hdmi_probe()
3430 ret = PTR_ERR(hdmi->regm); in dw_hdmi_probe()
3434 hdmi->regm = plat_data->regm; in dw_hdmi_probe()
3437 hdmi->isfr_clk = devm_clk_get(hdmi->dev, "isfr"); in dw_hdmi_probe()
3438 if (IS_ERR(hdmi->isfr_clk)) { in dw_hdmi_probe()
3439 ret = PTR_ERR(hdmi->isfr_clk); in dw_hdmi_probe()
3440 dev_err(hdmi->dev, "Unable to get HDMI isfr clk: %d\n", ret); in dw_hdmi_probe()
3444 ret = clk_prepare_enable(hdmi->isfr_clk); in dw_hdmi_probe()
3446 dev_err(hdmi->dev, "Cannot enable HDMI isfr clock: %d\n", ret); in dw_hdmi_probe()
3450 hdmi->iahb_clk = devm_clk_get(hdmi->dev, "iahb"); in dw_hdmi_probe()
3451 if (IS_ERR(hdmi->iahb_clk)) { in dw_hdmi_probe()
3452 ret = PTR_ERR(hdmi->iahb_clk); in dw_hdmi_probe()
3453 dev_err(hdmi->dev, "Unable to get HDMI iahb clk: %d\n", ret); in dw_hdmi_probe()
3457 ret = clk_prepare_enable(hdmi->iahb_clk); in dw_hdmi_probe()
3459 dev_err(hdmi->dev, "Cannot enable HDMI iahb clock: %d\n", ret); in dw_hdmi_probe()
3463 hdmi->cec_clk = devm_clk_get(hdmi->dev, "cec"); in dw_hdmi_probe()
3464 if (PTR_ERR(hdmi->cec_clk) == -ENOENT) { in dw_hdmi_probe()
3465 hdmi->cec_clk = NULL; in dw_hdmi_probe()
3466 } else if (IS_ERR(hdmi->cec_clk)) { in dw_hdmi_probe()
3467 ret = PTR_ERR(hdmi->cec_clk); in dw_hdmi_probe()
3469 dev_err(hdmi->dev, "Cannot get HDMI cec clock: %d\n", in dw_hdmi_probe()
3472 hdmi->cec_clk = NULL; in dw_hdmi_probe()
3475 ret = clk_prepare_enable(hdmi->cec_clk); in dw_hdmi_probe()
3477 dev_err(hdmi->dev, "Cannot enable HDMI cec clock: %d\n", in dw_hdmi_probe()
3484 hdmi->version = (hdmi_readb(hdmi, HDMI_DESIGN_ID) << 8) in dw_hdmi_probe()
3485 | (hdmi_readb(hdmi, HDMI_REVISION_ID) << 0); in dw_hdmi_probe()
3486 prod_id0 = hdmi_readb(hdmi, HDMI_PRODUCT_ID0); in dw_hdmi_probe()
3487 prod_id1 = hdmi_readb(hdmi, HDMI_PRODUCT_ID1); in dw_hdmi_probe()
3492 hdmi->version, prod_id0, prod_id1); in dw_hdmi_probe()
3497 ret = dw_hdmi_detect_phy(hdmi); in dw_hdmi_probe()
3502 hdmi->version >> 12, hdmi->version & 0xfff, in dw_hdmi_probe()
3504 hdmi->phy.name); in dw_hdmi_probe()
3506 dw_hdmi_init_hw(hdmi); in dw_hdmi_probe()
3516 dev_name(dev), hdmi); in dw_hdmi_probe()
3524 hdmi_init_clk_regenerator(hdmi); in dw_hdmi_probe()
3527 if (!hdmi->ddc) { in dw_hdmi_probe()
3529 hdmi->pinctrl = devm_pinctrl_get(dev); in dw_hdmi_probe()
3530 if (!IS_ERR(hdmi->pinctrl)) { in dw_hdmi_probe()
3531 hdmi->unwedge_state = in dw_hdmi_probe()
3532 pinctrl_lookup_state(hdmi->pinctrl, "unwedge"); in dw_hdmi_probe()
3533 hdmi->default_state = in dw_hdmi_probe()
3534 pinctrl_lookup_state(hdmi->pinctrl, "default"); in dw_hdmi_probe()
3536 if (IS_ERR(hdmi->default_state) || in dw_hdmi_probe()
3537 IS_ERR(hdmi->unwedge_state)) { in dw_hdmi_probe()
3538 if (!IS_ERR(hdmi->unwedge_state)) in dw_hdmi_probe()
3541 hdmi->default_state = NULL; in dw_hdmi_probe()
3542 hdmi->unwedge_state = NULL; in dw_hdmi_probe()
3546 hdmi->ddc = dw_hdmi_i2c_adapter(hdmi); in dw_hdmi_probe()
3547 if (IS_ERR(hdmi->ddc)) in dw_hdmi_probe()
3548 hdmi->ddc = NULL; in dw_hdmi_probe()
3551 hdmi->bridge.driver_private = hdmi; in dw_hdmi_probe()
3552 hdmi->bridge.funcs = &dw_hdmi_bridge_funcs; in dw_hdmi_probe()
3553 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID in dw_hdmi_probe()
3555 hdmi->bridge.interlace_allowed = true; in dw_hdmi_probe()
3557 hdmi->bridge.of_node = pdev->dev.of_node; in dw_hdmi_probe()
3564 config0 = hdmi_readb(hdmi, HDMI_CONFIG0_ID); in dw_hdmi_probe()
3565 config3 = hdmi_readb(hdmi, HDMI_CONFIG3_ID); in dw_hdmi_probe()
3571 audio.base = hdmi->regs; in dw_hdmi_probe()
3573 audio.hdmi = hdmi; in dw_hdmi_probe()
3575 hdmi->enable_audio = dw_hdmi_ahb_audio_enable; in dw_hdmi_probe()
3576 hdmi->disable_audio = dw_hdmi_ahb_audio_disable; in dw_hdmi_probe()
3582 hdmi->audio = platform_device_register_full(&pdevinfo); in dw_hdmi_probe()
3586 audio.hdmi = hdmi; in dw_hdmi_probe()
3590 hdmi->enable_audio = dw_hdmi_i2s_audio_enable; in dw_hdmi_probe()
3591 hdmi->disable_audio = dw_hdmi_i2s_audio_disable; in dw_hdmi_probe()
3597 hdmi->audio = platform_device_register_full(&pdevinfo); in dw_hdmi_probe()
3602 audio.base = hdmi->regs; in dw_hdmi_probe()
3604 audio.hdmi = hdmi; in dw_hdmi_probe()
3607 hdmi->enable_audio = dw_hdmi_gp_audio_enable; in dw_hdmi_probe()
3608 hdmi->disable_audio = dw_hdmi_gp_audio_disable; in dw_hdmi_probe()
3615 hdmi->audio = platform_device_register_full(&pdevinfo); in dw_hdmi_probe()
3619 cec.hdmi = hdmi; in dw_hdmi_probe()
3628 hdmi->cec = platform_device_register_full(&pdevinfo); in dw_hdmi_probe()
3631 drm_bridge_add(&hdmi->bridge); in dw_hdmi_probe()
3633 return hdmi; in dw_hdmi_probe()
3636 clk_disable_unprepare(hdmi->iahb_clk); in dw_hdmi_probe()
3637 clk_disable_unprepare(hdmi->cec_clk); in dw_hdmi_probe()
3639 clk_disable_unprepare(hdmi->isfr_clk); in dw_hdmi_probe()
3641 i2c_put_adapter(hdmi->ddc); in dw_hdmi_probe()
3647 void dw_hdmi_remove(struct dw_hdmi *hdmi) in dw_hdmi_remove() argument
3649 drm_bridge_remove(&hdmi->bridge); in dw_hdmi_remove()
3651 if (hdmi->audio && !IS_ERR(hdmi->audio)) in dw_hdmi_remove()
3652 platform_device_unregister(hdmi->audio); in dw_hdmi_remove()
3653 if (!IS_ERR(hdmi->cec)) in dw_hdmi_remove()
3654 platform_device_unregister(hdmi->cec); in dw_hdmi_remove()
3657 hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); in dw_hdmi_remove()
3659 clk_disable_unprepare(hdmi->iahb_clk); in dw_hdmi_remove()
3660 clk_disable_unprepare(hdmi->isfr_clk); in dw_hdmi_remove()
3661 clk_disable_unprepare(hdmi->cec_clk); in dw_hdmi_remove()
3663 if (hdmi->i2c) in dw_hdmi_remove()
3664 i2c_del_adapter(&hdmi->i2c->adap); in dw_hdmi_remove()
3666 i2c_put_adapter(hdmi->ddc); in dw_hdmi_remove()
3677 struct dw_hdmi *hdmi; in dw_hdmi_bind() local
3680 hdmi = dw_hdmi_probe(pdev, plat_data); in dw_hdmi_bind()
3681 if (IS_ERR(hdmi)) in dw_hdmi_bind()
3682 return hdmi; in dw_hdmi_bind()
3684 ret = drm_bridge_attach(encoder, &hdmi->bridge, NULL, 0); in dw_hdmi_bind()
3686 dw_hdmi_remove(hdmi); in dw_hdmi_bind()
3690 return hdmi; in dw_hdmi_bind()
3694 void dw_hdmi_unbind(struct dw_hdmi *hdmi) in dw_hdmi_unbind() argument
3696 dw_hdmi_remove(hdmi); in dw_hdmi_unbind()
3700 void dw_hdmi_resume(struct dw_hdmi *hdmi) in dw_hdmi_resume() argument
3702 dw_hdmi_init_hw(hdmi); in dw_hdmi_resume()