Lines Matching refs:hdmi
144 void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
145 u8 (*read)(struct dw_hdmi *hdmi, int offset);
156 static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset) in dw_hdmi_writel() argument
158 writel(val, hdmi->regs + (offset << 2)); in dw_hdmi_writel()
161 static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset) in dw_hdmi_readl() argument
163 return readl(hdmi->regs + (offset << 2)); in dw_hdmi_readl()
166 static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset) in dw_hdmi_writeb() argument
168 writeb(val, hdmi->regs + offset); in dw_hdmi_writeb()
171 static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset) in dw_hdmi_readb() argument
173 return readb(hdmi->regs + offset); in dw_hdmi_readb()
176 static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset) in hdmi_writeb() argument
178 hdmi->write(hdmi, val, offset); in hdmi_writeb()
181 static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset) in hdmi_readb() argument
183 return hdmi->read(hdmi, offset); in hdmi_readb()
186 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg) in hdmi_modb() argument
188 u8 val = hdmi_readb(hdmi, reg) & ~mask; in hdmi_modb()
191 hdmi_writeb(hdmi, val, reg); in hdmi_modb()
194 static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg, in hdmi_mask_writeb() argument
197 hdmi_modb(hdmi, data << shift, mask, reg); in hdmi_mask_writeb()
200 static void hdmi_set_cts_n(struct dw_hdmi *hdmi, unsigned int cts, in hdmi_set_cts_n() argument
204 hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_CTS_MANUAL, HDMI_AUD_CTS3); in hdmi_set_cts_n()
207 hdmi_modb(hdmi, 0, HDMI_AUD_CTS3_N_SHIFT_MASK, HDMI_AUD_CTS3); in hdmi_set_cts_n()
209 hdmi_writeb(hdmi, ((cts >> 16) & HDMI_AUD_CTS3_AUDCTS19_16_MASK) | in hdmi_set_cts_n()
211 hdmi_writeb(hdmi, (cts >> 8) & 0xff, HDMI_AUD_CTS2); in hdmi_set_cts_n()
212 hdmi_writeb(hdmi, cts & 0xff, HDMI_AUD_CTS1); in hdmi_set_cts_n()
214 hdmi_writeb(hdmi, (n >> 16) & 0x0f, HDMI_AUD_N3); in hdmi_set_cts_n()
215 hdmi_writeb(hdmi, (n >> 8) & 0xff, HDMI_AUD_N2); in hdmi_set_cts_n()
216 hdmi_writeb(hdmi, n & 0xff, HDMI_AUD_N1); in hdmi_set_cts_n()
275 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, in hdmi_set_clk_regenerator() argument
295 dev_dbg(hdmi->dev, "%s: fs=%uHz ftdms=%lu.%03luMHz N=%d cts=%d\n", in hdmi_set_clk_regenerator()
299 spin_lock_irq(&hdmi->audio_lock); in hdmi_set_clk_regenerator()
300 hdmi->audio_n = n; in hdmi_set_clk_regenerator()
301 hdmi->audio_cts = cts; in hdmi_set_clk_regenerator()
302 hdmi_set_cts_n(hdmi, cts, hdmi->audio_enable ? n : 0); in hdmi_set_clk_regenerator()
303 spin_unlock_irq(&hdmi->audio_lock); in hdmi_set_clk_regenerator()
306 static void hdmi_init_clk_regenerator(struct dw_hdmi *hdmi) in hdmi_init_clk_regenerator() argument
308 mutex_lock(&hdmi->audio_mutex); in hdmi_init_clk_regenerator()
309 hdmi_set_clk_regenerator(hdmi, 74250000, hdmi->sample_rate); in hdmi_init_clk_regenerator()
310 mutex_unlock(&hdmi->audio_mutex); in hdmi_init_clk_regenerator()
313 static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi) in hdmi_clk_regenerator_update_pixel_clock() argument
315 mutex_lock(&hdmi->audio_mutex); in hdmi_clk_regenerator_update_pixel_clock()
316 hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock, in hdmi_clk_regenerator_update_pixel_clock()
317 hdmi->sample_rate); in hdmi_clk_regenerator_update_pixel_clock()
318 mutex_unlock(&hdmi->audio_mutex); in hdmi_clk_regenerator_update_pixel_clock()
321 void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate) in dw_hdmi_set_sample_rate() argument
323 mutex_lock(&hdmi->audio_mutex); in dw_hdmi_set_sample_rate()
324 hdmi->sample_rate = rate; in dw_hdmi_set_sample_rate()
325 hdmi_set_clk_regenerator(hdmi, hdmi->hdmi_data.video_mode.mpixelclock, in dw_hdmi_set_sample_rate()
326 hdmi->sample_rate); in dw_hdmi_set_sample_rate()
327 mutex_unlock(&hdmi->audio_mutex); in dw_hdmi_set_sample_rate()
331 void dw_hdmi_audio_enable(struct dw_hdmi *hdmi) in dw_hdmi_audio_enable() argument
335 spin_lock_irqsave(&hdmi->audio_lock, flags); in dw_hdmi_audio_enable()
336 hdmi->audio_enable = true; in dw_hdmi_audio_enable()
337 hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); in dw_hdmi_audio_enable()
338 spin_unlock_irqrestore(&hdmi->audio_lock, flags); in dw_hdmi_audio_enable()
342 void dw_hdmi_audio_disable(struct dw_hdmi *hdmi) in dw_hdmi_audio_disable() argument
346 spin_lock_irqsave(&hdmi->audio_lock, flags); in dw_hdmi_audio_disable()
347 hdmi->audio_enable = false; in dw_hdmi_audio_disable()
348 hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0); in dw_hdmi_audio_disable()
349 spin_unlock_irqrestore(&hdmi->audio_lock, flags); in dw_hdmi_audio_disable()
360 static void hdmi_video_sample(struct dw_hdmi *hdmi) in hdmi_video_sample() argument
365 if (hdmi->hdmi_data.enc_in_format == RGB) { in hdmi_video_sample()
366 if (hdmi->hdmi_data.enc_color_depth == 8) in hdmi_video_sample()
368 else if (hdmi->hdmi_data.enc_color_depth == 10) in hdmi_video_sample()
370 else if (hdmi->hdmi_data.enc_color_depth == 12) in hdmi_video_sample()
372 else if (hdmi->hdmi_data.enc_color_depth == 16) in hdmi_video_sample()
376 } else if (hdmi->hdmi_data.enc_in_format == YCBCR444) { in hdmi_video_sample()
377 if (hdmi->hdmi_data.enc_color_depth == 8) in hdmi_video_sample()
379 else if (hdmi->hdmi_data.enc_color_depth == 10) in hdmi_video_sample()
381 else if (hdmi->hdmi_data.enc_color_depth == 12) in hdmi_video_sample()
383 else if (hdmi->hdmi_data.enc_color_depth == 16) in hdmi_video_sample()
387 } else if (hdmi->hdmi_data.enc_in_format == YCBCR422_8BITS) { in hdmi_video_sample()
388 if (hdmi->hdmi_data.enc_color_depth == 8) in hdmi_video_sample()
390 else if (hdmi->hdmi_data.enc_color_depth == 10) in hdmi_video_sample()
392 else if (hdmi->hdmi_data.enc_color_depth == 12) in hdmi_video_sample()
401 hdmi_writeb(hdmi, val, HDMI_TX_INVID0); in hdmi_video_sample()
407 hdmi_writeb(hdmi, val, HDMI_TX_INSTUFFING); in hdmi_video_sample()
408 hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA0); in hdmi_video_sample()
409 hdmi_writeb(hdmi, 0x0, HDMI_TX_GYDATA1); in hdmi_video_sample()
410 hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA0); in hdmi_video_sample()
411 hdmi_writeb(hdmi, 0x0, HDMI_TX_RCRDATA1); in hdmi_video_sample()
412 hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA0); in hdmi_video_sample()
413 hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA1); in hdmi_video_sample()
416 static int is_color_space_conversion(struct dw_hdmi *hdmi) in is_color_space_conversion() argument
418 return hdmi->hdmi_data.enc_in_format != hdmi->hdmi_data.enc_out_format; in is_color_space_conversion()
421 static int is_color_space_decimation(struct dw_hdmi *hdmi) in is_color_space_decimation() argument
423 if (hdmi->hdmi_data.enc_out_format != YCBCR422_8BITS) in is_color_space_decimation()
425 if (hdmi->hdmi_data.enc_in_format == RGB || in is_color_space_decimation()
426 hdmi->hdmi_data.enc_in_format == YCBCR444) in is_color_space_decimation()
431 static int is_color_space_interpolation(struct dw_hdmi *hdmi) in is_color_space_interpolation() argument
433 if (hdmi->hdmi_data.enc_in_format != YCBCR422_8BITS) in is_color_space_interpolation()
435 if (hdmi->hdmi_data.enc_out_format == RGB || in is_color_space_interpolation()
436 hdmi->hdmi_data.enc_out_format == YCBCR444) in is_color_space_interpolation()
441 static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) in dw_hdmi_update_csc_coeffs() argument
447 if (is_color_space_conversion(hdmi)) { in dw_hdmi_update_csc_coeffs()
448 if (hdmi->hdmi_data.enc_out_format == RGB) { in dw_hdmi_update_csc_coeffs()
449 if (hdmi->hdmi_data.colorimetry == in dw_hdmi_update_csc_coeffs()
454 } else if (hdmi->hdmi_data.enc_in_format == RGB) { in dw_hdmi_update_csc_coeffs()
455 if (hdmi->hdmi_data.colorimetry == in dw_hdmi_update_csc_coeffs()
470 hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2); in dw_hdmi_update_csc_coeffs()
471 hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2); in dw_hdmi_update_csc_coeffs()
472 hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2); in dw_hdmi_update_csc_coeffs()
473 hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2); in dw_hdmi_update_csc_coeffs()
474 hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2); in dw_hdmi_update_csc_coeffs()
475 hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2); in dw_hdmi_update_csc_coeffs()
478 hdmi_modb(hdmi, csc_scale, HDMI_CSC_SCALE_CSCSCALE_MASK, in dw_hdmi_update_csc_coeffs()
482 static void hdmi_video_csc(struct dw_hdmi *hdmi) in hdmi_video_csc() argument
489 if (is_color_space_interpolation(hdmi)) in hdmi_video_csc()
491 else if (is_color_space_decimation(hdmi)) in hdmi_video_csc()
494 if (hdmi->hdmi_data.enc_color_depth == 8) in hdmi_video_csc()
496 else if (hdmi->hdmi_data.enc_color_depth == 10) in hdmi_video_csc()
498 else if (hdmi->hdmi_data.enc_color_depth == 12) in hdmi_video_csc()
500 else if (hdmi->hdmi_data.enc_color_depth == 16) in hdmi_video_csc()
506 hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG); in hdmi_video_csc()
507 hdmi_modb(hdmi, color_depth, HDMI_CSC_SCALE_CSC_COLORDE_PTH_MASK, in hdmi_video_csc()
510 dw_hdmi_update_csc_coeffs(hdmi); in hdmi_video_csc()
518 static void hdmi_video_packetize(struct dw_hdmi *hdmi) in hdmi_video_packetize() argument
523 struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; in hdmi_video_packetize()
563 hdmi_writeb(hdmi, val, HDMI_VP_PR_CD); in hdmi_video_packetize()
565 hdmi_modb(hdmi, HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE, in hdmi_video_packetize()
577 hdmi_modb(hdmi, vp_conf, in hdmi_video_packetize()
581 hdmi_modb(hdmi, 1 << HDMI_VP_STUFF_IDEFAULT_PHASE_OFFSET, in hdmi_video_packetize()
584 hdmi_writeb(hdmi, remap_size, HDMI_VP_REMAP); in hdmi_video_packetize()
602 hdmi_modb(hdmi, vp_conf, in hdmi_video_packetize()
606 hdmi_modb(hdmi, HDMI_VP_STUFF_PP_STUFFING_STUFFING_MODE | in hdmi_video_packetize()
611 hdmi_modb(hdmi, output_select, HDMI_VP_CONF_OUTPUT_SELECTOR_MASK, in hdmi_video_packetize()
615 static inline void hdmi_phy_test_clear(struct dw_hdmi *hdmi, in hdmi_phy_test_clear() argument
618 hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLR_OFFSET, in hdmi_phy_test_clear()
622 static inline void hdmi_phy_test_enable(struct dw_hdmi *hdmi, in hdmi_phy_test_enable() argument
625 hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTEN_OFFSET, in hdmi_phy_test_enable()
629 static inline void hdmi_phy_test_clock(struct dw_hdmi *hdmi, in hdmi_phy_test_clock() argument
632 hdmi_modb(hdmi, bit << HDMI_PHY_TST0_TSTCLK_OFFSET, in hdmi_phy_test_clock()
636 static inline void hdmi_phy_test_din(struct dw_hdmi *hdmi, in hdmi_phy_test_din() argument
639 hdmi_writeb(hdmi, bit, HDMI_PHY_TST1); in hdmi_phy_test_din()
642 static inline void hdmi_phy_test_dout(struct dw_hdmi *hdmi, in hdmi_phy_test_dout() argument
645 hdmi_writeb(hdmi, bit, HDMI_PHY_TST2); in hdmi_phy_test_dout()
648 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec) in hdmi_phy_wait_i2c_done() argument
652 while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) { in hdmi_phy_wait_i2c_done()
657 hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0); in hdmi_phy_wait_i2c_done()
662 static void __hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, in __hdmi_phy_i2c_write() argument
665 hdmi_writeb(hdmi, 0xFF, HDMI_IH_I2CMPHY_STAT0); in __hdmi_phy_i2c_write()
666 hdmi_writeb(hdmi, addr, HDMI_PHY_I2CM_ADDRESS_ADDR); in __hdmi_phy_i2c_write()
667 hdmi_writeb(hdmi, (unsigned char)(data >> 8), in __hdmi_phy_i2c_write()
669 hdmi_writeb(hdmi, (unsigned char)(data >> 0), in __hdmi_phy_i2c_write()
671 hdmi_writeb(hdmi, HDMI_PHY_I2CM_OPERATION_ADDR_WRITE, in __hdmi_phy_i2c_write()
673 hdmi_phy_wait_i2c_done(hdmi, 1000); in __hdmi_phy_i2c_write()
676 static int hdmi_phy_i2c_write(struct dw_hdmi *hdmi, unsigned short data, in hdmi_phy_i2c_write() argument
679 __hdmi_phy_i2c_write(hdmi, data, addr); in hdmi_phy_i2c_write()
683 static void dw_hdmi_phy_enable_powerdown(struct dw_hdmi *hdmi, bool enable) in dw_hdmi_phy_enable_powerdown() argument
685 hdmi_mask_writeb(hdmi, !enable, HDMI_PHY_CONF0, in dw_hdmi_phy_enable_powerdown()
690 static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_enable_tmds() argument
692 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_enable_tmds()
697 static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_enable_spare() argument
699 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_enable_spare()
704 static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_gen2_pddq() argument
706 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_gen2_pddq()
711 static void dw_hdmi_phy_gen2_txpwron(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_gen2_txpwron() argument
713 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_gen2_txpwron()
718 static void dw_hdmi_phy_sel_data_en_pol(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_sel_data_en_pol() argument
720 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_sel_data_en_pol()
725 static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) in dw_hdmi_phy_sel_interface_control() argument
727 hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0, in dw_hdmi_phy_sel_interface_control()
732 static int hdmi_phy_configure(struct dw_hdmi *hdmi, unsigned char prep, in hdmi_phy_configure() argument
737 const struct dw_hdmi_plat_data *pdata = hdmi->plat_data; in hdmi_phy_configure()
762 if (hdmi->hdmi_data.video_mode.mpixelclock <= in hdmi_phy_configure()
767 if (hdmi->hdmi_data.video_mode.mpixelclock <= in hdmi_phy_configure()
772 if (hdmi->hdmi_data.video_mode.mpixelclock <= in hdmi_phy_configure()
779 dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n", in hdmi_phy_configure()
780 hdmi->hdmi_data.video_mode.mpixelclock); in hdmi_phy_configure()
790 hdmi_writeb(hdmi, val, HDMI_MC_FLOWCTRL); in hdmi_phy_configure()
793 dw_hdmi_phy_gen2_txpwron(hdmi, 0); in hdmi_phy_configure()
796 dw_hdmi_phy_gen2_pddq(hdmi, 1); in hdmi_phy_configure()
799 hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_DEASSERT, HDMI_MC_PHYRSTZ); in hdmi_phy_configure()
800 hdmi_writeb(hdmi, HDMI_MC_PHYRSTZ_ASSERT, HDMI_MC_PHYRSTZ); in hdmi_phy_configure()
802 hdmi_writeb(hdmi, HDMI_MC_HEACPHY_RST_ASSERT, HDMI_MC_HEACPHY_RST); in hdmi_phy_configure()
804 hdmi_phy_test_clear(hdmi, 1); in hdmi_phy_configure()
805 hdmi_writeb(hdmi, HDMI_PHY_I2CM_SLAVE_ADDR_PHY_GEN2, in hdmi_phy_configure()
807 hdmi_phy_test_clear(hdmi, 0); in hdmi_phy_configure()
809 hdmi_phy_i2c_write(hdmi, mpll_config->res[res_idx].cpce, 0x06); in hdmi_phy_configure()
810 hdmi_phy_i2c_write(hdmi, mpll_config->res[res_idx].gmp, 0x15); in hdmi_phy_configure()
813 hdmi_phy_i2c_write(hdmi, curr_ctrl->curr[res_idx], 0x10); in hdmi_phy_configure()
815 hdmi_phy_i2c_write(hdmi, 0x0000, 0x13); /* PLLPHBYCTRL */ in hdmi_phy_configure()
816 hdmi_phy_i2c_write(hdmi, 0x0006, 0x17); in hdmi_phy_configure()
818 hdmi_phy_i2c_write(hdmi, phy_config->term, 0x19); /* TXTERM */ in hdmi_phy_configure()
819 hdmi_phy_i2c_write(hdmi, phy_config->sym_ctr, 0x09); /* CKSYMTXCTRL */ in hdmi_phy_configure()
820 hdmi_phy_i2c_write(hdmi, phy_config->vlev_ctr, 0x0E); /* VLEVCTRL */ in hdmi_phy_configure()
823 hdmi_phy_i2c_write(hdmi, 0x8000, 0x05); /* CKCALCTRL */ in hdmi_phy_configure()
825 dw_hdmi_phy_enable_powerdown(hdmi, false); in hdmi_phy_configure()
828 dw_hdmi_phy_enable_tmds(hdmi, 0); in hdmi_phy_configure()
829 dw_hdmi_phy_enable_tmds(hdmi, 1); in hdmi_phy_configure()
832 dw_hdmi_phy_gen2_txpwron(hdmi, 1); in hdmi_phy_configure()
833 dw_hdmi_phy_gen2_pddq(hdmi, 0); in hdmi_phy_configure()
835 if (hdmi->dev_type == RK3288_HDMI) in hdmi_phy_configure()
836 dw_hdmi_phy_enable_spare(hdmi, 1); in hdmi_phy_configure()
841 val = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_TX_PHY_LOCK; in hdmi_phy_configure()
846 dev_err(hdmi->dev, "PHY PLL not locked\n"); in hdmi_phy_configure()
857 static int dw_hdmi_phy_init(struct dw_hdmi *hdmi) in dw_hdmi_phy_init() argument
863 cscon = hdmi->sink_is_hdmi && is_color_space_conversion(hdmi); in dw_hdmi_phy_init()
867 dw_hdmi_phy_sel_data_en_pol(hdmi, 1); in dw_hdmi_phy_init()
868 dw_hdmi_phy_sel_interface_control(hdmi, 0); in dw_hdmi_phy_init()
869 dw_hdmi_phy_enable_tmds(hdmi, 0); in dw_hdmi_phy_init()
870 dw_hdmi_phy_enable_powerdown(hdmi, true); in dw_hdmi_phy_init()
873 ret = hdmi_phy_configure(hdmi, 0, 8, cscon); in dw_hdmi_phy_init()
878 hdmi->phy_enabled = true; in dw_hdmi_phy_init()
882 static void hdmi_tx_hdcp_config(struct dw_hdmi *hdmi) in hdmi_tx_hdcp_config() argument
886 if (hdmi->hdmi_data.video_mode.mdataenablepolarity) in hdmi_tx_hdcp_config()
892 hdmi_modb(hdmi, HDMI_A_HDCPCFG0_RXDETECT_DISABLE, in hdmi_tx_hdcp_config()
895 hdmi_modb(hdmi, de, HDMI_A_VIDPOLCFG_DATAENPOL_MASK, HDMI_A_VIDPOLCFG); in hdmi_tx_hdcp_config()
897 hdmi_modb(hdmi, HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_DISABLE, in hdmi_tx_hdcp_config()
901 static void hdmi_config_AVI(struct dw_hdmi *hdmi, struct drm_display_mode *mode) in hdmi_config_AVI() argument
909 if (hdmi->hdmi_data.enc_out_format == YCBCR444) in hdmi_config_AVI()
911 else if (hdmi->hdmi_data.enc_out_format == YCBCR422_8BITS) in hdmi_config_AVI()
917 if (hdmi->hdmi_data.enc_out_format == XVYCC444) { in hdmi_config_AVI()
919 if (hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_601) in hdmi_config_AVI()
925 } else if (hdmi->hdmi_data.enc_out_format != RGB) { in hdmi_config_AVI()
926 frame.colorimetry = hdmi->hdmi_data.colorimetry; in hdmi_config_AVI()
952 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF0); in hdmi_config_AVI()
958 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF1); in hdmi_config_AVI()
966 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF2); in hdmi_config_AVI()
970 hdmi_writeb(hdmi, val, HDMI_FC_AVIVID); in hdmi_config_AVI()
973 val = (((hdmi->hdmi_data.video_mode.mpixelrepetitioninput + 1) << in hdmi_config_AVI()
976 ((hdmi->hdmi_data.video_mode.mpixelrepetitionoutput << in hdmi_config_AVI()
979 hdmi_writeb(hdmi, val, HDMI_FC_PRCONF); in hdmi_config_AVI()
987 hdmi_writeb(hdmi, val, HDMI_FC_AVICONF3); in hdmi_config_AVI()
990 hdmi_writeb(hdmi, frame.top_bar & 0xff, HDMI_FC_AVIETB0); in hdmi_config_AVI()
991 hdmi_writeb(hdmi, (frame.top_bar >> 8) & 0xff, HDMI_FC_AVIETB1); in hdmi_config_AVI()
992 hdmi_writeb(hdmi, frame.bottom_bar & 0xff, HDMI_FC_AVISBB0); in hdmi_config_AVI()
993 hdmi_writeb(hdmi, (frame.bottom_bar >> 8) & 0xff, HDMI_FC_AVISBB1); in hdmi_config_AVI()
994 hdmi_writeb(hdmi, frame.left_bar & 0xff, HDMI_FC_AVIELB0); in hdmi_config_AVI()
995 hdmi_writeb(hdmi, (frame.left_bar >> 8) & 0xff, HDMI_FC_AVIELB1); in hdmi_config_AVI()
996 hdmi_writeb(hdmi, frame.right_bar & 0xff, HDMI_FC_AVISRB0); in hdmi_config_AVI()
997 hdmi_writeb(hdmi, (frame.right_bar >> 8) & 0xff, HDMI_FC_AVISRB1); in hdmi_config_AVI()
1000 static void hdmi_av_composer(struct dw_hdmi *hdmi, in hdmi_av_composer() argument
1004 struct hdmi_vmode *vmode = &hdmi->hdmi_data.video_mode; in hdmi_av_composer()
1010 dev_dbg(hdmi->dev, "final pixclk = %d\n", vmode->mpixelclock); in hdmi_av_composer()
1013 inv_val = (hdmi->hdmi_data.hdcp_enable ? in hdmi_av_composer()
1029 if (hdmi->vic == 39) in hdmi_av_composer()
1040 inv_val |= hdmi->sink_is_hdmi ? in hdmi_av_composer()
1044 hdmi_writeb(hdmi, inv_val, HDMI_FC_INVIDCONF); in hdmi_av_composer()
1063 hdmi_writeb(hdmi, mode->hdisplay >> 8, HDMI_FC_INHACTV1); in hdmi_av_composer()
1064 hdmi_writeb(hdmi, mode->hdisplay, HDMI_FC_INHACTV0); in hdmi_av_composer()
1067 hdmi_writeb(hdmi, vdisplay >> 8, HDMI_FC_INVACTV1); in hdmi_av_composer()
1068 hdmi_writeb(hdmi, vdisplay, HDMI_FC_INVACTV0); in hdmi_av_composer()
1072 hdmi_writeb(hdmi, hblank >> 8, HDMI_FC_INHBLANK1); in hdmi_av_composer()
1073 hdmi_writeb(hdmi, hblank, HDMI_FC_INHBLANK0); in hdmi_av_composer()
1076 hdmi_writeb(hdmi, vblank, HDMI_FC_INVBLANK); in hdmi_av_composer()
1080 hdmi_writeb(hdmi, h_de_hs >> 8, HDMI_FC_HSYNCINDELAY1); in hdmi_av_composer()
1081 hdmi_writeb(hdmi, h_de_hs, HDMI_FC_HSYNCINDELAY0); in hdmi_av_composer()
1084 hdmi_writeb(hdmi, v_de_vs, HDMI_FC_VSYNCINDELAY); in hdmi_av_composer()
1088 hdmi_writeb(hdmi, hsync_len >> 8, HDMI_FC_HSYNCINWIDTH1); in hdmi_av_composer()
1089 hdmi_writeb(hdmi, hsync_len, HDMI_FC_HSYNCINWIDTH0); in hdmi_av_composer()
1092 hdmi_writeb(hdmi, vsync_len, HDMI_FC_VSYNCINWIDTH); in hdmi_av_composer()
1095 static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi) in dw_hdmi_phy_disable() argument
1097 if (!hdmi->phy_enabled) in dw_hdmi_phy_disable()
1100 dw_hdmi_phy_enable_tmds(hdmi, 0); in dw_hdmi_phy_disable()
1101 dw_hdmi_phy_enable_powerdown(hdmi, true); in dw_hdmi_phy_disable()
1103 hdmi->phy_enabled = false; in dw_hdmi_phy_disable()
1107 static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi) in dw_hdmi_enable_video_path() argument
1112 hdmi_writeb(hdmi, 12, HDMI_FC_CTRLDUR); in dw_hdmi_enable_video_path()
1113 hdmi_writeb(hdmi, 32, HDMI_FC_EXCTRLDUR); in dw_hdmi_enable_video_path()
1114 hdmi_writeb(hdmi, 1, HDMI_FC_EXCTRLSPAC); in dw_hdmi_enable_video_path()
1117 hdmi_writeb(hdmi, 0x0B, HDMI_FC_CH0PREAM); in dw_hdmi_enable_video_path()
1118 hdmi_writeb(hdmi, 0x16, HDMI_FC_CH1PREAM); in dw_hdmi_enable_video_path()
1119 hdmi_writeb(hdmi, 0x21, HDMI_FC_CH2PREAM); in dw_hdmi_enable_video_path()
1124 hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
1127 hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
1130 if (is_color_space_conversion(hdmi)) { in dw_hdmi_enable_video_path()
1132 hdmi_writeb(hdmi, clkdis, HDMI_MC_CLKDIS); in dw_hdmi_enable_video_path()
1136 static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi) in hdmi_enable_audio_clk() argument
1138 hdmi_modb(hdmi, 0, HDMI_MC_CLKDIS_AUDCLK_DISABLE, HDMI_MC_CLKDIS); in hdmi_enable_audio_clk()
1142 static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) in dw_hdmi_clear_overflow() argument
1148 hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, HDMI_MC_SWRSTZ); in dw_hdmi_clear_overflow()
1150 val = hdmi_readb(hdmi, HDMI_FC_INVIDCONF); in dw_hdmi_clear_overflow()
1151 if (hdmi->dev_type == IMX6DL_HDMI) { in dw_hdmi_clear_overflow()
1152 hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF); in dw_hdmi_clear_overflow()
1157 hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF); in dw_hdmi_clear_overflow()
1160 static void hdmi_enable_overflow_interrupts(struct dw_hdmi *hdmi) in hdmi_enable_overflow_interrupts() argument
1162 hdmi_writeb(hdmi, 0, HDMI_FC_MASK2); in hdmi_enable_overflow_interrupts()
1163 hdmi_writeb(hdmi, 0, HDMI_IH_MUTE_FC_STAT2); in hdmi_enable_overflow_interrupts()
1166 static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) in hdmi_disable_overflow_interrupts() argument
1168 hdmi_writeb(hdmi, HDMI_IH_MUTE_FC_STAT2_OVERFLOW_MASK, in hdmi_disable_overflow_interrupts()
1172 static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) in dw_hdmi_setup() argument
1176 hdmi_disable_overflow_interrupts(hdmi); in dw_hdmi_setup()
1178 hdmi->vic = drm_match_cea_mode(mode); in dw_hdmi_setup()
1180 if (!hdmi->vic) { in dw_hdmi_setup()
1181 dev_dbg(hdmi->dev, "Non-CEA mode used in HDMI\n"); in dw_hdmi_setup()
1183 dev_dbg(hdmi->dev, "CEA mode used vic=%d\n", hdmi->vic); in dw_hdmi_setup()
1186 if ((hdmi->vic == 6) || (hdmi->vic == 7) || in dw_hdmi_setup()
1187 (hdmi->vic == 21) || (hdmi->vic == 22) || in dw_hdmi_setup()
1188 (hdmi->vic == 2) || (hdmi->vic == 3) || in dw_hdmi_setup()
1189 (hdmi->vic == 17) || (hdmi->vic == 18)) in dw_hdmi_setup()
1190 hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_601; in dw_hdmi_setup()
1192 hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; in dw_hdmi_setup()
1194 hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; in dw_hdmi_setup()
1195 hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; in dw_hdmi_setup()
1198 hdmi->hdmi_data.enc_in_format = RGB; in dw_hdmi_setup()
1200 hdmi->hdmi_data.enc_out_format = RGB; in dw_hdmi_setup()
1202 hdmi->hdmi_data.enc_color_depth = 8; in dw_hdmi_setup()
1203 hdmi->hdmi_data.pix_repet_factor = 0; in dw_hdmi_setup()
1204 hdmi->hdmi_data.hdcp_enable = 0; in dw_hdmi_setup()
1205 hdmi->hdmi_data.video_mode.mdataenablepolarity = true; in dw_hdmi_setup()
1208 hdmi_av_composer(hdmi, mode); in dw_hdmi_setup()
1211 ret = dw_hdmi_phy_init(hdmi); in dw_hdmi_setup()
1216 dw_hdmi_enable_video_path(hdmi); in dw_hdmi_setup()
1218 if (hdmi->sink_has_audio) { in dw_hdmi_setup()
1219 dev_dbg(hdmi->dev, "sink has audio support\n"); in dw_hdmi_setup()
1222 hdmi_clk_regenerator_update_pixel_clock(hdmi); in dw_hdmi_setup()
1223 hdmi_enable_audio_clk(hdmi); in dw_hdmi_setup()
1227 if (hdmi->sink_is_hdmi) { in dw_hdmi_setup()
1228 dev_dbg(hdmi->dev, "%s HDMI mode\n", __func__); in dw_hdmi_setup()
1231 hdmi_config_AVI(hdmi, mode); in dw_hdmi_setup()
1233 dev_dbg(hdmi->dev, "%s DVI mode\n", __func__); in dw_hdmi_setup()
1236 hdmi_video_packetize(hdmi); in dw_hdmi_setup()
1237 hdmi_video_csc(hdmi); in dw_hdmi_setup()
1238 hdmi_video_sample(hdmi); in dw_hdmi_setup()
1239 hdmi_tx_hdcp_config(hdmi); in dw_hdmi_setup()
1241 dw_hdmi_clear_overflow(hdmi); in dw_hdmi_setup()
1242 if (hdmi->cable_plugin && hdmi->sink_is_hdmi) in dw_hdmi_setup()
1243 hdmi_enable_overflow_interrupts(hdmi); in dw_hdmi_setup()
1249 static int dw_hdmi_fb_registered(struct dw_hdmi *hdmi) in dw_hdmi_fb_registered() argument
1251 hdmi_writeb(hdmi, HDMI_PHY_I2CM_INT_ADDR_DONE_POL, in dw_hdmi_fb_registered()
1254 hdmi_writeb(hdmi, HDMI_PHY_I2CM_CTLINT_ADDR_NAC_POL | in dw_hdmi_fb_registered()
1259 hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); in dw_hdmi_fb_registered()
1262 hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, in dw_hdmi_fb_registered()
1268 static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi) in initialize_hdmi_ih_mutes() argument
1279 ih_mute = hdmi_readb(hdmi, HDMI_IH_MUTE) | in initialize_hdmi_ih_mutes()
1283 hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); in initialize_hdmi_ih_mutes()
1286 hdmi_writeb(hdmi, 0xff, HDMI_VP_MASK); in initialize_hdmi_ih_mutes()
1287 hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK0); in initialize_hdmi_ih_mutes()
1288 hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK1); in initialize_hdmi_ih_mutes()
1289 hdmi_writeb(hdmi, 0xff, HDMI_FC_MASK2); in initialize_hdmi_ih_mutes()
1290 hdmi_writeb(hdmi, 0xff, HDMI_PHY_MASK0); in initialize_hdmi_ih_mutes()
1291 hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_INT_ADDR); in initialize_hdmi_ih_mutes()
1292 hdmi_writeb(hdmi, 0xff, HDMI_PHY_I2CM_CTLINT_ADDR); in initialize_hdmi_ih_mutes()
1293 hdmi_writeb(hdmi, 0xff, HDMI_AUD_INT); in initialize_hdmi_ih_mutes()
1294 hdmi_writeb(hdmi, 0xff, HDMI_AUD_SPDIFINT); in initialize_hdmi_ih_mutes()
1295 hdmi_writeb(hdmi, 0xff, HDMI_AUD_HBR_MASK); in initialize_hdmi_ih_mutes()
1296 hdmi_writeb(hdmi, 0xff, HDMI_GP_MASK); in initialize_hdmi_ih_mutes()
1297 hdmi_writeb(hdmi, 0xff, HDMI_A_APIINTMSK); in initialize_hdmi_ih_mutes()
1298 hdmi_writeb(hdmi, 0xff, HDMI_CEC_MASK); in initialize_hdmi_ih_mutes()
1299 hdmi_writeb(hdmi, 0xff, HDMI_I2CM_INT); in initialize_hdmi_ih_mutes()
1300 hdmi_writeb(hdmi, 0xff, HDMI_I2CM_CTLINT); in initialize_hdmi_ih_mutes()
1303 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT0); in initialize_hdmi_ih_mutes()
1304 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT1); in initialize_hdmi_ih_mutes()
1305 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_FC_STAT2); in initialize_hdmi_ih_mutes()
1306 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AS_STAT0); in initialize_hdmi_ih_mutes()
1307 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_PHY_STAT0); in initialize_hdmi_ih_mutes()
1308 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CM_STAT0); in initialize_hdmi_ih_mutes()
1309 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_CEC_STAT0); in initialize_hdmi_ih_mutes()
1310 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_VP_STAT0); in initialize_hdmi_ih_mutes()
1311 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_I2CMPHY_STAT0); in initialize_hdmi_ih_mutes()
1312 hdmi_writeb(hdmi, 0xff, HDMI_IH_MUTE_AHBDMAAUD_STAT0); in initialize_hdmi_ih_mutes()
1317 hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE); in initialize_hdmi_ih_mutes()
1320 static void dw_hdmi_poweron(struct dw_hdmi *hdmi) in dw_hdmi_poweron() argument
1322 hdmi->bridge_is_on = true; in dw_hdmi_poweron()
1323 dw_hdmi_setup(hdmi, &hdmi->previous_mode); in dw_hdmi_poweron()
1326 static void dw_hdmi_poweroff(struct dw_hdmi *hdmi) in dw_hdmi_poweroff() argument
1328 dw_hdmi_phy_disable(hdmi); in dw_hdmi_poweroff()
1329 hdmi->bridge_is_on = false; in dw_hdmi_poweroff()
1332 static void dw_hdmi_update_power(struct dw_hdmi *hdmi) in dw_hdmi_update_power() argument
1334 int force = hdmi->force; in dw_hdmi_update_power()
1336 if (hdmi->disabled) { in dw_hdmi_update_power()
1339 if (hdmi->rxsense) in dw_hdmi_update_power()
1346 if (hdmi->bridge_is_on) in dw_hdmi_update_power()
1347 dw_hdmi_poweroff(hdmi); in dw_hdmi_update_power()
1349 if (!hdmi->bridge_is_on) in dw_hdmi_update_power()
1350 dw_hdmi_poweron(hdmi); in dw_hdmi_update_power()
1366 static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi) in dw_hdmi_update_phy_mask() argument
1368 u8 old_mask = hdmi->phy_mask; in dw_hdmi_update_phy_mask()
1370 if (hdmi->force || hdmi->disabled || !hdmi->rxsense) in dw_hdmi_update_phy_mask()
1371 hdmi->phy_mask |= HDMI_PHY_RX_SENSE; in dw_hdmi_update_phy_mask()
1373 hdmi->phy_mask &= ~HDMI_PHY_RX_SENSE; in dw_hdmi_update_phy_mask()
1375 if (old_mask != hdmi->phy_mask) in dw_hdmi_update_phy_mask()
1376 hdmi_writeb(hdmi, hdmi->phy_mask, HDMI_PHY_MASK0); in dw_hdmi_update_phy_mask()
1383 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_mode_set() local
1385 mutex_lock(&hdmi->mutex); in dw_hdmi_bridge_mode_set()
1388 memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode)); in dw_hdmi_bridge_mode_set()
1390 mutex_unlock(&hdmi->mutex); in dw_hdmi_bridge_mode_set()
1402 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_disable() local
1404 mutex_lock(&hdmi->mutex); in dw_hdmi_bridge_disable()
1405 hdmi->disabled = true; in dw_hdmi_bridge_disable()
1406 dw_hdmi_update_power(hdmi); in dw_hdmi_bridge_disable()
1407 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_bridge_disable()
1408 mutex_unlock(&hdmi->mutex); in dw_hdmi_bridge_disable()
1413 struct dw_hdmi *hdmi = bridge->driver_private; in dw_hdmi_bridge_enable() local
1415 mutex_lock(&hdmi->mutex); in dw_hdmi_bridge_enable()
1416 hdmi->disabled = false; in dw_hdmi_bridge_enable()
1417 dw_hdmi_update_power(hdmi); in dw_hdmi_bridge_enable()
1418 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_bridge_enable()
1419 mutex_unlock(&hdmi->mutex); in dw_hdmi_bridge_enable()
1430 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_detect() local
1433 mutex_lock(&hdmi->mutex); in dw_hdmi_connector_detect()
1434 hdmi->force = DRM_FORCE_UNSPECIFIED; in dw_hdmi_connector_detect()
1435 dw_hdmi_update_power(hdmi); in dw_hdmi_connector_detect()
1436 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_connector_detect()
1437 mutex_unlock(&hdmi->mutex); in dw_hdmi_connector_detect()
1439 return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ? in dw_hdmi_connector_detect()
1445 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_get_modes() local
1450 if (!hdmi->ddc) in dw_hdmi_connector_get_modes()
1453 edid = drm_get_edid(connector, hdmi->ddc); in dw_hdmi_connector_get_modes()
1455 dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n", in dw_hdmi_connector_get_modes()
1458 hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid); in dw_hdmi_connector_get_modes()
1459 hdmi->sink_has_audio = drm_detect_monitor_audio(edid); in dw_hdmi_connector_get_modes()
1466 dev_dbg(hdmi->dev, "failed to get edid\n"); in dw_hdmi_connector_get_modes()
1476 struct dw_hdmi *hdmi = container_of(connector, in dw_hdmi_connector_mode_valid() local
1484 if (hdmi->plat_data->mode_valid) in dw_hdmi_connector_mode_valid()
1485 mode_status = hdmi->plat_data->mode_valid(connector, mode); in dw_hdmi_connector_mode_valid()
1493 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_best_encoder() local
1496 return hdmi->encoder; in dw_hdmi_connector_best_encoder()
1507 struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, in dw_hdmi_connector_force() local
1510 mutex_lock(&hdmi->mutex); in dw_hdmi_connector_force()
1511 hdmi->force = connector->force; in dw_hdmi_connector_force()
1512 dw_hdmi_update_power(hdmi); in dw_hdmi_connector_force()
1513 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_connector_force()
1514 mutex_unlock(&hdmi->mutex); in dw_hdmi_connector_force()
1542 struct dw_hdmi *hdmi = dev_id; in dw_hdmi_hardirq() local
1545 intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); in dw_hdmi_hardirq()
1547 hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); in dw_hdmi_hardirq()
1554 struct dw_hdmi *hdmi = dev_id; in dw_hdmi_irq() local
1557 intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); in dw_hdmi_irq()
1558 phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0); in dw_hdmi_irq()
1559 phy_stat = hdmi_readb(hdmi, HDMI_PHY_STAT0); in dw_hdmi_irq()
1574 hdmi_modb(hdmi, ~phy_int_pol, phy_pol_mask, HDMI_PHY_POL0); in dw_hdmi_irq()
1585 mutex_lock(&hdmi->mutex); in dw_hdmi_irq()
1586 if (!hdmi->disabled && !hdmi->force) { in dw_hdmi_irq()
1592 hdmi->rxsense = false; in dw_hdmi_irq()
1601 hdmi->rxsense = true; in dw_hdmi_irq()
1603 dw_hdmi_update_power(hdmi); in dw_hdmi_irq()
1604 dw_hdmi_update_phy_mask(hdmi); in dw_hdmi_irq()
1606 mutex_unlock(&hdmi->mutex); in dw_hdmi_irq()
1610 dev_dbg(hdmi->dev, "EVENT=%s\n", in dw_hdmi_irq()
1612 drm_helper_hpd_irq_event(hdmi->bridge->dev); in dw_hdmi_irq()
1615 hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0); in dw_hdmi_irq()
1616 hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), in dw_hdmi_irq()
1622 static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi) in dw_hdmi_register() argument
1624 struct drm_encoder *encoder = hdmi->encoder; in dw_hdmi_register()
1634 hdmi->bridge = bridge; in dw_hdmi_register()
1635 bridge->driver_private = hdmi; in dw_hdmi_register()
1644 hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; in dw_hdmi_register()
1646 drm_connector_helper_add(&hdmi->connector, in dw_hdmi_register()
1648 drm_connector_init(drm, &hdmi->connector, &dw_hdmi_connector_funcs, in dw_hdmi_register()
1651 hdmi->connector.encoder = encoder; in dw_hdmi_register()
1653 drm_mode_connector_attach_encoder(&hdmi->connector, encoder); in dw_hdmi_register()
1668 struct dw_hdmi *hdmi; in dw_hdmi_bind() local
1672 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in dw_hdmi_bind()
1673 if (!hdmi) in dw_hdmi_bind()
1676 hdmi->connector.interlace_allowed = 1; in dw_hdmi_bind()
1678 hdmi->plat_data = plat_data; in dw_hdmi_bind()
1679 hdmi->dev = dev; in dw_hdmi_bind()
1680 hdmi->dev_type = plat_data->dev_type; in dw_hdmi_bind()
1681 hdmi->sample_rate = 48000; in dw_hdmi_bind()
1682 hdmi->encoder = encoder; in dw_hdmi_bind()
1683 hdmi->disabled = true; in dw_hdmi_bind()
1684 hdmi->rxsense = true; in dw_hdmi_bind()
1685 hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); in dw_hdmi_bind()
1687 mutex_init(&hdmi->mutex); in dw_hdmi_bind()
1688 mutex_init(&hdmi->audio_mutex); in dw_hdmi_bind()
1689 spin_lock_init(&hdmi->audio_lock); in dw_hdmi_bind()
1695 hdmi->write = dw_hdmi_writel; in dw_hdmi_bind()
1696 hdmi->read = dw_hdmi_readl; in dw_hdmi_bind()
1699 hdmi->write = dw_hdmi_writeb; in dw_hdmi_bind()
1700 hdmi->read = dw_hdmi_readb; in dw_hdmi_bind()
1709 hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node); in dw_hdmi_bind()
1711 if (!hdmi->ddc) { in dw_hdmi_bind()
1712 dev_dbg(hdmi->dev, "failed to read ddc node\n"); in dw_hdmi_bind()
1717 dev_dbg(hdmi->dev, "no ddc property found\n"); in dw_hdmi_bind()
1720 hdmi->regs = devm_ioremap_resource(dev, iores); in dw_hdmi_bind()
1721 if (IS_ERR(hdmi->regs)) in dw_hdmi_bind()
1722 return PTR_ERR(hdmi->regs); in dw_hdmi_bind()
1724 hdmi->isfr_clk = devm_clk_get(hdmi->dev, "isfr"); in dw_hdmi_bind()
1725 if (IS_ERR(hdmi->isfr_clk)) { in dw_hdmi_bind()
1726 ret = PTR_ERR(hdmi->isfr_clk); in dw_hdmi_bind()
1727 dev_err(hdmi->dev, "Unable to get HDMI isfr clk: %d\n", ret); in dw_hdmi_bind()
1731 ret = clk_prepare_enable(hdmi->isfr_clk); in dw_hdmi_bind()
1733 dev_err(hdmi->dev, "Cannot enable HDMI isfr clock: %d\n", ret); in dw_hdmi_bind()
1737 hdmi->iahb_clk = devm_clk_get(hdmi->dev, "iahb"); in dw_hdmi_bind()
1738 if (IS_ERR(hdmi->iahb_clk)) { in dw_hdmi_bind()
1739 ret = PTR_ERR(hdmi->iahb_clk); in dw_hdmi_bind()
1740 dev_err(hdmi->dev, "Unable to get HDMI iahb clk: %d\n", ret); in dw_hdmi_bind()
1744 ret = clk_prepare_enable(hdmi->iahb_clk); in dw_hdmi_bind()
1746 dev_err(hdmi->dev, "Cannot enable HDMI iahb clock: %d\n", ret); in dw_hdmi_bind()
1753 hdmi_readb(hdmi, HDMI_DESIGN_ID), in dw_hdmi_bind()
1754 hdmi_readb(hdmi, HDMI_REVISION_ID), in dw_hdmi_bind()
1755 hdmi_readb(hdmi, HDMI_PRODUCT_ID0), in dw_hdmi_bind()
1756 hdmi_readb(hdmi, HDMI_PRODUCT_ID1)); in dw_hdmi_bind()
1758 initialize_hdmi_ih_mutes(hdmi); in dw_hdmi_bind()
1762 dev_name(dev), hdmi); in dw_hdmi_bind()
1770 hdmi_init_clk_regenerator(hdmi); in dw_hdmi_bind()
1776 hdmi_writeb(hdmi, HDMI_PHY_HPD | HDMI_PHY_RX_SENSE, HDMI_PHY_POL0); in dw_hdmi_bind()
1779 hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE, in dw_hdmi_bind()
1782 ret = dw_hdmi_fb_registered(hdmi); in dw_hdmi_bind()
1786 ret = dw_hdmi_register(drm, hdmi); in dw_hdmi_bind()
1791 hdmi_writeb(hdmi, ~(HDMI_IH_PHY_STAT0_HPD | HDMI_IH_PHY_STAT0_RX_SENSE), in dw_hdmi_bind()
1798 if (hdmi_readb(hdmi, HDMI_CONFIG1_ID) & HDMI_CONFIG1_AHB) { in dw_hdmi_bind()
1800 audio.base = hdmi->regs; in dw_hdmi_bind()
1802 audio.hdmi = hdmi; in dw_hdmi_bind()
1803 audio.eld = hdmi->connector.eld; in dw_hdmi_bind()
1809 hdmi->audio = platform_device_register_full(&pdevinfo); in dw_hdmi_bind()
1812 dev_set_drvdata(dev, hdmi); in dw_hdmi_bind()
1817 clk_disable_unprepare(hdmi->iahb_clk); in dw_hdmi_bind()
1819 clk_disable_unprepare(hdmi->isfr_clk); in dw_hdmi_bind()
1827 struct dw_hdmi *hdmi = dev_get_drvdata(dev); in dw_hdmi_unbind() local
1829 if (hdmi->audio && !IS_ERR(hdmi->audio)) in dw_hdmi_unbind()
1830 platform_device_unregister(hdmi->audio); in dw_hdmi_unbind()
1833 hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0); in dw_hdmi_unbind()
1835 hdmi->connector.funcs->destroy(&hdmi->connector); in dw_hdmi_unbind()
1836 hdmi->encoder->funcs->destroy(hdmi->encoder); in dw_hdmi_unbind()
1838 clk_disable_unprepare(hdmi->iahb_clk); in dw_hdmi_unbind()
1839 clk_disable_unprepare(hdmi->isfr_clk); in dw_hdmi_unbind()
1840 i2c_put_adapter(hdmi->ddc); in dw_hdmi_unbind()