Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: pwm-vibra - add support for enable GPIO

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: Brian Masney <bmasney@redhat.com>
Reviewed-by: Sebastian Reichel <sre@kernel.org>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Link: https://lore.kernel.org/r/20230427-hammerhead-vibra-v1-3-e87eeb94da51@z3ntu.xyz
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Luca Weiss and committed by
Dmitry Torokhov
bcf78498 29ebf697

+16
+16
drivers/input/misc/pwm-vibra.c
··· 11 11 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> 12 12 */ 13 13 14 + #include <linux/gpio/consumer.h> 14 15 #include <linux/input.h> 15 16 #include <linux/kernel.h> 16 17 #include <linux/module.h> ··· 24 23 25 24 struct pwm_vibrator { 26 25 struct input_dev *input; 26 + struct gpio_desc *enable_gpio; 27 27 struct pwm_device *pwm; 28 28 struct pwm_device *pwm_dir; 29 29 struct regulator *vcc; ··· 49 47 } 50 48 vibrator->vcc_on = true; 51 49 } 50 + 51 + gpiod_set_value_cansleep(vibrator->enable_gpio, 1); 52 52 53 53 pwm_get_state(vibrator->pwm, &state); 54 54 pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff); ··· 83 79 if (vibrator->pwm_dir) 84 80 pwm_disable(vibrator->pwm_dir); 85 81 pwm_disable(vibrator->pwm); 82 + 83 + gpiod_set_value_cansleep(vibrator->enable_gpio, 0); 86 84 87 85 if (vibrator->vcc_on) { 88 86 regulator_disable(vibrator->vcc); ··· 144 138 if (err) { 145 139 if (err != -EPROBE_DEFER) 146 140 dev_err(&pdev->dev, "Failed to request regulator: %d\n", 141 + err); 142 + return err; 143 + } 144 + 145 + vibrator->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", 146 + GPIOD_OUT_LOW); 147 + err = PTR_ERR_OR_ZERO(vibrator->enable_gpio); 148 + if (err) { 149 + if (err != -EPROBE_DEFER) 150 + dev_err(&pdev->dev, "Failed to request enable gpio: %d\n", 147 151 err); 148 152 return err; 149 153 }