MLK-20481: hdp: change hdmi keep-alive check mechanism
authorSandor Yu <Sandor.yu@nxp.com>
Wed, 28 Nov 2018 07:06:17 +0000 (15:06 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
The current keep-alive check mechanism uses a static variable
that is initialized to 0. When the function is first called, it may
happen to catch the 8-bit keep-alive counter right when it
overflows, hence returning BUSY.

This patch will keep checking the counter for 10us, every 1us,
but it will immediately return if the keep-alive counter changed.

Signed-off-by: Laurentiu Palcu<laurentiu.palcu@nxp.com>
Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
drivers/mxc/hdp/API_General.c

index 85c0b61..6c2c5fe 100644 (file)
@@ -51,8 +51,6 @@
 #include "general_handler.h"
 #include "util.h"
 
-static u32 alive;
-
 CDN_API_STATUS CDN_API_LoadFirmware(state_struct *state, u8 *iMem,
                                    int imemSize, u8 *dMem, int dmemSize)
 {
@@ -243,15 +241,25 @@ CDN_API_STATUS CDN_API_Get_Debug_Reg_Val(state_struct *state, u16 *val)
 
 CDN_API_STATUS CDN_API_CheckAlive(state_struct *state)
 {
-       u32 newalive;
-       if (cdn_apb_read(state, KEEP_ALIVE << 2, &newalive))
+       u32  alive, newalive;
+       u8 retries_left = 10;
+
+       if (cdn_apb_read(state, KEEP_ALIVE << 2, &alive))
                return CDN_ERR;
-       if (alive == newalive)
-               return CDN_BSY;
-       alive = newalive;
-       return CDN_OK;
+
+       while (retries_left--) {
+               udelay(1);
+
+               if (cdn_apb_read(state, KEEP_ALIVE << 2, &newalive))
+                       return CDN_ERR;
+               if (alive == newalive)
+                       continue;
+               return CDN_OK;
+       }
+       return CDN_BSY;
 }
 
+
 CDN_API_STATUS CDN_API_CheckAlive_blocking(state_struct *state)
 {
        internal_block_function(&state->mutex, CDN_API_CheckAlive(state));