Beispiel #1
0
static int act8846_resume(struct i2c_client *i2c)
{
/****add by nition at 20130527 s********************/	
#if 0
	int ret,k=10;	
       u16 val = 0;//add by nition 
       struct act8846 *act8846 = g_act8846;
	//ret = act8846_set_bits(act8846, 0xe4,(0x1<<7),(0x1<<7));
	val=0x8f;
	ret = act8846_i2c_write(act8846->i2c, 0xe4, 1, val);	
	printk("act8846_i2c_write ret =%d  ***********wakeup\n",ret);
	while(ret<0){
		ret = act8846_i2c_write(act8846->i2c, 0xe4, 1, val);	
		if(ret>0)break;
		k--;
		if(k<0){
			printk("act8846_i2c_write error -----wakeup nition\n");
			break;
			}
	}	
	act8846_i2c_read(act8846->i2c, 0xe4, 1, &val);
	printk("act8846_resume 0xe4 = %d******************nition\n",val);
#endif
/****add by nition at 20130527 e********************/	
	act8846_device_resume();

	return 0;
}
Beispiel #2
0
static int act8846_set_bits(struct act8846 *act8846, u8 reg, u16 mask, u16 val)
{
	u16 tmp;
	int ret;

	mutex_lock(&act8846->io_lock);

	ret = act8846_i2c_read(act8846->i2c, reg, 1, &tmp);
	if(ret < 0){
		mutex_unlock(&act8846->io_lock);
		return ret;
	}
	DBG("1 reg read 0x%02x -> 0x%02x\n", (int)reg, (unsigned)tmp&0xff);
	tmp = (tmp & ~mask) | val;
	ret = act8846_i2c_write(act8846->i2c, reg, 1, tmp);
	if(ret < 0){
		mutex_unlock(&act8846->io_lock);
		return ret;
	}
	DBG("reg write 0x%02x -> 0x%02x\n", (int)reg, (unsigned)val&0xff);
	
	ret = act8846_i2c_read(act8846->i2c, reg, 1, &tmp);
	if(ret < 0){
		mutex_unlock(&act8846->io_lock);
		return ret;
	}
	DBG("2 reg read 0x%02x -> 0x%02x\n", (int)reg, (unsigned)tmp&0xff);
	mutex_unlock(&act8846->io_lock);

	return 0;//ret;	
}
Beispiel #3
0
static int __devinit act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
	struct act8846 *act8846;	
	struct act8846_platform_data *pdata = i2c->dev.platform_data;
	int ret;
	u16 val = 0;//add by nition 
	act8846 = kzalloc(sizeof(struct act8846), GFP_KERNEL);
	if (act8846 == NULL) {
		ret = -ENOMEM;		
		goto err;
	}
	act8846->i2c = i2c;
	act8846->dev = &i2c->dev;
	i2c_set_clientdata(i2c, act8846);
	mutex_init(&act8846->io_lock);	

	ret = act8846_reg_read(act8846,0x22);
	if ((ret < 0) || (ret == 0xff)){
		printk("The device is not act8846 \n");
		return 0;
	}

	ret = act8846_set_bits(act8846, 0xf4,(0x1<<7),(0x0<<7));
	if (ret < 0) {
		printk("act8846 set 0xf4 error!\n");
		goto err;
	}
	
	if (pdata) {
		ret = setup_regulators(act8846, pdata);
		if (ret < 0)		
			goto err;
	} else
		dev_warn(act8846->dev, "No platform init data supplied\n");

	g_act8846 = act8846;
	pdata->set_init(act8846);

	#ifdef CONFIG_HAS_EARLYSUSPEND
	act8846->act8846_suspend.suspend = act8846_early_suspend,
	act8846->act8846_suspend.resume = act8846_late_resume,
	act8846->act8846_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1,
	register_early_suspend(&act8846->act8846_suspend);
	#endif
/****add by nition at 20130527 s********************/	
	act8846_i2c_read(act8846->i2c, 0xe4, 1, &val);
	printk("act8846 0xe4 = %d******************nition-1\n",val);
	val=0x8f;
	ret = act8846_i2c_write(act8846->i2c, 0xe4, 1, val);
	act8846_i2c_read(act8846->i2c, 0xe4, 1, &val);
	printk("act8846 0xe4 = %d******************nition-2\n",val);
/****add by nition at 20130527 e********************/	
	return 0;

err:
	return ret;	

}
Beispiel #4
0
void regulator_ctrl_vcc_tp(bool on)
{
	int ret;
	struct act8846 *act8846 = g_act8846;
	const char REG9 = 0x71;
	if(on)
	{
		/*close out9*/
		reg9_val = act8846_reg_read(act8846,REG9);
		DBG("before set REG9 = %d\n", reg9_val);
		ret = act8846_set_bits(act8846, REG9,(0x1<<7),(0x0<<7));
		DBG("after set REG89 = %d\n", act8846_reg_read(act8846,REG9));
		if (ret < 0) {
			DBG("act8846 set 0xc3 error!\n");
		}
	}
	else
	{
		/*resume reg9*/
		act8846_i2c_write(act8846->i2c, REG9, 1, reg9_val);
		reg9_val = act8846_reg_read(act8846,REG9);
		DBG("resume REG8 = %d\n", reg9_val);
	}
}