18 #include <linux/module.h>
19 #include <linux/i2c.h>
26 #define VCNL4000_DRV_NAME "vcnl4000"
28 #define VCNL4000_COMMAND 0x80
29 #define VCNL4000_PROD_REV 0x81
30 #define VCNL4000_LED_CURRENT 0x83
31 #define VCNL4000_AL_PARAM 0x84
32 #define VCNL4000_AL_RESULT_HI 0x85
33 #define VCNL4000_AL_RESULT_LO 0x86
34 #define VCNL4000_PS_RESULT_HI 0x87
35 #define VCNL4000_PS_RESULT_LO 0x88
36 #define VCNL4000_PS_MEAS_FREQ 0x89
37 #define VCNL4000_PS_MOD_ADJ 0x8a
40 #define VCNL4000_AL_RDY 0x40
41 #define VCNL4000_PS_RDY 0x20
42 #define VCNL4000_AL_OD 0x10
43 #define VCNL4000_PS_OD 0x08
56 u8 rdy_mask,
u8 data_reg,
int *
val)
79 "vcnl4000_measure() failed, data not ready\n");
84 data_reg,
sizeof(buf), (
u8 *) &buf);
104 static int vcnl4000_read_raw(
struct iio_dev *indio_dev,
106 int *val,
int *val2,
long mask)
113 switch (chan->
type) {
115 ret = vcnl4000_measure(data,
123 ret = vcnl4000_measure(data,
148 static const struct iio_info vcnl4000_info = {
149 .read_raw = vcnl4000_read_raw,
164 data = iio_priv(indio_dev);
165 i2c_set_clientdata(client, indio_dev);
172 dev_info(&client->
dev,
"VCNL4000 Ambient light/proximity sensor, Prod %02x, Rev: %02x\n",
173 ret >> 4, ret & 0xf);
175 indio_dev->
dev.parent = &client->
dev;
176 indio_dev->
info = &vcnl4000_info;
177 indio_dev->
channels = vcnl4000_channels;
195 struct iio_dev *indio_dev = i2c_get_clientdata(client);
208 .probe = vcnl4000_probe,
210 .id_table = vcnl4000_id,