Lines Matching refs:haptics
127 static int drv2667_set_waveform_freq(struct drv2667_data *haptics) in drv2667_set_waveform_freq() argument
136 freq = (haptics->frequency * 1000) / 78125; in drv2667_set_waveform_freq()
138 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
143 error = regmap_read(haptics->regmap, DRV2667_PAGE, &read_buf); in drv2667_set_waveform_freq()
145 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
151 haptics->page != read_buf) { in drv2667_set_waveform_freq()
152 error = regmap_write(haptics->regmap, in drv2667_set_waveform_freq()
153 DRV2667_PAGE, haptics->page); in drv2667_set_waveform_freq()
155 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
161 error = regmap_write(haptics->regmap, DRV2667_RAM_FREQ, freq); in drv2667_set_waveform_freq()
163 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
168 haptics->page != read_buf) { in drv2667_set_waveform_freq()
169 error = regmap_write(haptics->regmap, DRV2667_PAGE, read_buf); in drv2667_set_waveform_freq()
171 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
182 struct drv2667_data *haptics = container_of(work, struct drv2667_data, work); in drv2667_worker() local
185 if (haptics->magnitude) { in drv2667_worker()
186 error = regmap_write(haptics->regmap, in drv2667_worker()
187 DRV2667_PAGE, haptics->page); in drv2667_worker()
189 dev_err(&haptics->client->dev, in drv2667_worker()
194 error = regmap_write(haptics->regmap, DRV2667_RAM_AMP, in drv2667_worker()
195 haptics->magnitude); in drv2667_worker()
197 dev_err(&haptics->client->dev, in drv2667_worker()
202 error = regmap_write(haptics->regmap, in drv2667_worker()
205 dev_err(&haptics->client->dev, in drv2667_worker()
210 error = regmap_write(haptics->regmap, in drv2667_worker()
213 dev_err(&haptics->client->dev, in drv2667_worker()
217 error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_worker()
220 dev_err(&haptics->client->dev, in drv2667_worker()
229 struct drv2667_data *haptics = input_get_drvdata(input); in drv2667_haptics_play() local
232 haptics->magnitude = effect->u.rumble.strong_magnitude; in drv2667_haptics_play()
234 haptics->magnitude = effect->u.rumble.weak_magnitude; in drv2667_haptics_play()
236 haptics->magnitude = 0; in drv2667_haptics_play()
238 schedule_work(&haptics->work); in drv2667_haptics_play()
245 struct drv2667_data *haptics = input_get_drvdata(input); in drv2667_close() local
248 cancel_work_sync(&haptics->work); in drv2667_close()
250 error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_close()
253 dev_err(&haptics->client->dev, in drv2667_close()
276 static int drv2667_init(struct drv2667_data *haptics) in drv2667_init() argument
281 haptics->frequency = 195; in drv2667_init()
282 haptics->page = DRV2667_PAGE_1; in drv2667_init()
284 error = regmap_register_patch(haptics->regmap, in drv2667_init()
288 dev_err(&haptics->client->dev, in drv2667_init()
294 error = regmap_write(haptics->regmap, DRV2667_PAGE, haptics->page); in drv2667_init()
296 dev_err(&haptics->client->dev, "Failed to set page: %d\n", in drv2667_init()
301 error = drv2667_set_waveform_freq(haptics); in drv2667_init()
305 error = regmap_register_patch(haptics->regmap, in drv2667_init()
309 dev_err(&haptics->client->dev, in drv2667_init()
315 error = regmap_write(haptics->regmap, DRV2667_PAGE, DRV2667_PAGE_0); in drv2667_init()
319 regmap_write(haptics->regmap, DRV2667_PAGE, DRV2667_PAGE_0); in drv2667_init()
337 struct drv2667_data *haptics; in drv2667_probe() local
340 haptics = devm_kzalloc(&client->dev, sizeof(*haptics), GFP_KERNEL); in drv2667_probe()
341 if (!haptics) in drv2667_probe()
344 haptics->regulator = devm_regulator_get(&client->dev, "vbat"); in drv2667_probe()
345 if (IS_ERR(haptics->regulator)) { in drv2667_probe()
346 error = PTR_ERR(haptics->regulator); in drv2667_probe()
352 haptics->input_dev = devm_input_allocate_device(&client->dev); in drv2667_probe()
353 if (!haptics->input_dev) { in drv2667_probe()
358 haptics->input_dev->name = "drv2667:haptics"; in drv2667_probe()
359 haptics->input_dev->dev.parent = client->dev.parent; in drv2667_probe()
360 haptics->input_dev->close = drv2667_close; in drv2667_probe()
361 input_set_drvdata(haptics->input_dev, haptics); in drv2667_probe()
362 input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE); in drv2667_probe()
364 error = input_ff_create_memless(haptics->input_dev, NULL, in drv2667_probe()
372 INIT_WORK(&haptics->work, drv2667_worker); in drv2667_probe()
374 haptics->client = client; in drv2667_probe()
375 i2c_set_clientdata(client, haptics); in drv2667_probe()
377 haptics->regmap = devm_regmap_init_i2c(client, &drv2667_regmap_config); in drv2667_probe()
378 if (IS_ERR(haptics->regmap)) { in drv2667_probe()
379 error = PTR_ERR(haptics->regmap); in drv2667_probe()
385 error = drv2667_init(haptics); in drv2667_probe()
391 error = input_register_device(haptics->input_dev); in drv2667_probe()
403 struct drv2667_data *haptics = dev_get_drvdata(dev); in drv2667_suspend() local
406 mutex_lock(&haptics->input_dev->mutex); in drv2667_suspend()
408 if (haptics->input_dev->users) { in drv2667_suspend()
409 ret = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_suspend()
413 regulator_disable(haptics->regulator); in drv2667_suspend()
417 ret = regulator_disable(haptics->regulator); in drv2667_suspend()
420 regmap_update_bits(haptics->regmap, in drv2667_suspend()
426 mutex_unlock(&haptics->input_dev->mutex); in drv2667_suspend()
432 struct drv2667_data *haptics = dev_get_drvdata(dev); in drv2667_resume() local
435 mutex_lock(&haptics->input_dev->mutex); in drv2667_resume()
437 if (haptics->input_dev->users) { in drv2667_resume()
438 ret = regulator_enable(haptics->regulator); in drv2667_resume()
444 ret = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_resume()
448 regulator_disable(haptics->regulator); in drv2667_resume()
455 mutex_unlock(&haptics->input_dev->mutex); in drv2667_resume()