dev: pmic: Move the old-gen vibrator to the common pm8x41 file

QM215 uses the msm8952 platform configuration. The PMIC supported
on QM215 is PM8916 which uses the old-gen vibrator. To support
both the vibrators (PM8916 and PMI8950/37) add logic which
detects the PMIC type and calls into the right vibrator function.

Change-Id: I75999c0d7e16e831947e537fc54d538be376fd99
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 4e0b85a..6575f95 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -36,6 +36,9 @@
 #include <rpm-ipc.h>
 #include <regulator.h>
 #include <platform/timer.h>
+#include <pm_vib.h>
+
+#define QPNP_VIB_EN    BIT(7)
 
 /* Enable LN BB CLK */
 static uint32_t ln_bb_clk[][8] = {
@@ -841,3 +844,27 @@
 
 	return batt_is_broken;
 }
+
+void pm8x41_vib_turn_on(void)
+{
+	uint8_t val;
+
+	val = pm8x41_reg_read(QPNP_VIB_VTG_CTL);
+	val &= ~QPNP_VIB_VTG_SET_MASK;
+	val |= (QPNP_VIB_DEFAULT_VTG_LVL & QPNP_VIB_VTG_SET_MASK);
+	pm8x41_reg_write(QPNP_VIB_VTG_CTL, val);
+
+	val = pm8x41_reg_read(QPNP_VIB_EN_CTL);
+	val |= QPNP_VIB_EN;
+	pm8x41_reg_write(QPNP_VIB_EN_CTL, val);
+}
+
+/* Turn off vibrator */
+void pm8x41_vib_turn_off(void)
+{
+	uint8_t val;
+
+	val = pm8x41_reg_read(QPNP_VIB_EN_CTL);
+	val &= ~QPNP_VIB_EN;
+	pm8x41_reg_write(QPNP_VIB_EN_CTL, val);
+}