hdmitx: replace I2C_REACTIVE with I2C_RESET logic [1/1]
authorZongdong Jiao <zongdong.jiao@amlogic.com>
Thu, 23 May 2019 12:59:32 +0000 (20:59 +0800)
committerNick Xie <nick@khadas.com>
Mon, 5 Aug 2019 06:45:51 +0000 (14:45 +0800)
PD#OTT-3716

Problem:
In GX, there is the I2C_REACTIVE method to avoid the I2C hangup
issue. But it is fixed in G12, so need replace it.

Solution:
Replace I2C_REACTIVE with I2C_RESET logic

Verify:
G12/U212

Change-Id: I1ca2f77a213db0d7de067745b3701816b7c85c27
Signed-off-by: Zongdong Jiao <zongdong.jiao@amlogic.com>
drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hdmi_tx_main.c
drivers/amlogic/media/vout/hdmitx/hdmi_tx_20/hw/hdmi_tx_hw.c
include/linux/amlogic/media/vout/hdmi_tx/hdmi_tx_module.h

index 2136573..8ea929c 100644 (file)
@@ -3944,7 +3944,8 @@ static void hdmitx_hpd_plugin_handler(struct work_struct *work)
        }
        mutex_lock(&setclk_mutex);
        pr_info(SYS "plugin\n");
-       hdev->HWOp.CntlMisc(hdev, MISC_I2C_REACTIVE, 0);
+       if (hdev->chip_type >= MESON_CPU_ID_G12A)
+               hdev->HWOp.CntlMisc(hdev, MISC_I2C_RESET, 0);
        hdev->hdmitx_event &= ~HDMI_TX_HPD_PLUGIN;
        /* start reading E-EDID */
        if (hdev->repeater_tx)
@@ -3958,6 +3959,8 @@ static void hdmitx_hpd_plugin_handler(struct work_struct *work)
                hdev->HWOp.CntlConfig(hdev,
                        CONF_HDMI_DVI_MODE, HDMI_MODE);
        mutex_lock(&getedid_mutex);
+       if (hdev->chip_type < MESON_CPU_ID_G12A)
+               hdev->HWOp.CntlMisc(hdev, MISC_I2C_REACTIVE, 0);
        mutex_unlock(&getedid_mutex);
        if (hdev->repeater_tx) {
                if (check_fbc_special(&hdev->EDID_buf[0])
index efd329a..51dc0d1 100644 (file)
@@ -4311,6 +4311,7 @@ static void hdmitx_getediddata(unsigned char *des, unsigned char *src)
 /*
  * Note: read 8 Bytes of EDID data every time
  */
+#define EDID_WAIT_TIMEOUT      10
 static void hdmitx_read_edid(unsigned char *rx_edid)
 {
        unsigned int timeout = 0;
@@ -4320,6 +4321,7 @@ static void hdmitx_read_edid(unsigned char *rx_edid)
 
        /* Program SLAVE/ADDR */
        hdmitx_wr_reg(HDMITX_DWC_I2CM_SLAVE, 0x50);
+       hdmitx_wr_reg(HDMITX_DWC_IH_I2CM_STAT0, 1 << 1);
        /* Read complete EDID data sequentially */
        while (byte_num < 128 * blk_no) {
                hdmitx_wr_reg(HDMITX_DWC_I2CM_ADDRESS,  byte_num&0xff);
@@ -4333,11 +4335,11 @@ static void hdmitx_read_edid(unsigned char *rx_edid)
                /* Wait until I2C done */
                timeout = 0;
                while ((!(hdmitx_rd_reg(HDMITX_DWC_IH_I2CM_STAT0) & (1 << 1)))
-                       && (timeout < 3)) {
+                       && (timeout < EDID_WAIT_TIMEOUT)) {
                        mdelay(2);
                        timeout++;
                }
-               if (timeout == 3)
+               if (timeout == EDID_WAIT_TIMEOUT)
                        pr_info(HW "ddc timeout\n");
                hdmitx_wr_reg(HDMITX_DWC_IH_I2CM_STAT0, 1 << 1);
                /* Read back 8 bytes */
@@ -5042,6 +5044,13 @@ static int hdmitx_cntl_misc(struct hdmitx_dev *hdev, unsigned int cmd,
                }
                hdmitx_set_reg_bits(HDMITX_DWC_MC_CLKDIS, !!argv, 6, 1);
                break;
+       case MISC_I2C_RESET:
+               hdmitx_set_reg_bits(HDMITX_TOP_SW_RESET, 1, 9, 1);
+               usleep_range(1000, 2000);
+               hdmitx_set_reg_bits(HDMITX_TOP_SW_RESET, 0, 9, 1);
+               usleep_range(1000, 2000);
+               hdmi_hwi_init(hdev);
+               break;
        case MISC_I2C_REACTIVE:
                hdmitx_hdcp_opr(4);
                hdmitx_set_reg_bits(HDMITX_DWC_A_HDCPCFG1, 0, 0, 1);
index 8352f3d..5b85d43 100644 (file)
@@ -565,7 +565,8 @@ struct hdmitx_dev {
 #define MISC_HDCP_CLKDIS       (CMD_MISC_OFFSET + 0x0e)
 #define MISC_TMDS_RXSENSE      (CMD_MISC_OFFSET + 0x0f)
 #define MISC_I2C_REACTIVE       (CMD_MISC_OFFSET + 0x10)
-#define MISC_READ_AVMUTE_OP     (CMD_MISC_OFFSET + 0x11)
+#define MISC_I2C_RESET         (CMD_MISC_OFFSET + 0x11)
+#define MISC_READ_AVMUTE_OP     (CMD_MISC_OFFSET + 0x12)
 
 /***********************************************************************
  *                          Get State //GetState