static int pmic8058_vib_set(struct pmic8058_vib *vib, int on)
{
	int rc;
	u8 val;

	if (on) {
		val = vib->reg_vib_drv;
		val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
		vib->enabled = 1;

	} else {
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
		vib->enabled = 0;
	}
	__dump_vib_regs(vib, "vib_set_end");

	return rc;
}
static int pm8xxx_vib_set(struct pm8xxx_vib *vib, int on)
{
	int rc;
	u8 val;
/* LGE_CHANGE_S */
	unsigned long flags;

	spin_lock_irqsave(&vib->lock, flags);
/* LGE_CHANGE_E */

	if (on) {
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
	} else {
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
	}
	__dump_vib_regs(vib, "vib_set_end");

/* LGE_CHANGE_S */
    if(unlikely(debug_mask))
        printk(KERN_INFO "pm8xxx_vib_set vib->level:%d, val:0x%x\n",vib->level,val);

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_REST_POWER
	if(on)
	{
		if(vib->vib_state == 0)
		{
			vib->vib_state = 1;
			do_gettimeofday(&(vib->start_tv));
		}
	}
	else
	{
		if(vib->vib_state == 1)
		{
			vib->vib_state = 0;
			do_gettimeofday(&(vib->stop_tv));
		}
	}
#endif

	spin_unlock_irqrestore(&vib->lock, flags);
/* LGE_CHANGE_E */

	return rc;
}
Esempio n. 3
0
static int pm8xxx_vib_set(struct pm8xxx_vib *vib, int on, int time)
{
    int rc;
    u8 val;

    mutex_lock(&vib->vib_mutex);
    VIB_DEBUG_LOG(KERN_INFO, "called. on=%d,time=%d\n", on, time);
    if (on) {
        VIB_DEBUG_LOG(KERN_INFO, "VIB ON.reg_vib_drv=0x%02X,level=0x%02X\n",
                                              vib->reg_vib_drv, vib->level);
        val = vib->reg_vib_drv;
        val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
        rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
        VIB_DEBUG_LOG(KERN_INFO,
                      "pm8xxx_vib_write_u8 called.rc=%d,val=0x%02X\n", rc, val);
        if (rc < 0) {
            VIB_DEBUG_LOG(KERN_INFO, "pm8xxx_vib_write_u8() error. rc=%d\n",
                                                                        rc);
            mutex_unlock(&vib->vib_mutex);
            return rc;
        }
        vib->reg_vib_drv = val;
        hrtimer_start(&vib->vib_timer,
                  ktime_set(time / 1000, (time % 1000) * 1000000),
                  HRTIMER_MODE_REL);
    } else {
        VIB_DEBUG_LOG(KERN_INFO, "VIB OFF.reg_vib_drv=0x%02X,level=0x%02X\n",
                                               vib->reg_vib_drv, vib->level);
        val = vib->reg_vib_drv;
        val &= ~VIB_DRV_SEL_MASK;
        rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
        VIB_DEBUG_LOG(KERN_INFO,
                      "pm8xxx_vib_write_u8 called.rc=%d,val=0x%02X\n", rc, val);
        if (rc < 0) {
            VIB_DEBUG_LOG(KERN_INFO, "pm8xxx_vib_write_u8() error. rc=%d\n"
                                                                     , rc);
            mutex_unlock(&vib->vib_mutex);
            return rc;
        }
        vib->reg_vib_drv = val;
    }
#ifdef DEBUG_VIB_PM8XXX
    __dump_vib_regs(vib, "vib_set_end");
#endif /* DEBUG_VIB_PM8XXX */

    mutex_unlock(&vib->vib_mutex);
    VIB_DEBUG_LOG(KERN_INFO, "end.rc=%d,reg_vib_drv=0x%02X\n", rc,
                                                vib->reg_vib_drv);
    return rc;
}
Esempio n. 4
0
static int pm8xxx_vib_set_off(struct pm8xxx_vib *vib)
{
	int rc;
	u8 val2;
	val2 = vib->reg_vib_drv;
	val2 &= ~VIB_DRV_SEL_MASK;
	VIB_INFO_LOG("%s + val: %x \n", __func__, val2);
	rc = pm8xxx_vib_write_u8(vib, val2, VIB_DRV);
	if (rc < 0){
		VIB_ERR_LOG("%s writing pmic fail, ret:%X\n", __func__, rc);
		return rc;
	}
	__dump_vib_regs(vib, "vib_set_end");
	VIB_INFO_LOG("%s - \n", __func__);
	return rc;
}
Esempio n. 5
0
static int pm8xxx_vib_set_on(struct pm8xxx_vib *vib)
{
	int rc;
	u8 val1;
	val1 = vib->reg_vib_drv;
	val1 &= ~VIB_DRV_SEL_MASK;
	val1 |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
	VIB_INFO_LOG("%s + val: %x \n", __func__, val1);
	rc = pm8xxx_vib_write_u8(vib, val1, VIB_DRV);
	if (rc < 0){
		VIB_ERR_LOG("%s writing pmic fail, ret:%X\n", __func__, rc);
		return rc;
	}
	__dump_vib_regs(vib, "vib_set_end");
	VIB_INFO_LOG("%s - \n", __func__);
	return rc;
}
Esempio n. 6
0
static int pmic8058_vib_set(struct pmic8058_vib *vib, int on)
{
	int rc;
	u8 val;

	if (on) {
		rc = pm_runtime_resume(vib->dev);
		if (rc < 0)
			dev_dbg(vib->dev, "pm_runtime_resume failed\n");

//[SIMT-lilening-20110804] add vibrator start voltage{
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		val |= ((VIB_START_VOLTAGE_mV << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		udelay(20);
//[SIMT-lilening-20110804] add vibrator start voltage}
		val = vib->reg_vib_drv;
		val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
	} else {
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;

		rc = pm_runtime_suspend(vib->dev);
		if (rc < 0)
			dev_dbg(vib->dev, "pm_runtime_suspend failed\n");
	}
	__dump_vib_regs(vib, "vib_set_end");

	return rc;
}
static int pm8xxx_vib_set(struct pm8xxx_vib *vib, int on)
{
	int rc;
	u8 val;

	if (on) {
		val = vib->reg_vib_drv;
		val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
/*add for PM_log*/
#ifdef CONFIG_PM_LOG
		rc = pmlog_device_on(vib->pmlog_device);
		if (rc)
			printk("pmlog_device_on fall rc = %d\n",rc);
#endif
/*Carl Chang,20120528*/
	} else {
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
/*add for PM_log*/
#ifdef CONFIG_PM_LOG
                rc = pmlog_device_off(vib->pmlog_device);
                if (rc)
                        printk("pmlog_device_off fall rc = %d\n",rc);
#endif
/*Carl Chang,20120528*/
	}
	__dump_vib_regs(vib, "vib_set_end");

	return rc;
}
Esempio n. 8
0
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
	const struct pm8xxx_vibrator_platform_data *pdata =
						pdev->dev.platform_data;
	struct pm8xxx_vib *vib;
	u8 val;
	int rc;

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pm8xxx_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pm8xxx_vib_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pm8xxx_vib_get_time;
	vib->timed_dev.enable = pm8xxx_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/*
	 * Configure the vibrator, it operates in manual mode
	 * for timed_output framework.
	 */
	rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_voltage_level);
	if (rc < 0) {
		VIB_ERR_LOG("%s, create sysfs fail: voltage_level\n", __func__);
	}

	platform_set_drvdata(pdev, vib);
	vib_dev = vib;
	return 0;

err_read_vib:
	kfree(vib);
	return rc;
}
static int __devinit pmic8058_vib_probe(struct platform_device *pdev)

