Lines Matching +full:gpio +full:- +full:latch
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/gpio/driver.h>
54 * The digital-chip EIC controller can support maximum 3 banks, and each bank
60 #define SPRD_EIC_BIT(x) ((x) & (SPRD_EIC_PER_BANK_NR - 1))
67 * The Spreadtrum digital-chip EIC controller contains 4 sub-modules:
68 * debounce EIC, latch EIC, async EIC and sync EIC,
71 * (millisecond resolution) and a single-trigger mechanism is introduced
72 * into this sub-module to enhance the input event detection reliability.
75 * The latch EIC is used to latch some special power down signals and
76 * generate interrupts, since the latch EIC does not depend on the APB clock
82 * The EIC-sync is similar with GPIO's input function, which is a synchronized
114 "eic-debounce", "eic-latch", "eic-async",
115 "eic-sync",
140 return sprd_eic->base[bank]; in sprd_eic_offset_base()
152 spin_lock_irqsave(&sprd_eic->lock, flags); in sprd_eic_update()
161 spin_unlock_irqrestore(&sprd_eic->lock, flags); in sprd_eic_update()
188 switch (sprd_eic->type) { in sprd_eic_get()
196 return -ENOTSUPP; in sprd_eic_get()
235 return -ENOTSUPP; in sprd_eic_set_config()
244 switch (sprd_eic->type) { in sprd_eic_irq_mask()
259 dev_err(chip->parent, "Unsupported EIC type.\n"); in sprd_eic_irq_mask()
273 switch (sprd_eic->type) { in sprd_eic_irq_unmask()
288 dev_err(chip->parent, "Unsupported EIC type.\n"); in sprd_eic_irq_unmask()
298 switch (sprd_eic->type) { in sprd_eic_irq_ack()
312 dev_err(chip->parent, "Unsupported EIC type.\n"); in sprd_eic_irq_ack()
323 switch (sprd_eic->type) { in sprd_eic_irq_set_type()
351 return -ENOTSUPP; in sprd_eic_irq_set_type()
383 return -ENOTSUPP; in sprd_eic_irq_set_type()
425 return -ENOTSUPP; in sprd_eic_irq_set_type()
465 return -ENOTSUPP; in sprd_eic_irq_set_type()
469 dev_err(chip->parent, "Unsupported EIC type.\n"); in sprd_eic_irq_set_type()
470 return -ENOTSUPP; in sprd_eic_irq_set_type()
485 * The debounce EIC and latch EIC can only support level trigger, so we in sprd_eic_toggle_trigger()
488 if ((sprd_eic->type != SPRD_EIC_DEBOUNCE && in sprd_eic_toggle_trigger()
489 sprd_eic->type != SPRD_EIC_LATCH) || in sprd_eic_toggle_trigger()
497 switch (sprd_eic->type) { in sprd_eic_toggle_trigger()
517 dev_warn(chip->parent, "EIC level was changed.\n"); in sprd_eic_toggle_trigger()
530 for (bank = 0; bank * SPRD_EIC_PER_BANK_NR < chip->ngpio; bank++) { in sprd_eic_handle_one_type()
534 switch (sprd_eic->type) { in sprd_eic_handle_one_type()
552 dev_err(chip->parent, "Unsupported EIC type.\n"); in sprd_eic_handle_one_type()
559 girq = irq_find_mapping(chip->irq.domain, offset); in sprd_eic_handle_one_type()
574 * Since the digital-chip EIC 4 sub-modules (debounce, latch, async in sprd_eic_irq_handler()
588 sprd_eic_handle_one_type(&sprd_eic->chip); in sprd_eic_irq_notify()
594 .name = "sprd-eic",
613 struct device *dev = &pdev->dev; in sprd_eic_probe()
623 return -EINVAL; in sprd_eic_probe()
628 return -ENOMEM; in sprd_eic_probe()
630 spin_lock_init(&sprd_eic->lock); in sprd_eic_probe()
631 sprd_eic->type = pdata->type; in sprd_eic_probe()
633 sprd_eic->irq = platform_get_irq(pdev, 0); in sprd_eic_probe()
634 if (sprd_eic->irq < 0) in sprd_eic_probe()
635 return sprd_eic->irq; in sprd_eic_probe()
648 sprd_eic->base[i] = devm_ioremap_resource(dev, res); in sprd_eic_probe()
649 if (IS_ERR(sprd_eic->base[i])) in sprd_eic_probe()
650 return PTR_ERR(sprd_eic->base[i]); in sprd_eic_probe()
655 sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type]; in sprd_eic_probe()
656 sprd_eic->chip.ngpio = num_banks * SPRD_EIC_PER_BANK_NR; in sprd_eic_probe()
657 sprd_eic->chip.base = -1; in sprd_eic_probe()
658 sprd_eic->chip.parent = dev; in sprd_eic_probe()
659 sprd_eic->chip.direction_input = sprd_eic_direction_input; in sprd_eic_probe()
660 switch (sprd_eic->type) { in sprd_eic_probe()
662 sprd_eic->chip.request = sprd_eic_request; in sprd_eic_probe()
663 sprd_eic->chip.free = sprd_eic_free; in sprd_eic_probe()
664 sprd_eic->chip.set_config = sprd_eic_set_config; in sprd_eic_probe()
665 sprd_eic->chip.set = sprd_eic_set; in sprd_eic_probe()
669 sprd_eic->chip.get = sprd_eic_get; in sprd_eic_probe()
676 irq = &sprd_eic->chip.irq; in sprd_eic_probe()
678 irq->handler = handle_bad_irq; in sprd_eic_probe()
679 irq->default_type = IRQ_TYPE_NONE; in sprd_eic_probe()
680 irq->parent_handler = sprd_eic_irq_handler; in sprd_eic_probe()
681 irq->parent_handler_data = sprd_eic; in sprd_eic_probe()
682 irq->num_parents = 1; in sprd_eic_probe()
683 irq->parents = &sprd_eic->irq; in sprd_eic_probe()
685 ret = devm_gpiochip_add_data(dev, &sprd_eic->chip, sprd_eic); in sprd_eic_probe()
691 sprd_eic->irq_nb.notifier_call = sprd_eic_irq_notify; in sprd_eic_probe()
693 &sprd_eic->irq_nb); in sprd_eic_probe()
699 &sprd_eic->irq_nb); in sprd_eic_probe()
704 .compatible = "sprd,sc9860-eic-debounce",
708 .compatible = "sprd,sc9860-eic-latch",
712 .compatible = "sprd,sc9860-eic-async",
716 .compatible = "sprd,sc9860-eic-sync",
728 .name = "sprd-eic",