Lines Matching refs:haptics
129 static int drv2667_set_waveform_freq(struct drv2667_data *haptics) in drv2667_set_waveform_freq() argument
138 freq = (haptics->frequency * 1000) / 78125; in drv2667_set_waveform_freq()
140 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
145 error = regmap_read(haptics->regmap, DRV2667_PAGE, &read_buf); in drv2667_set_waveform_freq()
147 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
153 haptics->page != read_buf) { in drv2667_set_waveform_freq()
154 error = regmap_write(haptics->regmap, in drv2667_set_waveform_freq()
155 DRV2667_PAGE, haptics->page); in drv2667_set_waveform_freq()
157 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
163 error = regmap_write(haptics->regmap, DRV2667_RAM_FREQ, freq); in drv2667_set_waveform_freq()
165 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
170 haptics->page != read_buf) { in drv2667_set_waveform_freq()
171 error = regmap_write(haptics->regmap, DRV2667_PAGE, read_buf); in drv2667_set_waveform_freq()
173 dev_err(&haptics->client->dev, in drv2667_set_waveform_freq()
184 struct drv2667_data *haptics = container_of(work, struct drv2667_data, work); in drv2667_worker() local
187 if (haptics->magnitude) { in drv2667_worker()
188 error = regmap_write(haptics->regmap, in drv2667_worker()
189 DRV2667_PAGE, haptics->page); in drv2667_worker()
191 dev_err(&haptics->client->dev, in drv2667_worker()
196 error = regmap_write(haptics->regmap, DRV2667_RAM_AMP, in drv2667_worker()
197 haptics->magnitude); in drv2667_worker()
199 dev_err(&haptics->client->dev, in drv2667_worker()
204 error = regmap_write(haptics->regmap, in drv2667_worker()
207 dev_err(&haptics->client->dev, in drv2667_worker()
212 error = regmap_write(haptics->regmap, in drv2667_worker()
215 dev_err(&haptics->client->dev, in drv2667_worker()
219 error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_worker()
222 dev_err(&haptics->client->dev, in drv2667_worker()
231 struct drv2667_data *haptics = input_get_drvdata(input); in drv2667_haptics_play() local
234 haptics->magnitude = effect->u.rumble.strong_magnitude; in drv2667_haptics_play()
236 haptics->magnitude = effect->u.rumble.weak_magnitude; in drv2667_haptics_play()
238 haptics->magnitude = 0; in drv2667_haptics_play()
240 schedule_work(&haptics->work); in drv2667_haptics_play()
247 struct drv2667_data *haptics = input_get_drvdata(input); in drv2667_close() local
250 cancel_work_sync(&haptics->work); in drv2667_close()
252 error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_close()
255 dev_err(&haptics->client->dev, in drv2667_close()
278 static int drv2667_init(struct drv2667_data *haptics) in drv2667_init() argument
283 haptics->frequency = 195; in drv2667_init()
284 haptics->page = DRV2667_PAGE_1; in drv2667_init()
286 error = regmap_register_patch(haptics->regmap, in drv2667_init()
290 dev_err(&haptics->client->dev, in drv2667_init()
296 error = regmap_write(haptics->regmap, DRV2667_PAGE, haptics->page); in drv2667_init()
298 dev_err(&haptics->client->dev, "Failed to set page: %d\n", in drv2667_init()
303 error = drv2667_set_waveform_freq(haptics); in drv2667_init()
307 error = regmap_register_patch(haptics->regmap, in drv2667_init()
311 dev_err(&haptics->client->dev, in drv2667_init()
317 error = regmap_write(haptics->regmap, DRV2667_PAGE, DRV2667_PAGE_0); in drv2667_init()
321 regmap_write(haptics->regmap, DRV2667_PAGE, DRV2667_PAGE_0); in drv2667_init()
338 struct drv2667_data *haptics; in drv2667_probe() local
341 haptics = devm_kzalloc(&client->dev, sizeof(*haptics), GFP_KERNEL); in drv2667_probe()
342 if (!haptics) in drv2667_probe()
345 haptics->regulator = devm_regulator_get(&client->dev, "vbat"); in drv2667_probe()
346 if (IS_ERR(haptics->regulator)) { in drv2667_probe()
347 error = PTR_ERR(haptics->regulator); in drv2667_probe()
353 haptics->input_dev = devm_input_allocate_device(&client->dev); in drv2667_probe()
354 if (!haptics->input_dev) { in drv2667_probe()
359 haptics->input_dev->name = "drv2667:haptics"; in drv2667_probe()
360 haptics->input_dev->dev.parent = client->dev.parent; in drv2667_probe()
361 haptics->input_dev->close = drv2667_close; in drv2667_probe()
362 input_set_drvdata(haptics->input_dev, haptics); in drv2667_probe()
363 input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE); in drv2667_probe()
365 error = input_ff_create_memless(haptics->input_dev, NULL, in drv2667_probe()
373 INIT_WORK(&haptics->work, drv2667_worker); in drv2667_probe()
375 haptics->client = client; in drv2667_probe()
376 i2c_set_clientdata(client, haptics); in drv2667_probe()
378 haptics->regmap = devm_regmap_init_i2c(client, &drv2667_regmap_config); in drv2667_probe()
379 if (IS_ERR(haptics->regmap)) { in drv2667_probe()
380 error = PTR_ERR(haptics->regmap); in drv2667_probe()
386 error = drv2667_init(haptics); in drv2667_probe()
392 error = input_register_device(haptics->input_dev); in drv2667_probe()
404 struct drv2667_data *haptics = dev_get_drvdata(dev); in drv2667_suspend() local
407 guard(mutex)(&haptics->input_dev->mutex); in drv2667_suspend()
409 if (input_device_enabled(haptics->input_dev)) { in drv2667_suspend()
410 error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_suspend()
414 regulator_disable(haptics->regulator); in drv2667_suspend()
418 error = regulator_disable(haptics->regulator); in drv2667_suspend()
421 regmap_update_bits(haptics->regmap, in drv2667_suspend()
433 struct drv2667_data *haptics = dev_get_drvdata(dev); in drv2667_resume() local
436 guard(mutex)(&haptics->input_dev->mutex); in drv2667_resume()
438 if (input_device_enabled(haptics->input_dev)) { in drv2667_resume()
439 error = regulator_enable(haptics->regulator); in drv2667_resume()
445 error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2, in drv2667_resume()
449 regulator_disable(haptics->regulator); in drv2667_resume()