diff mbox

[v2,3/5] Input: pm8xxx-vib: handle separate enable register

Message ID 20170404154153.19901-3-damien.riegel@savoirfairelinux.com (mailing list archive)
State Accepted
Headers show

Commit Message

Damien Riegel April 4, 2017, 3:41 p.m. UTC
Some PMIC vibrator IPs use a separate enable register to turn the
vibrator on and off. To detect if a vibrator uses this feature, rely on
the enable_mask being non-zero.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
Changes in v2:
 - Removed reading register base address from device tree as it can
   already be infered from the compatible string.

 drivers/input/misc/pm8xxx-vibrator.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
index b9b73957a48f..50b874e6f678 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -14,6 +14,7 @@ 
 #include <linux/input.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
@@ -26,6 +27,9 @@ 
 #define MAX_FF_SPEED		0xff
 
 struct pm8xxx_regs {
+	unsigned int enable_addr;
+	unsigned int enable_mask;
+
 	unsigned int drv_addr;
 	unsigned int drv_mask;
 	unsigned int drv_shift;
@@ -82,7 +86,14 @@  static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
 		return rc;
 
 	vib->reg_vib_drv = val;
-	return 0;
+
+	if (regs->enable_mask) {
+		unsigned int val = on ? regs->enable_mask : 0;
+		rc = regmap_update_bits(vib->regmap, regs->enable_addr,
+					regs->enable_mask, val);
+	}
+
+	return rc;
 }
 
 /**