Lines Matching +full:edge +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-sa1100/gpio.c
5 * Generic SA-1100 GPIO handling
39 static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) in sa1100_gpio_get() argument
41 return readl_relaxed(sa1100_gpio_chip(chip)->membase + R_GPLR) & in sa1100_gpio_get()
42 BIT(offset); in sa1100_gpio_get()
45 static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) in sa1100_gpio_set() argument
49 writel_relaxed(BIT(offset), sa1100_gpio_chip(chip)->membase + reg); in sa1100_gpio_set()
52 static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset) in sa1100_get_direction() argument
54 void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR; in sa1100_get_direction()
56 if (readl_relaxed(gpdr) & BIT(offset)) in sa1100_get_direction()
62 static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset) in sa1100_direction_input() argument
64 void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR; in sa1100_direction_input()
68 writel_relaxed(readl_relaxed(gpdr) & ~BIT(offset), gpdr); in sa1100_direction_input()
74 static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value) in sa1100_direction_output() argument
76 void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR; in sa1100_direction_output()
80 sa1100_gpio_set(chip, offset, value); in sa1100_direction_output()
81 writel_relaxed(readl_relaxed(gpdr) | BIT(offset), gpdr); in sa1100_direction_output()
87 static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset) in sa1100_to_irq() argument
89 return sa1100_gpio_chip(chip)->irqbase + offset; in sa1100_to_irq()
109 * SA1100 GPIO edge detection for IRQs:
110 * IRQs are generated on Falling-Edge, Rising-Edge, or both.
115 void *base = sgc->membase; in sa1100_update_edge_regs()
118 grer = sgc->irqrising & sgc->irqmask; in sa1100_update_edge_regs()
119 gfer = sgc->irqfalling & sgc->irqmask; in sa1100_update_edge_regs()
128 unsigned int mask = BIT(d->hwirq); in sa1100_gpio_type()
131 if ((sgc->irqrising | sgc->irqfalling) & mask) in sa1100_gpio_type()
137 sgc->irqrising |= mask; in sa1100_gpio_type()
139 sgc->irqrising &= ~mask; in sa1100_gpio_type()
141 sgc->irqfalling |= mask; in sa1100_gpio_type()
143 sgc->irqfalling &= ~mask; in sa1100_gpio_type()
157 writel_relaxed(BIT(d->hwirq), sgc->membase + R_GEDR); in sa1100_gpio_ack()
163 unsigned int mask = BIT(d->hwirq); in sa1100_gpio_mask()
165 sgc->irqmask &= ~mask; in sa1100_gpio_mask()
173 unsigned int mask = BIT(d->hwirq); in sa1100_gpio_unmask()
175 sgc->irqmask |= mask; in sa1100_gpio_unmask()
183 int ret = sa11x0_gpio_set_wake(d->hwirq, on); in sa1100_gpio_wake()
186 sgc->irqwake |= BIT(d->hwirq); in sa1100_gpio_wake()
188 sgc->irqwake &= ~BIT(d->hwirq); in sa1100_gpio_wake()
208 struct sa1100_gpio_chip *sgc = d->host_data; in sa1100_gpio_irqdomain_map()
225 * IRQ 0-11 (GPIO) handler. We enter here with the
233 void __iomem *gedr = sgc->membase + R_GEDR; in sa1100_gpio_handler()
243 irq = sgc->irqbase; in sa1100_gpio_handler()
262 writel_relaxed(sgc->irqwake & sgc->irqrising, sgc->membase + R_GRER); in sa1100_gpio_suspend()
263 writel_relaxed(sgc->irqwake & sgc->irqfalling, sgc->membase + R_GFER); in sa1100_gpio_suspend()
268 writel_relaxed(readl_relaxed(sgc->membase + R_GEDR), in sa1100_gpio_suspend()
269 sgc->membase + R_GEDR); in sa1100_gpio_suspend()
293 /* Install handlers for GPIO 0-10 edge detect interrupts */
305 /* Install handler for GPIO 11-27 edge detect interrupts */
314 /* clear all GPIO edge detects */ in sa1100_init_gpio()
315 writel_relaxed(0, sgc->membase + R_GFER); in sa1100_init_gpio()
316 writel_relaxed(0, sgc->membase + R_GRER); in sa1100_init_gpio()
317 writel_relaxed(-1, sgc->membase + R_GEDR); in sa1100_init_gpio()