Merge branch 'next/drivers' into HEAD
[deliverable/linux.git] / drivers / staging / iio / light / isl29018.c
CommitLineData
94042874
RK
1/*
2 * A iio driver for the light sensor ISL 29018.
3 *
4 * IIO driver for monitoring ambient light intensity in luxi, proximity
5 * sensing and infrared sensing.
6 *
7 * Copyright (c) 2010, NVIDIA Corporation.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/i2c.h>
26#include <linux/err.h>
27#include <linux/mutex.h>
28#include <linux/delay.h>
057340e3 29#include <linux/regmap.h>
94042874 30#include <linux/slab.h>
06458e27
JC
31#include <linux/iio/iio.h>
32#include <linux/iio/sysfs.h>
057340e3 33
94042874
RK
34#define CONVERSION_TIME_MS 100
35
36#define ISL29018_REG_ADD_COMMAND1 0x00
37#define COMMMAND1_OPMODE_SHIFT 5
38#define COMMMAND1_OPMODE_MASK (7 << COMMMAND1_OPMODE_SHIFT)
39#define COMMMAND1_OPMODE_POWER_DOWN 0
40#define COMMMAND1_OPMODE_ALS_ONCE 1
41#define COMMMAND1_OPMODE_IR_ONCE 2
42#define COMMMAND1_OPMODE_PROX_ONCE 3
43
44#define ISL29018_REG_ADD_COMMANDII 0x01
45#define COMMANDII_RESOLUTION_SHIFT 2
46#define COMMANDII_RESOLUTION_MASK (0x3 << COMMANDII_RESOLUTION_SHIFT)
47
48#define COMMANDII_RANGE_SHIFT 0
49#define COMMANDII_RANGE_MASK (0x3 << COMMANDII_RANGE_SHIFT)
50
51#define COMMANDII_SCHEME_SHIFT 7
52#define COMMANDII_SCHEME_MASK (0x1 << COMMANDII_SCHEME_SHIFT)
53
54#define ISL29018_REG_ADD_DATA_LSB 0x02
55#define ISL29018_REG_ADD_DATA_MSB 0x03
94042874 56
176f9f29
GG
57#define ISL29018_REG_TEST 0x08
58#define ISL29018_TEST_SHIFT 0
59#define ISL29018_TEST_MASK (0xFF << ISL29018_TEST_SHIFT)
60
94042874 61struct isl29018_chip {
057340e3
LD
62 struct device *dev;
63 struct regmap *regmap;
94042874 64 struct mutex lock;
6d1ad0f8 65 unsigned int lux_scale;
932323b7 66 unsigned int lux_uscale;
94042874
RK
67 unsigned int range;
68 unsigned int adc_bit;
69 int prox_scheme;
94042874
RK
70};
71
057340e3 72static int isl29018_set_range(struct isl29018_chip *chip, unsigned long range,
94042874
RK
73 unsigned int *new_range)
74{
75 static const unsigned long supp_ranges[] = {1000, 4000, 16000, 64000};
76 int i;
77
78 for (i = 0; i < ARRAY_SIZE(supp_ranges); ++i) {
79 if (range <= supp_ranges[i]) {
80 *new_range = (unsigned int)supp_ranges[i];
81 break;
82 }
83 }
84
85 if (i >= ARRAY_SIZE(supp_ranges))
86 return -EINVAL;
87
057340e3
LD
88 return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
89 COMMANDII_RANGE_MASK, i << COMMANDII_RANGE_SHIFT);
94042874
RK
90}
91
057340e3 92static int isl29018_set_resolution(struct isl29018_chip *chip,
94042874
RK
93 unsigned long adcbit, unsigned int *conf_adc_bit)
94{
95 static const unsigned long supp_adcbit[] = {16, 12, 8, 4};
96 int i;
97
98 for (i = 0; i < ARRAY_SIZE(supp_adcbit); ++i) {
99 if (adcbit >= supp_adcbit[i]) {
100 *conf_adc_bit = (unsigned int)supp_adcbit[i];
101 break;
102 }
103 }
104
105 if (i >= ARRAY_SIZE(supp_adcbit))
106 return -EINVAL;
107
057340e3
LD
108 return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
109 COMMANDII_RESOLUTION_MASK,
110 i << COMMANDII_RESOLUTION_SHIFT);
94042874
RK
111}
112
057340e3 113static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
94042874
RK
114{
115 int status;
057340e3
LD
116 unsigned int lsb;
117 unsigned int msb;
94042874
RK
118
119 /* Set mode */
057340e3
LD
120 status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1,
121 mode << COMMMAND1_OPMODE_SHIFT);
94042874 122 if (status) {
057340e3
LD
123 dev_err(chip->dev,
124 "Error in setting operating mode err %d\n", status);
94042874
RK
125 return status;
126 }
127 msleep(CONVERSION_TIME_MS);
057340e3
LD
128 status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_LSB, &lsb);
129 if (status < 0) {
130 dev_err(chip->dev,
131 "Error in reading LSB DATA with err %d\n", status);
132 return status;
94042874
RK
133 }
134
057340e3
LD
135 status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_MSB, &msb);
136 if (status < 0) {
137 dev_err(chip->dev,
138 "Error in reading MSB DATA with error %d\n", status);
139 return status;
94042874 140 }
057340e3 141 dev_vdbg(chip->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb);
94042874
RK
142
143 return (msb << 8) | lsb;
144}
145
057340e3 146static int isl29018_read_lux(struct isl29018_chip *chip, int *lux)
94042874
RK
147{
148 int lux_data;
932323b7 149 unsigned int data_x_range, lux_unshifted;
94042874 150
057340e3 151 lux_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_ALS_ONCE);
94042874
RK
152
153 if (lux_data < 0)
154 return lux_data;
155
932323b7
BF
156 /* To support fractional scaling, separate the unshifted lux
157 * into two calculations: int scaling and micro-scaling.
158 * lux_uscale ranges from 0-999999, so about 20 bits. Split
159 * the /1,000,000 in two to reduce the risk of over/underflow.
160 */
161 data_x_range = lux_data * chip->range;
162 lux_unshifted = data_x_range * chip->lux_scale;
163 lux_unshifted += data_x_range / 1000 * chip->lux_uscale / 1000;
164 *lux = lux_unshifted >> chip->adc_bit;
94042874
RK
165
166 return 0;
167}
168
057340e3 169static int isl29018_read_ir(struct isl29018_chip *chip, int *ir)
94042874
RK
170{
171 int ir_data;
172
057340e3 173 ir_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_IR_ONCE);
94042874
RK
174
175 if (ir_data < 0)
176 return ir_data;
177
178 *ir = ir_data;
179
180 return 0;
181}
182
057340e3 183static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme,
94042874
RK
184 int *near_ir)
185{
186 int status;
187 int prox_data = -1;
188 int ir_data = -1;
189
190 /* Do proximity sensing with required scheme */
057340e3
LD
191 status = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
192 COMMANDII_SCHEME_MASK,
193 scheme << COMMANDII_SCHEME_SHIFT);
94042874 194 if (status) {
057340e3 195 dev_err(chip->dev, "Error in setting operating mode\n");
94042874
RK
196 return status;
197 }
198
057340e3 199 prox_data = isl29018_read_sensor_input(chip,
94042874
RK
200 COMMMAND1_OPMODE_PROX_ONCE);
201 if (prox_data < 0)
202 return prox_data;
203
204 if (scheme == 1) {
205 *near_ir = prox_data;
206 return 0;
207 }
208
057340e3 209 ir_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_IR_ONCE);
94042874
RK
210
211 if (ir_data < 0)
212 return ir_data;
213
214 if (prox_data >= ir_data)
215 *near_ir = prox_data - ir_data;
216 else
217 *near_ir = 0;
218
219 return 0;
220}
221
94042874
RK
222/* Sysfs interface */
223/* range */
224static ssize_t show_range(struct device *dev,
225 struct device_attribute *attr, char *buf)
226{
96f691f9 227 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
927afbec 228 struct isl29018_chip *chip = iio_priv(indio_dev);
94042874
RK
229
230 return sprintf(buf, "%u\n", chip->range);
231}
232
233static ssize_t store_range(struct device *dev,
234 struct device_attribute *attr, const char *buf, size_t count)
235{
96f691f9 236 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
927afbec 237 struct isl29018_chip *chip = iio_priv(indio_dev);
94042874
RK
238 int status;
239 unsigned long lval;
240 unsigned int new_range;
241
242 if (strict_strtoul(buf, 10, &lval))
243 return -EINVAL;
244
245 if (!(lval == 1000UL || lval == 4000UL ||
246 lval == 16000UL || lval == 64000UL)) {
247 dev_err(dev, "The range is not supported\n");
248 return -EINVAL;
249 }
250
251 mutex_lock(&chip->lock);
057340e3 252 status = isl29018_set_range(chip, lval, &new_range);
94042874
RK
253 if (status < 0) {
254 mutex_unlock(&chip->lock);
057340e3
LD
255 dev_err(dev,
256 "Error in setting max range with err %d\n", status);
94042874
RK
257 return status;
258 }
259 chip->range = new_range;
260 mutex_unlock(&chip->lock);
261
262 return count;
263}
264
265/* resolution */
266static ssize_t show_resolution(struct device *dev,
267 struct device_attribute *attr, char *buf)
268{
96f691f9 269 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
927afbec 270 struct isl29018_chip *chip = iio_priv(indio_dev);
94042874
RK
271
272 return sprintf(buf, "%u\n", chip->adc_bit);
273}
274
275static ssize_t store_resolution(struct device *dev,
276 struct device_attribute *attr, const char *buf, size_t count)
277{
96f691f9 278 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
927afbec 279 struct isl29018_chip *chip = iio_priv(indio_dev);
94042874
RK
280 int status;
281 unsigned long lval;
282 unsigned int new_adc_bit;
283
284 if (strict_strtoul(buf, 10, &lval))
285 return -EINVAL;
286 if (!(lval == 4 || lval == 8 || lval == 12 || lval == 16)) {
287 dev_err(dev, "The resolution is not supported\n");
288 return -EINVAL;
289 }
290
291 mutex_lock(&chip->lock);
057340e3 292 status = isl29018_set_resolution(chip, lval, &new_adc_bit);
94042874
RK
293 if (status < 0) {
294 mutex_unlock(&chip->lock);
295 dev_err(dev, "Error in setting resolution\n");
296 return status;
297 }
298 chip->adc_bit = new_adc_bit;
299 mutex_unlock(&chip->lock);
300
301 return count;
302}
303
304/* proximity scheme */
2a1d45ec 305static ssize_t show_prox_infrared_suppression(struct device *dev,
94042874
RK
306 struct device_attribute *attr, char *buf)
307{
96f691f9 308 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
927afbec 309 struct isl29018_chip *chip = iio_priv(indio_dev);
94042874
RK
310
311 /* return the "proximity scheme" i.e. if the chip does on chip
2a1d45ec 312 infrared suppression (1 means perform on chip suppression) */
94042874
RK
313 return sprintf(buf, "%d\n", chip->prox_scheme);
314}
315
2a1d45ec 316static ssize_t store_prox_infrared_suppression(struct device *dev,
94042874
RK
317 struct device_attribute *attr, const char *buf, size_t count)
318{
96f691f9 319 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
927afbec 320 struct isl29018_chip *chip = iio_priv(indio_dev);
94042874
RK
321 unsigned long lval;
322
323 if (strict_strtoul(buf, 10, &lval))
324 return -EINVAL;
325 if (!(lval == 0UL || lval == 1UL)) {
326 dev_err(dev, "The mode is not supported\n");
327 return -EINVAL;
328 }
329
330 /* get the "proximity scheme" i.e. if the chip does on chip
2a1d45ec 331 infrared suppression (1 means perform on chip suppression) */
94042874
RK
332 mutex_lock(&chip->lock);
333 chip->prox_scheme = (int)lval;
334 mutex_unlock(&chip->lock);
335
336 return count;
337}
338
01e57c57
BF
339/* Channel IO */
340static int isl29018_write_raw(struct iio_dev *indio_dev,
341 struct iio_chan_spec const *chan,
342 int val,
343 int val2,
344 long mask)
94042874 345{
01e57c57
BF
346 struct isl29018_chip *chip = iio_priv(indio_dev);
347 int ret = -EINVAL;
94042874 348
01e57c57 349 mutex_lock(&chip->lock);
c8a9f805 350 if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) {
01e57c57 351 chip->lux_scale = val;
932323b7
BF
352 /* With no write_raw_get_fmt(), val2 is a MICRO fraction. */
353 chip->lux_uscale = val2;
01e57c57
BF
354 ret = 0;
355 }
356 mutex_unlock(&chip->lock);
357
358 return 0;
94042874
RK
359}
360
01e57c57
BF
361static int isl29018_read_raw(struct iio_dev *indio_dev,
362 struct iio_chan_spec const *chan,
363 int *val,
364 int *val2,
365 long mask)
94042874 366{
01e57c57
BF
367 int ret = -EINVAL;
368 struct isl29018_chip *chip = iio_priv(indio_dev);
01e57c57
BF
369
370 mutex_lock(&chip->lock);
371 switch (mask) {
90354d00
JC
372 case IIO_CHAN_INFO_RAW:
373 case IIO_CHAN_INFO_PROCESSED:
01e57c57
BF
374 switch (chan->type) {
375 case IIO_LIGHT:
057340e3 376 ret = isl29018_read_lux(chip, val);
01e57c57
BF
377 break;
378 case IIO_INTENSITY:
057340e3 379 ret = isl29018_read_ir(chip, val);
01e57c57
BF
380 break;
381 case IIO_PROXIMITY:
057340e3 382 ret = isl29018_read_proximity_ir(chip,
01e57c57
BF
383 chip->prox_scheme, val);
384 break;
385 default:
386 break;
387 }
388 if (!ret)
389 ret = IIO_VAL_INT;
390 break;
c8a9f805 391 case IIO_CHAN_INFO_CALIBSCALE:
01e57c57
BF
392 if (chan->type == IIO_LIGHT) {
393 *val = chip->lux_scale;
932323b7
BF
394 *val2 = chip->lux_uscale;
395 ret = IIO_VAL_INT_PLUS_MICRO;
01e57c57
BF
396 }
397 break;
398 default:
399 break;
400 }
401 mutex_unlock(&chip->lock);
402 return ret;
94042874
RK
403}
404
01e57c57
BF
405static const struct iio_chan_spec isl29018_channels[] = {
406 {
407 .type = IIO_LIGHT,
408 .indexed = 1,
409 .channel = 0,
90354d00
JC
410 .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT |
411 IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
01e57c57
BF
412 }, {
413 .type = IIO_INTENSITY,
414 .modified = 1,
90354d00 415 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
01e57c57
BF
416 .channel2 = IIO_MOD_LIGHT_IR,
417 }, {
418 /* Unindexed in current ABI. But perhaps it should be. */
419 .type = IIO_PROXIMITY,
90354d00 420 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
01e57c57
BF
421 }
422};
423
94042874
RK
424static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0);
425static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000");
426static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16");
427static IIO_DEVICE_ATTR(adc_resolution, S_IRUGO | S_IWUSR,
428 show_resolution, store_resolution, 0);
2a1d45ec 429static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_suppression,
94042874 430 S_IRUGO | S_IWUSR,
2a1d45ec
PM
431 show_prox_infrared_suppression,
432 store_prox_infrared_suppression, 0);
94042874
RK
433
434#define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr)
435#define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
436static struct attribute *isl29018_attributes[] = {
94042874
RK
437 ISL29018_DEV_ATTR(range),
438 ISL29018_CONST_ATTR(range_available),
439 ISL29018_DEV_ATTR(adc_resolution),
440 ISL29018_CONST_ATTR(adc_resolution_available),
2a1d45ec 441 ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_suppression),
94042874
RK
442 NULL
443};
444
445static const struct attribute_group isl29108_group = {
446 .attrs = isl29018_attributes,
447};
448
057340e3 449static int isl29018_chip_init(struct isl29018_chip *chip)
94042874 450{
94042874
RK
451 int status;
452 int new_adc_bit;
453 unsigned int new_range;
454
176f9f29
GG
455 /* Code added per Intersil Application Note 1534:
456 * When VDD sinks to approximately 1.8V or below, some of
457 * the part's registers may change their state. When VDD
458 * recovers to 2.25V (or greater), the part may thus be in an
459 * unknown mode of operation. The user can return the part to
460 * a known mode of operation either by (a) setting VDD = 0V for
461 * 1 second or more and then powering back up with a slew rate
462 * of 0.5V/ms or greater, or (b) via I2C disable all ALS/PROX
463 * conversions, clear the test registers, and then rewrite all
464 * registers to the desired values.
465 * ...
466 * FOR ISL29011, ISL29018, ISL29021, ISL29023
467 * 1. Write 0x00 to register 0x08 (TEST)
468 * 2. Write 0x00 to register 0x00 (CMD1)
469 * 3. Rewrite all registers to the desired values
470 *
471 * ISL29018 Data Sheet (FN6619.1, Feb 11, 2010) essentially says
472 * the same thing EXCEPT the data sheet asks for a 1ms delay after
473 * writing the CMD1 register.
474 */
057340e3 475 status = regmap_write(chip->regmap, ISL29018_REG_TEST, 0x0);
176f9f29 476 if (status < 0) {
057340e3 477 dev_err(chip->dev, "Failed to clear isl29018 TEST reg."
176f9f29
GG
478 "(%d)\n", status);
479 return status;
480 }
481
482 /* See Intersil AN1534 comments above.
483 * "Operating Mode" (COMMAND1) register is reprogrammed when
484 * data is read from the device.
485 */
057340e3 486 status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, 0);
176f9f29 487 if (status < 0) {
057340e3 488 dev_err(chip->dev, "Failed to clear isl29018 CMD1 reg."
176f9f29
GG
489 "(%d)\n", status);
490 return status;
491 }
492
493 msleep(1); /* per data sheet, page 10 */
494
94042874 495 /* set defaults */
057340e3 496 status = isl29018_set_range(chip, chip->range, &new_range);
94042874 497 if (status < 0) {
057340e3 498 dev_err(chip->dev, "Init of isl29018 fails\n");
94042874
RK
499 return status;
500 }
501
057340e3 502 status = isl29018_set_resolution(chip, chip->adc_bit,
94042874
RK
503 &new_adc_bit);
504
505 return 0;
506}
507
6fe8135f
JC
508static const struct iio_info isl29108_info = {
509 .attrs = &isl29108_group,
510 .driver_module = THIS_MODULE,
01e57c57
BF
511 .read_raw = &isl29018_read_raw,
512 .write_raw = &isl29018_write_raw,
6fe8135f
JC
513};
514
057340e3
LD
515static bool is_volatile_reg(struct device *dev, unsigned int reg)
516{
517 switch (reg) {
518 case ISL29018_REG_ADD_DATA_LSB:
519 case ISL29018_REG_ADD_DATA_MSB:
520 case ISL29018_REG_ADD_COMMAND1:
521 case ISL29018_REG_TEST:
522 return true;
523 default:
524 return false;
525 }
526}
527
528/*
529 * isl29018_regmap_config: regmap configuration.
530 * Use RBTREE mechanism for caching.
531 */
532static const struct regmap_config isl29018_regmap_config = {
533 .reg_bits = 8,
534 .val_bits = 8,
535 .volatile_reg = is_volatile_reg,
536 .max_register = ISL29018_REG_TEST,
537 .num_reg_defaults_raw = ISL29018_REG_TEST + 1,
538 .cache_type = REGCACHE_RBTREE,
539};
540
94042874
RK
541static int __devinit isl29018_probe(struct i2c_client *client,
542 const struct i2c_device_id *id)
543{
544 struct isl29018_chip *chip;
927afbec 545 struct iio_dev *indio_dev;
94042874
RK
546 int err;
547
7cbb7537 548 indio_dev = iio_device_alloc(sizeof(*chip));
927afbec
JC
549 if (indio_dev == NULL) {
550 dev_err(&client->dev, "iio allocation fails\n");
94042874
RK
551 err = -ENOMEM;
552 goto exit;
553 }
927afbec 554 chip = iio_priv(indio_dev);
94042874 555
927afbec 556 i2c_set_clientdata(client, indio_dev);
057340e3 557 chip->dev = &client->dev;
94042874
RK
558
559 mutex_init(&chip->lock);
560
6d1ad0f8 561 chip->lux_scale = 1;
94042874
RK
562 chip->range = 1000;
563 chip->adc_bit = 16;
564
057340e3
LD
565 chip->regmap = devm_regmap_init_i2c(client, &isl29018_regmap_config);
566 if (IS_ERR(chip->regmap)) {
567 err = PTR_ERR(chip->regmap);
568 dev_err(chip->dev, "regmap initialization failed: %d\n", err);
569 goto exit;
570 }
571
572 err = isl29018_chip_init(chip);
94042874 573 if (err)
927afbec 574 goto exit_iio_free;
94042874 575
927afbec 576 indio_dev->info = &isl29108_info;
01e57c57
BF
577 indio_dev->channels = isl29018_channels;
578 indio_dev->num_channels = ARRAY_SIZE(isl29018_channels);
927afbec
JC
579 indio_dev->name = id->name;
580 indio_dev->dev.parent = &client->dev;
581 indio_dev->modes = INDIO_DIRECT_MODE;
582 err = iio_device_register(indio_dev);
94042874
RK
583 if (err) {
584 dev_err(&client->dev, "iio registration fails\n");
585 goto exit_iio_free;
586 }
587
588 return 0;
589exit_iio_free:
7cbb7537 590 iio_device_free(indio_dev);
94042874
RK
591exit:
592 return err;
593}
594
595static int __devexit isl29018_remove(struct i2c_client *client)
596{
927afbec 597 struct iio_dev *indio_dev = i2c_get_clientdata(client);
94042874
RK
598
599 dev_dbg(&client->dev, "%s()\n", __func__);
927afbec 600 iio_device_unregister(indio_dev);
7cbb7537 601 iio_device_free(indio_dev);
94042874
RK
602
603 return 0;
604}
605
606static const struct i2c_device_id isl29018_id[] = {
607 {"isl29018", 0},
608 {}
609};
610
611MODULE_DEVICE_TABLE(i2c, isl29018_id);
612
4ee19524 613static const struct of_device_id isl29018_of_match[] = {
610202dd 614 { .compatible = "isil,isl29018", },
4ee19524
OJ
615 { },
616};
617MODULE_DEVICE_TABLE(of, isl29018_of_match);
618
94042874
RK
619static struct i2c_driver isl29018_driver = {
620 .class = I2C_CLASS_HWMON,
621 .driver = {
622 .name = "isl29018",
623 .owner = THIS_MODULE,
4ee19524 624 .of_match_table = isl29018_of_match,
94042874
RK
625 },
626 .probe = isl29018_probe,
627 .remove = __devexit_p(isl29018_remove),
628 .id_table = isl29018_id,
629};
6e5af184 630module_i2c_driver(isl29018_driver);
94042874
RK
631
632MODULE_DESCRIPTION("ISL29018 Ambient Light Sensor driver");
633MODULE_LICENSE("GPL");
This page took 0.246106 seconds and 5 git commands to generate.