Lines Matching refs:sgpio
408 sirfsoc_gpio_to_bank(struct sirfsoc_gpio_chip *sgpio, unsigned int offset) in sirfsoc_gpio_to_bank() argument
410 return &sgpio->sgpio_bank[offset / SIRFSOC_GPIO_BANK_SIZE]; in sirfsoc_gpio_to_bank()
421 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); in sirfsoc_gpio_irq_ack() local
422 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); in sirfsoc_gpio_irq_ack()
429 spin_lock_irqsave(&sgpio->lock, flags); in sirfsoc_gpio_irq_ack()
431 val = readl(sgpio->chip.regs + offset); in sirfsoc_gpio_irq_ack()
433 writel(val, sgpio->chip.regs + offset); in sirfsoc_gpio_irq_ack()
435 spin_unlock_irqrestore(&sgpio->lock, flags); in sirfsoc_gpio_irq_ack()
438 static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, in __sirfsoc_gpio_irq_mask() argument
447 spin_lock_irqsave(&sgpio->lock, flags); in __sirfsoc_gpio_irq_mask()
449 val = readl(sgpio->chip.regs + offset); in __sirfsoc_gpio_irq_mask()
452 writel(val, sgpio->chip.regs + offset); in __sirfsoc_gpio_irq_mask()
454 spin_unlock_irqrestore(&sgpio->lock, flags); in __sirfsoc_gpio_irq_mask()
460 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); in sirfsoc_gpio_irq_mask() local
461 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); in sirfsoc_gpio_irq_mask()
463 __sirfsoc_gpio_irq_mask(sgpio, bank, d->hwirq % SIRFSOC_GPIO_BANK_SIZE); in sirfsoc_gpio_irq_mask()
469 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); in sirfsoc_gpio_irq_unmask() local
470 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); in sirfsoc_gpio_irq_unmask()
477 spin_lock_irqsave(&sgpio->lock, flags); in sirfsoc_gpio_irq_unmask()
479 val = readl(sgpio->chip.regs + offset); in sirfsoc_gpio_irq_unmask()
482 writel(val, sgpio->chip.regs + offset); in sirfsoc_gpio_irq_unmask()
484 spin_unlock_irqrestore(&sgpio->lock, flags); in sirfsoc_gpio_irq_unmask()
490 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); in sirfsoc_gpio_irq_type() local
491 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, d->hwirq); in sirfsoc_gpio_irq_type()
498 spin_lock_irqsave(&sgpio->lock, flags); in sirfsoc_gpio_irq_type()
500 val = readl(sgpio->chip.regs + offset); in sirfsoc_gpio_irq_type()
533 writel(val, sgpio->chip.regs + offset); in sirfsoc_gpio_irq_type()
535 spin_unlock_irqrestore(&sgpio->lock, flags); in sirfsoc_gpio_irq_type()
552 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(gc); in sirfsoc_gpio_handle_irq() local
560 bank = &sgpio->sgpio_bank[i]; in sirfsoc_gpio_handle_irq()
568 status = readl(sgpio->chip.regs + SIRFSOC_GPIO_INT_STATUS(bank->id)); in sirfsoc_gpio_handle_irq()
578 ctrl = readl(sgpio->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, idx)); in sirfsoc_gpio_handle_irq()
598 static inline void sirfsoc_gpio_set_input(struct sirfsoc_gpio_chip *sgpio, in sirfsoc_gpio_set_input() argument
603 val = readl(sgpio->chip.regs + ctrl_offset); in sirfsoc_gpio_set_input()
605 writel(val, sgpio->chip.regs + ctrl_offset); in sirfsoc_gpio_set_input()
610 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); in sirfsoc_gpio_request() local
611 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); in sirfsoc_gpio_request()
623 sirfsoc_gpio_set_input(sgpio, SIRFSOC_GPIO_CTRL(bank->id, offset)); in sirfsoc_gpio_request()
624 __sirfsoc_gpio_irq_mask(sgpio, bank, offset); in sirfsoc_gpio_request()
633 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); in sirfsoc_gpio_free() local
634 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); in sirfsoc_gpio_free()
639 __sirfsoc_gpio_irq_mask(sgpio, bank, offset); in sirfsoc_gpio_free()
640 sirfsoc_gpio_set_input(sgpio, SIRFSOC_GPIO_CTRL(bank->id, offset)); in sirfsoc_gpio_free()
649 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); in sirfsoc_gpio_direction_input() local
650 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); in sirfsoc_gpio_direction_input()
659 sirfsoc_gpio_set_input(sgpio, offset); in sirfsoc_gpio_direction_input()
666 static inline void sirfsoc_gpio_set_output(struct sirfsoc_gpio_chip *sgpio, in sirfsoc_gpio_set_output() argument
676 out_ctrl = readl(sgpio->chip.regs + offset); in sirfsoc_gpio_set_output()
684 writel(out_ctrl, sgpio->chip.regs + offset); in sirfsoc_gpio_set_output()
692 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); in sirfsoc_gpio_direction_output() local
693 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, gpio); in sirfsoc_gpio_direction_output()
700 spin_lock_irqsave(&sgpio->lock, flags); in sirfsoc_gpio_direction_output()
702 sirfsoc_gpio_set_output(sgpio, bank, offset, value); in sirfsoc_gpio_direction_output()
704 spin_unlock_irqrestore(&sgpio->lock, flags); in sirfsoc_gpio_direction_output()
711 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); in sirfsoc_gpio_get_value() local
712 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); in sirfsoc_gpio_get_value()
718 val = readl(sgpio->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, offset)); in sirfsoc_gpio_get_value()
728 struct sirfsoc_gpio_chip *sgpio = to_sirfsoc_gpio(chip); in sirfsoc_gpio_set_value() local
729 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(sgpio, offset); in sirfsoc_gpio_set_value()
735 ctrl = readl(sgpio->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, offset)); in sirfsoc_gpio_set_value()
740 writel(ctrl, sgpio->chip.regs + SIRFSOC_GPIO_CTRL(bank->id, offset)); in sirfsoc_gpio_set_value()
745 static void sirfsoc_gpio_set_pullup(struct sirfsoc_gpio_chip *sgpio, in sirfsoc_gpio_set_pullup() argument
754 u32 val = readl(sgpio->chip.regs + offset); in sirfsoc_gpio_set_pullup()
757 writel(val, sgpio->chip.regs + offset); in sirfsoc_gpio_set_pullup()
762 static void sirfsoc_gpio_set_pulldown(struct sirfsoc_gpio_chip *sgpio, in sirfsoc_gpio_set_pulldown() argument
771 u32 val = readl(sgpio->chip.regs + offset); in sirfsoc_gpio_set_pulldown()
774 writel(val, sgpio->chip.regs + offset); in sirfsoc_gpio_set_pulldown()
782 static struct sirfsoc_gpio_chip *sgpio; in sirfsoc_gpio_probe() local
793 sgpio = devm_kzalloc(&pdev->dev, sizeof(*sgpio), GFP_KERNEL); in sirfsoc_gpio_probe()
794 if (!sgpio) in sirfsoc_gpio_probe()
796 spin_lock_init(&sgpio->lock); in sirfsoc_gpio_probe()
802 sgpio->chip.gc.request = sirfsoc_gpio_request; in sirfsoc_gpio_probe()
803 sgpio->chip.gc.free = sirfsoc_gpio_free; in sirfsoc_gpio_probe()
804 sgpio->chip.gc.direction_input = sirfsoc_gpio_direction_input; in sirfsoc_gpio_probe()
805 sgpio->chip.gc.get = sirfsoc_gpio_get_value; in sirfsoc_gpio_probe()
806 sgpio->chip.gc.direction_output = sirfsoc_gpio_direction_output; in sirfsoc_gpio_probe()
807 sgpio->chip.gc.set = sirfsoc_gpio_set_value; in sirfsoc_gpio_probe()
808 sgpio->chip.gc.base = 0; in sirfsoc_gpio_probe()
809 sgpio->chip.gc.ngpio = SIRFSOC_GPIO_BANK_SIZE * SIRFSOC_GPIO_NO_OF_BANKS; in sirfsoc_gpio_probe()
810 sgpio->chip.gc.label = kstrdup(np->full_name, GFP_KERNEL); in sirfsoc_gpio_probe()
811 sgpio->chip.gc.of_node = np; in sirfsoc_gpio_probe()
812 sgpio->chip.gc.of_xlate = sirfsoc_gpio_of_xlate; in sirfsoc_gpio_probe()
813 sgpio->chip.gc.of_gpio_n_cells = 2; in sirfsoc_gpio_probe()
814 sgpio->chip.gc.dev = &pdev->dev; in sirfsoc_gpio_probe()
815 sgpio->chip.regs = regs; in sirfsoc_gpio_probe()
817 err = gpiochip_add(&sgpio->chip.gc); in sirfsoc_gpio_probe()
824 err = gpiochip_irqchip_add(&sgpio->chip.gc, in sirfsoc_gpio_probe()
835 bank = &sgpio->sgpio_bank[i]; in sirfsoc_gpio_probe()
843 gpiochip_set_chained_irqchip(&sgpio->chip.gc, in sirfsoc_gpio_probe()
849 err = gpiochip_add_pin_range(&sgpio->chip.gc, dev_name(&pdev->dev), in sirfsoc_gpio_probe()
859 sirfsoc_gpio_set_pullup(sgpio, pullups); in sirfsoc_gpio_probe()
863 sirfsoc_gpio_set_pulldown(sgpio, pulldowns); in sirfsoc_gpio_probe()
869 gpiochip_remove(&sgpio->chip.gc); in sirfsoc_gpio_probe()