Lines Matching refs:haptics
250 struct drv260x_data *haptics = container_of(work, struct drv260x_data, work); in drv260x_worker() local
253 gpiod_set_value(haptics->enable_gpio, 1); in drv260x_worker()
257 error = regmap_write(haptics->regmap, in drv260x_worker()
260 dev_err(&haptics->client->dev, in drv260x_worker()
263 error = regmap_write(haptics->regmap, in drv260x_worker()
264 DRV260X_RT_PB_IN, haptics->magnitude); in drv260x_worker()
266 dev_err(&haptics->client->dev, in drv260x_worker()
274 struct drv260x_data *haptics = input_get_drvdata(input); in drv260x_haptics_play() local
276 haptics->mode = DRV260X_LRA_NO_CAL_MODE; in drv260x_haptics_play()
279 haptics->magnitude = effect->u.rumble.strong_magnitude; in drv260x_haptics_play()
281 haptics->magnitude = effect->u.rumble.weak_magnitude; in drv260x_haptics_play()
283 haptics->magnitude = 0; in drv260x_haptics_play()
285 schedule_work(&haptics->work); in drv260x_haptics_play()
292 struct drv260x_data *haptics = input_get_drvdata(input); in drv260x_close() local
295 cancel_work_sync(&haptics->work); in drv260x_close()
297 error = regmap_write(haptics->regmap, DRV260X_MODE, DRV260X_STANDBY); in drv260x_close()
299 dev_err(&haptics->client->dev, in drv260x_close()
302 gpiod_set_value(haptics->enable_gpio, 0); in drv260x_close()
344 static int drv260x_init(struct drv260x_data *haptics) in drv260x_init() argument
349 error = regmap_write(haptics->regmap, in drv260x_init()
350 DRV260X_RATED_VOLT, haptics->rated_voltage); in drv260x_init()
352 dev_err(&haptics->client->dev, in drv260x_init()
358 error = regmap_write(haptics->regmap, in drv260x_init()
359 DRV260X_OD_CLAMP_VOLT, haptics->overdrive_voltage); in drv260x_init()
361 dev_err(&haptics->client->dev, in drv260x_init()
367 switch (haptics->mode) { in drv260x_init()
369 error = regmap_register_patch(haptics->regmap, in drv260x_init()
373 dev_err(&haptics->client->dev, in drv260x_init()
382 error = regmap_register_patch(haptics->regmap, in drv260x_init()
386 dev_err(&haptics->client->dev, in drv260x_init()
392 error = regmap_update_bits(haptics->regmap, DRV260X_LIB_SEL, in drv260x_init()
394 haptics->library); in drv260x_init()
396 dev_err(&haptics->client->dev, in drv260x_init()
405 error = regmap_register_patch(haptics->regmap, in drv260x_init()
409 dev_err(&haptics->client->dev, in drv260x_init()
415 error = regmap_update_bits(haptics->regmap, DRV260X_LIB_SEL, in drv260x_init()
417 haptics->library); in drv260x_init()
419 dev_err(&haptics->client->dev, in drv260x_init()
429 error = regmap_write(haptics->regmap, DRV260X_GO, DRV260X_GO_BIT); in drv260x_init()
431 dev_err(&haptics->client->dev, in drv260x_init()
438 error = regmap_read(haptics->regmap, DRV260X_GO, &cal_buf); in drv260x_init()
440 dev_err(&haptics->client->dev, in drv260x_init()
464 struct drv260x_data *haptics; in drv260x_probe() local
468 haptics = devm_kzalloc(dev, sizeof(*haptics), GFP_KERNEL); in drv260x_probe()
469 if (!haptics) in drv260x_probe()
472 error = device_property_read_u32(dev, "mode", &haptics->mode); in drv260x_probe()
478 if (haptics->mode < DRV260X_LRA_MODE || in drv260x_probe()
479 haptics->mode > DRV260X_ERM_MODE) { in drv260x_probe()
480 dev_err(dev, "Vibrator mode is invalid: %i\n", haptics->mode); in drv260x_probe()
484 error = device_property_read_u32(dev, "library-sel", &haptics->library); in drv260x_probe()
490 if (haptics->library < DRV260X_LIB_EMPTY || in drv260x_probe()
491 haptics->library > DRV260X_ERM_LIB_F) { in drv260x_probe()
493 "Library value is invalid: %i\n", haptics->library); in drv260x_probe()
497 if (haptics->mode == DRV260X_LRA_MODE && in drv260x_probe()
498 haptics->library != DRV260X_LIB_EMPTY && in drv260x_probe()
499 haptics->library != DRV260X_LIB_LRA) { in drv260x_probe()
504 if (haptics->mode == DRV260X_ERM_MODE && in drv260x_probe()
505 (haptics->library == DRV260X_LIB_EMPTY || in drv260x_probe()
506 haptics->library == DRV260X_LIB_LRA)) { in drv260x_probe()
512 haptics->rated_voltage = error ? DRV260X_DEF_RATED_VOLT : in drv260x_probe()
516 haptics->overdrive_voltage = error ? DRV260X_DEF_OD_CLAMP_VOLT : in drv260x_probe()
519 haptics->regulator = devm_regulator_get(dev, "vbat"); in drv260x_probe()
520 if (IS_ERR(haptics->regulator)) { in drv260x_probe()
521 error = PTR_ERR(haptics->regulator); in drv260x_probe()
526 haptics->enable_gpio = devm_gpiod_get_optional(dev, "enable", in drv260x_probe()
528 if (IS_ERR(haptics->enable_gpio)) in drv260x_probe()
529 return PTR_ERR(haptics->enable_gpio); in drv260x_probe()
531 haptics->input_dev = devm_input_allocate_device(dev); in drv260x_probe()
532 if (!haptics->input_dev) { in drv260x_probe()
537 haptics->input_dev->name = "drv260x:haptics"; in drv260x_probe()
538 haptics->input_dev->close = drv260x_close; in drv260x_probe()
539 input_set_drvdata(haptics->input_dev, haptics); in drv260x_probe()
540 input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE); in drv260x_probe()
542 error = input_ff_create_memless(haptics->input_dev, NULL, in drv260x_probe()
549 INIT_WORK(&haptics->work, drv260x_worker); in drv260x_probe()
551 haptics->client = client; in drv260x_probe()
552 i2c_set_clientdata(client, haptics); in drv260x_probe()
554 haptics->regmap = devm_regmap_init_i2c(client, &drv260x_regmap_config); in drv260x_probe()
555 if (IS_ERR(haptics->regmap)) { in drv260x_probe()
556 error = PTR_ERR(haptics->regmap); in drv260x_probe()
561 error = drv260x_init(haptics); in drv260x_probe()
567 error = input_register_device(haptics->input_dev); in drv260x_probe()
578 struct drv260x_data *haptics = dev_get_drvdata(dev); in drv260x_suspend() local
581 mutex_lock(&haptics->input_dev->mutex); in drv260x_suspend()
583 if (haptics->input_dev->users) { in drv260x_suspend()
584 ret = regmap_update_bits(haptics->regmap, in drv260x_suspend()
593 gpiod_set_value(haptics->enable_gpio, 0); in drv260x_suspend()
595 ret = regulator_disable(haptics->regulator); in drv260x_suspend()
598 regmap_update_bits(haptics->regmap, in drv260x_suspend()
604 mutex_unlock(&haptics->input_dev->mutex); in drv260x_suspend()
610 struct drv260x_data *haptics = dev_get_drvdata(dev); in drv260x_resume() local
613 mutex_lock(&haptics->input_dev->mutex); in drv260x_resume()
615 if (haptics->input_dev->users) { in drv260x_resume()
616 ret = regulator_enable(haptics->regulator); in drv260x_resume()
622 ret = regmap_update_bits(haptics->regmap, in drv260x_resume()
627 regulator_disable(haptics->regulator); in drv260x_resume()
631 gpiod_set_value(haptics->enable_gpio, 1); in drv260x_resume()
635 mutex_unlock(&haptics->input_dev->mutex); in drv260x_resume()