Merge tag 'gpio-updates-for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 9 Dec 2020 14:17:24 +0000 (15:17 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 9 Dec 2020 14:17:24 +0000 (15:17 +0100)
gpio updates for v5.11-rc1

- several refactoring patches of the core gpiolib code
- add support for NXP PCAL9554B/C to gpio-pca953x
- allow probing mockup devices from device tree
- refactoring and improvements to gpio-rcar
- improvements to locking in gpio-tegra
- code shrink in gpiolib devres
- get the irq offset from device tree in gpio-sifive
- major refactoring of gpio-exar
- convert gpio-mvebu pwm access to regmap
- create a new submenu for virtual GPIO drivers
- fix clang fall-through warnings treewide
- minor driver refactoring and tweaks sprinkled all over

1  2 
drivers/gpio/Kconfig
drivers/gpio/gpio-dwapb.c
drivers/gpio/gpio-omap.c
drivers/gpio/gpio-sifive.c
drivers/gpio/gpiolib-acpi.c
drivers/gpio/gpiolib-cdev.c
drivers/gpio/gpiolib.c
drivers/gpio/gpiolib.h

Simple merge
Simple merge
Simple merge
Simple merge
@@@ -205,67 -205,6 +205,68 @@@ static void acpi_gpiochip_request_irqs(
                acpi_gpiochip_request_irq(acpi_gpio, event);
  }
  
 +static enum gpiod_flags
 +acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio, int polarity)
 +{
 +      /* GpioInt() implies input configuration */
 +      if (agpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT)
 +              return GPIOD_IN;
 +
 +      switch (agpio->io_restriction) {
 +      case ACPI_IO_RESTRICT_INPUT:
 +              return GPIOD_IN;
 +      case ACPI_IO_RESTRICT_OUTPUT:
 +              /*
 +               * ACPI GPIO resources don't contain an initial value for the
 +               * GPIO. Therefore we deduce that value from the pull field
 +               * and the polarity instead. If the pin is pulled up we assume
 +               * default to be high, if it is pulled down we assume default
 +               * to be low, otherwise we leave pin untouched. For active low
 +               * polarity values will be switched. See also
 +               * Documentation/firmware-guide/acpi/gpio-properties.rst.
 +               */
 +              switch (agpio->pin_config) {
 +              case ACPI_PIN_CONFIG_PULLUP:
 +                      return polarity == GPIO_ACTIVE_LOW ? GPIOD_OUT_LOW : GPIOD_OUT_HIGH;
 +              case ACPI_PIN_CONFIG_PULLDOWN:
 +                      return polarity == GPIO_ACTIVE_LOW ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
 +              default:
 +                      break;
 +              }
++              break;
 +      default:
 +              break;
 +      }
 +
 +      /*
 +       * Assume that the BIOS has configured the direction and pull
 +       * accordingly.
 +       */
 +      return GPIOD_ASIS;
 +}
 +
 +static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip,
 +                                              struct acpi_resource_gpio *agpio,
 +                                              unsigned int index,
 +                                              const char *label)
 +{
 +      int polarity = GPIO_ACTIVE_HIGH;
 +      enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio, polarity);
 +      unsigned int pin = agpio->pin_table[index];
 +      struct gpio_desc *desc;
 +      int ret;
 +
 +      desc = gpiochip_request_own_desc(chip, pin, label, polarity, flags);
 +      if (IS_ERR(desc))
 +              return desc;
 +
 +      ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
 +      if (ret)
 +              gpiochip_free_own_desc(desc);
 +
 +      return ret ? ERR_PTR(ret) : desc;
 +}
 +
  static bool acpi_gpio_in_ignore_list(const char *controller_in, int pin_in)
  {
        const char *controller, *pin_str;
Simple merge
Simple merge
Simple merge