iio: light: vl6180: add something initialization from vendor

Change-Id: I77ca2c836c998be5158e222909834bda8bb24245
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
This commit is contained in:
Ziyuan Xu
2018-06-14 16:46:39 +08:00
committed by Tao Huang
parent b2950611bb
commit 10dbf59d3f

View File

@@ -442,6 +442,76 @@ static const struct iio_info vl6180_info = {
.driver_module = THIS_MODULE,
};
static int vl6180_misc_init(struct vl6180_data *data)
{
struct i2c_client *client = data->client;
/* REGISTER_TUNING_SR03_270514_CustomerView.txt */
vl6180_write_byte(client, 0x0207, 0x01);
vl6180_write_byte(client, 0x0208, 0x01);
vl6180_write_byte(client, 0x0096, 0x00);
vl6180_write_byte(client, 0x0097, 0xfd);
vl6180_write_byte(client, 0x00e3, 0x00);
vl6180_write_byte(client, 0x00e4, 0x04);
vl6180_write_byte(client, 0x00e5, 0x02);
vl6180_write_byte(client, 0x00e6, 0x01);
vl6180_write_byte(client, 0x00e7, 0x03);
vl6180_write_byte(client, 0x00f5, 0x02);
vl6180_write_byte(client, 0x00d9, 0x05);
vl6180_write_byte(client, 0x00db, 0xce);
vl6180_write_byte(client, 0x00dc, 0x03);
vl6180_write_byte(client, 0x00dd, 0xf8);
vl6180_write_byte(client, 0x009f, 0x00);
vl6180_write_byte(client, 0x00a3, 0x3c);
vl6180_write_byte(client, 0x00b7, 0x00);
vl6180_write_byte(client, 0x00bb, 0x3c);
vl6180_write_byte(client, 0x00b2, 0x09);
vl6180_write_byte(client, 0x00ca, 0x09);
vl6180_write_byte(client, 0x0198, 0x01);
vl6180_write_byte(client, 0x01b0, 0x17);
vl6180_write_byte(client, 0x01ad, 0x00);
vl6180_write_byte(client, 0x00ff, 0x05);
vl6180_write_byte(client, 0x0100, 0x05);
vl6180_write_byte(client, 0x0199, 0x05);
vl6180_write_byte(client, 0x01a6, 0x1b);
vl6180_write_byte(client, 0x01ac, 0x3e);
vl6180_write_byte(client, 0x01a7, 0x1f);
vl6180_write_byte(client, 0x0030, 0x00);
/* Recommended : Public registers - See data sheet for more detail */
/* Enables polling for New Sample ready when measurement completes */
vl6180_write_byte(client, 0x0011, 0x10);
/*
* Set the averaging sample period (compromise between lower noise
* and increased execution time)
*/
vl6180_write_byte(client, 0x010a, 0x30);
/*
* Sets the light and dark gain (upper nibble). Dark gain should
* not be changed.
*/
vl6180_write_byte(client, 0x003f, 0x46);
/*
* Sets the # of range measurements after which auto calibration
* of system is performed.
*/
vl6180_write_byte(client, 0x0031, 0xFF);
/* Set ALS integration time to 100ms */
vl6180_write_byte(client, 0x0040, 0x63);
/* perform a single temperature calibration of the ranging sensor */
vl6180_write_byte(client, 0x002e, 0x01);
/* Optional: Public registers - See data sheet for more detail */
/* Set default ranging inter-measurement period to 100ms */
vl6180_write_byte(client, 0x001b, 0x09);
/* Set default ALS inter-measurement period to 500ms */
vl6180_write_byte(client, 0x003e, 0x31);
/* Configures interrupt on New sample ready */
vl6180_write_byte(client, 0x0014, 0x24);
return 0;
}
static int vl6180_init(struct vl6180_data *data)
{
struct i2c_client *client = data->client;
@@ -493,6 +563,8 @@ static int vl6180_init(struct vl6180_data *data)
if (ret < 0)
return ret;
vl6180_misc_init(data);
return vl6180_hold(data, false);
}