isl29028.c 17.2 KB
Newer Older
1 2 3 4 5
/*
 * IIO driver for the light sensor ISL29028.
 * ISL29028 is Concurrent Ambient Light and Proximity Sensor
 *
 * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
6
 * Copyright (c) 2016-2017 Brian Masney <masneyb@onstation.org>
7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 20 21 22
 *
 * Datasheets:
 *  - http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29028.pdf
 *  - http://www.intersil.com/content/dam/Intersil/documents/isl2/isl29030.pdf
23 24 25 26 27 28 29 30 31
 */

#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/regmap.h>
32 33
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
34
#include <linux/pm_runtime.h>
35

36
#define ISL29028_CONV_TIME_MS			100
37

38
#define ISL29028_REG_CONFIGURE			0x01
39

40 41 42
#define ISL29028_CONF_ALS_IR_MODE_ALS		0
#define ISL29028_CONF_ALS_IR_MODE_IR		BIT(0)
#define ISL29028_CONF_ALS_IR_MODE_MASK		BIT(0)
43

44
#define ISL29028_CONF_ALS_RANGE_LOW_LUX		0
45
#define ISL29028_CONF_ALS_RANGE_HIGH_LUX	BIT(1)
46
#define ISL29028_CONF_ALS_RANGE_MASK		BIT(1)
47

48 49 50
#define ISL29028_CONF_ALS_DIS			0
#define ISL29028_CONF_ALS_EN			BIT(2)
#define ISL29028_CONF_ALS_EN_MASK		BIT(2)
51

52 53
#define ISL29028_CONF_PROX_SLP_SH		4
#define ISL29028_CONF_PROX_SLP_MASK		(7 << ISL29028_CONF_PROX_SLP_SH)
54

55 56
#define ISL29028_CONF_PROX_EN			BIT(7)
#define ISL29028_CONF_PROX_EN_MASK		BIT(7)
57

58
#define ISL29028_REG_INTERRUPT			0x02
59

60 61 62
#define ISL29028_REG_PROX_DATA			0x08
#define ISL29028_REG_ALSIR_L			0x09
#define ISL29028_REG_ALSIR_U			0x0A
63

64 65
#define ISL29028_REG_TEST1_MODE			0x0E
#define ISL29028_REG_TEST2_MODE			0x0F
66

67
#define ISL29028_NUM_REGS			(ISL29028_REG_TEST2_MODE + 1)
68

69 70
#define ISL29028_POWER_OFF_DELAY_MS		2000

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
struct isl29028_prox_data {
	int sampling_int;
	int sampling_fract;
	int sleep_time;
};

static const struct isl29028_prox_data isl29028_prox_data[] = {
	{   1, 250000, 800 },
	{   2, 500000, 400 },
	{   5,      0, 200 },
	{  10,      0, 100 },
	{  13, 300000,  75 },
	{  20,      0,  50 },
	{  80,      0,  13 }, /*
			       * Note: Data sheet lists 12.5 ms sleep time.
			       * Round up a half millisecond for msleep().
			       */
	{ 100,  0,   0 }
};
90

91 92 93 94
enum isl29028_als_ir_mode {
	ISL29028_MODE_NONE = 0,
	ISL29028_MODE_ALS,
	ISL29028_MODE_IR,
95 96 97
};

struct isl29028_chip {
98 99
	struct mutex			lock;
	struct regmap			*regmap;
100 101
	int				prox_sampling_int;
	int				prox_sampling_frac;
102 103
	bool				enable_prox;
	int				lux_scale;
104
	enum isl29028_als_ir_mode	als_ir_mode;
105 106
};

107
static int isl29028_find_prox_sleep_index(int sampling_int, int sampling_fract)
108
{
109
	int i;
110

111 112 113 114
	for (i = 0; i < ARRAY_SIZE(isl29028_prox_data); ++i) {
		if (isl29028_prox_data[i].sampling_int == sampling_int &&
		    isl29028_prox_data[i].sampling_fract == sampling_fract)
			return i;
115
	}
116

117
	return -EINVAL;
118 119 120
}

