Merge "target: msm8994: Enable PWM and QPNP WLED driver compilation."
diff --git a/app/aboot/recovery.c b/app/aboot/recovery.c
index 2d70cef..3c42902 100644
--- a/app/aboot/recovery.c
+++ b/app/aboot/recovery.c
@@ -454,7 +454,7 @@
 			sizeof(msg->command), msg->command);
 	}
 
-	if (!strncmp(msg->command, "boot-recovery", strlen("boot-recovery"))) {
+	if (!strcmp(msg->command, "boot-recovery")) {
 		boot_into_recovery = 1;
 	}
 
diff --git a/dev/pmic/pm8x41/include/pm8x41.h b/dev/pmic/pm8x41/include/pm8x41.h
index 5f87bcb..472e69f 100644
--- a/dev/pmic/pm8x41/include/pm8x41.h
+++ b/dev/pmic/pm8x41/include/pm8x41.h
@@ -79,6 +79,10 @@
 #define CBLPWR_N                64
 #define KPDPWR_N                128
 
+/*Target power off reasons*/
+#define KPDPWR_AND_RESIN        32
+#define STAGE3                  128
+
 struct pm8x41_gpio {
 	int direction;
 	int output_buffer;
@@ -203,6 +207,8 @@
 int pm8x41_ldo_control(struct pm8x41_ldo *ldo, uint8_t enable);
 uint8_t pm8x41_get_pmic_rev();
 uint8_t pm8x41_get_pon_reason();
+uint8_t pm8x41_get_pon_poff_reason1();
+uint8_t pm8x41_get_pon_poff_reason2();
 uint32_t pm8x41_get_pwrkey_is_pressed();
 void pm8x41_config_output_mpp(struct pm8x41_mpp *mpp);
 void pm8x41_enable_mpp(struct pm8x41_mpp *mpp, enum mpp_en_ctl enable);
diff --git a/dev/pmic/pm8x41/include/pm8x41_hw.h b/dev/pmic/pm8x41/include/pm8x41_hw.h
index 4a0d803..9d05219 100644
--- a/dev/pmic/pm8x41/include/pm8x41_hw.h
+++ b/dev/pmic/pm8x41/include/pm8x41_hw.h
@@ -65,6 +65,8 @@
 #define PON_PON_REASON1                       0x808
 #define PON_WARMBOOT_STATUS1                  0x80A
 #define PON_WARMBOOT_STATUS2                  0x80B
+#define PON_POFF_REASON1                      0x80C
+#define PON_POFF_REASON2                      0x80D
 #define PON_INT_RT_STS                        0x810
 #define PON_INT_SET_TYPE                      0x811
 #define PON_INT_POLARITY_HIGH                 0x812
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 09649c6..3b9783d 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -387,6 +387,16 @@
 	return REG_READ(PON_PON_REASON1);
 }
 
+uint8_t pm8x41_get_pon_poff_reason1()
+{
+	return REG_READ(PON_POFF_REASON1);
+}
+
+uint8_t pm8x41_get_pon_poff_reason2()
+{
+	return REG_READ(PON_POFF_REASON2);
+}
+
 void pm8x41_enable_mpp(struct pm8x41_mpp *mpp, enum mpp_en_ctl enable)
 {
 	ASSERT(mpp);
diff --git a/platform/msm8994/acpuclock.c b/platform/msm8994/acpuclock.c
index c80d76d..72f4962 100644
--- a/platform/msm8994/acpuclock.c
+++ b/platform/msm8994/acpuclock.c
@@ -93,6 +93,12 @@
 		ASSERT(0);
 	}
 
+	ret = clk_get_set_enable("usb_phy_cfg_ahb2phy_clk", 0, 1);
+	if(ret)
+	{
+		dprintf(CRITICAL, "failed to enable usb_phy_cfg_ahb2phy_clk = %d\n", ret);
+		ASSERT(0);
+	}
 }
 
 void clock_init_mmc(uint32_t interface)
diff --git a/target/msm8994/init.c b/target/msm8994/init.c
index 359f9dc..cfd665f 100644
--- a/target/msm8994/init.c
+++ b/target/msm8994/init.c
@@ -164,9 +164,6 @@
 		qusb2_phy_reset();
 	}
 
-	/* Select and enable external configuration with USB PHY */
-	ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET);
-
 	/* Enable sess_vld */
 	val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN;
 	writel(val, USB_GENCONFIG_2);
@@ -179,8 +176,6 @@
 
 void target_usb_stop(void)
 {
-	/* Disable VBUS mimicing in the controller. */
-	ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR);
 }
 
 static void set_sdc_power_ctrl()
@@ -396,6 +391,8 @@
 /* identify the usb controller to be used for the target */
 const char * target_usb_controller()
 {
+    if(board_hardware_id() == HW_PLATFORM_DRAGON)
+	    return "ci";
 	return "dwc";
 }