• Home
  • Raw
  • Download

Lines Matching refs:chip

70 static int max8997_haptic_set_duty_cycle(struct max8997_haptic *chip)  in max8997_haptic_set_duty_cycle()  argument
74 if (chip->mode == MAX8997_EXTERNAL_MODE) { in max8997_haptic_set_duty_cycle()
75 unsigned int duty = chip->pwm_period * chip->level / 100; in max8997_haptic_set_duty_cycle()
76 ret = pwm_config(chip->pwm, duty, chip->pwm_period); in max8997_haptic_set_duty_cycle()
82 if (chip->level <= i * 100 / 64) { in max8997_haptic_set_duty_cycle()
87 switch (chip->internal_mode_pattern) { in max8997_haptic_set_duty_cycle()
89 max8997_write_reg(chip->client, in max8997_haptic_set_duty_cycle()
93 max8997_write_reg(chip->client, in max8997_haptic_set_duty_cycle()
97 max8997_write_reg(chip->client, in max8997_haptic_set_duty_cycle()
101 max8997_write_reg(chip->client, in max8997_haptic_set_duty_cycle()
111 static void max8997_haptic_configure(struct max8997_haptic *chip) in max8997_haptic_configure() argument
115 value = chip->type << MAX8997_MOTOR_TYPE_SHIFT | in max8997_haptic_configure()
116 chip->enabled << MAX8997_ENABLE_SHIFT | in max8997_haptic_configure()
117 chip->mode << MAX8997_MODE_SHIFT | chip->pwm_divisor; in max8997_haptic_configure()
118 max8997_write_reg(chip->client, MAX8997_HAPTIC_REG_CONF2, value); in max8997_haptic_configure()
120 if (chip->mode == MAX8997_INTERNAL_MODE && chip->enabled) { in max8997_haptic_configure()
121 value = chip->internal_mode_pattern << MAX8997_CYCLE_SHIFT | in max8997_haptic_configure()
122 chip->internal_mode_pattern << MAX8997_SIG_PERIOD_SHIFT | in max8997_haptic_configure()
123 chip->internal_mode_pattern << MAX8997_SIG_DUTY_SHIFT | in max8997_haptic_configure()
124 chip->internal_mode_pattern << MAX8997_PWM_DUTY_SHIFT; in max8997_haptic_configure()
125 max8997_write_reg(chip->client, in max8997_haptic_configure()
128 switch (chip->internal_mode_pattern) { in max8997_haptic_configure()
130 value = chip->pattern_cycle << 4; in max8997_haptic_configure()
131 max8997_write_reg(chip->client, in max8997_haptic_configure()
133 value = chip->pattern_signal_period; in max8997_haptic_configure()
134 max8997_write_reg(chip->client, in max8997_haptic_configure()
139 value = chip->pattern_cycle; in max8997_haptic_configure()
140 max8997_write_reg(chip->client, in max8997_haptic_configure()
142 value = chip->pattern_signal_period; in max8997_haptic_configure()
143 max8997_write_reg(chip->client, in max8997_haptic_configure()
148 value = chip->pattern_cycle << 4; in max8997_haptic_configure()
149 max8997_write_reg(chip->client, in max8997_haptic_configure()
151 value = chip->pattern_signal_period; in max8997_haptic_configure()
152 max8997_write_reg(chip->client, in max8997_haptic_configure()
157 value = chip->pattern_cycle; in max8997_haptic_configure()
158 max8997_write_reg(chip->client, in max8997_haptic_configure()
160 value = chip->pattern_signal_period; in max8997_haptic_configure()
161 max8997_write_reg(chip->client, in max8997_haptic_configure()
171 static void max8997_haptic_enable(struct max8997_haptic *chip) in max8997_haptic_enable() argument
175 mutex_lock(&chip->mutex); in max8997_haptic_enable()
177 error = max8997_haptic_set_duty_cycle(chip); in max8997_haptic_enable()
179 dev_err(chip->dev, "set_pwm_cycle failed, error: %d\n", error); in max8997_haptic_enable()
183 if (!chip->enabled) { in max8997_haptic_enable()
184 error = regulator_enable(chip->regulator); in max8997_haptic_enable()
186 dev_err(chip->dev, "Failed to enable regulator\n"); in max8997_haptic_enable()
189 max8997_haptic_configure(chip); in max8997_haptic_enable()
190 if (chip->mode == MAX8997_EXTERNAL_MODE) { in max8997_haptic_enable()
191 error = pwm_enable(chip->pwm); in max8997_haptic_enable()
193 dev_err(chip->dev, "Failed to enable PWM\n"); in max8997_haptic_enable()
194 regulator_disable(chip->regulator); in max8997_haptic_enable()
198 chip->enabled = true; in max8997_haptic_enable()
202 mutex_unlock(&chip->mutex); in max8997_haptic_enable()
205 static void max8997_haptic_disable(struct max8997_haptic *chip) in max8997_haptic_disable() argument
207 mutex_lock(&chip->mutex); in max8997_haptic_disable()
209 if (chip->enabled) { in max8997_haptic_disable()
210 chip->enabled = false; in max8997_haptic_disable()
211 max8997_haptic_configure(chip); in max8997_haptic_disable()
212 if (chip->mode == MAX8997_EXTERNAL_MODE) in max8997_haptic_disable()
213 pwm_disable(chip->pwm); in max8997_haptic_disable()
214 regulator_disable(chip->regulator); in max8997_haptic_disable()
217 mutex_unlock(&chip->mutex); in max8997_haptic_disable()
222 struct max8997_haptic *chip = in max8997_haptic_play_effect_work() local
225 if (chip->level) in max8997_haptic_play_effect_work()
226 max8997_haptic_enable(chip); in max8997_haptic_play_effect_work()
228 max8997_haptic_disable(chip); in max8997_haptic_play_effect_work()
234 struct max8997_haptic *chip = input_get_drvdata(dev); in max8997_haptic_play_effect() local
236 chip->level = effect->u.rumble.strong_magnitude; in max8997_haptic_play_effect()
237 if (!chip->level) in max8997_haptic_play_effect()
238 chip->level = effect->u.rumble.weak_magnitude; in max8997_haptic_play_effect()
240 schedule_work(&chip->work); in max8997_haptic_play_effect()
247 struct max8997_haptic *chip = input_get_drvdata(dev); in max8997_haptic_close() local
249 cancel_work_sync(&chip->work); in max8997_haptic_close()
250 max8997_haptic_disable(chip); in max8997_haptic_close()
259 struct max8997_haptic *chip; in max8997_haptic_probe() local
271 chip = kzalloc(sizeof(struct max8997_haptic), GFP_KERNEL); in max8997_haptic_probe()
273 if (!chip || !input_dev) { in max8997_haptic_probe()
279 INIT_WORK(&chip->work, max8997_haptic_play_effect_work); in max8997_haptic_probe()
280 mutex_init(&chip->mutex); in max8997_haptic_probe()
282 chip->client = iodev->haptic; in max8997_haptic_probe()
283 chip->dev = &pdev->dev; in max8997_haptic_probe()
284 chip->input_dev = input_dev; in max8997_haptic_probe()
285 chip->pwm_period = haptic_pdata->pwm_period; in max8997_haptic_probe()
286 chip->type = haptic_pdata->type; in max8997_haptic_probe()
287 chip->mode = haptic_pdata->mode; in max8997_haptic_probe()
288 chip->pwm_divisor = haptic_pdata->pwm_divisor; in max8997_haptic_probe()
290 switch (chip->mode) { in max8997_haptic_probe()
292 chip->internal_mode_pattern = in max8997_haptic_probe()
294 chip->pattern_cycle = haptic_pdata->pattern_cycle; in max8997_haptic_probe()
295 chip->pattern_signal_period = in max8997_haptic_probe()
300 chip->pwm = pwm_request(haptic_pdata->pwm_channel_id, in max8997_haptic_probe()
302 if (IS_ERR(chip->pwm)) { in max8997_haptic_probe()
303 error = PTR_ERR(chip->pwm); in max8997_haptic_probe()
313 "Invalid chip mode specified (%d)\n", chip->mode); in max8997_haptic_probe()
318 chip->regulator = regulator_get(&pdev->dev, "inmotor"); in max8997_haptic_probe()
319 if (IS_ERR(chip->regulator)) { in max8997_haptic_probe()
320 error = PTR_ERR(chip->regulator); in max8997_haptic_probe()
331 input_set_drvdata(input_dev, chip); in max8997_haptic_probe()
351 platform_set_drvdata(pdev, chip); in max8997_haptic_probe()
357 regulator_put(chip->regulator); in max8997_haptic_probe()
359 if (chip->mode == MAX8997_EXTERNAL_MODE) in max8997_haptic_probe()
360 pwm_free(chip->pwm); in max8997_haptic_probe()
363 kfree(chip); in max8997_haptic_probe()
370 struct max8997_haptic *chip = platform_get_drvdata(pdev); in max8997_haptic_remove() local
372 input_unregister_device(chip->input_dev); in max8997_haptic_remove()
373 regulator_put(chip->regulator); in max8997_haptic_remove()
375 if (chip->mode == MAX8997_EXTERNAL_MODE) in max8997_haptic_remove()
376 pwm_free(chip->pwm); in max8997_haptic_remove()
378 kfree(chip); in max8997_haptic_remove()
386 struct max8997_haptic *chip = platform_get_drvdata(pdev); in max8997_haptic_suspend() local
388 max8997_haptic_disable(chip); in max8997_haptic_suspend()