1. 19 Feb, 2016 3 commits
    • Linus Walleij's avatar
      gpio: add userspace ABI for GPIO line information · 521a2ad6
      Linus Walleij authored
      This adds a GPIO line ABI for getting name, label and a few select
      flags from the kernel.
      
      This hides the kernel internals and only tells userspace what it
      may need to know: the different in-kernel consumers are masked
      behind the flag "kernel" and that is all userspace needs to know.
      
      However electric characteristics like active low, open drain etc
      are reflected to userspace, as this is important information.
      
      We provide information on all lines on all chips, later on we will
      likely add a flag for the chardev consumer so we can filter and
      display only the lines userspace actually uses in e.g. lsgpio,
      but then we first need an ABI for userspace to grab and use
      (get/set/select direction) a GPIO line.
      
      Sample output from "lsgpio" on ux500:
      
      GPIO chip: gpiochip7, "8011e000.gpio", 32 GPIO lines
              line 0: unnamed unlabeled
              line 1: unnamed unlabeled
      (...)
              line 25: unnamed "SFH7741 Proximity Sensor" [kernel output open-drain]
              line 26: unnamed unlabeled
      (...)
      Tested-by: default avatarMichael Welling <mwelling@ieee.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      521a2ad6
    • Linus Walleij's avatar
      gpio: store reflect the label to userspace · df4878e9
      Linus Walleij authored
      The gpio_chip label is useful for userspace to understand what
      kind of GPIO chip it is dealing with. Let's store a copy of this
      label in the gpio_device, add it to the struct passed to userspace
      for GPIO_GET_CHIPINFO_IOCTL and modify lsgpio to show it.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      df4878e9
    • Linus Walleij's avatar
      gpio: tps65218: remove unused #include · 0a7439ef
      Linus Walleij authored
      Just as it says: after adding the proper interfaces to gpiolib,
      this is no longer needed.
      Suggested-by: default avatarNicolas Saenz Julienne <nicolassaenzj@gmail.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      0a7439ef
  2. 18 Feb, 2016 5 commits
  3. 16 Feb, 2016 4 commits
  4. 15 Feb, 2016 15 commits
  5. 11 Feb, 2016 7 commits
    • Linus Walleij's avatar
      gpio: reference count the gpio device for each desc · 33a68e86
      Linus Walleij authored
      Every time a descriptor is retrieved from the gpiolib, we issue
      module_get() to reference count the module supplying the GPIOs.
      We also need to call device_get() and device_put() as we also
      reference the backing gpio_device when doing this.
      
      Since the sysfs GPIO interface is using gpiod_get() this will
      also reference count the sysfs requests until all GPIOs are
      unexported.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      33a68e86
    • Linus Walleij's avatar
      gpio: reflect base and ngpio into gpio_device · fdeb8e15
      Linus Walleij authored
      Some information about the GPIO chip need to stay around also
      after the gpio_chip has been removed and only the gpio_device
      persist. The base and ngpio are such things, for example we
      don't want a new chip arriving to overlap the number space
      of a dangling gpio_device, and the chardev may still query
      the device for the number of lines etc.
      
      Note that the code that assigns base and insert gpio_device
      into the global list no longer check for a missing gpio_chip:
      we respect the number space allocated by any other gpio_device.
      
      As a consequence of the gdev being referenced directly from
      the gpio_desc, we need to verify it differently from all
      in-kernel API calls that fall through to direct queries to
      the gpio_chip vtable: we first check that desc is !NULL, then
      that desc->gdev is !NULL, then, if desc->gdev->chip is NULL,
      we *BAIL OUT* without any error, so as to manage the case
      where operations are requested on a device that is gone.
      
      These checks were non-uniform and partly missing in the past:
      so to simplify: create the macros VALIDATE_DESC() that will
      return -EINVAL if the desc or desc->gdev is missing and just
      0 if the chip is gone, and conversely VALIDATE_DESC_VOID()
      for the case where the function does not return an error.
      By using these macros, we get warning messages about missing
      gdev with reference to the right function in the kernel log.
      
      Despite the macro business this simplifies the code and make
      it more readable than if we copy/paste the same descriptor
      checking code into all code ABI call sites (IMHO).
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      fdeb8e15
    • Linus Walleij's avatar
      gpio/pinctrl: sunxi: stop poking around in private vars · 6cee3821
      Linus Walleij authored
      This kind of hacks disturbs the refactoring of the gpiolib.
      
      The descriptor table belongs to the gpiolib, if we want to know
      something about something in it, use or define the proper accessor
      functions. Let's add this gpiochip_lins_is_irq() to do what the
      sunxi driver is trying at so we can privatize the descriptors
      properly.
      
      Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
      Cc: Chen-Yu Tsai <wens@csie.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      6cee3821
    • Linus Walleij's avatar
      gpio: move descriptors into gpio_device · 1c3cdb18
      Linus Walleij authored
      We need gpio_device to hold the descriptors so that they can
      be lifecycled with the struct gpio_device held from userspace.
      Move the descriptor array into gpio_device. Also rename it from
      "desc" (singularis) to "descs" (pluralis) to reflect the fact
      that it is an array.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      1c3cdb18
    • Linus Walleij's avatar
      gpio: move sysfs mock device to the gpio_device · afbc4f31
      Linus Walleij authored
      Since gpio_device is the struct that survives if the backing
      gpio_chip is removed, move the sysfs mock device to this state
      container so it becomes part of the dangling state of the
      GPIO device on removal.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      afbc4f31
    • Linus Walleij's avatar
      gpio: remember to finally free gpio_device · 9efd9e69
      Linus Walleij authored
      When the device core reference count for the device goes to
      0 and it calls .release() we free resources and so can also
      finally free up the GPIO state container, struct gpio_device.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      9efd9e69
    • Nicolas Saenz Julienne's avatar
      gpio: add tps65218 gpio · c366c76a
      Nicolas Saenz Julienne authored
      Driver for the GPIO block found in ti's tps65218 pmics.
      
      The device has two GPIOs and one GPO pin which can be configured as follows:
      GPIO1:
      	-general-purpose, open-drain output controlled by GPO1 user bit and/or
      	 sequencer
      	-DDR3 reset input signal from SOC. Signal is either latched or
      	 passed-trough to GPO2 pin. See below for details.
      GPO2:
      	-general-purpose output controlled by GPO2 user bit
      	-DDR3 reset output signal. Signal is controlled by GPIO1 and PGOOD.
      	 See below for details.
      	-Output buffer can be configured as open-drain or push-pull.
      GPIO3:
      	-general-purpose, open-drain output controlled by GPO3 user bit and/or
      	 sequencer
      	-reset input-signal for DCDC1 and DCDC2.
      
      The input configurations are not meant to be used by the user so the driver
      only offers GPOs.
      
      v2: Added request routine that evaluates the fw config flags and removed module
          owner
      v3: Added .direction_input() routine, and took care of all Linus Walleij
      suggestions (clamp to bool, use proper include)
      Signed-off-by: default avatarNicolas Saenz Julienne <nicolassaenzj@gmail.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      c366c76a
  6. 10 Feb, 2016 6 commits