{
	struct pmic8058_vibrator_pdata *pdata = pdev->dev.platform_data;
	struct pmic8058_vib *vib;
	u8 val;
	int rc;

	struct pm8058_chip	*pm_chip;

	pm_chip = platform_get_drvdata(pdev);
	if (pm_chip == NULL) {
		dev_err(&pdev->dev, "no parent data passed in\n");
		return -EFAULT;
	}

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pm_chip	= pm_chip;
	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pmic8058_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pmic8058_vib_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pmic8058_vib_get_time;
	vib->timed_dev.enable = pmic8058_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/* operate in manual mode */
	rc = pmic8058_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;

	pmic8058_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);

	platform_set_drvdata(pdev, vib);

	return 0;

err_read_vib:
	kfree(vib);
	return rc;
}
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
	const struct pm8xxx_vibrator_platform_data *pdata =
						pdev->dev.platform_data;
	struct pm8xxx_vib *vib;
	u8 val;
	int rc;
	printk("[vibrator] %s ,probe+++++ \n",__func__ );/*Carl Chang*/

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

	//spin_lock_init(&vib->lock);
	mutex_init(&vib->lock);
	/*Register PM_log*/
#ifdef CONFIG_PM_LOG
	vib->pmlog_device = pmlog_register_device(&pdev->dev);
