Lines Matching +full:vib +full:- +full:rated +full:- +full:mv

1 // SPDX-License-Identifier: GPL-2.0-only
19 #include <dt-bindings/input/ti-drv260x.h>
169 * struct drv260x_data -
200 * Rated and Overdriver Voltages:
203 * and v is the rated or overdriver voltage of the actuator
215 gpiod_set_value(haptics->enable_gpio, 1); in drv260x_worker()
219 error = regmap_write(haptics->regmap, in drv260x_worker()
222 dev_err(&haptics->client->dev, in drv260x_worker()
225 error = regmap_write(haptics->regmap, in drv260x_worker()
226 DRV260X_RT_PB_IN, haptics->magnitude); in drv260x_worker()
228 dev_err(&haptics->client->dev, in drv260x_worker()
238 haptics->mode = DRV260X_LRA_NO_CAL_MODE; in drv260x_haptics_play()
241 if (effect->u.rumble.strong_magnitude > 0) in drv260x_haptics_play()
242 haptics->magnitude = effect->u.rumble.strong_magnitude >> 8; in drv260x_haptics_play()
243 else if (effect->u.rumble.weak_magnitude > 0) in drv260x_haptics_play()
244 haptics->magnitude = effect->u.rumble.weak_magnitude >> 8; in drv260x_haptics_play()
246 haptics->magnitude = 0; in drv260x_haptics_play()
248 schedule_work(&haptics->work); in drv260x_haptics_play()
258 cancel_work_sync(&haptics->work); in drv260x_close()
260 error = regmap_write(haptics->regmap, DRV260X_MODE, DRV260X_STANDBY); in drv260x_close()
262 dev_err(&haptics->client->dev, in drv260x_close()
265 gpiod_set_value(haptics->enable_gpio, 0); in drv260x_close()
312 error = regmap_write(haptics->regmap, in drv260x_init()
313 DRV260X_RATED_VOLT, haptics->rated_voltage); in drv260x_init()
315 dev_err(&haptics->client->dev, in drv260x_init()
321 error = regmap_write(haptics->regmap, in drv260x_init()
322 DRV260X_OD_CLAMP_VOLT, haptics->overdrive_voltage); in drv260x_init()
324 dev_err(&haptics->client->dev, in drv260x_init()
330 switch (haptics->mode) { in drv260x_init()
332 error = regmap_register_patch(haptics->regmap, in drv260x_init()
336 dev_err(&haptics->client->dev, in drv260x_init()
345 error = regmap_register_patch(haptics->regmap, in drv260x_init()
349 dev_err(&haptics->client->dev, in drv260x_init()
355 error = regmap_update_bits(haptics->regmap, DRV260X_LIB_SEL, in drv260x_init()
357 haptics->library); in drv260x_init()
359 dev_err(&haptics->client->dev, in drv260x_init()
368 error = regmap_register_patch(haptics->regmap, in drv260x_init()
372 dev_err(&haptics->client->dev, in drv260x_init()
378 error = regmap_update_bits(haptics->regmap, DRV260X_LIB_SEL, in drv260x_init()
380 haptics->library); in drv260x_init()
382 dev_err(&haptics->client->dev, in drv260x_init()
392 error = regmap_write(haptics->regmap, DRV260X_GO, DRV260X_GO_BIT); in drv260x_init()
394 dev_err(&haptics->client->dev, in drv260x_init()
402 error = regmap_read(haptics->regmap, DRV260X_GO, &cal_buf); in drv260x_init()
404 dev_err(&haptics->client->dev, in drv260x_init()
424 struct device *dev = &client->dev; in drv260x_probe()
431 return -ENOMEM; in drv260x_probe()
433 error = device_property_read_u32(dev, "mode", &haptics->mode); in drv260x_probe()
439 if (haptics->mode < DRV260X_LRA_MODE || in drv260x_probe()
440 haptics->mode > DRV260X_ERM_MODE) { in drv260x_probe()
441 dev_err(dev, "Vibrator mode is invalid: %i\n", haptics->mode); in drv260x_probe()
442 return -EINVAL; in drv260x_probe()
445 error = device_property_read_u32(dev, "library-sel", &haptics->library); in drv260x_probe()
447 dev_err(dev, "Can't fetch 'library-sel' property: %d\n", error); in drv260x_probe()
451 if (haptics->library < DRV260X_LIB_EMPTY || in drv260x_probe()
452 haptics->library > DRV260X_ERM_LIB_F) { in drv260x_probe()
454 "Library value is invalid: %i\n", haptics->library); in drv260x_probe()
455 return -EINVAL; in drv260x_probe()
458 if (haptics->mode == DRV260X_LRA_MODE && in drv260x_probe()
459 haptics->library != DRV260X_LIB_EMPTY && in drv260x_probe()
460 haptics->library != DRV260X_LIB_LRA) { in drv260x_probe()
462 return -EINVAL; in drv260x_probe()
465 if (haptics->mode == DRV260X_ERM_MODE && in drv260x_probe()
466 (haptics->library == DRV260X_LIB_EMPTY || in drv260x_probe()
467 haptics->library == DRV260X_LIB_LRA)) { in drv260x_probe()
469 return -EINVAL; in drv260x_probe()
472 error = device_property_read_u32(dev, "vib-rated-mv", &voltage); in drv260x_probe()
473 haptics->rated_voltage = error ? DRV260X_DEF_RATED_VOLT : in drv260x_probe()
476 error = device_property_read_u32(dev, "vib-overdrive-mv", &voltage); in drv260x_probe()
477 haptics->overdrive_voltage = error ? DRV260X_DEF_OD_CLAMP_VOLT : in drv260x_probe()
480 haptics->regulator = devm_regulator_get(dev, "vbat"); in drv260x_probe()
481 if (IS_ERR(haptics->regulator)) { in drv260x_probe()
482 error = PTR_ERR(haptics->regulator); in drv260x_probe()
487 haptics->enable_gpio = devm_gpiod_get_optional(dev, "enable", in drv260x_probe()
489 if (IS_ERR(haptics->enable_gpio)) in drv260x_probe()
490 return PTR_ERR(haptics->enable_gpio); in drv260x_probe()
492 haptics->input_dev = devm_input_allocate_device(dev); in drv260x_probe()
493 if (!haptics->input_dev) { in drv260x_probe()
495 return -ENOMEM; in drv260x_probe()
498 haptics->input_dev->name = "drv260x:haptics"; in drv260x_probe()
499 haptics->input_dev->close = drv260x_close; in drv260x_probe()
500 input_set_drvdata(haptics->input_dev, haptics); in drv260x_probe()
501 input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE); in drv260x_probe()
503 error = input_ff_create_memless(haptics->input_dev, NULL, in drv260x_probe()
510 INIT_WORK(&haptics->work, drv260x_worker); in drv260x_probe()
512 haptics->client = client; in drv260x_probe()
515 haptics->regmap = devm_regmap_init_i2c(client, &drv260x_regmap_config); in drv260x_probe()
516 if (IS_ERR(haptics->regmap)) { in drv260x_probe()
517 error = PTR_ERR(haptics->regmap); in drv260x_probe()
528 error = input_register_device(haptics->input_dev); in drv260x_probe()
542 mutex_lock(&haptics->input_dev->mutex); in drv260x_suspend()
544 if (input_device_enabled(haptics->input_dev)) { in drv260x_suspend()
545 ret = regmap_update_bits(haptics->regmap, in drv260x_suspend()
554 gpiod_set_value(haptics->enable_gpio, 0); in drv260x_suspend()
556 ret = regulator_disable(haptics->regulator); in drv260x_suspend()
559 regmap_update_bits(haptics->regmap, in drv260x_suspend()
565 mutex_unlock(&haptics->input_dev->mutex); in drv260x_suspend()
574 mutex_lock(&haptics->input_dev->mutex); in drv260x_resume()
576 if (input_device_enabled(haptics->input_dev)) { in drv260x_resume()
577 ret = regulator_enable(haptics->regulator); in drv260x_resume()
583 ret = regmap_update_bits(haptics->regmap, in drv260x_resume()
588 regulator_disable(haptics->regulator); in drv260x_resume()
592 gpiod_set_value(haptics->enable_gpio, 1); in drv260x_resume()
596 mutex_unlock(&haptics->input_dev->mutex); in drv260x_resume()
620 .name = "drv260x-haptics",