* [PATCH v7 0/3] Add regulator-haptic driver @ 2014-12-17 3:35 Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 1/3] Input: add regulator haptic driver Jaewon Kim ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Jaewon Kim @ 2014-12-17 3:35 UTC (permalink / raw) To: Dmitry Torokhov, Kukjin Kim Cc: linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Jaewon Kim This patch series adds regulator-haptic driver. The regulator-haptic has haptic motor and it is controlled by voltage of regulator via force feedback framework. Changes in v7: - move platform_data or of_node check. - prevent to start playing effect when kernel entering suspend state. Changes in v6: - prevent racing condition Changes in v5: - give preference to platform data Changes in v4: - _regulator_get() -> _regulator_get_exclusive() Changes in v3: - fix typo in Documentation - add define in header file Changes in v2: - remove driver owner - merge enable/disable function - support platform data - fix wrong suspends_state check in regulator_haptic_resume() Jaewon Kim (3): Input: add regulator haptic driver ARM: dts: exynos3250-rinato: Add regulator-haptic node for haptics ARM: dts: exynos3250-monk: Add regulator-haptic node for haptics .../devicetree/bindings/input/regulator-haptic.txt | 21 ++ arch/arm/boot/dts/exynos3250-monk.dts | 7 + arch/arm/boot/dts/exynos3250-rinato.dts | 7 + drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/regulator-haptic.c | 247 ++++++++++++++++++++ include/linux/platform_data/regulator-haptic.h | 29 +++ 7 files changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/regulator-haptic.txt create mode 100644 drivers/input/misc/regulator-haptic.c create mode 100644 include/linux/platform_data/regulator-haptic.h -- 1.7.9.5 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v7 1/3] Input: add regulator haptic driver 2014-12-17 3:35 [PATCH v7 0/3] Add regulator-haptic driver Jaewon Kim @ 2014-12-17 3:35 ` Jaewon Kim 2014-12-17 22:06 ` Dmitry Torokhov 2014-12-17 3:35 ` [PATCH v7 2/3] ARM: dts: exynos3250-rinato: Add regulator-haptic node for haptics Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 3/3] ARM: dts: exynos3250-monk: " Jaewon Kim 2 siblings, 1 reply; 7+ messages in thread From: Jaewon Kim @ 2014-12-17 3:35 UTC (permalink / raw) To: Dmitry Torokhov, Kukjin Kim Cc: linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Jaewon Kim, Hyunhee Kim This patch adds support for haptic driver controlled by voltage of regulator. And this driver support for Force Feedback interface from input framework Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com> Signed-off-by: Hyunhee Kim <hyunhee.kim@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Tested-by: Chanwoo Choi <cw00.choi@samsung.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com> --- .../devicetree/bindings/input/regulator-haptic.txt | 21 ++ drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/regulator-haptic.c | 247 ++++++++++++++++++++ include/linux/platform_data/regulator-haptic.h | 29 +++ 5 files changed, 309 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/regulator-haptic.txt create mode 100644 drivers/input/misc/regulator-haptic.c create mode 100644 include/linux/platform_data/regulator-haptic.h diff --git a/Documentation/devicetree/bindings/input/regulator-haptic.txt b/Documentation/devicetree/bindings/input/regulator-haptic.txt new file mode 100644 index 0000000..3ed1c7e --- /dev/null +++ b/Documentation/devicetree/bindings/input/regulator-haptic.txt @@ -0,0 +1,21 @@ +* Regulator Haptic Device Tree Bindings + +Required Properties: + - compatible : Should be "regulator-haptic" + - haptic-supply : Power supply to the haptic motor. + [*] refer Documentation/devicetree/bindings/regulator/regulator.txt + + - max-microvolt : The maximum voltage value supplied to the haptic motor. + [The unit of the voltage is a micro] + + - min-microvolt : The minimum voltage value supplied to the haptic motor. + [The unit of the voltage is a micro] + +Example: + + haptics { + compatible = "regulator-haptic"; + haptic-supply = <&motor_regulator>; + max-microvolt = <2700000>; + min-microvolt = <1100000>; + }; diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 23297ab..e5e556d 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -394,6 +394,17 @@ config INPUT_CM109 To compile this driver as a module, choose M here: the module will be called cm109. +config INPUT_REGULATOR_HAPTIC + tristate "regulator haptics support" + select INPUT_FF_MEMLESS + help + This option enables device driver support for the haptic controlled + by regulator. This driver supports ff-memless interface + from input framework. + + To compile this driver as a module, choose M here: the + module will be called regulator-haptic. + config INPUT_RETU_PWRBUTTON tristate "Retu Power button Driver" depends on MFD_RETU diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 19c7603..1f135af 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY) += pmic8xxx-pwrkey.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o +obj-$(CONFIG_INPUT_REGULATOR_HAPTIC) += regulator-haptic.o obj-$(CONFIG_INPUT_RETU_PWRBUTTON) += retu-pwrbutton.o obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c new file mode 100644 index 0000000..16f5ec8 --- /dev/null +++ b/drivers/input/misc/regulator-haptic.c @@ -0,0 +1,247 @@ +/* + * Regulator haptic driver + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Author: Jaewon Kim <jaewon02.kim@samsung.com> + * Author: Hyunhee Kim <hyunhee.kim@samsung.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/input.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_data/regulator-haptic.h> +#include <linux/platform_device.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> + +#define MAX_MAGNITUDE_SHIFT 16 + +struct regulator_haptic { + struct device *dev; + struct input_dev *input_dev; + struct regulator *regulator; + + struct work_struct work; + struct mutex mutex; + + bool enabled; + bool suspend_state; + unsigned int max_volt; + unsigned int min_volt; + unsigned int intensity; + unsigned int magnitude; +}; + +static void regulator_haptic_enable(struct regulator_haptic *haptic, bool state) +{ + int error; + + if (haptic->enabled == state) + return; + + error = state ? regulator_enable(haptic->regulator) : + regulator_disable(haptic->regulator); + if (error) { + dev_err(haptic->dev, "cannot enable regulator\n"); + return; + } + + haptic->enabled = state; +} + +static void regulator_haptic_work(struct work_struct *work) +{ + struct regulator_haptic *haptic = container_of(work, + struct regulator_haptic, work); + int error; + + mutex_lock(&haptic->mutex); + + if (haptic->suspend_state) + goto err; + + error = regulator_set_voltage(haptic->regulator, + haptic->intensity + haptic->min_volt, haptic->max_volt); + if (error) { + dev_err(haptic->dev, "cannot set regulator voltage\n"); + goto err; + } + + if (haptic->magnitude) + regulator_haptic_enable(haptic, true); + else + regulator_haptic_enable(haptic, false); + +err: + mutex_unlock(&haptic->mutex); +} + +static int regulator_haptic_play_effect(struct input_dev *input, void *data, + struct ff_effect *effect) +{ + struct regulator_haptic *haptic = input_get_drvdata(input); + u64 volt_mag_multi; + + haptic->magnitude = effect->u.rumble.strong_magnitude; + if (!haptic->magnitude) + haptic->magnitude = effect->u.rumble.weak_magnitude; + + + volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * + haptic->magnitude; + haptic->intensity = (unsigned int)(volt_mag_multi >> + MAX_MAGNITUDE_SHIFT); + + schedule_work(&haptic->work); + + return 0; +} + +static void regulator_haptic_close(struct input_dev *input) +{ + struct regulator_haptic *haptic = input_get_drvdata(input); + + cancel_work_sync(&haptic->work); + regulator_haptic_enable(haptic, false); +} + +static int regulator_haptic_get_data(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct regulator_haptic_data *data = dev_get_platdata(&pdev->dev); + struct regulator_haptic *haptic = platform_get_drvdata(pdev); + int error; + + if (data) { + haptic->max_volt = data->max_volt; + haptic->min_volt = data->min_volt; + } else if (pdev->dev.of_node) { + error = of_property_read_u32(node, "max-microvolt", + &haptic->max_volt); + if (error) { + dev_err(&pdev->dev, "cannot parse max-microvolt\n"); + return error; + } + + error = of_property_read_u32(node, "min-microvolt", + &haptic->min_volt); + if (error) { + dev_err(&pdev->dev, "cannot parse min-microvolt\n"); + return error; + } + } else { + return -ENODEV; + } + + return 0; +} + +static int regulator_haptic_probe(struct platform_device *pdev) +{ + struct regulator_haptic *haptic; + struct input_dev *input_dev; + int error; + + haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL); + if (!haptic) + return -ENOMEM; + + platform_set_drvdata(pdev, haptic); + haptic->dev = &pdev->dev; + haptic->enabled = false; + haptic->suspend_state = false; + mutex_init(&haptic->mutex); + INIT_WORK(&haptic->work, regulator_haptic_work); + + error = regulator_haptic_get_data(pdev); + if (error) { + dev_err(&pdev->dev, "failed to get voltage value\n"); + return error; + } + + haptic->regulator = devm_regulator_get_exclusive(&pdev->dev, "haptic"); + if (IS_ERR(haptic->regulator)) { + dev_err(&pdev->dev, "failed to get regulator\n"); + return PTR_ERR(haptic->regulator); + } + + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) + return -ENOMEM; + + haptic->input_dev = input_dev; + haptic->input_dev->name = "regulator-haptic"; + haptic->input_dev->dev.parent = &pdev->dev; + haptic->input_dev->close = regulator_haptic_close; + input_set_drvdata(haptic->input_dev, haptic); + input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE); + + error = input_ff_create_memless(input_dev, NULL, + regulator_haptic_play_effect); + if (error) { + dev_err(&pdev->dev, "failed to create force-feedback\n"); + return error; + } + + error = input_register_device(haptic->input_dev); + if (error) { + dev_err(&pdev->dev, "failed to register input device\n"); + return error; + } + + return 0; +} + +static int __maybe_unused regulator_haptic_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct regulator_haptic *haptic = platform_get_drvdata(pdev); + + mutex_lock(&haptic->mutex); + + haptic->suspend_state = true; + + if (haptic->enabled) + regulator_haptic_enable(haptic, false); + + mutex_unlock(&haptic->mutex); + + return 0; +} + +static int __maybe_unused regulator_haptic_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct regulator_haptic *haptic = platform_get_drvdata(pdev); + + haptic->suspend_state = false; + + return 0; +} + +static SIMPLE_DEV_PM_OPS(regulator_haptic_pm_ops, + regulator_haptic_suspend, regulator_haptic_resume); + +static struct of_device_id regulator_haptic_dt_match[] = { + { .compatible = "regulator-haptic" }, + { /* sentinel */ }, +}; + +static struct platform_driver regulator_haptic_driver = { + .probe = regulator_haptic_probe, + .driver = { + .name = "regulator-haptic", + .of_match_table = regulator_haptic_dt_match, + .pm = ®ulator_haptic_pm_ops, + }, +}; +module_platform_driver(regulator_haptic_driver); + +MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>"); +MODULE_AUTHOR("Hyunhee Kim <hyunhee.kim@samsung.com>"); +MODULE_DESCRIPTION("Regulator haptic driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/platform_data/regulator-haptic.h b/include/linux/platform_data/regulator-haptic.h new file mode 100644 index 0000000..5658e58 --- /dev/null +++ b/include/linux/platform_data/regulator-haptic.h @@ -0,0 +1,29 @@ +/* + * Regulator Haptic Platform Data + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Author: Jaewon Kim <jaewon02.kim@samsung.com> + * Author: Hyunhee Kim <hyunhee.kim@samsung.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _REGULATOR_HAPTIC_H +#define _REGULATOR_HAPTIC_H + +/* + * struct regulator_haptic_data - Platform device data + * + * @max_volt: maximum voltage value supplied to the haptic motor. + * <The unit of the voltage is a micro> + * @min_volt: minimum voltage value supplied to the haptic motor. + * <The unit of the voltage is a micro> + */ +struct regulator_haptic_data { + unsigned int max_volt; + unsigned int min_volt; +}; + +#endif /* _REGULATOR_HAPTIC_H */ -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v7 1/3] Input: add regulator haptic driver 2014-12-17 3:35 ` [PATCH v7 1/3] Input: add regulator haptic driver Jaewon Kim @ 2014-12-17 22:06 ` Dmitry Torokhov 2014-12-18 1:17 ` Jaewon Kim 0 siblings, 1 reply; 7+ messages in thread From: Dmitry Torokhov @ 2014-12-17 22:06 UTC (permalink / raw) To: Jaewon Kim Cc: Kukjin Kim, linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Hyunhee Kim HI Jaewon, On Wed, Dec 17, 2014 at 12:35:06PM +0900, Jaewon Kim wrote: > This patch adds support for haptic driver controlled by > voltage of regulator. And this driver support for > Force Feedback interface from input framework > > Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com> > Signed-off-by: Hyunhee Kim <hyunhee.kim@samsung.com> > Acked-by: Kyungmin Park <kyungmin.park@samsung.com> > Tested-by: Chanwoo Choi <cw00.choi@samsung.com> > Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> > Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com> Does the driver still work if you apply the patch below on top of yours? Thanks. -- Dmitry Input: regulator-haptics - misc changes From: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- drivers/input/misc/Kconfig | 4 - drivers/input/misc/regulator-haptic.c | 164 ++++++++++++++++++++------------- 2 files changed, 100 insertions(+), 68 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index e5e556d..0b652c5 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -395,11 +395,11 @@ config INPUT_CM109 called cm109. config INPUT_REGULATOR_HAPTIC - tristate "regulator haptics support" + tristate "Regulator haptics support" select INPUT_FF_MEMLESS help This option enables device driver support for the haptic controlled - by regulator. This driver supports ff-memless interface + by a regulator. This driver supports ff-memless interface from input framework. To compile this driver as a module, choose M here: the diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c index 16f5ec8..9426221 100644 --- a/drivers/input/misc/regulator-haptic.c +++ b/drivers/input/misc/regulator-haptic.c @@ -28,55 +28,78 @@ struct regulator_haptic { struct work_struct work; struct mutex mutex; - bool enabled; - bool suspend_state; + bool active; + bool suspended; + unsigned int max_volt; unsigned int min_volt; - unsigned int intensity; unsigned int magnitude; }; -static void regulator_haptic_enable(struct regulator_haptic *haptic, bool state) +static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on) { int error; - if (haptic->enabled == state) - return; + if (haptic->active != on) { + + error = on ? regulator_enable(haptic->regulator) : + regulator_disable(haptic->regulator); + if (error) { + dev_err(haptic->dev, + "failed to switch regulator %s: %d\n", + on ? "on" : "off", error); + return error; + } + + haptic->active = on; + } - error = state ? regulator_enable(haptic->regulator) : - regulator_disable(haptic->regulator); + return 0; +} + +static int regulator_haptic_set_voltage(struct regulator_haptic *haptic, + unsigned int magnitude) +{ + u64 volt_mag_multi; + unsigned int intensity; + int error; + + volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * magnitude; + intensity = (unsigned int)(volt_mag_multi >> MAX_MAGNITUDE_SHIFT); + + error = regulator_set_voltage(haptic->regulator, + intensity + haptic->min_volt, + haptic->max_volt); if (error) { - dev_err(haptic->dev, "cannot enable regulator\n"); - return; + dev_err(haptic->dev, "cannot set regulator voltage to %d: %d\n", + intensity + haptic->min_volt, error); + return error; } - haptic->enabled = state; + return 0; } static void regulator_haptic_work(struct work_struct *work) { struct regulator_haptic *haptic = container_of(work, struct regulator_haptic, work); + unsigned int magnitude; int error; mutex_lock(&haptic->mutex); - if (haptic->suspend_state) - goto err; + if (haptic->suspended) + goto out; - error = regulator_set_voltage(haptic->regulator, - haptic->intensity + haptic->min_volt, haptic->max_volt); - if (error) { - dev_err(haptic->dev, "cannot set regulator voltage\n"); - goto err; - } + magnitude = ACCESS_ONCE(haptic->magnitude); - if (haptic->magnitude) - regulator_haptic_enable(haptic, true); - else - regulator_haptic_enable(haptic, false); + error = regulator_haptic_set_voltage(haptic, magnitude); + if (error) + goto out; -err: + regulator_haptic_toggle(haptic, magnitude != 0); + +out: mutex_unlock(&haptic->mutex); } @@ -84,18 +107,11 @@ static int regulator_haptic_play_effect(struct input_dev *input, void *data, struct ff_effect *effect) { struct regulator_haptic *haptic = input_get_drvdata(input); - u64 volt_mag_multi; haptic->magnitude = effect->u.rumble.strong_magnitude; if (!haptic->magnitude) haptic->magnitude = effect->u.rumble.weak_magnitude; - - volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * - haptic->magnitude; - haptic->intensity = (unsigned int)(volt_mag_multi >> - MAX_MAGNITUDE_SHIFT); - schedule_work(&haptic->work); return 0; @@ -106,35 +122,32 @@ static void regulator_haptic_close(struct input_dev *input) struct regulator_haptic *haptic = input_get_drvdata(input); cancel_work_sync(&haptic->work); - regulator_haptic_enable(haptic, false); + regulator_haptic_set_voltage(haptic, 0); + regulator_haptic_toggle(haptic, false); } -static int regulator_haptic_get_data(struct platform_device *pdev) +static int __maybe_unused +regulator_haptic_parse_dt(struct device *dev, struct regulator_haptic *haptic) { - struct device_node *node = pdev->dev.of_node; - struct regulator_haptic_data *data = dev_get_platdata(&pdev->dev); - struct regulator_haptic *haptic = platform_get_drvdata(pdev); + struct device_node *node; int error; - if (data) { - haptic->max_volt = data->max_volt; - haptic->min_volt = data->min_volt; - } else if (pdev->dev.of_node) { - error = of_property_read_u32(node, "max-microvolt", - &haptic->max_volt); - if (error) { - dev_err(&pdev->dev, "cannot parse max-microvolt\n"); - return error; - } + node = dev->of_node; + if(!node) { + dev_err(dev, "Missing dveice tree data\n"); + return -EINVAL; + } - error = of_property_read_u32(node, "min-microvolt", - &haptic->min_volt); - if (error) { - dev_err(&pdev->dev, "cannot parse min-microvolt\n"); - return error; - } - } else { - return -ENODEV; + error = of_property_read_u32(node, "max-microvolt", &haptic->max_volt); + if (error) { + dev_err(dev, "cannot parse max-microvolt\n"); + return error; + } + + error = of_property_read_u32(node, "min-microvolt", &haptic->min_volt); + if (error) { + dev_err(dev, "cannot parse min-microvolt\n"); + return error; } return 0; @@ -142,6 +155,7 @@ static int regulator_haptic_get_data(struct platform_device *pdev) static int regulator_haptic_probe(struct platform_device *pdev) { + const struct regulator_haptic_data *pdata = dev_get_platdata(&pdev->dev); struct regulator_haptic *haptic; struct input_dev *input_dev; int error; @@ -152,15 +166,19 @@ static int regulator_haptic_probe(struct platform_device *pdev) platform_set_drvdata(pdev, haptic); haptic->dev = &pdev->dev; - haptic->enabled = false; - haptic->suspend_state = false; mutex_init(&haptic->mutex); INIT_WORK(&haptic->work, regulator_haptic_work); - error = regulator_haptic_get_data(pdev); - if (error) { - dev_err(&pdev->dev, "failed to get voltage value\n"); - return error; + if (pdata) { + haptic->max_volt = pdata->max_volt; + haptic->min_volt = pdata->min_volt; + } else if (IS_ENABLED(CONFIG_OF)) { + error = regulator_haptic_parse_dt(&pdev->dev, haptic); + if (error) + return error; + } else { + dev_err(&pdev->dev, "Missing platform data\n"); + return -EINVAL; } haptic->regulator = devm_regulator_get_exclusive(&pdev->dev, "haptic"); @@ -181,7 +199,7 @@ static int regulator_haptic_probe(struct platform_device *pdev) input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE); error = input_ff_create_memless(input_dev, NULL, - regulator_haptic_play_effect); + regulator_haptic_play_effect); if (error) { dev_err(&pdev->dev, "failed to create force-feedback\n"); return error; @@ -200,13 +218,16 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct regulator_haptic *haptic = platform_get_drvdata(pdev); + int error; - mutex_lock(&haptic->mutex); + error = mutex_lock_interruptible(&haptic->mutex); + if (error) + return error; - haptic->suspend_state = true; + regulator_haptic_set_voltage(haptic, 0); + regulator_haptic_toggle(haptic, false); - if (haptic->enabled) - regulator_haptic_enable(haptic, false); + haptic->suspended = true; mutex_unlock(&haptic->mutex); @@ -217,8 +238,19 @@ static int __maybe_unused regulator_haptic_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct regulator_haptic *haptic = platform_get_drvdata(pdev); + unsigned int magnitude; + + mutex_lock(&haptic->mutex); + + haptic->suspended = false; - haptic->suspend_state = false; + magnitude = ACCESS_ONCE(haptic->magnitude); + if (magnitude) { + regulator_haptic_set_voltage(haptic, magnitude); + regulator_haptic_toggle(haptic, true); + } + + mutex_unlock(&haptic->mutex); return 0; } ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v7 1/3] Input: add regulator haptic driver 2014-12-17 22:06 ` Dmitry Torokhov @ 2014-12-18 1:17 ` Jaewon Kim 2014-12-18 1:20 ` Dmitry Torokhov 0 siblings, 1 reply; 7+ messages in thread From: Jaewon Kim @ 2014-12-18 1:17 UTC (permalink / raw) To: Dmitry Torokhov Cc: Kukjin Kim, linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Hyunhee Kim Hi Dmity, 2014년 12월 18일 07:06에 Dmitry Torokhov 이(가) 쓴 글: > HI Jaewon, > > On Wed, Dec 17, 2014 at 12:35:06PM +0900, Jaewon Kim wrote: >> This patch adds support for haptic driver controlled by >> voltage of regulator. And this driver support for >> Force Feedback interface from input framework >> >> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com> >> Signed-off-by: Hyunhee Kim <hyunhee.kim@samsung.com> >> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> >> Tested-by: Chanwoo Choi <cw00.choi@samsung.com> >> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> >> Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com> > Does the driver still work if you apply the patch below on top of yours? > > Thanks. > Yes, there is no problem to apply this one first. Thanks to review my patches. Thanks Jaewon Kim ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v7 1/3] Input: add regulator haptic driver 2014-12-18 1:17 ` Jaewon Kim @ 2014-12-18 1:20 ` Dmitry Torokhov 0 siblings, 0 replies; 7+ messages in thread From: Dmitry Torokhov @ 2014-12-18 1:20 UTC (permalink / raw) To: Jaewon Kim Cc: Kukjin Kim, linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Hyunhee Kim On Thursday, December 18, 2014 10:17:42 AM Jaewon Kim wrote: > Hi Dmity, > > 2014년 12월 18일 07:06에 Dmitry Torokhov 이(가) 쓴 글: > > HI Jaewon, > > > > On Wed, Dec 17, 2014 at 12:35:06PM +0900, Jaewon Kim wrote: > >> This patch adds support for haptic driver controlled by > >> voltage of regulator. And this driver support for > >> Force Feedback interface from input framework > >> > >> Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com> > >> Signed-off-by: Hyunhee Kim <hyunhee.kim@samsung.com> > >> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> > >> Tested-by: Chanwoo Choi <cw00.choi@samsung.com> > >> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> > >> Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com> > > > > Does the driver still work if you apply the patch below on top of yours? > > > > Thanks. > > Yes, there is no problem to apply this one first. Thank you. Then I'll fold it into yours and queue the driver for the next release. Thanks. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v7 2/3] ARM: dts: exynos3250-rinato: Add regulator-haptic node for haptics 2014-12-17 3:35 [PATCH v7 0/3] Add regulator-haptic driver Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 1/3] Input: add regulator haptic driver Jaewon Kim @ 2014-12-17 3:35 ` Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 3/3] ARM: dts: exynos3250-monk: " Jaewon Kim 2 siblings, 0 replies; 7+ messages in thread From: Jaewon Kim @ 2014-12-17 3:35 UTC (permalink / raw) To: Dmitry Torokhov, Kukjin Kim Cc: linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Jaewon Kim This patch adds regulator-haptic device node controlled by regulator. Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> --- arch/arm/boot/dts/exynos3250-rinato.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts b/arch/arm/boot/dts/exynos3250-rinato.dts index 80aa8b4..0e3d499 100644 --- a/arch/arm/boot/dts/exynos3250-rinato.dts +++ b/arch/arm/boot/dts/exynos3250-rinato.dts @@ -100,6 +100,13 @@ }; }; }; + + haptics { + compatible = "regulator-haptic"; + haptic-supply = <&motor_reg>; + min-microvolt = <1100000>; + max-microvolt = <2700000>; + }; }; &adc { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v7 3/3] ARM: dts: exynos3250-monk: Add regulator-haptic node for haptics 2014-12-17 3:35 [PATCH v7 0/3] Add regulator-haptic driver Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 1/3] Input: add regulator haptic driver Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 2/3] ARM: dts: exynos3250-rinato: Add regulator-haptic node for haptics Jaewon Kim @ 2014-12-17 3:35 ` Jaewon Kim 2 siblings, 0 replies; 7+ messages in thread From: Jaewon Kim @ 2014-12-17 3:35 UTC (permalink / raw) To: Dmitry Torokhov, Kukjin Kim Cc: linux-kernel, linux-samsung-soc, linux-input, Chanwoo Choi, Jaewon Kim This patch adds regulator-haptic device node controlled by regulator. Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com> --- arch/arm/boot/dts/exynos3250-monk.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/exynos3250-monk.dts b/arch/arm/boot/dts/exynos3250-monk.dts index 24822aa..7102d88 100644 --- a/arch/arm/boot/dts/exynos3250-monk.dts +++ b/arch/arm/boot/dts/exynos3250-monk.dts @@ -109,6 +109,13 @@ }; }; }; + + haptics { + compatible = "regulator-haptic"; + haptic-supply = <&motor_reg>; + min-microvolt = <1100000>; + max-microvolt = <2700000>; + }; }; &adc { -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-18 1:20 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-17 3:35 [PATCH v7 0/3] Add regulator-haptic driver Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 1/3] Input: add regulator haptic driver Jaewon Kim 2014-12-17 22:06 ` Dmitry Torokhov 2014-12-18 1:17 ` Jaewon Kim 2014-12-18 1:20 ` Dmitry Torokhov 2014-12-17 3:35 ` [PATCH v7 2/3] ARM: dts: exynos3250-rinato: Add regulator-haptic node for haptics Jaewon Kim 2014-12-17 3:35 ` [PATCH v7 3/3] ARM: dts: exynos3250-monk: " Jaewon Kim
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).