]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/leds/leds-lp5521.c
Merge branch 'omap-fixes'
[linux-2.6-omap-h63xx.git] / drivers / leds / leds-lp5521.c
1 /*
2  * lp5521.c - LP5521 LED Driver
3  *
4  * Copyright (C) 2007 Nokia Corporation
5  *
6  * Written by Mathias Nyman <mathias.nyman@nokia.com>
7  * Updated by Felipe Balbi <felipe.balbi@nokia.com>
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,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/i2c.h>
27 #include <linux/leds.h>
28 #include <linux/mutex.h>
29 #include <linux/workqueue.h>
30 #include <linux/i2c/lp5521.h>
31
32 #define LP5521_DRIVER_NAME              "lp5521"
33
34 #define LP5521_REG_R_PWM                0x02
35 #define LP5521_REG_B_PWM                0x04
36 #define LP5521_REG_ENABLE               0x00
37 #define LP5521_REG_OP_MODE              0x01
38 #define LP5521_REG_G_PWM                0x03
39 #define LP5521_REG_R_CNTRL              0x05
40 #define LP5521_REG_G_CNTRL              0x06
41 #define LP5521_REG_B_CNTRL              0x07
42 #define LP5521_REG_MISC                 0x08
43 #define LP5521_REG_R_CHANNEL_PC         0x09
44 #define LP5521_REG_G_CHANNEL_PC         0x0a
45 #define LP5521_REG_B_CHANNEL_PC         0x0b
46 #define LP5521_REG_STATUS               0x0c
47 #define LP5521_REG_RESET                0x0d
48 #define LP5521_REG_GPO                  0x0e
49 #define LP5521_REG_R_PROG_MEM           0x10
50 #define LP5521_REG_G_PROG_MEM           0x30
51 #define LP5521_REG_B_PROG_MEM           0x50
52
53 #define LP5521_CURRENT_1m5              0x0f
54 #define LP5521_CURRENT_3m1              0x1f
55 #define LP5521_CURRENT_4m7              0x2f
56 #define LP5521_CURRENT_6m3              0x3f
57 #define LP5521_CURRENT_7m9              0x4f
58 #define LP5521_CURRENT_9m5              0x5f
59 #define LP5521_CURRENT_11m1             0x6f
60 #define LP5521_CURRENT_12m7             0x7f
61 #define LP5521_CURRENT_14m3             0x8f
62 #define LP5521_CURRENT_15m9             0x9f
63 #define LP5521_CURRENT_17m5             0xaf
64 #define LP5521_CURRENT_19m1             0xbf
65 #define LP5521_CURRENT_20m7             0xcf
66 #define LP5521_CURRENT_22m3             0xdf
67 #define LP5521_CURRENT_23m9             0xef
68 #define LP5521_CURRENT_25m5             0xff
69
70 #define LP5521_PROGRAM_LENGTH           32      /* in bytes */
71
72 struct lp5521_chip {
73         /* device lock */
74         struct mutex            lock;
75         struct i2c_client       *client;
76
77         struct work_struct      red_work;
78         struct work_struct      green_work;
79         struct work_struct      blue_work;
80
81         struct led_classdev     ledr;
82         struct led_classdev     ledg;
83         struct led_classdev     ledb;
84
85         enum lp5521_mode        mode;
86
87         int                     red;
88         int                     green;
89         int                     blue;
90 };
91
92 static int lp5521_set_mode(struct lp5521_chip *chip, enum lp5521_mode mode);
93
94 static inline int lp5521_write(struct i2c_client *client, u8 reg, u8 value)
95 {
96         return i2c_smbus_write_byte_data(client, reg, value);
97 }
98
99 static inline int lp5521_read(struct i2c_client *client, u8 reg)
100 {
101         return i2c_smbus_read_byte_data(client, reg);
102 }
103
104 static int lp5521_configure(struct i2c_client *client)
105 {
106         int ret = 0;
107
108         /* Enable chip and set light to logarithmic mode*/
109         ret |= lp5521_write(client, LP5521_REG_ENABLE, 0xc0);
110
111         /* setting all color pwms to direct control mode */
112         ret |= lp5521_write(client, LP5521_REG_OP_MODE, 0x3f);
113
114         /* setting current to 4.7 mA for all channels */
115         ret |= lp5521_write(client, LP5521_REG_R_CNTRL, LP5521_CURRENT_4m7);
116         ret |= lp5521_write(client, LP5521_REG_G_CNTRL, LP5521_CURRENT_4m7);
117         ret |= lp5521_write(client, LP5521_REG_B_CNTRL, LP5521_CURRENT_4m7);
118
119         /* Enable auto-powersave, set charge pump to auto, red to battery */
120         ret |= lp5521_write(client, LP5521_REG_MISC, 0x3c);
121
122         /* initialize all channels pwm to zero */
123         ret |= lp5521_write(client, LP5521_REG_R_PWM, 0);
124         ret |= lp5521_write(client, LP5521_REG_G_PWM, 0);
125         ret |= lp5521_write(client, LP5521_REG_B_PWM, 0);
126
127         /* Not much can be done about errors at this point */
128         return ret;
129 }
130
131 static int lp5521_load_program(struct lp5521_chip *chip, u8 *pattern)
132 {
133         struct i2c_client *client = chip->client;
134         int ret = 0;
135
136         /* Enter load program mode for all led channels */
137         ret |= lp5521_write(client, LP5521_REG_OP_MODE, 0x15); /* 0001 0101 */
138         if (ret)
139                 return ret;
140
141         if (chip->red)
142                 ret |= i2c_smbus_write_i2c_block_data(client,
143                                 LP5521_REG_R_PROG_MEM,
144                                 LP5521_PROGRAM_LENGTH,
145                                 pattern);
146         if (chip->green)
147                 ret |= i2c_smbus_write_i2c_block_data(client,
148                                 LP5521_REG_G_PROG_MEM,
149                                 LP5521_PROGRAM_LENGTH,
150                                 pattern);
151         if (chip->blue)
152                 ret |= i2c_smbus_write_i2c_block_data(client,
153                                 LP5521_REG_B_PROG_MEM,
154                                 LP5521_PROGRAM_LENGTH,
155                                 pattern);
156
157         return ret;
158 }
159
160 static int lp5521_run_program(struct lp5521_chip *chip)
161 {
162         struct i2c_client *client = chip->client;
163         int reg;
164         u8 mask = 0xc0;
165         u8 exec_state = 0;
166
167         reg = lp5521_read(client, LP5521_REG_ENABLE);
168         if (reg < 0)
169                 return reg;
170
171         reg &= mask;
172
173         /* set all active channels exec state to countinous run*/
174         exec_state |= (chip->red << 5);
175         exec_state |= (chip->green << 3);
176         exec_state |= (chip->blue << 1);
177
178         reg |= exec_state;
179
180         if (lp5521_write(client, LP5521_REG_ENABLE, reg))
181                 dev_dbg(&client->dev, "failed writing to register %02x\n",
182                                 LP5521_REG_ENABLE);
183
184         /* set op-mode to run for active channels, disabled for others */
185         if (lp5521_write(client, LP5521_REG_OP_MODE, exec_state))
186                 dev_dbg(&client->dev, "failed writing to register %02x\n",
187                                 LP5521_REG_OP_MODE);
188
189         return 0;
190 }
191
192 /*--------------------------------------------------------------*/
193 /*                      Sysfs interface                         */
194 /*--------------------------------------------------------------*/
195
196 static ssize_t show_active_channels(struct device *dev,
197                 struct device_attribute *attr,
198                 char *buf)
199 {
200         struct lp5521_chip *chip = dev_get_drvdata(dev);
201         char channels[4];
202         int pos = 0;
203
204         if (chip->red)
205                 pos += sprintf(channels + pos, "r");
206         if (chip->green)
207                 pos += sprintf(channels + pos, "g");
208         if (chip->blue)
209                 pos += sprintf(channels + pos, "b");
210
211         channels[pos] = '\0';
212
213         return sprintf(buf, "%s\n", channels);
214 }
215
216 static ssize_t store_active_channels(struct device *dev,
217                 struct device_attribute *attr,
218                 const char *buf, size_t len)
219 {
220         struct lp5521_chip *chip = dev_get_drvdata(dev);
221
222         chip->red = 0;
223         chip->green = 0;
224         chip->blue = 0;
225
226         if (strchr(buf, 'r') != NULL)
227                 chip->red = 1;
228         if (strchr(buf, 'b') != NULL)
229                 chip->blue = 1;
230         if (strchr(buf, 'g') != NULL)
231                 chip->green = 1;
232
233         return len;
234 }
235
236 static ssize_t show_color(struct device *dev,
237                 struct device_attribute *attr,
238                 char *buf)
239 {
240         struct i2c_client *client = to_i2c_client(dev);
241         int r, g, b;
242
243         r = lp5521_read(client, LP5521_REG_R_PWM);
244         g = lp5521_read(client, LP5521_REG_G_PWM);
245         b = lp5521_read(client, LP5521_REG_B_PWM);
246
247         if (r < 0 || g < 0 || b < 0)
248                 return -EINVAL;
249
250         return sprintf(buf, "%.2x:%.2x:%.2x\n", r, g, b);
251 }
252
253 static ssize_t store_color(struct device *dev,
254                 struct device_attribute *attr,
255                 const char *buf, size_t len)
256 {
257         struct i2c_client *client = to_i2c_client(dev);
258         struct lp5521_chip *chip = i2c_get_clientdata(client);
259         int ret;
260         unsigned r, g, b;
261
262
263         ret = sscanf(buf, "%2x:%2x:%2x", &r, &g, &b);
264         if (ret != 3)
265                 return  -EINVAL;
266
267         mutex_lock(&chip->lock);
268
269         ret = lp5521_write(client, LP5521_REG_R_PWM, (u8)r);
270         ret = lp5521_write(client, LP5521_REG_G_PWM, (u8)g);
271         ret = lp5521_write(client, LP5521_REG_B_PWM, (u8)b);
272
273         mutex_unlock(&chip->lock);
274
275         return len;
276 }
277
278 static ssize_t store_load(struct device *dev,
279                 struct device_attribute *attr,
280                 const char *buf, size_t len)
281 {
282         struct lp5521_chip *chip = dev_get_drvdata(dev);
283         int  ret, nrchars, offset = 0, i = 0;
284         char c[3];
285         unsigned cmd;
286         u8 pattern[LP5521_PROGRAM_LENGTH] = {0};
287
288         while ((offset < len - 1) && (i < LP5521_PROGRAM_LENGTH)) {
289
290                 /* separate sscanfs because length is working only for %s */
291                 ret = sscanf(buf + offset, "%2s%n ", c, &nrchars);
292                 ret = sscanf(c, "%2x", &cmd);
293                 if (ret != 1)
294                         goto fail;
295                 pattern[i] = (u8)cmd;
296
297                 offset += nrchars;
298                 i++;
299         }
300
301         /* pattern commands are always two bytes long */
302         if (i % 2)
303                 goto fail;
304
305         mutex_lock(&chip->lock);
306
307         ret = lp5521_load_program(chip, pattern);
308         mutex_unlock(&chip->lock);
309
310         if (ret) {
311                 dev_err(dev, "lp5521 failed loading pattern\n");
312                 return ret;
313         }
314
315         return len;
316 fail:
317         dev_err(dev, "lp5521 wrong pattern format\n");
318         return -EINVAL;
319 }
320
321 static ssize_t show_mode(struct device *dev,
322                 struct device_attribute *attr,
323                 char *buf)
324 {
325         struct lp5521_chip *chip = dev_get_drvdata(dev);
326         char *mode;
327
328         mutex_lock(&chip->lock);
329         switch (chip->mode) {
330         case LP5521_MODE_RUN:
331                 mode = "run";
332                 break;
333         case LP5521_MODE_LOAD:
334                 mode = "load";
335                 break;
336         case LP5521_MODE_DIRECT_CONTROL:
337                 mode = "direct";
338                 break;
339         default:
340                 mode = "undefined";
341         }
342         mutex_unlock(&chip->lock);
343
344         return sprintf(buf, "%s\n", mode);
345 }
346
347 static ssize_t store_mode(struct device *dev,
348                 struct device_attribute *attr,
349                 const char *buf, size_t len)
350 {
351         struct lp5521_chip *chip = dev_get_drvdata(dev);
352
353         mutex_lock(&chip->lock);
354
355         if (sysfs_streq(buf, "run"))
356                 lp5521_set_mode(chip, LP5521_MODE_RUN);
357         else if (sysfs_streq(buf, "load"))
358                 lp5521_set_mode(chip, LP5521_MODE_LOAD);
359         else if (sysfs_streq(buf, "direct"))
360                 lp5521_set_mode(chip, LP5521_MODE_DIRECT_CONTROL);
361         else
362                 len = -EINVAL;
363
364         mutex_unlock(&chip->lock);
365
366         return len;
367 }
368
369 static ssize_t show_current(struct device *dev,
370                 struct device_attribute *attr,
371                 char *buf)
372 {
373         struct i2c_client *client = to_i2c_client(dev);
374         int r, g, b;
375
376         r = lp5521_read(client, LP5521_REG_R_CNTRL);
377         g = lp5521_read(client, LP5521_REG_G_CNTRL);
378         b = lp5521_read(client, LP5521_REG_B_CNTRL);
379
380         if (r < 0 || g < 0 || b < 0)
381                 return -EINVAL;
382
383         r >>= 4;
384         g >>= 4;
385         b >>= 4;
386
387         return sprintf(buf, "%x %x %x\n", r, g, b);
388 }
389
390 static ssize_t store_current(struct device *dev,
391                 struct device_attribute *attr,
392                 const char *buf, size_t len)
393 {
394         struct lp5521_chip *chip = dev_get_drvdata(dev);
395         struct i2c_client *client = chip->client;
396         int ret;
397         unsigned curr;
398
399         ret = sscanf(buf, "%1x", &curr);
400         if (ret != 1)
401                 return  -EINVAL;
402
403         /* current level is determined by the 4 upper bits, rest is ones */
404         curr = (curr << 4) | 0x0f;
405
406         mutex_lock(&chip->lock);
407
408         ret |= lp5521_write(client, LP5521_REG_R_CNTRL, (u8)curr);
409         ret |= lp5521_write(client, LP5521_REG_G_CNTRL, (u8)curr);
410         ret |= lp5521_write(client, LP5521_REG_B_CNTRL, (u8)curr);
411
412         mutex_unlock(&chip->lock);
413
414         return len;
415 }
416
417 static DEVICE_ATTR(color, S_IRUGO | S_IWUGO, show_color, store_color);
418 static DEVICE_ATTR(load, S_IWUGO, NULL, store_load);
419 static DEVICE_ATTR(mode, S_IRUGO | S_IWUGO, show_mode, store_mode);
420 static DEVICE_ATTR(active_channels, S_IRUGO | S_IWUGO,
421                 show_active_channels, store_active_channels);
422 static DEVICE_ATTR(led_current, S_IRUGO | S_IWUGO, show_current, store_current);
423
424 static int lp5521_register_sysfs(struct i2c_client *client)
425 {
426         struct device *dev = &client->dev;
427         int ret;
428
429         ret = device_create_file(dev, &dev_attr_color);
430         if (ret)
431                 goto fail1;
432         ret = device_create_file(dev, &dev_attr_load);
433         if (ret)
434                 goto fail2;
435         ret = device_create_file(dev, &dev_attr_active_channels);
436         if (ret)
437                 goto fail3;
438         ret = device_create_file(dev, &dev_attr_mode);
439         if (ret)
440                 goto fail4;
441         ret = device_create_file(dev, &dev_attr_led_current);
442         if (ret)
443                 goto fail5;
444
445         return 0;
446
447 fail5:
448         device_remove_file(dev, &dev_attr_mode);
449 fail4:
450         device_remove_file(dev, &dev_attr_active_channels);
451 fail3:
452         device_remove_file(dev, &dev_attr_load);
453 fail2:
454         device_remove_file(dev, &dev_attr_color);
455 fail1:
456         return ret;
457 }
458
459 static void lp5521_unregister_sysfs(struct i2c_client *client)
460 {
461         struct device *dev = &client->dev;
462
463         device_remove_file(dev, &dev_attr_led_current);
464         device_remove_file(dev, &dev_attr_mode);
465         device_remove_file(dev, &dev_attr_active_channels);
466         device_remove_file(dev, &dev_attr_color);
467         device_remove_file(dev, &dev_attr_load);
468 }
469
470 /*--------------------------------------------------------------*/
471 /*                      Set chip operating mode                 */
472 /*--------------------------------------------------------------*/
473
474 static int lp5521_set_mode(struct lp5521_chip *chip, enum lp5521_mode mode)
475 {
476         struct i2c_client *client = chip->client ;
477         int ret = 0;
478
479         /* if in that mode already do nothing, except for run */
480         if (chip->mode == mode && mode != LP5521_MODE_RUN)
481                 return 0;
482
483         switch (mode) {
484         case LP5521_MODE_RUN:
485                 ret = lp5521_run_program(chip);
486                 break;
487         case LP5521_MODE_LOAD:
488                 ret |= lp5521_write(client, LP5521_REG_OP_MODE, 0x15);
489                 break;
490         case LP5521_MODE_DIRECT_CONTROL:
491                 ret |= lp5521_write(client, LP5521_REG_OP_MODE, 0x3F);
492                 break;
493         default:
494                 dev_dbg(&client->dev, "unsupported mode %d\n", mode);
495         }
496
497         chip->mode = mode;
498
499         return ret;
500 }
501
502 static void lp5521_red_work(struct work_struct *work)
503 {
504         struct lp5521_chip *chip = container_of(work, struct lp5521_chip, red_work);
505         int ret;
506
507         ret = lp5521_configure(chip->client);
508         if (ret) {
509                 dev_dbg(&chip->client->dev, "could not configure lp5521, %d\n",
510                                 ret);
511                 return;
512         }
513
514         ret = lp5521_write(chip->client, LP5521_REG_R_PWM, chip->red);
515         if (ret)
516                 dev_dbg(&chip->client->dev, "could not set brightness, %d\n",
517                                 ret);
518 }
519
520 static void lp5521_red_set(struct led_classdev *led,
521                 enum led_brightness value)
522 {
523         struct lp5521_chip *chip = container_of(led, struct lp5521_chip, ledr);
524
525         chip->red = value;
526         schedule_work(&chip->red_work);
527 }
528
529 static void lp5521_green_work(struct work_struct *work)
530 {
531         struct lp5521_chip *chip = container_of(work, struct lp5521_chip, green_work);
532         int ret;
533
534         ret = lp5521_configure(chip->client);
535         if (ret) {
536                 dev_dbg(&chip->client->dev, "could not configure lp5521, %d\n",
537                                 ret);
538                 return;
539         }
540
541         ret = lp5521_write(chip->client, LP5521_REG_G_PWM, chip->green);
542         if (ret)
543                 dev_dbg(&chip->client->dev, "could not set brightness, %d\n",
544                                 ret);
545 }
546
547 static void lp5521_green_set(struct led_classdev *led,
548                 enum led_brightness value)
549 {
550         struct lp5521_chip *chip = container_of(led, struct lp5521_chip, ledg);
551
552         chip->green = value;
553         schedule_work(&chip->green_work);
554 }
555
556 static void lp5521_blue_work(struct work_struct *work)
557 {
558         struct lp5521_chip *chip = container_of(work, struct lp5521_chip, blue_work);
559         int ret;
560
561         ret = lp5521_configure(chip->client);
562         if (ret) {
563                 dev_dbg(&chip->client->dev, "could not configure lp5521, %d\n",
564                                 ret);
565                 return;
566         }
567
568         ret = lp5521_write(chip->client, LP5521_REG_B_PWM, chip->blue);
569         if (ret)
570                 dev_dbg(&chip->client->dev, "could not set brightness, %d\n",
571                                 ret);
572 }
573
574 static void lp5521_blue_set(struct led_classdev *led,
575                 enum led_brightness value)
576 {
577         struct lp5521_chip *chip = container_of(led, struct lp5521_chip, ledb);
578
579         chip->blue = value;
580         schedule_work(&chip->blue_work);
581 }
582
583 /*--------------------------------------------------------------*/
584 /*                      Probe, Attach, Remove                   */
585 /*--------------------------------------------------------------*/
586
587 static int __init lp5521_probe(struct i2c_client *client,
588                 const struct i2c_device_id *id)
589 {
590         struct lp5521_platform_data *pdata = client->dev.platform_data;
591         struct lp5521_chip *chip;
592         char name[16];
593         int ret = 0;
594
595         if (!pdata) {
596                 dev_err(&client->dev, "platform_data is missing\n");
597                 return -EINVAL;
598         }
599
600         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
601         if (!chip)
602                 return -ENOMEM;
603
604         chip->client = client;
605         strncpy(client->name, LP5521_DRIVER_NAME, I2C_NAME_SIZE);
606         i2c_set_clientdata(client, chip);
607
608         mutex_init(&chip->lock);
609
610         INIT_WORK(&chip->red_work, lp5521_red_work);
611         INIT_WORK(&chip->green_work, lp5521_green_work);
612         INIT_WORK(&chip->blue_work, lp5521_blue_work);
613
614         ret = lp5521_configure(client);
615         if (ret < 0) {
616                 dev_err(&client->dev, "lp5521 error configuring chip \n");
617                 goto fail1;
618         }
619
620         /* Set default values */
621         chip->mode      = pdata->mode;
622         chip->red       = pdata->red_present;
623         chip->green     = pdata->green_present;
624         chip->blue      = pdata->blue_present;
625
626         chip->ledr.brightness_set = lp5521_red_set;
627         chip->ledr.default_trigger = NULL;
628         snprintf(name, sizeof(name), "%s::red", pdata->label);
629         chip->ledr.name = name;
630         ret = led_classdev_register(&client->dev, &chip->ledr);
631         if (ret < 0) {
632                 dev_dbg(&client->dev, "failed to register led %s, %d\n",
633                                 chip->ledb.name, ret);
634                 goto fail1;
635         }
636
637         chip->ledg.brightness_set = lp5521_green_set;
638         chip->ledg.default_trigger = NULL;
639         snprintf(name, sizeof(name), "%s::green", pdata->label);
640         chip->ledg.name = name;
641         ret = led_classdev_register(&client->dev, &chip->ledg);
642         if (ret < 0) {
643                 dev_dbg(&client->dev, "failed to register led %s, %d\n",
644                                 chip->ledb.name, ret);
645                 goto fail2;
646         }
647
648         chip->ledb.brightness_set = lp5521_blue_set;
649         chip->ledb.default_trigger = NULL;
650         snprintf(name, sizeof(name), "%s::blue", pdata->label);
651         chip->ledb.name = name;
652         ret = led_classdev_register(&client->dev, &chip->ledb);
653         if (ret < 0) {
654                 dev_dbg(&client->dev, "failed to register led %s, %d\n", chip->ledb.name, ret);
655                 goto fail3;
656         }
657
658         ret = lp5521_register_sysfs(client);
659         if (ret) {
660                 dev_err(&client->dev, "lp5521 registering sysfs failed \n");
661                 goto fail4;
662         }
663
664         return 0;
665
666 fail4:
667         led_classdev_unregister(&chip->ledb);
668 fail3:
669         led_classdev_unregister(&chip->ledg);
670 fail2:
671         led_classdev_unregister(&chip->ledr);
672 fail1:
673         i2c_set_clientdata(client, NULL);
674         kfree(chip);
675
676         return ret;
677 }
678
679 static int __exit lp5521_remove(struct i2c_client *client)
680 {
681         struct lp5521_chip *chip = i2c_get_clientdata(client);
682
683         lp5521_unregister_sysfs(client);
684         i2c_set_clientdata(client, NULL);
685
686         led_classdev_unregister(&chip->ledb);
687         led_classdev_unregister(&chip->ledg);
688         led_classdev_unregister(&chip->ledr);
689
690         kfree(chip);
691
692         return 0;
693 }
694
695 static const struct i2c_device_id lp5521_id[] = {
696         { LP5521_DRIVER_NAME, 0},
697         { },
698 };
699 MODULE_DEVICE_TABLE(i2c, lp5521_id);
700
701 static struct i2c_driver lp5521_driver = {
702         .driver         = {
703                 .name   = LP5521_DRIVER_NAME,
704         },
705         .probe          = lp5521_probe,
706         .remove         = __exit_p(lp5521_remove),
707         .id_table       = lp5521_id,
708 };
709
710 static int __init lp5521_init(void)
711 {
712         return i2c_add_driver(&lp5521_driver);
713 }
714 module_init(lp5521_init);
715
716 static void __exit lp5521_exit(void)
717 {
718         i2c_del_driver(&lp5521_driver);
719 }
720 module_exit(lp5521_exit);
721
722 MODULE_AUTHOR("Mathias Nyman <mathias.nyman@nokia.com>");
723 MODULE_DESCRIPTION("lp5521 LED driver");
724 MODULE_LICENSE("GPL");