/*
 * Initialization function
 */
static int apds9130_init_client(struct i2c_client *client)
{
	int err;
	int id;

	err = apds9130_set_enable(client, 0);
	if (err < 0)
		return err;
	
	id = i2c_smbus_read_byte_data(client, CMD_BYTE|APDS9130_ID_REG);
	if (id == 0x39) {
		printk("[ProximitySensor] APDS-9130\n");
	} else {
		printk("[ProximitySensor_E] Not APDS-9130 %x\n", id);
		return -EIO;
	}

	err = apds9130_set_ptime(client, 0xFF);	// 2.72ms Prox integration time
	if (err < 0) return err;

	err = apds9130_set_wtime(client, 0xDC);	// 100ms Wait time for POLL_MEDIUM
	if (err < 0) return err;

	err = apds9130_set_ppcount(client, APDS9130_PS_PULSE_NUMBER);
	if (err < 0) return err;

	err = apds9130_set_config(client, 0);   // no long wait
	if (err < 0) return err;

#if defined(CONFIG_MACH_LGE_L9II_OPEN_EU)
	err = apds9130_set_control(client, APDS9130_PDRVIE_100MA|APDS9130_PRX_IR_DIOD|APDS9130_PGAIN_2X);
#else
	err = apds9130_set_control(client, APDS9130_PDRVIE_100MA|APDS9130_PRX_IR_DIOD|APDS9130_PGAIN_4X);
#endif
	if (err < 0) return err;

	err = apds9130_set_pilt(client, 1023);		// to force first Near-to-Far interrupt
	if (err < 0) return err;

	err = apds9130_set_piht(client, 0);
	if (err < 0) return err;

	err = apds9130_set_pers(client, APDS9130_PPERS_2);	// 2 consecutive Interrupt persistence
	if (err < 0) return err;

	// sensor is in disabled mode but all the configurations are preset

	return 0;
}
Пример #2
0
 */

static int apds9130_init_client(struct i2c_client *client)
{
	struct apds9130_data *data = i2c_get_clientdata(client);
	int err;
	int id;

	err = apds9130_set_enable(client, 0);
	if (err < 0)
		return err;

	data->pDrive = APDS9130_PDRVIE_100MA;

	id = i2c_smbus_read_byte_data(client, CMD_BYTE|APDS9130_ID_REG);
	if (id == 0x39) {
		printk(KERN_INFO"APDS-9130\n");
	}
	else {
		printk(KERN_INFO"Not APDS-9130 %x\n", id);
		return -EIO;
	}

	err = apds9130_set_ptime(client, 0xFF);	// 2.72ms Prox integration time
	if (err < 0) return err;

	err = apds9130_set_wtime(client, 0xDC);	// 100ms Wait time for POLL_MEDIUM
	if (err < 0) return err;

	err = apds9130_set_ppcount(client, APDS9130_PS_PULSE_NUMBER);
	if (err < 0) return err;

	err = apds9130_set_config(client, 0);		// no long wait
	if (err < 0) return err;

	err = apds9130_set_control(client, APDS9130_PDRVIE_100MA|APDS9130_PRX_IR_DIOD|APDS9130_PGAIN_2X);	// 2012.10.10 PGAIN 4x-> 2x chkim.
	if (err < 0) return err;

	err = apds9130_set_pilt(client, 0);		// init threshold for proximity
	if (err < 0) return err;

	err = apds9130_set_piht(client, APDS9130_PS_DETECTION_THRESHOLD);
	if (err < 0) return err;

	err = apds9130_set_pers(client, APDS9130_PPERS_2);	// 2 consecutive Interrupt persistence
	if (err < 0) return err;

	// sensor is in disabled mode but all the configurations are preset
/* Temp block the below code as no need to set cross talk threshold during proximity OFF state [LGSI_SP4_BSP][[email protected]]
#if defined(APDS9130_PROXIMITY_CAL)
	err = apds9130_set_enable(client,0);
	if(err < 0){
		printk(KERN_INFO "%s, enable set Fail\n",__func__);
		return err;
	}
#endif
*/
Пример #3
0
 */

static int apds9130_init_client(struct i2c_client *client)
{
	struct apds9130_data *data = i2c_get_clientdata(client);
	int err;
	int id;

	err = apds9130_set_enable(client, 0);
	if (err < 0)
		return err;

	data->pDrive = APDS9130_PDRVIE_100MA;

	id = i2c_smbus_read_byte_data(client, CMD_BYTE|APDS9130_ID_REG);
	if (id == 0x39) {
		printk(KERN_INFO"APDS-9130\n");
	}
	else {
		printk(KERN_INFO"Not APDS-9130 %x\n", id);
		return -EIO;
	}

	err = apds9130_set_ptime(client, 0xFF);	// 2.72ms Prox integration time
	if (err < 0) return err;

	err = apds9130_set_wtime(client, 0xDC);	// 100ms Wait time for POLL_MEDIUM
	if (err < 0) return err;

	err = apds9130_set_ppcount(client, APDS9130_PS_PULSE_NUMBER);
	if (err < 0) return err;

	err = apds9130_set_config(client, 0);		// no long wait
	if (err < 0) return err;

	err = apds9130_set_control(client, APDS9130_PDRVIE_100MA|APDS9130_PRX_IR_DIOD|APDS9130_PGAIN_2X);	// 2012.10.10 PGAIN 4x-> 2x chkim.
	if (err < 0) return err;

	err = apds9130_set_pilt(client, 0);		// init threshold for proximity
	if (err < 0) return err;

	err = apds9130_set_piht(client, APDS9130_PS_DETECTION_THRESHOLD);
	if (err < 0) return err;

	err = apds9130_set_pers(client, APDS9130_PPERS_2);	// 2 consecutive Interrupt persistence
	if (err < 0) return err;

	// sensor is in disabled mode but all the configurations are preset
/*                                                                                                                                  
                                   
                                     
             
                                                     
             
  
      
*/
Пример #4
0
}

static ssize_t apds9130_store_control(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
    int ret = 0;
    unsigned long val;
    struct i2c_client *client = to_i2c_client(dev);

    val = simple_strtoul(buf, NULL, 10);

    ret = apds9130_set_control(client, val);

    if (ret < 0)
        return ret;
static ssize_t apds9130_store_pdrive(struct device *dev,
					struct device_attribute *attr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	unsigned char val = simple_strtoul(buf, NULL, 10);
    unsigned char cntl_reg = 0x3F & i2c_smbus_read_byte_data(client, CMD_WORD|APDS9130_CONTROL_REG);

    if(val > 3) {
        printk("[ProximitySensor_E] %s: invalid argument\n", __func__);
        return count;
    }
    cntl_reg |= (val << 6);
    printk("[ProximitySensor] %s: pdrive=%x, cntl_reg=%x\n", __func__, val, cntl_reg);
	apds9130_set_control(client, cntl_reg);

    return count;
}
Пример #6
0
}

static ssize_t apds9130_store_pdrive(struct device *dev,
				struct device_attribute *attr, const char *buf, size_t count)
{
		struct i2c_client *client = to_i2c_client(dev);
		struct apds9130_data *data = i2c_get_clientdata(client);
		unsigned int rdata;

		sscanf(buf, "%d", &rdata);

		if(client != NULL){
				data->pDrive= rdata;
				apds9130_set_control(client,(data->pDrive |APDS9130_PRX_IR_DIOD|APDS9130_PGAIN_2X));
		}
		else
				return -1;