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 <linux/of_platform.h>
22 #include <linux/acpi.h>
24 #define PCA953X_INPUT 0
25 #define PCA953X_OUTPUT 1
26 #define PCA953X_INVERT 2
27 #define PCA953X_DIRECTION 3
29 #define REG_ADDR_AI 0x80
32 #define PCA957X_INVRT 1
33 #define PCA957X_BKEN 2
34 #define PCA957X_PUPD 3
38 #define PCA957X_INTS 7
40 #define PCA_GPIO_MASK 0x00FF
41 #define PCA_INT 0x0100
42 #define PCA953X_TYPE 0x1000
43 #define PCA957X_TYPE 0x2000
44 #define PCA_TYPE_MASK 0xF000
46 #define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK)
48 static const struct i2c_device_id pca953x_id
[] = {
49 { "pca9505", 40 | PCA953X_TYPE
| PCA_INT
, },
50 { "pca9534", 8 | PCA953X_TYPE
| PCA_INT
, },
51 { "pca9535", 16 | PCA953X_TYPE
| PCA_INT
, },
52 { "pca9536", 4 | PCA953X_TYPE
, },
53 { "pca9537", 4 | PCA953X_TYPE
| PCA_INT
, },
54 { "pca9538", 8 | PCA953X_TYPE
| PCA_INT
, },
55 { "pca9539", 16 | PCA953X_TYPE
| PCA_INT
, },
56 { "pca9554", 8 | PCA953X_TYPE
| PCA_INT
, },
57 { "pca9555", 16 | PCA953X_TYPE
| PCA_INT
, },
58 { "pca9556", 8 | PCA953X_TYPE
, },
59 { "pca9557", 8 | PCA953X_TYPE
, },
60 { "pca9574", 8 | PCA957X_TYPE
| PCA_INT
, },
61 { "pca9575", 16 | PCA957X_TYPE
| PCA_INT
, },
62 { "pca9698", 40 | PCA953X_TYPE
, },
64 { "max7310", 8 | PCA953X_TYPE
, },
65 { "max7312", 16 | PCA953X_TYPE
| PCA_INT
, },
66 { "max7313", 16 | PCA953X_TYPE
| PCA_INT
, },
67 { "max7315", 8 | PCA953X_TYPE
| PCA_INT
, },
68 { "pca6107", 8 | PCA953X_TYPE
| PCA_INT
, },
69 { "tca6408", 8 | PCA953X_TYPE
| PCA_INT
, },
70 { "tca6416", 16 | PCA953X_TYPE
| PCA_INT
, },
71 { "tca6424", 24 | PCA953X_TYPE
| PCA_INT
, },
72 { "tca9539", 16 | PCA953X_TYPE
| PCA_INT
, },
73 { "xra1202", 8 | PCA953X_TYPE
},
76 MODULE_DEVICE_TABLE(i2c
, pca953x_id
);
78 static const struct acpi_device_id pca953x_acpi_ids
[] = {
79 { "INT3491", 16 | PCA953X_TYPE
| PCA_INT
, },
82 MODULE_DEVICE_TABLE(acpi
, pca953x_acpi_ids
);
87 #define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
91 u8 reg_output
[MAX_BANK
];
92 u8 reg_direction
[MAX_BANK
];
93 struct mutex i2c_lock
;
95 #ifdef CONFIG_GPIO_PCA953X_IRQ
96 struct mutex irq_lock
;
97 u8 irq_mask
[MAX_BANK
];
98 u8 irq_stat
[MAX_BANK
];
99 u8 irq_trig_raise
[MAX_BANK
];
100 u8 irq_trig_fall
[MAX_BANK
];
103 struct i2c_client
*client
;
104 struct gpio_chip gpio_chip
;
105 const char *const *names
;
107 unsigned long driver_data
;
110 static int pca953x_read_single(struct pca953x_chip
*chip
, int reg
, u32
*val
,
114 int bank_shift
= fls((chip
->gpio_chip
.ngpio
- 1) / BANK_SZ
);
115 int offset
= off
/ BANK_SZ
;
117 ret
= i2c_smbus_read_byte_data(chip
->client
,
118 (reg
<< bank_shift
) + offset
);
122 dev_err(&chip
->client
->dev
, "failed reading register\n");
129 static int pca953x_write_single(struct pca953x_chip
*chip
, int reg
, u32 val
,
133 int bank_shift
= fls((chip
->gpio_chip
.ngpio
- 1) / BANK_SZ
);
134 int offset
= off
/ BANK_SZ
;
136 ret
= i2c_smbus_write_byte_data(chip
->client
,
137 (reg
<< bank_shift
) + offset
, val
);
140 dev_err(&chip
->client
->dev
, "failed writing register\n");
147 static int pca953x_write_regs(struct pca953x_chip
*chip
, int reg
, u8
*val
)
151 if (chip
->gpio_chip
.ngpio
<= 8)
152 ret
= i2c_smbus_write_byte_data(chip
->client
, reg
, *val
);
153 else if (chip
->gpio_chip
.ngpio
>= 24) {
154 int bank_shift
= fls((chip
->gpio_chip
.ngpio
- 1) / BANK_SZ
);
155 ret
= i2c_smbus_write_i2c_block_data(chip
->client
,
156 (reg
<< bank_shift
) | REG_ADDR_AI
,
159 switch (chip
->chip_type
) {
161 ret
= i2c_smbus_write_word_data(chip
->client
,
162 reg
<< 1, (u16
) *val
);
165 ret
= i2c_smbus_write_byte_data(chip
->client
, reg
<< 1,
169 ret
= i2c_smbus_write_byte_data(chip
->client
,
177 dev_err(&chip
->client
->dev
, "failed writing register\n");
184 static int pca953x_read_regs(struct pca953x_chip
*chip
, int reg
, u8
*val
)
188 if (chip
->gpio_chip
.ngpio
<= 8) {
189 ret
= i2c_smbus_read_byte_data(chip
->client
, reg
);
191 } else if (chip
->gpio_chip
.ngpio
>= 24) {
192 int bank_shift
= fls((chip
->gpio_chip
.ngpio
- 1) / BANK_SZ
);
194 ret
= i2c_smbus_read_i2c_block_data(chip
->client
,
195 (reg
<< bank_shift
) | REG_ADDR_AI
,
198 ret
= i2c_smbus_read_word_data(chip
->client
, reg
<< 1);
199 val
[0] = (u16
)ret
& 0xFF;
200 val
[1] = (u16
)ret
>> 8;
203 dev_err(&chip
->client
->dev
, "failed reading register\n");
210 static int pca953x_gpio_direction_input(struct gpio_chip
*gc
, unsigned off
)
212 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
216 mutex_lock(&chip
->i2c_lock
);
217 reg_val
= chip
->reg_direction
[off
/ BANK_SZ
] | (1u << (off
% BANK_SZ
));
219 switch (chip
->chip_type
) {
221 offset
= PCA953X_DIRECTION
;
224 offset
= PCA957X_CFG
;
227 ret
= pca953x_write_single(chip
, offset
, reg_val
, off
);
231 chip
->reg_direction
[off
/ BANK_SZ
] = reg_val
;
234 mutex_unlock(&chip
->i2c_lock
);
238 static int pca953x_gpio_direction_output(struct gpio_chip
*gc
,
239 unsigned off
, int val
)
241 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
245 mutex_lock(&chip
->i2c_lock
);
246 /* set output level */
248 reg_val
= chip
->reg_output
[off
/ BANK_SZ
]
249 | (1u << (off
% BANK_SZ
));
251 reg_val
= chip
->reg_output
[off
/ BANK_SZ
]
252 & ~(1u << (off
% BANK_SZ
));
254 switch (chip
->chip_type
) {
256 offset
= PCA953X_OUTPUT
;
259 offset
= PCA957X_OUT
;
262 ret
= pca953x_write_single(chip
, offset
, reg_val
, off
);
266 chip
->reg_output
[off
/ BANK_SZ
] = reg_val
;
269 reg_val
= chip
->reg_direction
[off
/ BANK_SZ
] & ~(1u << (off
% BANK_SZ
));
270 switch (chip
->chip_type
) {
272 offset
= PCA953X_DIRECTION
;
275 offset
= PCA957X_CFG
;
278 ret
= pca953x_write_single(chip
, offset
, reg_val
, off
);
282 chip
->reg_direction
[off
/ BANK_SZ
] = reg_val
;
285 mutex_unlock(&chip
->i2c_lock
);
289 static int pca953x_gpio_get_value(struct gpio_chip
*gc
, unsigned off
)
291 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
295 mutex_lock(&chip
->i2c_lock
);
296 switch (chip
->chip_type
) {
298 offset
= PCA953X_INPUT
;
304 ret
= pca953x_read_single(chip
, offset
, ®_val
, off
);
305 mutex_unlock(&chip
->i2c_lock
);
307 /* NOTE: diagnostic already emitted; that's all we should
308 * do unless gpio_*_value_cansleep() calls become different
309 * from their nonsleeping siblings (and report faults).
314 return (reg_val
& (1u << (off
% BANK_SZ
))) ? 1 : 0;
317 static void pca953x_gpio_set_value(struct gpio_chip
*gc
, unsigned off
, int val
)
319 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
323 mutex_lock(&chip
->i2c_lock
);
325 reg_val
= chip
->reg_output
[off
/ BANK_SZ
]
326 | (1u << (off
% BANK_SZ
));
328 reg_val
= chip
->reg_output
[off
/ BANK_SZ
]
329 & ~(1u << (off
% BANK_SZ
));
331 switch (chip
->chip_type
) {
333 offset
= PCA953X_OUTPUT
;
336 offset
= PCA957X_OUT
;
339 ret
= pca953x_write_single(chip
, offset
, reg_val
, off
);
343 chip
->reg_output
[off
/ BANK_SZ
] = reg_val
;
345 mutex_unlock(&chip
->i2c_lock
);
349 static void pca953x_gpio_set_multiple(struct gpio_chip
*gc
,
350 unsigned long *mask
, unsigned long *bits
)
352 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
353 u8 reg_val
[MAX_BANK
];
355 int bank_shift
= fls((chip
->gpio_chip
.ngpio
- 1) / BANK_SZ
);
358 switch (chip
->chip_type
) {
360 offset
= PCA953X_OUTPUT
;
363 offset
= PCA957X_OUT
;
367 memcpy(reg_val
, chip
->reg_output
, NBANK(chip
));
368 mutex_lock(&chip
->i2c_lock
);
369 for(bank
=0; bank
<NBANK(chip
); bank
++) {
370 unsigned bankmask
= mask
[bank
/4] >> ((bank
% 4) * 8);
372 unsigned bankval
= bits
[bank
/4] >> ((bank
% 4) * 8);
373 reg_val
[bank
] = (reg_val
[bank
] & ~bankmask
) | bankval
;
376 ret
= i2c_smbus_write_i2c_block_data(chip
->client
, offset
<< bank_shift
, NBANK(chip
), reg_val
);
380 memcpy(chip
->reg_output
, reg_val
, NBANK(chip
));
382 mutex_unlock(&chip
->i2c_lock
);
385 static void pca953x_setup_gpio(struct pca953x_chip
*chip
, int gpios
)
387 struct gpio_chip
*gc
;
389 gc
= &chip
->gpio_chip
;
391 gc
->direction_input
= pca953x_gpio_direction_input
;
392 gc
->direction_output
= pca953x_gpio_direction_output
;
393 gc
->get
= pca953x_gpio_get_value
;
394 gc
->set
= pca953x_gpio_set_value
;
395 gc
->set_multiple
= pca953x_gpio_set_multiple
;
396 gc
->can_sleep
= true;
398 gc
->base
= chip
->gpio_start
;
400 gc
->label
= chip
->client
->name
;
401 gc
->parent
= &chip
->client
->dev
;
402 gc
->owner
= THIS_MODULE
;
403 gc
->names
= chip
->names
;
406 #ifdef CONFIG_GPIO_PCA953X_IRQ
407 static void pca953x_irq_mask(struct irq_data
*d
)
409 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
410 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
412 chip
->irq_mask
[d
->hwirq
/ BANK_SZ
] &= ~(1 << (d
->hwirq
% BANK_SZ
));
415 static void pca953x_irq_unmask(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_bus_lock(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 mutex_lock(&chip
->irq_lock
);
431 static void pca953x_irq_bus_sync_unlock(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
);
438 /* Look for any newly setup interrupt */
439 for (i
= 0; i
< NBANK(chip
); i
++) {
440 new_irqs
= chip
->irq_trig_fall
[i
] | chip
->irq_trig_raise
[i
];
441 new_irqs
&= ~chip
->reg_direction
[i
];
444 level
= __ffs(new_irqs
);
445 pca953x_gpio_direction_input(&chip
->gpio_chip
,
446 level
+ (BANK_SZ
* i
));
447 new_irqs
&= ~(1 << level
);
451 mutex_unlock(&chip
->irq_lock
);
454 static int pca953x_irq_set_type(struct irq_data
*d
, unsigned int type
)
456 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
457 struct pca953x_chip
*chip
= gpiochip_get_data(gc
);
458 int bank_nb
= d
->hwirq
/ BANK_SZ
;
459 u8 mask
= 1 << (d
->hwirq
% BANK_SZ
);
461 if (!(type
& IRQ_TYPE_EDGE_BOTH
)) {
462 dev_err(&chip
->client
->dev
, "irq %d: unsupported type %d\n",
467 if (type
& IRQ_TYPE_EDGE_FALLING
)
468 chip
->irq_trig_fall
[bank_nb
] |= mask
;
470 chip
->irq_trig_fall
[bank_nb
] &= ~mask
;
472 if (type
& IRQ_TYPE_EDGE_RISING
)
473 chip
->irq_trig_raise
[bank_nb
] |= mask
;
475 chip
->irq_trig_raise
[bank_nb
] &= ~mask
;
480 static struct irq_chip pca953x_irq_chip
= {
482 .irq_mask
= pca953x_irq_mask
,
483 .irq_unmask
= pca953x_irq_unmask
,
484 .irq_bus_lock
= pca953x_irq_bus_lock
,
485 .irq_bus_sync_unlock
= pca953x_irq_bus_sync_unlock
,
486 .irq_set_type
= pca953x_irq_set_type
,
489 static bool pca953x_irq_pending(struct pca953x_chip
*chip
, u8
*pending
)
491 u8 cur_stat
[MAX_BANK
];
492 u8 old_stat
[MAX_BANK
];
493 bool pending_seen
= false;
494 bool trigger_seen
= false;
495 u8 trigger
[MAX_BANK
];
496 int ret
, i
, offset
= 0;
498 switch (chip
->chip_type
) {
500 offset
= PCA953X_INPUT
;
506 ret
= pca953x_read_regs(chip
, offset
, cur_stat
);
510 /* Remove output pins from the equation */
511 for (i
= 0; i
< NBANK(chip
); i
++)
512 cur_stat
[i
] &= chip
->reg_direction
[i
];
514 memcpy(old_stat
, chip
->irq_stat
, NBANK(chip
));
516 for (i
= 0; i
< NBANK(chip
); i
++) {
517 trigger
[i
] = (cur_stat
[i
] ^ old_stat
[i
]) & chip
->irq_mask
[i
];
525 memcpy(chip
->irq_stat
, cur_stat
, NBANK(chip
));
527 for (i
= 0; i
< NBANK(chip
); i
++) {
528 pending
[i
] = (old_stat
[i
] & chip
->irq_trig_fall
[i
]) |
529 (cur_stat
[i
] & chip
->irq_trig_raise
[i
]);
530 pending
[i
] &= trigger
[i
];
538 static irqreturn_t
pca953x_irq_handler(int irq
, void *devid
)
540 struct pca953x_chip
*chip
= devid
;
541 u8 pending
[MAX_BANK
];
543 unsigned nhandled
= 0;
546 if (!pca953x_irq_pending(chip
, pending
))
549 for (i
= 0; i
< NBANK(chip
); i
++) {
551 level
= __ffs(pending
[i
]);
552 handle_nested_irq(irq_find_mapping(chip
->gpio_chip
.irqdomain
,
553 level
+ (BANK_SZ
* i
)));
554 pending
[i
] &= ~(1 << level
);
559 return (nhandled
> 0) ? IRQ_HANDLED
: IRQ_NONE
;
562 static int pca953x_irq_setup(struct pca953x_chip
*chip
,
565 struct i2c_client
*client
= chip
->client
;
566 int ret
, i
, offset
= 0;
568 if (client
->irq
&& irq_base
!= -1
569 && (chip
->driver_data
& PCA_INT
)) {
571 switch (chip
->chip_type
) {
573 offset
= PCA953X_INPUT
;
579 ret
= pca953x_read_regs(chip
, offset
, chip
->irq_stat
);
584 * There is no way to know which GPIO line generated the
585 * interrupt. We have to rely on the previous read for
588 for (i
= 0; i
< NBANK(chip
); i
++)
589 chip
->irq_stat
[i
] &= chip
->reg_direction
[i
];
590 mutex_init(&chip
->irq_lock
);
592 ret
= devm_request_threaded_irq(&client
->dev
,
596 IRQF_TRIGGER_LOW
| IRQF_ONESHOT
|
598 dev_name(&client
->dev
), chip
);
600 dev_err(&client
->dev
, "failed to request irq %d\n",
605 ret
= gpiochip_irqchip_add(&chip
->gpio_chip
,
611 dev_err(&client
->dev
,
612 "could not connect irqchip to gpiochip\n");
616 gpiochip_set_chained_irqchip(&chip
->gpio_chip
,
624 #else /* CONFIG_GPIO_PCA953X_IRQ */
625 static int pca953x_irq_setup(struct pca953x_chip
*chip
,
628 struct i2c_client
*client
= chip
->client
;
630 if (irq_base
!= -1 && (chip
->driver_data
& PCA_INT
))
631 dev_warn(&client
->dev
, "interrupt support not compiled in\n");
637 static int device_pca953x_init(struct pca953x_chip
*chip
, u32 invert
)
642 ret
= pca953x_read_regs(chip
, PCA953X_OUTPUT
, chip
->reg_output
);
646 ret
= pca953x_read_regs(chip
, PCA953X_DIRECTION
,
647 chip
->reg_direction
);
651 /* set platform specific polarity inversion */
653 memset(val
, 0xFF, NBANK(chip
));
655 memset(val
, 0, NBANK(chip
));
657 ret
= pca953x_write_regs(chip
, PCA953X_INVERT
, val
);
662 static int device_pca957x_init(struct pca953x_chip
*chip
, u32 invert
)
667 ret
= pca953x_read_regs(chip
, PCA957X_OUT
, chip
->reg_output
);
670 ret
= pca953x_read_regs(chip
, PCA957X_CFG
, chip
->reg_direction
);
674 /* set platform specific polarity inversion */
676 memset(val
, 0xFF, NBANK(chip
));
678 memset(val
, 0, NBANK(chip
));
679 ret
= pca953x_write_regs(chip
, PCA957X_INVRT
, val
);
683 /* To enable register 6, 7 to control pull up and pull down */
684 memset(val
, 0x02, NBANK(chip
));
685 ret
= pca953x_write_regs(chip
, PCA957X_BKEN
, val
);
694 static const struct of_device_id pca953x_dt_ids
[];
696 static int pca953x_probe(struct i2c_client
*client
,
697 const struct i2c_device_id
*id
)
699 struct pca953x_platform_data
*pdata
;
700 struct pca953x_chip
*chip
;
705 chip
= devm_kzalloc(&client
->dev
,
706 sizeof(struct pca953x_chip
), GFP_KERNEL
);
710 pdata
= dev_get_platdata(&client
->dev
);
712 irq_base
= pdata
->irq_base
;
713 chip
->gpio_start
= pdata
->gpio_base
;
714 invert
= pdata
->invert
;
715 chip
->names
= pdata
->names
;
717 chip
->gpio_start
= -1;
721 chip
->client
= client
;
724 chip
->driver_data
= id
->driver_data
;
726 const struct acpi_device_id
*id
;
727 const struct of_device_id
*match
;
729 match
= of_match_device(pca953x_dt_ids
, &client
->dev
);
731 chip
->driver_data
= (int)(uintptr_t)match
->data
;
733 id
= acpi_match_device(pca953x_acpi_ids
, &client
->dev
);
737 chip
->driver_data
= id
->driver_data
;
741 chip
->chip_type
= PCA_CHIP_TYPE(chip
->driver_data
);
743 mutex_init(&chip
->i2c_lock
);
745 /* initialize cached registers from their original values.
746 * we can't share this chip with another i2c master.
748 pca953x_setup_gpio(chip
, chip
->driver_data
& PCA_GPIO_MASK
);
750 if (chip
->chip_type
== PCA953X_TYPE
)
751 ret
= device_pca953x_init(chip
, invert
);
753 ret
= device_pca957x_init(chip
, invert
);
757 ret
= gpiochip_add_data(&chip
->gpio_chip
, chip
);
761 ret
= pca953x_irq_setup(chip
, irq_base
);
765 if (pdata
&& pdata
->setup
) {
766 ret
= pdata
->setup(client
, chip
->gpio_chip
.base
,
767 chip
->gpio_chip
.ngpio
, pdata
->context
);
769 dev_warn(&client
->dev
, "setup failed, %d\n", ret
);
772 i2c_set_clientdata(client
, chip
);
776 static int pca953x_remove(struct i2c_client
*client
)
778 struct pca953x_platform_data
*pdata
= dev_get_platdata(&client
->dev
);
779 struct pca953x_chip
*chip
= i2c_get_clientdata(client
);
782 if (pdata
&& pdata
->teardown
) {
783 ret
= pdata
->teardown(client
, chip
->gpio_chip
.base
,
784 chip
->gpio_chip
.ngpio
, pdata
->context
);
786 dev_err(&client
->dev
, "%s failed, %d\n",
792 gpiochip_remove(&chip
->gpio_chip
);
797 /* convenience to stop overlong match-table lines */
798 #define OF_953X(__nrgpio, __int) (void *)(__nrgpio | PCA953X_TYPE | __int)
799 #define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int)
801 static const struct of_device_id pca953x_dt_ids
[] = {
802 { .compatible
= "nxp,pca9505", .data
= OF_953X(40, PCA_INT
), },
803 { .compatible
= "nxp,pca9534", .data
= OF_953X( 8, PCA_INT
), },
804 { .compatible
= "nxp,pca9535", .data
= OF_953X(16, PCA_INT
), },
805 { .compatible
= "nxp,pca9536", .data
= OF_953X( 4, 0), },
806 { .compatible
= "nxp,pca9537", .data
= OF_953X( 4, PCA_INT
), },
807 { .compatible
= "nxp,pca9538", .data
= OF_953X( 8, PCA_INT
), },
808 { .compatible
= "nxp,pca9539", .data
= OF_953X(16, PCA_INT
), },
809 { .compatible
= "nxp,pca9554", .data
= OF_953X( 8, PCA_INT
), },
810 { .compatible
= "nxp,pca9555", .data
= OF_953X(16, PCA_INT
), },
811 { .compatible
= "nxp,pca9556", .data
= OF_953X( 8, 0), },
812 { .compatible
= "nxp,pca9557", .data
= OF_953X( 8, 0), },
813 { .compatible
= "nxp,pca9574", .data
= OF_957X( 8, PCA_INT
), },
814 { .compatible
= "nxp,pca9575", .data
= OF_957X(16, PCA_INT
), },
815 { .compatible
= "nxp,pca9698", .data
= OF_953X(40, 0), },
817 { .compatible
= "maxim,max7310", .data
= OF_953X( 8, 0), },
818 { .compatible
= "maxim,max7312", .data
= OF_953X(16, PCA_INT
), },
819 { .compatible
= "maxim,max7313", .data
= OF_953X(16, PCA_INT
), },
820 { .compatible
= "maxim,max7315", .data
= OF_953X( 8, PCA_INT
), },
822 { .compatible
= "ti,pca6107", .data
= OF_953X( 8, PCA_INT
), },
823 { .compatible
= "ti,tca6408", .data
= OF_953X( 8, PCA_INT
), },
824 { .compatible
= "ti,tca6416", .data
= OF_953X(16, PCA_INT
), },
825 { .compatible
= "ti,tca6424", .data
= OF_953X(24, PCA_INT
), },
827 { .compatible
= "onsemi,pca9654", .data
= OF_953X( 8, PCA_INT
), },
829 { .compatible
= "exar,xra1202", .data
= OF_953X( 8, 0), },
833 MODULE_DEVICE_TABLE(of
, pca953x_dt_ids
);
835 static struct i2c_driver pca953x_driver
= {
838 .of_match_table
= pca953x_dt_ids
,
839 .acpi_match_table
= ACPI_PTR(pca953x_acpi_ids
),
841 .probe
= pca953x_probe
,
842 .remove
= pca953x_remove
,
843 .id_table
= pca953x_id
,
846 static int __init
pca953x_init(void)
848 return i2c_add_driver(&pca953x_driver
);
850 /* register after i2c postcore initcall and before
851 * subsys initcalls that may rely on these GPIOs
853 subsys_initcall(pca953x_init
);
855 static void __exit
pca953x_exit(void)
857 i2c_del_driver(&pca953x_driver
);
859 module_exit(pca953x_exit
);
861 MODULE_AUTHOR("eric miao <eric.miao@marvell.com>");
862 MODULE_DESCRIPTION("GPIO expander driver for PCA953x");
863 MODULE_LICENSE("GPL");