Lines Matching +full:lock +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/gpio/gpio-mb86s7x.c
23 #include "gpiolib-acpi.h"
33 #define OFFSET(x) BIT((x) % 8) macro
38 spinlock_t lock; member
47 spin_lock_irqsave(&gchip->lock, flags); in mb86s70_gpio_request()
49 val = readl(gchip->base + PFR(gpio)); in mb86s70_gpio_request()
50 val &= ~OFFSET(gpio); in mb86s70_gpio_request()
51 writel(val, gchip->base + PFR(gpio)); in mb86s70_gpio_request()
53 spin_unlock_irqrestore(&gchip->lock, flags); in mb86s70_gpio_request()
64 spin_lock_irqsave(&gchip->lock, flags); in mb86s70_gpio_free()
66 val = readl(gchip->base + PFR(gpio)); in mb86s70_gpio_free()
67 val |= OFFSET(gpio); in mb86s70_gpio_free()
68 writel(val, gchip->base + PFR(gpio)); in mb86s70_gpio_free()
70 spin_unlock_irqrestore(&gchip->lock, flags); in mb86s70_gpio_free()
79 spin_lock_irqsave(&gchip->lock, flags); in mb86s70_gpio_direction_input()
81 val = readl(gchip->base + DDR(gpio)); in mb86s70_gpio_direction_input()
82 val &= ~OFFSET(gpio); in mb86s70_gpio_direction_input()
83 writel(val, gchip->base + DDR(gpio)); in mb86s70_gpio_direction_input()
85 spin_unlock_irqrestore(&gchip->lock, flags); in mb86s70_gpio_direction_input()
97 spin_lock_irqsave(&gchip->lock, flags); in mb86s70_gpio_direction_output()
99 val = readl(gchip->base + PDR(gpio)); in mb86s70_gpio_direction_output()
101 val |= OFFSET(gpio); in mb86s70_gpio_direction_output()
103 val &= ~OFFSET(gpio); in mb86s70_gpio_direction_output()
104 writel(val, gchip->base + PDR(gpio)); in mb86s70_gpio_direction_output()
106 val = readl(gchip->base + DDR(gpio)); in mb86s70_gpio_direction_output()
107 val |= OFFSET(gpio); in mb86s70_gpio_direction_output()
108 writel(val, gchip->base + DDR(gpio)); in mb86s70_gpio_direction_output()
110 spin_unlock_irqrestore(&gchip->lock, flags); in mb86s70_gpio_direction_output()
119 return !!(readl(gchip->base + PDR(gpio)) & OFFSET(gpio)); in mb86s70_gpio_get()
128 spin_lock_irqsave(&gchip->lock, flags); in mb86s70_gpio_set()
130 val = readl(gchip->base + PDR(gpio)); in mb86s70_gpio_set()
132 val |= OFFSET(gpio); in mb86s70_gpio_set()
134 val &= ~OFFSET(gpio); in mb86s70_gpio_set()
135 writel(val, gchip->base + PDR(gpio)); in mb86s70_gpio_set()
137 spin_unlock_irqrestore(&gchip->lock, flags); in mb86s70_gpio_set()
140 static int mb86s70_gpio_to_irq(struct gpio_chip *gc, unsigned int offset) in mb86s70_gpio_to_irq() argument
145 irq = platform_get_irq(to_platform_device(gc->parent), index); in mb86s70_gpio_to_irq()
150 if (irq_get_irq_data(irq)->hwirq == offset) in mb86s70_gpio_to_irq()
153 return -EINVAL; in mb86s70_gpio_to_irq()
162 gchip = devm_kzalloc(&pdev->dev, sizeof(*gchip), GFP_KERNEL); in mb86s70_gpio_probe()
164 return -ENOMEM; in mb86s70_gpio_probe()
168 gchip->base = devm_platform_ioremap_resource(pdev, 0); in mb86s70_gpio_probe()
169 if (IS_ERR(gchip->base)) in mb86s70_gpio_probe()
170 return PTR_ERR(gchip->base); in mb86s70_gpio_probe()
172 clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); in mb86s70_gpio_probe()
176 spin_lock_init(&gchip->lock); in mb86s70_gpio_probe()
178 gchip->gc.direction_output = mb86s70_gpio_direction_output; in mb86s70_gpio_probe()
179 gchip->gc.direction_input = mb86s70_gpio_direction_input; in mb86s70_gpio_probe()
180 gchip->gc.request = mb86s70_gpio_request; in mb86s70_gpio_probe()
181 gchip->gc.free = mb86s70_gpio_free; in mb86s70_gpio_probe()
182 gchip->gc.get = mb86s70_gpio_get; in mb86s70_gpio_probe()
183 gchip->gc.set = mb86s70_gpio_set; in mb86s70_gpio_probe()
184 gchip->gc.to_irq = mb86s70_gpio_to_irq; in mb86s70_gpio_probe()
185 gchip->gc.label = dev_name(&pdev->dev); in mb86s70_gpio_probe()
186 gchip->gc.ngpio = 32; in mb86s70_gpio_probe()
187 gchip->gc.owner = THIS_MODULE; in mb86s70_gpio_probe()
188 gchip->gc.parent = &pdev->dev; in mb86s70_gpio_probe()
189 gchip->gc.base = -1; in mb86s70_gpio_probe()
191 ret = gpiochip_add_data(&gchip->gc, gchip); in mb86s70_gpio_probe()
193 return dev_err_probe(&pdev->dev, ret, in mb86s70_gpio_probe()
196 acpi_gpiochip_request_interrupts(&gchip->gc); in mb86s70_gpio_probe()
205 acpi_gpiochip_free_interrupts(&gchip->gc); in mb86s70_gpio_remove()
206 gpiochip_remove(&gchip->gc); in mb86s70_gpio_remove()
210 { .compatible = "fujitsu,mb86s70-gpio" },
225 .name = "mb86s70-gpio",
235 MODULE_ALIAS("platform:mb86s70-gpio");