Merge current mainline tree into linux-omap tree
[pandora-kernel.git] / drivers / i2c / chips / tsl2563.c
1 /*
2  * drivers/i2c/chips/tsl2563.c
3  *
4  * Copyright (C) 2008 Nokia Corporation
5  *
6  * Written by Timo O. Karjalainen <timo.o.karjalainen@nokia.com>
7  * Contact: Mathias Nyman <mathias.nyman@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23
24 #include <linux/module.h>
25 #include <linux/i2c.h>
26 #include <linux/interrupt.h>
27 #include <linux/sched.h>
28 #include <linux/mutex.h>
29 #include <linux/delay.h>
30 #include <linux/platform_device.h>
31 #include <linux/pm.h>
32 #include <linux/hwmon.h>
33 #include <linux/err.h>
34 #include <mach/board.h>
35
36 #define DRIVER_NAME  "tsl2563"
37
38 /* Use this many bits for fraction part. */
39 #define ADC_FRAC_BITS           (14)
40
41 /* Given number of 1/10000's in ADC_FRAC_BITS precision. */
42 #define FRAC10K(f)              (((f) * (1L << (ADC_FRAC_BITS))) / (10000))
43
44 /* Bits used for fraction in calibration coefficients.*/
45 #define CALIB_FRAC_BITS         (10)
46 /* 0.5 in CALIB_FRAC_BITS precision */
47 #define CALIB_FRAC_HALF         (1 << (CALIB_FRAC_BITS - 1))
48 /* Make a fraction from a number n that was multiplied with b. */
49 #define CALIB_FRAC(n, b)        (((n) << CALIB_FRAC_BITS) / (b))
50 /* Decimal 10^(digits in sysfs presentation) */
51 #define CALIB_BASE_SYSFS        (1000)
52
53 #define TSL2563_CMD             (0x80)
54 #define TSL2563_CLEARINT        (0x40)
55
56 #define TSL2563_REG_CTRL        (0x00)
57 #define TSL2563_REG_TIMING      (0x01)
58 #define TSL2563_REG_LOWLOW      (0x02) /* data0 low threshold, 2 bytes */
59 #define TSL2563_REG_LOWHIGH     (0x03)
60 #define TSL2563_REG_HIGHLOW     (0x04) /* data0 high threshold, 2 bytes */
61 #define TSL2563_REG_HIGHHIGH    (0x05)
62 #define TSL2563_REG_INT         (0x06)
63 #define TSL2563_REG_ID          (0x0a)
64 #define TSL2563_REG_DATA0LOW    (0x0c) /* broadband sensor value, 2 bytes */
65 #define TSL2563_REG_DATA0HIGH   (0x0d)
66 #define TSL2563_REG_DATA1LOW    (0x0e) /* infrared sensor value, 2 bytes */
67 #define TSL2563_REG_DATA1HIGH   (0x0f)
68
69 #define TSL2563_CMD_POWER_ON    (0x03)
70 #define TSL2563_CMD_POWER_OFF   (0x00)
71 #define TSL2563_CTRL_POWER_MASK (0x03)
72
73 #define TSL2563_TIMING_13MS     (0x00)
74 #define TSL2563_TIMING_100MS    (0x01)
75 #define TSL2563_TIMING_400MS    (0x02)
76 #define TSL2563_TIMING_MASK     (0x03)
77 #define TSL2563_TIMING_GAIN16   (0x10)
78 #define TSL2563_TIMING_GAIN1    (0x00)
79
80 #define TSL2563_INT_DISBLED     (0x00)
81 #define TSL2563_INT_LEVEL       (0x10)
82 #define TSL2563_INT_PERSIST(n)  ((n) & 0x0F)
83
84 struct tsl2563_gainlevel_coeff {
85         u8 gaintime;
86         u16 min;
87         u16 max;
88 };
89
90 static struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = {
91         {
92                 .gaintime       = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN16,
93                 .min            = 0,
94                 .max            = 65534,
95         }, {
96                 .gaintime       = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN1,
97                 .min            = 2048,
98                 .max            = 65534,
99         }, {
100                 .gaintime       = TSL2563_TIMING_100MS | TSL2563_TIMING_GAIN1,
101                 .min            = 4095,
102                 .max            = 37177,
103         }, {
104                 .gaintime       = TSL2563_TIMING_13MS | TSL2563_TIMING_GAIN1,
105                 .min            = 3000,
106                 .max            = 65535,
107         },
108 };
109
110 struct tsl2563_chip {
111         struct mutex            lock;
112         struct i2c_client       *client;
113         struct device           *hwmon_dev;
114
115         /* Remember state for suspend and resume functions */
116         pm_message_t            state;
117
118         struct tsl2563_gainlevel_coeff *gainlevel;
119
120         /* Thresholds are in lux */
121         u16                     low_thres;
122         u16                     high_thres;
123         u8                      intr;
124
125         /* Calibration coefficients */
126         u32                     calib0;
127         u32                     calib1;
128
129         /* Cache current values, to be returned while suspended */
130         u32                     data0;
131         u32                     data1;
132 };
133
134 static int tsl2563_write(struct i2c_client *client, u8 reg, u8 value)
135 {
136         int ret;
137         u8 buf[2];
138
139         buf[0] = TSL2563_CMD | reg;
140         buf[1] = value;
141
142         ret = i2c_master_send(client, buf, sizeof(buf));
143         return (ret == sizeof(buf)) ? 0 : ret;
144 }
145
146 static int tsl2563_read(struct i2c_client *client, u8 reg, void *buf, int len)
147 {
148         int ret;
149         u8 cmd = TSL2563_CMD | reg;
150
151         ret = i2c_master_send(client, &cmd, sizeof(cmd));
152         if (ret != sizeof(cmd))
153                 return ret;
154
155         return i2c_master_recv(client, buf, len);
156 }
157
158 static int tsl2563_set_power(struct tsl2563_chip *chip, int on)
159 {
160         struct i2c_client *client = chip->client;
161         u8 cmd;
162
163         cmd = on ? TSL2563_CMD_POWER_ON : TSL2563_CMD_POWER_OFF;
164         return tsl2563_write(client, TSL2563_REG_CTRL, cmd);
165 }
166
167 /*
168  * Return value is 0 for off, 1 for on, or a negative error
169  * code if reading failed.
170  */
171 static int tsl2563_get_power(struct tsl2563_chip *chip)
172 {
173         struct i2c_client *client = chip->client;
174         int ret;
175         u8 val;
176
177         ret = tsl2563_read(client, TSL2563_REG_CTRL, &val, sizeof(val));
178         if (ret != sizeof(val))
179                 return ret;
180
181         return (val & TSL2563_CTRL_POWER_MASK) == TSL2563_CMD_POWER_ON;
182 }
183
184 static int tsl2563_configure(struct tsl2563_chip *chip)
185 {
186         struct i2c_client *client = chip->client;
187         int ret;
188
189         ret = tsl2563_write(client, TSL2563_REG_TIMING,
190                         chip->gainlevel->gaintime);
191         if (ret)
192                 goto out;
193
194         ret = tsl2563_write(client, TSL2563_REG_INT, chip->intr);
195
196 out:
197         return ret;
198 }
199
200 static int tsl2563_detect(struct tsl2563_chip *chip)
201 {
202         int ret;
203
204         ret = tsl2563_set_power(chip, 1);
205         if (ret)
206                 return ret;
207
208         ret = tsl2563_get_power(chip);
209         if (ret < 0)
210                 return ret;
211
212         return ret ? 0 : -ENODEV;
213 }
214
215 static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id)
216 {
217         struct i2c_client *client = chip->client;
218         int ret;
219
220         ret = tsl2563_read(client, TSL2563_REG_ID, id, sizeof(*id));
221         if (ret != sizeof(*id))
222                 return ret;
223
224         return 0;
225 }
226
227 /*
228  * "Normalized" ADC value is one obtained with 400ms of integration time and
229  * 16x gain. This function returns the number of bits of shift needed to
230  * convert between normalized values and HW values obtained using given
231  * timing and gain settings.
232  */
233 static int adc_shiftbits(u8 timing)
234 {
235         int shift = 0;
236
237         switch (timing & TSL2563_TIMING_MASK) {
238         case TSL2563_TIMING_13MS:
239                 shift += 5;
240                 break;
241         case TSL2563_TIMING_100MS:
242                 shift += 2;
243                 break;
244         case TSL2563_TIMING_400MS:
245                 /* no-op */
246                 break;
247         }
248
249         if (!(timing & TSL2563_TIMING_GAIN16))
250                 shift += 4;
251
252         return shift;
253 }
254
255 /* Convert a HW ADC value to normalized scale. */
256 static u32 normalize_adc(u16 adc, u8 timing)
257 {
258         return adc << adc_shiftbits(timing);
259 }
260
261 static void tsl2563_wait_adc(struct tsl2563_chip *chip)
262 {
263         unsigned int delay;
264
265         switch (chip->gainlevel->gaintime & TSL2563_TIMING_MASK) {
266         case TSL2563_TIMING_13MS:
267                 delay = 14;
268                 break;
269         case TSL2563_TIMING_100MS:
270                 delay = 101;
271                 break;
272         default:
273                 delay = 402;
274         }
275         /*
276          * TODO: Make sure that we wait at least required delay but why we
277          * have to extend it one tick more?
278          */
279         schedule_timeout_interruptible(msecs_to_jiffies(delay) + 2);
280 }
281
282 static int tsl2563_adjust_gainlevel(struct tsl2563_chip *chip, u16 adc)
283 {
284         struct i2c_client *client = chip->client;
285
286         if (adc > chip->gainlevel->max || adc < chip->gainlevel->min) {
287
288                 (adc > chip->gainlevel->max) ?
289                         chip->gainlevel++ : chip->gainlevel--;
290
291                 tsl2563_write(client, TSL2563_REG_TIMING,
292                               chip->gainlevel->gaintime);
293
294                 tsl2563_wait_adc(chip);
295                 tsl2563_wait_adc(chip);
296
297                 return 1;
298         } else
299                 return 0;
300 }
301
302 static int tsl2563_get_adc(struct tsl2563_chip *chip)
303 {
304         struct i2c_client *client = chip->client;
305         u8 buf0[2], buf1[2];
306         u16 adc0, adc1;
307         int retry = 1;
308         int ret = 0;
309
310         if (chip->state.event != PM_EVENT_ON)
311                 goto out;
312
313         while (retry) {
314                 ret = tsl2563_read(client,
315                                    TSL2563_REG_DATA0LOW | TSL2563_CLEARINT,
316                                    buf0, sizeof(buf0));
317                 if (ret != sizeof(buf0))
318                         goto out;
319
320                 ret = tsl2563_read(client, TSL2563_REG_DATA1LOW,
321                                    buf1, sizeof(buf1));
322                 if (ret != sizeof(buf1))
323                         goto out;
324
325                 adc0 = (buf0[1] << 8) + buf0[0];
326                 adc1 = (buf1[1] << 8) + buf1[0];
327
328                 retry = tsl2563_adjust_gainlevel(chip, adc0);
329         }
330
331         chip->data0 = normalize_adc(adc0, chip->gainlevel->gaintime);
332         chip->data1 = normalize_adc(adc1, chip->gainlevel->gaintime);
333
334         ret = 0;
335 out:
336         return ret;
337 }
338
339 static inline int calib_to_sysfs(u32 calib)
340 {
341         return (int) (((calib * CALIB_BASE_SYSFS) +
342                        CALIB_FRAC_HALF) >> CALIB_FRAC_BITS);
343 }
344
345 static inline u32 calib_from_sysfs(int value)
346 {
347         return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS;
348 }
349
350 /*
351  * Conversions between lux and ADC values.
352  *
353  * The basic formula is lux = c0 * adc0 - c1 * adc1, where c0 and c1 are
354  * appropriate constants. Different constants are needed for different
355  * kinds of light, determined by the ratio adc1/adc0 (basically the ratio
356  * of the intensities in infrared and visible wavelengths). lux_table below
357  * lists the upper threshold of the adc1/adc0 ratio and the corresponding
358  * constants.
359  */
360
361 struct tsl2563_lux_coeff {
362         unsigned long ch_ratio;
363         unsigned long ch0_coeff;
364         unsigned long ch1_coeff;
365 };
366
367 static const struct tsl2563_lux_coeff lux_table[] = {
368         {
369                 .ch_ratio       = FRAC10K(1300),
370                 .ch0_coeff      = FRAC10K(315),
371                 .ch1_coeff      = FRAC10K(262),
372         }, {
373                 .ch_ratio       = FRAC10K(2600),
374                 .ch0_coeff      = FRAC10K(337),
375                 .ch1_coeff      = FRAC10K(430),
376         }, {
377                 .ch_ratio       = FRAC10K(3900),
378                 .ch0_coeff      = FRAC10K(363),
379                 .ch1_coeff      = FRAC10K(529),
380         }, {
381                 .ch_ratio       = FRAC10K(5200),
382                 .ch0_coeff      = FRAC10K(392),
383                 .ch1_coeff      = FRAC10K(605),
384         }, {
385                 .ch_ratio       = FRAC10K(6500),
386                 .ch0_coeff      = FRAC10K(229),
387                 .ch1_coeff      = FRAC10K(291),
388         }, {
389                 .ch_ratio       = FRAC10K(8000),
390                 .ch0_coeff      = FRAC10K(157),
391                 .ch1_coeff      = FRAC10K(180),
392         }, {
393                 .ch_ratio       = FRAC10K(13000),
394                 .ch0_coeff      = FRAC10K(34),
395                 .ch1_coeff      = FRAC10K(26),
396         }, {
397                 .ch_ratio       = ULONG_MAX,
398                 .ch0_coeff      = 0,
399                 .ch1_coeff      = 0,
400         },
401 };
402
403 /*
404  * Convert normalized, scaled ADC values to lux.
405  */
406 static unsigned int adc_to_lux(u32 adc0, u32 adc1)
407 {
408         const struct tsl2563_lux_coeff *lp = lux_table;
409         unsigned long ratio, lux, ch0 = adc0, ch1 = adc1;
410
411         ratio = ch0 ? ((ch1 << ADC_FRAC_BITS) / ch0) : ULONG_MAX;
412
413         while (lp->ch_ratio < ratio)
414                 lp++;
415
416         lux = ch0 * lp->ch0_coeff - ch1 * lp->ch1_coeff;
417
418         return (unsigned int) (lux >> ADC_FRAC_BITS);
419 }
420
421 /*--------------------------------------------------------------*/
422 /*                      Sysfs interface                         */
423 /*--------------------------------------------------------------*/
424
425 static ssize_t tsl2563_adc0_show(struct device *dev,
426                                 struct device_attribute *attr, char *buf)
427 {
428         struct tsl2563_chip *chip = dev_get_drvdata(dev);
429         int ret;
430
431         mutex_lock(&chip->lock);
432
433         ret = tsl2563_get_adc(chip);
434         if (ret)
435                 return ret;
436
437         ret = snprintf(buf, PAGE_SIZE, "%d\n", chip->data0);
438         mutex_unlock(&chip->lock);
439
440         return ret;
441 }
442
443 static ssize_t tsl2563_adc1_show(struct device *dev,
444                                 struct device_attribute *attr, char *buf)
445 {
446         struct tsl2563_chip *chip = dev_get_drvdata(dev);
447         int ret;
448
449         mutex_lock(&chip->lock);
450
451         ret = tsl2563_get_adc(chip);
452         if (ret)
453                 return ret;
454
455         ret = snprintf(buf, PAGE_SIZE, "%d\n", chip->data1);
456         mutex_unlock(&chip->lock);
457
458         return ret;
459 }
460
461 /* Apply calibration coefficient to ADC count. */
462 static u32 calib_adc(u32 adc, u32 calib)
463 {
464         unsigned long scaled = adc;
465
466         scaled *= calib;
467         scaled >>= CALIB_FRAC_BITS;
468
469         return (u32) scaled;
470 }
471
472 static ssize_t tsl2563_lux_show(struct device *dev,
473                                 struct device_attribute *attr, char *buf)
474 {
475         struct tsl2563_chip *chip = dev_get_drvdata(dev);
476         u32 calib0, calib1;
477         int ret;
478
479         mutex_lock(&chip->lock);
480
481         ret = tsl2563_get_adc(chip);
482         if (ret)
483                 goto out;
484
485         calib0 = calib_adc(chip->data0, chip->calib0);
486         calib1 = calib_adc(chip->data1, chip->calib1);
487
488         ret = snprintf(buf, PAGE_SIZE, "%d\n", adc_to_lux(calib0, calib1));
489
490 out:
491         mutex_unlock(&chip->lock);
492         return ret;
493 }
494
495 static ssize_t format_calib(char *buf, int len, u32 calib)
496 {
497         return snprintf(buf, PAGE_SIZE, "%d\n", calib_to_sysfs(calib));
498 }
499
500 static ssize_t tsl2563_calib0_show(struct device *dev,
501                                    struct device_attribute *attr, char *buf)
502 {
503         struct tsl2563_chip *chip = dev_get_drvdata(dev);
504         int ret;
505
506         mutex_lock(&chip->lock);
507         ret = format_calib(buf, PAGE_SIZE, chip->calib0);
508         mutex_unlock(&chip->lock);
509         return ret;
510 }
511
512 static ssize_t tsl2563_calib1_show(struct device *dev,
513                                    struct device_attribute *attr, char *buf)
514 {
515         struct tsl2563_chip *chip = dev_get_drvdata(dev);
516         int ret;
517
518         mutex_lock(&chip->lock);
519         ret = format_calib(buf, PAGE_SIZE, chip->calib1);
520         mutex_unlock(&chip->lock);
521         return ret;
522 }
523
524 static int do_calib_store(struct device *dev, const char *buf, size_t len,
525                           int ch)
526 {
527         struct tsl2563_chip *chip = dev_get_drvdata(dev);
528         int value;
529         u32 calib;
530
531         if (1 != sscanf(buf, "%d", &value))
532                 return -EINVAL;
533
534         calib = calib_from_sysfs(value);
535
536         if (ch)
537                 chip->calib1 = calib;
538         else
539                 chip->calib0 = calib;
540
541         return len;
542 }
543
544 static ssize_t tsl2563_calib0_store(struct device *dev,
545                                     struct device_attribute *attr,
546                                     const char *buf, size_t len)
547 {
548         return do_calib_store(dev, buf, len, 0);
549 }
550
551 static ssize_t tsl2563_calib1_store(struct device *dev,
552                                     struct device_attribute *attr,
553                                     const char *buf, size_t len)
554 {
555         return do_calib_store(dev, buf, len, 1);
556 }
557
558 static DEVICE_ATTR(adc0, S_IRUGO, tsl2563_adc0_show, NULL);
559 static DEVICE_ATTR(adc1, S_IRUGO, tsl2563_adc1_show, NULL);
560 static DEVICE_ATTR(lux, S_IRUGO, tsl2563_lux_show, NULL);
561 static DEVICE_ATTR(calib0, S_IRUGO | S_IWUSR,
562                    tsl2563_calib0_show, tsl2563_calib0_store);
563 static DEVICE_ATTR(calib1, S_IRUGO | S_IWUSR,
564                    tsl2563_calib1_show, tsl2563_calib1_store);
565
566 static struct attribute *tsl2563_attributes[] = {
567         &dev_attr_adc0.attr,
568         &dev_attr_adc1.attr,
569         &dev_attr_lux.attr,
570         &dev_attr_calib0.attr,
571         &dev_attr_calib1.attr,
572         NULL
573 };
574
575 static const struct attribute_group tsl2563_group = {
576         .attrs = tsl2563_attributes,
577 };
578
579 static int tsl2563_register_sysfs(struct i2c_client *client)
580 {
581         struct device *dev = &client->dev;
582
583         return sysfs_create_group(&dev->kobj, &tsl2563_group);
584 }
585
586 static void tsl2563_unregister_sysfs(struct i2c_client *client)
587 {
588         struct device *dev = &client->dev;
589
590         sysfs_remove_group(&dev->kobj, &tsl2563_group);
591 }
592
593 /*--------------------------------------------------------------*/
594 /*                      Probe, Attach, Remove                   */
595 /*--------------------------------------------------------------*/
596 static struct i2c_driver tsl2563_i2c_driver;
597
598 static int tsl2563_probe(struct i2c_client *client,
599                 const struct i2c_device_id *device_id)
600 {
601         struct tsl2563_chip *chip;
602         int err = 0;
603         u8 id;
604
605         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
606         if (!chip)
607                 return -ENOMEM;
608
609         i2c_set_clientdata(client, chip);
610         chip->client = client;
611
612         err = tsl2563_detect(chip);
613         if (err) {
614                 dev_err(&client->dev, "device not found, error %d \n", -err);
615                 goto fail1;
616         }
617
618         err = tsl2563_read_id(chip, &id);
619         if (err)
620                 goto fail1;
621
622         mutex_init(&chip->lock);
623
624         /* Default values used until userspace says otherwise */
625         chip->low_thres = 0x0;
626         chip->high_thres = 0xffff;
627         chip->gainlevel = tsl2563_gainlevel_table;
628         chip->intr = TSL2563_INT_PERSIST(4);
629         chip->calib0 = calib_from_sysfs(CALIB_BASE_SYSFS);
630         chip->calib1 = calib_from_sysfs(CALIB_BASE_SYSFS);
631
632         dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
633
634         err = tsl2563_configure(chip);
635         if (err)
636                 goto fail1;
637
638         chip->hwmon_dev = hwmon_device_register(&client->dev);
639         if (IS_ERR(chip->hwmon_dev))
640                 goto fail1;
641
642         err = tsl2563_register_sysfs(client);
643         if (err) {
644                 dev_err(&client->dev, "sysfs registration failed, %d\n", err);
645                 goto fail2;
646         }
647
648         return 0;
649 fail2:
650         hwmon_device_unregister(chip->hwmon_dev);
651 fail1:
652         kfree(chip);
653         return err;
654 }
655
656 static int tsl2563_remove(struct i2c_client *client)
657 {
658         struct tsl2563_chip *chip = i2c_get_clientdata(client);
659
660         tsl2563_unregister_sysfs(client);
661         hwmon_device_unregister(chip->hwmon_dev);
662
663         kfree(chip);
664         return 0;
665 }
666
667 static int tsl2563_suspend(struct i2c_client *client, pm_message_t state)
668 {
669         struct tsl2563_chip *chip = i2c_get_clientdata(client);
670         int ret;
671
672         mutex_lock(&chip->lock);
673
674         ret = tsl2563_set_power(chip, 0);
675         if (ret)
676                 goto out;
677
678         chip->state = state;
679
680 out:
681         mutex_unlock(&chip->lock);
682         return ret;
683 }
684
685 static int tsl2563_resume(struct i2c_client *client)
686 {
687         struct tsl2563_chip *chip = i2c_get_clientdata(client);
688         int ret;
689
690         mutex_lock(&chip->lock);
691
692         ret = tsl2563_set_power(chip, 1);
693         if (ret)
694                 goto out;
695
696         ret = tsl2563_configure(chip);
697         if (ret)
698                 goto out;
699
700         chip->state.event = PM_EVENT_ON;
701
702 out:
703         mutex_unlock(&chip->lock);
704         return ret;
705 }
706
707 static const struct i2c_device_id tsl2563_id[] = {
708         { DRIVER_NAME, 0 },
709         { },
710 };
711 MODULE_DEVICE_TABLE(i2c, tsl2563_id);
712
713 static struct i2c_driver tsl2563_i2c_driver = {
714         .driver = {
715                 .name    = DRIVER_NAME,
716         },
717         .suspend        = tsl2563_suspend,
718         .resume         = tsl2563_resume,
719         .probe          = tsl2563_probe,
720         .remove         = __devexit_p(tsl2563_remove),
721         .id_table       = tsl2563_id,
722 };
723
724 static int __init tsl2563_init(void)
725 {
726         return i2c_add_driver(&tsl2563_i2c_driver);
727 }
728
729 static void __exit tsl2563_exit(void)
730 {
731         i2c_del_driver(&tsl2563_i2c_driver);
732 }
733
734 MODULE_AUTHOR("Nokia Corporation");
735 MODULE_DESCRIPTION("tsl2563 light sensor driver");
736 MODULE_LICENSE("GPL");
737
738 module_init(tsl2563_init);
739 module_exit(tsl2563_exit);