Lines Matching +full:flags +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2007-2009 Andres Salomon <dilinger@collabora.co.uk>
17 #define DRV_NAME "cs5535-gpio"
21 * 31-29,23 : reserved (always mask out)
24 * 22-16 : LPC
33 * If a mask was not specified, allow all except
38 static ulong mask = GPIO_DEFAULT_MASK; variable
39 module_param_named(mask, mask, ulong, 0444);
40 MODULE_PARM_DESC(mask, "GPIO channel mask.");
44 * design pattern, see Documentation/driver-api/driver-model/design-patterns.rst
63 unsigned long addr = chip->base + 0x80 + reg; in errata_outl()
68 * non-selected bits; the recommended workaround is a in errata_outl()
69 * read-modify-write operation. in errata_outl()
88 outl(1 << offset, chip->base + reg); in __cs5535_gpio_set()
91 errata_outl(chip, 1 << (offset - 16), reg); in __cs5535_gpio_set()
97 unsigned long flags; in cs5535_gpio_set() local
99 spin_lock_irqsave(&chip->lock, flags); in cs5535_gpio_set()
101 spin_unlock_irqrestore(&chip->lock, flags); in cs5535_gpio_set()
110 outl(1 << (offset + 16), chip->base + reg); in __cs5535_gpio_clear()
119 unsigned long flags; in cs5535_gpio_clear() local
121 spin_lock_irqsave(&chip->lock, flags); in cs5535_gpio_clear()
123 spin_unlock_irqrestore(&chip->lock, flags); in cs5535_gpio_clear()
130 unsigned long flags; in cs5535_gpio_isset() local
133 spin_lock_irqsave(&chip->lock, flags); in cs5535_gpio_isset()
136 val = inl(chip->base + reg); in cs5535_gpio_isset()
139 val = inl(chip->base + 0x80 + reg); in cs5535_gpio_isset()
140 offset -= 16; in cs5535_gpio_isset()
142 spin_unlock_irqrestore(&chip->lock, flags); in cs5535_gpio_isset()
153 return -EINVAL; in cs5535_gpio_set_irq()
169 unsigned long flags; in cs5535_gpio_setup_event() local
181 spin_lock_irqsave(&chip->lock, flags); in cs5535_gpio_setup_event()
182 val = inl(chip->base + offset); in cs5535_gpio_setup_event()
194 outl(val, chip->base + offset); in cs5535_gpio_setup_event()
195 spin_unlock_irqrestore(&chip->lock, flags); in cs5535_gpio_setup_event()
206 unsigned long flags; in chip_gpio_request() local
208 spin_lock_irqsave(&chip->lock, flags); in chip_gpio_request()
211 if ((mask & (1 << offset)) == 0) { in chip_gpio_request()
212 dev_info(&chip->pdev->dev, in chip_gpio_request()
213 "pin %u is not available (check mask)\n", offset); in chip_gpio_request()
214 spin_unlock_irqrestore(&chip->lock, flags); in chip_gpio_request()
215 return -EINVAL; in chip_gpio_request()
225 spin_unlock_irqrestore(&chip->lock, flags); in chip_gpio_request()
246 unsigned long flags; in chip_direction_input() local
248 spin_lock_irqsave(&chip->lock, flags); in chip_direction_input()
251 spin_unlock_irqrestore(&chip->lock, flags); in chip_direction_input()
259 unsigned long flags; in chip_direction_output() local
261 spin_lock_irqsave(&chip->lock, flags); in chip_direction_output()
270 spin_unlock_irqrestore(&chip->lock, flags); in chip_direction_output()
307 int err = -EIO; in cs5535_gpio_probe()
308 ulong mask_orig = mask; in cs5535_gpio_probe()
319 dev_err(&pdev->dev, "can't fetch device resource info\n"); in cs5535_gpio_probe()
323 if (!devm_request_region(&pdev->dev, res->start, resource_size(res), in cs5535_gpio_probe()
324 pdev->name)) { in cs5535_gpio_probe()
325 dev_err(&pdev->dev, "can't request region\n"); in cs5535_gpio_probe()
329 /* set up the driver-specific struct */ in cs5535_gpio_probe()
330 cs5535_gpio_chip.base = res->start; in cs5535_gpio_probe()
334 dev_info(&pdev->dev, "reserved resource region %pR\n", res); in cs5535_gpio_probe()
336 /* mask out reserved pins */ in cs5535_gpio_probe()
337 mask &= 0x1F7FFFFF; in cs5535_gpio_probe()
341 mask &= ~(1 << 28); in cs5535_gpio_probe()
343 if (mask_orig != mask) in cs5535_gpio_probe()
344 dev_info(&pdev->dev, "mask changed from 0x%08lX to 0x%08lX\n", in cs5535_gpio_probe()
345 mask_orig, mask); in cs5535_gpio_probe()
348 return devm_gpiochip_add_data(&pdev->dev, &cs5535_gpio_chip.chip, in cs5535_gpio_probe()