blob: f062d1e7640ff4d0676b9bab23866daadc58fd4f [file] [log] [blame]
Nate Casef46e9202008-07-16 22:49:55 +01001/*
2 * Copyright 2007-2008 Extreme Engineering Solutions, Inc.
3 *
4 * Author: Nate Case <ncase@xes-inc.com>
5 *
6 * This file is subject to the terms and conditions of version 2 of
7 * the GNU General Public License. See the file COPYING in the main
8 * directory of this archive for more details.
9 *
10 * LED driver for various PCA955x I2C LED drivers
11 *
12 * Supported devices:
13 *
14 * Device Description 7-bit slave address
15 * ------ ----------- -------------------
16 * PCA9550 2-bit driver 0x60 .. 0x61
17 * PCA9551 8-bit driver 0x60 .. 0x67
18 * PCA9552 16-bit driver 0x60 .. 0x67
19 * PCA9553/01 4-bit driver 0x62
20 * PCA9553/02 4-bit driver 0x63
21 *
22 * Philips PCA955x LED driver chips follow a register map as shown below:
23 *
24 * Control Register Description
25 * ---------------- -----------
26 * 0x0 Input register 0
27 * ..
28 * NUM_INPUT_REGS - 1 Last Input register X
29 *
30 * NUM_INPUT_REGS Frequency prescaler 0
31 * NUM_INPUT_REGS + 1 PWM register 0
32 * NUM_INPUT_REGS + 2 Frequency prescaler 1
33 * NUM_INPUT_REGS + 3 PWM register 1
34 *
35 * NUM_INPUT_REGS + 4 LED selector 0
36 * NUM_INPUT_REGS + 4
37 * + NUM_LED_REGS - 1 Last LED selector
38 *
39 * where NUM_INPUT_REGS and NUM_LED_REGS vary depending on how many
40 * bits the chip supports.
41 */
42
Tin Huynh44b3e312016-12-02 11:39:13 +070043#include <linux/acpi.h>
Nate Casef46e9202008-07-16 22:49:55 +010044#include <linux/ctype.h>
Cédric Le Goatered1f4b92017-08-08 15:42:37 +020045#include <linux/delay.h>
Nate Casef46e9202008-07-16 22:49:55 +010046#include <linux/err.h>
Cédric Le Goatered1f4b92017-08-08 15:42:37 +020047#include <linux/gpio.h>
Nate Casef46e9202008-07-16 22:49:55 +010048#include <linux/i2c.h>
Cédric Le Goatered1f4b92017-08-08 15:42:37 +020049#include <linux/leds.h>
50#include <linux/module.h>
51#include <linux/of_device.h>
52#include <linux/of.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090053#include <linux/slab.h>
Cédric Le Goatered1f4b92017-08-08 15:42:37 +020054#include <linux/string.h>
Nate Casef46e9202008-07-16 22:49:55 +010055
Cédric Le Goater561099a12017-08-08 15:42:39 +020056#include <dt-bindings/leds/leds-pca955x.h>
57
Nate Casef46e9202008-07-16 22:49:55 +010058/* LED select registers determine the source that drives LED outputs */
59#define PCA955X_LS_LED_ON 0x0 /* Output LOW */
60#define PCA955X_LS_LED_OFF 0x1 /* Output HI-Z */
61#define PCA955X_LS_BLINK0 0x2 /* Blink at PWM0 rate */
62#define PCA955X_LS_BLINK1 0x3 /* Blink at PWM1 rate */
63
64enum pca955x_type {
65 pca9550,
66 pca9551,
67 pca9552,
68 pca9553,
69};
70
71struct pca955x_chipdef {
72 int bits;
73 u8 slv_addr; /* 7-bit slave address mask */
74 int slv_addr_shift; /* Number of bits to ignore */
75};
76
77static struct pca955x_chipdef pca955x_chipdefs[] = {
78 [pca9550] = {
79 .bits = 2,
80 .slv_addr = /* 110000x */ 0x60,
81 .slv_addr_shift = 1,
82 },
83 [pca9551] = {
84 .bits = 8,
85 .slv_addr = /* 1100xxx */ 0x60,
86 .slv_addr_shift = 3,
87 },
88 [pca9552] = {
89 .bits = 16,
90 .slv_addr = /* 1100xxx */ 0x60,
91 .slv_addr_shift = 3,
92 },
93 [pca9553] = {
94 .bits = 4,
95 .slv_addr = /* 110001x */ 0x62,
96 .slv_addr_shift = 1,
97 },
98};
99
100static const struct i2c_device_id pca955x_id[] = {
101 { "pca9550", pca9550 },
102 { "pca9551", pca9551 },
103 { "pca9552", pca9552 },
104 { "pca9553", pca9553 },
105 { }
106};
107MODULE_DEVICE_TABLE(i2c, pca955x_id);
108
Tin Huynh44b3e312016-12-02 11:39:13 +0700109static const struct acpi_device_id pca955x_acpi_ids[] = {
110 { "PCA9550", pca9550 },
111 { "PCA9551", pca9551 },
112 { "PCA9552", pca9552 },
113 { "PCA9553", pca9553 },
114 { }
115};
116MODULE_DEVICE_TABLE(acpi, pca955x_acpi_ids);
117
Alexander Steine7e11d82012-05-29 15:07:30 -0700118struct pca955x {
119 struct mutex lock;
120 struct pca955x_led *leds;
Nate Casef46e9202008-07-16 22:49:55 +0100121 struct pca955x_chipdef *chipdef;
122 struct i2c_client *client;
Cédric Le Goater561099a12017-08-08 15:42:39 +0200123#ifdef CONFIG_LEDS_PCA955X_GPIO
124 struct gpio_chip gpio;
125#endif
Alexander Steine7e11d82012-05-29 15:07:30 -0700126};
127
128struct pca955x_led {
129 struct pca955x *pca955x;
Nate Casef46e9202008-07-16 22:49:55 +0100130 struct led_classdev led_cdev;
131 int led_num; /* 0 .. 15 potentially */
132 char name[32];
Cédric Le Goater561099a12017-08-08 15:42:39 +0200133 u32 type;
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200134 const char *default_trigger;
135};
136
137struct pca955x_platform_data {
138 struct pca955x_led *leds;
139 int num_leds;
Nate Casef46e9202008-07-16 22:49:55 +0100140};
141
142/* 8 bits per input register */
143static inline int pca95xx_num_input_regs(int bits)
144{
145 return (bits + 7) / 8;
146}
147
148/* 4 bits per LED selector register */
149static inline int pca95xx_num_led_regs(int bits)
150{
151 return (bits + 3) / 4;
152}
153
154/*
155 * Return an LED selector register value based on an existing one, with
156 * the appropriate 2-bit state value set for the given LED number (0-3).
157 */
158static inline u8 pca955x_ledsel(u8 oldval, int led_num, int state)
159{
160 return (oldval & (~(0x3 << (led_num << 1)))) |
161 ((state & 0x3) << (led_num << 1));
162}
163
164/*
165 * Write to frequency prescaler register, used to program the
166 * period of the PWM output. period = (PSCx + 1) / 38
167 */
168static void pca955x_write_psc(struct i2c_client *client, int n, u8 val)
169{
Alexander Steine7e11d82012-05-29 15:07:30 -0700170 struct pca955x *pca955x = i2c_get_clientdata(client);
Nate Casef46e9202008-07-16 22:49:55 +0100171
172 i2c_smbus_write_byte_data(client,
173 pca95xx_num_input_regs(pca955x->chipdef->bits) + 2*n,
174 val);
175}
176
177/*
178 * Write to PWM register, which determines the duty cycle of the
179 * output. LED is OFF when the count is less than the value of this
180 * register, and ON when it is greater. If PWMx == 0, LED is always OFF.
181 *
182 * Duty cycle is (256 - PWMx) / 256
183 */
184static void pca955x_write_pwm(struct i2c_client *client, int n, u8 val)
185{
Alexander Steine7e11d82012-05-29 15:07:30 -0700186 struct pca955x *pca955x = i2c_get_clientdata(client);
Nate Casef46e9202008-07-16 22:49:55 +0100187
188 i2c_smbus_write_byte_data(client,
189 pca95xx_num_input_regs(pca955x->chipdef->bits) + 1 + 2*n,
190 val);
191}
192
193/*
194 * Write to LED selector register, which determines the source that
195 * drives the LED output.
196 */
197static void pca955x_write_ls(struct i2c_client *client, int n, u8 val)
198{
Alexander Steine7e11d82012-05-29 15:07:30 -0700199 struct pca955x *pca955x = i2c_get_clientdata(client);
Nate Casef46e9202008-07-16 22:49:55 +0100200
201 i2c_smbus_write_byte_data(client,
202 pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n,
203 val);
204}
205
206/*
207 * Read the LED selector register, which determines the source that
208 * drives the LED output.
209 */
210static u8 pca955x_read_ls(struct i2c_client *client, int n)
211{
Alexander Steine7e11d82012-05-29 15:07:30 -0700212 struct pca955x *pca955x = i2c_get_clientdata(client);
Nate Casef46e9202008-07-16 22:49:55 +0100213
214 return (u8) i2c_smbus_read_byte_data(client,
215 pca95xx_num_input_regs(pca955x->chipdef->bits) + 4 + n);
216}
217
Andrew Lunnc3482b82015-08-20 12:32:35 +0200218static int pca955x_led_set(struct led_classdev *led_cdev,
219 enum led_brightness value)
Nate Casef46e9202008-07-16 22:49:55 +0100220{
Alexander Steine7e11d82012-05-29 15:07:30 -0700221 struct pca955x_led *pca955x_led;
222 struct pca955x *pca955x;
Nate Casef46e9202008-07-16 22:49:55 +0100223 u8 ls;
224 int chip_ls; /* which LSx to use (0-3 potentially) */
225 int ls_led; /* which set of bits within LSx to use (0-3) */
226
Andrew Lunnc3482b82015-08-20 12:32:35 +0200227 pca955x_led = container_of(led_cdev, struct pca955x_led, led_cdev);
Alexander Steine7e11d82012-05-29 15:07:30 -0700228 pca955x = pca955x_led->pca955x;
229
230 chip_ls = pca955x_led->led_num / 4;
231 ls_led = pca955x_led->led_num % 4;
232
233 mutex_lock(&pca955x->lock);
Nate Casef46e9202008-07-16 22:49:55 +0100234
235 ls = pca955x_read_ls(pca955x->client, chip_ls);
236
Andrew Lunnc3482b82015-08-20 12:32:35 +0200237 switch (value) {
Nate Casef46e9202008-07-16 22:49:55 +0100238 case LED_FULL:
239 ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_ON);
240 break;
241 case LED_OFF:
242 ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_LED_OFF);
243 break;
244 case LED_HALF:
245 ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK0);
246 break;
247 default:
248 /*
249 * Use PWM1 for all other values. This has the unwanted
250 * side effect of making all LEDs on the chip share the
251 * same brightness level if set to a value other than
252 * OFF, HALF, or FULL. But, this is probably better than
253 * just turning off for all other values.
254 */
Alexander Steine7e11d82012-05-29 15:07:30 -0700255 pca955x_write_pwm(pca955x->client, 1,
Andrew Lunnc3482b82015-08-20 12:32:35 +0200256 255 - value);
Nate Casef46e9202008-07-16 22:49:55 +0100257 ls = pca955x_ledsel(ls, ls_led, PCA955X_LS_BLINK1);
258 break;
259 }
260
261 pca955x_write_ls(pca955x->client, chip_ls, ls);
Alexander Steine7e11d82012-05-29 15:07:30 -0700262
263 mutex_unlock(&pca955x->lock);
Nate Casef46e9202008-07-16 22:49:55 +0100264
Andrew Lunnc3482b82015-08-20 12:32:35 +0200265 return 0;
Nate Casef46e9202008-07-16 22:49:55 +0100266}
267
Cédric Le Goater561099a12017-08-08 15:42:39 +0200268#ifdef CONFIG_LEDS_PCA955X_GPIO
269/*
270 * Read the INPUT register, which contains the state of LEDs.
271 */
272static u8 pca955x_read_input(struct i2c_client *client, int n)
273{
274 return (u8)i2c_smbus_read_byte_data(client, n);
275}
276
277static int pca955x_gpio_request_pin(struct gpio_chip *gc, unsigned int offset)
278{
279 struct pca955x *pca955x = gpiochip_get_data(gc);
280 struct pca955x_led *led = &pca955x->leds[offset];
281
282 if (led->type == PCA955X_TYPE_GPIO)
283 return 0;
284
285 return -EBUSY;
286}
287
288static void pca955x_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
289 int val)
290{
291 struct pca955x *pca955x = gpiochip_get_data(gc);
292 struct pca955x_led *led = &pca955x->leds[offset];
293
294 if (val)
295 pca955x_led_set(&led->led_cdev, LED_FULL);
296 else
297 pca955x_led_set(&led->led_cdev, LED_OFF);
298}
299
300static int pca955x_gpio_get_value(struct gpio_chip *gc, unsigned int offset)
301{
302 struct pca955x *pca955x = gpiochip_get_data(gc);
303 struct pca955x_led *led = &pca955x->leds[offset];
304 u8 reg = pca955x_read_input(pca955x->client, led->led_num / 8);
305
306 return !!(reg & (1 << (led->led_num % 8)));
307}
308
309static int pca955x_gpio_direction_input(struct gpio_chip *gc,
310 unsigned int offset)
311{
312 /* To use as input ensure pin is not driven */
313 pca955x_gpio_set_value(gc, offset, 0);
314
315 return 0;
316}
317
318static int pca955x_gpio_direction_output(struct gpio_chip *gc,
319 unsigned int offset, int val)
320{
321 pca955x_gpio_set_value(gc, offset, val);
322
323 return 0;
324}
325#endif /* CONFIG_LEDS_PCA955X_GPIO */
326
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200327#if IS_ENABLED(CONFIG_OF)
328static struct pca955x_platform_data *
329pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip)
330{
331 struct device_node *np = client->dev.of_node;
332 struct device_node *child;
333 struct pca955x_platform_data *pdata;
334 int count;
335
336 count = of_get_child_count(np);
337 if (!count || count > chip->bits)
338 return ERR_PTR(-ENODEV);
339
340 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
341 if (!pdata)
342 return ERR_PTR(-ENOMEM);
343
344 pdata->leds = devm_kzalloc(&client->dev,
345 sizeof(struct pca955x_led) * chip->bits,
346 GFP_KERNEL);
347 if (!pdata->leds)
348 return ERR_PTR(-ENOMEM);
349
350 for_each_child_of_node(np, child) {
351 const char *name;
352 u32 reg;
353 int res;
354
355 res = of_property_read_u32(child, "reg", &reg);
356 if ((res != 0) || (reg >= chip->bits))
357 continue;
358
359 if (of_property_read_string(child, "label", &name))
360 name = child->name;
361
362 snprintf(pdata->leds[reg].name, sizeof(pdata->leds[reg].name),
363 "%s", name);
364
Cédric Le Goater561099a12017-08-08 15:42:39 +0200365 pdata->leds[reg].type = PCA955X_TYPE_LED;
366 of_property_read_u32(child, "type", &pdata->leds[reg].type);
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200367 of_property_read_string(child, "linux,default-trigger",
368 &pdata->leds[reg].default_trigger);
369 }
370
371 pdata->num_leds = chip->bits;
372
373 return pdata;
374}
375
376static const struct of_device_id of_pca955x_match[] = {
377 { .compatible = "nxp,pca9550", .data = (void *)pca9550 },
378 { .compatible = "nxp,pca9551", .data = (void *)pca9551 },
379 { .compatible = "nxp,pca9552", .data = (void *)pca9552 },
380 { .compatible = "nxp,pca9553", .data = (void *)pca9553 },
381 {},
382};
383
384MODULE_DEVICE_TABLE(of, of_pca955x_match);
385#else
386static struct pca955x_platform_data *
387pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip)
388{
389 return ERR_PTR(-ENODEV);
390}
391#endif
392
Bill Pemberton98ea1ea2012-11-19 13:23:02 -0500393static int pca955x_probe(struct i2c_client *client,
Nate Casef46e9202008-07-16 22:49:55 +0100394 const struct i2c_device_id *id)
395{
Alexander Steine7e11d82012-05-29 15:07:30 -0700396 struct pca955x *pca955x;
397 struct pca955x_led *pca955x_led;
Nate Casef46e9202008-07-16 22:49:55 +0100398 struct pca955x_chipdef *chip;
399 struct i2c_adapter *adapter;
Sven Wegener95bf14b2008-10-03 15:23:48 -0700400 int i, err;
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200401 struct pca955x_platform_data *pdata;
Cédric Le Goater561099a12017-08-08 15:42:39 +0200402 int ngpios = 0;
Nate Casef46e9202008-07-16 22:49:55 +0100403
Tin Huynh44b3e312016-12-02 11:39:13 +0700404 if (id) {
405 chip = &pca955x_chipdefs[id->driver_data];
406 } else {
407 const struct acpi_device_id *acpi_id;
408
409 acpi_id = acpi_match_device(pca955x_acpi_ids, &client->dev);
410 if (!acpi_id)
411 return -ENODEV;
412 chip = &pca955x_chipdefs[acpi_id->driver_data];
413 }
Nate Casef46e9202008-07-16 22:49:55 +0100414 adapter = to_i2c_adapter(client->dev.parent);
Jingoo Han87aae1e2013-07-30 01:07:35 -0700415 pdata = dev_get_platdata(&client->dev);
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200416 if (!pdata) {
417 pdata = pca955x_pdata_of_init(client, chip);
418 if (IS_ERR(pdata))
419 return PTR_ERR(pdata);
420 }
Nate Casef46e9202008-07-16 22:49:55 +0100421
422 /* Make sure the slave address / chip type combo given is possible */
423 if ((client->addr & ~((1 << chip->slv_addr_shift) - 1)) !=
424 chip->slv_addr) {
425 dev_err(&client->dev, "invalid slave address %02x\n",
426 client->addr);
427 return -ENODEV;
428 }
429
Sachin Kamatb40b0c12012-11-25 12:21:47 +0530430 dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at "
Nate Casef46e9202008-07-16 22:49:55 +0100431 "slave address 0x%02x\n",
Tin Huynh44b3e312016-12-02 11:39:13 +0700432 client->name, chip->bits, client->addr);
Nate Casef46e9202008-07-16 22:49:55 +0100433
Tin Huynhaace34c2017-05-22 16:19:20 +0700434 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
Nate Casef46e9202008-07-16 22:49:55 +0100435 return -EIO;
436
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200437 if (pdata->num_leds != chip->bits) {
438 dev_err(&client->dev,
439 "board info claims %d LEDs on a %d-bit chip\n",
440 pdata->num_leds, chip->bits);
441 return -ENODEV;
Nate Casef46e9202008-07-16 22:49:55 +0100442 }
443
Bryan Wu73759f62012-07-04 12:09:05 +0800444 pca955x = devm_kzalloc(&client->dev, sizeof(*pca955x), GFP_KERNEL);
Sven Wegener95bf14b2008-10-03 15:23:48 -0700445 if (!pca955x)
446 return -ENOMEM;
Nate Casef46e9202008-07-16 22:49:55 +0100447
Bryan Wu73759f62012-07-04 12:09:05 +0800448 pca955x->leds = devm_kzalloc(&client->dev,
449 sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
450 if (!pca955x->leds)
451 return -ENOMEM;
Alexander Steine7e11d82012-05-29 15:07:30 -0700452
Sven Wegener95bf14b2008-10-03 15:23:48 -0700453 i2c_set_clientdata(client, pca955x);
454
Alexander Steine7e11d82012-05-29 15:07:30 -0700455 mutex_init(&pca955x->lock);
456 pca955x->client = client;
457 pca955x->chipdef = chip;
458
Sven Wegener95bf14b2008-10-03 15:23:48 -0700459 for (i = 0; i < chip->bits; i++) {
Alexander Steine7e11d82012-05-29 15:07:30 -0700460 pca955x_led = &pca955x->leds[i];
461 pca955x_led->led_num = i;
462 pca955x_led->pca955x = pca955x;
Cédric Le Goater561099a12017-08-08 15:42:39 +0200463 pca955x_led->type = pdata->leds[i].type;
Sven Wegener95bf14b2008-10-03 15:23:48 -0700464
Cédric Le Goater561099a12017-08-08 15:42:39 +0200465 switch (pca955x_led->type) {
466 case PCA955X_TYPE_NONE:
467 break;
468 case PCA955X_TYPE_GPIO:
469 ngpios++;
470 break;
471 case PCA955X_TYPE_LED:
472 /*
473 * Platform data can specify LED names and
474 * default triggers
475 */
Nate Casef46e9202008-07-16 22:49:55 +0100476 if (pdata->leds[i].name)
Alexander Steine7e11d82012-05-29 15:07:30 -0700477 snprintf(pca955x_led->name,
478 sizeof(pca955x_led->name), "pca955x:%s",
479 pdata->leds[i].name);
Nate Casef46e9202008-07-16 22:49:55 +0100480 if (pdata->leds[i].default_trigger)
Alexander Steine7e11d82012-05-29 15:07:30 -0700481 pca955x_led->led_cdev.default_trigger =
Nate Casef46e9202008-07-16 22:49:55 +0100482 pdata->leds[i].default_trigger;
Cédric Le Goater561099a12017-08-08 15:42:39 +0200483
484 pca955x_led->led_cdev.name = pca955x_led->name;
485 pca955x_led->led_cdev.brightness_set_blocking =
486 pca955x_led_set;
487
488 err = devm_led_classdev_register(&client->dev,
489 &pca955x_led->led_cdev);
490 if (err)
491 return err;
492
493 /* Turn off LED */
494 pca955x_led_set(&pca955x_led->led_cdev, LED_OFF);
Nate Casef46e9202008-07-16 22:49:55 +0100495 }
Nate Casef46e9202008-07-16 22:49:55 +0100496 }
497
Nate Casef46e9202008-07-16 22:49:55 +0100498 /* PWM0 is used for half brightness or 50% duty cycle */
499 pca955x_write_pwm(client, 0, 255-LED_HALF);
500
501 /* PWM1 is used for variable brightness, default to OFF */
502 pca955x_write_pwm(client, 1, 0);
503
504 /* Set to fast frequency so we do not see flashing */
505 pca955x_write_psc(client, 0, 0);
506 pca955x_write_psc(client, 1, 0);
507
Cédric Le Goater561099a12017-08-08 15:42:39 +0200508#ifdef CONFIG_LEDS_PCA955X_GPIO
509 if (ngpios) {
510 pca955x->gpio.label = "gpio-pca955x";
511 pca955x->gpio.direction_input = pca955x_gpio_direction_input;
512 pca955x->gpio.direction_output = pca955x_gpio_direction_output;
513 pca955x->gpio.set = pca955x_gpio_set_value;
514 pca955x->gpio.get = pca955x_gpio_get_value;
515 pca955x->gpio.request = pca955x_gpio_request_pin;
516 pca955x->gpio.can_sleep = 1;
517 pca955x->gpio.base = -1;
518 pca955x->gpio.ngpio = ngpios;
519 pca955x->gpio.parent = &client->dev;
520 pca955x->gpio.owner = THIS_MODULE;
521
522 err = devm_gpiochip_add_data(&client->dev, &pca955x->gpio,
523 pca955x);
524 if (err) {
525 /* Use data->gpio.dev as a flag for freeing gpiochip */
526 pca955x->gpio.parent = NULL;
527 dev_warn(&client->dev, "could not add gpiochip\n");
528 return err;
529 }
530 dev_info(&client->dev, "gpios %i...%i\n",
531 pca955x->gpio.base, pca955x->gpio.base +
532 pca955x->gpio.ngpio - 1);
533 }
534#endif
535
Nate Casef46e9202008-07-16 22:49:55 +0100536 return 0;
Nate Casef46e9202008-07-16 22:49:55 +0100537}
538
539static struct i2c_driver pca955x_driver = {
540 .driver = {
541 .name = "leds-pca955x",
Tin Huynh44b3e312016-12-02 11:39:13 +0700542 .acpi_match_table = ACPI_PTR(pca955x_acpi_ids),
Cédric Le Goatered1f4b92017-08-08 15:42:37 +0200543 .of_match_table = of_match_ptr(of_pca955x_match),
Nate Casef46e9202008-07-16 22:49:55 +0100544 },
545 .probe = pca955x_probe,
Nate Casef46e9202008-07-16 22:49:55 +0100546 .id_table = pca955x_id,
547};
548
Axel Lin09a0d182012-01-10 15:09:27 -0800549module_i2c_driver(pca955x_driver);
Nate Casef46e9202008-07-16 22:49:55 +0100550
551MODULE_AUTHOR("Nate Case <ncase@xes-inc.com>");
552MODULE_DESCRIPTION("PCA955x LED driver");
553MODULE_LICENSE("GPL v2");