Merge "target: msm8976: Add lra motor support"
diff --git a/dev/qpnp_haptic/qpnp_haptic.c b/dev/qpnp_haptic/qpnp_haptic.c
index 1bdadee..e1200a1 100644
--- a/dev/qpnp_haptic/qpnp_haptic.c
+++ b/dev/qpnp_haptic/qpnp_haptic.c
@@ -29,6 +29,8 @@
 #include <spmi.h>
 #include <platform/iomap.h>
 #include <pm_vib.h>
+#include <target.h>
+#include <vibrator.h>
 
 #define HAPTIC_BASE (PMI_ADDR_BASE+ 0xC000)
 #define QPNP_HAP_EN_CTL_REG (HAPTIC_BASE + 0x46)
@@ -71,6 +73,7 @@
 #define QPNP_HAP_BRAKE_VMAX_MASK 0xFF
 #define QPNP_HAP_BRAKE_VMAX 0xF
 #define QPNP_HAP_ERM 0x1
+#define QPNP_HAP_LRA 0x0
 #define QPNP_HAP_PLAY_MASK 0x80
 #define QPNP_HAP_PLAY_EN 0x80
 #define QPNP_HAP_MASK 0x80
@@ -84,17 +87,23 @@
 /* Turn on vibrator */
 void pm_vib_turn_on(void)
 {
+	uint32_t vib_type = VIB_ERM_TYPE;
+	vib_type = get_vibration_type();
 	/* Configure the ACTUATOR TYPE register as ERM*/
 	pmic_spmi_reg_mask_write(QPNP_HAP_ACT_TYPE_REG,
-					QPNP_HAP_ACT_TYPE_MASK, QPNP_HAP_ERM);
+					QPNP_HAP_ACT_TYPE_MASK,
+					VIB_ERM_TYPE == vib_type ? QPNP_HAP_ERM
+					: QPNP_HAP_LRA);
 
 	/* Disable auto resonance for ERM */
 	pmic_spmi_reg_mask_write(QPNP_HAP_LRA_AUTO_RES_REG,
-					QPNP_HAP_LRA_AUTO_MASK, QPNP_HAP_LRA_AUTO_DISABLE);
+					QPNP_HAP_LRA_AUTO_MASK,
+					QPNP_HAP_LRA_AUTO_DISABLE);
 
 	/* Configure the PLAY MODE register as direct*/
 	pmic_spmi_reg_mask_write(QPNP_HAP_PLAY_MODE_REG,
-					QPNP_HAP_PLAY_MODE_MASK, QPNP_HAP_DIRECT);
+					QPNP_HAP_PLAY_MODE_MASK,
+					QPNP_HAP_DIRECT);
 
 	/* Configure the VMAX register */
 	pmic_spmi_reg_mask_write(QPNP_HAP_VMAX_REG,
diff --git a/dev/vib/include/vibrator.h b/dev/vib/include/vibrator.h
index d6fb8bf..2ec1346 100644
--- a/dev/vib/include/vibrator.h
+++ b/dev/vib/include/vibrator.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2015, 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
@@ -29,6 +29,8 @@
 #define __DEV_VIB_VIBRATOR_H
 
 #define VIB_TIMER_DEFAULT_TIMEOUT   250
+#define VIB_LRA_TYPE 0x00
+#define VIB_ERM_TYPE 0x01
 
 void vib_turn_on(void);
 void vib_turn_off(void);
diff --git a/include/target.h b/include/target.h
index b7f92a2..f2e2acd 100644
--- a/include/target.h
+++ b/include/target.h
@@ -87,4 +87,9 @@
 int target_cont_splash_screen(void);
 bool target_build_variant_user();
 void pmic_reset_configure(uint8_t reset_type);
+
+#if PON_VIB_SUPPORT
+uint32_t get_vibration_type();
+#endif
+
 #endif
diff --git a/target/init.c b/target/init.c
index fba226c..c3893d3 100644
--- a/target/init.c
+++ b/target/init.c
@@ -28,6 +28,11 @@
 #include <compiler.h>
 #include <dload_util.h>
 #include <sdhci_msm.h>
+#if PON_VIB_SUPPORT
+#include <smem.h>
+#include <vibrator.h>
+#include <board.h>
+#endif
 
 #define EXPAND(NAME) #NAME
 #define TARGET(NAME) EXPAND(NAME)
@@ -221,6 +226,31 @@
 	return DDR_CONFIG_VAL;
 }
 
+#if PON_VIB_SUPPORT
+uint32_t get_vibration_type()
+{
+	uint32_t ret = VIB_ERM_TYPE;
+	uint32_t hw_id = board_hardware_id();
+	uint32_t platform = board_platform_id();
+	switch(hw_id){
+	case HW_PLATFORM_MTP:
+		switch(platform){
+		case MSM8952:
+			ret = VIB_ERM_TYPE;
+			break;
+		case MSM8976:
+			ret = VIB_LRA_TYPE;
+			break;
+		}
+		break;
+	case HW_PLATFORM_QRD:
+		ret = VIB_ERM_TYPE;
+		break;
+	}
+	return ret;
+}
+#endif
+
 /* Return Build variant */
 __WEAK bool target_build_variant_user()
 {