1. 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
  2. 10 Feb, 2016 7 commits
  3. 09 Feb, 2016 7 commits
    • Linus Walleij's avatar
      Merge branch 'chardev' into devel · 60afe31d
      Linus Walleij authored
      60afe31d
    • Linus Walleij's avatar
      gpio: ABI: mark the sysfs ABI as obsolete · fe95046e
      Linus Walleij authored
      This marks the (optional) sysfs GPIO ABI as obsolete and schedules
      it for removal in 2020.
      
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Michael Welling <mwelling@ieee.org>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      fe95046e
    • Linus Walleij's avatar
      gpio: add a userspace character device ABI · 40c159b7
      Linus Walleij authored
      Put in some documentation for the new character device ABI
      so we can properly etch it in stone.
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      40c159b7
    • Linus Walleij's avatar
      tools/gpio: create GPIO tools · 6d591c46
      Linus Walleij authored
      This creates GPIO tools under tools/gpio/* and adds a single
      example program to list the GPIOs on a system. When proper
      devices are created it provides this minimal output:
      
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Michael Welling <mwelling@ieee.org>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      6d591c46
    • Linus Walleij's avatar
      gpio: add a userspace chardev ABI for GPIOs · 3c702e99
      Linus Walleij authored
      A new chardev that is to be used for userspace GPIO access is
      added in this patch. It is intended to gradually replace the
      horribly broken sysfs ABI.
      
      Using a chardev has many upsides:
      
      - All operations are per-gpiochip, which is the actual
        device underlying the GPIOs, making us tie in to the
        kernel device model properly.
      
      - Hotpluggable GPIO controllers can come and go, as this
        kind of problem has been know to userspace for character
        devices since ages, and if a gpiochip handle is held in
        userspace we know we will break something, whereas the
        sysfs is stateless.
      
      - The one-value-per-file rule of sysfs is really hard to
        maintain when you want to twist more than one knob at a time,
        for example have in-kernel APIs to switch several GPIO
        lines at the same time, and this will be possible to do
        with a single ioctl() from userspace, saving a lot of
        context switching.
      
      We also need to add a new bus type for GPIO. This is
      necessary for example for userspace coldplug, where sysfs is
      traversed to find the boot-time device nodes and create the
      character devices in /dev.
      
      This new chardev ABI is *non* *optional* and can be counted
      on to be present in the future, emphasizing the preference
      of this ABI.
      
      The ABI only implements one single ioctl() to get the name
      and number of GPIO lines of a chip. Even this is debatable:
      see it as a minimal example for review. This ABI shall be
      ruthlessly reviewed and etched in stone.
      
      The old /sys/class/gpio is still optional to compile in,
      but will be deprecated.
      
      Unique device IDs are created using IDR, which is overkill
      and insanely scalable, but also well tested.
      
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Michael Welling <mwelling@ieee.org>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      3c702e99
    • Linus Walleij's avatar
      gpio: refer to gpio device in prints and debugfs · 34ffd85d
      Linus Walleij authored
      We use the new struct device inside gpio_chip to related debug
      prints and warnings, and we also add it to the debugfs dump.
      
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Michael Welling <mwelling@ieee.org>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      34ffd85d
    • Linus Walleij's avatar
      gpio: make the gpiochip a real device · ff2b1359
      Linus Walleij authored
      GPIO chips have been around for years, but were never real devices,
      instead they were piggy-backing on a parent device (such as a
      platform_device or amba_device) but this was always optional.
      GPIO chips could also exist without any device at all, with its
      struct device *parent (ex *dev) pointer being set to null.
      
      When sysfs was in use, a mock device would be created, with the
      optional parent assigned, or just floating orphaned with NULL
      as parent.
      
      If sysfs is active, it will use this device as parent.
      
      We now create a gpio_device struct containing a real
      struct device and move the subsystem over to using that. The
      list of struct gpio_chip:s is augmented to hold struct
      gpio_device:s and we find gpio_chips:s by first looking up
      the struct gpio_device.
      
      The struct gpio_device is designed to stay around even if the
      gpio_chip is removed, so as to satisfy users in userspace
      that need a backing data structure to hold the state of the
      session initiated with e.g. a character device even if there is
      no physical chip anymore.
      
      From this point on, gpiochips are devices.
      
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Michael Welling <mwelling@ieee.org>
      Cc: Markus Pargmann <mpa@pengutronix.de>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      ff2b1359
  4. 08 Feb, 2016 2 commits
    • Liu Gang's avatar
      drivers/gpio: Switch gpio-mpc8xxx to use gpio-generic · 42178e2a
      Liu Gang authored
      The new Layerscape platforms has the same ip block/controller
      as GPIO on PowerPC platforms(MPC8XXX), but the GPIO registers
      may be big or little endian. So the code needs to get the
      endian property from DTB, then make additional functions to
      fit all the PowerPC/Layerscape GPIO register read/write
      operations.
      
      gpio-generic.c provides an universal infrastructure for both
      big and little endian register operations. So switch the
      gpio-mpc8xxx to use gpio-generic can simplify the driver and
      reduce a lot of code.
      
      The IRQ and some workaround parts in gpio-mpc8xxx.c will be
      updated with the new API interfaces but following the
      original functionalities.
      Signed-off-by: default avatarLiu Gang <Gang.Liu@nxp.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      42178e2a
    • Linus Walleij's avatar
      daec0bed
  5. 05 Feb, 2016 2 commits
  6. 28 Jan, 2016 6 commits
  7. 25 Jan, 2016 5 commits
    • Linus Walleij's avatar
      unicore: gpio: Be sure to clamp return value · a80bb4c9
      Linus Walleij authored
      As we want gpio_chip .get() calls to be able to return negative
      error codes and propagate to drivers, we need to go over all
      drivers and make sure their return values are clamped to [0,1].
      We do this by using the ret = !!(val) design pattern.
      
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      a80bb4c9
    • Linus Walleij's avatar
      powerpc: simple_gpio: Be sure to clamp return value · a4ce4b8d
      Linus Walleij authored
      As we want gpio_chip .get() calls to be able to return negative
      error codes and propagate to drivers, we need to go over all
      drivers and make sure their return values are clamped to [0,1].
      We do this by using the ret = !!(val) design pattern.
      
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Anatolij Gustschin <agust@denx.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      a4ce4b8d
    • Linus Walleij's avatar
      powerpc: qe_lib/gpio: Be sure to clamp return value · e847396b
      Linus Walleij authored
      As we want gpio_chip .get() calls to be able to return negative
      error codes and propagate to drivers, we need to go over all
      drivers and make sure their return values are clamped to [0,1].
      We do this by using the ret = !!(val) design pattern.
      
      Cc: Anatolij Gustschin <agust@denx.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      e847396b
    • Linus Walleij's avatar
      powerpc: ppc4cc/gpio: Be sure to clamp return value · eecdf59a
      Linus Walleij authored
      As we want gpio_chip .get() calls to be able to return negative
      error codes and propagate to drivers, we need to go over all
      drivers and make sure their return values are clamped to [0,1].
      We do this by using the ret = !!(val) design pattern.
      
      Cc: Anatolij Gustschin <agust@denx.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      eecdf59a
    • Linus Walleij's avatar
      blackfin: gpio: Be sure to clamp return value · 48295fe9
      Linus Walleij authored
      As we want gpio_chip .get() calls to be able to return negative
      error codes and propagate to drivers, we need to go over all
      drivers and make sure their return values are clamped to [0,1].
      We do this by using the ret = !!(val) design pattern.
      
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: adi-buildroot-devel@lists.sourceforge.net
      Acked-by: default avatarSonic Zhang <sonic.zhang@analog.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      48295fe9
  8. 24 Jan, 2016 4 commits
    • Linus Torvalds's avatar
      Linux 4.5-rc1 · 92e963f5
      Linus Torvalds authored
      92e963f5
    • Linus Torvalds's avatar
      Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus · e2464688
      Linus Torvalds authored
      Pull MIPS updates from Ralf Baechle:
       "This is the main pull request for MIPS for 4.5 plus some 4.4 fixes.
      
        The executive summary:
      
         - ATH79 platform improvments, use DT bindings for the ATH79 USB PHY.
         - Avoid useless rebuilds for zboot.
         - jz4780: Add NEMC, BCH and NAND device tree nodes
         - Initial support for the MicroChip's DT platform.  As all the device
           drivers are missing this is still of limited use.
         - Some Loongson3 cleanups.
         - The unavoidable whitespace polishing.
         - Reduce clock skew when synchronizing the CPU cycle counters on CPU
           startup.
         - Add MIPS R6 fixes.
         - Lots of cleanups across arch/mips as fallout from KVM.
         - Lots of minor fixes and changes for IEEE 754-2008 support to the
           FPU emulator / fp-assist software.
         - Minor Ralink, BCM47xx and bcm963xx platform support improvments.
         - Support SMP on BCM63168"
      
      * 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (84 commits)
        MIPS: zboot: Add support for serial debug using the PROM
        MIPS: zboot: Avoid useless rebuilds
        MIPS: BMIPS: Enable ARCH_WANT_OPTIONAL_GPIOLIB
        MIPS: bcm63xx: nvram: Remove unused bcm63xx_nvram_get_psi_size() function
        MIPS: bcm963xx: Update bcm_tag field image_sequence
        MIPS: bcm963xx: Move extended flash address to bcm_tag header file
        MIPS: bcm963xx: Move Broadcom BCM963xx image tag data structure
        MIPS: bcm63xx: nvram: Use nvram structure definition from header file
        MIPS: bcm963xx: Add Broadcom BCM963xx board nvram data structure
        MAINTAINERS: Add KVM for MIPS entry
        MIPS: KVM: Add missing newline to kvm_err()
        MIPS: Move KVM specific opcodes into asm/inst.h
        MIPS: KVM: Use cacheops.h definitions
        MIPS: Break down cacheops.h definitions
        MIPS: Use EXCCODE_ constants with set_except_vector()
        MIPS: Update trap codes
        MIPS: Move Cause.ExcCode trap codes to mipsregs.h
        MIPS: KVM: Make kvm_mips_{init,exit}() static
        MIPS: KVM: Refactor added offsetof()s
        MIPS: KVM: Convert EXPORT_SYMBOL to _GPL
        ...
      e2464688
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v4.5-2' of... · e1c10879
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v4.5-2' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86
      
      Pull x86 platform driver updates from Darren Hart:
       "Emergency travel prevented me from completing my final testing on this
        until today.  Nothing here that couldn't wait until RC1 fixes, but I
        thought it best to get it out sooner rather than later as it does
        contain a build warning fix.
      
        Summary:
      
        A build warning fix, MAINTAINERS cleanup, and a new DMI quirk:
      
        ideapad-laptop:
         - Add Lenovo Yoga 700 to no_hw_rfkill dmi list
      
        MAINTAINERS:
         - Combine multiple telemetry entries
      
        intel_telemetry_debugfs:
         - Fix unused warnings in telemetry debugfs"
      
      * tag 'platform-drivers-x86-v4.5-2' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86:
        ideapad-laptop: Add Lenovo Yoga 700 to no_hw_rfkill dmi list
        MAINTAINERS: Combine multiple telemetry entries
        intel_telemetry_debugfs: Fix unused warnings in telemetry debugfs
      e1c10879
    • Linus Torvalds's avatar
      Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux · 81f05fee
      Linus Torvalds authored
      Pull thermal management updates from Zhang Rui:
       "The top merge commit was re-generated yesterday because two topic
        branches were dropped from this pull request in the last minute due to
        some unaddressed comments.  All the other material has been in
        linux-next for quite a while.
      
        Specifics:
      
         - Enhance thermal core to handle unexpected device cooling states
           after fresh boot and system resume.  From Zhang Rui and Chen Yu.
      
         - Several fixes and cleanups on Rockchip and RCAR thermal drivers.
           From Caesar Wang and Kuninori Morimoto.
      
         - Add Broxton support for Intel processor thermal reporting device
           driver.  From Amy Wiles"
      
      * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
        thermal: trip_point_temp_store() calls thermal_zone_device_update()
        thermal: rcar: rcar_thermal_get_temp() return error if strange temp
        thermal: rcar: check irq possibility in rcar_thermal_irq_xxx()
        thermal: rcar: check every rcar_thermal_update_temp() return value
        thermal: rcar: move rcar_thermal_dt_ids to upside
        thermal: rockchip: Support the RK3399 SoCs in thermal driver
        thermal: rockchip: Support the RK3228 SoCs in thermal driver
        dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible
        thermal: rockchip: fix a trivial typo
        Thermal: Enable Broxton SoC thermal reporting device
        thermal: constify pch_dev_ops structure
        Thermal: do thermal zone update after a cooling device registered
        Thermal: handle thermal zone device properly during system sleep
        Thermal: initialize thermal zone device correctly
      81f05fee