gfx: drv: cleanup dsi pll lock loop in mdfld_restore_display_registers
authorImre Deak <imre.deak@intel.com>
Tue, 6 Mar 2012 19:17:28 +0000 (21:17 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:30:28 +0000 (12:30 +0300)
Use the already existing macro to wait for the HW flag becoming set. The
current timeout value will change from the current 3 second. The actual
PLL settling time according to measurement is < 100usec or 200
iterations of the busy wait loop. So the new timeout duration of 100000
iterations should be enough.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/staging/mrst/drv/psb_powermgmt.c

index 7bafa62..0f37348 100644 (file)
@@ -598,7 +598,6 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipe)
        struct mdfld_dsi_config * dsi_config = NULL;
        u32 i = 0;
        u32 dpll = 0;
-       u32 timeout = 0;
 
        /* regester */
        u32 dpll_reg = MRST_DPLL_A;
@@ -653,8 +652,6 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipe)
                dpll = PSB_RVDC32(dpll_reg);
 
                if (!(dpll & DPLL_VCO_ENABLE)) {
-                       unsigned long pipeconf_reg;
-
                        /* When ungating power of DPLL, needs to wait 0.5us before enable the VCO */
                        if (dpll & MDFLD_PWR_GATE_EN) {
                                dpll &= ~MDFLD_PWR_GATE_EN;
@@ -672,15 +669,9 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipe)
                        PSB_WVDC32(dpll_val, dpll_reg);
                        PSB_RVDC32(dpll_reg);
 
-                       pipeconf_reg = PSB_PIPECONF(pipe);
-                       /* wait for DSI PLL to lock */
-                       while ((timeout < 20000) && !(PSB_RVDC32(pipeconf_reg) & PIPECONF_DSIPLL_LOCK)) {
-                               udelay(150);
-                               timeout ++;
-                       }
-
-                       if (timeout == 20000) {
-                               DRM_ERROR("%s, can't lock DSIPLL. \n", __FUNCTION__);
+                       if (REG_FLAG_WAIT_SET(PSB_PIPECONF(pipe),
+                                             PIPECONF_DSIPLL_LOCK)) {
+                               DRM_ERROR("%s, can't lock DSIPLL.\n", __func__);
                                return -EINVAL;
                        }
                }