msm_fb: Change the sequence of backlight control for Gordon panel

During Resume, backlight control settings are getting set before the
Gordon panel has been initialized. This change corrects the sequence
and ensures that display is proper after resume operation

Change-Id: I22a6c857da3cb011404198b94e4347f76292a77e
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
diff --git a/drivers/video/msm/lcdc_gordon.c b/drivers/video/msm/lcdc_gordon.c
index f9532b4..8327c6c 100644
--- a/drivers/video/msm/lcdc_gordon.c
+++ b/drivers/video/msm/lcdc_gordon.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2009-2010, 2012 Code Aurora Forum. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -84,6 +84,7 @@
 static int spi_sdo;
 static int spi_sdi;
 static int spi_dac;
+static int bl_level;
 static unsigned char bit_shift[8] = { (1 << 7),	/* MSB */
 	(1 << 6),
 	(1 << 5),
@@ -313,6 +314,17 @@
 		spi_init();	/* LCD needs SPI */
 		gordon_disp_powerup();
 		gordon_disp_on();
+		if (bl_level <= 1) {
+			/* keep back light OFF */
+			serigo(GORDON_REG_LCDIFCTL2, 0x0B);
+			udelay(15);
+			serigo(GORDON_REG_VALTRAN, 0x01);
+		} else {
+			/* keep back light ON */
+			serigo(GORDON_REG_LCDIFCTL2, 0x7B);
+			udelay(15);
+			serigo(GORDON_REG_VALTRAN, 0x01);
+		}
 		gordon_state.disp_initialized = TRUE;
 	}
 	return 0;
@@ -351,18 +363,20 @@
 
 static void lcdc_gordon_set_backlight(struct msm_fb_data_type *mfd)
 {
-		int bl_level = mfd->bl_level;
+		bl_level = mfd->bl_level;
 
-		if (bl_level <= 1) {
-			/* keep back light OFF */
-			serigo(GORDON_REG_LCDIFCTL2, 0x0B);
-			udelay(15);
-			serigo(GORDON_REG_VALTRAN, 0x01);
-		} else {
-			/* keep back light ON */
-			serigo(GORDON_REG_LCDIFCTL2, 0x7B);
-			udelay(15);
-			serigo(GORDON_REG_VALTRAN, 0x01);
+		if (gordon_state.disp_initialized) {
+			if (bl_level <= 1) {
+				/* keep back light OFF */
+				serigo(GORDON_REG_LCDIFCTL2, 0x0B);
+				udelay(15);
+				serigo(GORDON_REG_VALTRAN, 0x01);
+			} else {
+				/* keep back light ON */
+				serigo(GORDON_REG_LCDIFCTL2, 0x7B);
+				udelay(15);
+				serigo(GORDON_REG_VALTRAN, 0x01);
+			}
 		}
 }