Lines Matching full:haptic

3  * Regulator haptic driver
13 #include <linux/platform_data/regulator-haptic.h>
36 static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on) in regulator_haptic_toggle() argument
40 if (haptic->active != on) { in regulator_haptic_toggle()
42 error = on ? regulator_enable(haptic->regulator) : in regulator_haptic_toggle()
43 regulator_disable(haptic->regulator); in regulator_haptic_toggle()
45 dev_err(haptic->dev, in regulator_haptic_toggle()
51 haptic->active = on; in regulator_haptic_toggle()
57 static int regulator_haptic_set_voltage(struct regulator_haptic *haptic, in regulator_haptic_set_voltage() argument
64 volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * magnitude; in regulator_haptic_set_voltage()
67 error = regulator_set_voltage(haptic->regulator, in regulator_haptic_set_voltage()
68 intensity + haptic->min_volt, in regulator_haptic_set_voltage()
69 haptic->max_volt); in regulator_haptic_set_voltage()
71 dev_err(haptic->dev, "cannot set regulator voltage to %d: %d\n", in regulator_haptic_set_voltage()
72 intensity + haptic->min_volt, error); in regulator_haptic_set_voltage()
76 regulator_haptic_toggle(haptic, !!magnitude); in regulator_haptic_set_voltage()
83 struct regulator_haptic *haptic = container_of(work, in regulator_haptic_work() local
86 mutex_lock(&haptic->mutex); in regulator_haptic_work()
88 if (!haptic->suspended) in regulator_haptic_work()
89 regulator_haptic_set_voltage(haptic, haptic->magnitude); in regulator_haptic_work()
91 mutex_unlock(&haptic->mutex); in regulator_haptic_work()
97 struct regulator_haptic *haptic = input_get_drvdata(input); in regulator_haptic_play_effect() local
99 haptic->magnitude = effect->u.rumble.strong_magnitude; in regulator_haptic_play_effect()
100 if (!haptic->magnitude) in regulator_haptic_play_effect()
101 haptic->magnitude = effect->u.rumble.weak_magnitude; in regulator_haptic_play_effect()
103 schedule_work(&haptic->work); in regulator_haptic_play_effect()
110 struct regulator_haptic *haptic = input_get_drvdata(input); in regulator_haptic_close() local
112 cancel_work_sync(&haptic->work); in regulator_haptic_close()
113 regulator_haptic_set_voltage(haptic, 0); in regulator_haptic_close()
117 regulator_haptic_parse_dt(struct device *dev, struct regulator_haptic *haptic) in regulator_haptic_parse_dt() argument
128 error = of_property_read_u32(node, "max-microvolt", &haptic->max_volt); in regulator_haptic_parse_dt()
134 error = of_property_read_u32(node, "min-microvolt", &haptic->min_volt); in regulator_haptic_parse_dt()
146 struct regulator_haptic *haptic; in regulator_haptic_probe() local
150 haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL); in regulator_haptic_probe()
151 if (!haptic) in regulator_haptic_probe()
154 platform_set_drvdata(pdev, haptic); in regulator_haptic_probe()
155 haptic->dev = &pdev->dev; in regulator_haptic_probe()
156 mutex_init(&haptic->mutex); in regulator_haptic_probe()
157 INIT_WORK(&haptic->work, regulator_haptic_work); in regulator_haptic_probe()
160 haptic->max_volt = pdata->max_volt; in regulator_haptic_probe()
161 haptic->min_volt = pdata->min_volt; in regulator_haptic_probe()
163 error = regulator_haptic_parse_dt(&pdev->dev, haptic); in regulator_haptic_probe()
171 haptic->regulator = devm_regulator_get_exclusive(&pdev->dev, "haptic"); in regulator_haptic_probe()
172 if (IS_ERR(haptic->regulator)) { in regulator_haptic_probe()
174 return PTR_ERR(haptic->regulator); in regulator_haptic_probe()
181 haptic->input_dev = input_dev; in regulator_haptic_probe()
182 haptic->input_dev->name = "regulator-haptic"; in regulator_haptic_probe()
183 haptic->input_dev->dev.parent = &pdev->dev; in regulator_haptic_probe()
184 haptic->input_dev->close = regulator_haptic_close; in regulator_haptic_probe()
185 input_set_drvdata(haptic->input_dev, haptic); in regulator_haptic_probe()
186 input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE); in regulator_haptic_probe()
195 error = input_register_device(haptic->input_dev); in regulator_haptic_probe()
207 struct regulator_haptic *haptic = platform_get_drvdata(pdev); in regulator_haptic_suspend() local
210 error = mutex_lock_interruptible(&haptic->mutex); in regulator_haptic_suspend()
214 regulator_haptic_set_voltage(haptic, 0); in regulator_haptic_suspend()
216 haptic->suspended = true; in regulator_haptic_suspend()
218 mutex_unlock(&haptic->mutex); in regulator_haptic_suspend()
226 struct regulator_haptic *haptic = platform_get_drvdata(pdev); in regulator_haptic_resume() local
229 mutex_lock(&haptic->mutex); in regulator_haptic_resume()
231 haptic->suspended = false; in regulator_haptic_resume()
233 magnitude = READ_ONCE(haptic->magnitude); in regulator_haptic_resume()
235 regulator_haptic_set_voltage(haptic, magnitude); in regulator_haptic_resume()
237 mutex_unlock(&haptic->mutex); in regulator_haptic_resume()
246 { .compatible = "regulator-haptic" },
254 .name = "regulator-haptic",
263 MODULE_DESCRIPTION("Regulator haptic driver");