Merge "msm8660: Turn off LDO2 and Set backlight to Zero"
diff --git a/platform/msm8x60/include/platform/pmic.h b/platform/msm8x60/include/platform/pmic.h
index 51e6055..8ae6f54 100644
--- a/platform/msm8x60/include/platform/pmic.h
+++ b/platform/msm8x60/include/platform/pmic.h
@@ -1,5 +1,5 @@
 /*
- * * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -10,7 +10,7 @@
  *    copyright notice, this list of conditions and the following
  *    disclaimer in the documentation and/or other materials provided
  *    with the distribution.
- *  * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *  * Neither the name of The Linux Foundation nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
@@ -48,7 +48,21 @@
 #define PM8901_LDO_L6_TEST_BANK     (PM8901_LDO_BASE + 0x0D)
 #define PM8901_LDO_L7           (PM8901_LDO_BASE + 0x0E)
 #define PM8901_LDO_L7_TEST_BANK     (PM8901_LDO_BASE + 0x0F)
-#define PM8901_PMR_7            (0xAD)
+
+enum {
+	LDO_START,
+	LDO_L0 = LDO_START,
+	LDO_L1,
+	LDO_L2,
+	LDO_L3,
+	LDO_L4,
+	LDO_L5,
+	LDO_L6,
+	LDO_END = LDO_L6,
+};
+
+#define PM8901_PMR_REG_BASE 0xAB
+#define PM8901_PMR_REG(ldo_id)               (PM8901_PMR_REG_BASE + ldo_id)
 
 #define PM8901_LDO_TEST_BANK(n) ((n)<<4)
 
diff --git a/platform/msm8x60/panel.c b/platform/msm8x60/panel.c
index 73b4b3d..9dad93d 100644
--- a/platform/msm8x60/panel.c
+++ b/platform/msm8x60/panel.c
@@ -1,5 +1,5 @@
 /*
- * * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -10,7 +10,7 @@
  *    copyright notice, this list of conditions and the following
  *    disclaimer in the documentation and/or other materials provided
  *    with the distribution.
- *  * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *  * Neither the name of The Linux Foundation nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
@@ -173,10 +173,10 @@
 	/* Enable PMR for LDO L2 */
 	buffer = 0x7F;
 	mask = 0x7F;
-	if ((ret = pm8901_read(&prev_val, 1, PM8901_PMR_7))) {
+	if ((ret = pm8901_read(&prev_val, 1, PM8901_PMR_REG(LDO_L2)))) {
 		return ret;
 	}
-	ret = pm8901_vreg_write(&buffer, mask, PM8901_PMR_7, prev_val);
+	ret = pm8901_vreg_write(&buffer, mask, PM8901_PMR_REG(LDO_L2), prev_val);
 	return ret;
 }
 
@@ -242,7 +242,7 @@
 	int rc = -1;
 	uint32_t duty_us, period_us;
 
-	if ((bt_level <= 0) || (bt_level > 15)) {
+	if ((bt_level < 0) || (bt_level > 15)) {
 		dprintf(CRITICAL, "Error in brightness level (1-15 allowed)\n");
 		goto bail_out;
 	}
diff --git a/platform/msm8x60/platform.c b/platform/msm8x60/platform.c
index 12e455d..16086a9 100755
--- a/platform/msm8x60/platform.c
+++ b/platform/msm8x60/platform.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +39,7 @@
 #include <platform/iomap.h>
 #include <platform/clock.h>
 #include <platform/machtype.h>
+#include <platform/pmic.h>
 #include <qgic.h>
 #include <i2c_qup.h>
 #include <gsbi.h>
@@ -158,8 +159,13 @@
 void display_shutdown(void)
 {
 #if DISPLAY_TYPE_LCDC
+	unsigned rc = 0;
 	/* Turning off LCDC */
+	rc = panel_set_backlight(0);
+	if (rc)
+		dprintf(CRITICAL, "Error in setting panel backlight\n");
 	lcdc_shutdown();
+	pm8901_ldo_disable(LDO_L2);
 #endif
 #if DISPLAY_TYPE_MIPI
 	mipi_dsi_shutdown();
diff --git a/platform/msm8x60/pmic.c b/platform/msm8x60/pmic.c
index 6e5c83f..dc6db38 100644
--- a/platform/msm8x60/pmic.c
+++ b/platform/msm8x60/pmic.c
@@ -1,5 +1,5 @@
 /*
- * * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ * * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -10,7 +10,7 @@
  *    copyright notice, this list of conditions and the following
  *    disclaimer in the documentation and/or other materials provided
  *    with the distribution.
- *  * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ *  * Neither the name of The Linux Foundation nor the names of its
  *    contributors may be used to endorse or promote products derived
  *    from this software without specific prior written permission.
  *
@@ -290,6 +290,24 @@
 	return rc;
 }
 
+int pm8901_ldo_disable(int ldo_id)
+{
+	int rc = -1;
+	uint8_t prev_val = 0x0, val = 0x3F, mask = 0x7F;
+
+	if(ldo_id >= LDO_START && ldo_id <= LDO_END) {
+		rc = pm8901_read(&prev_val, 1, PM8901_PMR_REG(ldo_id));
+		if (rc)
+			goto get_out;
+
+		rc = pm8901_vreg_write(&val, mask, PM8901_PMR_REG(ldo_id), prev_val);
+		if (rc)
+			goto get_out;
+	}
+get_out:
+	return rc;
+}
+
 int pm8058_reset_pwr_off(int reset)
 {
 	int rc;