Merge "target: msm8996: Check for ENABLE_DISPLAY flag"
diff --git a/dev/gcdb/display/include/panel_auo_390p_cmd.h b/dev/gcdb/display/include/panel_auo_390p_cmd.h
new file mode 100644
index 0000000..705e562
--- /dev/null
+++ b/dev/gcdb/display/include/panel_auo_390p_cmd.h
@@ -0,0 +1,250 @@
+/* Copyright (c) 2017, 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 met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above 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 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PANEL_AUO_390P_CMD_H_
+
+#define _PANEL_AUO_390P_CMD_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+
+static struct panel_config auo_390p_cmd_panel_data = {
+	"qcom,mdss_dsi_auo_390p_cmd", "dsi:0:", "qcom,mdss-dsi-panel",
+	11, 1, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution auo_390p_cmd_panel_res = {
+	390, 390, 4, 4, 4, 0, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel Color Information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info auo_390p_cmd_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel Command information                                                 */
+/*---------------------------------------------------------------------------*/
+static char auo_390p_cmd_on_cmd0[] = {
+	0xfe, 0x01, 0x015, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd1[] = {
+	0x0a, 0xf0, 0x015, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd2[] = {
+	0xfe, 0x00, 0x15, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd3[] = {
+	0x35, 0x00, 0x15, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd4[] = {
+	0x05, 0x00, 0x29, 0xC0,
+	0x2a, 0x00, 0x04, 0x01,
+	0x89, 0xFF, 0xFF, 0xFF,
+};
+
+
+static char auo_390p_cmd_on_cmd5[] = {
+	0x05, 0x00, 0x29, 0xC0,
+	0x2b, 0x00, 0x00, 0x01,
+	0x85, 0xFF, 0xFF, 0xFF,
+};
+
+
+static char auo_390p_cmd_on_cmd6[] = {
+	0x05, 0x00, 0x29, 0xC0,
+	0x30, 0x00, 0x00, 0x01,
+	0x85, 0xFF, 0xFF, 0xFF,
+};
+
+
+static char auo_390p_cmd_on_cmd7[] = {
+	0x05, 0x00, 0x29, 0xC0,
+	0x31, 0x00, 0x04, 0x01,
+	0x89, 0xFF, 0xFF, 0xFF,
+};
+
+
+static char auo_390p_cmd_on_cmd8[] = {
+	0x12, 0x00, 0x05, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd9[] = {
+	0x53, 0x20, 0x015, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd10[] = {
+	0x36, 0xc0, 0x015, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd11[] = {
+	0x11, 0x00, 0x05, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd12[] = {
+	0x29, 0x00, 0x05, 0x80,
+};
+
+
+static char auo_390p_cmd_on_cmd13[] = {
+	0x06, 0x00, 0x39, 0xC0,
+	0xf0, 0x55, 0xaa, 0x52,
+	0x08, 0x01, 0xff, 0xff,
+};
+
+
+static char auo_390p_cmd_on_cmd14[] = {
+	0x07, 0x00, 0x39, 0xC0,
+	0xff, 0x00, 0x55, 0xaa,
+	0x52, 0x08, 0x01, 0xff,
+};
+
+
+static struct mipi_dsi_cmd auo_390p_cmd_on_command[] = {
+	{ 0x4 , auo_390p_cmd_on_cmd0, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd1, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd2, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd3, 0x00},
+	{ 0xc , auo_390p_cmd_on_cmd4, 0x00},
+	{ 0xc , auo_390p_cmd_on_cmd5, 0x78},
+	{ 0xc , auo_390p_cmd_on_cmd6, 0x00},
+	{ 0xc , auo_390p_cmd_on_cmd7, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd8, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd9, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd10, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd11, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd12, 0x00},
+	{ 0xc , auo_390p_cmd_on_cmd13, 0x00},
+	{ 0xc , auo_390p_cmd_on_cmd14, 0x00},
+};
+
+#define AUO_390P_CMD_ON_COMMAND 15
+
+
+static char auo_390p_cmd_off_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+
+static char auo_390p_cmd_off_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+
+static struct mipi_dsi_cmd auo_390p_cmd_off_command[] = {
+	{ 0x4 , auo_390p_cmd_off_cmd0, 0x0},
+	{ 0x4 , auo_390p_cmd_off_cmd1, 0x0}
+};
+
+#define AUO_390P_CMD_OFF_COMMAND 2
+
+
+static struct command_state auo_390p_cmd_state = {
+	0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+
+static struct commandpanel_info auo_390p_cmd_command_panel = {
+	0x1, 0x1, 0x1, 0, 0, 0, 0, 0, 0, 0x1, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+
+static struct videopanel_info auo_390p_cmd_video_panel = {
+	0, 0, 0, 0, 1, 1, 1, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane Configuration                                                        */
+/*---------------------------------------------------------------------------*/
+
+static struct lane_configuration auo_390p_cmd_lane_config = {
+	1, 0, 1, 0, 0, 0, 0
+};
+
+
+/*---------------------------------------------------------------------------*/
+/* Panel Timing                                                              */
+/*---------------------------------------------------------------------------*/
+const uint32_t auo_390p_cmd_timings[] = {
+	0x5F, 0x12, 0x0A, 0x00, 0x32, 0x34, 0x10, 0x16, 0x0F, 0x03, 0x04, 0x00
+};
+
+static struct panel_timing auo_390p_cmd_timing_info = {
+	0, 4, 0x05, 0x11
+};
+
+static const uint32_t auo_390p_14nm_cmd_timings[] = {
+	0x23, 0x1e, 0x7, 0x8, 0x5, 0x3, 0x4, 0xa0,
+	0x23, 0x1e, 0x7, 0x8, 0x5, 0x3, 0x4, 0xa0,
+	0x23, 0x1e, 0x7, 0x8, 0x5, 0x3, 0x4, 0xa0,
+	0x23, 0x1e, 0x7, 0x8, 0x5, 0x3, 0x4, 0xa0,
+	0x23, 0x18, 0x7, 0x8, 0x5, 0x3, 0x4, 0xa0,
+};
+
+static struct panel_reset_sequence auo_390p_cmd_panel_reset_seq = {
+	{ 1, 0, 1, }, { 200, 200, 200, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight Settings                                                        */
+/*---------------------------------------------------------------------------*/
+
+static struct backlight auo_390p_cmd_backlight = {
+	1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#define AUO_390P_CMD_SIGNATURE 0xFFFF
+
+#endif /*_AUO_390P_CMD_H_*/
diff --git a/dev/pmic/pm8x41/include/pm8x41.h b/dev/pmic/pm8x41/include/pm8x41.h
index 2c79ee4..2e0a270 100644
--- a/dev/pmic/pm8x41/include/pm8x41.h
+++ b/dev/pmic/pm8x41/include/pm8x41.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015, 2017, 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
@@ -64,6 +64,9 @@
 #define PON_PSHOLD_SHUTDOWN     0x4
 #define PON_PSHOLD_HARD_RESET   0x7
 
+#define PM_GPIO_NO_INVERT       0x00
+#define PM_GPIO_INVERT          0x01
+
 enum PM8X41_VERSIONS
 {
 	PM8X41_VERSION_V1 = 0,
diff --git a/dev/pmic/pm8x41/include/pm8x41_hw.h b/dev/pmic/pm8x41/include/pm8x41_hw.h
index 26fbd5e..6484a10 100644
--- a/dev/pmic/pm8x41/include/pm8x41_hw.h
+++ b/dev/pmic/pm8x41/include/pm8x41_hw.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015, 2017, 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
@@ -58,6 +58,7 @@
 #define GPIO_MODE_CTL                         0x40
 #define GPIO_DIG_VIN_CTL                      0x41
 #define GPIO_DIG_PULL_CTL                     0x42
+#define GPIO_DIG_OUT_SRC_CTL                  0x44
 #define GPIO_DIG_OUT_CTL                      0x45
 #define GPIO_EN_CTL                           0x46
 
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 4a4da3a..51a0f96 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015, 2017, 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
@@ -186,6 +186,10 @@
 		REG_WRITE(gpio_base + GPIO_DIG_OUT_CTL, val);
 	}
 
+	/* Output source sel and output invert */
+	val = config->inv_int_pol << 7;
+	REG_WRITE(gpio_base + GPIO_DIG_OUT_SRC_CTL, val);
+
 	/* Enable the GPIO */
 	val  = REG_READ(gpio_base + GPIO_EN_CTL);
 	val |= BIT(PERPH_EN_BIT);
diff --git a/platform/msm_shared/include/regulator.h b/platform/msm_shared/include/regulator.h
index 03fb10a..9759354 100644
--- a/platform/msm_shared/include/regulator.h
+++ b/platform/msm_shared/include/regulator.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2017, 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
@@ -67,10 +67,13 @@
 
 #define REG_LDO1	BIT(0)
 #define REG_LDO2	BIT(1)
+#define REG_LDO5	BIT(4)
 #define REG_LDO6	BIT(5)
+#define REG_LDO11	BIT(10)
 #define REG_LDO12	BIT(11)
 #define REG_LDO14	BIT(13)
 #define REG_LDO17	BIT(16)
+#define REG_LDO18	BIT(17)
 #define REG_LDO28	BIT(27)
 #define REG_SMPS3	BIT(7)
 #define REG_LDO3	BIT(2)
diff --git a/target/msm8909/oem_panel.c b/target/msm8909/oem_panel.c
index 4909008..e4da42e 100644
--- a/target/msm8909/oem_panel.c
+++ b/target/msm8909/oem_panel.c
@@ -48,6 +48,7 @@
 #include "include/panel_auo_qvga_cmd.h"
 #include "include/panel_auo_cx_qvga_cmd.h"
 #include "include/panel_auo_400p_cmd.h"
+#include "include/panel_auo_390p_cmd.h"
 
 #define DISPLAY_MAX_PANEL_DETECTION 0
 #define ILI9806E_FWVGA_VIDEO_PANEL_POST_INIT_DELAY 68
@@ -79,6 +80,7 @@
 	AUO_QVGA_CMD_PANEL,
 	AUO_CX_QVGA_CMD_PANEL,
 	AUO_400P_CMD_PANEL,
+	AUO_390P_CMD_PANEL,
 	UNKNOWN_PANEL
 };
 
@@ -98,6 +100,7 @@
 	{"auo_qvga_cmd", AUO_QVGA_CMD_PANEL},
 	{"auo_cx_qvga_cmd", AUO_CX_QVGA_CMD_PANEL},
 	{"auo_400p_cmd", AUO_400P_CMD_PANEL},
+	{"auo_390p_cmd", AUO_390P_CMD_PANEL},
 };
 
 static uint32_t panel_id;
@@ -405,6 +408,30 @@
 					= auo_400P_CMD_OFF_COMMAND;
 		memcpy(phy_db->timing, auo_400p_cmd_timings, TIMING_SIZE);
 		break;
+	case AUO_390P_CMD_PANEL:
+		panelstruct->paneldata    = &auo_390p_cmd_panel_data;
+		panelstruct->panelres     = &auo_390p_cmd_panel_res;
+		panelstruct->color        = &auo_390p_cmd_color;
+		panelstruct->videopanel   = &auo_390p_cmd_video_panel;
+		panelstruct->commandpanel = &auo_390p_cmd_command_panel;
+		panelstruct->state        = &auo_390p_cmd_state;
+		panelstruct->laneconfig   = &auo_390p_cmd_lane_config;
+		panelstruct->paneltiminginfo
+					= &auo_390p_cmd_timing_info;
+		panelstruct->panelresetseq
+					= &auo_390p_cmd_panel_reset_seq;
+		panelstruct->backlightinfo
+					= &auo_390p_cmd_backlight;
+		pinfo->mipi.panel_on_cmds
+					= auo_390p_cmd_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+					= AUO_390P_CMD_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+					= auo_390p_cmd_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+					= AUO_390P_CMD_OFF_COMMAND;
+		memcpy(phy_db->timing, auo_390p_cmd_timings, TIMING_SIZE);
+		break;
 	case UNKNOWN_PANEL:
 	default:
 		memset(panelstruct, 0, sizeof(struct panel_struct));
@@ -457,7 +484,7 @@
 	case HW_PLATFORM_RCM:
 		switch (platform_subtype) {
 		case BG_WTP:
-			panel_id = AUO_CX_QVGA_CMD_PANEL;
+			panel_id = AUO_390P_CMD_PANEL;
 			break;
 		default:
 			panel_id = HX8394D_720P_VIDEO_PANEL;
diff --git a/target/msm8909/regulator.c b/target/msm8909/regulator.c
index bbe83b4..be9b532 100644
--- a/target/msm8909/regulator.c
+++ b/target/msm8909/regulator.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2015, 2017, 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
@@ -49,6 +49,24 @@
 	},
 };
 
+static uint32_t ldo5[][11]=
+{
+	{
+		LDOA_RES_TYPE, 5,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 5,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 1200000,
+		KEY_CURRENT, 4, 86,
+	},
+};
+
+
 static uint32_t ldo6[][11]=
 {
 	{
@@ -67,6 +85,42 @@
 };
 
 
+static uint32_t ldo11[][11]=
+{
+	{
+		LDOA_RES_TYPE, 11,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 11,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 1800000,
+		KEY_CURRENT, 4, 150,
+	},
+};
+
+
+static uint32_t ldo12[][11]=
+{
+	{
+		LDOA_RES_TYPE, 12,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 12,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 1800000,
+		KEY_CURRENT, 4, 150,
+	},
+};
+
+
 static uint32_t ldo17[][11]=
 {
 	{
@@ -84,6 +138,24 @@
 	},
 };
 
+static uint32_t ldo18[][11]=
+{
+	{
+		LDOA_RES_TYPE, 18,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_MICRO_VOLT, 4, 0,
+		KEY_CURRENT, 4, 0,
+	},
+
+	{
+		LDOA_RES_TYPE, 18,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_MICRO_VOLT, 4, 3000000,
+		KEY_CURRENT, 4, 5,
+	},
+};
+
+
 void regulator_enable(uint32_t enable)
 {
 	if (enable & REG_LDO2)
@@ -95,6 +167,17 @@
 	if (enable & REG_LDO6)
 		rpm_send_data(&ldo6[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
 
+	if (enable & REG_LDO5)
+		rpm_send_data(&ldo5[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	if (enable & REG_LDO11)
+		rpm_send_data(&ldo11[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	if (enable & REG_LDO12)
+		rpm_send_data(&ldo12[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	if (enable & REG_LDO18)
+		rpm_send_data(&ldo18[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
 
 
 }
diff --git a/target/msm8909/target_display.c b/target/msm8909/target_display.c
index 63f546f..9c4cd48 100755
--- a/target/msm8909/target_display.c
+++ b/target/msm8909/target_display.c
@@ -54,6 +54,13 @@
 #define PWM_PERIOD_US 27
 #define PM8916_VER 0x20000
 
+/*---------------------------------------------------------------------------*/
+/* GPIO configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct gpio_pin bob_gpio = {
+  "pm8941_gpios", 12, 2, 1, 0, 1
+};
+
 static void mdss_dsi_uniphy_pll_sw_reset_8909(uint32_t pll_base)
 {
 	writel(0x01, pll_base + 0x0068); /* PLL TEST CFG */
@@ -187,38 +194,44 @@
 
 int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
 {
-	struct pm8x41_mpp mpp;
 	uint32_t hw_id = board_hardware_id();
-	struct board_pmic_data pmic_info;
-	int rc;
+	uint32_t platform = board_platform_id();
+	uint32_t platform_subtype = board_hardware_subtype();
 
 	if (bl->bl_interface_type == BL_DCS)
 		return 0;
 
-	board_pmic_info(&pmic_info, 1);
-	if (pmic_info.pmic_version == PM8916_VER)
-		mpp.base = PM8x41_MMP4_BASE;
-	else
-		mpp.base = PM8x41_MMP2_BASE;
+	if (!((HW_PLATFORM_SUBTYPE_8909_PM660 == platform_subtype) &&
+		(MSM8909W == platform) &&
+		(HW_PLATFORM_MTP == hw_id))) {
+		struct pm8x41_mpp mpp;
+		struct board_pmic_data pmic_info;
+		int rc;
 
-	mpp.vin = MPP_VIN0;
-	if (enable) {
-		pm_pwm_enable(false);
-		rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
-		if (rc < 0)
-			mpp.mode = MPP_HIGH;
-		else {
-			mpp.mode = MPP_DTEST1;
-			pm_pwm_enable(true);
+		board_pmic_info(&pmic_info, 1);
+		if (pmic_info.pmic_version == PM8916_VER)
+			mpp.base = PM8x41_MMP4_BASE;
+		else
+			mpp.base = PM8x41_MMP2_BASE;
+
+		mpp.vin = MPP_VIN0;
+		if (enable) {
+			pm_pwm_enable(false);
+			rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
+			if (rc < 0)
+				mpp.mode = MPP_HIGH;
+			else {
+				mpp.mode = MPP_DTEST1;
+				pm_pwm_enable(true);
+			}
+			pm8x41_config_output_mpp(&mpp);
+			pm8x41_enable_mpp(&mpp, MPP_ENABLE);
+		} else {
+			pm_pwm_enable(false);
+			pm8x41_enable_mpp(&mpp, MPP_DISABLE);
 		}
-		pm8x41_config_output_mpp(&mpp);
-		pm8x41_enable_mpp(&mpp, MPP_ENABLE);
-	} else {
-		pm_pwm_enable(false);
-		pm8x41_enable_mpp(&mpp, MPP_DISABLE);
+		mdelay(20);
 	}
-	mdelay(20);
-
 	if (enable) {
 		gpio_tlmm_config(bkl_gpio.pin_id, 0,
 			bkl_gpio.pin_direction, bkl_gpio.pin_pull,
@@ -280,8 +293,25 @@
 						struct msm_panel_info *pinfo)
 {
 	int ret = NO_ERROR;
+	uint32_t bob_pmic_gpio = bob_gpio.pin_id;
 	uint32_t hw_id = board_hardware_id();
 	uint32_t hw_subtype = board_hardware_subtype();
+	uint32_t platform = board_platform_id();
+
+	if ((HW_PLATFORM_SUBTYPE_8909_PM660 == hw_subtype) &&
+		(MSM8909W == platform) &&
+		(HW_PLATFORM_MTP == hw_id)) {
+		struct pm8x41_gpio bobgpio_param = {
+			.direction = PM_GPIO_DIR_OUT,
+			.vin_sel = 0,
+			.out_strength = PM_GPIO_OUT_DRIVE_MED,
+			.function = PM_GPIO_FUNC_HIGH,
+			.pull = PM_GPIO_PULLDOWN_10,
+			.inv_int_pol = PM_GPIO_INVERT,
+		};
+
+		pm8x41_gpio_config(bob_pmic_gpio, &bobgpio_param);
+	}
 
 	if (enable) {
 		if (pinfo->mipi.use_enable_gpio) {
@@ -318,8 +348,18 @@
 
 int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
 {
-	if (enable)
-		regulator_enable(REG_LDO2 | REG_LDO6 | REG_LDO17);
+	uint32_t hw_id = board_hardware_id();
+	uint32_t hw_subtype = board_hardware_subtype();
+	uint32_t platform = board_platform_id();
+
+	if (enable) {
+		if ((HW_PLATFORM_SUBTYPE_8909_PM660 == hw_subtype) &&
+			(MSM8909W == platform) &&
+			(HW_PLATFORM_MTP == hw_id))
+			regulator_enable(REG_LDO12 | REG_LDO5 | REG_LDO11 | REG_LDO18);
+		else
+			regulator_enable(REG_LDO2 | REG_LDO6 | REG_LDO17);
+	}
 
 	return NO_ERROR;
 }