25 #include <linux/module.h>
27 #include <linux/slab.h>
31 #include <linux/input.h>
37 #define MAX8997_MOTOR_TYPE_SHIFT 7
38 #define MAX8997_ENABLE_SHIFT 6
39 #define MAX8997_MODE_SHIFT 5
42 #define MAX8997_CYCLE_SHIFT 6
43 #define MAX8997_SIG_PERIOD_SHIFT 4
44 #define MAX8997_SIG_DUTY_SHIFT 2
45 #define MAX8997_PWM_DUTY_SHIFT 0
82 for (i = 0; i <= 64; i++) {
83 if (chip->
level <= i * 100 / 64) {
178 error = max8997_haptic_set_duty_cycle(chip);
180 dev_err(chip->
dev,
"set_pwm_cycle failed, error: %d\n", error);
187 max8997_haptic_configure(chip);
202 max8997_haptic_configure(chip);
217 max8997_haptic_enable(chip);
219 max8997_haptic_disable(chip);
236 static void max8997_haptic_close(
struct input_dev *dev)
241 max8997_haptic_disable(chip);
248 dev_get_platdata(iodev->
dev);
252 struct input_dev *input_dev;
256 dev_err(&pdev->
dev,
"no haptic platform data\n");
261 input_dev = input_allocate_device();
262 if (!chip || !input_dev) {
263 dev_err(&pdev->
dev,
"unable to allocate memory\n");
279 switch (chip->
mode) {
291 if (IS_ERR(chip->
pwm)) {
292 error = PTR_ERR(chip->
pwm);
294 "unable to request PWM for haptic, error: %d\n",
302 "Invalid chip mode specified (%d)\n", chip->
mode);
311 "unable to get regulator, error: %d\n",
316 input_dev->name =
"max8997-haptic";
317 input_dev->id.version = 1;
318 input_dev->dev.parent = &pdev->
dev;
319 input_dev->close = max8997_haptic_close;
320 input_set_drvdata(input_dev, chip);
324 max8997_haptic_play_effect);
327 "unable to create FF device, error: %d\n",
329 goto err_put_regulator;
332 error = input_register_device(input_dev);
335 "unable to register input device, error: %d\n",
340 platform_set_drvdata(pdev, chip);
344 input_ff_destroy(input_dev);
351 input_free_device(input_dev);
361 input_unregister_device(chip->
input_dev);
372 #ifdef CONFIG_PM_SLEEP
373 static int max8997_haptic_suspend(
struct device *dev)
378 max8997_haptic_disable(chip);
387 {
"max8997-haptic", 0 },
394 .name =
"max8997-haptic",
396 .pm = &max8997_haptic_pm_ops,
398 .probe = max8997_haptic_probe,
400 .id_table = max8997_haptic_id,