From patchwork Tue Apr 4 15:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Riegel X-Patchwork-Id: 9661915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E896D602B9 for ; Tue, 4 Apr 2017 15:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8F0E27C0B for ; Tue, 4 Apr 2017 15:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDFF927F60; Tue, 4 Apr 2017 15:42:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE87027C0B for ; Tue, 4 Apr 2017 15:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754349AbdDDPmx (ORCPT ); Tue, 4 Apr 2017 11:42:53 -0400 Received: from mail.savoirfairelinux.com ([208.88.110.44]:55442 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752202AbdDDPmw (ORCPT ); Tue, 4 Apr 2017 11:42:52 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 76A889C1FF1; Tue, 4 Apr 2017 11:42:51 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id k2n1U-G9WPlx; Tue, 4 Apr 2017 11:42:51 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 065819C1FD4; Tue, 4 Apr 2017 11:42:51 -0400 (EDT) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id eqyGqt7iFXts; Tue, 4 Apr 2017 11:42:50 -0400 (EDT) Received: from workotop.humanware.local (unknown [192.252.129.34]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id CBB679C1FED; Tue, 4 Apr 2017 11:42:50 -0400 (EDT) From: Damien Riegel To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Rob Herring , Mark Rutland , kernel@savoirfairelinux.com, Damien Riegel Subject: [PATCH v2 3/5] Input: pm8xxx-vib: handle separate enable register Date: Tue, 4 Apr 2017 11:41:51 -0400 Message-Id: <20170404154153.19901-3-damien.riegel@savoirfairelinux.com> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170404154153.19901-1-damien.riegel@savoirfairelinux.com> References: <20170404154153.19901-1-damien.riegel@savoirfairelinux.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include +#include #include #include #include @@ -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; } /**