From d283b841244ca5f17a88cfe648bc0d78159e6e86 Mon Sep 17 00:00:00 2001 From: Sandor Yu Date: Thu, 10 Aug 2017 18:51:10 +0800 Subject: [PATCH] MLK-16184: hdmi: Add timeout check to hdmi initialize Add timeout check for hdmi FW alive function to avoid kernel booting hang for that board without HDMI FW. CDN_API_General_Test_Echo_Ext_blocking is the first function that calling mailbox. Add timeout to the function to avoid kernel booting hang for that board without HDMI ROM patch. Signed-off-by: Sandor Yu --- drivers/video/fbdev/mxc/cdn_hdp/API_General.c | 7 +++--- drivers/video/fbdev/mxc/cdn_hdp/util.h | 25 +++++++++++++++++-- drivers/video/fbdev/mxc/imx8_hdmi.c | 21 +++++++++++++--- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/drivers/video/fbdev/mxc/cdn_hdp/API_General.c b/drivers/video/fbdev/mxc/cdn_hdp/API_General.c index 9002d74e27b2..5958a1012e76 100644 --- a/drivers/video/fbdev/mxc/cdn_hdp/API_General.c +++ b/drivers/video/fbdev/mxc/cdn_hdp/API_General.c @@ -176,9 +176,8 @@ CDN_API_STATUS CDN_API_General_Test_Echo_Ext_blocking(uint8_t const *msg, uint16_t num_bytes, CDN_BUS_TYPE bus_type) { - internal_block_function(CDN_API_General_Test_Echo_Ext - (msg, resp, num_bytes, bus_type) - ); + internal_block_function_udelay(CDN_API_General_Test_Echo_Ext + (msg, resp, num_bytes, bus_type), 1000); } CDN_API_STATUS CDN_API_General_getCurVersion(unsigned short *ver, @@ -258,7 +257,7 @@ CDN_API_STATUS CDN_API_CheckAlive(void) CDN_API_STATUS CDN_API_CheckAlive_blocking(void) { - internal_block_function(CDN_API_CheckAlive()); + internal_block_function_udelay(CDN_API_CheckAlive(), 1000); } CDN_API_STATUS CDN_API_MainControl(unsigned char mode, unsigned char *resp) diff --git a/drivers/video/fbdev/mxc/cdn_hdp/util.h b/drivers/video/fbdev/mxc/cdn_hdp/util.h index 0248878e476a..dc8fdd81ed9c 100644 --- a/drivers/video/fbdev/mxc/cdn_hdp/util.h +++ b/drivers/video/fbdev/mxc/cdn_hdp/util.h @@ -45,9 +45,10 @@ */ #ifndef UTIL_H_ -# define UTIL_H_ +#define UTIL_H_ -# include "API_General.h" +#include +#include "API_General.h" /** * \addtogroup UTILS * \{ @@ -67,6 +68,26 @@ do { \ return ret; \ } while (0) +/** + * \brief expands to blocking function body + * \param x - function call + * \param y - num of loop + */ +# define internal_block_function_udelay(x, y) \ +do { \ + CDN_API_STATUS ret; \ + int i; \ + for (i = 0; i < y; i++) { \ + ret = x; \ + if (ret == CDN_OK) \ + break; \ + udelay(1); \ + } \ + if (i == y) \ + printk("timeout %s\n", __func__); \ + return ret; \ +} while (0) + /** * \brief write message and write response (if any), non-blocking way. Also sets state.running = 0 */ diff --git a/drivers/video/fbdev/mxc/imx8_hdmi.c b/drivers/video/fbdev/mxc/imx8_hdmi.c index dc0ae6cf94bb..b7dce3d583b0 100644 --- a/drivers/video/fbdev/mxc/imx8_hdmi.c +++ b/drivers/video/fbdev/mxc/imx8_hdmi.c @@ -117,6 +117,10 @@ static int hdmi_init(int vic, int encoding, int color_depth) ret = CDN_API_CheckAlive_blocking(); printk("CDN_API_CheckAlive returned ret = %d\n", ret); + if (ret != 0) { + printk("NO HDMI FW running\n"); + return -EINVAL; + } ret = CDN_API_General_Test_Echo_Ext_blocking(echo_msg, echo_resp, sizeof(echo_msg), @@ -124,6 +128,11 @@ static int hdmi_init(int vic, int encoding, int color_depth) printk ("CDN_API_General_Test_Echo_Ext_blocking - APB(ret = %d echo_resp = %s)\n", ret, echo_resp); + if (ret != 0) { + printk("HDMI mailbox access failed\n"); + return -EINVAL; + } + /* Configure PHY */ character_freq_khz = phy_cfg_hdp(4, vic_mode, bps, format, pixel_clk_from_phy); @@ -294,13 +303,17 @@ static int imx_hdmi_probe(struct platform_device *pdev) /* 0-480p, 1-720p, 2-1080p, 3-2160p60, 4-2160p30 */ /* Pixel Format - 1 RGB, 2 YCbCr 444, 3 YCbCr 420 */ if (vmode_index == 16) - hdmi_init(2, 1, 8); + ret = hdmi_init(2, 1, 8); else if (vmode_index == 97) - hdmi_init(3, 1, 8); + ret = hdmi_init(3, 1, 8); else if (vmode_index == 95) - hdmi_init(4, 1, 8); + ret = hdmi_init(4, 1, 8); else - hdmi_init(1, 1, 8); + ret = hdmi_init(1, 1, 8); + + if (ret < 0) + return -EINVAL; + dev_info(&pdev->dev, "i.MX HDMI driver probed\n"); return ret; -- 2.17.1