Lines Matching full:haptic
3 * Regulator haptic driver
13 #include <linux/platform_data/regulator-haptic.h>
37 static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on) in regulator_haptic_toggle() argument
41 if (haptic->active != on) { in regulator_haptic_toggle()
43 error = on ? regulator_enable(haptic->regulator) : in regulator_haptic_toggle()
44 regulator_disable(haptic->regulator); in regulator_haptic_toggle()
46 dev_err(haptic->dev, in regulator_haptic_toggle()
52 haptic->active = on; in regulator_haptic_toggle()
58 static int regulator_haptic_set_voltage(struct regulator_haptic *haptic, in regulator_haptic_set_voltage() argument
65 volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * magnitude; in regulator_haptic_set_voltage()
68 error = regulator_set_voltage(haptic->regulator, in regulator_haptic_set_voltage()
69 intensity + haptic->min_volt, in regulator_haptic_set_voltage()
70 haptic->max_volt); in regulator_haptic_set_voltage()
72 dev_err(haptic->dev, "cannot set regulator voltage to %d: %d\n", in regulator_haptic_set_voltage()
73 intensity + haptic->min_volt, error); in regulator_haptic_set_voltage()
77 regulator_haptic_toggle(haptic, !!magnitude); in regulator_haptic_set_voltage()
84 struct regulator_haptic *haptic = container_of(work, in regulator_haptic_work() local
87 guard(mutex)(&haptic->mutex); in regulator_haptic_work()
89 if (!haptic->suspended) in regulator_haptic_work()
90 regulator_haptic_set_voltage(haptic, haptic->magnitude); in regulator_haptic_work()
96 struct regulator_haptic *haptic = input_get_drvdata(input); in regulator_haptic_play_effect() local
98 haptic->magnitude = effect->u.rumble.strong_magnitude; in regulator_haptic_play_effect()
99 if (!haptic->magnitude) in regulator_haptic_play_effect()
100 haptic->magnitude = effect->u.rumble.weak_magnitude; in regulator_haptic_play_effect()
102 schedule_work(&haptic->work); in regulator_haptic_play_effect()
109 struct regulator_haptic *haptic = input_get_drvdata(input); in regulator_haptic_close() local
111 cancel_work_sync(&haptic->work); in regulator_haptic_close()
112 regulator_haptic_set_voltage(haptic, 0); in regulator_haptic_close()
116 regulator_haptic_parse_dt(struct device *dev, struct regulator_haptic *haptic) in regulator_haptic_parse_dt() argument
127 error = of_property_read_u32(node, "max-microvolt", &haptic->max_volt); in regulator_haptic_parse_dt()
133 error = of_property_read_u32(node, "min-microvolt", &haptic->min_volt); in regulator_haptic_parse_dt()
145 struct regulator_haptic *haptic; in regulator_haptic_probe() local
149 haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL); in regulator_haptic_probe()
150 if (!haptic) in regulator_haptic_probe()
153 platform_set_drvdata(pdev, haptic); in regulator_haptic_probe()
154 haptic->dev = &pdev->dev; in regulator_haptic_probe()
155 mutex_init(&haptic->mutex); in regulator_haptic_probe()
156 INIT_WORK(&haptic->work, regulator_haptic_work); in regulator_haptic_probe()
159 haptic->max_volt = pdata->max_volt; in regulator_haptic_probe()
160 haptic->min_volt = pdata->min_volt; in regulator_haptic_probe()
162 error = regulator_haptic_parse_dt(&pdev->dev, haptic); in regulator_haptic_probe()
170 haptic->regulator = devm_regulator_get_exclusive(&pdev->dev, "haptic"); in regulator_haptic_probe()
171 if (IS_ERR(haptic->regulator)) { in regulator_haptic_probe()
173 return PTR_ERR(haptic->regulator); in regulator_haptic_probe()
180 haptic->input_dev = input_dev; in regulator_haptic_probe()
181 haptic->input_dev->name = "regulator-haptic"; in regulator_haptic_probe()
182 haptic->input_dev->dev.parent = &pdev->dev; in regulator_haptic_probe()
183 haptic->input_dev->close = regulator_haptic_close; in regulator_haptic_probe()
184 input_set_drvdata(haptic->input_dev, haptic); in regulator_haptic_probe()
185 input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE); in regulator_haptic_probe()
194 error = input_register_device(haptic->input_dev); in regulator_haptic_probe()
206 struct regulator_haptic *haptic = platform_get_drvdata(pdev); in regulator_haptic_suspend() local
208 scoped_guard(mutex_intr, &haptic->mutex) { in regulator_haptic_suspend()
209 regulator_haptic_set_voltage(haptic, 0); in regulator_haptic_suspend()
210 haptic->suspended = true; in regulator_haptic_suspend()
221 struct regulator_haptic *haptic = platform_get_drvdata(pdev); in regulator_haptic_resume() local
224 guard(mutex)(&haptic->mutex); in regulator_haptic_resume()
226 haptic->suspended = false; in regulator_haptic_resume()
228 magnitude = READ_ONCE(haptic->magnitude); in regulator_haptic_resume()
230 regulator_haptic_set_voltage(haptic, magnitude); in regulator_haptic_resume()
239 { .compatible = "regulator-haptic" },
247 .name = "regulator-haptic",
256 MODULE_DESCRIPTION("Regulator haptic driver");