Lines Matching +full:iproc +full:- +full:gpio +full:- +full:cca

1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/gpio/driver.h>
48 int pin = d->hwirq; in iproc_gpio_irq_ack()
50 u32 irq = d->irq; in iproc_gpio_irq_ack()
53 spin_lock_irqsave(&chip->lock, flags); in iproc_gpio_irq_ack()
58 chip->base + IPROC_GPIO_CCA_INT_EVENT); in iproc_gpio_irq_ack()
60 spin_unlock_irqrestore(&chip->lock, flags); in iproc_gpio_irq_ack()
67 int pin = d->hwirq; in iproc_gpio_irq_unmask()
69 u32 irq = d->irq; in iproc_gpio_irq_unmask()
73 spin_lock_irqsave(&chip->lock, flags); in iproc_gpio_irq_unmask()
75 event_mask = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); in iproc_gpio_irq_unmask()
76 int_mask = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); in iproc_gpio_irq_unmask()
81 chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); in iproc_gpio_irq_unmask()
85 chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); in iproc_gpio_irq_unmask()
87 spin_unlock_irqrestore(&chip->lock, flags); in iproc_gpio_irq_unmask()
94 int pin = d->hwirq; in iproc_gpio_irq_mask()
96 u32 irq = d->irq; in iproc_gpio_irq_mask()
99 spin_lock_irqsave(&chip->lock, flags); in iproc_gpio_irq_mask()
101 event_mask = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); in iproc_gpio_irq_mask()
102 int_mask = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); in iproc_gpio_irq_mask()
107 chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); in iproc_gpio_irq_mask()
111 chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); in iproc_gpio_irq_mask()
113 spin_unlock_irqrestore(&chip->lock, flags); in iproc_gpio_irq_mask()
121 int pin = d->hwirq; in iproc_gpio_irq_set_type()
123 u32 irq = d->irq; in iproc_gpio_irq_set_type()
127 spin_lock_irqsave(&chip->lock, flags); in iproc_gpio_irq_set_type()
130 event_pol = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EDGE); in iproc_gpio_irq_set_type()
132 writel_relaxed(event_pol, chip->base + IPROC_GPIO_CCA_INT_EDGE); in iproc_gpio_irq_set_type()
135 event_pol = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EDGE); in iproc_gpio_irq_set_type()
137 writel_relaxed(event_pol, chip->base + IPROC_GPIO_CCA_INT_EDGE); in iproc_gpio_irq_set_type()
140 int_pol = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_LEVEL); in iproc_gpio_irq_set_type()
142 writel_relaxed(int_pol, chip->base + IPROC_GPIO_CCA_INT_LEVEL); in iproc_gpio_irq_set_type()
145 int_pol = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_LEVEL); in iproc_gpio_irq_set_type()
147 writel_relaxed(int_pol, chip->base + IPROC_GPIO_CCA_INT_LEVEL); in iproc_gpio_irq_set_type()
151 ret = -EINVAL; in iproc_gpio_irq_set_type()
161 spin_unlock_irqrestore(&chip->lock, flags); in iproc_gpio_irq_set_type()
175 int_status = readl_relaxed(chip->intr + IPROC_CCA_INT_STS); in iproc_gpio_irq_handler()
181 readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); in iproc_gpio_irq_handler()
182 event &= readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EVENT); in iproc_gpio_irq_handler()
183 level = readl_relaxed(chip->base + IPROC_GPIO_CCA_DIN); in iproc_gpio_irq_handler()
184 level ^= readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_LEVEL); in iproc_gpio_irq_handler()
186 readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); in iproc_gpio_irq_handler()
189 for_each_set_bit(bit, &int_bits, gc->ngpio) in iproc_gpio_irq_handler()
190 generic_handle_domain_irq(gc->irq.domain, bit); in iproc_gpio_irq_handler()
201 seq_printf(p, dev_name(chip->dev)); in iproc_gpio_irq_print_chip()
216 struct device *dev = &pdev->dev; in iproc_gpio_probe()
217 struct device_node *dn = pdev->dev.of_node; in iproc_gpio_probe()
224 return -ENOMEM; in iproc_gpio_probe()
226 chip->dev = dev; in iproc_gpio_probe()
228 spin_lock_init(&chip->lock); in iproc_gpio_probe()
230 chip->base = devm_platform_ioremap_resource(pdev, 0); in iproc_gpio_probe()
231 if (IS_ERR(chip->base)) in iproc_gpio_probe()
232 return PTR_ERR(chip->base); in iproc_gpio_probe()
234 ret = bgpio_init(&chip->gc, dev, 4, in iproc_gpio_probe()
235 chip->base + IPROC_GPIO_CCA_DIN, in iproc_gpio_probe()
236 chip->base + IPROC_GPIO_CCA_DOUT, in iproc_gpio_probe()
238 chip->base + IPROC_GPIO_CCA_OUT_EN, in iproc_gpio_probe()
242 dev_err(dev, "unable to init GPIO chip\n"); in iproc_gpio_probe()
246 chip->gc.label = dev_name(dev); in iproc_gpio_probe()
248 chip->gc.ngpio = num_gpios; in iproc_gpio_probe()
255 chip->intr = devm_platform_ioremap_resource(pdev, 1); in iproc_gpio_probe()
256 if (IS_ERR(chip->intr)) in iproc_gpio_probe()
257 return PTR_ERR(chip->intr); in iproc_gpio_probe()
259 /* Enable GPIO interrupts for CCA GPIO */ in iproc_gpio_probe()
260 val = readl_relaxed(chip->intr + IPROC_CCA_INT_MASK); in iproc_gpio_probe()
262 writel_relaxed(val, chip->intr + IPROC_CCA_INT_MASK); in iproc_gpio_probe()
266 * a flow-handler because the irq is shared. in iproc_gpio_probe()
269 IRQF_SHARED, chip->gc.label, &chip->gc); in iproc_gpio_probe()
275 girq = &chip->gc.irq; in iproc_gpio_probe()
278 girq->parent_handler = NULL; in iproc_gpio_probe()
279 girq->num_parents = 0; in iproc_gpio_probe()
280 girq->parents = NULL; in iproc_gpio_probe()
281 girq->default_type = IRQ_TYPE_NONE; in iproc_gpio_probe()
282 girq->handler = handle_simple_irq; in iproc_gpio_probe()
285 ret = devm_gpiochip_add_data(dev, &chip->gc, chip); in iproc_gpio_probe()
287 dev_err(dev, "unable to add GPIO chip\n"); in iproc_gpio_probe()
298 if (chip->intr) { in iproc_gpio_remove()
301 val = readl_relaxed(chip->intr + IPROC_CCA_INT_MASK); in iproc_gpio_remove()
303 writel_relaxed(val, chip->intr + IPROC_CCA_INT_MASK); in iproc_gpio_remove()
308 { .compatible = "brcm,iproc-gpio-cca" },
315 .name = "iproc-xgs-gpio",
324 MODULE_DESCRIPTION("XGS IPROC GPIO driver");