Lines Matching refs:hdmi

47 static int sun4i_hdmi_setup_avi_infoframes(struct sun4i_hdmi *hdmi,  in sun4i_hdmi_setup_avi_infoframes()  argument
55 &hdmi->connector, mode); in sun4i_hdmi_setup_avi_infoframes()
68 writeb(buffer[i], hdmi->base + SUN4I_HDMI_AVI_INFOFRAME_REG(i)); in sun4i_hdmi_setup_avi_infoframes()
87 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); in sun4i_hdmi_disable() local
92 val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG); in sun4i_hdmi_disable()
94 writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG); in sun4i_hdmi_disable()
96 clk_disable_unprepare(hdmi->tmds_clk); in sun4i_hdmi_disable()
102 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); in sun4i_hdmi_enable() local
103 struct drm_display_info *display = &hdmi->connector.display_info; in sun4i_hdmi_enable()
108 clk_prepare_enable(hdmi->tmds_clk); in sun4i_hdmi_enable()
110 sun4i_hdmi_setup_avi_infoframes(hdmi, mode); in sun4i_hdmi_enable()
113 writel(val, hdmi->base + SUN4I_HDMI_PKT_CTRL_REG(0)); in sun4i_hdmi_enable()
119 writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG); in sun4i_hdmi_enable()
126 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); in sun4i_hdmi_mode_set() local
130 clk_set_rate(hdmi->mod_clk, mode->crtc_clock * 1000); in sun4i_hdmi_mode_set()
131 clk_set_rate(hdmi->tmds_clk, mode->crtc_clock * 1000); in sun4i_hdmi_mode_set()
135 hdmi->base + SUN4I_HDMI_UNKNOWN_REG); in sun4i_hdmi_mode_set()
147 val = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG); in sun4i_hdmi_mode_set()
149 val |= hdmi->variant->pad_ctrl1_init_val; in sun4i_hdmi_mode_set()
150 writel(val, hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG); in sun4i_hdmi_mode_set()
151 val = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG); in sun4i_hdmi_mode_set()
156 hdmi->base + SUN4I_HDMI_VID_TIMING_ACT_REG); in sun4i_hdmi_mode_set()
161 hdmi->base + SUN4I_HDMI_VID_TIMING_BP_REG); in sun4i_hdmi_mode_set()
166 hdmi->base + SUN4I_HDMI_VID_TIMING_FP_REG); in sun4i_hdmi_mode_set()
171 hdmi->base + SUN4I_HDMI_VID_TIMING_SPW_REG); in sun4i_hdmi_mode_set()
180 writel(val, hdmi->base + SUN4I_HDMI_VID_TIMING_POL_REG); in sun4i_hdmi_mode_set()
186 struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); in sun4i_hdmi_mode_valid() local
194 rounded_rate = clk_round_rate(hdmi->tmds_clk, rate); in sun4i_hdmi_mode_valid()
212 struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector); in sun4i_hdmi_get_modes() local
216 edid = drm_get_edid(connector, hdmi->ddc_i2c ?: hdmi->i2c); in sun4i_hdmi_get_modes()
224 cec_s_phys_addr_from_edid(hdmi->cec_adap, edid); in sun4i_hdmi_get_modes()
260 struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector); in sun4i_hdmi_connector_detect() local
263 reg = readl(hdmi->base + SUN4I_HDMI_HPD_REG); in sun4i_hdmi_connector_detect()
265 cec_phys_addr_invalidate(hdmi->cec_adap); in sun4i_hdmi_connector_detect()
284 struct sun4i_hdmi *hdmi = cec_get_drvdata(adap); in sun4i_hdmi_cec_pin_read() local
286 return readl(hdmi->base + SUN4I_HDMI_CEC) & SUN4I_HDMI_CEC_RX; in sun4i_hdmi_cec_pin_read()
291 struct sun4i_hdmi *hdmi = cec_get_drvdata(adap); in sun4i_hdmi_cec_pin_low() local
294 writel(SUN4I_HDMI_CEC_ENABLE, hdmi->base + SUN4I_HDMI_CEC); in sun4i_hdmi_cec_pin_low()
299 struct sun4i_hdmi *hdmi = cec_get_drvdata(adap); in sun4i_hdmi_cec_pin_high() local
305 writel(0, hdmi->base + SUN4I_HDMI_CEC); in sun4i_hdmi_cec_pin_high()
492 struct sun4i_hdmi *hdmi; in sun4i_hdmi_bind() local
496 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in sun4i_hdmi_bind()
497 if (!hdmi) in sun4i_hdmi_bind()
499 dev_set_drvdata(dev, hdmi); in sun4i_hdmi_bind()
500 hdmi->dev = dev; in sun4i_hdmi_bind()
501 hdmi->drv = drv; in sun4i_hdmi_bind()
503 hdmi->variant = of_device_get_match_data(dev); in sun4i_hdmi_bind()
504 if (!hdmi->variant) in sun4i_hdmi_bind()
507 hdmi->base = devm_platform_ioremap_resource(pdev, 0); in sun4i_hdmi_bind()
508 if (IS_ERR(hdmi->base)) { in sun4i_hdmi_bind()
510 return PTR_ERR(hdmi->base); in sun4i_hdmi_bind()
513 if (hdmi->variant->has_reset_control) { in sun4i_hdmi_bind()
514 hdmi->reset = devm_reset_control_get(dev, NULL); in sun4i_hdmi_bind()
515 if (IS_ERR(hdmi->reset)) { in sun4i_hdmi_bind()
517 return PTR_ERR(hdmi->reset); in sun4i_hdmi_bind()
520 ret = reset_control_deassert(hdmi->reset); in sun4i_hdmi_bind()
527 hdmi->bus_clk = devm_clk_get(dev, "ahb"); in sun4i_hdmi_bind()
528 if (IS_ERR(hdmi->bus_clk)) { in sun4i_hdmi_bind()
530 ret = PTR_ERR(hdmi->bus_clk); in sun4i_hdmi_bind()
533 clk_prepare_enable(hdmi->bus_clk); in sun4i_hdmi_bind()
535 hdmi->mod_clk = devm_clk_get(dev, "mod"); in sun4i_hdmi_bind()
536 if (IS_ERR(hdmi->mod_clk)) { in sun4i_hdmi_bind()
538 ret = PTR_ERR(hdmi->mod_clk); in sun4i_hdmi_bind()
541 clk_prepare_enable(hdmi->mod_clk); in sun4i_hdmi_bind()
543 hdmi->pll0_clk = devm_clk_get(dev, "pll-0"); in sun4i_hdmi_bind()
544 if (IS_ERR(hdmi->pll0_clk)) { in sun4i_hdmi_bind()
546 ret = PTR_ERR(hdmi->pll0_clk); in sun4i_hdmi_bind()
550 hdmi->pll1_clk = devm_clk_get(dev, "pll-1"); in sun4i_hdmi_bind()
551 if (IS_ERR(hdmi->pll1_clk)) { in sun4i_hdmi_bind()
553 ret = PTR_ERR(hdmi->pll1_clk); in sun4i_hdmi_bind()
557 hdmi->regmap = devm_regmap_init_mmio(dev, hdmi->base, in sun4i_hdmi_bind()
559 if (IS_ERR(hdmi->regmap)) { in sun4i_hdmi_bind()
561 ret = PTR_ERR(hdmi->regmap); in sun4i_hdmi_bind()
565 ret = sun4i_tmds_create(hdmi); in sun4i_hdmi_bind()
571 if (hdmi->variant->has_ddc_parent_clk) { in sun4i_hdmi_bind()
572 hdmi->ddc_parent_clk = devm_clk_get(dev, "ddc"); in sun4i_hdmi_bind()
573 if (IS_ERR(hdmi->ddc_parent_clk)) { in sun4i_hdmi_bind()
575 ret = PTR_ERR(hdmi->ddc_parent_clk); in sun4i_hdmi_bind()
579 hdmi->ddc_parent_clk = hdmi->tmds_clk; in sun4i_hdmi_bind()
582 writel(SUN4I_HDMI_CTRL_ENABLE, hdmi->base + SUN4I_HDMI_CTRL_REG); in sun4i_hdmi_bind()
584 writel(hdmi->variant->pad_ctrl0_init_val, in sun4i_hdmi_bind()
585 hdmi->base + SUN4I_HDMI_PAD_CTRL0_REG); in sun4i_hdmi_bind()
587 reg = readl(hdmi->base + SUN4I_HDMI_PLL_CTRL_REG); in sun4i_hdmi_bind()
589 reg |= hdmi->variant->pll_ctrl_init_val; in sun4i_hdmi_bind()
590 writel(reg, hdmi->base + SUN4I_HDMI_PLL_CTRL_REG); in sun4i_hdmi_bind()
592 ret = sun4i_hdmi_i2c_create(dev, hdmi); in sun4i_hdmi_bind()
598 hdmi->ddc_i2c = sun4i_hdmi_get_ddc(dev); in sun4i_hdmi_bind()
599 if (IS_ERR(hdmi->ddc_i2c)) { in sun4i_hdmi_bind()
600 ret = PTR_ERR(hdmi->ddc_i2c); in sun4i_hdmi_bind()
602 hdmi->ddc_i2c = NULL; in sun4i_hdmi_bind()
607 drm_encoder_helper_add(&hdmi->encoder, in sun4i_hdmi_bind()
609 ret = drm_simple_encoder_init(drm, &hdmi->encoder, in sun4i_hdmi_bind()
616 hdmi->encoder.possible_crtcs = drm_of_find_possible_crtcs(drm, in sun4i_hdmi_bind()
618 if (!hdmi->encoder.possible_crtcs) { in sun4i_hdmi_bind()
624 hdmi->cec_adap = cec_pin_allocate_adapter(&sun4i_hdmi_cec_pin_ops, in sun4i_hdmi_bind()
625 hdmi, "sun4i", CEC_CAP_DEFAULTS | CEC_CAP_CONNECTOR_INFO); in sun4i_hdmi_bind()
626 ret = PTR_ERR_OR_ZERO(hdmi->cec_adap); in sun4i_hdmi_bind()
629 writel(readl(hdmi->base + SUN4I_HDMI_CEC) & ~SUN4I_HDMI_CEC_TX, in sun4i_hdmi_bind()
630 hdmi->base + SUN4I_HDMI_CEC); in sun4i_hdmi_bind()
633 drm_connector_helper_add(&hdmi->connector, in sun4i_hdmi_bind()
635 ret = drm_connector_init_with_ddc(drm, &hdmi->connector, in sun4i_hdmi_bind()
638 hdmi->ddc_i2c); in sun4i_hdmi_bind()
644 cec_fill_conn_info_from_drm(&conn_info, &hdmi->connector); in sun4i_hdmi_bind()
645 cec_s_conn_info(hdmi->cec_adap, &conn_info); in sun4i_hdmi_bind()
648 hdmi->connector.polled = DRM_CONNECTOR_POLL_CONNECT | in sun4i_hdmi_bind()
651 ret = cec_register_adapter(hdmi->cec_adap, dev); in sun4i_hdmi_bind()
654 drm_connector_attach_encoder(&hdmi->connector, &hdmi->encoder); in sun4i_hdmi_bind()
659 cec_delete_adapter(hdmi->cec_adap); in sun4i_hdmi_bind()
660 drm_encoder_cleanup(&hdmi->encoder); in sun4i_hdmi_bind()
662 i2c_put_adapter(hdmi->ddc_i2c); in sun4i_hdmi_bind()
664 i2c_del_adapter(hdmi->i2c); in sun4i_hdmi_bind()
666 clk_disable_unprepare(hdmi->mod_clk); in sun4i_hdmi_bind()
668 clk_disable_unprepare(hdmi->bus_clk); in sun4i_hdmi_bind()
670 reset_control_assert(hdmi->reset); in sun4i_hdmi_bind()
677 struct sun4i_hdmi *hdmi = dev_get_drvdata(dev); in sun4i_hdmi_unbind() local
679 cec_unregister_adapter(hdmi->cec_adap); in sun4i_hdmi_unbind()
680 i2c_del_adapter(hdmi->i2c); in sun4i_hdmi_unbind()
681 i2c_put_adapter(hdmi->ddc_i2c); in sun4i_hdmi_unbind()
682 clk_disable_unprepare(hdmi->mod_clk); in sun4i_hdmi_unbind()
683 clk_disable_unprepare(hdmi->bus_clk); in sun4i_hdmi_unbind()