Commit f34fd6ee authored by Emil Renner Berthing's avatar Emil Renner Berthing Committed by Bartosz Golaszewski
Browse files

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: default avatarEmil Renner Berthing <emil.renner.berthing@canonical.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarSerge Semin <fancer.lancer@gmail.com>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 513246a3
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -416,13 +416,14 @@ static int dwapb_gpio_set_config(struct gpio_chip *gc, unsigned offset,
{
	u32 debounce;

	if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
		return -ENOTSUPP;

	if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
		debounce = pinconf_to_config_argument(config);
		return dwapb_gpio_set_debounce(gc, offset, debounce);
	}

	return gpiochip_generic_config(gc, offset, config);
}

static int dwapb_convert_irqs(struct dwapb_gpio_port_irqchip *pirq,
			      struct dwapb_port_property *pp)
{
@@ -530,10 +531,14 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio,
	port->gc.fwnode = pp->fwnode;
	port->gc.ngpio = pp->ngpio;
	port->gc.base = pp->gpio_base;
	port->gc.request = gpiochip_generic_request;
	port->gc.free = gpiochip_generic_free;

	/* Only port A support debounce */
	if (pp->idx == 0)
		port->gc.set_config = dwapb_gpio_set_config;
	else
		port->gc.set_config = gpiochip_generic_config;

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