• Home
  • Raw
  • Download

Lines Matching refs:bank

77 	void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable);
83 #define BANK_USED(bank) (bank->mod_usage || bank->irq_usage) argument
108 static void omap_set_gpio_direction(struct gpio_bank *bank, int gpio, in omap_set_gpio_direction() argument
111 bank->context.oe = omap_gpio_rmw(bank->base + bank->regs->direction, in omap_set_gpio_direction()
117 static void omap_set_gpio_dataout_reg(struct gpio_bank *bank, unsigned offset, in omap_set_gpio_dataout_reg() argument
120 void __iomem *reg = bank->base; in omap_set_gpio_dataout_reg()
124 reg += bank->regs->set_dataout; in omap_set_gpio_dataout_reg()
125 bank->context.dataout |= l; in omap_set_gpio_dataout_reg()
127 reg += bank->regs->clr_dataout; in omap_set_gpio_dataout_reg()
128 bank->context.dataout &= ~l; in omap_set_gpio_dataout_reg()
135 static void omap_set_gpio_dataout_mask(struct gpio_bank *bank, unsigned offset, in omap_set_gpio_dataout_mask() argument
138 bank->context.dataout = omap_gpio_rmw(bank->base + bank->regs->dataout, in omap_set_gpio_dataout_mask()
142 static inline void omap_gpio_dbck_enable(struct gpio_bank *bank) in omap_gpio_dbck_enable() argument
144 if (bank->dbck_enable_mask && !bank->dbck_enabled) { in omap_gpio_dbck_enable()
145 clk_enable(bank->dbck); in omap_gpio_dbck_enable()
146 bank->dbck_enabled = true; in omap_gpio_dbck_enable()
148 writel_relaxed(bank->dbck_enable_mask, in omap_gpio_dbck_enable()
149 bank->base + bank->regs->debounce_en); in omap_gpio_dbck_enable()
153 static inline void omap_gpio_dbck_disable(struct gpio_bank *bank) in omap_gpio_dbck_disable() argument
155 if (bank->dbck_enable_mask && bank->dbck_enabled) { in omap_gpio_dbck_disable()
161 writel_relaxed(0, bank->base + bank->regs->debounce_en); in omap_gpio_dbck_disable()
163 clk_disable(bank->dbck); in omap_gpio_dbck_disable()
164 bank->dbck_enabled = false; in omap_gpio_dbck_disable()
180 static int omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, in omap2_set_gpio_debounce() argument
187 if (!bank->dbck_flag) in omap2_set_gpio_debounce()
198 clk_enable(bank->dbck); in omap2_set_gpio_debounce()
199 writel_relaxed(debounce, bank->base + bank->regs->debounce); in omap2_set_gpio_debounce()
201 val = omap_gpio_rmw(bank->base + bank->regs->debounce_en, l, enable); in omap2_set_gpio_debounce()
202 bank->dbck_enable_mask = val; in omap2_set_gpio_debounce()
204 clk_disable(bank->dbck); in omap2_set_gpio_debounce()
213 omap_gpio_dbck_enable(bank); in omap2_set_gpio_debounce()
214 if (bank->dbck_enable_mask) { in omap2_set_gpio_debounce()
215 bank->context.debounce = debounce; in omap2_set_gpio_debounce()
216 bank->context.debounce_en = val; in omap2_set_gpio_debounce()
232 static void omap_clear_gpio_debounce(struct gpio_bank *bank, unsigned offset) in omap_clear_gpio_debounce() argument
236 if (!bank->dbck_flag) in omap_clear_gpio_debounce()
239 if (!(bank->dbck_enable_mask & gpio_bit)) in omap_clear_gpio_debounce()
242 bank->dbck_enable_mask &= ~gpio_bit; in omap_clear_gpio_debounce()
243 bank->context.debounce_en &= ~gpio_bit; in omap_clear_gpio_debounce()
244 writel_relaxed(bank->context.debounce_en, in omap_clear_gpio_debounce()
245 bank->base + bank->regs->debounce_en); in omap_clear_gpio_debounce()
247 if (!bank->dbck_enable_mask) { in omap_clear_gpio_debounce()
248 bank->context.debounce = 0; in omap_clear_gpio_debounce()
249 writel_relaxed(bank->context.debounce, bank->base + in omap_clear_gpio_debounce()
250 bank->regs->debounce); in omap_clear_gpio_debounce()
251 clk_disable(bank->dbck); in omap_clear_gpio_debounce()
252 bank->dbck_enabled = false; in omap_clear_gpio_debounce()
262 static bool omap_gpio_is_off_wakeup_capable(struct gpio_bank *bank, u32 gpio_mask) in omap_gpio_is_off_wakeup_capable() argument
264 u32 no_wake = bank->non_wakeup_gpios; in omap_gpio_is_off_wakeup_capable()
272 static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, in omap_set_gpio_trigger() argument
275 void __iomem *base = bank->base; in omap_set_gpio_trigger()
278 omap_gpio_rmw(base + bank->regs->leveldetect0, gpio_bit, in omap_set_gpio_trigger()
280 omap_gpio_rmw(base + bank->regs->leveldetect1, gpio_bit, in omap_set_gpio_trigger()
288 omap_gpio_rmw(base + bank->regs->risingdetect, gpio_bit, in omap_set_gpio_trigger()
290 omap_gpio_rmw(base + bank->regs->fallingdetect, gpio_bit, in omap_set_gpio_trigger()
293 bank->context.leveldetect0 = in omap_set_gpio_trigger()
294 readl_relaxed(bank->base + bank->regs->leveldetect0); in omap_set_gpio_trigger()
295 bank->context.leveldetect1 = in omap_set_gpio_trigger()
296 readl_relaxed(bank->base + bank->regs->leveldetect1); in omap_set_gpio_trigger()
297 bank->context.risingdetect = in omap_set_gpio_trigger()
298 readl_relaxed(bank->base + bank->regs->risingdetect); in omap_set_gpio_trigger()
299 bank->context.fallingdetect = in omap_set_gpio_trigger()
300 readl_relaxed(bank->base + bank->regs->fallingdetect); in omap_set_gpio_trigger()
302 bank->level_mask = bank->context.leveldetect0 | in omap_set_gpio_trigger()
303 bank->context.leveldetect1; in omap_set_gpio_trigger()
306 if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) { in omap_set_gpio_trigger()
314 bank->enabled_non_wakeup_gpios |= gpio_bit; in omap_set_gpio_trigger()
316 bank->enabled_non_wakeup_gpios &= ~gpio_bit; in omap_set_gpio_trigger()
324 static void omap_toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) in omap_toggle_gpio_edge_triggering() argument
326 if (IS_ENABLED(CONFIG_ARCH_OMAP1) && bank->regs->irqctrl) { in omap_toggle_gpio_edge_triggering()
327 void __iomem *reg = bank->base + bank->regs->irqctrl; in omap_toggle_gpio_edge_triggering()
333 static int omap_set_gpio_triggering(struct gpio_bank *bank, int gpio, in omap_set_gpio_triggering() argument
336 void __iomem *reg = bank->base; in omap_set_gpio_triggering()
339 if (bank->regs->leveldetect0 && bank->regs->wkup_en) { in omap_set_gpio_triggering()
340 omap_set_gpio_trigger(bank, gpio, trigger); in omap_set_gpio_triggering()
341 } else if (bank->regs->irqctrl) { in omap_set_gpio_triggering()
342 reg += bank->regs->irqctrl; in omap_set_gpio_triggering()
346 bank->toggle_mask |= BIT(gpio); in omap_set_gpio_triggering()
355 } else if (bank->regs->edgectrl1) { in omap_set_gpio_triggering()
357 reg += bank->regs->edgectrl2; in omap_set_gpio_triggering()
359 reg += bank->regs->edgectrl1; in omap_set_gpio_triggering()
373 static void omap_enable_gpio_module(struct gpio_bank *bank, unsigned offset) in omap_enable_gpio_module() argument
375 if (bank->regs->pinctrl) { in omap_enable_gpio_module()
376 void __iomem *reg = bank->base + bank->regs->pinctrl; in omap_enable_gpio_module()
382 if (bank->regs->ctrl && !BANK_USED(bank)) { in omap_enable_gpio_module()
383 void __iomem *reg = bank->base + bank->regs->ctrl; in omap_enable_gpio_module()
390 bank->context.ctrl = ctrl; in omap_enable_gpio_module()
394 static void omap_disable_gpio_module(struct gpio_bank *bank, unsigned offset) in omap_disable_gpio_module() argument
396 if (bank->regs->ctrl && !BANK_USED(bank)) { in omap_disable_gpio_module()
397 void __iomem *reg = bank->base + bank->regs->ctrl; in omap_disable_gpio_module()
404 bank->context.ctrl = ctrl; in omap_disable_gpio_module()
408 static int omap_gpio_is_input(struct gpio_bank *bank, unsigned offset) in omap_gpio_is_input() argument
410 void __iomem *reg = bank->base + bank->regs->direction; in omap_gpio_is_input()
415 static void omap_gpio_init_irq(struct gpio_bank *bank, unsigned offset) in omap_gpio_init_irq() argument
417 if (!LINE_USED(bank->mod_usage, offset)) { in omap_gpio_init_irq()
418 omap_enable_gpio_module(bank, offset); in omap_gpio_init_irq()
419 omap_set_gpio_direction(bank, offset, 1); in omap_gpio_init_irq()
421 bank->irq_usage |= BIT(offset); in omap_gpio_init_irq()
426 struct gpio_bank *bank = omap_irq_data_get_bank(d); in omap_gpio_irq_type() local
434 if (!bank->regs->leveldetect0 && in omap_gpio_irq_type()
438 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_irq_type()
439 retval = omap_set_gpio_triggering(bank, offset, type); in omap_gpio_irq_type()
441 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_irq_type()
444 omap_gpio_init_irq(bank, offset); in omap_gpio_irq_type()
445 if (!omap_gpio_is_input(bank, offset)) { in omap_gpio_irq_type()
446 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_irq_type()
450 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_irq_type()
469 static void omap_clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) in omap_clear_gpio_irqbank() argument
471 void __iomem *reg = bank->base; in omap_clear_gpio_irqbank()
473 reg += bank->regs->irqstatus; in omap_clear_gpio_irqbank()
477 if (bank->regs->irqstatus2) { in omap_clear_gpio_irqbank()
478 reg = bank->base + bank->regs->irqstatus2; in omap_clear_gpio_irqbank()
486 static inline void omap_clear_gpio_irqstatus(struct gpio_bank *bank, in omap_clear_gpio_irqstatus() argument
489 omap_clear_gpio_irqbank(bank, BIT(offset)); in omap_clear_gpio_irqstatus()
492 static u32 omap_get_gpio_irqbank_mask(struct gpio_bank *bank) in omap_get_gpio_irqbank_mask() argument
494 void __iomem *reg = bank->base; in omap_get_gpio_irqbank_mask()
496 u32 mask = (BIT(bank->width)) - 1; in omap_get_gpio_irqbank_mask()
498 reg += bank->regs->irqenable; in omap_get_gpio_irqbank_mask()
500 if (bank->regs->irqenable_inv) in omap_get_gpio_irqbank_mask()
506 static inline void omap_set_gpio_irqenable(struct gpio_bank *bank, in omap_set_gpio_irqenable() argument
509 void __iomem *reg = bank->base; in omap_set_gpio_irqenable()
512 if (bank->regs->set_irqenable && bank->regs->clr_irqenable) { in omap_set_gpio_irqenable()
514 reg += bank->regs->set_irqenable; in omap_set_gpio_irqenable()
515 bank->context.irqenable1 |= gpio_mask; in omap_set_gpio_irqenable()
517 reg += bank->regs->clr_irqenable; in omap_set_gpio_irqenable()
518 bank->context.irqenable1 &= ~gpio_mask; in omap_set_gpio_irqenable()
522 bank->context.irqenable1 = in omap_set_gpio_irqenable()
523 omap_gpio_rmw(reg + bank->regs->irqenable, gpio_mask, in omap_set_gpio_irqenable()
524 enable ^ bank->regs->irqenable_inv); in omap_set_gpio_irqenable()
533 if (bank->regs->wkup_en && in omap_set_gpio_irqenable()
534 (bank->regs->edgectrl1 || !(bank->non_wakeup_gpios & gpio_mask))) { in omap_set_gpio_irqenable()
535 bank->context.wake_en = in omap_set_gpio_irqenable()
536 omap_gpio_rmw(bank->base + bank->regs->wkup_en, in omap_set_gpio_irqenable()
544 struct gpio_bank *bank = omap_irq_data_get_bank(d); in omap_gpio_wake_enable() local
546 return irq_set_irq_wake(bank->irq, enable); in omap_gpio_wake_enable()
563 struct gpio_bank *bank = gpiobank; in omap_gpio_irq_handler() local
567 isr_reg = bank->base + bank->regs->irqstatus; in omap_gpio_irq_handler()
571 if (WARN_ONCE(!pm_runtime_active(bank->chip.parent), in omap_gpio_irq_handler()
576 raw_spin_lock_irqsave(&bank->lock, lock_flags); in omap_gpio_irq_handler()
578 enabled = omap_get_gpio_irqbank_mask(bank); in omap_gpio_irq_handler()
586 edge = isr & ~bank->level_mask; in omap_gpio_irq_handler()
588 omap_clear_gpio_irqbank(bank, edge); in omap_gpio_irq_handler()
590 raw_spin_unlock_irqrestore(&bank->lock, lock_flags); in omap_gpio_irq_handler()
599 raw_spin_lock_irqsave(&bank->lock, lock_flags); in omap_gpio_irq_handler()
607 if (bank->toggle_mask & (BIT(bit))) in omap_gpio_irq_handler()
608 omap_toggle_gpio_edge_triggering(bank, bit); in omap_gpio_irq_handler()
610 raw_spin_unlock_irqrestore(&bank->lock, lock_flags); in omap_gpio_irq_handler()
612 raw_spin_lock_irqsave(&bank->wa_lock, wa_lock_flags); in omap_gpio_irq_handler()
614 generic_handle_domain_irq(bank->chip.irq.domain, bit); in omap_gpio_irq_handler()
616 raw_spin_unlock_irqrestore(&bank->wa_lock, in omap_gpio_irq_handler()
626 struct gpio_bank *bank = omap_irq_data_get_bank(d); in omap_gpio_irq_startup() local
630 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_irq_startup()
632 if (!LINE_USED(bank->mod_usage, offset)) in omap_gpio_irq_startup()
633 omap_set_gpio_direction(bank, offset, 1); in omap_gpio_irq_startup()
634 omap_enable_gpio_module(bank, offset); in omap_gpio_irq_startup()
635 bank->irq_usage |= BIT(offset); in omap_gpio_irq_startup()
637 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_irq_startup()
645 struct gpio_bank *bank = omap_irq_data_get_bank(d); in omap_gpio_irq_shutdown() local
649 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_irq_shutdown()
650 bank->irq_usage &= ~(BIT(offset)); in omap_gpio_irq_shutdown()
651 omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); in omap_gpio_irq_shutdown()
652 omap_clear_gpio_irqstatus(bank, offset); in omap_gpio_irq_shutdown()
653 omap_set_gpio_irqenable(bank, offset, 0); in omap_gpio_irq_shutdown()
654 if (!LINE_USED(bank->mod_usage, offset)) in omap_gpio_irq_shutdown()
655 omap_clear_gpio_debounce(bank, offset); in omap_gpio_irq_shutdown()
656 omap_disable_gpio_module(bank, offset); in omap_gpio_irq_shutdown()
657 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_irq_shutdown()
662 struct gpio_bank *bank = omap_irq_data_get_bank(data); in omap_gpio_irq_bus_lock() local
664 pm_runtime_get_sync(bank->chip.parent); in omap_gpio_irq_bus_lock()
669 struct gpio_bank *bank = omap_irq_data_get_bank(data); in gpio_irq_bus_sync_unlock() local
671 pm_runtime_put(bank->chip.parent); in gpio_irq_bus_sync_unlock()
676 struct gpio_bank *bank = omap_irq_data_get_bank(d); in omap_gpio_mask_irq() local
680 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_mask_irq()
681 omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); in omap_gpio_mask_irq()
682 omap_set_gpio_irqenable(bank, offset, 0); in omap_gpio_mask_irq()
683 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_mask_irq()
688 struct gpio_bank *bank = omap_irq_data_get_bank(d); in omap_gpio_unmask_irq() local
693 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_unmask_irq()
694 omap_set_gpio_irqenable(bank, offset, 1); in omap_gpio_unmask_irq()
701 if (bank->regs->leveldetect0 && bank->regs->wkup_en && in omap_gpio_unmask_irq()
703 omap_clear_gpio_irqstatus(bank, offset); in omap_gpio_unmask_irq()
706 omap_set_gpio_triggering(bank, offset, trigger); in omap_gpio_unmask_irq()
708 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_unmask_irq()
715 struct gpio_bank *bank = dev_get_drvdata(dev); in omap_mpuio_suspend_noirq() local
716 void __iomem *mask_reg = bank->base + in omap_mpuio_suspend_noirq()
717 OMAP_MPUIO_GPIO_MASKIT / bank->stride; in omap_mpuio_suspend_noirq()
720 raw_spin_lock_irqsave(&bank->lock, flags); in omap_mpuio_suspend_noirq()
721 writel_relaxed(0xffff & ~bank->context.wake_en, mask_reg); in omap_mpuio_suspend_noirq()
722 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_mpuio_suspend_noirq()
729 struct gpio_bank *bank = dev_get_drvdata(dev); in omap_mpuio_resume_noirq() local
730 void __iomem *mask_reg = bank->base + in omap_mpuio_resume_noirq()
731 OMAP_MPUIO_GPIO_MASKIT / bank->stride; in omap_mpuio_resume_noirq()
734 raw_spin_lock_irqsave(&bank->lock, flags); in omap_mpuio_resume_noirq()
735 writel_relaxed(bank->context.wake_en, mask_reg); in omap_mpuio_resume_noirq()
736 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_mpuio_resume_noirq()
763 static inline void omap_mpuio_init(struct gpio_bank *bank) in omap_mpuio_init() argument
765 platform_set_drvdata(&omap_mpuio_device, bank); in omap_mpuio_init()
775 struct gpio_bank *bank = gpiochip_get_data(chip); in omap_gpio_request() local
780 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_request()
781 omap_enable_gpio_module(bank, offset); in omap_gpio_request()
782 bank->mod_usage |= BIT(offset); in omap_gpio_request()
783 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_request()
790 struct gpio_bank *bank = gpiochip_get_data(chip); in omap_gpio_free() local
793 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_free()
794 bank->mod_usage &= ~(BIT(offset)); in omap_gpio_free()
795 if (!LINE_USED(bank->irq_usage, offset)) { in omap_gpio_free()
796 omap_set_gpio_direction(bank, offset, 1); in omap_gpio_free()
797 omap_clear_gpio_debounce(bank, offset); in omap_gpio_free()
799 omap_disable_gpio_module(bank, offset); in omap_gpio_free()
800 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_free()
807 struct gpio_bank *bank = gpiochip_get_data(chip); in omap_gpio_get_direction() local
809 if (readl_relaxed(bank->base + bank->regs->direction) & BIT(offset)) in omap_gpio_get_direction()
817 struct gpio_bank *bank; in omap_gpio_input() local
820 bank = gpiochip_get_data(chip); in omap_gpio_input()
821 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_input()
822 omap_set_gpio_direction(bank, offset, 1); in omap_gpio_input()
823 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_input()
829 struct gpio_bank *bank = gpiochip_get_data(chip); in omap_gpio_get() local
832 if (omap_gpio_is_input(bank, offset)) in omap_gpio_get()
833 reg = bank->base + bank->regs->datain; in omap_gpio_get()
835 reg = bank->base + bank->regs->dataout; in omap_gpio_get()
842 struct gpio_bank *bank; in omap_gpio_output() local
845 bank = gpiochip_get_data(chip); in omap_gpio_output()
846 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_output()
847 bank->set_dataout(bank, offset, value); in omap_gpio_output()
848 omap_set_gpio_direction(bank, offset, 0); in omap_gpio_output()
849 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_output()
856 struct gpio_bank *bank = gpiochip_get_data(chip); in omap_gpio_get_multiple() local
857 void __iomem *base = bank->base; in omap_gpio_get_multiple()
860 direction = readl_relaxed(base + bank->regs->direction); in omap_gpio_get_multiple()
864 val |= readl_relaxed(base + bank->regs->datain) & m; in omap_gpio_get_multiple()
868 val |= readl_relaxed(base + bank->regs->dataout) & m; in omap_gpio_get_multiple()
878 struct gpio_bank *bank; in omap_gpio_debounce() local
882 bank = gpiochip_get_data(chip); in omap_gpio_debounce()
884 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_debounce()
885 ret = omap2_set_gpio_debounce(bank, offset, debounce); in omap_gpio_debounce()
886 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_debounce()
921 struct gpio_bank *bank; in omap_gpio_set() local
924 bank = gpiochip_get_data(chip); in omap_gpio_set()
925 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_set()
926 bank->set_dataout(bank, offset, value); in omap_gpio_set()
927 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_set()
933 struct gpio_bank *bank = gpiochip_get_data(chip); in omap_gpio_set_multiple() local
934 void __iomem *reg = bank->base + bank->regs->dataout; in omap_gpio_set_multiple()
938 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_set_multiple()
941 bank->context.dataout = l; in omap_gpio_set_multiple()
942 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_set_multiple()
947 static void omap_gpio_show_rev(struct gpio_bank *bank) in omap_gpio_show_rev() argument
952 if (called || bank->regs->revision == USHRT_MAX) in omap_gpio_show_rev()
955 rev = readw_relaxed(bank->base + bank->regs->revision); in omap_gpio_show_rev()
962 static void omap_gpio_mod_init(struct gpio_bank *bank) in omap_gpio_mod_init() argument
964 void __iomem *base = bank->base; in omap_gpio_mod_init()
967 if (bank->width == 16) in omap_gpio_mod_init()
970 if (bank->is_mpuio) { in omap_gpio_mod_init()
971 writel_relaxed(l, bank->base + bank->regs->irqenable); in omap_gpio_mod_init()
975 omap_gpio_rmw(base + bank->regs->irqenable, l, in omap_gpio_mod_init()
976 bank->regs->irqenable_inv); in omap_gpio_mod_init()
977 omap_gpio_rmw(base + bank->regs->irqstatus, l, in omap_gpio_mod_init()
978 !bank->regs->irqenable_inv); in omap_gpio_mod_init()
979 if (bank->regs->debounce_en) in omap_gpio_mod_init()
980 writel_relaxed(0, base + bank->regs->debounce_en); in omap_gpio_mod_init()
983 bank->context.oe = readl_relaxed(bank->base + bank->regs->direction); in omap_gpio_mod_init()
985 if (bank->regs->ctrl) in omap_gpio_mod_init()
986 writel_relaxed(0, base + bank->regs->ctrl); in omap_gpio_mod_init()
989 static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc, in omap_gpio_chip_init() argument
1002 bank->chip.request = omap_gpio_request; in omap_gpio_chip_init()
1003 bank->chip.free = omap_gpio_free; in omap_gpio_chip_init()
1004 bank->chip.get_direction = omap_gpio_get_direction; in omap_gpio_chip_init()
1005 bank->chip.direction_input = omap_gpio_input; in omap_gpio_chip_init()
1006 bank->chip.get = omap_gpio_get; in omap_gpio_chip_init()
1007 bank->chip.get_multiple = omap_gpio_get_multiple; in omap_gpio_chip_init()
1008 bank->chip.direction_output = omap_gpio_output; in omap_gpio_chip_init()
1009 bank->chip.set_config = omap_gpio_set_config; in omap_gpio_chip_init()
1010 bank->chip.set = omap_gpio_set; in omap_gpio_chip_init()
1011 bank->chip.set_multiple = omap_gpio_set_multiple; in omap_gpio_chip_init()
1012 if (bank->is_mpuio) { in omap_gpio_chip_init()
1013 bank->chip.label = "mpuio"; in omap_gpio_chip_init()
1014 if (bank->regs->wkup_en) in omap_gpio_chip_init()
1015 bank->chip.parent = &omap_mpuio_device.dev; in omap_gpio_chip_init()
1016 bank->chip.base = OMAP_MPUIO(0); in omap_gpio_chip_init()
1018 label = devm_kasprintf(bank->chip.parent, GFP_KERNEL, "gpio-%d-%d", in omap_gpio_chip_init()
1019 gpio, gpio + bank->width - 1); in omap_gpio_chip_init()
1022 bank->chip.label = label; in omap_gpio_chip_init()
1023 bank->chip.base = gpio; in omap_gpio_chip_init()
1025 bank->chip.ngpio = bank->width; in omap_gpio_chip_init()
1032 irq_base = devm_irq_alloc_descs(bank->chip.parent, in omap_gpio_chip_init()
1033 -1, 0, bank->width, 0); in omap_gpio_chip_init()
1035 dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); in omap_gpio_chip_init()
1041 if (bank->is_mpuio && !bank->regs->wkup_en) in omap_gpio_chip_init()
1044 irq = &bank->chip.irq; in omap_gpio_chip_init()
1049 irq->parents = &bank->irq; in omap_gpio_chip_init()
1052 ret = gpiochip_add_data(&bank->chip, bank); in omap_gpio_chip_init()
1054 return dev_err_probe(bank->chip.parent, ret, "Could not register gpio chip\n"); in omap_gpio_chip_init()
1056 irq_domain_set_pm_device(bank->chip.irq.domain, pm_dev); in omap_gpio_chip_init()
1057 ret = devm_request_irq(bank->chip.parent, bank->irq, in omap_gpio_chip_init()
1059 0, dev_name(bank->chip.parent), bank); in omap_gpio_chip_init()
1061 gpiochip_remove(&bank->chip); in omap_gpio_chip_init()
1063 if (!bank->is_mpuio) in omap_gpio_chip_init()
1064 gpio += bank->width; in omap_gpio_chip_init()
1089 static void omap_gpio_restore_context(struct gpio_bank *bank) in omap_gpio_restore_context() argument
1091 const struct omap_gpio_reg_offs *regs = bank->regs; in omap_gpio_restore_context()
1092 void __iomem *base = bank->base; in omap_gpio_restore_context()
1094 writel_relaxed(bank->context.sysconfig, base + regs->sysconfig); in omap_gpio_restore_context()
1095 writel_relaxed(bank->context.wake_en, base + regs->wkup_en); in omap_gpio_restore_context()
1096 writel_relaxed(bank->context.ctrl, base + regs->ctrl); in omap_gpio_restore_context()
1097 writel_relaxed(bank->context.leveldetect0, base + regs->leveldetect0); in omap_gpio_restore_context()
1098 writel_relaxed(bank->context.leveldetect1, base + regs->leveldetect1); in omap_gpio_restore_context()
1099 writel_relaxed(bank->context.risingdetect, base + regs->risingdetect); in omap_gpio_restore_context()
1100 writel_relaxed(bank->context.fallingdetect, base + regs->fallingdetect); in omap_gpio_restore_context()
1101 writel_relaxed(bank->context.dataout, base + regs->dataout); in omap_gpio_restore_context()
1102 writel_relaxed(bank->context.oe, base + regs->direction); in omap_gpio_restore_context()
1104 if (bank->dbck_enable_mask) { in omap_gpio_restore_context()
1105 writel_relaxed(bank->context.debounce, base + regs->debounce); in omap_gpio_restore_context()
1106 writel_relaxed(bank->context.debounce_en, in omap_gpio_restore_context()
1110 writel_relaxed(bank->context.irqenable1, base + regs->irqenable); in omap_gpio_restore_context()
1111 writel_relaxed(bank->context.irqenable2, base + regs->irqenable2); in omap_gpio_restore_context()
1114 static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) in omap_gpio_idle() argument
1116 struct device *dev = bank->chip.parent; in omap_gpio_idle()
1117 void __iomem *base = bank->base; in omap_gpio_idle()
1120 bank->saved_datain = readl_relaxed(base + bank->regs->datain); in omap_gpio_idle()
1123 if (bank->loses_context) in omap_gpio_idle()
1124 bank->context.sysconfig = readl_relaxed(base + bank->regs->sysconfig); in omap_gpio_idle()
1126 if (!bank->enabled_non_wakeup_gpios) in omap_gpio_idle()
1130 mask = bank->enabled_non_wakeup_gpios & bank->context.fallingdetect; in omap_gpio_idle()
1131 mask &= ~bank->context.risingdetect; in omap_gpio_idle()
1132 bank->saved_datain |= mask; in omap_gpio_idle()
1135 mask = bank->enabled_non_wakeup_gpios & bank->context.risingdetect; in omap_gpio_idle()
1136 mask &= ~bank->context.fallingdetect; in omap_gpio_idle()
1137 bank->saved_datain &= ~mask; in omap_gpio_idle()
1147 if (!bank->loses_context && bank->enabled_non_wakeup_gpios) { in omap_gpio_idle()
1148 nowake = bank->enabled_non_wakeup_gpios; in omap_gpio_idle()
1149 omap_gpio_rmw(base + bank->regs->fallingdetect, nowake, ~nowake); in omap_gpio_idle()
1150 omap_gpio_rmw(base + bank->regs->risingdetect, nowake, ~nowake); in omap_gpio_idle()
1154 if (bank->get_context_loss_count) in omap_gpio_idle()
1155 bank->context_loss_count = in omap_gpio_idle()
1156 bank->get_context_loss_count(dev); in omap_gpio_idle()
1158 omap_gpio_dbck_disable(bank); in omap_gpio_idle()
1161 static void omap_gpio_unidle(struct gpio_bank *bank) in omap_gpio_unidle() argument
1163 struct device *dev = bank->chip.parent; in omap_gpio_unidle()
1172 if (bank->loses_context && !bank->context_valid) { in omap_gpio_unidle()
1173 omap_gpio_init_context(bank); in omap_gpio_unidle()
1175 if (bank->get_context_loss_count) in omap_gpio_unidle()
1176 bank->context_loss_count = in omap_gpio_unidle()
1177 bank->get_context_loss_count(dev); in omap_gpio_unidle()
1180 omap_gpio_dbck_enable(bank); in omap_gpio_unidle()
1182 if (bank->loses_context) { in omap_gpio_unidle()
1183 if (!bank->get_context_loss_count) { in omap_gpio_unidle()
1184 omap_gpio_restore_context(bank); in omap_gpio_unidle()
1186 c = bank->get_context_loss_count(dev); in omap_gpio_unidle()
1187 if (c != bank->context_loss_count) { in omap_gpio_unidle()
1188 omap_gpio_restore_context(bank); in omap_gpio_unidle()
1195 writel_relaxed(bank->context.fallingdetect, in omap_gpio_unidle()
1196 bank->base + bank->regs->fallingdetect); in omap_gpio_unidle()
1197 writel_relaxed(bank->context.risingdetect, in omap_gpio_unidle()
1198 bank->base + bank->regs->risingdetect); in omap_gpio_unidle()
1201 l = readl_relaxed(bank->base + bank->regs->datain); in omap_gpio_unidle()
1209 l ^= bank->saved_datain; in omap_gpio_unidle()
1210 l &= bank->enabled_non_wakeup_gpios; in omap_gpio_unidle()
1216 gen0 = l & bank->context.fallingdetect; in omap_gpio_unidle()
1217 gen0 &= bank->saved_datain; in omap_gpio_unidle()
1219 gen1 = l & bank->context.risingdetect; in omap_gpio_unidle()
1220 gen1 &= ~(bank->saved_datain); in omap_gpio_unidle()
1223 gen = l & (~(bank->context.fallingdetect) & in omap_gpio_unidle()
1224 ~(bank->context.risingdetect)); in omap_gpio_unidle()
1231 old0 = readl_relaxed(bank->base + bank->regs->leveldetect0); in omap_gpio_unidle()
1232 old1 = readl_relaxed(bank->base + bank->regs->leveldetect1); in omap_gpio_unidle()
1234 if (!bank->regs->irqstatus_raw0) { in omap_gpio_unidle()
1235 writel_relaxed(old0 | gen, bank->base + in omap_gpio_unidle()
1236 bank->regs->leveldetect0); in omap_gpio_unidle()
1237 writel_relaxed(old1 | gen, bank->base + in omap_gpio_unidle()
1238 bank->regs->leveldetect1); in omap_gpio_unidle()
1241 if (bank->regs->irqstatus_raw0) { in omap_gpio_unidle()
1242 writel_relaxed(old0 | l, bank->base + in omap_gpio_unidle()
1243 bank->regs->leveldetect0); in omap_gpio_unidle()
1244 writel_relaxed(old1 | l, bank->base + in omap_gpio_unidle()
1245 bank->regs->leveldetect1); in omap_gpio_unidle()
1247 writel_relaxed(old0, bank->base + bank->regs->leveldetect0); in omap_gpio_unidle()
1248 writel_relaxed(old1, bank->base + bank->regs->leveldetect1); in omap_gpio_unidle()
1255 struct gpio_bank *bank; in gpio_omap_cpu_notifier() local
1260 bank = container_of(nb, struct gpio_bank, nb); in gpio_omap_cpu_notifier()
1262 raw_spin_lock_irqsave(&bank->lock, flags); in gpio_omap_cpu_notifier()
1263 if (bank->is_suspended) in gpio_omap_cpu_notifier()
1268 mask = omap_get_gpio_irqbank_mask(bank); in gpio_omap_cpu_notifier()
1269 isr = readl_relaxed(bank->base + bank->regs->irqstatus) & mask; in gpio_omap_cpu_notifier()
1274 omap_gpio_idle(bank, true); in gpio_omap_cpu_notifier()
1278 omap_gpio_unidle(bank); in gpio_omap_cpu_notifier()
1283 raw_spin_unlock_irqrestore(&bank->lock, flags); in gpio_omap_cpu_notifier()
1378 struct gpio_bank *bank; in omap_gpio_probe() local
1388 bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); in omap_gpio_probe()
1389 if (!bank) in omap_gpio_probe()
1408 bank->irq = platform_get_irq(pdev, 0); in omap_gpio_probe()
1409 if (bank->irq <= 0) { in omap_gpio_probe()
1410 if (!bank->irq) in omap_gpio_probe()
1411 bank->irq = -ENXIO; in omap_gpio_probe()
1412 return dev_err_probe(dev, bank->irq, "can't get irq resource\n"); in omap_gpio_probe()
1415 bank->chip.parent = dev; in omap_gpio_probe()
1416 bank->chip.owner = THIS_MODULE; in omap_gpio_probe()
1417 bank->dbck_flag = pdata->dbck_flag; in omap_gpio_probe()
1418 bank->stride = pdata->bank_stride; in omap_gpio_probe()
1419 bank->width = pdata->bank_width; in omap_gpio_probe()
1420 bank->is_mpuio = pdata->is_mpuio; in omap_gpio_probe()
1421 bank->non_wakeup_gpios = pdata->non_wakeup_gpios; in omap_gpio_probe()
1422 bank->regs = pdata->regs; in omap_gpio_probe()
1426 bank->loses_context = true; in omap_gpio_probe()
1428 bank->loses_context = pdata->loses_context; in omap_gpio_probe()
1430 if (bank->loses_context) in omap_gpio_probe()
1431 bank->get_context_loss_count = in omap_gpio_probe()
1435 if (bank->regs->set_dataout && bank->regs->clr_dataout) in omap_gpio_probe()
1436 bank->set_dataout = omap_set_gpio_dataout_reg; in omap_gpio_probe()
1438 bank->set_dataout = omap_set_gpio_dataout_mask; in omap_gpio_probe()
1440 raw_spin_lock_init(&bank->lock); in omap_gpio_probe()
1441 raw_spin_lock_init(&bank->wa_lock); in omap_gpio_probe()
1444 bank->base = devm_platform_ioremap_resource(pdev, 0); in omap_gpio_probe()
1445 if (IS_ERR(bank->base)) { in omap_gpio_probe()
1446 return PTR_ERR(bank->base); in omap_gpio_probe()
1449 if (bank->dbck_flag) { in omap_gpio_probe()
1450 bank->dbck = devm_clk_get(dev, "dbclk"); in omap_gpio_probe()
1451 if (IS_ERR(bank->dbck)) { in omap_gpio_probe()
1454 bank->dbck_flag = false; in omap_gpio_probe()
1456 clk_prepare(bank->dbck); in omap_gpio_probe()
1460 platform_set_drvdata(pdev, bank); in omap_gpio_probe()
1465 if (bank->is_mpuio) in omap_gpio_probe()
1466 omap_mpuio_init(bank); in omap_gpio_probe()
1468 omap_gpio_mod_init(bank); in omap_gpio_probe()
1470 ret = omap_gpio_chip_init(bank, irqc, dev); in omap_gpio_probe()
1474 if (bank->dbck_flag) in omap_gpio_probe()
1475 clk_unprepare(bank->dbck); in omap_gpio_probe()
1479 omap_gpio_show_rev(bank); in omap_gpio_probe()
1481 bank->nb.notifier_call = gpio_omap_cpu_notifier; in omap_gpio_probe()
1482 cpu_pm_register_notifier(&bank->nb); in omap_gpio_probe()
1491 struct gpio_bank *bank = platform_get_drvdata(pdev); in omap_gpio_remove() local
1493 cpu_pm_unregister_notifier(&bank->nb); in omap_gpio_remove()
1494 gpiochip_remove(&bank->chip); in omap_gpio_remove()
1496 if (bank->dbck_flag) in omap_gpio_remove()
1497 clk_unprepare(bank->dbck); in omap_gpio_remove()
1504 struct gpio_bank *bank = dev_get_drvdata(dev); in omap_gpio_runtime_suspend() local
1507 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_runtime_suspend()
1508 omap_gpio_idle(bank, true); in omap_gpio_runtime_suspend()
1509 bank->is_suspended = true; in omap_gpio_runtime_suspend()
1510 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_runtime_suspend()
1517 struct gpio_bank *bank = dev_get_drvdata(dev); in omap_gpio_runtime_resume() local
1520 raw_spin_lock_irqsave(&bank->lock, flags); in omap_gpio_runtime_resume()
1521 omap_gpio_unidle(bank); in omap_gpio_runtime_resume()
1522 bank->is_suspended = false; in omap_gpio_runtime_resume()
1523 raw_spin_unlock_irqrestore(&bank->lock, flags); in omap_gpio_runtime_resume()
1530 struct gpio_bank *bank = dev_get_drvdata(dev); in omap_gpio_suspend() local
1532 if (bank->is_suspended) in omap_gpio_suspend()
1535 bank->needs_resume = 1; in omap_gpio_suspend()
1542 struct gpio_bank *bank = dev_get_drvdata(dev); in omap_gpio_resume() local
1544 if (!bank->needs_resume) in omap_gpio_resume()
1547 bank->needs_resume = 0; in omap_gpio_resume()