Message ID | 20230427-hammerhead-vibra-v1-3-e87eeb94da51@z3ntu.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp521048vqo; Thu, 27 Apr 2023 13:46:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Cb1DWhGiSV6PEkUlUK41d2sFYrR181KbcpzCeXo+nsFQs9FT02Z0g6I1Xg892qCY9ZsIm X-Received: by 2002:a05:6a20:1595:b0:f4:d4a8:9c84 with SMTP id h21-20020a056a20159500b000f4d4a89c84mr3585232pzj.32.1682628394455; Thu, 27 Apr 2023 13:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682628394; cv=none; d=google.com; s=arc-20160816; b=OLAGRY5btd/L9p9KO83vJjDHikDeMIH71wFOxw2QuHoXZ32j5JxncQwU9JLZnAc1L4 NFrUEjTHhJVDDIo7O2ZyY3S63+JP94EjdvjoTgi1kom2q/kTMcu8F85jWDqy/an1wZm4 OYLwRzmg7JU9bSiq8FqLA/bV3pbRPqCg/iM5bGVCQrKSjAhuZDkVT8u+D7kFTVM5PM91 fl3gbWbixj6rq3JvkavTWoccFKQ19fs8LjBIzh/YcMi8esAFV0iCyRHT6G6UAWU0azwt WiIzCAee+pCvM+5DCn05vA4vulMQuWtm/ENV7xTJ7cMJMeEBCdEwoNZY8KjZ+B5ghU/U B1mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=6z4YyNcpUAxHnVoJjnf7yfDtSGDtavHUH03eFYoJB4Y=; b=AvC8/CxHxBx81YIfZ0gy5cqLkh1Or7wq05OYdcKAwYRN2S0S4XgNJGJH5dnIHe2HpF 643RRsreY+xh8XOSSzz0rZfZUzKTe0vXGIhuJbWVoXvB3s9RJ3fi41GXSi6uo5os+T5d DGZxYEnA3VXumRoC8dmizs82wYrIv5AmTr/9cehb8yGPyqRzqITWm/F9D+ChhaB/l4pM 3emHh5pagai94E1lGxpK5tQAA/8A5bfFzFfWsC8Vq4gZ9ad4HLsBMYPz4DfUfIWNqMW9 v1jgMbB/kcBiP5uyNOADs6RamuzHDf71x+oAaWPgN3q2/yj8I8IXLyxOwIHxA8yDaDu4 cDdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b=BM38CsTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w62-20020a638241000000b0050300a5cf3csi21340286pgd.469.2023.04.27.13.46.20; Thu, 27 Apr 2023 13:46:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b=BM38CsTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344306AbjD0Ufs (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 27 Apr 2023 16:35:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344222AbjD0Ufp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Apr 2023 16:35:45 -0400 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B2ED4EE2; Thu, 27 Apr 2023 13:35:24 -0700 (PDT) Received: from [192.168.178.23] (unknown [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 89EF7CEB9B; Thu, 27 Apr 2023 20:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1682627692; bh=6GdnfYGYIClKnqTCFJOePAiIDqCEBDJIJs44RnWeNMI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=BM38CsTAC+YX33G+87YR05wbDvYb23JPCjo0lqbtV17DCJDM8X8RZLaIMtxKcs9Rw WRz3Ta2BpFF5xlIpY/fivSlPJsRFxPyvvRMlIaqeZ5Mh0XCI7iApbWZ7JZlvbpicsy /nYoorwoxCBHxFAVGCQVCsuFY/Tz8r3PtF6uX3q4= From: Luca Weiss <luca@z3ntu.xyz> Date: Thu, 27 Apr 2023 22:34:28 +0200 Subject: [PATCH 3/4] Input: pwm-vibra - add support for enable GPIO MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230427-hammerhead-vibra-v1-3-e87eeb94da51@z3ntu.xyz> References: <20230427-hammerhead-vibra-v1-0-e87eeb94da51@z3ntu.xyz> In-Reply-To: <20230427-hammerhead-vibra-v1-0-e87eeb94da51@z3ntu.xyz> To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Sebastian Reichel <sre@kernel.org>, Andy Gross <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Brian Masney <masneyb@onstation.org> Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Luca Weiss <luca@z3ntu.xyz> X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2007; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=6GdnfYGYIClKnqTCFJOePAiIDqCEBDJIJs44RnWeNMI=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBkStxqKLWCk5HSYfAn/q5yapUULHi+KQnW6QcqU 51pZNACtoaJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCZErcagAKCRBy2EO4nU3X VkdDD/4/kj0m621vJLriUUkQ56LQdegmfkofZe7OHLc+QWGt81G53U5PdRd7p49dS0TDhooBOYM tNeg4wWAjcySxYfn7mIAVLLON9JPCdlO6s3SaG1ERe+T6JfmnjLWTnCN+vqP6kHZFM72KJCqjNC THlLjjVEC3QqBqiZyU7MDo9EDZ5ci0Dra8daI/7rGfJYhfK4Io3SU6nHpfQgSfGkjtZ2NelrWRQ qki789fAy4F7LTfNdGDwPixoaVSto3ILUAZisMl3+FnAhgTYOBbU/kZDc91A5sx1Qs/B4+AKryg 7LJJLXhj+qxm/TaQH6Jt8XIG7Ci6u6oRCqZauWJbcF5aNlsbvYdzqUB2LWBS/brzmDAgvB1TyM0 matK94MSkmy9RMwaTSLBTXwKoRMqF5/hDnAKuJkt/NkfSzcJHcY79sPGB8oP4XVRSAq+NEq6wPx AdbIAhQSo9IMtN8IL53gRMhFmez3YJK1dMpaNmWvHNDNQ5gbSQvFqc8MWo0XtaI4sP6/d1qsEzf X4Fx047lSEK0vcUQ7I9nrhMLXJNqTwx5XoQ/v83jE+DHhz+bjqZUyNMUEAr4e00KP9SP90G/+sP ilXtQZ3xVlSQ+/fpcuuSV8AMERYnuRXsPODnO9xwgy0uMenqby57VD3GOfxx0STzUd6klW8VLFV 8zKb7kSFmESLnuA== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764363751125286454?= X-GMAIL-MSGID: =?utf-8?q?1764363751125286454?= |
Series |
Add haptics support to Nexus 5 using pwm-vibra driver
|
|
Commit Message
Luca Weiss
April 27, 2023, 8:34 p.m. UTC
Some pwm vibrators have a dedicated enable GPIO that needs to be set
high so that the vibrator works. Add support for that optionally.
Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
---
drivers/input/misc/pwm-vibra.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Comments
On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: > Some pwm vibrators have a dedicated enable GPIO that needs to be set > high so that the vibrator works. Add support for that optionally. > > Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Hi Luca, Thank you for picking up this work! > + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", > + GPIOD_OUT_LOW); > + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); > + if (err) { > + if (err != -EPROBE_DEFER) > + dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", > + err); > + return err; > + } > + Take a look at dev_err_probe() to remove the -EPROBE_DEFER check. With that fixed: Reviewed-by: Brian Masney <bmasney@redhat.com>
On 27/04/2023 21:34, Luca Weiss wrote: > Some pwm vibrators have a dedicated enable GPIO that needs to be set > high so that the vibrator works. Add support for that optionally. > > Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org> > --- > drivers/input/misc/pwm-vibra.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c > index c08971c97ad6..2ba035299db8 100644 > --- a/drivers/input/misc/pwm-vibra.c > +++ b/drivers/input/misc/pwm-vibra.c > @@ -11,6 +11,7 @@ > * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> > */ > > +#include <linux/gpio/consumer.h> > #include <linux/input.h> > #include <linux/kernel.h> > #include <linux/module.h> > @@ -23,6 +24,7 @@ > > struct pwm_vibrator { > struct input_dev *input; > + struct gpio_desc *enable_gpio; > struct pwm_device *pwm; > struct pwm_device *pwm_dir; > struct regulator *vcc; > @@ -48,6 +50,8 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) > vibrator->vcc_on = true; > } > > + gpiod_set_value_cansleep(vibrator->enable_gpio, 1); > + > pwm_get_state(vibrator->pwm, &state); > pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff); > state.enabled = true; > @@ -80,6 +84,8 @@ static void pwm_vibrator_stop(struct pwm_vibrator *vibrator) > pwm_disable(vibrator->pwm_dir); > pwm_disable(vibrator->pwm); > > + gpiod_set_value_cansleep(vibrator->enable_gpio, 0); > + > if (vibrator->vcc_on) { > regulator_disable(vibrator->vcc); > vibrator->vcc_on = false; > @@ -142,6 +148,16 @@ static int pwm_vibrator_probe(struct platform_device *pdev) > return err; > } > > + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", > + GPIOD_OUT_LOW); > + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); > + if (err) { > + if (err != -EPROBE_DEFER) > + dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", > + err); > + return err; > + } > + > vibrator->pwm = devm_pwm_get(&pdev->dev, "enable"); > err = PTR_ERR_OR_ZERO(vibrator->pwm); > if (err) { >
On Freitag, 28. April 2023 01:29:27 CEST Brian Masney wrote: > On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: > > Some pwm vibrators have a dedicated enable GPIO that needs to be set > > high so that the vibrator works. Add support for that optionally. > > > > Signed-off-by: Luca Weiss <luca@z3ntu.xyz> > > Hi Luca, > > Thank you for picking up this work! > > > + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", > > + GPIOD_OUT_LOW); > > + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); > > + if (err) { > > + if (err != -EPROBE_DEFER) > > + dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", > > + err); > > + return err; > > + } > > + > > Take a look at dev_err_probe() to remove the -EPROBE_DEFER check. The input subsystem doesn't like dev_err_probe for some reason, you should quickly find examples of that being rejected on the mailing list (or see "git grep dev_err_probe drivers/input/") > > With that fixed: > > Reviewed-by: Brian Masney <bmasney@redhat.com> Thanks for the reviews!
On Fri, Apr 28, 2023 at 06:06:20PM +0200, Luca Weiss wrote: > On Freitag, 28. April 2023 01:29:27 CEST Brian Masney wrote: > > Take a look at dev_err_probe() to remove the -EPROBE_DEFER check. > > The input subsystem doesn't like dev_err_probe for some reason, you should > quickly find examples of that being rejected on the mailing list (or see > "git grep dev_err_probe drivers/input/") OK, that's fine then. Feel free to include my Reviewed-by. Brian
Hi, On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: > Some pwm vibrators have a dedicated enable GPIO that needs to be set > high so that the vibrator works. Add support for that optionally. > > Signed-off-by: Luca Weiss <luca@z3ntu.xyz> > --- Reviewed-by: Sebastian Reichel <sre@kernel.org> -- Sebastian > drivers/input/misc/pwm-vibra.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c > index c08971c97ad6..2ba035299db8 100644 > --- a/drivers/input/misc/pwm-vibra.c > +++ b/drivers/input/misc/pwm-vibra.c > @@ -11,6 +11,7 @@ > * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> > */ > > +#include <linux/gpio/consumer.h> > #include <linux/input.h> > #include <linux/kernel.h> > #include <linux/module.h> > @@ -23,6 +24,7 @@ > > struct pwm_vibrator { > struct input_dev *input; > + struct gpio_desc *enable_gpio; > struct pwm_device *pwm; > struct pwm_device *pwm_dir; > struct regulator *vcc; > @@ -48,6 +50,8 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) > vibrator->vcc_on = true; > } > > + gpiod_set_value_cansleep(vibrator->enable_gpio, 1); > + > pwm_get_state(vibrator->pwm, &state); > pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff); > state.enabled = true; > @@ -80,6 +84,8 @@ static void pwm_vibrator_stop(struct pwm_vibrator *vibrator) > pwm_disable(vibrator->pwm_dir); > pwm_disable(vibrator->pwm); > > + gpiod_set_value_cansleep(vibrator->enable_gpio, 0); > + > if (vibrator->vcc_on) { > regulator_disable(vibrator->vcc); > vibrator->vcc_on = false; > @@ -142,6 +148,16 @@ static int pwm_vibrator_probe(struct platform_device *pdev) > return err; > } > > + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", > + GPIOD_OUT_LOW); > + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); > + if (err) { > + if (err != -EPROBE_DEFER) > + dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", > + err); > + return err; > + } > + > vibrator->pwm = devm_pwm_get(&pdev->dev, "enable"); > err = PTR_ERR_OR_ZERO(vibrator->pwm); > if (err) { > > -- > 2.40.0 >
On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: > Some pwm vibrators have a dedicated enable GPIO that needs to be set > high so that the vibrator works. Add support for that optionally. So this is not simply a power supply in your case controlled by a GPIO? We truly can have both GPIO and a separate regulator? Thanks.
On 28.04.2023 18:06, Luca Weiss wrote: > On Freitag, 28. April 2023 01:29:27 CEST Brian Masney wrote: >> On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: >>> Some pwm vibrators have a dedicated enable GPIO that needs to be set >>> high so that the vibrator works. Add support for that optionally. >>> >>> Signed-off-by: Luca Weiss <luca@z3ntu.xyz> >> >> Hi Luca, >> >> Thank you for picking up this work! >> >>> + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, > "enable", >>> + > GPIOD_OUT_LOW); >>> + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); >>> + if (err) { >>> + if (err != -EPROBE_DEFER) >>> + dev_err(&pdev->dev, "Failed to request enable > gpio: %d\n", >>> + err); >>> + return err; >>> + } >>> + >> Looks like your email client messes with the replies.. perhaps it tries to round them to n characters forcefully? Konrad >> Take a look at dev_err_probe() to remove the -EPROBE_DEFER check. > > The input subsystem doesn't like dev_err_probe for some reason, you should > quickly find examples of that being rejected on the mailing list (or see > "git grep dev_err_probe drivers/input/") > >> >> With that fixed: >> >> Reviewed-by: Brian Masney <bmasney@redhat.com> > > Thanks for the reviews! > >
On Dienstag, 2. Mai 2023 12:39:10 CEST Konrad Dybcio wrote: > On 28.04.2023 18:06, Luca Weiss wrote: > > On Freitag, 28. April 2023 01:29:27 CEST Brian Masney wrote: > >> On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: > >>> Some pwm vibrators have a dedicated enable GPIO that needs to be set > >>> high so that the vibrator works. Add support for that optionally. > >>> > >>> Signed-off-by: Luca Weiss <luca@z3ntu.xyz> > >> > >> Hi Luca, > >> > >> Thank you for picking up this work! > >> > >>> + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, > > > > "enable", > > > >>> + > > > > GPIOD_OUT_LOW); > > > >>> + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); > >>> + if (err) { > >>> + if (err != -EPROBE_DEFER) > >>> + dev_err(&pdev->dev, "Failed to request enable > > > > gpio: %d\n", > > > >>> + err); > >>> + return err; > >>> + } > >>> + > > Looks like your email client messes with the replies.. perhaps it tries > to round them to n characters forcefully? Quite possible, I'm using KMail with Options -> Wordwrap turned on, otherwise I have to manually wrap everything but with this on there doesn't seem to be a way to get over that limit, even when posting links etc - or when quoting existing text. Regards Luca > > Konrad > > >> Take a look at dev_err_probe() to remove the -EPROBE_DEFER check. > > > > The input subsystem doesn't like dev_err_probe for some reason, you should > > quickly find examples of that being rejected on the mailing list (or see > > "git grep dev_err_probe drivers/input/") > > > >> With that fixed: > >> > >> Reviewed-by: Brian Masney <bmasney@redhat.com> > > > > Thanks for the reviews!
On Dienstag, 2. Mai 2023 02:47:29 CEST Dmitry Torokhov wrote: > On Thu, Apr 27, 2023 at 10:34:28PM +0200, Luca Weiss wrote: > > Some pwm vibrators have a dedicated enable GPIO that needs to be set > > high so that the vibrator works. Add support for that optionally. > > So this is not simply a power supply in your case controlled by a GPIO? > We truly can have both GPIO and a separate regulator? Yes it appears to be the EN pin on the ISA1000A, see https://electronics.stackexchange.com/q/380475 On apq8026-lg-lenok there is a similar setup for the vibration motor although there I don't know whether it's actually a fixed-regulator or not, but since the two devices were built in a similar time (without checking further) I could assume they both contain the same IC. Regards Luca > > Thanks.
diff --git a/drivers/input/misc/pwm-vibra.c b/drivers/input/misc/pwm-vibra.c index c08971c97ad6..2ba035299db8 100644 --- a/drivers/input/misc/pwm-vibra.c +++ b/drivers/input/misc/pwm-vibra.c @@ -11,6 +11,7 @@ * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> */ +#include <linux/gpio/consumer.h> #include <linux/input.h> #include <linux/kernel.h> #include <linux/module.h> @@ -23,6 +24,7 @@ struct pwm_vibrator { struct input_dev *input; + struct gpio_desc *enable_gpio; struct pwm_device *pwm; struct pwm_device *pwm_dir; struct regulator *vcc; @@ -48,6 +50,8 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator) vibrator->vcc_on = true; } + gpiod_set_value_cansleep(vibrator->enable_gpio, 1); + pwm_get_state(vibrator->pwm, &state); pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff); state.enabled = true; @@ -80,6 +84,8 @@ static void pwm_vibrator_stop(struct pwm_vibrator *vibrator) pwm_disable(vibrator->pwm_dir); pwm_disable(vibrator->pwm); + gpiod_set_value_cansleep(vibrator->enable_gpio, 0); + if (vibrator->vcc_on) { regulator_disable(vibrator->vcc); vibrator->vcc_on = false; @@ -142,6 +148,16 @@ static int pwm_vibrator_probe(struct platform_device *pdev) return err; } + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", + GPIOD_OUT_LOW); + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); + if (err) { + if (err != -EPROBE_DEFER) + dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", + err); + return err; + } + vibrator->pwm = devm_pwm_get(&pdev->dev, "enable"); err = PTR_ERR_OR_ZERO(vibrator->pwm); if (err) {