Lines Matching refs:haptic
39 static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on) in regulator_haptic_toggle() argument
43 if (haptic->active != on) { in regulator_haptic_toggle()
45 error = on ? regulator_enable(haptic->regulator) : in regulator_haptic_toggle()
46 regulator_disable(haptic->regulator); in regulator_haptic_toggle()
48 dev_err(haptic->dev, in regulator_haptic_toggle()
54 haptic->active = on; in regulator_haptic_toggle()
60 static int regulator_haptic_set_voltage(struct regulator_haptic *haptic, in regulator_haptic_set_voltage() argument
67 volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * magnitude; in regulator_haptic_set_voltage()
70 error = regulator_set_voltage(haptic->regulator, in regulator_haptic_set_voltage()
71 intensity + haptic->min_volt, in regulator_haptic_set_voltage()
72 haptic->max_volt); in regulator_haptic_set_voltage()
74 dev_err(haptic->dev, "cannot set regulator voltage to %d: %d\n", in regulator_haptic_set_voltage()
75 intensity + haptic->min_volt, error); in regulator_haptic_set_voltage()
79 regulator_haptic_toggle(haptic, !!magnitude); in regulator_haptic_set_voltage()
86 struct regulator_haptic *haptic = container_of(work, in regulator_haptic_work() local
89 mutex_lock(&haptic->mutex); in regulator_haptic_work()
91 if (!haptic->suspended) in regulator_haptic_work()
92 regulator_haptic_set_voltage(haptic, haptic->magnitude); in regulator_haptic_work()
94 mutex_unlock(&haptic->mutex); in regulator_haptic_work()
100 struct regulator_haptic *haptic = input_get_drvdata(input); in regulator_haptic_play_effect() local
102 haptic->magnitude = effect->u.rumble.strong_magnitude; in regulator_haptic_play_effect()
103 if (!haptic->magnitude) in regulator_haptic_play_effect()
104 haptic->magnitude = effect->u.rumble.weak_magnitude; in regulator_haptic_play_effect()
106 schedule_work(&haptic->work); in regulator_haptic_play_effect()
113 struct regulator_haptic *haptic = input_get_drvdata(input); in regulator_haptic_close() local
115 cancel_work_sync(&haptic->work); in regulator_haptic_close()
116 regulator_haptic_set_voltage(haptic, 0); in regulator_haptic_close()
120 regulator_haptic_parse_dt(struct device *dev, struct regulator_haptic *haptic) in regulator_haptic_parse_dt() argument
131 error = of_property_read_u32(node, "max-microvolt", &haptic->max_volt); in regulator_haptic_parse_dt()
137 error = of_property_read_u32(node, "min-microvolt", &haptic->min_volt); in regulator_haptic_parse_dt()
149 struct regulator_haptic *haptic; in regulator_haptic_probe() local
153 haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL); in regulator_haptic_probe()
154 if (!haptic) in regulator_haptic_probe()
157 platform_set_drvdata(pdev, haptic); in regulator_haptic_probe()
158 haptic->dev = &pdev->dev; in regulator_haptic_probe()
159 mutex_init(&haptic->mutex); in regulator_haptic_probe()
160 INIT_WORK(&haptic->work, regulator_haptic_work); in regulator_haptic_probe()
163 haptic->max_volt = pdata->max_volt; in regulator_haptic_probe()
164 haptic->min_volt = pdata->min_volt; in regulator_haptic_probe()
166 error = regulator_haptic_parse_dt(&pdev->dev, haptic); in regulator_haptic_probe()
174 haptic->regulator = devm_regulator_get_exclusive(&pdev->dev, "haptic"); in regulator_haptic_probe()
175 if (IS_ERR(haptic->regulator)) { in regulator_haptic_probe()
177 return PTR_ERR(haptic->regulator); in regulator_haptic_probe()
184 haptic->input_dev = input_dev; in regulator_haptic_probe()
185 haptic->input_dev->name = "regulator-haptic"; in regulator_haptic_probe()
186 haptic->input_dev->dev.parent = &pdev->dev; in regulator_haptic_probe()
187 haptic->input_dev->close = regulator_haptic_close; in regulator_haptic_probe()
188 input_set_drvdata(haptic->input_dev, haptic); in regulator_haptic_probe()
189 input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE); in regulator_haptic_probe()
198 error = input_register_device(haptic->input_dev); in regulator_haptic_probe()
210 struct regulator_haptic *haptic = platform_get_drvdata(pdev); in regulator_haptic_suspend() local
213 error = mutex_lock_interruptible(&haptic->mutex); in regulator_haptic_suspend()
217 regulator_haptic_set_voltage(haptic, 0); in regulator_haptic_suspend()
219 haptic->suspended = true; in regulator_haptic_suspend()
221 mutex_unlock(&haptic->mutex); in regulator_haptic_suspend()
229 struct regulator_haptic *haptic = platform_get_drvdata(pdev); in regulator_haptic_resume() local
232 mutex_lock(&haptic->mutex); in regulator_haptic_resume()
234 haptic->suspended = false; in regulator_haptic_resume()
236 magnitude = ACCESS_ONCE(haptic->magnitude); in regulator_haptic_resume()
238 regulator_haptic_set_voltage(haptic, magnitude); in regulator_haptic_resume()
240 mutex_unlock(&haptic->mutex); in regulator_haptic_resume()