Skip to content

Commit f34fd6e

Browse files
esmilBartosz Golaszewski
authored andcommitted
gpio: dwapb: Use generic request, free and set_config
This way GPIO will be denied on pins already claimed by other devices and basic pin configuration (pull-up, pull-down etc.) can be done through the userspace GPIO API. Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Serge Semin <fancer.lancer@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 513246a commit f34fd6e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

drivers/gpio/gpio-dwapb.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,12 @@ static int dwapb_gpio_set_config(struct gpio_chip *gc, unsigned offset,
416416
{
417417
u32 debounce;
418418

419-
if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
420-
return -ENOTSUPP;
419+
if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
420+
debounce = pinconf_to_config_argument(config);
421+
return dwapb_gpio_set_debounce(gc, offset, debounce);
422+
}
421423

422-
debounce = pinconf_to_config_argument(config);
423-
return dwapb_gpio_set_debounce(gc, offset, debounce);
424+
return gpiochip_generic_config(gc, offset, config);
424425
}
425426

426427
static int dwapb_convert_irqs(struct dwapb_gpio_port_irqchip *pirq,
@@ -530,10 +531,14 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
530531
port->gc.fwnode = pp->fwnode;
531532
port->gc.ngpio = pp->ngpio;
532533
port->gc.base = pp->gpio_base;
534+
port->gc.request = gpiochip_generic_request;
535+
port->gc.free = gpiochip_generic_free;
533536

534537
/* Only port A support debounce */
535538
if (pp->idx == 0)
536539
port->gc.set_config = dwapb_gpio_set_config;
540+
else
541+
port->gc.set_config = gpiochip_generic_config;
537542

538543
/* Only port A can provide interrupts in all configurations of the IP */
539544
if (pp->idx == 0)

0 commit comments

Comments
 (0)