void max77828_vibtonz_en(bool en) { if (g_hap_data == NULL) { return ; } if (en) { if (g_hap_data->running) return; max77828_haptic_i2c(g_hap_data, true); g_hap_data->running = true; } else { if (!g_hap_data->running) return; max77828_haptic_i2c(g_hap_data, false); g_hap_data->running = false; } }
void vibtonz_en(bool en) { if (g_hap_data == NULL) { pr_err("[VIB] the motor is not ready!!!"); return ; } if (en) { if (g_hap_data->running) return; max77828_haptic_i2c(g_hap_data, true); pwm_config(g_hap_data->pwm, prev_duty, g_hap_data->pdata->period); pwm_enable(g_hap_data->pwm); if (g_hap_data->pdata->motor_en) g_hap_data->pdata->motor_en(true); else { int ret; ret = regulator_enable(g_hap_data->regulator); pr_info("regulator_enable returns %d\n", ret); } g_hap_data->running = true; } else { if (!g_hap_data->running) return; if (g_hap_data->pdata->motor_en) g_hap_data->pdata->motor_en(false); else regulator_disable(g_hap_data->regulator); pwm_disable(g_hap_data->pwm); max77828_haptic_i2c(g_hap_data, false); g_hap_data->running = false; } }
static void haptic_work(struct work_struct *work) { struct max77828_haptic_data *hap_data = container_of(work, struct max77828_haptic_data, work); pr_info("[VIB] %s\n", __func__); if (hap_data->timeout > 0) { if (hap_data->running) return; max77828_haptic_i2c(hap_data, true); pwm_config(hap_data->pwm, hap_data->pdata->duty, hap_data->pdata->period); pwm_enable(hap_data->pwm); if (hap_data->pdata->motor_en) hap_data->pdata->motor_en(true); else { int ret; ret = regulator_enable(hap_data->regulator); pr_info("regulator_enable returns %d\n", ret); } hap_data->running = true; } else { if (!hap_data->running) return; if (hap_data->pdata->motor_en) hap_data->pdata->motor_en(false); else regulator_disable(hap_data->regulator); pwm_disable(hap_data->pwm); max77828_haptic_i2c(hap_data, false); hap_data->running = false; } return; }
static int __devinit max77828_haptic_probe(struct platform_device *pdev) { int error = 0; struct max77828_dev *max77828 = dev_get_drvdata(pdev->dev.parent); struct max77828_platform_data *max77828_pdata = dev_get_platdata(max77828->dev); #ifdef CONFIG_SS_VIBRATOR struct max77828_haptic_platform_data *pdata = max77828_pdata->haptic_data; #endif struct max77828_haptic_data *hap_data; pr_err("[VIB] ++ %s\n", __func__); if (pdata == NULL) { pr_err("%s: no pdata\n", __func__); return -ENODEV; } hap_data = kzalloc(sizeof(struct max77828_haptic_data), GFP_KERNEL); if (!hap_data) return -ENOMEM; g_hap_data = hap_data; g_hap_data->reg = MOTOR_LRA | DIVIDER_128; hap_data->max77828 = max77828; hap_data->i2c = max77828->i2c; hap_data->pdata = pdata; platform_set_drvdata(pdev, hap_data); max77828_haptic_i2c(hap_data, true); spin_lock_init(&(hap_data->lock)); pr_err("[VIB] -- %s\n", __func__); return error; }