#endif
	/*Carl Chang,20120528*/
	INIT_WORK(&vib->work, pm8xxx_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pm8xxx_vib_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pm8xxx_vib_get_time;
	vib->timed_dev.enable = pm8xxx_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/*
	 * Configure the vibrator, it operates in manual mode
	 * for timed_output framework.
	 */
	rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;

	//pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);
	// Carl Chang, 20120829, remove initial vibrate

	platform_set_drvdata(pdev, vib);

	vib_dev = vib;

	/* Add for debugfs and fvs mode test */
	vibrator_create_debugfs_entries(vib_dev);
	vibrator_create_kernel_debuglevel_entries();
	/* Emily Jiang, 20120201 */
	printk("[vibrator] %s ,probe----- \n",__func__ );/*Carl Chang*/
	
	return 0;

err_read_vib:
	kfree(vib);
	return rc;
}
static int __devinit pmic8058_vib_probe(struct platform_device *pdev)

{
	struct pmic8058_vibrator_pdata *pdata = pdev->dev.platform_data;
	struct pmic8058_vib *vib;
	u8 val;
	int rc;

	struct pm8058_chip	*pm_chip;

	pm_chip = dev_get_drvdata(pdev->parent.dev);
	if (pm_chip == NULL) {
		dev_err(&pdev->dev, "no parent data passed in\n");
		return -EFAULT;
	}

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pm_chip	= pm_chip;
	vib->enabled	= 0;
	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pmic8058_work_handler);

	vib->info = input_allocate_device();

	if (vib->info == NULL) {
		dev_err(&pdev->dev, "couldn't allocate input device\n");
		return -ENOMEM;
	}

	input_set_drvdata(vib->info, vib);

	vib->info->name = "pmic8058:vibrator";
	vib->info->id.version = 1;
	vib->info->dev.parent = pdev->dev.parent;

	__set_bit(FF_RUMBLE, vib->info->ffbit);
	__dump_vib_regs(vib, "boot_vib_default");

	/*                        */
	rc = pmic8058_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = input_ff_create_memless(vib->info, NULL, pmic8058_vib_play_effect);
	if (rc < 0) {
		dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n");
		goto create_memless_err;
	}

	platform_set_drvdata(pdev, vib);

	rc = input_register_device(vib->info);
	if (rc < 0) {
		dev_dbg(&pdev->dev, "couldn't register input device\n");
		goto reg_err;
	}

	return 0;

reg_err:
	input_ff_destroy(vib->info);
create_memless_err:
	input_free_device(vib->info);
err_read_vib:
	kfree(vib);
	return rc;
}
Esempio n. 12
0
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
	const struct pm8xxx_vibrator_platform_data *pdata =
						pdev->dev.platform_data;
	struct pm8xxx_vib *vib;
	u8 val;
	int rc;

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pm8xxx_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pm8xxx_vib_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pm8xxx_vib_get_time;
	vib->timed_dev.enable = pm8xxx_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/*
	 * Configure the vibrator, it operates in manual mode
	 * for timed_output framework.
	 */
	rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;

	/*PERI-AH-VIBRATOR_Add_level_file_node-00+[ */
	vib_Level = vib->level;
	dev_info(&pdev->dev, "default vib_Level %d \n", vib_Level);
	
	/* Set voltage parameter of vibrator(corresponding to the file node /sys/class/timed_output/vibrator/level) */
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_level);	
	if (rc) {
		dev_err(&pdev->dev, "dev_attr_level device_create_file failed\n");
		device_remove_file(vib->timed_dev.dev, &dev_attr_level);
	}
	/*PERI-AH-VIBRATOR_Add_level_file_node-00+[ */

	#ifdef INIT_VIB_ENABLE
	pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);
	#endif

	platform_set_drvdata(pdev, vib);

	vib_dev = vib;

	return 0;

err_read_vib:
	kfree(vib);
	return rc;
}
Esempio n. 13
0
//[SIMT-lilening-20110804]}
static int __devinit pmic8058_vib_probe(struct platform_device *pdev)

