aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/twl6040-vibra.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc/twl6040-vibra.c')
-rw-r--r--drivers/input/misc/twl6040-vibra.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index 23855e12a30b..ad153a417eed 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -74,12 +74,12 @@ static irqreturn_t twl6040_vib_irq_handler(int irq, void *data)
74 if (status & TWL6040_VIBLOCDET) { 74 if (status & TWL6040_VIBLOCDET) {
75 dev_warn(info->dev, "Left Vibrator overcurrent detected\n"); 75 dev_warn(info->dev, "Left Vibrator overcurrent detected\n");
76 twl6040_clear_bits(twl6040, TWL6040_REG_VIBCTLL, 76 twl6040_clear_bits(twl6040, TWL6040_REG_VIBCTLL,
77 TWL6040_VIBENAL); 77 TWL6040_VIBENA);
78 } 78 }
79 if (status & TWL6040_VIBROCDET) { 79 if (status & TWL6040_VIBROCDET) {
80 dev_warn(info->dev, "Right Vibrator overcurrent detected\n"); 80 dev_warn(info->dev, "Right Vibrator overcurrent detected\n");
81 twl6040_clear_bits(twl6040, TWL6040_REG_VIBCTLR, 81 twl6040_clear_bits(twl6040, TWL6040_REG_VIBCTLR,
82 TWL6040_VIBENAR); 82 TWL6040_VIBENA);
83 } 83 }
84 84
85 return IRQ_HANDLED; 85 return IRQ_HANDLED;
@@ -97,23 +97,23 @@ static void twl6040_vibra_enable(struct vibra_info *info)
97 } 97 }
98 98
99 twl6040_power(info->twl6040, 1); 99 twl6040_power(info->twl6040, 1);
100 if (twl6040->rev <= TWL6040_REV_ES1_1) { 100 if (twl6040_get_revid(twl6040) <= TWL6040_REV_ES1_1) {
101 /* 101 /*
102 * ERRATA: Disable overcurrent protection for at least 102 * ERRATA: Disable overcurrent protection for at least
103 * 3ms when enabling vibrator drivers to avoid false 103 * 3ms when enabling vibrator drivers to avoid false
104 * overcurrent detection 104 * overcurrent detection
105 */ 105 */
106 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLL, 106 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLL,
107 TWL6040_VIBENAL | TWL6040_VIBCTRLL); 107 TWL6040_VIBENA | TWL6040_VIBCTRL);
108 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLR, 108 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLR,
109 TWL6040_VIBENAR | TWL6040_VIBCTRLR); 109 TWL6040_VIBENA | TWL6040_VIBCTRL);
110 usleep_range(3000, 3500); 110 usleep_range(3000, 3500);
111 } 111 }
112 112
113 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLL, 113 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLL,
114 TWL6040_VIBENAL); 114 TWL6040_VIBENA);
115 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLR, 115 twl6040_reg_write(twl6040, TWL6040_REG_VIBCTLR,
116 TWL6040_VIBENAR); 116 TWL6040_VIBENA);
117 117
118 info->enabled = true; 118 info->enabled = true;
119} 119}
@@ -201,6 +201,13 @@ static int vibra_play(struct input_dev *input, void *data,
201 struct vibra_info *info = input_get_drvdata(input); 201 struct vibra_info *info = input_get_drvdata(input);
202 int ret; 202 int ret;
203 203
204 /* Do not allow effect, while the routing is set to use audio */
205 ret = twl6040_get_vibralr_status(info->twl6040);
206 if (ret & TWL6040_VIBSEL) {
207 dev_info(&input->dev, "Vibra is configured for audio\n");
208 return -EBUSY;
209 }
210
204 info->weak_speed = effect->u.rumble.weak_magnitude; 211 info->weak_speed = effect->u.rumble.weak_magnitude;
205 info->strong_speed = effect->u.rumble.strong_magnitude; 212 info->strong_speed = effect->u.rumble.strong_magnitude;
206 info->direction = effect->direction < EFFECT_DIR_180_DEG ? 1 : -1; 213 info->direction = effect->direction < EFFECT_DIR_180_DEG ? 1 : -1;