static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
121
					int sampling_int, int sampling_fract)
122 123 124 125
{
	struct device *dev = regmap_get_device(chip->regmap);
	int sleep_index, ret;

126 127 128 129 130
	sleep_index = isl29028_find_prox_sleep_index(sampling_int,
						     sampling_fract);
	if (sleep_index < 0)
		return sleep_index;

131 132
	ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
				 ISL29028_CONF_PROX_SLP_MASK,
133
				 sleep_index << ISL29028_CONF_PROX_SLP_SH);
134 135 136 137 138 139 140

	if (ret < 0) {
		dev_err(dev, "%s(): Error %d setting the proximity sampling\n",
			__func__, ret);
		return ret;
	}

141 142
	chip->prox_sampling_int = sampling_int;
	chip->prox_sampling_frac = sampling_fract;
143 144

	return ret;
145 146
}

147
static int isl29028_enable_proximity(struct isl29028_chip *chip)
148
{
149
	int prox_index, ret;
150

151 152
	ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling_int,
					   chip->prox_sampling_frac);
153 154 155
	if (ret < 0)
		return ret;

156
	ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
157 158
				 ISL29028_CONF_PROX_EN_MASK,
				 ISL29028_CONF_PROX_EN);
159 160 161 162
	if (ret < 0)
		return ret;

	/* Wait for conversion to be complete for first sample */
163 164 165 166 167 168
	prox_index = isl29028_find_prox_sleep_index(chip->prox_sampling_int,
						    chip->prox_sampling_frac);
	if (prox_index < 0)
		return prox_index;

	msleep(isl29028_prox_data[prox_index].sleep_time);
169

170 171 172 173 174
	return 0;
}

static int isl29028_set_als_scale(struct isl29028_chip *chip, int lux_scale)
{
175
	struct device *dev = regmap_get_device(chip->regmap);
176 177
	int val = (lux_scale == 2000) ? ISL29028_CONF_ALS_RANGE_HIGH_LUX :
					ISL29028_CONF_ALS_RANGE_LOW_LUX;
178 179 180 181 182 183 184 185 186 187 188
	int ret;

	ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
				 ISL29028_CONF_ALS_RANGE_MASK, val);
	if (ret < 0) {
		dev_err(dev, "%s(): Error %d setting the ALS scale\n", __func__,
			ret);
		return ret;
	}

	chip->lux_scale = lux_scale;
189

190
	return ret;
191 192 193
}

static int isl29028_set_als_ir_mode(struct isl29028_chip *chip,
194
				    enum isl29028_als_ir_mode mode)
195
{
196
	int ret;
197

198 199 200
	if (chip->als_ir_mode == mode)
		return 0;

201 202 203 204
	ret = isl29028_set_als_scale(chip, chip->lux_scale);
	if (ret < 0)
		return ret;

205
	switch (mode) {
206
	case ISL29028_MODE_ALS:
207
		ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
208 209
					 ISL29028_CONF_ALS_IR_MODE_MASK,
					 ISL29028_CONF_ALS_IR_MODE_ALS);
210 211 212 213
		if (ret < 0)
			return ret;

		ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
214 215
					 ISL29028_CONF_ALS_RANGE_MASK,
					 ISL29028_CONF_ALS_RANGE_HIGH_LUX);
216
		break;
217
	case ISL29028_MODE_IR:
218
		ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
219 220
					 ISL29028_CONF_ALS_IR_MODE_MASK,
					 ISL29028_CONF_ALS_IR_MODE_IR);
221
		break;
222
	case ISL29028_MODE_NONE:
223
		return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
224 225
					  ISL29028_CONF_ALS_EN_MASK,
					  ISL29028_CONF_ALS_DIS);
226 227 228 229 230 231 232
	}

	if (ret < 0)
		return ret;

	/* Enable the ALS/IR */
	ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
233 234
				 ISL29028_CONF_ALS_EN_MASK,
				 ISL29028_CONF_ALS_EN);
235 236 237 238
	if (ret < 0)
		return ret;

	/* Need to wait for conversion time if ALS/IR mode enabled */
