2 * PCA953x 4/8/16/24/40 bit I/O ports
4 * Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
5 * Copyright (C) 2007 Marvell International Ltd.
7 * Derived from drivers/i2c/chips/pca9539.c
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; version 2 of the License.
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/gpio.h>
17 #include <linux/interrupt.h>
18 #include <linux/i2c.h>
19 #include <linux/platform_data/pca953x.h>
20 #include <linux/slab.h>
21 #include <asm/unaligned.h>
22 #include <linux/of_platform.h>
23 #include <linux/acpi.h>
25 #define PCA953X_INPUT 0
26 #define PCA953X_OUTPUT 1
27 #define PCA953X_INVERT 2
28 #define PCA953X_DIRECTION 3
30 #define REG_ADDR_AI 0x80
33 #define PCA957X_INVRT 1
34 #define PCA957X_BKEN 2
35 #define PCA957X_PUPD 3
39 #define PCA957X_INTS 7
41 #define PCAL953X_IN_LATCH 34
42 #define PCAL953X_INT_MASK 37
43 #define PCAL953X_INT_STAT 38
45 #define PCA_GPIO_MASK 0x00FF
46 #define PCA_INT 0x0100
47 #define PCA_PCAL 0x0200
48 #define PCA953X_TYPE 0x1000
49 #define PCA957X_TYPE 0x2000
50 #define PCA_TYPE_MASK 0xF000
52 #define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK)
54 static const struct i2c_device_id pca953x_id[] = {
55 { "pca9505", 40 | PCA953X_TYPE | PCA_INT, },
56 { "pca9534", 8 | PCA953X_TYPE | PCA_INT, },
57 { "pca9535", 16 | PCA953X_TYPE | PCA_INT, },
58 { "pca9536", 4 | PCA953X_TYPE, },
59 { "pca9537", 4 | PCA953X_TYPE | PCA_INT, },
60 { "pca9538", 8 | PCA953X_TYPE | PCA_INT, },
61 { "pca9539", 16 | PCA953X_TYPE | PCA_INT, },
62 { "pca9554", 8 | PCA953X_TYPE | PCA_INT, },
63 { "pca9555", 16 | PCA953X_TYPE | PCA_INT, },
64 { "pca9556", 8 | PCA953X_TYPE, },
65 { "pca9557", 8 | PCA953X_TYPE, },
66 { "pca9574", 8 | PCA957X_TYPE | PCA_INT, },
67 { "pca9575", 16 | PCA957X_TYPE | PCA_INT, },
68 { "pca9698", 40 | PCA953X_TYPE, },
70 { "max7310", 8 | PCA953X_TYPE, },
71 { "max7312", 16 | PCA953X_TYPE | PCA_INT, },
72 { "max7313", 16 | PCA953X_TYPE | PCA_INT, },
73 { "max7315", 8 | PCA953X_TYPE | PCA_INT, },
74 { "pca6107", 8 | PCA953X_TYPE | PCA_INT, },
75 { "tca6408", 8 | PCA953X_TYPE | PCA_INT, },
76 { "tca6416", 16 | PCA953X_TYPE | PCA_INT, },
77 { "tca6424", 24 | PCA953X_TYPE | PCA_INT, },
78 { "tca9539", 16 | PCA953X_TYPE | PCA_INT, },
79 { "xra1202", 8 | PCA953X_TYPE },
82 MODULE_DEVICE_TABLE(i2c, pca953x_id);
84 static const struct acpi_device_id pca953x_acpi_ids[] = {
85 { "INT3491", 16 | PCA953X_TYPE | PCA_INT | PCA_PCAL, },
88 MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids);
93 #define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
97 u8 reg_output[MAX_BANK];
98 u8 reg_direction[MAX_BANK];
99 struct mutex i2c_lock;
101 #ifdef CONFIG_GPIO_PCA953X_IRQ
102 struct mutex irq_lock;
103 u8 irq_mask[MAX_BANK];
104 u8 irq_stat[MAX_BANK];
105 u8 irq_trig_raise[MAX_BANK];
106 u8 irq_trig_fall[MAX_BANK];
109 struct i2c_client *client;
110 struct gpio_chip gpio_chip;
111 const char *const *names;
113 unsigned long driver_data;
116 static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val,
120 int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
121 int offset = off / BANK_SZ;
123 ret = i2c_smbus_read_byte_data(chip->client,
124 (reg << bank_shift) + offset);
128 dev_err(&chip->client->dev, "failed reading register\n");
135 static int pca953x_write_single(struct pca953x_chip *chip, int reg, u32 val,
139 int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
140 int offset = off / BANK_SZ;
142 ret = i2c_smbus_write_byte_data(chip->client,
143 (reg << bank_shift) + offset, val);
146 dev_err(&chip->client->dev, "failed writing register\n");
153 static int pca953x_write_regs(struct pca953x_chip *chip, int reg, u8 *val)
157 if (chip->gpio_chip.ngpio <= 8)
158 ret = i2c_smbus_write_byte_data(chip->client, reg, *val);
159 else if (chip->gpio_chip.ngpio >= 24) {
160 int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
161 ret = i2c_smbus_write_i2c_block_data(chip->client,
162 (reg << bank_shift) | REG_ADDR_AI,
165 switch (chip->chip_type) {
167 ret = i2c_smbus_write_word_data(chip->client,
168 reg << 1, cpu_to_le16(get_unaligned((u16 *)val)));
171 ret = i2c_smbus_write_byte_data(chip->client, reg << 1,
175 ret = i2c_smbus_write_byte_data(chip->client,
183 dev_err(&chip->client->dev, "failed writing register\n");
190 static int pca953x_read_regs(struct pca953x_chip *chip, int reg, u8 *val)
194 if (chip->gpio_chip.ngpio <= 8) {
195 ret = i2c_smbus_read_byte_data(chip->client, reg);
197 } else if (chip->gpio_chip.ngpio >= 24) {
198 int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
200 ret = i2c_smbus_read_i2c_block_data(chip->client,
201 (reg << bank_shift) | REG_ADDR_AI,
204 ret = i2c_smbus_read_word_data(chip->client, reg << 1);
205 val[0] = (u16)ret & 0xFF;
206 val[1] = (u16)ret >> 8;
209 dev_err(&chip->client->dev, "failed reading register\n");
216 static int pca953x_gpio_direction_input(struct gpio_chip *gc, unsigned off)
218 struct pca953x_chip *chip = gpiochip_get_data(gc);
222 mutex_lock(&chip->i2c_lock);
223 reg_val = chip->reg_direction[off / BANK_SZ] | (1u << (off % BANK_SZ));
225 switch (chip->chip_type) {
227 offset = PCA953X_DIRECTION;
230 offset = PCA957X_CFG;
233 ret = pca953x_write_single(chip, offset, reg_val, off);
237 chip->reg_direction[off / BANK_SZ] = reg_val;
240 mutex_unlock(&chip->i2c_lock);
244 static int pca953x_gpio_direction_output(struct gpio_chip *gc,
245 unsigned off, int val)
247 struct pca953x_chip *chip = gpiochip_get_data(gc);
251 mutex_lock(&chip->i2c_lock);
252 /* set output level */
254 reg_val = chip->reg_output[off / BANK_SZ]
255 | (1u << (off % BANK_SZ));
257 reg_val = chip->reg_output[off / BANK_SZ]
258 & ~(1u << (off % BANK_SZ));
260 switch (chip->chip_type) {
262 offset = PCA953X_OUTPUT;
265 offset = PCA957X_OUT;
268 ret = pca953x_write_single(chip, offset, reg_val, off);
272 chip->reg_output[off / BANK_SZ] = reg_val;
275 reg_val = chip->reg_direction[off / BANK_SZ] & ~(1u << (off % BANK_SZ));
276 switch (chip->chip_type) {
278 offset = PCA953X_DIRECTION;
281 offset = PCA957X_CFG;
284 ret = pca953x_write_single(chip, offset, reg_val, off);
288 chip->reg_direction[off / BANK_SZ] = reg_val;
291 mutex_unlock(&chip->i2c_lock);
295 static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
297 struct pca953x_chip *chip = gpiochip_get_data(gc);
301 mutex_lock(&chip->i2c_lock);
302 switch (chip->chip_type) {
304 offset = PCA953X_INPUT;
310 ret = pca953x_read_single(chip, offset, ®_val, off);
311 mutex_unlock(&chip->i2c_lock);
313 /* NOTE: diagnostic already emitted; that's all we should
314 * do unless gpio_*_value_cansleep() calls become different
315 * from their nonsleeping siblings (and report faults).
320 return (reg_val & (1u << (off % BANK_SZ))) ? 1 : 0;
323 static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
325 struct pca953x_chip *chip = gpiochip_get_data(gc);
329 mutex_lock(&chip->i2c_lock);
331 reg_val = chip->reg_output[off / BANK_SZ]
332 | (1u << (off % BANK_SZ));
334 reg_val = chip->reg_output[off / BANK_SZ]
335 & ~(1u << (off % BANK_SZ));
337 switch (chip->chip_type) {
339 offset = PCA953X_OUTPUT;
342 offset = PCA957X_OUT;
345 ret = pca953x_write_single(chip, offset, reg_val, off);
349 chip->reg_output[off / BANK_SZ] = reg_val;
351 mutex_unlock(&chip->i2c_lock);
355 static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
356 unsigned long *mask, unsigned long *bits)
358 struct pca953x_chip *chip = gpiochip_get_data(gc);
359 u8 reg_val[MAX_BANK];
361 int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
364 switch (chip->chip_type) {
366 offset = PCA953X_OUTPUT;
369 offset = PCA957X_OUT;
373 memcpy(reg_val, chip->reg_output, NBANK(chip));
374 mutex_lock(&chip->i2c_lock);
375 for(bank=0; bank<NBANK(chip); bank++) {
376 unsigned bankmask = mask[bank / sizeof(*mask)] >>
377 ((bank % sizeof(*mask)) * 8);
379 unsigned bankval = bits[bank / sizeof(*bits)] >>
380 ((bank % sizeof(*bits)) * 8);
381 reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval;
384 ret = i2c_smbus_write_i2c_block_data(chip->client, offset << bank_shift, NBANK(chip), reg_val);
388 memcpy(chip->reg_output, reg_val, NBANK(chip));
390 mutex_unlock(&chip->i2c_lock);
393 static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
395 struct gpio_chip *gc;
397 gc = &chip->gpio_chip;
399 gc->direction_input = pca953x_gpio_direction_input;
400 gc->direction_output = pca953x_gpio_direction_output;
401 gc->get = pca953x_gpio_get_value;
402 gc->set = pca953x_gpio_set_value;
403 gc->set_multiple = pca953x_gpio_set_multiple;
404 gc->can_sleep = true;
406 gc->base = chip->gpio_start;
408 gc->label = chip->client->name;
409 gc->parent = &chip->client->dev;
410 gc->owner = THIS_MODULE;
411 gc->names = chip->names;
414 #ifdef CONFIG_GPIO_PCA953X_IRQ
415 static void pca953x_irq_mask(struct irq_data *d)
417 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
418 struct pca953x_chip *chip = gpiochip_get_data(gc);
420 chip->irq_mask[d->hwirq / BANK_SZ] &= ~(1 << (d->hwirq % BANK_SZ));
423 static void pca953x_irq_unmask(struct irq_data *d)
425 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
426 struct pca953x_chip *chip = gpiochip_get_data(gc);
428 chip->irq_mask[d->hwirq / BANK_SZ] |= 1 << (d->hwirq % BANK_SZ);
431 static void pca953x_irq_bus_lock(struct irq_data *d)
433 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
434 struct pca953x_chip *chip = gpiochip_get_data(gc);
436 mutex_lock(&chip->irq_lock);
439 static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
441 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
442 struct pca953x_chip *chip = gpiochip_get_data(gc);
445 u8 invert_irq_mask[MAX_BANK];
447 if (chip->driver_data & PCA_PCAL) {
448 /* Enable latch on interrupt-enabled inputs */
449 pca953x_write_regs(chip, PCAL953X_IN_LATCH, chip->irq_mask);
451 for (i = 0; i < NBANK(chip); i++)
452 invert_irq_mask[i] = ~chip->irq_mask[i];
454 /* Unmask enabled interrupts */
455 pca953x_write_regs(chip, PCAL953X_INT_MASK, invert_irq_mask);
458 /* Look for any newly setup interrupt */
459 for (i = 0; i < NBANK(chip); i++) {
460 new_irqs = chip->irq_trig_fall[i] | chip->irq_trig_raise[i];
461 new_irqs &= ~chip->reg_direction[i];
464 level = __ffs(new_irqs);
465 pca953x_gpio_direction_input(&chip->gpio_chip,
466 level + (BANK_SZ * i));
467 new_irqs &= ~(1 << level);
471 mutex_unlock(&chip->irq_lock);
474 static int pca953x_irq_set_type(struct irq_data *d, unsigned int type)
476 struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
477 struct pca953x_chip *chip = gpiochip_get_data(gc);
478 int bank_nb = d->hwirq / BANK_SZ;
479 u8 mask = 1 << (d->hwirq % BANK_SZ);
481 if (!(type & IRQ_TYPE_EDGE_BOTH)) {
482 dev_err(&chip->client->dev, "irq %d: unsupported type %d\n",
487 if (type & IRQ_TYPE_EDGE_FALLING)
488 chip->irq_trig_fall[bank_nb] |= mask;
490 chip->irq_trig_fall[bank_nb] &= ~mask;
492 if (type & IRQ_TYPE_EDGE_RISING)
493 chip->irq_trig_raise[bank_nb] |= mask;
495 chip->irq_trig_raise[bank_nb] &= ~mask;
500 static struct irq_chip pca953x_irq_chip = {
502 .irq_mask = pca953x_irq_mask,
503 .irq_unmask = pca953x_irq_unmask,
504 .irq_bus_lock = pca953x_irq_bus_lock,
505 .irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock,
506 .irq_set_type = pca953x_irq_set_type,
509 static bool pca953x_irq_pending(struct pca953x_chip *chip, u8 *pending)
511 u8 cur_stat[MAX_BANK];
512 u8 old_stat[MAX_BANK];
513 bool pending_seen = false;
514 bool trigger_seen = false;
515 u8 trigger[MAX_BANK];
516 int ret, i, offset = 0;
518 if (chip->driver_data & PCA_PCAL) {
519 /* Read the current interrupt status from the device */
520 ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, trigger);
524 /* Check latched inputs and clear interrupt status */
525 ret = pca953x_read_regs(chip, PCA953X_INPUT, cur_stat);
529 for (i = 0; i < NBANK(chip); i++) {
530 /* Apply filter for rising/falling edge selection */
531 pending[i] = (~cur_stat[i] & chip->irq_trig_fall[i]) |
532 (cur_stat[i] & chip->irq_trig_raise[i]);
533 pending[i] &= trigger[i];
541 switch (chip->chip_type) {
543 offset = PCA953X_INPUT;
549 ret = pca953x_read_regs(chip, offset, cur_stat);
553 /* Remove output pins from the equation */
554 for (i = 0; i < NBANK(chip); i++)
555 cur_stat[i] &= chip->reg_direction[i];
557 memcpy(old_stat, chip->irq_stat, NBANK(chip));
559 for (i = 0; i < NBANK(chip); i++) {
560 trigger[i] = (cur_stat[i] ^ old_stat[i]) & chip->irq_mask[i];
568 memcpy(chip->irq_stat, cur_stat, NBANK(chip));
570 for (i = 0; i < NBANK(chip); i++) {
571 pending[i] = (old_stat[i] & chip->irq_trig_fall[i]) |
572 (cur_stat[i] & chip->irq_trig_raise[i]);
573 pending[i] &= trigger[i];
581 static irqreturn_t pca953x_irq_handler(int irq, void *devid)
583 struct pca953x_chip *chip = devid;
584 u8 pending[MAX_BANK];
586 unsigned nhandled = 0;
589 if (!pca953x_irq_pending(chip, pending))
592 for (i = 0; i < NBANK(chip); i++) {
594 level = __ffs(pending[i]);
595 handle_nested_irq(irq_find_mapping(chip->gpio_chip.irqdomain,
596 level + (BANK_SZ * i)));
597 pending[i] &= ~(1 << level);
602 return (nhandled > 0) ? IRQ_HANDLED : IRQ_NONE;
605 static int pca953x_irq_setup(struct pca953x_chip *chip,
608 struct i2c_client *client = chip->client;
609 int ret, i, offset = 0;
611 if (client->irq && irq_base != -1
612 && (chip->driver_data & PCA_INT)) {
614 switch (chip->chip_type) {
616 offset = PCA953X_INPUT;
622 ret = pca953x_read_regs(chip, offset, chip->irq_stat);
627 * There is no way to know which GPIO line generated the
628 * interrupt. We have to rely on the previous read for
631 for (i = 0; i < NBANK(chip); i++)
632 chip->irq_stat[i] &= chip->reg_direction[i];
633 mutex_init(&chip->irq_lock);
635 ret = devm_request_threaded_irq(&client->dev,
639 IRQF_TRIGGER_LOW | IRQF_ONESHOT |
641 dev_name(&client->dev), chip);
643 dev_err(&client->dev, "failed to request irq %d\n",
648 ret = gpiochip_irqchip_add(&chip->gpio_chip,
654 dev_err(&client->dev,
655 "could not connect irqchip to gpiochip\n");
659 gpiochip_set_chained_irqchip(&chip->gpio_chip,
667 #else /* CONFIG_GPIO_PCA953X_IRQ */
668 static int pca953x_irq_setup(struct pca953x_chip *chip,
671 struct i2c_client *client = chip->client;
673 if (irq_base != -1 && (chip->driver_data & PCA_INT))
674 dev_warn(&client->dev, "interrupt support not compiled in\n");
680 static int device_pca953x_init(struct pca953x_chip *chip, u32 invert)
685 ret = pca953x_read_regs(chip, PCA953X_OUTPUT, chip->reg_output);
689 ret = pca953x_read_regs(chip, PCA953X_DIRECTION,
690 chip->reg_direction);
694 /* set platform specific polarity inversion */
696 memset(val, 0xFF, NBANK(chip));
698 memset(val, 0, NBANK(chip));
700 ret = pca953x_write_regs(chip, PCA953X_INVERT, val);
705 static int device_pca957x_init(struct pca953x_chip *chip, u32 invert)
710 ret = pca953x_read_regs(chip, PCA957X_OUT, chip->reg_output);
713 ret = pca953x_read_regs(chip, PCA957X_CFG, chip->reg_direction);
717 /* set platform specific polarity inversion */
719 memset(val, 0xFF, NBANK(chip));
721 memset(val, 0, NBANK(chip));
722 ret = pca953x_write_regs(chip, PCA957X_INVRT, val);
726 /* To enable register 6, 7 to control pull up and pull down */
727 memset(val, 0x02, NBANK(chip));
728 ret = pca953x_write_regs(chip, PCA957X_BKEN, val);
737 static const struct of_device_id pca953x_dt_ids[];
739 static int pca953x_probe(struct i2c_client *client,
740 const struct i2c_device_id *id)
742 struct pca953x_platform_data *pdata;
743 struct pca953x_chip *chip;
748 chip = devm_kzalloc(&client->dev,
749 sizeof(struct pca953x_chip), GFP_KERNEL);
753 pdata = dev_get_platdata(&client->dev);
755 irq_base = pdata->irq_base;
756 chip->gpio_start = pdata->gpio_base;
757 invert = pdata->invert;
758 chip->names = pdata->names;
760 chip->gpio_start = -1;
764 chip->client = client;
767 chip->driver_data = id->driver_data;
769 const struct acpi_device_id *id;
770 const struct of_device_id *match;
772 match = of_match_device(pca953x_dt_ids, &client->dev);
774 chip->driver_data = (int)(uintptr_t)match->data;
776 id = acpi_match_device(pca953x_acpi_ids, &client->dev);
780 chip->driver_data = id->driver_data;
784 chip->chip_type = PCA_CHIP_TYPE(chip->driver_data);
786 mutex_init(&chip->i2c_lock);
788 /* initialize cached registers from their original values.
789 * we can't share this chip with another i2c master.
791 pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
793 if (chip->chip_type == PCA953X_TYPE)
794 ret = device_pca953x_init(chip, invert);
796 ret = device_pca957x_init(chip, invert);
800 ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip);
804 ret = pca953x_irq_setup(chip, irq_base);
808 if (pdata && pdata->setup) {
809 ret = pdata->setup(client, chip->gpio_chip.base,
810 chip->gpio_chip.ngpio, pdata->context);
812 dev_warn(&client->dev, "setup failed, %d\n", ret);
815 i2c_set_clientdata(client, chip);
819 static int pca953x_remove(struct i2c_client *client)
821 struct pca953x_platform_data *pdata = dev_get_platdata(&client->dev);
822 struct pca953x_chip *chip = i2c_get_clientdata(client);
825 if (pdata && pdata->teardown) {
826 ret = pdata->teardown(client, chip->gpio_chip.base,
827 chip->gpio_chip.ngpio, pdata->context);
829 dev_err(&client->dev, "%s failed, %d\n",
838 /* convenience to stop overlong match-table lines */
839 #define OF_953X(__nrgpio, __int) (void *)(__nrgpio | PCA953X_TYPE | __int)
840 #define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int)
842 static const struct of_device_id pca953x_dt_ids[] = {
843 { .compatible = "nxp,pca9505", .data = OF_953X(40, PCA_INT), },
844 { .compatible = "nxp,pca9534", .data = OF_953X( 8, PCA_INT), },
845 { .compatible = "nxp,pca9535", .data = OF_953X(16, PCA_INT), },
846 { .compatible = "nxp,pca9536", .data = OF_953X( 4, 0), },
847 { .compatible = "nxp,pca9537", .data = OF_953X( 4, PCA_INT), },
848 { .compatible = "nxp,pca9538", .data = OF_953X( 8, PCA_INT), },
849 { .compatible = "nxp,pca9539", .data = OF_953X(16, PCA_INT), },
850 { .compatible = "nxp,pca9554", .data = OF_953X( 8, PCA_INT), },
851 { .compatible = "nxp,pca9555", .data = OF_953X(16, PCA_INT), },
852 { .compatible = "nxp,pca9556", .data = OF_953X( 8, 0), },
853 { .compatible = "nxp,pca9557", .data = OF_953X( 8, 0), },
854 { .compatible = "nxp,pca9574", .data = OF_957X( 8, PCA_INT), },
855 { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), },
856 { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), },
858 { .compatible = "maxim,max7310", .data = OF_953X( 8, 0), },
859 { .compatible = "maxim,max7312", .data = OF_953X(16, PCA_INT), },
860 { .compatible = "maxim,max7313", .data = OF_953X(16, PCA_INT), },
861 { .compatible = "maxim,max7315", .data = OF_953X( 8, PCA_INT), },
863 { .compatible = "ti,pca6107", .data = OF_953X( 8, PCA_INT), },
864 { .compatible = "ti,tca6408", .data = OF_953X( 8, PCA_INT), },
865 { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), },
866 { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), },
868 { .compatible = "onsemi,pca9654", .data = OF_953X( 8, PCA_INT), },
870 { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), },
874 MODULE_DEVICE_TABLE(of, pca953x_dt_ids);
876 static struct i2c_driver pca953x_driver = {
879 .of_match_table = pca953x_dt_ids,
880 .acpi_match_table = ACPI_PTR(pca953x_acpi_ids),
882 .probe = pca953x_probe,
883 .remove = pca953x_remove,
884 .id_table = pca953x_id,
887 static int __init pca953x_init(void)
889 return i2c_add_driver(&pca953x_driver);
891 /* register after i2c postcore initcall and before
892 * subsys initcalls that may rely on these GPIOs
894 subsys_initcall(pca953x_init);
896 static void __exit pca953x_exit(void)
898 i2c_del_driver(&pca953x_driver);
900 module_exit(pca953x_exit);
902 MODULE_AUTHOR("eric miao <eric.miao@marvell.com>");
903 MODULE_DESCRIPTION("GPIO expander driver for PCA953x");
904 MODULE_LICENSE("GPL");