{
	struct pmic8058_vibrator_pdata *pdata = pdev->dev.platform_data;
	struct pmic8058_vib *vib;
	u8 val;
	int rc;

	struct pm8058_chip	*pm_chip;

	pm_chip = platform_get_drvdata(pdev);
	if (pm_chip == NULL) {
		dev_err(&pdev->dev, "no parent data passed in\n");
		return -EFAULT;
	}

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	/* Enable runtime PM ops, start in ACTIVE mode */
	rc = pm_runtime_set_active(&pdev->dev);
	if (rc < 0)
		dev_dbg(&pdev->dev, "unable to set runtime pm state\n");
	pm_runtime_enable(&pdev->dev);

	vib->pm_chip	= pm_chip;
	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pmic8058_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pmic8058_vib_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pmic8058_vib_get_time;
	vib->timed_dev.enable = pmic8058_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/* operate in manual mode */
	rc = pmic8058_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;

	//[SIM-chengbin-110926] del the second vib event 
    #if  0
	pmic8058_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);
    #endif

	platform_set_drvdata(pdev, vib);

	pm_runtime_set_suspended(&pdev->dev);
//[SIMT-lilening-20110804] add vibrator start voltage{
	rc = device_create_file(&pdev->dev, &dev_attr_vib_set);
	if(rc)
		return rc;
//[SIMT-lilening-20110804]}
	return 0;

err_read_vib:
	pm_runtime_set_suspended(&pdev->dev);
	pm_runtime_disable(&pdev->dev);
	kfree(vib);
	return rc;
}
Esempio n. 14
0
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
	const struct pm8xxx_vibrator_platform_data *pdata =
						pdev->dev.platform_data;
	struct pm8xxx_vib *vib;
	u8 val;
	int rc;

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->pre_value  = 0;
	vib->dev	= &pdev->dev;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pm8xxx_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pm8xxx_vib_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pm8xxx_vib_get_time;
	vib->timed_dev.enable = pm8xxx_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/*
	 * Configure the vibrator, it operates in manual mode
	 * for timed_output framework.
	 */
	rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_VOL
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_amp);
	if (rc < 0)
		goto err_read_vib;

	/* no vibration during initialization, [email protected], 01/02/2012 */
	//pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);
#else
	pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);
#endif

	platform_set_drvdata(pdev, vib);

	vib_dev = vib;

	return 0;

err_read_vib:
	kfree(vib);
	return rc;
}
Esempio n. 15
0
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
    const struct pm8xxx_vibrator_platform_data *pdata =
                        pdev->dev.platform_data;
    struct pm8xxx_vib *vib;
    u8 val;
    int rc;
    int count = 0;

    VIB_DEBUG_LOG(KERN_INFO, "called.\n");
    if (!pdata) {
        VIB_LOG(KERN_ERR, "pdata is NULL\n");
        return -EINVAL;
    }

    if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
             pdata->level_mV > VIB_MAX_LEVEL_mV) {
        VIB_LOG(KERN_ERR, "level_mV error. level_mV=%d\n",
                                         pdata->level_mV);
        return -EINVAL;
    }

    vib = kzalloc(sizeof(*vib), GFP_KERNEL);
    if (!vib) {
        VIB_LOG(KERN_ERR, "kzalloc error.\n");
        return -ENOMEM;
    }

    vib->pdata  = pdata;
    vib->level  = pdata->level_mV / 100;
    vib->dev    = &pdev->dev;

    mutex_init(&vib->vib_mutex);
    for (count = 0; count < VIB_WORK_NUM; count++) {
        INIT_WORK(&(vib->vib_on_work_data[count].work_vib_on),
                                          pm8xxx_vibrator_on);
        INIT_WORK(&vib->work_vib_off[count], pm8xxx_vibrator_off);
        vib->vib_on_work_data[count].vib_time = 0;
        VIB_DEBUG_LOG(KERN_INFO, "vib_on_work_data[%d].vib_time=%d\n", count,
                                      vib->vib_on_work_data[count].vib_time);
    }

    vib->work_vib_on_pos = 0;
    vib->work_vib_off_pos = 0;

    hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    vib->vib_timer.function = pm8xxx_vib_timer_func;

    vib->timed_dev.name = "vibrator";
    vib->timed_dev.get_time = pm8xxx_vib_get_time;
    vib->timed_dev.enable = pm8xxx_vib_enable;

#ifdef DEBUG_VIB_PM8XXX
    __dump_vib_regs(vib, "boot_vib_default");