239
	msleep(ISL29028_CONV_TIME_MS);
240 241 242

	chip->als_ir_mode = mode;

243 244 245 246 247
	return 0;
}

static int isl29028_read_als_ir(struct isl29028_chip *chip, int *als_ir)
{
248
	struct device *dev = regmap_get_device(chip->regmap);
249 250 251 252 253 254
	unsigned int lsb;
	unsigned int msb;
	int ret;

	ret = regmap_read(chip->regmap, ISL29028_REG_ALSIR_L, &lsb);
	if (ret < 0) {
255
		dev_err(dev,
256 257
			"%s(): Error %d reading register ALSIR_L\n",
			__func__, ret);
258 259 260 261 262
		return ret;
	}

	ret = regmap_read(chip->regmap, ISL29028_REG_ALSIR_U, &msb);
	if (ret < 0) {
263
		dev_err(dev,
264 265
			"%s(): Error %d reading register ALSIR_U\n",
			__func__, ret);
266 267 268 269
		return ret;
	}

	*als_ir = ((msb & 0xF) << 8) | (lsb & 0xFF);
270

271 272 273 274 275
	return 0;
}

static int isl29028_read_proxim(struct isl29028_chip *chip, int *prox)
{
276
	struct device *dev = regmap_get_device(chip->regmap);
277 278 279
	unsigned int data;
	int ret;

280
	if (!chip->enable_prox) {
281
		ret = isl29028_enable_proximity(chip);
282 283
		if (ret < 0)
			return ret;
284

285 286 287
		chip->enable_prox = true;
	}

288 289
	ret = regmap_read(chip->regmap, ISL29028_REG_PROX_DATA, &data);
	if (ret < 0) {
290 291
		dev_err(dev, "%s(): Error %d reading register PROX_DATA\n",
			__func__, ret);
292 293
		return ret;
	}
294

295
	*prox = data;
296

297 298 299 300 301
	return 0;
}

static int isl29028_als_get(struct isl29028_chip *chip, int *als_data)
{
302
	struct device *dev = regmap_get_device(chip->regmap);
303 304 305
	int ret;
	int als_ir_data;

306 307
	ret = isl29028_set_als_ir_mode(chip, ISL29028_MODE_ALS);
	if (ret < 0) {
308 309
		dev_err(dev, "%s(): Error %d enabling ALS mode\n", __func__,
			ret);
310
		return ret;
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
	}

	ret = isl29028_read_als_ir(chip, &als_ir_data);
	if (ret < 0)
		return ret;

	/*
	 * convert als data count to lux.
	 * if lux_scale = 125,  lux = count * 0.031
	 * if lux_scale = 2000, lux = count * 0.49
	 */
	if (chip->lux_scale == 125)
		als_ir_data = (als_ir_data * 31) / 1000;
	else
		als_ir_data = (als_ir_data * 49) / 100;

	*als_data = als_ir_data;
328

329 330 331 332 333
	return 0;
}

static int isl29028_ir_get(struct isl29028_chip *chip, int *ir_data)
{
334
	struct device *dev = regmap_get_device(chip->regmap);
335 336
	int ret;

337 338
	ret = isl29028_set_als_ir_mode(chip, ISL29028_MODE_IR);
	if (ret < 0) {
339 340
		dev_err(dev, "%s(): Error %d enabling IR mode\n", __func__,
			ret);
341
		return ret;
342
	}
343

344 345 346
	return isl29028_read_als_ir(chip, ir_data);
}

347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
static int isl29028_set_pm_runtime_busy(struct isl29028_chip *chip, bool on)
{
	struct device *dev = regmap_get_device(chip->regmap);
	int ret;

	if (on) {
		ret = pm_runtime_get_sync(dev);
		if (ret < 0)
			pm_runtime_put_noidle(dev);
	} else {
		pm_runtime_mark_last_busy(dev);
		ret = pm_runtime_put_autosuspend(dev);
	}

	return ret;
}

