MLK-17206 hdp: Disable firmware hdp loading
authorOliver Brown <oliver.brown@nxp.com>
Thu, 14 Dec 2017 00:16:08 +0000 (18:16 -0600)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Disabling HDP firmware loading except for debug.
Added simple checks to test HDP firmware status.

Signed-off-by: Oliver Brown <oliver.brown@nxp.com>
drivers/gpu/drm/imx/hdp/imx-dp.c
drivers/gpu/drm/imx/hdp/imx-dp.h
drivers/gpu/drm/imx/hdp/imx-hdmi.c
drivers/gpu/drm/imx/hdp/imx-hdmi.h
drivers/gpu/drm/imx/hdp/imx-hdp.c
drivers/gpu/drm/imx/hdp/imx-hdp.h

index 93ed753..cfdd3c1 100644 (file)
  */
 
 #include <linux/clk.h>
+#ifdef DEBUG_FW_LOAD
 #include "mhdp_firmware.h"
+#endif
 #include "imx-hdp.h"
 #include "imx-hdmi.h"
 #include "imx-dp.h"
 
+#ifdef DEBUG_FW_LOAD
 void dp_fw_load(state_struct *state)
 {
        pr_info("loading hdmi firmware\n");
@@ -27,8 +30,8 @@ void dp_fw_load(state_struct *state)
                (u8 *)mhdp_dram0_get_ptr(),
                mhdp_dram0_get_size());
 }
-
-void dp_fw_init(state_struct *state)
+#endif
+int dp_fw_init(state_struct *state)
 {
        u8 echo_msg[] = "echo test";
        u8 echo_resp[sizeof(echo_msg) + 1];
@@ -47,7 +50,11 @@ void dp_fw_init(state_struct *state)
        pr_info("Started firmware!\n");
 
        ret = CDN_API_CheckAlive_blocking(state);
-       pr_info("CDN_API_CheckAlive returned (ret = %d)\n", ret);
+       if (ret != 0) {
+               pr_err("CDN_API_CheckAlive failed - check firmware!\n");
+               return -ENXIO;
+       } else
+               pr_info("CDN_API_CheckAlive returned ret = %d\n", ret);
 
        /* turn on IP activity */
        ret = CDN_API_MainControl_blocking(state, 1, &resp);
@@ -56,6 +63,10 @@ void dp_fw_init(state_struct *state)
 
        ret = CDN_API_General_Test_Echo_Ext_blocking(state, echo_msg, echo_resp,
                sizeof(echo_msg), CDN_BUS_TYPE_APB);
+       if (0 != strncmp(echo_msg, echo_resp, sizeof(echo_msg))) {
+               pr_err("CDN_API_General_Test_Echo_Ext_blocking - echo test failed, check firmware!");
+               return -ENXIO;
+       }
        pr_info("CDN_API_General_Test_Echo_Ext_blocking (ret = %d echo_resp = %s)\n",
                ret, echo_resp);
 
@@ -63,6 +74,8 @@ void dp_fw_init(state_struct *state)
        CDN_API_General_Write_Register_blocking(state,
                ADDR_SOURCD_PHY + (LANES_CONFIG << 2), 0x0040001b);
        pr_info("CDN_API_General_Write_Register_blockin ... setting LANES_CONFIG\n");
+
+       return 0;
 }
 
 int dp_phy_init(state_struct *state, int vic, int format, int color_depth)
index 26300a8..dc597a9 100644 (file)
@@ -15,7 +15,7 @@
 #define _IMX_DP_H_
 
 void dp_fw_load(state_struct *state);
-void dp_fw_init(state_struct *state);
+int dp_fw_init(state_struct *state);
 void dp_mode_set(state_struct *state, int vic, int format, int color_depth, int max_link_rate);
 int dp_phy_init(state_struct *state, int vic, int format, int color_depth);
 int dp_get_edid_block(void *data, u8 *buf, u32 block, size_t len);
index 28b15ba..51bac00 100644 (file)
  */
 
 #include <linux/clk.h>
+#ifdef DEBUG_FW_LOAD
 #include "hdmitx_firmware.h"
+#endif
 #include "imx-hdp.h"
 #include "imx-hdmi.h"
 #include "API_AFE_ss28fdsoi_kiran_hdmitx.h"
 #include "API_AFE_t28hpc_hdmitx.h"
 
 static int character_freq_khz;
-
+#ifdef DEBUG_FW_LOAD
 void hdmi_fw_load(state_struct *state)
 {
        pr_info("loading hdmi firmware\n");
@@ -30,8 +32,8 @@ void hdmi_fw_load(state_struct *state)
                (u8 *)hdmitx_dram0_get_ptr(),
                hdmitx_dram0_get_size());
 }