#endif /* DEBUG_VIB_PM8XXX */

    /*
     * Configure the vibrator, it operates in manual mode
     * for timed_output framework.
     */
    rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
    if (rc < 0) {
        VIB_LOG(KERN_ERR, "pm8xxx_vib_read_u8 error. rc=%d\n", rc);
        goto err_read_vib;
    }
    val &= ~VIB_DRV_EN_MANUAL_MASK;
    rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
    if (rc < 0) {
        VIB_LOG(KERN_ERR, "pm8xxx_vib_write_u8 error. rc=%d\n", rc);
        goto err_read_vib;
    }

    vib->reg_vib_drv = val;

    rc = timed_output_dev_register(&vib->timed_dev);
    if (rc < 0) {
        VIB_LOG(KERN_ERR, "timed_output_dev_register error. rc=%d\n", rc);
        goto err_read_vib;
    }

    platform_set_drvdata(pdev, vib);

    vib_dev = vib;

    VIB_DEBUG_LOG(KERN_INFO, "end.rc=%d\n", 0);
    return 0;

err_read_vib:
    VIB_DEBUG_LOG(KERN_INFO, "err_read_vib.\n");
    kfree(vib);
    VIB_DEBUG_LOG(KERN_INFO, "end.rc=%d\n", rc);
    return rc;
}
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
	const struct pm8xxx_vibrator_platform_data *pdata =
						pdev->dev.platform_data;
	struct pm8xxx_vib *vib;
	u8 val;
	int rc;

	if (!pdata)
		return -EINVAL;

	if (pdata->level_mV < VIB_MIN_LEVEL_mV ||
			 pdata->level_mV > VIB_MAX_LEVEL_mV)
		return -EINVAL;

	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;

	vib->pdata	= pdata;
	vib->level	= pdata->level_mV / 100;
	vib->dev	= &pdev->dev;

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_VOL
	vib->default_level  = vib->level;
	vib->request_level  = vib->level;
#endif

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_MIN_TIMEOUT
	vib->min_timeout_ms  = pdata->min_timeout_ms;
	vib->pre_value  = 0;
#endif

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_OVERDRIVE
	vib->overdrive_ms  = pdata->overdrive_ms;
	vib->overdrive_range_ms  = pdata->overdrive_range_ms;
#endif

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_REST_POWER
	vib->min_stop_ms  = pdata->min_stop_ms;
	vib->start_tv.tv_sec = 0;
	vib->start_tv.tv_usec = 0;
	vib->stop_tv.tv_sec = 0;
	vib->stop_tv.tv_usec = 0;
#endif

    vib->max_level_mv = VIB_MAX_LEVEL_mV;
    vib->min_level_mv = VIB_MIN_LEVEL_mV;

	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pm8xxx_vib_update);

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pm8xxx_vib_timer_func;

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_OVERDRIVE
	hrtimer_init(&vib->vib_overdrive_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_overdrive_timer.function = pm8xxx_vib_overdrive_timer_func;
#endif

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pm8xxx_vib_get_time;
	vib->timed_dev.enable = pm8xxx_vib_enable;

	__dump_vib_regs(vib, "boot_vib_default");

	/*
	 * Configure the vibrator, it operates in manual mode
	 * for timed_output framework.
	 */
	rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;
	val &= ~VIB_DRV_EN_MANUAL_MASK;
	rc = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
	if (rc < 0)
		goto err_read_vib;

	vib->reg_vib_drv = val;

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;

    rc = sysfs_create_group(&vib->timed_dev.dev->kobj, &pm8xxx_vib_attr_group);

#if 0

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_VOL
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_amp);
	if (rc < 0)
		goto err_read_vib;

	rc = device_create_file(vib->timed_dev.dev, &dev_attr_default_level);
	if (rc < 0)
		goto err_read_vib;
#endif

// LGE does not use this function. power on vib effect is played at SBL3
#ifndef CONFIG_MACH_LGE
	pm8xxx_vib_enable(&vib->timed_dev, pdata->initial_vibrate_ms);
#endif

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_MIN_TIMEOUT
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_min_ms);
	if (rc < 0)
		goto err_read_vib;
#endif

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_OVERDRIVE
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_over_ms);
	if (rc < 0)
		goto err_read_vib;

	rc = device_create_file(vib->timed_dev.dev, &dev_attr_over_range_ms);
	if (rc < 0)
		goto err_read_vib;
#endif

#ifdef CONFIG_LGE_PMIC8XXX_VIBRATOR_REST_POWER
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_min_stop_ms);
	if (rc < 0)
		goto err_read_vib;
#endif

#endif // #if 0
	platform_set_drvdata(pdev, vib);

	vib_dev = vib;

	return 0;

err_read_vib:
	kfree(vib);
	return rc;
}