364 365
/* Channel IO */
static int isl29028_write_raw(struct iio_dev *indio_dev,
366 367
			      struct iio_chan_spec const *chan,
			      int val, int val2, long mask)
368 369
{
	struct isl29028_chip *chip = iio_priv(indio_dev);
370
	struct device *dev = regmap_get_device(chip->regmap);
371 372 373 374 375
	int ret;

	ret = isl29028_set_pm_runtime_busy(chip, true);
	if (ret < 0)
		return ret;
376 377

	mutex_lock(&chip->lock);
378 379

	ret = -EINVAL;
380 381
	switch (chan->type) {
	case IIO_PROXIMITY:
382
		if (mask != IIO_CHAN_INFO_SAMP_FREQ) {
383
			dev_err(dev,
384 385
				"%s(): proximity: Mask value 0x%08lx is not supported\n",
				__func__, mask);
386 387
			break;
		}
388

389
		if (val < 1 || val > 100) {
390
			dev_err(dev,
391 392
				"%s(): proximity: Sampling frequency %d is not in the range [1:100]\n",
				__func__, val);
393 394
			break;
		}
395

396
		ret = isl29028_set_proxim_sampling(chip, val, val2);
397 398
		break;
	case IIO_LIGHT:
399
		if (mask != IIO_CHAN_INFO_SCALE) {
400
			dev_err(dev,
401 402
				"%s(): light: Mask value 0x%08lx is not supported\n",
				__func__, mask);
403 404
			break;
		}
405

406
		if (val != 125 && val != 2000) {
407
			dev_err(dev,
408 409
				"%s(): light: Lux scale %d is not in the set {125, 2000}\n",
				__func__, val);
410 411
			break;
		}
412

413 414 415
		ret = isl29028_set_als_scale(chip, val);
		break;
	default:
416 417
		dev_err(dev, "%s(): Unsupported channel type %x\n",
			__func__, chan->type);
418 419
		break;
	}
420

421
	mutex_unlock(&chip->lock);
422

423 424 425 426 427 428 429
	if (ret < 0)
		return ret;

	ret = isl29028_set_pm_runtime_busy(chip, false);
	if (ret < 0)
		return ret;

430 431 432 433
	return ret;
}

static int isl29028_read_raw(struct iio_dev *indio_dev,
434 435
			     struct iio_chan_spec const *chan,
			     int *val, int *val2, long mask)
436 437
{
	struct isl29028_chip *chip = iio_priv(indio_dev);
438
	struct device *dev = regmap_get_device(chip->regmap);
439 440 441 442 443
	int ret, pm_ret;

	ret = isl29028_set_pm_runtime_busy(chip, true);
	if (ret < 0)
		return ret;
444 445

	mutex_lock(&chip->lock);
446 447

	ret = -EINVAL;
448
	switch (mask) {
449 450
	case IIO_CHAN_INFO_RAW:
	case IIO_CHAN_INFO_PROCESSED:
451 452 453 454 455 456 457 458
		switch (chan->type) {
		case IIO_LIGHT:
			ret = isl29028_als_get(chip, val);
			break;
		case IIO_INTENSITY:
			ret = isl29028_ir_get(chip, val);
			break;
		case IIO_PROXIMITY:
459
			ret = isl29028_read_proxim(chip, val);
460 461 462 463
			break;
		default:
			break;
		}
464

465 466
		if (ret < 0)
			break;
467

468 469
		ret = IIO_VAL_INT;
		break;
470
	case IIO_CHAN_INFO_SAMP_FREQ:
471 472
		if (chan->type != IIO_PROXIMITY)
			break;
473

474 475
		*val = chip->prox_sampling_int;
		*val2 = chip->prox_sampling_frac;
476 477
		ret = IIO_VAL_INT;
		break;
478
	case IIO_CHAN_INFO_SCALE:
479 480 481 482 483 484
		if (chan->type != IIO_LIGHT)
			break;
		*val = chip->lux_scale;
		ret = IIO_VAL_INT;
		break;
	default:
485 486
		dev_err(dev, "%s(): mask value 0x%08lx is not supported\n",
			__func__, mask);
487 488
		break;
	}
489

490
	mutex_unlock(&chip->lock);
491

492 493 494 495 496 497 498 499 500 501 502 503
	if (ret < 0)
		return ret;

	/**
	 * Preserve the ret variable if the call to
	 * isl29028_set_pm_runtime_busy() is successful so the reading
	 * (if applicable) is returned to user space.
	 */
	pm_ret = isl29028_set_pm_runtime_busy(chip, false);
	if (pm_ret < 0)
		return pm_ret;

504 505 506 507
	return ret;
}

