Lines Matching +full:i +full:- +full:drive
1 // SPDX-License-Identifier: GPL-2.0-or-later
10 * - GPIO interrupt support
11 * - Pin pad configuration (pull up/down, strength)
23 #include <linux/pinctrl/pinconf-generic.h>
27 #include "pinctrl-utils.h"
29 #define DRIVER_NAME "pinctrl-digicolor"
36 #define PIN_COLLECTIONS ('R' - 'A' + 1)
63 return pmap->desc->pins[selector].name; in dc_get_group_name()
72 *pins = &pmap->desc->pins[selector].number; in dc_get_group_pins()
109 *groups = pmap->pin_names; in dc_get_groups()
121 *bit -= PINS_PER_COLLECTION; in dc_client_sel()
135 reg = readb_relaxed(pmap->regs + reg_off); in dc_set_mux()
138 writeb_relaxed(reg, pmap->regs + reg_off); in dc_set_mux()
153 reg = readb_relaxed(pmap->regs + reg_off); in dc_pmx_request_gpio()
155 return -EBUSY; in dc_pmx_request_gpio()
173 u8 drive; in dc_gpio_direction_input() local
176 spin_lock_irqsave(&pmap->lock, flags); in dc_gpio_direction_input()
177 drive = readb_relaxed(pmap->regs + reg_off); in dc_gpio_direction_input()
178 drive &= ~BIT(bit_off); in dc_gpio_direction_input()
179 writeb_relaxed(drive, pmap->regs + reg_off); in dc_gpio_direction_input()
180 spin_unlock_irqrestore(&pmap->lock, flags); in dc_gpio_direction_input()
193 u8 drive; in dc_gpio_direction_output() local
198 spin_lock_irqsave(&pmap->lock, flags); in dc_gpio_direction_output()
199 drive = readb_relaxed(pmap->regs + reg_off); in dc_gpio_direction_output()
200 drive |= BIT(bit_off); in dc_gpio_direction_output()
201 writeb_relaxed(drive, pmap->regs + reg_off); in dc_gpio_direction_output()
202 spin_unlock_irqrestore(&pmap->lock, flags); in dc_gpio_direction_output()
214 input = readb_relaxed(pmap->regs + reg_off); in dc_gpio_get()
227 spin_lock_irqsave(&pmap->lock, flags); in dc_gpio_set()
228 output = readb_relaxed(pmap->regs + reg_off); in dc_gpio_set()
233 writeb_relaxed(output, pmap->regs + reg_off); in dc_gpio_set()
234 spin_unlock_irqrestore(&pmap->lock, flags); in dc_gpio_set()
239 struct gpio_chip *chip = &pmap->chip; in dc_gpiochip_add()
242 chip->label = DRIVER_NAME; in dc_gpiochip_add()
243 chip->parent = pmap->dev; in dc_gpiochip_add()
244 chip->request = gpiochip_generic_request; in dc_gpiochip_add()
245 chip->free = gpiochip_generic_free; in dc_gpiochip_add()
246 chip->direction_input = dc_gpio_direction_input; in dc_gpiochip_add()
247 chip->direction_output = dc_gpio_direction_output; in dc_gpiochip_add()
248 chip->get = dc_gpio_get; in dc_gpiochip_add()
249 chip->set = dc_gpio_set; in dc_gpiochip_add()
250 chip->base = -1; in dc_gpiochip_add()
251 chip->ngpio = PINS_COUNT; in dc_gpiochip_add()
253 spin_lock_init(&pmap->lock); in dc_gpiochip_add()
259 ret = gpiochip_add_pin_range(chip, dev_name(pmap->dev), 0, 0, in dc_gpiochip_add()
276 int i, j; in dc_pinctrl_probe() local
278 pmap = devm_kzalloc(&pdev->dev, sizeof(*pmap), GFP_KERNEL); in dc_pinctrl_probe()
280 return -ENOMEM; in dc_pinctrl_probe()
282 pmap->regs = devm_platform_ioremap_resource(pdev, 0); in dc_pinctrl_probe()
283 if (IS_ERR(pmap->regs)) in dc_pinctrl_probe()
284 return PTR_ERR(pmap->regs); in dc_pinctrl_probe()
286 pins = devm_kcalloc(&pdev->dev, PINS_COUNT, sizeof(*pins), in dc_pinctrl_probe()
289 return -ENOMEM; in dc_pinctrl_probe()
290 pin_names = devm_kcalloc(&pdev->dev, PINS_COUNT, name_len, in dc_pinctrl_probe()
293 return -ENOMEM; in dc_pinctrl_probe()
295 for (i = 0; i < PIN_COLLECTIONS; i++) { in dc_pinctrl_probe()
297 int pin_id = i*PINS_PER_COLLECTION + j; in dc_pinctrl_probe()
300 snprintf(name, name_len, "GP_%c%c", 'A'+i, '0'+j); in dc_pinctrl_probe()
304 pmap->pin_names[pin_id] = name; in dc_pinctrl_probe()
308 pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL); in dc_pinctrl_probe()
310 return -ENOMEM; in dc_pinctrl_probe()
312 pctl_desc->name = DRIVER_NAME, in dc_pinctrl_probe()
313 pctl_desc->owner = THIS_MODULE, in dc_pinctrl_probe()
314 pctl_desc->pctlops = &dc_pinctrl_ops, in dc_pinctrl_probe()
315 pctl_desc->pmxops = &dc_pmxops, in dc_pinctrl_probe()
316 pctl_desc->npins = PINS_COUNT; in dc_pinctrl_probe()
317 pctl_desc->pins = pins; in dc_pinctrl_probe()
318 pmap->desc = pctl_desc; in dc_pinctrl_probe()
320 pmap->dev = &pdev->dev; in dc_pinctrl_probe()
322 pmap->pctl = devm_pinctrl_register(&pdev->dev, pctl_desc, pmap); in dc_pinctrl_probe()
323 if (IS_ERR(pmap->pctl)) { in dc_pinctrl_probe()
324 dev_err(&pdev->dev, "pinctrl driver registration failed\n"); in dc_pinctrl_probe()
325 return PTR_ERR(pmap->pctl); in dc_pinctrl_probe()
332 { .compatible = "cnxt,cx92755-pinctrl" },