-
-void hdmi_fw_init(state_struct *state)
+#endif
+int hdmi_fw_init(state_struct *state)
 {
        u8 echo_msg[] = "echo test";
        u8 echo_resp[sizeof(echo_msg) + 1];
@@ -51,7 +53,11 @@ void hdmi_fw_init(state_struct *state)
        pr_info("Started firmware!\n");
 
        ret = CDN_API_CheckAlive_blocking(state);
-       pr_info("CDN_API_CheckAlive returned ret = %d\n", ret);
+       if (ret != 0) {
+               pr_err("CDN_API_CheckAlive failed - check firmware!\n");
+               return -ENXIO;
+       } else
+               pr_info("CDN_API_CheckAlive returned ret = %d\n", ret);
 
        /* turn on IP activity */
        ret = CDN_API_MainControl_blocking(state, 1, &sts);
@@ -59,8 +65,15 @@ void hdmi_fw_init(state_struct *state)
 
        ret = CDN_API_General_Test_Echo_Ext_blocking(state, echo_msg, echo_resp,
                 sizeof(echo_msg), CDN_BUS_TYPE_APB);
-        pr_info("CDN_API_General_Test_Echo_Ext_blocking - APB(ret = %d echo_resp = %s)\n",
-                ret, echo_resp);
+
+       if (0 != strncmp(echo_msg, echo_resp, sizeof(echo_msg))) {
+               pr_err("CDN_API_General_Test_Echo_Ext_blocking - echo test failed, check firmware!");
+               return -ENXIO;
+       }
+       pr_info("CDN_API_General_Test_Echo_Ext_blocking - APB(ret = %d echo_resp = %s)\n",
+                 ret, echo_resp);
+
+       return 0;
 }
 
 int hdmi_phy_init(state_struct *state, int vic, int format, int color_depth)
index e6c4b7c..de46462 100644 (file)
@@ -15,7 +15,7 @@
 #define _IMX_HDMI_H_
 
 void hdmi_fw_load(state_struct *state);
-void hdmi_fw_init(state_struct *state);
+int hdmi_fw_init(state_struct *state);
 int hdmi_phy_init(state_struct *state, int vic, int format, int color_depth);
 void hdmi_mode_set(state_struct *state, int vic, int format, int color_depth, int temp);
 int hdmi_get_edid_block(void *data, u8 *buf, u32 block, size_t len);
index 7a7acf1..26a5bcc 100644 (file)
@@ -885,7 +885,9 @@ static struct hdp_rw_func imx8qm_rw = {
 };
 
 static struct hdp_ops imx8qm_dp_ops = {
+#ifdef DEBUG_FW_LOAD
        .fw_load = dp_fw_load,
+#endif
        .fw_init = dp_fw_init,
        .phy_init = dp_phy_init,
        .mode_set = dp_mode_set,
@@ -907,7 +909,9 @@ static struct hdp_ops imx8qm_dp_ops = {
 };
 
 static struct hdp_ops imx8qm_hdmi_ops = {
+#ifdef DEBUG_FW_LOAD
        .fw_load = hdmi_fw_load,
+#endif
        .fw_init = hdmi_fw_init,
        .phy_init = hdmi_phy_init,
        .mode_set = hdmi_mode_set,
@@ -1099,7 +1103,12 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master,
 
        imx_hdp_call(hdp, fw_load, &hdp->state);
 
-       imx_hdp_call(hdp, fw_init, &hdp->state);
+       ret = imx_hdp_call(hdp, fw_init, &hdp->state);
+       if (ret < 0) {
+               pr_err("Failed to initialise HDP firmware\n");
+               DRM_ERROR("Failed to initialise HDP firmware\n");
+               return ret;
+       }
 
        /* Pixel Format - 1 RGB, 2 YCbCr 444, 3 YCbCr 420 */
        /* bpp (bits per subpixel) - 8 24bpp, 10 30bpp, 12 36bpp, 16 48bpp */
index 1323bae..5ece813 100644 (file)
@@ -27,6 +27,8 @@
 #include <drm/drm_dp_helper.h>
 #include "../../../../mxc/hdp/all.h"
 
+/* For testing hdp firmware define DEBUG_FW_LOAD */
+#undef DEBUG_FW_LOAD
 #define PLL_1188MHZ (1188000000)
 #define PLL_675MHZ (675000000)
 
@@ -81,7 +83,7 @@ struct hdp_clks;
 
 struct hdp_ops {
        void (*fw_load)(state_struct *state);
-       void (*fw_init)(state_struct *state);
+       int (*fw_init)(state_struct *state);
        int (*phy_init)(state_struct *state, int vic, int format, int color_depth);
        void (*mode_set)(state_struct *state, int vic, int format, int color_depth, int max_link);
        int (*get_edid_block)(void *data, u8 *buf, u32 block, size_t len);