static IIO_CONST_ATTR(in_proximity_sampling_frequency_available,
508
				"1.25 2.5 5 10 13.3 20 80 100");
509
static IIO_CONST_ATTR(in_illuminance_scale_available, "125 2000");
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524

#define ISL29028_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
static struct attribute *isl29028_attributes[] = {
	ISL29028_CONST_ATTR(in_proximity_sampling_frequency_available),
	ISL29028_CONST_ATTR(in_illuminance_scale_available),
	NULL,
};

static const struct attribute_group isl29108_group = {
	.attrs = isl29028_attributes,
};

static const struct iio_chan_spec isl29028_channels[] = {
	{
		.type = IIO_LIGHT,
525 526
		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
		BIT(IIO_CHAN_INFO_SCALE),
527 528
	}, {
		.type = IIO_INTENSITY,
529
		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
530 531
	}, {
		.type = IIO_PROXIMITY,
532 533
		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
		BIT(IIO_CHAN_INFO_SAMP_FREQ),
534 535 536 537 538
	}
};

static const struct iio_info isl29028_info = {
	.attrs = &isl29108_group,
539 540
	.read_raw = isl29028_read_raw,
	.write_raw = isl29028_write_raw,
541 542
};

543
static int isl29028_clear_configure_reg(struct isl29028_chip *chip)
544
{
545
	struct device *dev = regmap_get_device(chip->regmap);
546 547 548
	int ret;

	ret = regmap_write(chip->regmap, ISL29028_REG_CONFIGURE, 0x0);
549
	if (ret < 0)
550 551
		dev_err(dev, "%s(): Error %d clearing the CONFIGURE register\n",
			__func__, ret);
552 553 554

	chip->als_ir_mode = ISL29028_MODE_NONE;
	chip->enable_prox = false;
555

556
	return ret;
557 558
}

559
static bool isl29028_is_volatile_reg(struct device *dev, unsigned int reg)
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
{
	switch (reg) {
	case ISL29028_REG_INTERRUPT:
	case ISL29028_REG_PROX_DATA:
	case ISL29028_REG_ALSIR_L:
	case ISL29028_REG_ALSIR_U:
		return true;
	default:
		return false;
	}
}

static const struct regmap_config isl29028_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
575
	.volatile_reg = isl29028_is_volatile_reg,
576 577 578 579 580
	.max_register = ISL29028_NUM_REGS - 1,
	.num_reg_defaults_raw = ISL29028_NUM_REGS,
	.cache_type = REGCACHE_RBTREE,
};

581
static int isl29028_probe(struct i2c_client *client,
582
			  const struct i2c_device_id *id)
