Lines Matching +full:gpio +full:- +full:ctrl

1 // SPDX-License-Identifier: GPL-2.0
5 #include <linux/gpio/driver.h>
23 void __iomem *gpio; member
30 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); in idt_gpio_dispatch() local
37 pending = readl(ctrl->pic + IDT_PIC_IRQ_PEND); in idt_gpio_dispatch()
38 pending &= ~ctrl->mask_cache; in idt_gpio_dispatch()
39 for_each_set_bit(bit, &pending, gc->ngpio) { in idt_gpio_dispatch()
40 virq = irq_linear_revmap(gc->irq.domain, bit); in idt_gpio_dispatch()
51 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); in idt_gpio_irq_set_type() local
58 return -EINVAL; in idt_gpio_irq_set_type()
60 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); in idt_gpio_irq_set_type()
62 ilevel = readl(ctrl->gpio + IDT_GPIO_ILEVEL); in idt_gpio_irq_set_type()
64 ilevel |= BIT(d->hwirq); in idt_gpio_irq_set_type()
66 ilevel &= ~BIT(d->hwirq); in idt_gpio_irq_set_type()
68 writel(ilevel, ctrl->gpio + IDT_GPIO_ILEVEL); in idt_gpio_irq_set_type()
71 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); in idt_gpio_irq_set_type()
78 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); in idt_gpio_ack() local
80 writel(~BIT(d->hwirq), ctrl->gpio + IDT_GPIO_ISTAT); in idt_gpio_ack()
86 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); in idt_gpio_mask() local
89 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); in idt_gpio_mask()
91 ctrl->mask_cache |= BIT(d->hwirq); in idt_gpio_mask()
92 writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); in idt_gpio_mask()
94 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); in idt_gpio_mask()
102 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); in idt_gpio_unmask() local
106 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); in idt_gpio_unmask()
108 ctrl->mask_cache &= ~BIT(d->hwirq); in idt_gpio_unmask()
109 writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); in idt_gpio_unmask()
111 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); in idt_gpio_unmask()
116 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); in idt_gpio_irq_init_hw() local
119 ctrl->mask_cache = 0xffffffff; in idt_gpio_irq_init_hw()
120 writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); in idt_gpio_irq_init_hw()
137 struct device *dev = &pdev->dev; in idt_gpio_probe()
139 struct idt_gpio_ctrl *ctrl; in idt_gpio_probe() local
145 ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); in idt_gpio_probe()
146 if (!ctrl) in idt_gpio_probe()
147 return -ENOMEM; in idt_gpio_probe()
149 ctrl->gpio = devm_platform_ioremap_resource_byname(pdev, "gpio"); in idt_gpio_probe()
150 if (IS_ERR(ctrl->gpio)) in idt_gpio_probe()
151 return PTR_ERR(ctrl->gpio); in idt_gpio_probe()
153 ctrl->gc.parent = dev; in idt_gpio_probe()
155 ret = bgpio_init(&ctrl->gc, &pdev->dev, 4, ctrl->gpio + IDT_GPIO_DATA, in idt_gpio_probe()
156 NULL, NULL, ctrl->gpio + IDT_GPIO_DIR, NULL, 0); in idt_gpio_probe()
164 ctrl->gc.ngpio = ngpios; in idt_gpio_probe()
166 if (device_property_read_bool(dev, "interrupt-controller")) { in idt_gpio_probe()
167 ctrl->pic = devm_platform_ioremap_resource_byname(pdev, "pic"); in idt_gpio_probe()
168 if (IS_ERR(ctrl->pic)) in idt_gpio_probe()
169 return PTR_ERR(ctrl->pic); in idt_gpio_probe()
175 girq = &ctrl->gc.irq; in idt_gpio_probe()
177 girq->init_hw = idt_gpio_irq_init_hw; in idt_gpio_probe()
178 girq->parent_handler = idt_gpio_dispatch; in idt_gpio_probe()
179 girq->num_parents = 1; in idt_gpio_probe()
180 girq->parents = devm_kcalloc(dev, girq->num_parents, in idt_gpio_probe()
181 sizeof(*girq->parents), in idt_gpio_probe()
183 if (!girq->parents) in idt_gpio_probe()
184 return -ENOMEM; in idt_gpio_probe()
186 girq->parents[0] = parent_irq; in idt_gpio_probe()
187 girq->default_type = IRQ_TYPE_NONE; in idt_gpio_probe()
188 girq->handler = handle_bad_irq; in idt_gpio_probe()
191 return devm_gpiochip_add_data(&pdev->dev, &ctrl->gc, ctrl); in idt_gpio_probe()
195 { .compatible = "idt,32434-gpio" },
203 .name = "idt3243x-gpio",
209 MODULE_DESCRIPTION("IDT 79RC3243x GPIO/PIC Driver");