All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Riegel <damien.riegel@savoirfairelinux.com>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	kernel@savoirfairelinux.com,
	Damien Riegel <damien.riegel@savoirfairelinux.com>
Subject: [PATCH v2 3/5] Input: pm8xxx-vib: handle separate enable register
Date: Tue,  4 Apr 2017 11:41:51 -0400	[thread overview]
Message-ID: <20170404154153.19901-3-damien.riegel@savoirfairelinux.com> (raw)
In-Reply-To: <20170404154153.19901-1-damien.riegel@savoirfairelinux.com>

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 --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;
 }
 
 /**
-- 
2.12.1


  parent reply	other threads:[~2017-04-04 15:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 15:41 [PATCH v2 1/5] Input: pm8xxx-vib: reorder header alphabetically Damien Riegel
2017-04-04 15:41 ` [PATCH v2 2/5] Input: pm8xxx-vib: parametrize the driver Damien Riegel
2017-04-04 15:41 ` Damien Riegel [this message]
2017-04-04 15:41 ` [PATCH v2 4/5] dt-bindings: input: add pm8916-vib bindings Damien Riegel
2017-04-04 15:41 ` [PATCH v2 5/5] Input: pm8xxx-vib: add support for pm8916's vibrator Damien Riegel
2017-04-04 23:31 ` [PATCH v2 1/5] Input: pm8xxx-vib: reorder header alphabetically Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170404154153.19901-3-damien.riegel@savoirfairelinux.com \
    --to=damien.riegel@savoirfairelinux.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-input@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.