blob: 5a6363d161a2f91e203a58923a3b09cc26a980b9 [file] [log] [blame]
Riku Voipioe14fa822008-05-31 14:43:41 +01001/*
2 * pca9532.c - 16-bit Led dimmer
3 *
Jan Weitzel3dbf6222011-05-24 17:13:26 -07004 * Copyright (C) 2011 Jan Weitzel
Riku Voipiob26e0ed2009-03-03 21:37:17 +02005 * Copyright (C) 2008 Riku Voipio
Riku Voipioe14fa822008-05-31 14:43:41 +01006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
Jan Weitzel3dbf6222011-05-24 17:13:26 -070011 * Datasheet: http://www.nxp.com/documents/data_sheet/PCA9532.pdf
Riku Voipioe14fa822008-05-31 14:43:41 +010012 *
13 */
14
15#include <linux/module.h>
16#include <linux/i2c.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Riku Voipioe14fa822008-05-31 14:43:41 +010018#include <linux/leds.h>
19#include <linux/input.h>
20#include <linux/mutex.h>
Riku Voipio934cd3f2008-12-03 08:21:36 +000021#include <linux/workqueue.h>
Riku Voipioe14fa822008-05-31 14:43:41 +010022#include <linux/leds-pca9532.h>
Joachim Eastwood3c1ab502011-05-24 17:13:23 -070023#include <linux/gpio.h>
Riku Voipioe14fa822008-05-31 14:43:41 +010024
Jan Weitzel3dbf6222011-05-24 17:13:26 -070025/* m = num_leds*/
26#define PCA9532_REG_INPUT(i) ((i) >> 3)
27#define PCA9532_REG_OFFSET(m) ((m) >> 4)
28#define PCA9532_REG_PSC(m, i) (PCA9532_REG_OFFSET(m) + 0x1 + (i) * 2)
29#define PCA9532_REG_PWM(m, i) (PCA9532_REG_OFFSET(m) + 0x2 + (i) * 2)
30#define LED_REG(m, led) (PCA9532_REG_OFFSET(m) + 0x5 + (led >> 2))
31#define LED_NUM(led) (led & 0x3)
Riku Voipioe14fa822008-05-31 14:43:41 +010032
33#define ldev_to_led(c) container_of(c, struct pca9532_led, ldev)
34
Jan Weitzel3dbf6222011-05-24 17:13:26 -070035struct pca9532_chip_info {
36 u8 num_leds;
37};
38
Riku Voipioe14fa822008-05-31 14:43:41 +010039struct pca9532_data {
40 struct i2c_client *client;
41 struct pca9532_led leds[16];
42 struct mutex update_lock;
Richard Purdie85c52042009-09-07 14:35:04 +010043 struct input_dev *idev;
Antonio Ospite07172d22009-06-19 13:53:07 +020044 struct work_struct work;
Joachim Eastwood3c1ab502011-05-24 17:13:23 -070045#ifdef CONFIG_LEDS_PCA9532_GPIO
46 struct gpio_chip gpio;
47#endif
Jan Weitzel3dbf6222011-05-24 17:13:26 -070048 const struct pca9532_chip_info *chip_info;
Riku Voipioe14fa822008-05-31 14:43:41 +010049 u8 pwm[2];
50 u8 psc[2];
51};
52
53static int pca9532_probe(struct i2c_client *client,
54 const struct i2c_device_id *id);
55static int pca9532_remove(struct i2c_client *client);
56
Jan Weitzel3dbf6222011-05-24 17:13:26 -070057enum {
58 pca9530,
59 pca9531,
60 pca9532,
61 pca9533,
62};
63
Riku Voipioe14fa822008-05-31 14:43:41 +010064static const struct i2c_device_id pca9532_id[] = {
Jan Weitzel3dbf6222011-05-24 17:13:26 -070065 { "pca9530", pca9530 },
66 { "pca9531", pca9531 },
67 { "pca9532", pca9532 },
68 { "pca9533", pca9533 },
Riku Voipioe14fa822008-05-31 14:43:41 +010069 { }
70};
71
72MODULE_DEVICE_TABLE(i2c, pca9532_id);
73
Jan Weitzel3dbf6222011-05-24 17:13:26 -070074static const struct pca9532_chip_info pca9532_chip_info_tbl[] = {
75 [pca9530] = {
76 .num_leds = 2,
77 },
78 [pca9531] = {
79 .num_leds = 8,
80 },
81 [pca9532] = {
82 .num_leds = 16,
83 },
84 [pca9533] = {
85 .num_leds = 4,
86 },
87};
88
Riku Voipioe14fa822008-05-31 14:43:41 +010089static struct i2c_driver pca9532_driver = {
90 .driver = {
Wolfram Sang30cb35b2011-07-08 15:39:46 -070091 .name = "leds-pca953x",
Riku Voipioe14fa822008-05-31 14:43:41 +010092 },
Richard Purdie85c52042009-09-07 14:35:04 +010093 .probe = pca9532_probe,
Riku Voipioe14fa822008-05-31 14:43:41 +010094 .remove = pca9532_remove,
95 .id_table = pca9532_id,
96};
97
Lucas De Marchi25985ed2011-03-30 22:57:33 -030098/* We have two pwm/blinkers, but 16 possible leds to drive. Additionally,
Riku Voipioe14fa822008-05-31 14:43:41 +010099 * the clever Thecus people are using one pwm to drive the beeper. So,
100 * as a compromise we average one pwm to the values requested by all
101 * leds that are not ON/OFF.
102 * */
Riku Voipio934cd3f2008-12-03 08:21:36 +0000103static int pca9532_calcpwm(struct i2c_client *client, int pwm, int blink,
Riku Voipioe14fa822008-05-31 14:43:41 +0100104 enum led_brightness value)
105{
106 int a = 0, b = 0, i = 0;
107 struct pca9532_data *data = i2c_get_clientdata(client);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700108 for (i = 0; i < data->chip_info->num_leds; i++) {
Riku Voipioe14fa822008-05-31 14:43:41 +0100109 if (data->leds[i].type == PCA9532_TYPE_LED &&
110 data->leds[i].state == PCA9532_PWM0+pwm) {
111 a++;
112 b += data->leds[i].ldev.brightness;
113 }
114 }
115 if (a == 0) {
116 dev_err(&client->dev,
117 "fear of division by zero %d/%d, wanted %d\n",
118 b, a, value);
119 return -EINVAL;
120 }
121 b = b/a;
122 if (b > 0xFF)
123 return -EINVAL;
Riku Voipioe14fa822008-05-31 14:43:41 +0100124 data->pwm[pwm] = b;
Antonio Ospite07172d22009-06-19 13:53:07 +0200125 data->psc[pwm] = blink;
126 return 0;
Riku Voipio934cd3f2008-12-03 08:21:36 +0000127}
128
129static int pca9532_setpwm(struct i2c_client *client, int pwm)
130{
Antonio Ospite07172d22009-06-19 13:53:07 +0200131 struct pca9532_data *data = i2c_get_clientdata(client);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700132 u8 maxleds = data->chip_info->num_leds;
133
Antonio Ospite07172d22009-06-19 13:53:07 +0200134 mutex_lock(&data->update_lock);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700135 i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(maxleds, pwm),
Riku Voipioe14fa822008-05-31 14:43:41 +0100136 data->pwm[pwm]);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700137 i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(maxleds, pwm),
Riku Voipioe14fa822008-05-31 14:43:41 +0100138 data->psc[pwm]);
139 mutex_unlock(&data->update_lock);
140 return 0;
141}
142
143/* Set LED routing */
144static void pca9532_setled(struct pca9532_led *led)
145{
146 struct i2c_client *client = led->client;
147 struct pca9532_data *data = i2c_get_clientdata(client);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700148 u8 maxleds = data->chip_info->num_leds;
Riku Voipioe14fa822008-05-31 14:43:41 +0100149 char reg;
150
151 mutex_lock(&data->update_lock);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700152 reg = i2c_smbus_read_byte_data(client, LED_REG(maxleds, led->id));
Riku Voipioe14fa822008-05-31 14:43:41 +0100153 /* zero led bits */
154 reg = reg & ~(0x3<<LED_NUM(led->id)*2);
155 /* set the new value */
156 reg = reg | (led->state << LED_NUM(led->id)*2);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700157 i2c_smbus_write_byte_data(client, LED_REG(maxleds, led->id), reg);
Riku Voipioe14fa822008-05-31 14:43:41 +0100158 mutex_unlock(&data->update_lock);
159}
160
161static void pca9532_set_brightness(struct led_classdev *led_cdev,
162 enum led_brightness value)
163{
164 int err = 0;
165 struct pca9532_led *led = ldev_to_led(led_cdev);
166
167 if (value == LED_OFF)
168 led->state = PCA9532_OFF;
169 else if (value == LED_FULL)
170 led->state = PCA9532_ON;
171 else {
172 led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */
Antonio Ospite07172d22009-06-19 13:53:07 +0200173 err = pca9532_calcpwm(led->client, 0, 0, value);
Riku Voipioe14fa822008-05-31 14:43:41 +0100174 if (err)
175 return; /* XXX: led api doesn't allow error code? */
176 }
Antonio Ospite07172d22009-06-19 13:53:07 +0200177 schedule_work(&led->work);
Riku Voipioe14fa822008-05-31 14:43:41 +0100178}
179
180static int pca9532_set_blink(struct led_classdev *led_cdev,
181 unsigned long *delay_on, unsigned long *delay_off)
182{
183 struct pca9532_led *led = ldev_to_led(led_cdev);
184 struct i2c_client *client = led->client;
185 int psc;
Antonio Ospite07172d22009-06-19 13:53:07 +0200186 int err = 0;
Riku Voipioe14fa822008-05-31 14:43:41 +0100187
188 if (*delay_on == 0 && *delay_off == 0) {
Jingoo Han962363c2013-01-21 21:58:07 -0800189 /* led subsystem ask us for a blink rate */
Richard Purdie85c52042009-09-07 14:35:04 +0100190 *delay_on = 1000;
Riku Voipioe14fa822008-05-31 14:43:41 +0100191 *delay_off = 1000;
192 }
193 if (*delay_on != *delay_off || *delay_on > 1690 || *delay_on < 6)
194 return -EINVAL;
195
196 /* Thecus specific: only use PSC/PWM 0 */
197 psc = (*delay_on * 152-1)/1000;
Antonio Ospite07172d22009-06-19 13:53:07 +0200198 err = pca9532_calcpwm(client, 0, psc, led_cdev->brightness);
199 if (err)
200 return err;
201 schedule_work(&led->work);
202 return 0;
Riku Voipioe14fa822008-05-31 14:43:41 +0100203}
204
Sven Wegener0d733572008-11-17 14:33:41 +0000205static int pca9532_event(struct input_dev *dev, unsigned int type,
206 unsigned int code, int value)
Riku Voipioe14fa822008-05-31 14:43:41 +0100207{
208 struct pca9532_data *data = input_get_drvdata(dev);
209
Riku Voipio7fbc3a92009-03-03 22:13:06 +0200210 if (!(type == EV_SND && (code == SND_BELL || code == SND_TONE)))
Riku Voipioe14fa822008-05-31 14:43:41 +0100211 return -1;
212
213 /* XXX: allow different kind of beeps with psc/pwm modifications */
214 if (value > 1 && value < 32767)
215 data->pwm[1] = 127;
216 else
217 data->pwm[1] = 0;
218
Antonio Ospite07172d22009-06-19 13:53:07 +0200219 schedule_work(&data->work);
Riku Voipio934cd3f2008-12-03 08:21:36 +0000220
Antonio Ospite07172d22009-06-19 13:53:07 +0200221 return 0;
Riku Voipio934cd3f2008-12-03 08:21:36 +0000222}
223
224static void pca9532_input_work(struct work_struct *work)
225{
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700226 struct pca9532_data *data =
227 container_of(work, struct pca9532_data, work);
228 u8 maxleds = data->chip_info->num_leds;
229
Riku Voipioe14fa822008-05-31 14:43:41 +0100230 mutex_lock(&data->update_lock);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700231 i2c_smbus_write_byte_data(data->client, PCA9532_REG_PWM(maxleds, 1),
Riku Voipioe14fa822008-05-31 14:43:41 +0100232 data->pwm[1]);
233 mutex_unlock(&data->update_lock);
Riku Voipio934cd3f2008-12-03 08:21:36 +0000234}
Riku Voipioe14fa822008-05-31 14:43:41 +0100235
Riku Voipio934cd3f2008-12-03 08:21:36 +0000236static void pca9532_led_work(struct work_struct *work)
237{
Antonio Ospite07172d22009-06-19 13:53:07 +0200238 struct pca9532_led *led;
239 led = container_of(work, struct pca9532_led, work);
240 if (led->state == PCA9532_PWM0)
241 pca9532_setpwm(led->client, 0);
242 pca9532_setled(led);
Riku Voipioe14fa822008-05-31 14:43:41 +0100243}
244
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700245#ifdef CONFIG_LEDS_PCA9532_GPIO
246static int pca9532_gpio_request_pin(struct gpio_chip *gc, unsigned offset)
247{
248 struct pca9532_data *data = container_of(gc, struct pca9532_data, gpio);
249 struct pca9532_led *led = &data->leds[offset];
250
251 if (led->type == PCA9532_TYPE_GPIO)
252 return 0;
253
254 return -EBUSY;
255}
256
257static void pca9532_gpio_set_value(struct gpio_chip *gc, unsigned offset, int val)
258{
259 struct pca9532_data *data = container_of(gc, struct pca9532_data, gpio);
260 struct pca9532_led *led = &data->leds[offset];
261
262 if (val)
263 led->state = PCA9532_ON;
264 else
265 led->state = PCA9532_OFF;
266
267 pca9532_setled(led);
268}
269
270static int pca9532_gpio_get_value(struct gpio_chip *gc, unsigned offset)
271{
272 struct pca9532_data *data = container_of(gc, struct pca9532_data, gpio);
273 unsigned char reg;
274
275 reg = i2c_smbus_read_byte_data(data->client, PCA9532_REG_INPUT(offset));
276
277 return !!(reg & (1 << (offset % 8)));
278}
279
280static int pca9532_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
281{
282 /* To use as input ensure pin is not driven */
283 pca9532_gpio_set_value(gc, offset, 0);
284
285 return 0;
286}
287
288static int pca9532_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int val)
289{
290 pca9532_gpio_set_value(gc, offset, val);
291
292 return 0;
293}
294#endif /* CONFIG_LEDS_PCA9532_GPIO */
295
296static int pca9532_destroy_devices(struct pca9532_data *data, int n_devs)
Axel Lin125c7132011-01-12 16:59:15 -0800297{
298 int i = n_devs;
299
300 if (!data)
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700301 return -EINVAL;
Axel Lin125c7132011-01-12 16:59:15 -0800302
303 while (--i >= 0) {
304 switch (data->leds[i].type) {
305 case PCA9532_TYPE_NONE:
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700306 case PCA9532_TYPE_GPIO:
Axel Lin125c7132011-01-12 16:59:15 -0800307 break;
308 case PCA9532_TYPE_LED:
309 led_classdev_unregister(&data->leds[i].ldev);
310 cancel_work_sync(&data->leds[i].work);
311 break;
312 case PCA9532_TYPE_N2100_BEEP:
313 if (data->idev != NULL) {
Axel Lin125c7132011-01-12 16:59:15 -0800314 cancel_work_sync(&data->work);
315 data->idev = NULL;
316 }
317 break;
318 }
319 }
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700320
321#ifdef CONFIG_LEDS_PCA9532_GPIO
abdoulaye berthe88d5e522014-07-12 22:30:14 +0200322 if (data->gpio.dev)
323 gpiochip_remove(&data->gpio);
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700324#endif
325
326 return 0;
Axel Lin125c7132011-01-12 16:59:15 -0800327}
328
Riku Voipioe14fa822008-05-31 14:43:41 +0100329static int pca9532_configure(struct i2c_client *client,
330 struct pca9532_data *data, struct pca9532_platform_data *pdata)
331{
332 int i, err = 0;
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700333 int gpios = 0;
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700334 u8 maxleds = data->chip_info->num_leds;
Riku Voipioe14fa822008-05-31 14:43:41 +0100335
336 for (i = 0; i < 2; i++) {
337 data->pwm[i] = pdata->pwm[i];
338 data->psc[i] = pdata->psc[i];
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700339 i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(maxleds, i),
Riku Voipioe14fa822008-05-31 14:43:41 +0100340 data->pwm[i]);
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700341 i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(maxleds, i),
Riku Voipioe14fa822008-05-31 14:43:41 +0100342 data->psc[i]);
343 }
344
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700345 for (i = 0; i < data->chip_info->num_leds; i++) {
Riku Voipioe14fa822008-05-31 14:43:41 +0100346 struct pca9532_led *led = &data->leds[i];
347 struct pca9532_led *pled = &pdata->leds[i];
348 led->client = client;
349 led->id = i;
350 led->type = pled->type;
351 switch (led->type) {
352 case PCA9532_TYPE_NONE:
353 break;
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700354 case PCA9532_TYPE_GPIO:
355 gpios++;
356 break;
Riku Voipioe14fa822008-05-31 14:43:41 +0100357 case PCA9532_TYPE_LED:
358 led->state = pled->state;
Richard Purdie85c52042009-09-07 14:35:04 +0100359 led->name = pled->name;
Riku Voipioe14fa822008-05-31 14:43:41 +0100360 led->ldev.name = led->name;
361 led->ldev.brightness = LED_OFF;
362 led->ldev.brightness_set = pca9532_set_brightness;
363 led->ldev.blink_set = pca9532_set_blink;
Antonio Ospite07172d22009-06-19 13:53:07 +0200364 INIT_WORK(&led->work, pca9532_led_work);
Sven Wegenerf785d022008-12-03 08:12:53 +0000365 err = led_classdev_register(&client->dev, &led->ldev);
366 if (err < 0) {
Riku Voipioe14fa822008-05-31 14:43:41 +0100367 dev_err(&client->dev,
368 "couldn't register LED %s\n",
369 led->name);
370 goto exit;
371 }
372 pca9532_setled(led);
373 break;
374 case PCA9532_TYPE_N2100_BEEP:
375 BUG_ON(data->idev);
376 led->state = PCA9532_PWM1;
377 pca9532_setled(led);
Axel Lin8614fb42012-12-25 02:16:54 -0800378 data->idev = devm_input_allocate_device(&client->dev);
Riku Voipioe14fa822008-05-31 14:43:41 +0100379 if (data->idev == NULL) {
380 err = -ENOMEM;
381 goto exit;
382 }
383 data->idev->name = pled->name;
384 data->idev->phys = "i2c/pca9532";
385 data->idev->id.bustype = BUS_HOST;
Richard Purdie85c52042009-09-07 14:35:04 +0100386 data->idev->id.vendor = 0x001f;
Riku Voipioe14fa822008-05-31 14:43:41 +0100387 data->idev->id.product = 0x0001;
388 data->idev->id.version = 0x0100;
389 data->idev->evbit[0] = BIT_MASK(EV_SND);
390 data->idev->sndbit[0] = BIT_MASK(SND_BELL) |
391 BIT_MASK(SND_TONE);
392 data->idev->event = pca9532_event;
393 input_set_drvdata(data->idev, data);
Antonio Ospite07172d22009-06-19 13:53:07 +0200394 INIT_WORK(&data->work, pca9532_input_work);
Riku Voipioe14fa822008-05-31 14:43:41 +0100395 err = input_register_device(data->idev);
396 if (err) {
Antonio Ospite07172d22009-06-19 13:53:07 +0200397 cancel_work_sync(&data->work);
Riku Voipioe14fa822008-05-31 14:43:41 +0100398 data->idev = NULL;
399 goto exit;
400 }
401 break;
402 }
403 }
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700404
405#ifdef CONFIG_LEDS_PCA9532_GPIO
406 if (gpios) {
407 data->gpio.label = "gpio-pca9532";
408 data->gpio.direction_input = pca9532_gpio_direction_input;
409 data->gpio.direction_output = pca9532_gpio_direction_output;
410 data->gpio.set = pca9532_gpio_set_value;
411 data->gpio.get = pca9532_gpio_get_value;
412 data->gpio.request = pca9532_gpio_request_pin;
413 data->gpio.can_sleep = 1;
414 data->gpio.base = pdata->gpio_base;
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700415 data->gpio.ngpio = data->chip_info->num_leds;
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700416 data->gpio.dev = &client->dev;
417 data->gpio.owner = THIS_MODULE;
418
419 err = gpiochip_add(&data->gpio);
420 if (err) {
421 /* Use data->gpio.dev as a flag for freeing gpiochip */
422 data->gpio.dev = NULL;
423 dev_warn(&client->dev, "could not add gpiochip\n");
424 } else {
425 dev_info(&client->dev, "gpios %i...%i\n",
426 data->gpio.base, data->gpio.base +
427 data->gpio.ngpio - 1);
428 }
429 }
430#endif
431
Riku Voipioe14fa822008-05-31 14:43:41 +0100432 return 0;
433
434exit:
Axel Lin125c7132011-01-12 16:59:15 -0800435 pca9532_destroy_devices(data, i);
Riku Voipioe14fa822008-05-31 14:43:41 +0100436 return err;
Riku Voipioe14fa822008-05-31 14:43:41 +0100437}
438
439static int pca9532_probe(struct i2c_client *client,
440 const struct i2c_device_id *id)
441{
442 struct pca9532_data *data = i2c_get_clientdata(client);
Jingoo Han87aae1e2013-07-30 01:07:35 -0700443 struct pca9532_platform_data *pca9532_pdata =
444 dev_get_platdata(&client->dev);
Sven Wegenerf785d022008-12-03 08:12:53 +0000445
446 if (!pca9532_pdata)
447 return -EIO;
Riku Voipioe14fa822008-05-31 14:43:41 +0100448
449 if (!i2c_check_functionality(client->adapter,
450 I2C_FUNC_SMBUS_BYTE_DATA))
451 return -EIO;
452
Bryan Wu0f4630c2012-07-04 11:59:19 +0800453 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
Riku Voipioe14fa822008-05-31 14:43:41 +0100454 if (!data)
455 return -ENOMEM;
456
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700457 data->chip_info = &pca9532_chip_info_tbl[id->driver_data];
458
Riku Voipioe14fa822008-05-31 14:43:41 +0100459 dev_info(&client->dev, "setting platform data\n");
460 i2c_set_clientdata(client, data);
461 data->client = client;
462 mutex_init(&data->update_lock);
463
Bryan Wu0f4630c2012-07-04 11:59:19 +0800464 return pca9532_configure(client, data, pca9532_pdata);
Riku Voipioe14fa822008-05-31 14:43:41 +0100465}
466
467static int pca9532_remove(struct i2c_client *client)
468{
469 struct pca9532_data *data = i2c_get_clientdata(client);
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700470 int err;
471
Jan Weitzel3dbf6222011-05-24 17:13:26 -0700472 err = pca9532_destroy_devices(data, data->chip_info->num_leds);
Joachim Eastwood3c1ab502011-05-24 17:13:23 -0700473 if (err)
474 return err;
475
Riku Voipioe14fa822008-05-31 14:43:41 +0100476 return 0;
477}
478
Axel Lin09a0d182012-01-10 15:09:27 -0800479module_i2c_driver(pca9532_driver);
Riku Voipioe14fa822008-05-31 14:43:41 +0100480
Riku Voipiob26e0ed2009-03-03 21:37:17 +0200481MODULE_AUTHOR("Riku Voipio");
Riku Voipioe14fa822008-05-31 14:43:41 +0100482MODULE_LICENSE("GPL");
483MODULE_DESCRIPTION("PCA 9532 LED dimmer");