Ejemplo n.º 1
0
static int sensor_active(struct i2c_client *client, int enable, int rate)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	int status = 0;
		
	sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg);

	//register setting according to chip datasheet		
	if(enable)
	{	
		status = L3G4200D_ENABLE;	//l3g4200d	
		sensor->ops->ctrl_data |= status;	
	}
	else
	{
		status = ~L3G4200D_ENABLE;	//l3g4200d
		sensor->ops->ctrl_data &= status;
	}

	DBG("%s:reg=0x%x,reg_ctrl=0x%x,enable=%d\n",__func__,sensor->ops->ctrl_reg, sensor->ops->ctrl_data, enable);
	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
		printk("%s:fail to active sensor\n",__func__);

	return result;

}
Ejemplo n.º 2
0
int cm3511_sensor_init(void)
{
	cm3511_set_mclk(0);
	cm3511_reset();

	sensor_write_reg(cm3511.client,0x03, 0x00);//
	sensor_write_reg(cm3511.client,0x01, 0xC1);
	sensor_write_reg(cm3511.client,0x01, 0xC3);//
	sensor_write_reg(cm3511.client,0x01, 0xC1);

	mdelay(50);
	sensor_write_reg(cm3511.client,0x03, 0x00);//

	cm3511_init_setting(cm3511.client);
	return 0;
}
Ejemplo n.º 3
0
static int sensor_active(struct i2c_client *client, int enable, int rate)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	int status = 0;

	sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg);
	
	//register setting according to chip datasheet		
	if(enable)
	{	
		sensor->ops->ctrl_data &= 0x1f;		
		sensor->ops->ctrl_data |= COMMMAND1_OPMODE_ALS_CONTINUE;	
	}
	else
	{
		sensor->ops->ctrl_data &= 0x1f;	
		//sensor->ops->ctrl_data |= COMMMAND1_OPMODE_POWER_DOWN;	
	}
		
	DBG("%s:reg=0x%x,reg_ctrl=0x%x,enable=%d\n",__func__,sensor->ops->ctrl_reg, sensor->ops->ctrl_data, enable);
	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
		printk("%s:fail to active sensor\n",__func__);

	if(enable)
	sensor->ops->report(sensor->client);
	
	return result;

}
Ejemplo n.º 4
0
static ssize_t i2c_set_write(struct file *file, const char __user *buf, size_t count,
				loff_t *ppos)
{
 	int len;
	int arg[2];
	arg[0]=0;

	if (*ppos)
		return 0;	/* the end */

	len=(count > DBG_TXT_BUF_SIZE-1)?(DBG_TXT_BUF_SIZE-1):(count);
	if (copy_from_user(debugTxtBuf,buf,len))
		return -EFAULT;

	debugTxtBuf[len]=0; //add string end

	sscanf(debugTxtBuf, "%x %x", &arg[0], &arg[1]);



	*ppos=len;
  

	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, arg[0], arg[1]);
	return len;	/* the end */
}
Ejemplo n.º 5
0
static int sensor_active(struct i2c_client *client, int enable, int rate)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
		
	//sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg);
	
	//register setting according to chip datasheet		
	if(enable)
	{	
		sensor->ops->ctrl_data = AK8975_MODE_SNG_MEASURE;	
	}
	else
	{
		sensor->ops->ctrl_data = AK8975_MODE_POWERDOWN;
	}

	DBG("%s:reg=0x%x,reg_ctrl=0x%x,enable=%d\n",__func__,sensor->ops->ctrl_reg, sensor->ops->ctrl_data, enable);
	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
		printk("%s:fail to active sensor\n",__func__);
	
	return result;

}
Ejemplo n.º 6
0
static int sensor_init(struct i2c_client *client)
{	
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;	
	unsigned char buf[5];		
	unsigned char data = 0;
	int i = 0;
	
	result = sensor->ops->active(client,0,0);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
	
	sensor->status_cur = SENSOR_OFF;
	
	buf[0] = 0x07;	//27
	buf[1] = 0x00;	
	buf[2] = 0x00;	
	buf[3] = 0x20;	//0x00
	buf[4] = 0x00;	
	for(i=0; i<5; i++)
	{
		result = sensor_write_reg(client, sensor->ops->ctrl_reg+i, buf[i]);
		if(result)
		{
			printk("%s:line=%d,error\n",__func__,__LINE__);
			return result;
		}
	}
	
	result = sensor_read_reg(client, sensor->ops->ctrl_reg);
	if (result >= 0)
		data = result & 0x000F;

	sensor->ops->ctrl_data = data + ODR100_BW12_5;	
	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
	
	return result;
}
Ejemplo n.º 7
0
/************************FPS Set******************************/
int ov7690_set_FPS15(struct i2c_client *client)
{
	sensor_write_reg(client, 0x11, 0x01);
	sensor_write_reg(client, 0x29, 0x50);
	sensor_write_reg(client, 0x2a, 0x30);
	sensor_write_reg(client, 0x2b, 0x08);
	sensor_write_reg(client, 0x2c, 0x00);
	sensor_write_reg(client, 0x15, 0x00);
	sensor_write_reg(client, 0x2d, 0x00);
	sensor_write_reg(client, 0x2e, 0x00);
	return 0;
}
Ejemplo n.º 8
0
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	int value = 0;
	char buffer[2] = {0};	
	char index = 0;
	
	if(sensor->ops->read_len < 2)	//sensor->ops->read_len = 2
	{
		printk("%s:lenth is error,len=%d\n",__func__,sensor->ops->read_len);
		return -1;
	}
	
	memset(buffer, 0, 2);

	buffer[0] = sensor->ops->read_reg;
	result = sensor_rx_data(client, buffer, sensor->ops->read_len);	
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}

	value = (buffer[0] << 8) | buffer[1];

	
	index = light_report_value(sensor->input_dev, value);

	DBG("%s:%s result=0x%x,index=%d\n",__func__,sensor->ops->name, value,index);
	
	if(sensor->pdata->irq_enable)
	{
		if(sensor->ops->int_status_reg)
		{	
			value = sensor_read_reg(client, sensor->ops->int_status_reg);
		}
		
		if(value & STA_ALS_INT)
		{
			value &= ~STA_ALS_INT;
			result = sensor_write_reg(client, sensor->ops->int_status_reg,value);	//clear int
			if(result)
			{
				printk("%s:line=%d,error\n",__func__,__LINE__);
				return result;
			}
		}
	}
	
			
	return result;
}
Ejemplo n.º 9
0
static int sensor_init(struct i2c_client *client)
{	
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	
	result = sensor->ops->active(client,0,0);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
	
	sensor->status_cur = SENSOR_OFF;

	result = sensor_write_reg(client, SW_RESET, 0);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}


	sensor->ops->ctrl_data |= PS_15T_3MS| PS_SLP_90MS;
	sensor->ops->ctrl_data &= ~TRIG_PS_AND_LS;

	if(sensor->pdata->irq_enable)
		sensor->ops->ctrl_data |= PS_INT_ENABLE;
	else
		sensor->ops->ctrl_data &= ~PS_INT_ENABLE;
	
	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
		
	return result;
}
Ejemplo n.º 10
0
static int sensor_active(struct i2c_client *client, int enable, int rate)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	char value = 0;

	if(enable)	
	sensor_power_updown(client, 1);

	value = sensor_read_reg(client, sensor->ops->ctrl_reg);
	
	//register setting according to chip datasheet		
	if(enable)
	{	
		if( (value & 0x03) == ONLY_PROX_EN )
		{
			value &= ~0x03;
			value |= ALL_PROX_ALS_EN;
		}
		else if((value & 0x03) == ALL_IDLE )
		{
			value &= ~0x03;
			value |= ONLY_ALS_EN;
		}

	}
	else
	{
		if( (value & 0x03) == ONLY_ALS_EN )
		{
			value &= ~0x03;
			value |= ALL_IDLE;
		}
		else if((value & 0x03) == ALL_PROX_ALS_EN )
		{
			value &= ~0x03;
			value |= ONLY_PROX_EN;
		}
	
	}
	
	sensor->ops->ctrl_data = value;
	
	DBG("%s:reg=0x%x,reg_ctrl=0x%x,enable=%d\n",__func__,sensor->ops->ctrl_reg, sensor->ops->ctrl_data, enable);
	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
		printk("%s:fail to active sensor\n",__func__);

	return result;

}
Ejemplo n.º 11
0
int ov7690_color_matrix_set(struct i2c_client *client)
{
	sensor_write_reg(client, 0xbb, 0x80);
	sensor_write_reg(client, 0xbc, 0x62);
	sensor_write_reg(client, 0xbd, 0x1e);
	sensor_write_reg(client, 0xbe, 0x26);
	sensor_write_reg(client, 0xbf, 0x7b);
	sensor_write_reg(client, 0xc0, 0xac);
	sensor_write_reg(client, 0xc1, 0x1e);
	return 0;
}
Ejemplo n.º 12
0
/****************lens corrention**********************/
int ov7690_lens_corrention_set(struct i2c_client *client)
{
	sensor_write_reg(client, 0x85, 0x90);
	sensor_write_reg(client, 0x86, 0x00);
	sensor_write_reg(client, 0x87, 0x00);
	sensor_write_reg(client, 0x88, 0x10);
	sensor_write_reg(client, 0x89, 0x30);
	sensor_write_reg(client, 0x8a, 0x29);
	sensor_write_reg(client, 0x8b, 0x26);
	return 0;
}
Ejemplo n.º 13
0
int cm3511_sensor_probe(void)
{
	int sensor_id=0;
	cm3511_power_up();
	cm3511_reset();

	sensor_write_reg(cm3511.client,0x03, 0x00);//
	sensor_write_reg(cm3511.client,0x01, 0xC1);
	sensor_write_reg(cm3511.client,0x01, 0xC3);//
	sensor_write_reg(cm3511.client,0x01, 0xC1);

	mdelay(50);
	sensor_write_reg(cm3511.client,0x03, 0x00);//
	sensor_id = sensor_read_reg(cm3511.client,0x04);

	cm3511_power_down();
	if(sensor_id == 0x81)
		return 0;

	dprintk("sensor read is %d",sensor_id);
	return -1;
}
Ejemplo n.º 14
0
static int sensor_active(struct i2c_client *client, int enable, int rate)
{
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	//int status = 0;
	
	//sensor->client->addr = sensor->ops->ctrl_reg;	
	//sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg);
	//printk("%s:  client addr = %#x\n\n", __func__, client->addr);	
	//register setting according to chip datasheet		
	if (enable) {
		sensor->ops->ctrl_data = ALS_RESET(1);	
		result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
		if(result) {
			printk("%s:fail to active sensor\n",__func__);
			return -1;
		}
	}

	if(enable)
	{	
		sensor->ops->ctrl_data = ALS_IT(ALS_IT200MS) | HIGH_SENSITIVITY(1);
	}
	else
	{
		sensor->ops->ctrl_data = SHUT_DOWN(1);
	}

	DBG("%s:reg=0x%x,reg_ctrl=0x%x,enable=%d\n",__func__,sensor->ops->ctrl_reg, sensor->ops->ctrl_data, enable);

	result = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(result)
		printk("%s:fail to active sensor\n",__func__);
	
	return result;

}
Ejemplo n.º 15
0
static int sensor_init(struct i2c_client *client)
{	
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	char value = 0;
	
	sensor_power_updown(client, 0);
	
	result = sensor->ops->active(client,0,0);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
	
	sensor->status_cur = SENSOR_OFF;

	value = 0x41;//The ADC effective resolution = 9;  Low lux threshold level = 1;
	//value = 0x69; //The ADC effective resolution = 17;  Low lux threshold level = 9;
	result = sensor_write_reg(client, ALS_CTL_REG, value);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}

	//value = 0x04;//0x01-0x0f; 17%->93.5% if value = 0x04,then Compensate Loss 52%
	value = 0x02;//0x01-0x0f; 17%->93.5% if value = 0x02,then Compensate Loss 31%	
	result = sensor_write_reg(client, ALS_WINDOWS_REG, value);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
		
	return result;
}
Ejemplo n.º 16
0
/************************Format Set******************************/
int ov7690_format_yuv422(struct i2c_client *client)
{
	sensor_write_reg(client, 0x12, 0x00);
	sensor_write_reg(client, 0x82, 0x03);
	sensor_write_reg(client, 0xd0, 0x48);
	sensor_write_reg(client, 0x80, 0x7f);
	sensor_write_reg(client, 0x3e, 0x30);
	sensor_write_reg(client, 0x22, 0x00);
	return 0;
}
Ejemplo n.º 17
0
static int sensor_init(struct i2c_client *client)
{	
	struct sensor_private_data *sensor =
	    (struct sensor_private_data *) i2c_get_clientdata(client);	
	int result = 0;
	
	result = sensor->ops->active(client,0,0);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
	
	sensor->status_cur = SENSOR_OFF;

	result = sensor_write_reg(client, ISL29023_REG_ADD_COMMANDII, COMMANDII_RANGE_4000 | COMMANDII_RESOLUTION_4096);
	if(result)
	{
		printk("%s:line=%d,error\n",__func__,__LINE__);
		return result;
	}
		
	return result;
}
Ejemplo n.º 18
0
static int compass_akm_reset(struct i2c_client *client)
{
	struct sensor_private_data* sensor = (struct sensor_private_data *)i2c_get_clientdata(this_client); 
	int result = 0;	
	
	if(sensor->pdata->reset_pin > 0)
	{
		gpio_direction_output(sensor->pdata->reset_pin, GPIO_LOW);
		udelay(10);
		gpio_direction_output(sensor->pdata->reset_pin, GPIO_HIGH);
	}
	else	
	{
		/* Set measure mode */
		result = sensor_write_reg(client, AK8963_REG_CNTL2, AK8963_MODE_SNG_MEASURE);
		if(result)
		printk("%s:fail to Set measure mode\n",__func__);
	}
	
	udelay(100);
	
	return result;

}
Ejemplo n.º 19
0
/*************************Resolution Set*************************/
int ov7690_640_480(struct i2c_client *client)
{
	sensor_write_reg(client,0x16,0x03);
	sensor_write_reg(client,0x17,0x69);
	sensor_write_reg(client,0x18,0xa4);
	sensor_write_reg(client,0x19,0x0c);
	sensor_write_reg(client,0x1a,0xf6);
	sensor_write_reg(client,0x22,0x00);
	sensor_write_reg(client,0xc8,0x02);
	sensor_write_reg(client,0xc9,0x80);
	sensor_write_reg(client,0xca,0x01);
	sensor_write_reg(client,0xcb,0xe0);
	sensor_write_reg(client,0xcc,0x02);
	sensor_write_reg(client,0xcd,0x80);
	sensor_write_reg(client,0xce,0x01);
	sensor_write_reg(client,0xcf,0xe0);
	return 0;
}
Ejemplo n.º 20
0
int ov7690_set_scene_night(struct i2c_client *client)
{
	sensor_write_reg(client, 0x13, 0xf7); 
	sensor_write_reg(client, 0x15, 0xb8);
	return 0;
}
Ejemplo n.º 21
0
int ov7690_set_scene_auto(struct i2c_client *client)
{
	sensor_write_reg(client, 0x13, 0xf7); 
	sensor_write_reg(client, 0x15, 0x00);
	return 0;
}
Ejemplo n.º 22
0
int ov7690_set_wb_auto(struct i2c_client *client)
{
	sensor_write_reg(client, 0x8c, 0x5c);
	sensor_write_reg(client, 0x8d, 0x11);
	sensor_write_reg(client, 0x8e, 0x12);
	sensor_write_reg(client, 0x8f, 0x19);
	sensor_write_reg(client, 0x90, 0x50);
	sensor_write_reg(client, 0x91, 0x20);
	sensor_write_reg(client, 0x92, 0x99);
	sensor_write_reg(client, 0x93, 0x91);
	sensor_write_reg(client, 0x94, 0x0f);
	sensor_write_reg(client, 0x95, 0x13);
	sensor_write_reg(client, 0x96, 0xff);
	sensor_write_reg(client, 0x97, 0x00);
	sensor_write_reg(client, 0x98, 0x38);
	sensor_write_reg(client, 0x99, 0x33);
	sensor_write_reg(client, 0x9a, 0x4f);
	sensor_write_reg(client, 0x9b, 0x43);
	sensor_write_reg(client, 0x9c, 0xf0);
	sensor_write_reg(client, 0x9d, 0xf0);
	sensor_write_reg(client, 0x9e, 0xf0);
	sensor_write_reg(client, 0x9f, 0xff);
	sensor_write_reg(client, 0xa0, 0x60);
	sensor_write_reg(client, 0xa1, 0x5a);
	sensor_write_reg(client, 0xa2, 0x10);
	return 0;
}	
Ejemplo n.º 23
0
int ov7690_general_control_set(struct i2c_client *client)
{
	sensor_write_reg(client, 0x14, 0x20);
	sensor_write_reg(client, 0x13, 0xf7);
	return 0;
}
Ejemplo n.º 24
0
int ov7690_gama_set(struct i2c_client *client)
{
	sensor_write_reg(client, 0xa3, 0x08);
	sensor_write_reg(client, 0xa4, 0x15);
	sensor_write_reg(client, 0xa5, 0x24);
	sensor_write_reg(client, 0xa6, 0x45);
	sensor_write_reg(client, 0xa7, 0x55);
	sensor_write_reg(client, 0xa8, 0x6a);
	sensor_write_reg(client, 0xa9, 0x78);
	sensor_write_reg(client, 0xaa, 0x87);
	sensor_write_reg(client, 0xab, 0x96);
	sensor_write_reg(client, 0xac, 0xa3);
	sensor_write_reg(client, 0xad, 0xb4);
	sensor_write_reg(client, 0xae, 0xc3);
	sensor_write_reg(client, 0xaf, 0xd6);
	sensor_write_reg(client, 0xb0, 0xe6);
	sensor_write_reg(client, 0xb1, 0xf2);
	sensor_write_reg(client, 0xb2, 0x12);
	return 0;
}
Ejemplo n.º 25
0
int ov7690_352_288(struct i2c_client *client)
{
	sensor_write_reg(client,0x16,0x03);
	sensor_write_reg(client,0x17,0x83);
	sensor_write_reg(client,0x18,0x97);
	sensor_write_reg(client,0x19,0x08);
	sensor_write_reg(client,0x1a,0xf6);
	sensor_write_reg(client,0x22,0x00);
	sensor_write_reg(client,0xc8,0x02);
	sensor_write_reg(client,0xc9,0x4c);
	sensor_write_reg(client,0xca,0x01);
	sensor_write_reg(client,0xcb,0xe2);
	sensor_write_reg(client,0xcc,0x01);
	sensor_write_reg(client,0xcd,0x60);
	sensor_write_reg(client,0xce,0x01);
	sensor_write_reg(client,0xcf,0x20);
	return 0;
}
Ejemplo n.º 26
0
static int sensor_report_value(struct i2c_client *client)
{
	struct sensor_private_data *sensor =
	    	(struct sensor_private_data *) i2c_get_clientdata(client);	
	char buffer[8] = {0};	
	unsigned char *stat;
	unsigned char *stat2;	
	int ret = 0;	
	char value = 0;
#ifdef SENSOR_DEBUG_TYPE	
	int i;
#endif			
	if(sensor->ops->read_len < 8)	//sensor->ops->read_len = 8
	{
		printk("%s:lenth is error,len=%d\n",__func__,sensor->ops->read_len);
		return -1;
	}
	
	memset(buffer, 0, 8);
	
	/* Data bytes from hardware xL, xH, yL, yH, zL, zH */	
	do {
		*buffer = sensor->ops->read_reg;
		ret = sensor_rx_data(client, buffer, sensor->ops->read_len);
		if (ret < 0)
		return ret;
	} while (0);

	stat = &buffer[0];
	stat2 = &buffer[7];
	
	/*
	 * ST : data ready -
	 * Measurement has been completed and data is ready to be read.
	 */
	if ((*stat & 0x01) != 0x01) {
		DBG(KERN_ERR "%s:ST is not set\n",__func__);
		return -1;
	}

	/*
	 * ST2 : data error -
	 * occurs when data read is started outside of a readable period;
	 * data read would not be correct.
	 * Valid in continuous measurement mode only.
	 * In single measurement mode this error should not occour but we
	 * stil account for it and return an error, since the data would be
	 * corrupted.
	 * DERR bit is self-clearing when ST2 register is read.
	 */
	if (*stat2 & 0x04)
	{
		DBG(KERN_ERR "%s:compass data error\n",__func__);
		return -2;
	}
	
	/*
	 * ST2 : overflow -
	 * the sum of the absolute values of all axis |X|+|Y|+|Z| < 2400uT.
	 * This is likely to happen in presence of an external magnetic
	 * disturbance; it indicates, the sensor data is incorrect and should
	 * be ignored.
	 * An error is returned.
	 * HOFL bit clears when a new measurement starts.
	 */
	if (*stat2 & 0x08)
	{	
		DBG(KERN_ERR "%s:compass data overflow\n",__func__);
		return -3;
	}
	
	/* »¥³âµØ»º´æÊý¾Ý. */
	mutex_lock(&sensor->data_mutex);	
	memcpy(sensor->sensor_data, buffer, sensor->ops->read_len);
	mutex_unlock(&sensor->data_mutex);
#ifdef SENSOR_DEBUG_TYPE	
	DBG("%s:",__func__);
	for(i=0; i<sensor->ops->read_len; i++)
		DBG("%d,",buffer[i]);
	DBG("\n");
#endif	

	if((sensor->pdata->irq_enable)&& (sensor->ops->int_status_reg >= 0))	//read sensor intterupt status register
	{
		
		value = sensor_read_reg(client, sensor->ops->int_status_reg);
		DBG("%s:sensor int status :0x%x\n",__func__,value);
	}

	
	//trigger next measurement 
	ret = sensor_write_reg(client, sensor->ops->ctrl_reg, sensor->ops->ctrl_data);
	if(ret)
	{
		printk(KERN_ERR "%s:fail to set ctrl_data:0x%x\n",__func__,sensor->ops->ctrl_data);
		return ret;
	}

	return ret;
}
Ejemplo n.º 27
0
static int compass_akm_set_mode(struct i2c_client *client, char mode)
{
	struct sensor_private_data* sensor = (struct sensor_private_data *)i2c_get_clientdata(this_client); 
	int result = 0;	

	switch(mode)
	{
		case AK8975_MODE_SNG_MEASURE:
		case AK8975_MODE_SELF_TEST: 	
		case AK8975_MODE_FUSE_ACCESS:			
			if(sensor->status_cur == SENSOR_OFF)
			{
				if(sensor->pdata->irq_enable)
				{
					//DBG("%s:enable irq=%d\n",__func__,client->irq);
					//enable_irq(client->irq);
				}	
				else
				{
					schedule_delayed_work(&sensor->delaywork, msecs_to_jiffies(sensor->pdata->poll_delay_ms));
				}
				
				sensor->status_cur = SENSOR_ON;
			}

			break;

		case AK8975_MODE_POWERDOWN: 	
			if(sensor->status_cur == SENSOR_ON)
			{
				if(sensor->pdata->irq_enable)
				{	
					//DBG("%s:disable irq=%d\n",__func__,client->irq);
					//disable_irq_nosync(client->irq);//disable irq
				}
				else
				cancel_delayed_work_sync(&sensor->delaywork);	

				sensor->status_cur = SENSOR_OFF;
			}
			break;

	}
	
	switch(mode)
	{
		case AK8975_MODE_SNG_MEASURE:		
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_SNG_MEASURE);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);				
			break;
		case AK8975_MODE_SELF_TEST:			
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_SELF_TEST);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);
			break;
		case AK8975_MODE_FUSE_ACCESS:
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_FUSE_ACCESS);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);
			break;
		case AK8975_MODE_POWERDOWN:
			/* Set powerdown mode */
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_POWERDOWN);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);
			udelay(100);
			break;
		default:
			printk("%s: Unknown mode(%d)", __func__, mode);
			result = -EINVAL;
			break;
	}
	DBG("%s:mode=%d\n",__func__,mode);
	return result;

}
Ejemplo n.º 28
0
static int init_read_otp(void){
	int i=0;
	u16 opt_start_addr=imx219_opt_start;
	int block=2;
	int bank=0;
	//static u32 otp_get_value;

	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x0100,0x00);//write standby mode
	//sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, 0x0100, (u16 *)&otp_get_value);
	//pr_err("init_read_otp  +0x0100++ otp_get_value =%x\n",otp_get_value);

	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3302,0x02);//write OTP write clock
	//sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, 0x3302, (u16 *)&otp_get_value);
	//pr_err("init_read_otp  +0x3302++ otp_get_value =%x\n",otp_get_value);
	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3303,0x58);//write OTP write clock
	//sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, 0x3303, (u16 *)&otp_get_value);
	//pr_err("init_read_otp  +0x3303++ otp_get_value =%x\n",otp_get_value);

	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x012A,0x18);//write INCK
	//sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, 0x012A, (u16 *)&otp_get_value);
	//pr_err("init_read_otp  +0x012A++ otp_get_value =%x\n",otp_get_value);
	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x012B,0x00);//write INCK
	//sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, 0x012B, (u16 *)&otp_get_value);
	//pr_err("init_read_otp  +0x012B++ otp_get_value =%x\n",otp_get_value);

	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3300,0x08);//write ECC
	//sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, 0x3300, (u16 *)&otp_get_value);
	//pr_err("init_read_otp  +0x3300++ otp_get_value =%x\n",otp_get_value);

	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3200,1);
	sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3202,block);
	sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, opt_start_addr+8, (u16 *)&i2c_get_value);
	pr_err("init_read_otp  +++ i2c_get_value =%x\n",i2c_get_value);
	if( i2c_get_value!=0xa){
		block=1;	
		sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3200,1);
		sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3202,block);
		sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, opt_start_addr+8, (u16 *)&i2c_get_value);
		if(i2c_get_value!=0xa){
			block=0;
			sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3200,1);
			sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3202,block);
			sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, opt_start_addr+8, (u16 *)&i2c_get_value);
			if(i2c_get_value!=0xa) return -1;
		}	
	}
	for(bank=0;bank<3;bank++){
		sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3200,1);
		sensor_write_reg(imx219_asus_s_ctrl.sensor_i2c_client->client,0x3202,block);
		for(i=0;i<8;i++){
			sensor_read_reg(imx219_asus_s_ctrl.sensor_i2c_client->client, opt_start_addr+(bank*8+i), (u16 *)&i2c_get_value);	  	 
			pr_err("init_read_otp  page = %d bank=%x addr=%x value=%x\n",block,bank,opt_start_addr+(bank*8+i),i2c_get_value);
			imx219_asus_otp_value[bank*8+i]=i2c_get_value;
		}
	}
#ifdef CONFIG_MSMB_CAMERA_DEBUG	
	for(i=0;i<opt_size;i++)
		printk("imx219_asus_otp_value i=%d =%x\n",i,imx219_asus_otp_value[i]);
#endif


	return 0;
}