1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (C) 2015-2017 Broadcom
4 #include <linux/bitops.h>
5 #include <linux/gpio/driver.h>
7 #include <linux/module.h>
8 #include <linux/irqdomain.h>
9 #include <linux/irqchip/chained_irq.h>
10 #include <linux/interrupt.h>
11 #include <linux/platform_device.h>
22 NUMBER_OF_GIO_REGISTERS
25 #define GIO_BANK_SIZE (NUMBER_OF_GIO_REGISTERS * sizeof(u32))
26 #define GIO_BANK_OFF(bank, off) (((bank) * GIO_BANK_SIZE) + (off * sizeof(u32)))
27 #define GIO_ODEN(bank) GIO_BANK_OFF(bank, GIO_REG_ODEN)
28 #define GIO_DATA(bank) GIO_BANK_OFF(bank, GIO_REG_DATA)
29 #define GIO_IODIR(bank) GIO_BANK_OFF(bank, GIO_REG_IODIR)
30 #define GIO_EC(bank) GIO_BANK_OFF(bank, GIO_REG_EC)
31 #define GIO_EI(bank) GIO_BANK_OFF(bank, GIO_REG_EI)
32 #define GIO_MASK(bank) GIO_BANK_OFF(bank, GIO_REG_MASK)
33 #define GIO_LEVEL(bank) GIO_BANK_OFF(bank, GIO_REG_LEVEL)
34 #define GIO_STAT(bank) GIO_BANK_OFF(bank, GIO_REG_STAT)
36 struct brcmstb_gpio_bank
{
37 struct list_head node
;
40 struct brcmstb_gpio_priv
*parent_priv
;
43 u32 saved_regs
[GIO_REG_STAT
]; /* Don't save and restore GIO_REG_STAT */
46 struct brcmstb_gpio_priv
{
47 struct list_head bank_list
;
48 void __iomem
*reg_base
;
49 struct platform_device
*pdev
;
50 struct irq_domain
*irq_domain
;
51 struct irq_chip irq_chip
;
57 #define MAX_GPIO_PER_BANK 32
58 #define GPIO_BANK(gpio) ((gpio) >> 5)
59 /* assumes MAX_GPIO_PER_BANK is a multiple of 2 */
60 #define GPIO_BIT(gpio) ((gpio) & (MAX_GPIO_PER_BANK - 1))
62 static inline struct brcmstb_gpio_priv
*
63 brcmstb_gpio_gc_to_priv(struct gpio_chip
*gc
)
65 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
66 return bank
->parent_priv
;
70 __brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank
*bank
)
72 void __iomem
*reg_base
= bank
->parent_priv
->reg_base
;
74 return bank
->gc
.read_reg(reg_base
+ GIO_STAT(bank
->id
)) &
75 bank
->gc
.read_reg(reg_base
+ GIO_MASK(bank
->id
));
79 brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank
*bank
)
84 raw_spin_lock_irqsave(&bank
->gc
.bgpio_lock
, flags
);
85 status
= __brcmstb_gpio_get_active_irqs(bank
);
86 raw_spin_unlock_irqrestore(&bank
->gc
.bgpio_lock
, flags
);
91 static int brcmstb_gpio_hwirq_to_offset(irq_hw_number_t hwirq
,
92 struct brcmstb_gpio_bank
*bank
)
94 return hwirq
- bank
->gc
.offset
;
97 static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank
*bank
,
98 unsigned int hwirq
, bool enable
)
100 struct gpio_chip
*gc
= &bank
->gc
;
101 struct brcmstb_gpio_priv
*priv
= bank
->parent_priv
;
102 u32 mask
= BIT(brcmstb_gpio_hwirq_to_offset(hwirq
, bank
));
106 raw_spin_lock_irqsave(&gc
->bgpio_lock
, flags
);
107 imask
= gc
->read_reg(priv
->reg_base
+ GIO_MASK(bank
->id
));
112 gc
->write_reg(priv
->reg_base
+ GIO_MASK(bank
->id
), imask
);
113 raw_spin_unlock_irqrestore(&gc
->bgpio_lock
, flags
);
116 static int brcmstb_gpio_to_irq(struct gpio_chip
*gc
, unsigned offset
)
118 struct brcmstb_gpio_priv
*priv
= brcmstb_gpio_gc_to_priv(gc
);
119 /* gc_offset is relative to this gpio_chip; want real offset */
120 int hwirq
= offset
+ gc
->offset
;
122 if (hwirq
>= priv
->num_gpios
)
124 return irq_create_mapping(priv
->irq_domain
, hwirq
);
127 /* -------------------- IRQ chip functions -------------------- */
129 static void brcmstb_gpio_irq_mask(struct irq_data
*d
)
131 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
132 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
134 brcmstb_gpio_set_imask(bank
, d
->hwirq
, false);
137 static void brcmstb_gpio_irq_unmask(struct irq_data
*d
)
139 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
140 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
142 brcmstb_gpio_set_imask(bank
, d
->hwirq
, true);
145 static void brcmstb_gpio_irq_ack(struct irq_data
*d
)
147 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
148 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
149 struct brcmstb_gpio_priv
*priv
= bank
->parent_priv
;
150 u32 mask
= BIT(brcmstb_gpio_hwirq_to_offset(d
->hwirq
, bank
));
152 gc
->write_reg(priv
->reg_base
+ GIO_STAT(bank
->id
), mask
);
155 static int brcmstb_gpio_irq_set_type(struct irq_data
*d
, unsigned int type
)
157 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
158 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
159 struct brcmstb_gpio_priv
*priv
= bank
->parent_priv
;
160 u32 mask
= BIT(brcmstb_gpio_hwirq_to_offset(d
->hwirq
, bank
));
161 u32 edge_insensitive
, iedge_insensitive
;
162 u32 edge_config
, iedge_config
;
167 case IRQ_TYPE_LEVEL_LOW
:
170 edge_insensitive
= 0;
172 case IRQ_TYPE_LEVEL_HIGH
:
175 edge_insensitive
= 0;
177 case IRQ_TYPE_EDGE_FALLING
:
180 edge_insensitive
= 0;
182 case IRQ_TYPE_EDGE_RISING
:
185 edge_insensitive
= 0;
187 case IRQ_TYPE_EDGE_BOTH
:
189 edge_config
= 0; /* don't care, but want known value */
190 edge_insensitive
= mask
;
196 raw_spin_lock_irqsave(&bank
->gc
.bgpio_lock
, flags
);
198 iedge_config
= bank
->gc
.read_reg(priv
->reg_base
+
199 GIO_EC(bank
->id
)) & ~mask
;
200 iedge_insensitive
= bank
->gc
.read_reg(priv
->reg_base
+
201 GIO_EI(bank
->id
)) & ~mask
;
202 ilevel
= bank
->gc
.read_reg(priv
->reg_base
+
203 GIO_LEVEL(bank
->id
)) & ~mask
;
205 bank
->gc
.write_reg(priv
->reg_base
+ GIO_EC(bank
->id
),
206 iedge_config
| edge_config
);
207 bank
->gc
.write_reg(priv
->reg_base
+ GIO_EI(bank
->id
),
208 iedge_insensitive
| edge_insensitive
);
209 bank
->gc
.write_reg(priv
->reg_base
+ GIO_LEVEL(bank
->id
),
212 raw_spin_unlock_irqrestore(&bank
->gc
.bgpio_lock
, flags
);
216 static int brcmstb_gpio_priv_set_wake(struct brcmstb_gpio_priv
*priv
,
222 ret
= enable_irq_wake(priv
->parent_wake_irq
);
224 ret
= disable_irq_wake(priv
->parent_wake_irq
);
226 dev_err(&priv
->pdev
->dev
, "failed to %s wake-up interrupt\n",
227 enable
? "enable" : "disable");
231 static int brcmstb_gpio_irq_set_wake(struct irq_data
*d
, unsigned int enable
)
233 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
234 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
235 struct brcmstb_gpio_priv
*priv
= bank
->parent_priv
;
236 u32 mask
= BIT(brcmstb_gpio_hwirq_to_offset(d
->hwirq
, bank
));
239 * Do not do anything specific for now, suspend/resume callbacks will
240 * configure the interrupt mask appropriately
243 bank
->wake_active
|= mask
;
245 bank
->wake_active
&= ~mask
;
247 return brcmstb_gpio_priv_set_wake(priv
, enable
);
250 static irqreturn_t
brcmstb_gpio_wake_irq_handler(int irq
, void *data
)
252 struct brcmstb_gpio_priv
*priv
= data
;
254 if (!priv
|| irq
!= priv
->parent_wake_irq
)
261 static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank
*bank
)
263 struct brcmstb_gpio_priv
*priv
= bank
->parent_priv
;
264 struct irq_domain
*domain
= priv
->irq_domain
;
265 int hwbase
= bank
->gc
.offset
;
266 unsigned long status
;
268 while ((status
= brcmstb_gpio_get_active_irqs(bank
))) {
271 for_each_set_bit(offset
, &status
, 32) {
272 if (offset
>= bank
->width
)
273 dev_warn(&priv
->pdev
->dev
,
274 "IRQ for invalid GPIO (bank=%d, offset=%d)\n",
276 generic_handle_domain_irq(domain
, hwbase
+ offset
);
281 /* Each UPG GIO block has one IRQ for all banks */
282 static void brcmstb_gpio_irq_handler(struct irq_desc
*desc
)
284 struct brcmstb_gpio_priv
*priv
= irq_desc_get_handler_data(desc
);
285 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
286 struct brcmstb_gpio_bank
*bank
;
288 /* Interrupts weren't properly cleared during probe */
289 BUG_ON(!priv
|| !chip
);
291 chained_irq_enter(chip
, desc
);
292 list_for_each_entry(bank
, &priv
->bank_list
, node
)
293 brcmstb_gpio_irq_bank_handler(bank
);
294 chained_irq_exit(chip
, desc
);
297 static struct brcmstb_gpio_bank
*brcmstb_gpio_hwirq_to_bank(
298 struct brcmstb_gpio_priv
*priv
, irq_hw_number_t hwirq
)
300 struct brcmstb_gpio_bank
*bank
;
303 /* banks are in descending order */
304 list_for_each_entry_reverse(bank
, &priv
->bank_list
, node
) {
313 * This lock class tells lockdep that GPIO irqs are in a different
314 * category than their parents, so it won't report false recursion.
316 static struct lock_class_key brcmstb_gpio_irq_lock_class
;
317 static struct lock_class_key brcmstb_gpio_irq_request_class
;
320 static int brcmstb_gpio_irq_map(struct irq_domain
*d
, unsigned int irq
,
321 irq_hw_number_t hwirq
)
323 struct brcmstb_gpio_priv
*priv
= d
->host_data
;
324 struct brcmstb_gpio_bank
*bank
=
325 brcmstb_gpio_hwirq_to_bank(priv
, hwirq
);
326 struct platform_device
*pdev
= priv
->pdev
;
332 dev_dbg(&pdev
->dev
, "Mapping irq %d for gpio line %d (bank %d)\n",
333 irq
, (int)hwirq
, bank
->id
);
334 ret
= irq_set_chip_data(irq
, &bank
->gc
);
337 irq_set_lockdep_class(irq
, &brcmstb_gpio_irq_lock_class
,
338 &brcmstb_gpio_irq_request_class
);
339 irq_set_chip_and_handler(irq
, &priv
->irq_chip
, handle_level_irq
);
340 irq_set_noprobe(irq
);
344 static void brcmstb_gpio_irq_unmap(struct irq_domain
*d
, unsigned int irq
)
346 irq_set_chip_and_handler(irq
, NULL
, NULL
);
347 irq_set_chip_data(irq
, NULL
);
350 static const struct irq_domain_ops brcmstb_gpio_irq_domain_ops
= {
351 .map
= brcmstb_gpio_irq_map
,
352 .unmap
= brcmstb_gpio_irq_unmap
,
353 .xlate
= irq_domain_xlate_twocell
,
356 /* Make sure that the number of banks matches up between properties */
357 static int brcmstb_gpio_sanity_check_banks(struct device
*dev
,
358 struct device_node
*np
, struct resource
*res
)
360 int res_num_banks
= resource_size(res
) / GIO_BANK_SIZE
;
362 of_property_count_u32_elems(np
, "brcm,gpio-bank-widths");
364 if (res_num_banks
!= num_banks
) {
365 dev_err(dev
, "Mismatch in banks: res had %d, bank-widths had %d\n",
366 res_num_banks
, num_banks
);
373 static void brcmstb_gpio_remove(struct platform_device
*pdev
)
375 struct brcmstb_gpio_priv
*priv
= platform_get_drvdata(pdev
);
376 struct brcmstb_gpio_bank
*bank
;
379 if (priv
->parent_irq
> 0)
380 irq_set_chained_handler_and_data(priv
->parent_irq
, NULL
, NULL
);
382 /* Remove all IRQ mappings and delete the domain */
383 if (priv
->irq_domain
) {
384 for (offset
= 0; offset
< priv
->num_gpios
; offset
++) {
385 virq
= irq_find_mapping(priv
->irq_domain
, offset
);
386 irq_dispose_mapping(virq
);
388 irq_domain_remove(priv
->irq_domain
);
392 * You can lose return values below, but we report all errors, and it's
393 * more important to actually perform all of the steps.
395 list_for_each_entry(bank
, &priv
->bank_list
, node
)
396 gpiochip_remove(&bank
->gc
);
399 static int brcmstb_gpio_of_xlate(struct gpio_chip
*gc
,
400 const struct of_phandle_args
*gpiospec
, u32
*flags
)
402 struct brcmstb_gpio_priv
*priv
= brcmstb_gpio_gc_to_priv(gc
);
403 struct brcmstb_gpio_bank
*bank
= gpiochip_get_data(gc
);
406 if (gc
->of_gpio_n_cells
!= 2) {
411 if (WARN_ON(gpiospec
->args_count
< gc
->of_gpio_n_cells
))
414 offset
= gpiospec
->args
[0] - bank
->gc
.offset
;
415 if (offset
>= gc
->ngpio
|| offset
< 0)
418 if (unlikely(offset
>= bank
->width
)) {
419 dev_warn_ratelimited(&priv
->pdev
->dev
,
420 "Received request for invalid GPIO offset %d\n",
425 *flags
= gpiospec
->args
[1];
430 /* priv->parent_irq and priv->num_gpios must be set before calling */
431 static int brcmstb_gpio_irq_setup(struct platform_device
*pdev
,
432 struct brcmstb_gpio_priv
*priv
)
434 struct device
*dev
= &pdev
->dev
;
435 struct device_node
*np
= dev
->of_node
;
439 irq_domain_add_linear(np
, priv
->num_gpios
,
440 &brcmstb_gpio_irq_domain_ops
,
442 if (!priv
->irq_domain
) {
443 dev_err(dev
, "Couldn't allocate IRQ domain\n");
447 if (of_property_read_bool(np
, "wakeup-source")) {
448 priv
->parent_wake_irq
= platform_get_irq(pdev
, 1);
449 if (priv
->parent_wake_irq
< 0) {
450 priv
->parent_wake_irq
= 0;
452 "Couldn't get wake IRQ - GPIOs will not be able to wake from sleep");
455 * Set wakeup capability so we can process boot-time
456 * "wakeups" (e.g., from S5 cold boot)
458 device_set_wakeup_capable(dev
, true);
459 device_wakeup_enable(dev
);
460 err
= devm_request_irq(dev
, priv
->parent_wake_irq
,
461 brcmstb_gpio_wake_irq_handler
,
463 "brcmstb-gpio-wake", priv
);
466 dev_err(dev
, "Couldn't request wake IRQ");
467 goto out_free_domain
;
472 priv
->irq_chip
.name
= dev_name(dev
);
473 priv
->irq_chip
.irq_disable
= brcmstb_gpio_irq_mask
;
474 priv
->irq_chip
.irq_mask
= brcmstb_gpio_irq_mask
;
475 priv
->irq_chip
.irq_unmask
= brcmstb_gpio_irq_unmask
;
476 priv
->irq_chip
.irq_ack
= brcmstb_gpio_irq_ack
;
477 priv
->irq_chip
.irq_set_type
= brcmstb_gpio_irq_set_type
;
479 if (priv
->parent_wake_irq
)
480 priv
->irq_chip
.irq_set_wake
= brcmstb_gpio_irq_set_wake
;
482 irq_set_chained_handler_and_data(priv
->parent_irq
,
483 brcmstb_gpio_irq_handler
, priv
);
484 irq_set_status_flags(priv
->parent_irq
, IRQ_DISABLE_UNLAZY
);
489 irq_domain_remove(priv
->irq_domain
);
494 static void brcmstb_gpio_bank_save(struct brcmstb_gpio_priv
*priv
,
495 struct brcmstb_gpio_bank
*bank
)
497 struct gpio_chip
*gc
= &bank
->gc
;
500 for (i
= 0; i
< GIO_REG_STAT
; i
++)
501 bank
->saved_regs
[i
] = gc
->read_reg(priv
->reg_base
+
502 GIO_BANK_OFF(bank
->id
, i
));
505 static void brcmstb_gpio_quiesce(struct device
*dev
, bool save
)
507 struct brcmstb_gpio_priv
*priv
= dev_get_drvdata(dev
);
508 struct brcmstb_gpio_bank
*bank
;
509 struct gpio_chip
*gc
;
512 /* disable non-wake interrupt */
513 if (priv
->parent_irq
>= 0)
514 disable_irq(priv
->parent_irq
);
516 list_for_each_entry(bank
, &priv
->bank_list
, node
) {
520 brcmstb_gpio_bank_save(priv
, bank
);
522 /* Unmask GPIOs which have been flagged as wake-up sources */
523 if (priv
->parent_wake_irq
)
524 imask
= bank
->wake_active
;
527 gc
->write_reg(priv
->reg_base
+ GIO_MASK(bank
->id
),
532 static void brcmstb_gpio_shutdown(struct platform_device
*pdev
)
534 /* Enable GPIO for S5 cold boot */
535 brcmstb_gpio_quiesce(&pdev
->dev
, false);
538 #ifdef CONFIG_PM_SLEEP
539 static void brcmstb_gpio_bank_restore(struct brcmstb_gpio_priv
*priv
,
540 struct brcmstb_gpio_bank
*bank
)
542 struct gpio_chip
*gc
= &bank
->gc
;
545 for (i
= 0; i
< GIO_REG_STAT
; i
++)
546 gc
->write_reg(priv
->reg_base
+ GIO_BANK_OFF(bank
->id
, i
),
547 bank
->saved_regs
[i
]);
550 static int brcmstb_gpio_suspend(struct device
*dev
)
552 brcmstb_gpio_quiesce(dev
, true);
556 static int brcmstb_gpio_resume(struct device
*dev
)
558 struct brcmstb_gpio_priv
*priv
= dev_get_drvdata(dev
);
559 struct brcmstb_gpio_bank
*bank
;
560 bool need_wakeup_event
= false;
562 list_for_each_entry(bank
, &priv
->bank_list
, node
) {
563 need_wakeup_event
|= !!__brcmstb_gpio_get_active_irqs(bank
);
564 brcmstb_gpio_bank_restore(priv
, bank
);
567 if (priv
->parent_wake_irq
&& need_wakeup_event
)
568 pm_wakeup_event(dev
, 0);
570 /* enable non-wake interrupt */
571 if (priv
->parent_irq
>= 0)
572 enable_irq(priv
->parent_irq
);
578 #define brcmstb_gpio_suspend NULL
579 #define brcmstb_gpio_resume NULL
580 #endif /* CONFIG_PM_SLEEP */
582 static const struct dev_pm_ops brcmstb_gpio_pm_ops
= {
583 .suspend_noirq
= brcmstb_gpio_suspend
,
584 .resume_noirq
= brcmstb_gpio_resume
,
587 static int brcmstb_gpio_probe(struct platform_device
*pdev
)
589 struct device
*dev
= &pdev
->dev
;
590 struct device_node
*np
= dev
->of_node
;
591 void __iomem
*reg_base
;
592 struct brcmstb_gpio_priv
*priv
;
593 struct resource
*res
;
598 unsigned long flags
= 0;
599 bool need_wakeup_event
= false;
601 priv
= devm_kzalloc(dev
, sizeof(*priv
), GFP_KERNEL
);
604 platform_set_drvdata(pdev
, priv
);
605 INIT_LIST_HEAD(&priv
->bank_list
);
607 reg_base
= devm_platform_get_and_ioremap_resource(pdev
, 0, &res
);
608 if (IS_ERR(reg_base
))
609 return PTR_ERR(reg_base
);
611 priv
->reg_base
= reg_base
;
614 if (of_property_read_bool(np
, "interrupt-controller")) {
615 priv
->parent_irq
= platform_get_irq(pdev
, 0);
616 if (priv
->parent_irq
<= 0)
619 priv
->parent_irq
= -ENOENT
;
622 if (brcmstb_gpio_sanity_check_banks(dev
, np
, res
))
626 * MIPS endianness is configured by boot strap, which also reverses all
627 * bus endianness (i.e., big-endian CPU + big endian bus ==> native
630 * Other architectures (e.g., ARM) either do not support big endian, or
631 * else leave I/O in little endian mode.
633 #if defined(CONFIG_MIPS) && defined(__BIG_ENDIAN)
634 flags
= BGPIOF_BIG_ENDIAN_BYTE_ORDER
;
637 of_property_for_each_u32(np
, "brcm,gpio-bank-widths", bank_width
) {
638 struct brcmstb_gpio_bank
*bank
;
639 struct gpio_chip
*gc
;
642 * If bank_width is 0, then there is an empty bank in the
643 * register block. Special handling for this case.
645 if (bank_width
== 0) {
646 dev_dbg(dev
, "Width 0 found: Empty bank @ %d\n",
649 num_gpios
+= MAX_GPIO_PER_BANK
;
653 bank
= devm_kzalloc(dev
, sizeof(*bank
), GFP_KERNEL
);
659 bank
->parent_priv
= priv
;
660 bank
->id
= num_banks
;
661 if (bank_width
<= 0 || bank_width
> MAX_GPIO_PER_BANK
) {
662 dev_err(dev
, "Invalid bank width %d\n", bank_width
);
666 bank
->width
= bank_width
;
670 * Regs are 4 bytes wide, have data reg, no set/clear regs,
671 * and direction bits have 0 = output and 1 = input
674 err
= bgpio_init(gc
, dev
, 4,
675 reg_base
+ GIO_DATA(bank
->id
),
677 reg_base
+ GIO_IODIR(bank
->id
), flags
);
679 dev_err(dev
, "bgpio_init() failed\n");
683 gc
->owner
= THIS_MODULE
;
684 gc
->label
= devm_kasprintf(dev
, GFP_KERNEL
, "%pOF", np
);
689 gc
->of_gpio_n_cells
= 2;
690 gc
->of_xlate
= brcmstb_gpio_of_xlate
;
691 /* not all ngpio lines are valid, will use bank width later */
692 gc
->ngpio
= MAX_GPIO_PER_BANK
;
693 gc
->offset
= bank
->id
* MAX_GPIO_PER_BANK
;
694 gc
->request
= gpiochip_generic_request
;
695 gc
->free
= gpiochip_generic_free
;
696 if (priv
->parent_irq
> 0)
697 gc
->to_irq
= brcmstb_gpio_to_irq
;
700 * Mask all interrupts by default, since wakeup interrupts may
701 * be retained from S5 cold boot
703 need_wakeup_event
|= !!__brcmstb_gpio_get_active_irqs(bank
);
704 gc
->write_reg(reg_base
+ GIO_MASK(bank
->id
), 0);
706 err
= gpiochip_add_data(gc
, bank
);
708 dev_err(dev
, "Could not add gpiochip for bank %d\n",
712 num_gpios
+= gc
->ngpio
;
714 dev_dbg(dev
, "bank=%d, base=%d, ngpio=%d, width=%d\n", bank
->id
,
715 gc
->base
, gc
->ngpio
, bank
->width
);
717 /* Everything looks good, so add bank to list */
718 list_add(&bank
->node
, &priv
->bank_list
);
723 priv
->num_gpios
= num_gpios
;
724 if (priv
->parent_irq
> 0) {
725 err
= brcmstb_gpio_irq_setup(pdev
, priv
);
730 if (priv
->parent_wake_irq
&& need_wakeup_event
)
731 pm_wakeup_event(dev
, 0);
736 (void) brcmstb_gpio_remove(pdev
);
740 static const struct of_device_id brcmstb_gpio_of_match
[] = {
741 { .compatible
= "brcm,brcmstb-gpio" },
745 MODULE_DEVICE_TABLE(of
, brcmstb_gpio_of_match
);
747 static struct platform_driver brcmstb_gpio_driver
= {
749 .name
= "brcmstb-gpio",
750 .of_match_table
= brcmstb_gpio_of_match
,
751 .pm
= &brcmstb_gpio_pm_ops
,
753 .probe
= brcmstb_gpio_probe
,
754 .remove
= brcmstb_gpio_remove
,
755 .shutdown
= brcmstb_gpio_shutdown
,
757 module_platform_driver(brcmstb_gpio_driver
);
759 MODULE_AUTHOR("Gregory Fong");
760 MODULE_DESCRIPTION("Driver for Broadcom BRCMSTB SoC UPG GPIO");
761 MODULE_LICENSE("GPL v2");