Exemplo n.º 1
0
static int vibrator_probe(struct platform_device *pdev)
{
	int ret = 0;

#if defined(CONFIG_HAS_WAKELOCK)
	wake_lock_init(&vib_wl, WAKE_LOCK_SUSPEND, __stringify(vib_wl));
#endif
	
	/* Setup timed_output obj */
	vibrator_timed_dev.name = "vibrator";
	vibrator_timed_dev.enable = vibrator_enable_set_timeout;
	vibrator_timed_dev.get_time = vibrator_get_remaining_time;
	vib_voltage = pdev->voltage;

	/* Vibrator dev register in /sys/class/timed_output/ */
	ret = timed_output_dev_register(&vibrator_timed_dev);
	if (ret < 0) {
		printk(KERN_ERR "Vibrator: timed_output dev registration failure\n");
		timed_output_dev_unregister(&vibrator_timed_dev);
	}

	init_timer(&vibrate_timer);
	vibrate_timer.function = on_vibrate_timer_expired;
	vibrate_timer.data = (unsigned long)NULL;
	INIT_WORK(&vibrator_off_work,
		 vibrator_off_worker);
	Is_vib_shortly = false;
	return 0;
}
static int incident_led_blink_probe(struct platform_device *pdev)
{
  int ret =0;
  struct incident_led_blink_data *data;
  data = kzalloc(sizeof(struct incident_led_blink_data) ,GFP_KERNEL);
  if (!data)
    return -ENOMEM;
  
  INIT_WORK(&data->work_incident_led_blink_on, incident_led_blink_on);
  INIT_WORK(&data->work_incident_led_blink_off, incident_led_blink_off);
  INIT_WORK(&data->work_incident_led_on_all_long, incident_led_on_all_long);

  hrtimer_init(&data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  data->timer.function = incident_led_blink_timer_func;
  spin_lock_init(&data->lock);

  data->dev.name = "incident_led";
  data->dev.get_time = incident_led_blink_get_time;
  data->dev.enable = incident_led_blink_enable;
	
  ret = timed_output_dev_register(&data->dev);
  if (ret < 0){
    timed_output_dev_unregister(&data->dev);
    kfree(data);
    return ret;
  }
  platform_set_drvdata(pdev, data);
  return 0;
}
Exemplo n.º 3
0
static int vibrator_probe(struct platform_device *pdev)
{
	int ret;
	data = kzalloc(sizeof(struct vibrator_data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data->regulator = regulator_get(NULL, "vdd_vbrtr");
	if (IS_ERR_OR_NULL(data->regulator)) {
		pr_err("vibrator_init:Couldn't get regulator vdd_vbrtr\n");
		data->regulator = NULL;
		ret = PTR_ERR(data->regulator);
		goto err;
	}
	hrtimer_init(&data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	/* Intialize the work queue */
	INIT_WORK(&data->work, vibrator_work_func);
	data->timer.function = vibrator_timer_func;
	data->dev = vibrator_dev;
	data->vibrator_on = false;

	ret = timed_output_dev_register(&data->dev);
	if (ret)
		goto err2;

	return 0;

err2:
	regulator_put(data->regulator);
err:
	kfree(data);
	return ret;
}
Exemplo n.º 4
0
static void vibetonz_start(void)
{
	int ret = 0;

	//printk("[VIBETONZ] %s : \n",__func__);
	spin_lock_init(&vib_lock);

	/* hrtimer settings */
	hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	timer.function = vibetonz_timer_func;

	if (gpio_is_valid(GPIO_VIB_EN)) {
		if (gpio_request(GPIO_VIB_EN, S3C_GPIO_LAVEL(GPIO_VIB_EN))) 
			printk(KERN_ERR "Failed to request GPIO_VIB_EN!\n");
		gpio_direction_output(GPIO_VIB_EN,0);
		mdelay(10);
		gpio_set_value(GPIO_VIB_EN, GPIO_LEVEL_LOW);
	}
	s3c_gpio_setpull(GPIO_VIB_EN, S3C_GPIO_PULL_NONE);

	/* pwm timer settings */
	s3c6410_timer_setup(1,10,VIBRATOR_ON_STRONG_PERIOD, VIBRATOR_OFF_STRONG_PERIOD);
	
	/* timed_output_device settings */
	ret = timed_output_dev_register(&timed_output_vt);
	if(ret)
		printk(KERN_ERR "[VIBETONZ] timed_output_dev_register is fail \n");	
}
Exemplo n.º 5
0
static int __init s3c_keypad_probe(struct platform_device *pdev)
{
	int ret;
	struct input_dev *input_dev;
	struct s3c_keypad *s3c_keypad;

	if (device_create_file(&(pdev->dev), &dev_attr_key_pressed) < 0) {
		printk("%s s3c_keypad_probe\n",__FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
			dev_attr_key_pressed.attr.name);
	}

#ifdef FLASH_MOVIE_MODE
        /* hrtimer settings */
        hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        timer.function = aat1271_flash_timer_func;

        timed_output_dev_register(&timed_output_flash);

#endif

	return 0;


}
static int msm_vibrator_probe(struct platform_device *pdev)
{
	int rc = 0;
	struct vibrator_platform_data_motor *pdata;
	if (pdev->dev.platform_data == NULL) {
			printk("Platform data is null");
			return -EINVAL;
		} else {
			pdata = pdev->dev.platform_data;
			vibrator_drvdata.power_onoff = pdata->power_onoff;
			}

	printk("[VIB] Probe function is called\n");

	INIT_WORK(&work_vibrator_on, msm_vibrator_on);
	INIT_WORK(&work_vibrator_off, msm_vibrator_off);

	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	rc = timed_output_dev_register(&msm_vibrator);
	if (rc < 0) {
		goto err_read_vib;
	}
	return 0;

err_read_vib:
	printk(KERN_ERR "[VIB] timed_output_dev_register fail (rc=%d)\n", rc);
	return rc;
}
Exemplo n.º 7
0
static int android_vibrator_probe(struct platform_device *pdev)
{
	int ret = 0;

	vibe_data = (struct android_vibrator_platform_data *)pdev->dev.platform_data;
	atomic_set(&vibe_gain,vibe_data->amp_value);
	vibe_data->pwm_set(1, 32);

	if (android_vibrator_intialize() < 0) {
		printk(KERN_ERR "Android Vibrator Initialization was failed\n");
		return -1;
	}

	android_vibrator_force_set(0); /* disable vibrator */

	hrtimer_init(&android_vibrator_data.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	android_vibrator_data.timer.function = vibrator_timer_func;
	spin_lock_init(&android_vibrator_data.lock);

	ret = timed_output_dev_register(&android_vibrator_data.dev);
	if (ret < 0) {
		timed_output_dev_unregister(&android_vibrator_data.dev);
		return -ENODEV;
	}

	ret = device_create_file(android_vibrator_data.dev.dev, &dev_attr_amp);
	if (ret < 0) {
		timed_output_dev_unregister(&android_vibrator_data.dev);
		device_remove_file(android_vibrator_data.dev.dev, &dev_attr_amp);
		return -ENODEV;
	}
	
	printk(KERN_INFO "LGE: Android Vibrator Initialization was done\n");
	return 0;
}
Exemplo n.º 8
0
int aat1271a_flash_init(void)
{	

	int ret;


	/* hrtimer settings */
	hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	timer.function = aat1271_flash_timer_func;


	if (gpio_is_valid(GPIO_CAM_FLASH_SET)) {
		if (gpio_request(GPIO_CAM_FLASH_SET, S3C_GPIO_LAVEL(GPIO_CAM_FLASH_SET))) 
			printk(KERN_ERR "Failed to request GPIO_CAM_FLASH_SET!\n");
		gpio_direction_output(GPIO_CAM_FLASH_SET, GPIO_LEVEL_LOW);
	}
	s3c_gpio_setpull(GPIO_CAM_FLASH_SET, S3C_GPIO_PULL_NONE);

	if (gpio_is_valid(GPIO_CAM_FLASH_EN)) {
		if (gpio_request(GPIO_CAM_FLASH_EN, S3C_GPIO_LAVEL(GPIO_CAM_FLASH_EN))) 
			printk(KERN_ERR "Failed to request GPIO_CAM_FLASH_EN!\n");
		gpio_direction_output(GPIO_CAM_FLASH_EN, GPIO_LEVEL_LOW);
	}
	s3c_gpio_setpull(GPIO_CAM_FLASH_EN, S3C_GPIO_PULL_NONE);
	
	/* timed_output_device settings */
	ret = timed_output_dev_register(&timed_output_flash);
	if(ret)
		printk(KERN_ERR "[VIBETONZ] timed_output_dev_register is fail \n");

}
Exemplo n.º 9
0
	void __init mx6_motor_init()  
	{  
	     int ret =0;  
	     hrtimer_init(&vibdata.timer,CLOCK_MONOTONIC, HRTIMER_MODE_REL);//初始化定时器  
	     vibdata.timer.function= mx6_vibrator_timer_func;           //设置回调函数  
	     INIT_WORK(&vibdata.work,mx6_vibrator_work);    //初始化工作队列  
	     ret =gpio_request(SABRESD_VIBRATOR_CTL, "vibrator-en");    //申请IO  
	     if (ret< 0)  
	     {  
		       printk("vibratorrequest IO err!:%d\n",ret);  
		       returnret;  
	     }  
	     wake_lock_init(&vibdata.wklock,WAKE_LOCK_SUSPEND, "vibrator"); //初始化 wake_lock  
	     mutex_init(&vibdata.lock);             //初始化 互斥锁  
	     ret=timed_output_dev_register(&mx6_motot_driver);		//注册timed_output 设备  
	     if (ret< 0)  
		       gotoerr_to_dev_reg;  
	     return 0;  
	err_to_dev_reg:          					 //错误了 就释放所有资源  
	     mutex_destroy(&vibdata.lock);  
	     wake_lock_destroy(&vibdata.wklock);  

	     gpio_free(+_VIBRATOR_CTL);  
	     printk("vibrator   err!:%d\n",ret);  
	     returnret;  
	      
	}  
static int __init vibrator_init(void)
{
	int ret;
	/*
	 * Use GMI_AD15 pin as a software-controlled GPIO
	 * to control vibrator
	 */
	printk(KERN_INFO "%s+ #####\n", __func__);
	ret = gpio_request(TEGRA_GPIO_PH7, "ENB_VIB");
	if (ret) {
		pr_info("[VIB]: gpio_request failed.\n");
		gpio_free(TEGRA_GPIO_PH7);
		return ret;
	}
	tegra_gpio_enable(TEGRA_GPIO_PH7);

	/* Turn off vibrator in default*/
	gpio_direction_output(TEGRA_GPIO_PH7, 0);

	init_timer(&v_timer);
	v_timer.expires = jiffies;
	v_timer.data = 0;
	v_timer.function = stop_vibrator;
	ret = timed_output_dev_register(&tegra_vibrator);

	if (ret)
		pr_info("[VIB]: timed_output_dev_register failed.\n");
	printk(KERN_INFO "%s- #####\n", __func__);
	return ret;
}
static int msm_vibrator_probe(struct platform_device *pdev)
{
	int rc = 0;

	printk("[VIB] Prob\n");

	INIT_WORK(&work_vibrator_on, msm_vibrator_on);
	INIT_WORK(&work_vibrator_off, msm_vibrator_off);

	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	rc = timed_output_dev_register(&msm_vibrator);
	if (rc < 0) {
		goto err_read_vib;
	}

	if (board_hw_revision >= 7)	
	gpio_tlmm_config(GPIO_CFG(MOTOR_EN_GPIO, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_10MA),GPIO_CFG_ENABLE);

	return 0;

err_read_vib:
	printk(KERN_ERR "[VIB] timed_output_dev_register fail (rc=%d)\n", rc);
	return rc;
}
static int __init sprd_init_vibrator(void)
{
	int ret = 0;
	
	vibrator_hw_init();

#if defined(CONFIG_HAS_WAKELOCK)
	wake_lock_init(&vib_wl, WAKE_LOCK_SUSPEND, __stringify(vib_wl));
#endif

	ret = timed_output_dev_register(&sprd_vibrator);
	if (ret < 0) {
		printk(KERN_ERR "Vibrator: timed_output dev registration failure\n");
		goto error;
	}

	vib_workqueue = create_workqueue("vib_wq");
	INIT_DELAYED_WORK(&vibrator_off_work, vibrator_off_worker);

	return 0;

error:
#if defined(CONFIG_HAS_WAKELOCK)
	wake_lock_destroy(&vib_wl);
#endif
	return ret;
}
Exemplo n.º 13
0
static int __devinit lc898300_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	struct lc898300_data *data;
	int rc;

	if (!i2c_check_functionality(client->adapter,
				I2C_FUNC_SMBUS_BYTE_DATA))
		return -EIO;

	if (!client->dev.platform_data)
		return -EIO;

	data = kzalloc(sizeof(struct lc898300_data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data->client = client;
	data->dev    = &client->dev;
	data->pdata  = client->dev.platform_data;
	data->on = false;
	mutex_init(&data->lock);

	i2c_set_clientdata(client, data);

	rc = data->pdata->gpio_allocate(data->dev);
	if (rc)
		goto error;
	rc = data->pdata->power_config(data->dev, true);
	if (rc)
		goto error_gpio_release;

	rc = lc898300_resume(data);
	if (rc) {
		dev_err(&client->dev, "Configure failed rc = %d\n", rc);
		goto error;
	}

	hrtimer_init(&data->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	data->vib_timer.function = vibrator_timer_func;

	data->timed_dev.name = data->pdata->name;
	data->timed_dev.get_time = lc898300_vib_get_time;
	data->timed_dev.enable = lc898300_vib_enable;

	rc = timed_output_dev_register(&data->timed_dev);
	if (rc < 0)
		goto error;

	return rc;

error_gpio_release:
	data->pdata->gpio_release(data->dev);

error:
	i2c_set_clientdata(client, NULL);
	kfree(data);
	return rc;
}
Exemplo n.º 14
0
	void mx6_motor_exit()  
	{  
	     mutex_destroy(&vibdata.lock);  
	     wake_lock_destroy(&vibdata.wklock);  
	     gpio_free(SABRESD_VIBRATOR_CTL);  
	     printk("vibrator  exit!\n");  
	     timed_output_dev_register(&mx6_motot_driver);  
	}  
Exemplo n.º 15
0
void __init ImmVibe_timed_output(void)
{
	INIT_WORK(&vibrator_work, ImmVibeSPI_Control);
	hrtimer_init(&vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib_timer.function = vibrator_timer_func;
	vib_state = 0; //Default is Vibrator OFF	
	timed_output_dev_register(&timed_dev);
}
Exemplo n.º 16
0
void __init msm_init_pmic_vibrator(void)
{
	INIT_WORK(&vibrator_work, update_vibrator);
	hrtimer_init(&vibrator_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibrator_timer.function = vibrator_timer_func;

	timed_output_dev_register(&pmic_vibrator);
}
Exemplo n.º 17
0
static int vib_pwm_probe(struct platform_device *pdev)
{
	struct vib_pwm_platform_data *pdata = pdev->dev.platform_data;
	struct vib_pwm_data *pwm_data;
	int ret = 0;

	if (!pdata) {
		ret = -EBUSY;
		printk(KERN_ERR "vib-pwm platform data is null\n");
		goto err0;
	}

	pwm_data = kzalloc(sizeof(struct vib_pwm_data), GFP_KERNEL);
	if (!pwm_data) {
		printk(KERN_ERR "vib-pwm: memory allocation failed\n");
		ret = -ENOMEM;
		goto err0;
	}

	pwm_data->pdata = pdata;

	INIT_WORK(&pwm_data->vib_work, vib_pwm_update);

	hrtimer_init(&pwm_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);

	pwm_data->timer.function = pwm_timer_func;
	spin_lock_init(&pwm_data->lock);

	pwm_data->dev.name = pdata->device_name;
	pwm_data->dev.get_time = vib_pwm_get_time;
	pwm_data->dev.enable = vib_pwm_enable;
	ret = timed_output_dev_register(&pwm_data->dev);
	if (ret < 0) {
		printk(KERN_ERR "timed o/p dev. lvib. registration failed\n");
		goto err1;
	}

	if (pwm_data->pdata->init)
		ret = pwm_data->pdata->init();
	if (ret < 0) {
		printk(KERN_ERR "vib-pwm: platform data not available\n");
		goto err2;
	}

	misc_data = pwm_data;
	platform_set_drvdata(pdev, pwm_data);

	printk(KERN_ALERT "vib-pwm probed\n");
	return 0;
err2:
	timed_output_dev_unregister(&pwm_data->dev);
err1:
	kfree(pwm_data);
err0:
	return ret;
}
Exemplo n.º 18
0
static int vib_gpio_probe(struct platform_device *pdev)
{
	struct vib_gpio_platform_data *pdata = pdev->dev.platform_data;
	struct vib_gpio_data *gpio_data;
	int ret = 0;

	if (!pdata) {
		ret = -EBUSY;
		goto err0;
	}

	gpio_data = kzalloc(sizeof(struct vib_gpio_data), GFP_KERNEL);
	if (!gpio_data) {
		ret = -ENOMEM;
		goto err0;
	}

	gpio_data->pdata = pdata;

	INIT_WORK(&gpio_data->vib_work, vib_gpio_update);

	hrtimer_init(&gpio_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);

	gpio_data->timer.function = gpio_timer_func;
	spin_lock_init(&gpio_data->lock);

	gpio_data->dev.name = "vibrator";
	gpio_data->dev.get_time = vib_gpio_get_time;
	gpio_data->dev.enable = vib_gpio_enable;
	ret = timed_output_dev_register(&gpio_data->dev);
	if (ret < 0)
		goto err1;

	if (gpio_data->pdata->init)
		ret = gpio_data->pdata->init();
	if (ret < 0)
		goto err2;

	gpio_direction_output(gpio_data->pdata->gpio,
			      gpio_data->pdata->active_low);

	misc_data = gpio_data;
	platform_set_drvdata(pdev, gpio_data);

	vib_gpio_enable(&gpio_data->dev, gpio_data->pdata->initial_vibrate);

	return 0;

err2:
	timed_output_dev_unregister(&gpio_data->dev);
err1:
	kfree(gpio_data->pdata);
	kfree(gpio_data);
err0:
	return ret;
}
Exemplo n.º 19
0
static int __init msm_init_pmic_vibrator(void)
{
	INIT_WORK(&work_vibrator_on, pmic_vibrator_on);
	INIT_WORK(&work_vibrator_off, pmic_vibrator_off);

	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	return timed_output_dev_register(&pmic_vibrator);
}
Exemplo n.º 20
0
static int __init vibrator_init(void)
{
	int status;

	status = timed_output_dev_register(&vibrator_dev);

	if (status) {
            printk("failed to register a timed_ouput dev\n");
    	}
	return status;
}
Exemplo n.º 21
0
void __init msm_init_pmic_vibrator(void)
{
	pr_info(ZHY_VIB_TAG" msm_init_pmic_vibrator\n");
	INIT_WORK(&work_vibrator_on, pmic_vibrator_on);
	INIT_WORK(&work_vibrator_off, pmic_vibrator_off);

	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&pmic_vibrator);
}
Exemplo n.º 22
0
static int vib_probe(struct platform_device *pdev)
{
	struct twl4030_codec_vibra_data *pdata = pdev->dev.platform_data;
	struct vib_data *data;
	int ret = 0;

	if (!pdata) {
		ret = -EBUSY;
		goto err0;
	}

	data = kzalloc(sizeof(struct vib_data), GFP_KERNEL);
	if (!data) {
		ret = -ENOMEM;
		goto err0;
	}

	data->pdata = pdata;
	data->twl6040 = dev_get_drvdata(pdev->dev.parent);

	INIT_WORK(&data->vib_work, vib_update);

	hrtimer_init(&data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);

	data->timer.function = vib_timer_func;
	spin_lock_init(&data->lock);

	data->dev.name = "vibrator";
	data->dev.get_time = vib_get_time;
	data->dev.enable = vib_enable;
	ret = timed_output_dev_register(&data->dev);
	if (ret < 0)
		goto err1;

	if (data->pdata->init)
		ret = data->pdata->init();
	if (ret < 0)
		goto err2;

	misc_data = data;
	platform_set_drvdata(pdev, data);

	twl6040_enable(data->twl6040);
	vib_enable(&data->dev, data->pdata->initial_vibrate);

	return 0;

err2:
	timed_output_dev_unregister(&data->dev);
err1:
	kfree(data);
err0:
	return ret;
}
Exemplo n.º 23
0
static void vibetonz_start(void)
{
	int ret = 0;

	hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	timer.function = vibetonz_timer_func;

	ret = timed_output_dev_register(&timed_output_vt);
	if(ret)
		printk(KERN_ERR "[VIBETONZ] timed_output_dev_register is fail \n");	
}
Exemplo n.º 24
0
void __init msm_init_pmic_vibrator(void)
{
	mutex_init(&vib_mutex);
	INIT_WORK(&work_vibrator_on, pmic_vibrator_on);
	INIT_DELAYED_WORK(&work_vibrator_off, pmic_vibrator_off);

	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&pmic_vibrator);
}
Exemplo n.º 25
0
// chui101: registers timed output device in sysfs so libhardware_legacy can interface
static void timed_output_register(void)
{
	int ret = 0;

	hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	timer.function = tspdrv_timer_callback;

	ret = timed_output_dev_register(&timed_output_tspdrv);
	if(ret)
		printk(KERN_ERR "[ImmVibe] timed_output_dev_register is fail \n");	
}
void __init msm_init_pmic_vibrator(void)
{
	INIT_WORK(&work_vibrator_on, pmic_vibrator_on);
	INIT_WORK(&work_vibrator_off, pmic_vibrator_off);

	vibe_workqueue = create_singlethread_workqueue("vibe_workqueue");
	spin_lock_init(&vibe_lock);
	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&pmic_vibrator);
}
Exemplo n.º 27
0
/*
** Called at initialization time to set PWM freq, disable amp, etc...
*/
VibeStatus ImmVibeSPI_ForceOut_Initialize(void)
{
    int Ret;

    /* Kick start the ISA1200 set up */
    Ret = isa1000_setup();
    if(Ret < 0)
    {
        printk(KERN_ERR "%s, ISA1000 initialization failed\n", __func__);
        return VIBE_E_FAIL;
    }

    /* Set PWM duty cycle to 50%, i.e. output level to 0 */
    isa1000_vib_set_level(0);

    /* Set PWM frequency */
    /* Xiaomi TODO: Please change to the PWM configuration procedures for
    **              setting the PWM output frequency on
    **              the Hong Mi 2A platform
    */

    /* Compute the period of PWM cycle */
    pwm_period_ns = NSEC_PER_SEC / PWM_FREQUENCY;

    /*add google interface*/
    vib_dev = kmalloc(sizeof(struct isa1000_vib),GFP_KERNEL);
    mutex_init(&vib_dev->lock);
    INIT_WORK(&vib_dev->work, isa1000_vib_update);

    hrtimer_init(&vib_dev->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    vib_dev->vib_timer.function = isa1000_vib_timer_func;
    vib_dev->timeout = ISA1000_VIB_DEFAULT_TIMEOUT;
    vib_dev->timed_dev.name = "vibrator";
    vib_dev->timed_dev.get_time = isa1000_vib_get_time;
    vib_dev->timed_dev.enable = isa1000_vib_enable;
    Ret = timed_output_dev_register(&vib_dev->timed_dev);
    if (Ret < 0){
	printk(KERN_ERR "%s, ISA1000 register failed\n", __func__);
        return VIBE_E_FAIL;
    }
    /**/

    Ret = device_create_file(vib_dev->timed_dev.dev, &dev_attr_amp);
    if (Ret < 0) {
	pr_err("[VIB] %s, create sysfs fail: amp\n", __func__);
    }

    /* Disable amp */
    ImmVibeSPI_ForceOut_AmpDisable(0);

    return VIBE_S_SUCCESS;
}
static int __init sun4i_vibrator_init(void)
{
	int vibe_used;
	int err = -1;

	pr_info("hello, sun4i_vibrator init\n");
	err = script_parser_fetch("motor_para", "motor_used",
					&vibe_used, sizeof(vibe_used)/sizeof(int));
	if(err) {
		pr_err("%s script_parser_fetch \"motor_para\" \"motor_used\" error = %d\n",
				__FUNCTION__, err);
		goto exit;
	}

	if(!vibe_used) {
		pr_err("%s motor is not used in config\n", __FUNCTION__);
		err = -1;
		goto exit;
	}

	err = script_parser_fetch("motor_para", "motor_shake",
					(int *)&vibe_gpio, sizeof(vibe_gpio)/sizeof(int));

	if(err) {
		pr_err("%s script_parser_fetch \"motor_para\" \"motor_shaked\" error = %d\n",
				__FUNCTION__, err);
		goto exit;
	}

	vibe_off = vibe_gpio.data;
	pr_debug("vibe_off is %d\n", vibe_off);

	vibe_gpio_handler = gpio_request_ex("motor_para", "motor_shake");

	if(!vibe_gpio_handler) {
		pr_err("%s request motor gpio err\n", __FUNCTION__);
		err = -1;
		goto exit;
	}

	INIT_WORK(&vibrator_work, update_vibrator);

	spin_lock_init(&vibe_lock);
	vibe_state = 0;
	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&sun4i_vibrator);

exit:
	return err;
}
Exemplo n.º 29
0
static int __init sprd_init_vibrator(void)
{
	vibrator_hw_init();

	INIT_WORK(&vibrator_work, update_vibrator);
	vibe_state = 0;
	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&sprd_vibrator);

	return 0;
}
Exemplo n.º 30
0
void __init msm_init_pmic_vibrator(void)
{
	INIT_WORK(&vibrator_work, update_vibrator);

	spin_lock_init(&vibe_lock);
	vibe_state = 0;
	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&pmic_vibrator);
	printk(KERN_INFO "Vibrator: enable voltage %d(mV)\n",
		PM_VIBRATOR_LEVEL);
}