Lines Matching +full:ep9301 +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0
3 * Generic EP93xx GPIO handling
9 * linux/arch/arm/mach-ep93xx/core.c
19 #include <linux/gpio/driver.h>
44 return egc->eic; in to_ep93xx_gpio_irq_chip()
48 * Interrupt handling for EP93xx on-chip GPIOs
60 writeb_relaxed(0, eic->base + EP93XX_INT_EN_OFFSET); in ep93xx_gpio_update_int_params()
62 writeb_relaxed(eic->int_type2, in ep93xx_gpio_update_int_params()
63 eic->base + EP93XX_INT_TYPE2_OFFSET); in ep93xx_gpio_update_int_params()
65 writeb_relaxed(eic->int_type1, in ep93xx_gpio_update_int_params()
66 eic->base + EP93XX_INT_TYPE1_OFFSET); in ep93xx_gpio_update_int_params()
68 writeb_relaxed(eic->int_unmasked & eic->int_enabled, in ep93xx_gpio_update_int_params()
69 eic->base + EP93XX_INT_EN_OFFSET); in ep93xx_gpio_update_int_params()
79 eic->int_debounce |= port_mask; in ep93xx_gpio_int_debounce()
81 eic->int_debounce &= ~port_mask; in ep93xx_gpio_int_debounce()
83 writeb(eic->int_debounce, eic->base + EP93XX_INT_DEBOUNCE_OFFSET); in ep93xx_gpio_int_debounce()
92 stat = readb(eic->base + EP93XX_INT_STATUS_OFFSET); in ep93xx_gpio_ab_irq_handler()
94 generic_handle_domain_irq(gc->irq.domain, offset); in ep93xx_gpio_ab_irq_handler()
108 struct gpio_irq_chip *gic = &gc->irq; in ep93xx_gpio_f_irq_handler()
113 for (i = 0; i < gic->num_parents; i++) in ep93xx_gpio_f_irq_handler()
114 if (gic->parents[i] == parent) in ep93xx_gpio_f_irq_handler()
117 if (i < gic->num_parents) in ep93xx_gpio_f_irq_handler()
118 generic_handle_domain_irq(gc->irq.domain, i); in ep93xx_gpio_f_irq_handler()
130 eic->int_type2 ^= port_mask; /* switch edge direction */ in ep93xx_gpio_irq_ack()
134 writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET); in ep93xx_gpio_irq_ack()
145 eic->int_type2 ^= port_mask; /* switch edge direction */ in ep93xx_gpio_irq_mask_ack()
147 eic->int_unmasked &= ~port_mask; in ep93xx_gpio_irq_mask_ack()
150 writeb(port_mask, eic->base + EP93XX_INT_EOI_OFFSET); in ep93xx_gpio_irq_mask_ack()
160 eic->int_unmasked &= ~BIT(hwirq); in ep93xx_gpio_irq_mask()
172 eic->int_unmasked |= BIT(hwirq); in ep93xx_gpio_irq_unmask()
189 gc->direction_input(gc, hwirq); in ep93xx_gpio_irq_type()
193 eic->int_type1 |= port_mask; in ep93xx_gpio_irq_type()
194 eic->int_type2 |= port_mask; in ep93xx_gpio_irq_type()
198 eic->int_type1 |= port_mask; in ep93xx_gpio_irq_type()
199 eic->int_type2 &= ~port_mask; in ep93xx_gpio_irq_type()
203 eic->int_type1 &= ~port_mask; in ep93xx_gpio_irq_type()
204 eic->int_type2 |= port_mask; in ep93xx_gpio_irq_type()
208 eic->int_type1 &= ~port_mask; in ep93xx_gpio_irq_type()
209 eic->int_type2 &= ~port_mask; in ep93xx_gpio_irq_type()
213 eic->int_type1 |= port_mask; in ep93xx_gpio_irq_type()
215 if (gc->get(gc, hwirq)) in ep93xx_gpio_irq_type()
216 eic->int_type2 &= ~port_mask; /* falling */ in ep93xx_gpio_irq_type()
218 eic->int_type2 |= port_mask; /* rising */ in ep93xx_gpio_irq_type()
222 return -EINVAL; in ep93xx_gpio_irq_type()
227 eic->int_enabled |= port_mask; in ep93xx_gpio_irq_type()
240 return -ENOTSUPP; in ep93xx_gpio_set_config()
252 seq_printf(p, dev_name(gc->parent)); in ep93xx_irq_print_chip()
256 .name = "ep93xx-gpio-eic",
270 struct gpio_chip *gc = &egc->gc; in ep93xx_setup_irqs()
271 struct device *dev = &pdev->dev; in ep93xx_setup_irqs()
272 struct gpio_irq_chip *girq = &gc->irq; in ep93xx_setup_irqs()
280 gc->set_config = ep93xx_gpio_set_config; in ep93xx_setup_irqs()
281 egc->eic = devm_kzalloc(dev, sizeof(*egc->eic), GFP_KERNEL); in ep93xx_setup_irqs()
282 if (!egc->eic) in ep93xx_setup_irqs()
283 return -ENOMEM; in ep93xx_setup_irqs()
285 egc->eic->base = intr; in ep93xx_setup_irqs()
287 girq->num_parents = platform_irq_count(pdev); in ep93xx_setup_irqs()
288 if (girq->num_parents == 0) in ep93xx_setup_irqs()
289 return -EINVAL; in ep93xx_setup_irqs()
291 girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents), in ep93xx_setup_irqs()
293 if (!girq->parents) in ep93xx_setup_irqs()
294 return -ENOMEM; in ep93xx_setup_irqs()
296 if (girq->num_parents == 1) { /* A/B irqchips */ in ep93xx_setup_irqs()
302 IRQF_SHARED, gc->label, gc); in ep93xx_setup_irqs()
306 girq->parents[0] = irq; in ep93xx_setup_irqs()
308 girq->parent_handler = ep93xx_gpio_f_irq_handler; in ep93xx_setup_irqs()
310 for (i = 0; i < girq->num_parents; i++) { in ep93xx_setup_irqs()
315 girq->parents[i] = irq; in ep93xx_setup_irqs()
318 girq->map = girq->parents; in ep93xx_setup_irqs()
321 girq->default_type = IRQ_TYPE_NONE; in ep93xx_setup_irqs()
323 girq->handler = handle_simple_irq; in ep93xx_setup_irqs()
336 egc = devm_kzalloc(&pdev->dev, sizeof(*egc), GFP_KERNEL); in ep93xx_gpio_probe()
338 return -ENOMEM; in ep93xx_gpio_probe()
348 gc = &egc->gc; in ep93xx_gpio_probe()
349 ret = bgpio_init(gc, &pdev->dev, 1, data, NULL, NULL, dir, NULL, 0); in ep93xx_gpio_probe()
351 return dev_err_probe(&pdev->dev, ret, "unable to init generic GPIO\n"); in ep93xx_gpio_probe()
353 gc->label = dev_name(&pdev->dev); in ep93xx_gpio_probe()
355 dev_dbg(&pdev->dev, "setting up irqs for %s\n", dev_name(&pdev->dev)); in ep93xx_gpio_probe()
358 dev_err_probe(&pdev->dev, ret, "setup irqs failed"); in ep93xx_gpio_probe()
361 return devm_gpiochip_add_data(&pdev->dev, gc, egc); in ep93xx_gpio_probe()
365 { .compatible = "cirrus,ep9301-gpio" },
371 .name = "gpio-ep93xx",
385 MODULE_DESCRIPTION("EP93XX GPIO driver");