Lines Matching +full:i2c +full:- +full:hdmi
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Zheng Yang <zhengyang@rock-chips.com>
5 * Yakir Yang <ykk@rock-chips.com>
12 #include <linux/hdmi.h>
65 struct inno_hdmi_i2c *i2c; member
100 * Cb = -0.291G - 0.148R + 0.439B + 128
102 * Cr = -0.368G + 0.439R - 0.071B + 128
111 * Cb = - 0.338G - 0.101R + 0.439B + 128
113 * Cr = - 0.399G + 0.439R - 0.040B + 128
122 * R' = R x (235-16)/255 + 16;
123 * G' = G x (235-16)/255 + 16;
124 * B' = B x (235-16)/255 + 16;
145 static int inno_hdmi_find_phy_config(struct inno_hdmi *hdmi, in inno_hdmi_find_phy_config() argument
149 hdmi->variant->phy_configs; in inno_hdmi_find_phy_config()
157 DRM_DEV_DEBUG(hdmi->dev, "No phy configuration for pixelclock %lu\n", in inno_hdmi_find_phy_config()
160 return -EINVAL; in inno_hdmi_find_phy_config()
163 static inline u8 hdmi_readb(struct inno_hdmi *hdmi, u16 offset) in hdmi_readb() argument
165 return readl_relaxed(hdmi->regs + (offset) * 0x04); in hdmi_readb()
168 static inline void hdmi_writeb(struct inno_hdmi *hdmi, u16 offset, u32 val) in hdmi_writeb() argument
170 writel_relaxed(val, hdmi->regs + (offset) * 0x04); in hdmi_writeb()
173 static inline void hdmi_modb(struct inno_hdmi *hdmi, u16 offset, in hdmi_modb() argument
176 u8 temp = hdmi_readb(hdmi, offset) & ~msk; in hdmi_modb()
179 hdmi_writeb(hdmi, offset, temp); in hdmi_modb()
182 static void inno_hdmi_i2c_init(struct inno_hdmi *hdmi, unsigned long long rate) in inno_hdmi_i2c_init() argument
188 hdmi_writeb(hdmi, DDC_BUS_FREQ_L, ddc_bus_freq & 0xFF); in inno_hdmi_i2c_init()
189 hdmi_writeb(hdmi, DDC_BUS_FREQ_H, (ddc_bus_freq >> 8) & 0xFF); in inno_hdmi_i2c_init()
192 hdmi_writeb(hdmi, HDMI_INTERRUPT_MASK1, 0); in inno_hdmi_i2c_init()
193 hdmi_writeb(hdmi, HDMI_INTERRUPT_STATUS1, m_INT_EDID_READY); in inno_hdmi_i2c_init()
196 static void inno_hdmi_sys_power(struct inno_hdmi *hdmi, bool enable) in inno_hdmi_sys_power() argument
199 hdmi_modb(hdmi, HDMI_SYS_CTRL, m_POWER, v_PWR_ON); in inno_hdmi_sys_power()
201 hdmi_modb(hdmi, HDMI_SYS_CTRL, m_POWER, v_PWR_OFF); in inno_hdmi_sys_power()
204 static void inno_hdmi_standby(struct inno_hdmi *hdmi) in inno_hdmi_standby() argument
206 inno_hdmi_sys_power(hdmi, false); in inno_hdmi_standby()
208 hdmi_writeb(hdmi, HDMI_PHY_DRIVER, 0x00); in inno_hdmi_standby()
209 hdmi_writeb(hdmi, HDMI_PHY_PRE_EMPHASIS, 0x00); in inno_hdmi_standby()
210 hdmi_writeb(hdmi, HDMI_PHY_CHG_PWR, 0x00); in inno_hdmi_standby()
211 hdmi_writeb(hdmi, HDMI_PHY_SYS_CTL, 0x15); in inno_hdmi_standby()
214 static void inno_hdmi_power_up(struct inno_hdmi *hdmi, in inno_hdmi_power_up() argument
218 int ret = inno_hdmi_find_phy_config(hdmi, mpixelclock); in inno_hdmi_power_up()
221 phy_config = hdmi->variant->default_phy_config; in inno_hdmi_power_up()
222 DRM_DEV_ERROR(hdmi->dev, in inno_hdmi_power_up()
226 phy_config = &hdmi->variant->phy_configs[ret]; in inno_hdmi_power_up()
229 inno_hdmi_sys_power(hdmi, false); in inno_hdmi_power_up()
231 hdmi_writeb(hdmi, HDMI_PHY_PRE_EMPHASIS, phy_config->pre_emphasis); in inno_hdmi_power_up()
232 hdmi_writeb(hdmi, HDMI_PHY_DRIVER, phy_config->voltage_level_control); in inno_hdmi_power_up()
233 hdmi_writeb(hdmi, HDMI_PHY_SYS_CTL, 0x15); in inno_hdmi_power_up()
234 hdmi_writeb(hdmi, HDMI_PHY_SYS_CTL, 0x14); in inno_hdmi_power_up()
235 hdmi_writeb(hdmi, HDMI_PHY_SYS_CTL, 0x10); in inno_hdmi_power_up()
236 hdmi_writeb(hdmi, HDMI_PHY_CHG_PWR, 0x0f); in inno_hdmi_power_up()
237 hdmi_writeb(hdmi, HDMI_PHY_SYNC, 0x00); in inno_hdmi_power_up()
238 hdmi_writeb(hdmi, HDMI_PHY_SYNC, 0x01); in inno_hdmi_power_up()
240 inno_hdmi_sys_power(hdmi, true); in inno_hdmi_power_up()
243 static void inno_hdmi_reset(struct inno_hdmi *hdmi) in inno_hdmi_reset() argument
248 hdmi_modb(hdmi, HDMI_SYS_CTRL, m_RST_DIGITAL, v_NOT_RST_DIGITAL); in inno_hdmi_reset()
251 hdmi_modb(hdmi, HDMI_SYS_CTRL, m_RST_ANALOG, v_NOT_RST_ANALOG); in inno_hdmi_reset()
256 hdmi_modb(hdmi, HDMI_SYS_CTRL, msk, val); in inno_hdmi_reset()
258 inno_hdmi_standby(hdmi); in inno_hdmi_reset()
264 struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector); in inno_hdmi_disable_frame() local
267 drm_err(connector->dev, in inno_hdmi_disable_frame()
272 hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_BUF_INDEX, INFOFRAME_AVI); in inno_hdmi_disable_frame()
281 struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector); in inno_hdmi_upload_frame() local
285 drm_err(connector->dev, in inno_hdmi_upload_frame()
293 hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_ADDR + i, buffer[i]); in inno_hdmi_upload_frame()
303 static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi) in inno_hdmi_config_video_csc() argument
305 struct drm_connector *connector = &hdmi->connector; in inno_hdmi_config_video_csc()
306 struct drm_connector_state *conn_state = connector->state; in inno_hdmi_config_video_csc()
317 hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL1, v_DE_EXTERNAL | in inno_hdmi_config_video_csc()
324 hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL2, value); in inno_hdmi_config_video_csc()
326 if (conn_state->hdmi.output_format == HDMI_COLORSPACE_RGB) { in inno_hdmi_config_video_csc()
327 if (conn_state->hdmi.is_limited_range) { in inno_hdmi_config_video_csc()
335 hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); in inno_hdmi_config_video_csc()
337 hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, in inno_hdmi_config_video_csc()
344 if (inno_conn_state->colorimetry == HDMI_COLORIMETRY_ITU_601) { in inno_hdmi_config_video_csc()
345 if (conn_state->hdmi.output_format == HDMI_COLORSPACE_YUV444) { in inno_hdmi_config_video_csc()
352 if (conn_state->hdmi.output_format == HDMI_COLORSPACE_YUV444) { in inno_hdmi_config_video_csc()
362 hdmi_writeb(hdmi, HDMI_VIDEO_CSC_COEF + i, in inno_hdmi_config_video_csc()
366 hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL3, value); in inno_hdmi_config_video_csc()
367 hdmi_modb(hdmi, HDMI_VIDEO_CONTRL, m_VIDEO_AUTO_CSC | in inno_hdmi_config_video_csc()
374 static int inno_hdmi_config_video_timing(struct inno_hdmi *hdmi, in inno_hdmi_config_video_timing() argument
381 value |= mode->flags & DRM_MODE_FLAG_PHSYNC ? in inno_hdmi_config_video_timing()
383 value |= mode->flags & DRM_MODE_FLAG_PVSYNC ? in inno_hdmi_config_video_timing()
385 value |= mode->flags & DRM_MODE_FLAG_INTERLACE ? in inno_hdmi_config_video_timing()
387 hdmi_writeb(hdmi, HDMI_VIDEO_TIMING_CTL, value); in inno_hdmi_config_video_timing()
390 value = mode->htotal; in inno_hdmi_config_video_timing()
391 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HTOTAL_L, value & 0xFF); in inno_hdmi_config_video_timing()
392 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HTOTAL_H, (value >> 8) & 0xFF); in inno_hdmi_config_video_timing()
394 value = mode->htotal - mode->hdisplay; in inno_hdmi_config_video_timing()
395 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HBLANK_L, value & 0xFF); in inno_hdmi_config_video_timing()
396 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HBLANK_H, (value >> 8) & 0xFF); in inno_hdmi_config_video_timing()
398 value = mode->htotal - mode->hsync_start; in inno_hdmi_config_video_timing()
399 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HDELAY_L, value & 0xFF); in inno_hdmi_config_video_timing()
400 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HDELAY_H, (value >> 8) & 0xFF); in inno_hdmi_config_video_timing()
402 value = mode->hsync_end - mode->hsync_start; in inno_hdmi_config_video_timing()
403 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HDURATION_L, value & 0xFF); in inno_hdmi_config_video_timing()
404 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_HDURATION_H, (value >> 8) & 0xFF); in inno_hdmi_config_video_timing()
406 value = mode->vtotal; in inno_hdmi_config_video_timing()
407 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_VTOTAL_L, value & 0xFF); in inno_hdmi_config_video_timing()
408 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_VTOTAL_H, (value >> 8) & 0xFF); in inno_hdmi_config_video_timing()
410 value = mode->vtotal - mode->vdisplay; in inno_hdmi_config_video_timing()
411 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_VBLANK, value & 0xFF); in inno_hdmi_config_video_timing()
413 value = mode->vtotal - mode->vsync_start; in inno_hdmi_config_video_timing()
414 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_VDELAY, value & 0xFF); in inno_hdmi_config_video_timing()
416 value = mode->vsync_end - mode->vsync_start; in inno_hdmi_config_video_timing()
417 hdmi_writeb(hdmi, HDMI_VIDEO_EXT_VDURATION, value & 0xFF); in inno_hdmi_config_video_timing()
419 hdmi_writeb(hdmi, HDMI_PHY_PRE_DIV_RATIO, 0x1e); in inno_hdmi_config_video_timing()
420 hdmi_writeb(hdmi, HDMI_PHY_FEEDBACK_DIV_RATIO_LOW, 0x2c); in inno_hdmi_config_video_timing()
421 hdmi_writeb(hdmi, HDMI_PHY_FEEDBACK_DIV_RATIO_HIGH, 0x01); in inno_hdmi_config_video_timing()
426 static int inno_hdmi_setup(struct inno_hdmi *hdmi, in inno_hdmi_setup() argument
429 struct drm_connector *connector = &hdmi->connector; in inno_hdmi_setup()
430 struct drm_display_info *display = &connector->display_info; in inno_hdmi_setup()
436 return -EINVAL; in inno_hdmi_setup()
438 new_crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc); in inno_hdmi_setup()
440 return -EINVAL; in inno_hdmi_setup()
443 hdmi_modb(hdmi, HDMI_AV_MUTE, m_AUDIO_MUTE | m_VIDEO_BLACK, in inno_hdmi_setup()
446 /* Set HDMI Mode */ in inno_hdmi_setup()
447 hdmi_writeb(hdmi, HDMI_HDCP_CTRL, in inno_hdmi_setup()
448 v_HDMI_DVI(display->is_hdmi)); in inno_hdmi_setup()
450 inno_hdmi_config_video_timing(hdmi, &new_crtc_state->adjusted_mode); in inno_hdmi_setup()
452 inno_hdmi_config_video_csc(hdmi); in inno_hdmi_setup()
462 inno_hdmi_i2c_init(hdmi, new_conn_state->hdmi.tmds_char_rate); in inno_hdmi_setup()
465 hdmi_modb(hdmi, HDMI_AV_MUTE, m_AUDIO_MUTE | m_VIDEO_BLACK, in inno_hdmi_setup()
468 inno_hdmi_power_up(hdmi, new_conn_state->hdmi.tmds_char_rate); in inno_hdmi_setup()
473 static enum drm_mode_status inno_hdmi_display_mode_valid(struct inno_hdmi *hdmi, in inno_hdmi_display_mode_valid() argument
479 /* No support for double-clock modes */ in inno_hdmi_display_mode_valid()
480 if (mode->flags & DRM_MODE_FLAG_DBLCLK) in inno_hdmi_display_mode_valid()
483 mpixelclk = mode->clock * 1000; in inno_hdmi_display_mode_valid()
488 if (inno_hdmi_find_phy_config(hdmi, mpixelclk) < 0) in inno_hdmi_display_mode_valid()
491 if (hdmi->refclk) { in inno_hdmi_display_mode_valid()
492 rounded_refclk = clk_round_rate(hdmi->refclk, mpixelclk); in inno_hdmi_display_mode_valid()
496 /* Vesa DMT standard mentions +/- 0.5% max tolerance */ in inno_hdmi_display_mode_valid()
508 struct inno_hdmi *hdmi = encoder_to_inno_hdmi(encoder); in inno_hdmi_encoder_enable() local
510 inno_hdmi_setup(hdmi, state); in inno_hdmi_encoder_enable()
516 struct inno_hdmi *hdmi = encoder_to_inno_hdmi(encoder); in inno_hdmi_encoder_disable() local
518 inno_hdmi_standby(hdmi); in inno_hdmi_encoder_disable()
527 struct drm_display_mode *mode = &crtc_state->adjusted_mode; in inno_hdmi_encoder_atomic_check()
532 s->output_mode = ROCKCHIP_OUT_MODE_P888; in inno_hdmi_encoder_atomic_check()
533 s->output_type = DRM_MODE_CONNECTOR_HDMIA; in inno_hdmi_encoder_atomic_check()
539 inno_conn_state->colorimetry = HDMI_COLORIMETRY_ITU_601; in inno_hdmi_encoder_atomic_check()
541 inno_conn_state->colorimetry = HDMI_COLORIMETRY_ITU_709; in inno_hdmi_encoder_atomic_check()
555 struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector); in inno_hdmi_connector_detect() local
557 return (hdmi_readb(hdmi, HDMI_STATUS) & m_HOTPLUG) ? in inno_hdmi_connector_detect()
563 struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector); in inno_hdmi_connector_get_modes() local
567 if (!hdmi->ddc) in inno_hdmi_connector_get_modes()
570 drm_edid = drm_edid_read_ddc(connector, hdmi->ddc); in inno_hdmi_connector_get_modes()
582 struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector); in inno_hdmi_connector_mode_valid() local
584 return inno_hdmi_display_mode_valid(hdmi, mode); in inno_hdmi_connector_mode_valid()
594 __drm_atomic_helper_connector_destroy_state(&inno_conn_state->base); in inno_hdmi_connector_destroy_state()
602 if (connector->state) { in inno_hdmi_connector_reset()
603 inno_hdmi_connector_destroy_state(connector, connector->state); in inno_hdmi_connector_reset()
604 connector->state = NULL; in inno_hdmi_connector_reset()
611 __drm_atomic_helper_connector_reset(connector, &inno_conn_state->base); in inno_hdmi_connector_reset()
612 __drm_atomic_helper_connector_hdmi_reset(connector, connector->state); in inno_hdmi_connector_reset()
614 inno_conn_state->colorimetry = HDMI_COLORIMETRY_ITU_709; in inno_hdmi_connector_reset()
622 if (WARN_ON(!connector->state)) in inno_hdmi_connector_duplicate_state()
625 inno_conn_state = kmemdup(to_inno_hdmi_conn_state(connector->state), in inno_hdmi_connector_duplicate_state()
632 &inno_conn_state->base); in inno_hdmi_connector_duplicate_state()
634 return &inno_conn_state->base; in inno_hdmi_connector_duplicate_state()
651 static int inno_hdmi_register(struct drm_device *drm, struct inno_hdmi *hdmi) in inno_hdmi_register() argument
653 struct drm_encoder *encoder = &hdmi->encoder.encoder; in inno_hdmi_register()
654 struct device *dev = hdmi->dev; in inno_hdmi_register()
656 encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node); in inno_hdmi_register()
664 if (encoder->possible_crtcs == 0) in inno_hdmi_register()
665 return -EPROBE_DEFER; in inno_hdmi_register()
670 hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD; in inno_hdmi_register()
672 drm_connector_helper_add(&hdmi->connector, in inno_hdmi_register()
674 drmm_connector_hdmi_init(drm, &hdmi->connector, in inno_hdmi_register()
675 "Rockchip", "Inno HDMI", in inno_hdmi_register()
679 hdmi->ddc, in inno_hdmi_register()
683 drm_connector_attach_encoder(&hdmi->connector, encoder); in inno_hdmi_register()
688 static irqreturn_t inno_hdmi_i2c_irq(struct inno_hdmi *hdmi) in inno_hdmi_i2c_irq() argument
690 struct inno_hdmi_i2c *i2c = hdmi->i2c; in inno_hdmi_i2c_irq() local
693 stat = hdmi_readb(hdmi, HDMI_INTERRUPT_STATUS1); in inno_hdmi_i2c_irq()
697 /* Clear HDMI EDID interrupt flag */ in inno_hdmi_i2c_irq()
698 hdmi_writeb(hdmi, HDMI_INTERRUPT_STATUS1, m_INT_EDID_READY); in inno_hdmi_i2c_irq()
700 complete(&i2c->cmp); in inno_hdmi_i2c_irq()
707 struct inno_hdmi *hdmi = dev_id; in inno_hdmi_hardirq() local
711 if (hdmi->i2c) in inno_hdmi_hardirq()
712 ret = inno_hdmi_i2c_irq(hdmi); in inno_hdmi_hardirq()
714 interrupt = hdmi_readb(hdmi, HDMI_STATUS); in inno_hdmi_hardirq()
716 hdmi_modb(hdmi, HDMI_STATUS, m_INT_HOTPLUG, m_INT_HOTPLUG); in inno_hdmi_hardirq()
725 struct inno_hdmi *hdmi = dev_id; in inno_hdmi_irq() local
727 drm_helper_hpd_irq_event(hdmi->connector.dev); in inno_hdmi_irq()
732 static int inno_hdmi_i2c_read(struct inno_hdmi *hdmi, struct i2c_msg *msgs) in inno_hdmi_i2c_read() argument
734 int length = msgs->len; in inno_hdmi_i2c_read()
735 u8 *buf = msgs->buf; in inno_hdmi_i2c_read()
738 ret = wait_for_completion_timeout(&hdmi->i2c->cmp, HZ / 10); in inno_hdmi_i2c_read()
740 return -EAGAIN; in inno_hdmi_i2c_read()
742 while (length--) in inno_hdmi_i2c_read()
743 *buf++ = hdmi_readb(hdmi, HDMI_EDID_FIFO_ADDR); in inno_hdmi_i2c_read()
748 static int inno_hdmi_i2c_write(struct inno_hdmi *hdmi, struct i2c_msg *msgs) in inno_hdmi_i2c_write() argument
752 * we assume that each word write to this i2c adapter in inno_hdmi_i2c_write()
755 if ((msgs->len != 1) || in inno_hdmi_i2c_write()
756 ((msgs->addr != DDC_ADDR) && (msgs->addr != DDC_SEGMENT_ADDR))) in inno_hdmi_i2c_write()
757 return -EINVAL; in inno_hdmi_i2c_write()
759 reinit_completion(&hdmi->i2c->cmp); in inno_hdmi_i2c_write()
761 if (msgs->addr == DDC_SEGMENT_ADDR) in inno_hdmi_i2c_write()
762 hdmi->i2c->segment_addr = msgs->buf[0]; in inno_hdmi_i2c_write()
763 if (msgs->addr == DDC_ADDR) in inno_hdmi_i2c_write()
764 hdmi->i2c->ddc_addr = msgs->buf[0]; in inno_hdmi_i2c_write()
767 hdmi_writeb(hdmi, HDMI_EDID_FIFO_OFFSET, 0x00); in inno_hdmi_i2c_write()
770 hdmi_writeb(hdmi, HDMI_EDID_WORD_ADDR, hdmi->i2c->ddc_addr); in inno_hdmi_i2c_write()
773 hdmi_writeb(hdmi, HDMI_EDID_SEGMENT_POINTER, hdmi->i2c->segment_addr); in inno_hdmi_i2c_write()
781 struct inno_hdmi *hdmi = i2c_get_adapdata(adap); in inno_hdmi_i2c_xfer() local
782 struct inno_hdmi_i2c *i2c = hdmi->i2c; in inno_hdmi_i2c_xfer() local
785 mutex_lock(&i2c->lock); in inno_hdmi_i2c_xfer()
788 hdmi_writeb(hdmi, HDMI_INTERRUPT_MASK1, m_INT_EDID_READY); in inno_hdmi_i2c_xfer()
789 hdmi_writeb(hdmi, HDMI_INTERRUPT_STATUS1, m_INT_EDID_READY); in inno_hdmi_i2c_xfer()
792 DRM_DEV_DEBUG(hdmi->dev, in inno_hdmi_i2c_xfer()
797 ret = inno_hdmi_i2c_read(hdmi, &msgs[i]); in inno_hdmi_i2c_xfer()
799 ret = inno_hdmi_i2c_write(hdmi, &msgs[i]); in inno_hdmi_i2c_xfer()
808 /* Mute HDMI EDID interrupt */ in inno_hdmi_i2c_xfer()
809 hdmi_writeb(hdmi, HDMI_INTERRUPT_MASK1, 0); in inno_hdmi_i2c_xfer()
811 mutex_unlock(&i2c->lock); in inno_hdmi_i2c_xfer()
826 static struct i2c_adapter *inno_hdmi_i2c_adapter(struct inno_hdmi *hdmi) in inno_hdmi_i2c_adapter() argument
829 struct inno_hdmi_i2c *i2c; in inno_hdmi_i2c_adapter() local
832 i2c = devm_kzalloc(hdmi->dev, sizeof(*i2c), GFP_KERNEL); in inno_hdmi_i2c_adapter()
833 if (!i2c) in inno_hdmi_i2c_adapter()
834 return ERR_PTR(-ENOMEM); in inno_hdmi_i2c_adapter()
836 mutex_init(&i2c->lock); in inno_hdmi_i2c_adapter()
837 init_completion(&i2c->cmp); in inno_hdmi_i2c_adapter()
839 adap = &i2c->adap; in inno_hdmi_i2c_adapter()
840 adap->owner = THIS_MODULE; in inno_hdmi_i2c_adapter()
841 adap->dev.parent = hdmi->dev; in inno_hdmi_i2c_adapter()
842 adap->dev.of_node = hdmi->dev->of_node; in inno_hdmi_i2c_adapter()
843 adap->algo = &inno_hdmi_algorithm; in inno_hdmi_i2c_adapter()
844 strscpy(adap->name, "Inno HDMI", sizeof(adap->name)); in inno_hdmi_i2c_adapter()
845 i2c_set_adapdata(adap, hdmi); in inno_hdmi_i2c_adapter()
849 dev_warn(hdmi->dev, "cannot add %s I2C adapter\n", adap->name); in inno_hdmi_i2c_adapter()
850 devm_kfree(hdmi->dev, i2c); in inno_hdmi_i2c_adapter()
854 hdmi->i2c = i2c; in inno_hdmi_i2c_adapter()
856 DRM_DEV_INFO(hdmi->dev, "registered %s I2C bus driver\n", adap->name); in inno_hdmi_i2c_adapter()
866 struct inno_hdmi *hdmi; in inno_hdmi_bind() local
871 hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL); in inno_hdmi_bind()
872 if (!hdmi) in inno_hdmi_bind()
873 return -ENOMEM; in inno_hdmi_bind()
875 hdmi->dev = dev; in inno_hdmi_bind()
877 variant = of_device_get_match_data(hdmi->dev); in inno_hdmi_bind()
879 return -EINVAL; in inno_hdmi_bind()
881 hdmi->variant = variant; in inno_hdmi_bind()
883 hdmi->regs = devm_platform_ioremap_resource(pdev, 0); in inno_hdmi_bind()
884 if (IS_ERR(hdmi->regs)) in inno_hdmi_bind()
885 return PTR_ERR(hdmi->regs); in inno_hdmi_bind()
887 hdmi->pclk = devm_clk_get(hdmi->dev, "pclk"); in inno_hdmi_bind()
888 if (IS_ERR(hdmi->pclk)) { in inno_hdmi_bind()
889 DRM_DEV_ERROR(hdmi->dev, "Unable to get HDMI pclk clk\n"); in inno_hdmi_bind()
890 return PTR_ERR(hdmi->pclk); in inno_hdmi_bind()
893 ret = clk_prepare_enable(hdmi->pclk); in inno_hdmi_bind()
895 DRM_DEV_ERROR(hdmi->dev, in inno_hdmi_bind()
896 "Cannot enable HDMI pclk clock: %d\n", ret); in inno_hdmi_bind()
900 hdmi->refclk = devm_clk_get_optional(hdmi->dev, "ref"); in inno_hdmi_bind()
901 if (IS_ERR(hdmi->refclk)) { in inno_hdmi_bind()
902 DRM_DEV_ERROR(hdmi->dev, "Unable to get HDMI reference clock\n"); in inno_hdmi_bind()
903 ret = PTR_ERR(hdmi->refclk); in inno_hdmi_bind()
907 ret = clk_prepare_enable(hdmi->refclk); in inno_hdmi_bind()
909 DRM_DEV_ERROR(hdmi->dev, in inno_hdmi_bind()
910 "Cannot enable HDMI reference clock: %d\n", ret); in inno_hdmi_bind()
920 inno_hdmi_reset(hdmi); in inno_hdmi_bind()
922 hdmi->ddc = inno_hdmi_i2c_adapter(hdmi); in inno_hdmi_bind()
923 if (IS_ERR(hdmi->ddc)) { in inno_hdmi_bind()
924 ret = PTR_ERR(hdmi->ddc); in inno_hdmi_bind()
925 hdmi->ddc = NULL; in inno_hdmi_bind()
936 if (hdmi->refclk) in inno_hdmi_bind()
937 inno_hdmi_i2c_init(hdmi, clk_get_rate(hdmi->refclk)); in inno_hdmi_bind()
939 inno_hdmi_i2c_init(hdmi, clk_get_rate(hdmi->pclk)); in inno_hdmi_bind()
941 ret = inno_hdmi_register(drm, hdmi); in inno_hdmi_bind()
945 dev_set_drvdata(dev, hdmi); in inno_hdmi_bind()
948 hdmi_modb(hdmi, HDMI_STATUS, m_MASK_INT_HOTPLUG, v_MASK_INT_HOTPLUG(1)); in inno_hdmi_bind()
952 dev_name(dev), hdmi); in inno_hdmi_bind()
958 hdmi->connector.funcs->destroy(&hdmi->connector); in inno_hdmi_bind()
959 hdmi->encoder.encoder.funcs->destroy(&hdmi->encoder.encoder); in inno_hdmi_bind()
961 i2c_put_adapter(hdmi->ddc); in inno_hdmi_bind()
963 clk_disable_unprepare(hdmi->refclk); in inno_hdmi_bind()
965 clk_disable_unprepare(hdmi->pclk); in inno_hdmi_bind()
972 struct inno_hdmi *hdmi = dev_get_drvdata(dev); in inno_hdmi_unbind() local
974 hdmi->connector.funcs->destroy(&hdmi->connector); in inno_hdmi_unbind()
975 hdmi->encoder.encoder.funcs->destroy(&hdmi->encoder.encoder); in inno_hdmi_unbind()
977 i2c_put_adapter(hdmi->ddc); in inno_hdmi_unbind()
978 clk_disable_unprepare(hdmi->refclk); in inno_hdmi_unbind()
979 clk_disable_unprepare(hdmi->pclk); in inno_hdmi_unbind()
989 return component_add(&pdev->dev, &inno_hdmi_ops); in inno_hdmi_probe()
994 component_del(&pdev->dev, &inno_hdmi_ops); in inno_hdmi_remove()
1008 { .compatible = "rockchip,rk3036-inno-hdmi",
1011 { .compatible = "rockchip,rk3128-inno-hdmi",
1022 .name = "innohdmi-rockchip",