• Home
  • Raw
  • Download

Lines Matching full:bank

36 #define GIO_BANK_OFF(bank, off)	(((bank) * GIO_BANK_SIZE) + (off * sizeof(u32)))  argument
37 #define GIO_ODEN(bank) GIO_BANK_OFF(bank, GIO_REG_ODEN) argument
38 #define GIO_DATA(bank) GIO_BANK_OFF(bank, GIO_REG_DATA) argument
39 #define GIO_IODIR(bank) GIO_BANK_OFF(bank, GIO_REG_IODIR) argument
40 #define GIO_EC(bank) GIO_BANK_OFF(bank, GIO_REG_EC) argument
41 #define GIO_EI(bank) GIO_BANK_OFF(bank, GIO_REG_EI) argument
42 #define GIO_MASK(bank) GIO_BANK_OFF(bank, GIO_REG_MASK) argument
43 #define GIO_LEVEL(bank) GIO_BANK_OFF(bank, GIO_REG_LEVEL) argument
44 #define GIO_STAT(bank) GIO_BANK_OFF(bank, GIO_REG_STAT) argument
76 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_gc_to_priv() local
77 return bank->parent_priv; in brcmstb_gpio_gc_to_priv()
81 __brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank *bank) in __brcmstb_gpio_get_active_irqs() argument
83 void __iomem *reg_base = bank->parent_priv->reg_base; in __brcmstb_gpio_get_active_irqs()
85 return bank->gc.read_reg(reg_base + GIO_STAT(bank->id)) & in __brcmstb_gpio_get_active_irqs()
86 bank->gc.read_reg(reg_base + GIO_MASK(bank->id)); in __brcmstb_gpio_get_active_irqs()
90 brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank *bank) in brcmstb_gpio_get_active_irqs() argument
95 spin_lock_irqsave(&bank->gc.bgpio_lock, flags); in brcmstb_gpio_get_active_irqs()
96 status = __brcmstb_gpio_get_active_irqs(bank); in brcmstb_gpio_get_active_irqs()
97 spin_unlock_irqrestore(&bank->gc.bgpio_lock, flags); in brcmstb_gpio_get_active_irqs()
103 struct brcmstb_gpio_bank *bank) in brcmstb_gpio_hwirq_to_offset() argument
105 return hwirq - (bank->gc.base - bank->parent_priv->gpio_base); in brcmstb_gpio_hwirq_to_offset()
108 static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank, in brcmstb_gpio_set_imask() argument
111 struct gpio_chip *gc = &bank->gc; in brcmstb_gpio_set_imask()
112 struct brcmstb_gpio_priv *priv = bank->parent_priv; in brcmstb_gpio_set_imask()
113 u32 mask = BIT(brcmstb_gpio_hwirq_to_offset(hwirq, bank)); in brcmstb_gpio_set_imask()
118 imask = gc->read_reg(priv->reg_base + GIO_MASK(bank->id)); in brcmstb_gpio_set_imask()
123 gc->write_reg(priv->reg_base + GIO_MASK(bank->id), imask); in brcmstb_gpio_set_imask()
143 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_irq_mask() local
145 brcmstb_gpio_set_imask(bank, d->hwirq, false); in brcmstb_gpio_irq_mask()
151 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_irq_unmask() local
153 brcmstb_gpio_set_imask(bank, d->hwirq, true); in brcmstb_gpio_irq_unmask()
159 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_irq_ack() local
160 struct brcmstb_gpio_priv *priv = bank->parent_priv; in brcmstb_gpio_irq_ack()
161 u32 mask = BIT(brcmstb_gpio_hwirq_to_offset(d->hwirq, bank)); in brcmstb_gpio_irq_ack()
163 gc->write_reg(priv->reg_base + GIO_STAT(bank->id), mask); in brcmstb_gpio_irq_ack()
169 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_irq_set_type() local
170 struct brcmstb_gpio_priv *priv = bank->parent_priv; in brcmstb_gpio_irq_set_type()
171 u32 mask = BIT(brcmstb_gpio_hwirq_to_offset(d->hwirq, bank)); in brcmstb_gpio_irq_set_type()
207 spin_lock_irqsave(&bank->gc.bgpio_lock, flags); in brcmstb_gpio_irq_set_type()
209 iedge_config = bank->gc.read_reg(priv->reg_base + in brcmstb_gpio_irq_set_type()
210 GIO_EC(bank->id)) & ~mask; in brcmstb_gpio_irq_set_type()
211 iedge_insensitive = bank->gc.read_reg(priv->reg_base + in brcmstb_gpio_irq_set_type()
212 GIO_EI(bank->id)) & ~mask; in brcmstb_gpio_irq_set_type()
213 ilevel = bank->gc.read_reg(priv->reg_base + in brcmstb_gpio_irq_set_type()
214 GIO_LEVEL(bank->id)) & ~mask; in brcmstb_gpio_irq_set_type()
216 bank->gc.write_reg(priv->reg_base + GIO_EC(bank->id), in brcmstb_gpio_irq_set_type()
218 bank->gc.write_reg(priv->reg_base + GIO_EI(bank->id), in brcmstb_gpio_irq_set_type()
220 bank->gc.write_reg(priv->reg_base + GIO_LEVEL(bank->id), in brcmstb_gpio_irq_set_type()
223 spin_unlock_irqrestore(&bank->gc.bgpio_lock, flags); in brcmstb_gpio_irq_set_type()
245 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_irq_set_wake() local
246 struct brcmstb_gpio_priv *priv = bank->parent_priv; in brcmstb_gpio_irq_set_wake()
247 u32 mask = BIT(brcmstb_gpio_hwirq_to_offset(d->hwirq, bank)); in brcmstb_gpio_irq_set_wake()
254 bank->wake_active |= mask; in brcmstb_gpio_irq_set_wake()
256 bank->wake_active &= ~mask; in brcmstb_gpio_irq_set_wake()
272 static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank) in brcmstb_gpio_irq_bank_handler() argument
274 struct brcmstb_gpio_priv *priv = bank->parent_priv; in brcmstb_gpio_irq_bank_handler()
276 int hwbase = bank->gc.base - priv->gpio_base; in brcmstb_gpio_irq_bank_handler()
279 while ((status = brcmstb_gpio_get_active_irqs(bank))) { in brcmstb_gpio_irq_bank_handler()
283 if (offset >= bank->width) in brcmstb_gpio_irq_bank_handler()
285 "IRQ for invalid GPIO (bank=%d, offset=%d)\n", in brcmstb_gpio_irq_bank_handler()
286 bank->id, offset); in brcmstb_gpio_irq_bank_handler()
298 struct brcmstb_gpio_bank *bank; in brcmstb_gpio_irq_handler() local
304 list_for_each_entry(bank, &priv->bank_list, node) in brcmstb_gpio_irq_handler()
305 brcmstb_gpio_irq_bank_handler(bank); in brcmstb_gpio_irq_handler()
312 struct brcmstb_gpio_bank *bank; in brcmstb_gpio_hwirq_to_bank() local
316 list_for_each_entry_reverse(bank, &priv->bank_list, node) { in brcmstb_gpio_hwirq_to_bank()
317 i += bank->gc.ngpio; in brcmstb_gpio_hwirq_to_bank()
319 return bank; in brcmstb_gpio_hwirq_to_bank()
336 struct brcmstb_gpio_bank *bank = in brcmstb_gpio_irq_map() local
341 if (!bank) in brcmstb_gpio_irq_map()
344 dev_dbg(&pdev->dev, "Mapping irq %d for gpio line %d (bank %d)\n", in brcmstb_gpio_irq_map()
345 irq, (int)hwirq, bank->id); in brcmstb_gpio_irq_map()
346 ret = irq_set_chip_data(irq, &bank->gc); in brcmstb_gpio_irq_map()
374 of_property_count_u32_elems(np, "brcm,gpio-bank-widths"); in brcmstb_gpio_sanity_check_banks()
377 dev_err(dev, "Mismatch in banks: res had %d, bank-widths had %d\n", in brcmstb_gpio_sanity_check_banks()
388 struct brcmstb_gpio_bank *bank; in brcmstb_gpio_remove() local
412 list_for_each_entry(bank, &priv->bank_list, node) in brcmstb_gpio_remove()
413 gpiochip_remove(&bank->gc); in brcmstb_gpio_remove()
422 struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); in brcmstb_gpio_of_xlate() local
437 if (unlikely(offset >= bank->width)) { in brcmstb_gpio_of_xlate()
514 struct brcmstb_gpio_bank *bank) in brcmstb_gpio_bank_save() argument
516 struct gpio_chip *gc = &bank->gc; in brcmstb_gpio_bank_save()
520 bank->saved_regs[i] = gc->read_reg(priv->reg_base + in brcmstb_gpio_bank_save()
521 GIO_BANK_OFF(bank->id, i)); in brcmstb_gpio_bank_save()
527 struct brcmstb_gpio_bank *bank; in brcmstb_gpio_quiesce() local
535 list_for_each_entry(bank, &priv->bank_list, node) { in brcmstb_gpio_quiesce()
536 gc = &bank->gc; in brcmstb_gpio_quiesce()
539 brcmstb_gpio_bank_save(priv, bank); in brcmstb_gpio_quiesce()
543 imask = bank->wake_active; in brcmstb_gpio_quiesce()
546 gc->write_reg(priv->reg_base + GIO_MASK(bank->id), in brcmstb_gpio_quiesce()
559 struct brcmstb_gpio_bank *bank) in brcmstb_gpio_bank_restore() argument
561 struct gpio_chip *gc = &bank->gc; in brcmstb_gpio_bank_restore()
565 gc->write_reg(priv->reg_base + GIO_BANK_OFF(bank->id, i), in brcmstb_gpio_bank_restore()
566 bank->saved_regs[i]); in brcmstb_gpio_bank_restore()
578 struct brcmstb_gpio_bank *bank; in brcmstb_gpio_resume() local
581 list_for_each_entry(bank, &priv->bank_list, node) { in brcmstb_gpio_resume()
582 need_wakeup_event |= !!__brcmstb_gpio_get_active_irqs(bank); in brcmstb_gpio_resume()
583 brcmstb_gpio_bank_restore(priv, bank); in brcmstb_gpio_resume()
607 struct brcmstb_gpio_bank *bank) in brcmstb_gpio_set_names() argument
614 base = bank->id * MAX_GPIO_PER_BANK; in brcmstb_gpio_set_names()
630 for (i = 0; i < bank->width; i++) { in brcmstb_gpio_set_names()
646 bank->gc.names = names; in brcmstb_gpio_set_names()
703 of_property_for_each_u32(np, "brcm,gpio-bank-widths", prop, p, in brcmstb_gpio_probe()
705 struct brcmstb_gpio_bank *bank; in brcmstb_gpio_probe() local
709 * If bank_width is 0, then there is an empty bank in the in brcmstb_gpio_probe()
713 dev_dbg(dev, "Width 0 found: Empty bank @ %d\n", in brcmstb_gpio_probe()
720 bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); in brcmstb_gpio_probe()
721 if (!bank) { in brcmstb_gpio_probe()
726 bank->parent_priv = priv; in brcmstb_gpio_probe()
727 bank->id = num_banks; in brcmstb_gpio_probe()
729 dev_err(dev, "Invalid bank width %d\n", bank_width); in brcmstb_gpio_probe()
733 bank->width = bank_width; in brcmstb_gpio_probe()
740 gc = &bank->gc; in brcmstb_gpio_probe()
742 reg_base + GIO_DATA(bank->id), in brcmstb_gpio_probe()
744 reg_base + GIO_IODIR(bank->id), flags); in brcmstb_gpio_probe()
760 /* not all ngpio lines are valid, will use bank width later */ in brcmstb_gpio_probe()
769 need_wakeup_event |= !!__brcmstb_gpio_get_active_irqs(bank); in brcmstb_gpio_probe()
770 gc->write_reg(reg_base + GIO_MASK(bank->id), 0); in brcmstb_gpio_probe()
772 brcmstb_gpio_set_names(dev, bank); in brcmstb_gpio_probe()
773 err = gpiochip_add_data(gc, bank); in brcmstb_gpio_probe()
775 dev_err(dev, "Could not add gpiochip for bank %d\n", in brcmstb_gpio_probe()
776 bank->id); in brcmstb_gpio_probe()
781 dev_dbg(dev, "bank=%d, base=%d, ngpio=%d, width=%d\n", bank->id, in brcmstb_gpio_probe()
782 gc->base, gc->ngpio, bank->width); in brcmstb_gpio_probe()
784 /* Everything looks good, so add bank to list */ in brcmstb_gpio_probe()
785 list_add(&bank->node, &priv->bank_list); in brcmstb_gpio_probe()