Lines Matching +full:hdmi +full:- +full:bridge

1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/hdmi.h>
25 #include <sound/hdmi-codec.h>
95 #define HDMI_IFRAME_CFG_DI_N(x, n) ((x) << ((n-1)*4)) /* n from 1 to 6 */
163 struct sti_hdmi *hdmi; member
170 u32 hdmi_read(struct sti_hdmi *hdmi, int offset) in hdmi_read() argument
172 return readl(hdmi->regs + offset); in hdmi_read()
175 void hdmi_write(struct sti_hdmi *hdmi, u32 val, int offset) in hdmi_write() argument
177 writel(val, hdmi->regs + offset); in hdmi_write()
181 * HDMI interrupt handler threaded
188 struct sti_hdmi *hdmi = arg; in hdmi_irq_thread() local
191 if (hdmi->irq_status & HDMI_INT_HOT_PLUG) { in hdmi_irq_thread()
192 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in hdmi_irq_thread()
193 if (hdmi->drm_dev) in hdmi_irq_thread()
194 drm_helper_hpd_irq_event(hdmi->drm_dev); in hdmi_irq_thread()
200 if (hdmi->irq_status & (HDMI_INT_SW_RST | HDMI_INT_DLL_LCK)) { in hdmi_irq_thread()
201 hdmi->event_received = true; in hdmi_irq_thread()
202 wake_up_interruptible(&hdmi->wait_event); in hdmi_irq_thread()
206 if (hdmi->irq_status & HDMI_INT_AUDIO_FIFO_XRUN) in hdmi_irq_thread()
213 * HDMI interrupt handler
220 struct sti_hdmi *hdmi = arg; in hdmi_irq() local
223 hdmi->irq_status = hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
226 hdmi_write(hdmi, hdmi->irq_status, HDMI_INT_CLR); in hdmi_irq()
229 hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
235 * Set hdmi active area depending on the drm display mode selected
237 * @hdmi: pointer on the hdmi internal structure
239 static void hdmi_active_area(struct sti_hdmi *hdmi) in hdmi_active_area() argument
244 xmin = sti_vtg_get_pixel_number(hdmi->mode, 1); in hdmi_active_area()
245 xmax = sti_vtg_get_pixel_number(hdmi->mode, hdmi->mode.hdisplay); in hdmi_active_area()
246 ymin = sti_vtg_get_line_number(hdmi->mode, 0); in hdmi_active_area()
247 ymax = sti_vtg_get_line_number(hdmi->mode, hdmi->mode.vdisplay - 1); in hdmi_active_area()
249 hdmi_write(hdmi, xmin, HDMI_ACTIVE_VID_XMIN); in hdmi_active_area()
250 hdmi_write(hdmi, xmax, HDMI_ACTIVE_VID_XMAX); in hdmi_active_area()
251 hdmi_write(hdmi, ymin, HDMI_ACTIVE_VID_YMIN); in hdmi_active_area()
252 hdmi_write(hdmi, ymax, HDMI_ACTIVE_VID_YMAX); in hdmi_active_area()
256 * Overall hdmi configuration
258 * @hdmi: pointer on the hdmi internal structure
260 static void hdmi_config(struct sti_hdmi *hdmi) in hdmi_config() argument
271 if (hdmi->hdmi_monitor) in hdmi_config()
275 if (hdmi->mode.flags & DRM_MODE_FLAG_NHSYNC) { in hdmi_config()
281 if (hdmi->mode.flags & DRM_MODE_FLAG_NVSYNC) { in hdmi_config()
286 /* Enable HDMI */ in hdmi_config()
289 hdmi_write(hdmi, conf, HDMI_CFG); in hdmi_config()
295 * @hdmi: pointer on the hdmi internal structure
298 static void hdmi_infoframe_reset(struct sti_hdmi *hdmi, in hdmi_infoframe_reset() argument
323 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
325 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_reset()
328 hdmi_write(hdmi, 0x0, head_offset); in hdmi_infoframe_reset()
330 hdmi_write(hdmi, 0x0, pack_offset + i); in hdmi_infoframe_reset()
336 * @ptr: pointer on the hdmi internal structure
344 for (i = size; i > 0; i--) in hdmi_infoframe_subpack()
345 value = (value << 8) | ptr[i - 1]; in hdmi_infoframe_subpack()
353 * @hdmi: pointer on the hdmi internal structure
357 static void hdmi_infoframe_write_infopack(struct sti_hdmi *hdmi, in hdmi_infoframe_write_infopack() argument
390 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
392 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
397 writel(val, hdmi->regs + head_offset); in hdmi_infoframe_write_infopack()
404 size = size - HDMI_INFOFRAME_HEADER_SIZE + 1; in hdmi_infoframe_write_infopack()
408 num = min_t(size_t, size - i, sizeof(u32)); in hdmi_infoframe_write_infopack()
411 writel(val, hdmi->regs + pack_offset + i); in hdmi_infoframe_write_infopack()
415 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
417 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_infoframe_write_infopack()
424 * contains information about HDMI transmission mode such as color space,
427 * @hdmi: pointer on the hdmi internal structure
431 static int hdmi_avi_infoframe_config(struct sti_hdmi *hdmi) in hdmi_avi_infoframe_config() argument
433 struct drm_display_mode *mode = &hdmi->mode; in hdmi_avi_infoframe_config()
441 hdmi->drm_connector, mode); in hdmi_avi_infoframe_config()
448 infoframe.colorspace = hdmi->colorspace; in hdmi_avi_infoframe_config()
458 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_avi_infoframe_config()
467 * contains information about HDMI transmission mode such as audio codec,
470 * @hdmi: pointer on the hdmi internal structure
474 static int hdmi_audio_infoframe_config(struct sti_hdmi *hdmi) in hdmi_audio_infoframe_config() argument
476 struct hdmi_audio_params *audio = &hdmi->audio; in hdmi_audio_infoframe_config()
481 audio->enabled ? "enable" : "disable"); in hdmi_audio_infoframe_config()
482 if (audio->enabled) { in hdmi_audio_infoframe_config()
484 ret = hdmi_audio_infoframe_pack(&audio->cea, buffer, in hdmi_audio_infoframe_config()
490 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_audio_infoframe_config()
493 val = hdmi_read(hdmi, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
496 hdmi_write(hdmi, val, HDMI_SW_DI_CFG); in hdmi_audio_infoframe_config()
508 * @hdmi: pointer on the hdmi internal structure
513 static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi) in hdmi_vendor_infoframe_config() argument
515 struct drm_display_mode *mode = &hdmi->mode; in hdmi_vendor_infoframe_config()
523 hdmi->drm_connector, in hdmi_vendor_infoframe_config()
541 hdmi_infoframe_write_infopack(hdmi, buffer, ret); in hdmi_vendor_infoframe_config()
549 * Software reset of the hdmi subsystem
551 * @hdmi: pointer on the hdmi internal structure
554 static void hdmi_swreset(struct sti_hdmi *hdmi) in hdmi_swreset() argument
560 /* Enable hdmi_audio clock only during hdmi reset */ in hdmi_swreset()
561 if (clk_prepare_enable(hdmi->clk_audio)) in hdmi_swreset()
565 hdmi->event_received = false; in hdmi_swreset()
567 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
569 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
572 wait_event_interruptible_timeout(hdmi->wait_event, in hdmi_swreset()
573 hdmi->event_received, in hdmi_swreset()
581 if ((hdmi_read(hdmi, HDMI_STA) & HDMI_STA_SW_RST) == 0) in hdmi_swreset()
582 DRM_DEBUG_DRIVER("Warning: HDMI sw reset timeout occurs\n"); in hdmi_swreset()
584 val = hdmi_read(hdmi, HDMI_CFG); in hdmi_swreset()
586 hdmi_write(hdmi, val, HDMI_CFG); in hdmi_swreset()
589 clk_disable_unprepare(hdmi->clk_audio); in hdmi_swreset()
592 #define DBGFS_PRINT_STR(str1, str2) seq_printf(s, "%-24s %s\n", str1, str2)
593 #define DBGFS_PRINT_INT(str1, int2) seq_printf(s, "%-24s %d\n", str1, int2)
594 #define DBGFS_DUMP(str, reg) seq_printf(s, "%s %-25s 0x%08X", str, #reg, \
595 hdmi_read(hdmi, reg))
604 DBGFS_PRINT_STR("mode:", tmp ? "HDMI" : "DVI"); in hdmi_dbg_cfg()
631 DBGFS_PRINT_STR("hdmi cable:", tmp ? "connected" : "not connected"); in hdmi_dbg_sta()
664 struct drm_info_node *node = s->private; in hdmi_dbg_show()
665 struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; in hdmi_dbg_show() local
667 seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); in hdmi_dbg_show()
669 hdmi_dbg_cfg(s, hdmi_read(hdmi, HDMI_CFG)); in hdmi_dbg_show()
672 hdmi_dbg_sta(s, hdmi_read(hdmi, HDMI_STA)); in hdmi_dbg_show()
675 DBGFS_PRINT_INT("Xmin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMIN)); in hdmi_dbg_show()
678 DBGFS_PRINT_INT("Xmax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_XMAX)); in hdmi_dbg_show()
681 DBGFS_PRINT_INT("Ymin:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMIN)); in hdmi_dbg_show()
684 DBGFS_PRINT_INT("Ymax:", hdmi_read(hdmi, HDMI_ACTIVE_VID_YMAX)); in hdmi_dbg_show()
686 hdmi_dbg_sw_di_cfg(s, hdmi_read(hdmi, HDMI_SW_DI_CFG)); in hdmi_dbg_show()
727 { "hdmi", hdmi_dbg_show, 0, NULL },
730 static void hdmi_debugfs_init(struct sti_hdmi *hdmi, struct drm_minor *minor) in hdmi_debugfs_init() argument
735 hdmi_debugfs_files[i].data = hdmi; in hdmi_debugfs_init()
739 minor->debugfs_root, minor); in hdmi_debugfs_init()
742 static void sti_hdmi_disable(struct drm_bridge *bridge) in sti_hdmi_disable() argument
744 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_disable() local
746 u32 val = hdmi_read(hdmi, HDMI_CFG); in sti_hdmi_disable()
748 if (!hdmi->enabled) in sti_hdmi_disable()
753 /* Disable HDMI */ in sti_hdmi_disable()
755 hdmi_write(hdmi, val, HDMI_CFG); in sti_hdmi_disable()
757 hdmi_write(hdmi, 0xffffffff, HDMI_INT_CLR); in sti_hdmi_disable()
760 hdmi->phy_ops->stop(hdmi); in sti_hdmi_disable()
763 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AVI); in sti_hdmi_disable()
764 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_AUDIO); in sti_hdmi_disable()
765 hdmi_infoframe_reset(hdmi, HDMI_IFRAME_SLOT_VENDOR); in sti_hdmi_disable()
768 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL0_DAT); in sti_hdmi_disable()
769 hdmi_write(hdmi, 0x0000, HDMI_DFLT_CHL1_DAT); in sti_hdmi_disable()
770 hdmi_write(hdmi, 0x0060, HDMI_DFLT_CHL2_DAT); in sti_hdmi_disable()
772 /* Disable/unprepare hdmi clock */ in sti_hdmi_disable()
773 clk_disable_unprepare(hdmi->clk_phy); in sti_hdmi_disable()
774 clk_disable_unprepare(hdmi->clk_tmds); in sti_hdmi_disable()
775 clk_disable_unprepare(hdmi->clk_pix); in sti_hdmi_disable()
777 hdmi->enabled = false; in sti_hdmi_disable()
779 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_disable()
783 * sti_hdmi_audio_get_non_coherent_n() - get N parameter for non-coherent
784 * clocks. None-coherent clocks means that audio and TMDS clocks have not the
790 * Values computed are based on table described in HDMI specification 1.4b
821 /* Not pre-defined, recommended value: 128 * fs / 1000 */ in sti_hdmi_audio_get_non_coherent_n()
828 static int hdmi_audio_configure(struct sti_hdmi *hdmi) in hdmi_audio_configure() argument
831 struct hdmi_audio_params *params = &hdmi->audio; in hdmi_audio_configure()
832 struct hdmi_audio_infoframe *info = &params->cea; in hdmi_audio_configure()
836 if (!hdmi->enabled) in hdmi_audio_configure()
840 n = sti_hdmi_audio_get_non_coherent_n(params->sample_rate); in hdmi_audio_configure()
843 params->sample_rate, hdmi->mode.clock * 1000, n); in hdmi_audio_configure()
844 hdmi_write(hdmi, n, HDMI_AUDN); in hdmi_audio_configure()
846 /* update HDMI registers according to configuration */ in hdmi_audio_configure()
850 switch (info->channels) { in hdmi_audio_configure()
865 info->channels); in hdmi_audio_configure()
866 return -EINVAL; in hdmi_audio_configure()
869 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_configure()
871 return hdmi_audio_infoframe_config(hdmi); in hdmi_audio_configure()
874 static void sti_hdmi_pre_enable(struct drm_bridge *bridge) in sti_hdmi_pre_enable() argument
876 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_pre_enable() local
880 if (hdmi->enabled) in sti_hdmi_pre_enable()
884 if (clk_prepare_enable(hdmi->clk_pix)) in sti_hdmi_pre_enable()
886 if (clk_prepare_enable(hdmi->clk_tmds)) in sti_hdmi_pre_enable()
888 if (clk_prepare_enable(hdmi->clk_phy)) in sti_hdmi_pre_enable()
891 hdmi->enabled = true; in sti_hdmi_pre_enable()
893 /* Program hdmi serializer and start phy */ in sti_hdmi_pre_enable()
894 if (!hdmi->phy_ops->start(hdmi)) { in sti_hdmi_pre_enable()
895 DRM_ERROR("Unable to start hdmi phy\n"); in sti_hdmi_pre_enable()
899 /* Program hdmi active area */ in sti_hdmi_pre_enable()
900 hdmi_active_area(hdmi); in sti_hdmi_pre_enable()
903 hdmi_write(hdmi, HDMI_WORKING_INT, HDMI_INT_EN); in sti_hdmi_pre_enable()
905 /* Program hdmi config */ in sti_hdmi_pre_enable()
906 hdmi_config(hdmi); in sti_hdmi_pre_enable()
909 if (hdmi_avi_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
912 if (hdmi->audio.enabled) { in sti_hdmi_pre_enable()
913 if (hdmi_audio_configure(hdmi)) in sti_hdmi_pre_enable()
916 hdmi_audio_infoframe_config(hdmi); in sti_hdmi_pre_enable()
920 if (hdmi_vendor_infoframe_config(hdmi)) in sti_hdmi_pre_enable()
924 hdmi_swreset(hdmi); in sti_hdmi_pre_enable()
927 static void sti_hdmi_set_mode(struct drm_bridge *bridge, in sti_hdmi_set_mode() argument
931 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_set_mode() local
937 memcpy(&hdmi->mode, mode, sizeof(struct drm_display_mode)); in sti_hdmi_set_mode()
940 ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000); in sti_hdmi_set_mode()
943 mode->clock * 1000); in sti_hdmi_set_mode()
946 ret = clk_set_rate(hdmi->clk_phy, mode->clock * 1000); in sti_hdmi_set_mode()
949 mode->clock * 1000); in sti_hdmi_set_mode()
954 static void sti_hdmi_bridge_nope(struct drm_bridge *bridge) in sti_hdmi_bridge_nope() argument
971 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_modes() local
977 edid = drm_get_edid(connector, hdmi->ddc_adapt); in sti_hdmi_connector_get_modes()
981 hdmi->hdmi_monitor = drm_detect_hdmi_monitor(edid); in sti_hdmi_connector_get_modes()
983 (hdmi->hdmi_monitor ? "hdmi monitor" : "dvi monitor"), in sti_hdmi_connector_get_modes()
984 edid->width_cm, edid->height_cm); in sti_hdmi_connector_get_modes()
985 cec_notifier_set_phys_addr_from_edid(hdmi->notifier, edid); in sti_hdmi_connector_get_modes()
994 DRM_ERROR("Can't read HDMI EDID\n"); in sti_hdmi_connector_get_modes()
1003 int target = mode->clock * 1000; in sti_hdmi_connector_mode_valid()
1004 int target_min = target - CLK_TOLERANCE_HZ; in sti_hdmi_connector_mode_valid()
1009 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_mode_valid() local
1012 result = clk_round_rate(hdmi->clk_pix, target); in sti_hdmi_connector_mode_valid()
1018 DRM_DEBUG_DRIVER("hdmi pixclk=%d not supported\n", target); in sti_hdmi_connector_mode_valid()
1037 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_detect() local
1041 if (hdmi->hpd) { in sti_hdmi_connector_detect()
1042 DRM_DEBUG_DRIVER("hdmi cable connected\n"); in sti_hdmi_connector_detect()
1046 DRM_DEBUG_DRIVER("hdmi cable disconnected\n"); in sti_hdmi_connector_detect()
1047 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_connector_detect()
1056 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_init_property() local
1060 hdmi->colorspace = DEFAULT_COLORSPACE_MODE; in sti_hdmi_connector_init_property()
1068 hdmi_connector->colorspace_property = prop; in sti_hdmi_connector_init_property()
1069 drm_object_attach_property(&connector->base, prop, hdmi->colorspace); in sti_hdmi_connector_init_property()
1080 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_set_property() local
1082 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_set_property()
1083 hdmi->colorspace = val; in sti_hdmi_connector_set_property()
1087 DRM_ERROR("failed to set hdmi connector property\n"); in sti_hdmi_connector_set_property()
1088 return -EINVAL; in sti_hdmi_connector_set_property()
1099 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_property() local
1101 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_get_property()
1102 *val = hdmi->colorspace; in sti_hdmi_connector_get_property()
1106 DRM_ERROR("failed to get hdmi connector property\n"); in sti_hdmi_connector_get_property()
1107 return -EINVAL; in sti_hdmi_connector_get_property()
1114 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_late_register() local
1116 hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary); in sti_hdmi_late_register()
1137 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { in sti_hdmi_find_encoder()
1138 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) in sti_hdmi_find_encoder()
1147 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_shutdown() local
1155 hdmi_write(hdmi, audio_cfg, HDMI_AUDIO_CFG); in hdmi_audio_shutdown()
1157 hdmi->audio.enabled = false; in hdmi_audio_shutdown()
1158 hdmi_audio_infoframe_config(hdmi); in hdmi_audio_shutdown()
1166 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_hw_params() local
1171 if ((daifmt->fmt != HDMI_I2S) || daifmt->bit_clk_inv || in hdmi_audio_hw_params()
1172 daifmt->frame_clk_inv || daifmt->bit_clk_master || in hdmi_audio_hw_params()
1173 daifmt->frame_clk_master) { in hdmi_audio_hw_params()
1175 daifmt->bit_clk_inv, daifmt->frame_clk_inv, in hdmi_audio_hw_params()
1176 daifmt->bit_clk_master, in hdmi_audio_hw_params()
1177 daifmt->frame_clk_master); in hdmi_audio_hw_params()
1178 return -EINVAL; in hdmi_audio_hw_params()
1181 hdmi->audio.sample_width = params->sample_width; in hdmi_audio_hw_params()
1182 hdmi->audio.sample_rate = params->sample_rate; in hdmi_audio_hw_params()
1183 hdmi->audio.cea = params->cea; in hdmi_audio_hw_params()
1185 hdmi->audio.enabled = true; in hdmi_audio_hw_params()
1187 ret = hdmi_audio_configure(hdmi); in hdmi_audio_hw_params()
1197 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_mute() local
1202 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_ALL, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1204 hdmi_write(hdmi, HDMI_SAMPLE_FLAT_NO, HDMI_SAMPLE_FLAT_MASK); in hdmi_audio_mute()
1211 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in hdmi_audio_get_eld() local
1212 struct drm_connector *connector = hdmi->drm_connector; in hdmi_audio_get_eld()
1215 memcpy(buf, connector->eld, min(sizeof(connector->eld), len)); in hdmi_audio_get_eld()
1229 struct sti_hdmi *hdmi) in sti_hdmi_register_audio_driver() argument
1239 hdmi->audio.enabled = false; in sti_hdmi_register_audio_driver()
1241 hdmi->audio_pdev = platform_device_register_data( in sti_hdmi_register_audio_driver()
1245 if (IS_ERR(hdmi->audio_pdev)) in sti_hdmi_register_audio_driver()
1246 return PTR_ERR(hdmi->audio_pdev); in sti_hdmi_register_audio_driver()
1255 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_bind() local
1261 struct drm_bridge *bridge; in sti_hdmi_bind() local
1265 hdmi->drm_dev = drm_dev; in sti_hdmi_bind()
1269 return -EINVAL; in sti_hdmi_bind()
1273 return -EINVAL; in sti_hdmi_bind()
1275 connector->hdmi = hdmi; in sti_hdmi_bind()
1277 bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL); in sti_hdmi_bind()
1278 if (!bridge) in sti_hdmi_bind()
1279 return -EINVAL; in sti_hdmi_bind()
1281 bridge->driver_private = hdmi; in sti_hdmi_bind()
1282 bridge->funcs = &sti_hdmi_bridge_funcs; in sti_hdmi_bind()
1283 drm_bridge_attach(encoder, bridge, NULL, 0); in sti_hdmi_bind()
1285 connector->encoder = encoder; in sti_hdmi_bind()
1289 drm_connector->polled = DRM_CONNECTOR_POLL_HPD; in sti_hdmi_bind()
1294 hdmi->ddc_adapt); in sti_hdmi_bind()
1301 hdmi->drm_connector = drm_connector; in sti_hdmi_bind()
1309 err = sti_hdmi_register_audio_driver(dev, hdmi); in sti_hdmi_bind()
1316 err = hdmi_audio_infoframe_init(&hdmi->audio.cea); in sti_hdmi_bind()
1323 hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL, in sti_hdmi_bind()
1325 if (!hdmi->notifier) { in sti_hdmi_bind()
1326 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1327 return -ENOMEM; in sti_hdmi_bind()
1331 hdmi_write(hdmi, HDMI_DEFAULT_INT, HDMI_INT_EN); in sti_hdmi_bind()
1336 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1337 return -EINVAL; in sti_hdmi_bind()
1343 struct sti_hdmi *hdmi = dev_get_drvdata(dev); in sti_hdmi_unbind() local
1345 cec_notifier_conn_unregister(hdmi->notifier); in sti_hdmi_unbind()
1355 .compatible = "st,stih407-hdmi",
1365 struct device *dev = &pdev->dev; in sti_hdmi_probe()
1366 struct sti_hdmi *hdmi; in sti_hdmi_probe() local
1367 struct device_node *np = dev->of_node; in sti_hdmi_probe()
1374 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in sti_hdmi_probe()
1375 if (!hdmi) in sti_hdmi_probe()
1376 return -ENOMEM; in sti_hdmi_probe()
1378 ddc = of_parse_phandle(pdev->dev.of_node, "ddc", 0); in sti_hdmi_probe()
1380 hdmi->ddc_adapt = of_get_i2c_adapter_by_node(ddc); in sti_hdmi_probe()
1382 if (!hdmi->ddc_adapt) in sti_hdmi_probe()
1383 return -EPROBE_DEFER; in sti_hdmi_probe()
1386 hdmi->dev = pdev->dev; in sti_hdmi_probe()
1389 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg"); in sti_hdmi_probe()
1391 DRM_ERROR("Invalid hdmi resource\n"); in sti_hdmi_probe()
1392 ret = -ENOMEM; in sti_hdmi_probe()
1395 hdmi->regs = devm_ioremap(dev, res->start, resource_size(res)); in sti_hdmi_probe()
1396 if (!hdmi->regs) { in sti_hdmi_probe()
1397 ret = -ENOMEM; in sti_hdmi_probe()
1401 hdmi->phy_ops = (struct hdmi_phy_ops *) in sti_hdmi_probe()
1402 of_match_node(hdmi_of_match, np)->data; in sti_hdmi_probe()
1405 hdmi->clk_pix = devm_clk_get(dev, "pix"); in sti_hdmi_probe()
1406 if (IS_ERR(hdmi->clk_pix)) { in sti_hdmi_probe()
1408 ret = PTR_ERR(hdmi->clk_pix); in sti_hdmi_probe()
1412 hdmi->clk_tmds = devm_clk_get(dev, "tmds"); in sti_hdmi_probe()
1413 if (IS_ERR(hdmi->clk_tmds)) { in sti_hdmi_probe()
1415 ret = PTR_ERR(hdmi->clk_tmds); in sti_hdmi_probe()
1419 hdmi->clk_phy = devm_clk_get(dev, "phy"); in sti_hdmi_probe()
1420 if (IS_ERR(hdmi->clk_phy)) { in sti_hdmi_probe()
1422 ret = PTR_ERR(hdmi->clk_phy); in sti_hdmi_probe()
1426 hdmi->clk_audio = devm_clk_get(dev, "audio"); in sti_hdmi_probe()
1427 if (IS_ERR(hdmi->clk_audio)) { in sti_hdmi_probe()
1429 ret = PTR_ERR(hdmi->clk_audio); in sti_hdmi_probe()
1433 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in sti_hdmi_probe()
1435 init_waitqueue_head(&hdmi->wait_event); in sti_hdmi_probe()
1437 hdmi->irq = platform_get_irq_byname(pdev, "irq"); in sti_hdmi_probe()
1438 if (hdmi->irq < 0) { in sti_hdmi_probe()
1439 DRM_ERROR("Cannot get HDMI irq\n"); in sti_hdmi_probe()
1440 ret = hdmi->irq; in sti_hdmi_probe()
1444 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq, in sti_hdmi_probe()
1445 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi); in sti_hdmi_probe()
1447 DRM_ERROR("Failed to register HDMI interrupt\n"); in sti_hdmi_probe()
1451 hdmi->reset = devm_reset_control_get(dev, "hdmi"); in sti_hdmi_probe()
1452 /* Take hdmi out of reset */ in sti_hdmi_probe()
1453 if (!IS_ERR(hdmi->reset)) in sti_hdmi_probe()
1454 reset_control_deassert(hdmi->reset); in sti_hdmi_probe()
1456 platform_set_drvdata(pdev, hdmi); in sti_hdmi_probe()
1458 return component_add(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_probe()
1461 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_probe()
1468 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev); in sti_hdmi_remove() local
1470 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_remove()
1471 if (hdmi->audio_pdev) in sti_hdmi_remove()
1472 platform_device_unregister(hdmi->audio_pdev); in sti_hdmi_remove()
1473 component_del(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_remove()
1480 .name = "sti-hdmi",