583 584 585 586 587
{
	struct isl29028_chip *chip;
	struct iio_dev *indio_dev;
	int ret;

588
	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
589
	if (!indio_dev)
590 591 592 593 594 595 596 597 598 599
		return -ENOMEM;

	chip = iio_priv(indio_dev);

	i2c_set_clientdata(client, indio_dev);
	mutex_init(&chip->lock);

	chip->regmap = devm_regmap_init_i2c(client, &isl29028_regmap_config);
	if (IS_ERR(chip->regmap)) {
		ret = PTR_ERR(chip->regmap);
600 601
		dev_err(&client->dev, "%s: Error %d initializing regmap\n",
			__func__, ret);
602
		return ret;
603 604
	}

605
	chip->enable_prox  = false;
606 607
	chip->prox_sampling_int = 20;
	chip->prox_sampling_frac = 0;
608 609 610 611 612
	chip->lux_scale = 2000;

	ret = regmap_write(chip->regmap, ISL29028_REG_TEST1_MODE, 0x0);
	if (ret < 0) {
		dev_err(&client->dev,
613 614
			"%s(): Error %d writing to TEST1_MODE register\n",
			__func__, ret);
615 616
		return ret;
	}
617

618 619 620
	ret = regmap_write(chip->regmap, ISL29028_REG_TEST2_MODE, 0x0);
	if (ret < 0) {
		dev_err(&client->dev,
621 622
			"%s(): Error %d writing to TEST2_MODE register\n",
			__func__, ret);
623 624 625
		return ret;
	}

626
	ret = isl29028_clear_configure_reg(chip);
627
	if (ret < 0)
628
		return ret;
629 630 631 632 633 634 635

	indio_dev->info = &isl29028_info;
	indio_dev->channels = isl29028_channels;
	indio_dev->num_channels = ARRAY_SIZE(isl29028_channels);
	indio_dev->name = id->name;
	indio_dev->dev.parent = &client->dev;
	indio_dev->modes = INDIO_DIRECT_MODE;
636

637 638 639 640 641
	pm_runtime_enable(&client->dev);
	pm_runtime_set_autosuspend_delay(&client->dev,
					 ISL29028_POWER_OFF_DELAY_MS);
	pm_runtime_use_autosuspend(&client->dev);

642
	ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
643
	if (ret < 0) {
644
		dev_err(&client->dev,
645 646
			"%s(): iio registration failed with error %d\n",
			__func__, ret);
647
		return ret;
648
	}
649

650 651 652
	return 0;
}

653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
static int isl29028_remove(struct i2c_client *client)
{
	struct iio_dev *indio_dev = i2c_get_clientdata(client);
	struct isl29028_chip *chip = iio_priv(indio_dev);

	iio_device_unregister(indio_dev);

	pm_runtime_disable(&client->dev);
	pm_runtime_set_suspended(&client->dev);
	pm_runtime_put_noidle(&client->dev);

	return isl29028_clear_configure_reg(chip);
}

static int __maybe_unused isl29028_suspend(struct device *dev)
{
	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
	struct isl29028_chip *chip = iio_priv(indio_dev);
	int ret;

	mutex_lock(&chip->lock);

	ret = isl29028_clear_configure_reg(chip);

	mutex_unlock(&chip->lock);

	return ret;
}

static int __maybe_unused isl29028_resume(struct device *dev)
{
	/**
	 * The specific component (ALS/IR or proximity) will enable itself as
	 * needed the next time that the user requests a reading. This is done
	 * above in isl29028_set_als_ir_mode() and isl29028_enable_proximity().
	 */
	return 0;
}

static const struct dev_pm_ops isl29028_pm_ops = {
693 694
	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
				pm_runtime_force_resume)
695 696 697
	SET_RUNTIME_PM_OPS(isl29028_suspend, isl29028_resume, NULL)
};

698 699
static const struct i2c_device_id isl29028_id[] = {
	{"isl29028", 0},
700
	{"isl29030", 0},
701 702 703 704 705
	{}
};
MODULE_DEVICE_TABLE(i2c, isl29028_id);

static const struct of_device_id isl29028_of_match[] = {
706 707
	{ .compatible = "isl,isl29028", }, /* for backward compat., don't use */
	{ .compatible = "isil,isl29028", },
708
	{ .compatible = "isil,isl29030", },
709 710 711 712 713 714 715
	{ },
};
MODULE_DEVICE_TABLE(of, isl29028_of_match);

static struct i2c_driver isl29028_driver = {
	.driver  = {
		.name = "isl29028",
716
		.pm = &isl29028_pm_ops,
717 718 719
		.of_match_table = isl29028_of_match,
	},
	.probe	 = isl29028_probe,
720
	.remove  = isl29028_remove,
721 722 723 724 725 726 727 728
	.id_table = isl29028_id,
};

module_i2c_driver(isl29028_driver);

MODULE_DESCRIPTION("ISL29028 Ambient Light and Proximity Sensor driver");
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");