1. 12 11月, 2019 3 次提交
  2. 08 11月, 2019 1 次提交
  3. 07 11月, 2019 1 次提交
    • A
      gpiolib: No need to call gpiochip_remove_pin_ranges() twice · 2f4133bb
      Andy Shevchenko 提交于
      of_gpiochip_add(), when fails, calls gpiochip_remove_pin_ranges().
      
      ADD:
        gpiochip_add_data_with_key() ->
          of_gpiochip_add() -> (ERROR path)
            gpiochip_remove_pin_ranges()
      
      At the same time of_gpiochip_remove() calls exactly the above mentioned
      function unconditionally and so does gpiochip_remove().
      
      REMOVE:
        gpiochip_remove() ->
          gpiochip_remove_pin_ranges()
          of_gpiochip_remove() ->
            gpiochip_remove_pin_ranges()
      
      Since gpiochip_remove() calls gpiochip_remove_pin_ranges() unconditionally,
      we have duplicate call to the same function when it's not necessary.
      
      Move gpiochip_remove_pin_ranges() from of_gpiochip_add() to gpiochip_add()
      to avoid duplicate calls and be consistent with the explicit call in
      gpiochip_remove().
      
      Fixes: e93fa3f2 ("gpiolib: remove duplicate pin range code")
      Depends-on: f7299d44 ("gpio: of: Fix of_gpiochip_add() error path")
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      2f4133bb
  4. 05 11月, 2019 1 次提交
  5. 15 10月, 2019 1 次提交
  6. 06 10月, 2019 1 次提交
  7. 03 10月, 2019 1 次提交
  8. 01 10月, 2019 2 次提交
  9. 12 9月, 2019 1 次提交
  10. 11 9月, 2019 1 次提交
  11. 09 9月, 2019 2 次提交
  12. 06 9月, 2019 1 次提交
  13. 04 9月, 2019 1 次提交
  14. 23 8月, 2019 2 次提交
  15. 20 8月, 2019 2 次提交
  16. 15 8月, 2019 1 次提交
    • L
      gpio: Add support for hierarchical IRQ domains · fdd61a01
      Linus Walleij 提交于
      Hierarchical IRQ domains can be used to stack different IRQ
      controllers on top of each other.
      
      Bring hierarchical IRQ domains into the GPIOLIB core with the
      following basic idea:
      
      Drivers that need their interrupts handled hierarchically
      specify a callback to translate the child hardware IRQ and
      IRQ type for each GPIO offset to a parent hardware IRQ and
      parent hardware IRQ type.
      
      Users have to pass the callback, fwnode, and parent irqdomain
      before calling gpiochip_irqchip_add().
      
      We use the new method of just filling in the struct
      gpio_irq_chip before adding the gpiochip for all hierarchical
      irqchips of this type.
      
      The code path for device tree is pretty straight-forward,
      while the code path for old boardfiles or anything else will
      be more convoluted requireing upfront allocation of the
      interrupts when adding the chip.
      
      One specific use-case where this can be useful is if a power
      management controller has top-level controls for wakeup
      interrupts. In such cases, the power management controller can
      be a parent to other interrupt controllers and program
      additional registers when an IRQ has its wake capability
      enabled or disabled.
      
      The hierarchical irqchip helper code will only be available
      when IRQ_DOMAIN_HIERARCHY is selected to GPIO chips using
      this should select or depend on that symbol. When using
      hierarchical IRQs, the parent interrupt controller must
      also be hierarchical all the way up to the top interrupt
      controller wireing directly into the CPU, so on systems
      that do not have this we can get rid of all the extra
      code for supporting hierarchical irqs.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: Lina Iyer <ilina@codeaurora.org>
      Cc: Jon Hunter <jonathanh@nvidia.com>
      Cc: Sowjanya Komatineni <skomatineni@nvidia.com>
      Cc: Bitan Biswas <bbiswas@nvidia.com>
      Cc: linux-tegra@vger.kernel.org
      Cc: David Daney <david.daney@cavium.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Brian Masney <masneyb@onstation.org>
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NBrian Masney <masneyb@onstation.org>
      Co-developed-by: NBrian Masney <masneyb@onstation.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20190808123242.5359-1-linus.walleij@linaro.org
      fdd61a01
  17. 14 8月, 2019 1 次提交
  18. 03 8月, 2019 1 次提交
  19. 01 8月, 2019 1 次提交
  20. 31 7月, 2019 1 次提交
  21. 29 7月, 2019 2 次提交
  22. 22 7月, 2019 1 次提交
    • M
      gpiolib: fix incorrect IRQ requesting of an active-low lineevent · 223ecaf1
      Michael Wu 提交于
      When a pin is active-low, logical trigger edge should be inverted to match
      the same interrupt opportunity.
      
      For example, a button pushed triggers falling edge in ACTIVE_HIGH case; in
      ACTIVE_LOW case, the button pushed triggers rising edge. For user space the
      IRQ requesting doesn't need to do any modification except to configuring
      GPIOHANDLE_REQUEST_ACTIVE_LOW.
      
      For example, we want to catch the event when the button is pushed. The
      button on the original board drives level to be low when it is pushed, and
      drives level to be high when it is released.
      
      In user space we can do:
      
      	req.handleflags = GPIOHANDLE_REQUEST_INPUT;
      	req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE;
      
      	while (1) {
      		read(fd, &dat, sizeof(dat));
      		if (dat.id == GPIOEVENT_EVENT_FALLING_EDGE)
      			printf("button pushed\n");
      	}
      
      Run the same logic on another board which the polarity of the button is
      inverted; it drives level to be high when pushed, and level to be low when
      released. For this inversion we add flag GPIOHANDLE_REQUEST_ACTIVE_LOW:
      
      	req.handleflags = GPIOHANDLE_REQUEST_INPUT |
      		GPIOHANDLE_REQUEST_ACTIVE_LOW;
      	req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE;
      
      At the result, there are no any events caught when the button is pushed.
      By the way, button releasing will emit a "falling" event. The timing of
      "falling" catching is not expected.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NMichael Wu <michael.wu@vatics.com>
      Tested-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
      Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
      223ecaf1
  23. 04 7月, 2019 2 次提交
  24. 27 6月, 2019 1 次提交
  25. 25 6月, 2019 1 次提交
    • W
      gpio: Fix return value mismatch of function gpiod_get_from_of_node() · 025bf377
      Waibel Georg 提交于
      In case the requested gpio property is not found in the device tree, some
      callers of gpiod_get_from_of_node() expect a return value of NULL, others
      expect -ENOENT.
      In particular devm_fwnode_get_index_gpiod_from_child() expects -ENOENT.
      Currently it gets a NULL, which breaks the loop that tries all
      gpio_suffixes. The result is that a gpio property is not found, even
      though it is there.
      
      This patch changes gpiod_get_from_of_node() to return -ENOENT instead
      of NULL when the requested gpio property is not found in the device
      tree. Additionally it modifies all calling functions to properly
      evaluate the return value.
      
      Another approach would be to leave the return value of
      gpiod_get_from_of_node() as is and fix the bug in
      devm_fwnode_get_index_gpiod_from_child(). Other callers would still need
      to be reworked. The effort would be the same as with the chosen solution.
      Signed-off-by: NGeorg Waibel <georg.waibel@sensor-technik.de>
      Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      025bf377
  26. 14 6月, 2019 1 次提交
  27. 08 6月, 2019 1 次提交
    • L
      gpio: pass lookup and descriptor flags to request_own · 5923ea6c
      Linus Walleij 提交于
      When a gpio_chip wants to request a descriptor from itself
      using gpiochip_request_own_desc() it needs to be able to specify
      fully how to use the descriptor, notably line inversion
      semantics. The workaround in the gpiolib.c can be removed
      and cases (such as SPI CS) where we need at times to request
      a GPIO with line inversion semantics directly on a chip for
      workarounds, can be fully supported with this call.
      
      Fix up some users of the API that weren't really using the
      last flag to set up the line as input or output properly
      but instead just calling direction setting explicitly
      after requesting the line.
      
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      5923ea6c
  28. 25 4月, 2019 1 次提交
    • G
      gpio: Fix gpiochip_add_data_with_key() error path · 35779890
      Geert Uytterhoeven 提交于
      The err_remove_chip block is too coarse, and may perform cleanup that
      must not be done.  E.g. if of_gpiochip_add() fails, of_gpiochip_remove()
      is still called, causing:
      
          OF: ERROR: Bad of_node_put() on /soc/gpio@e6050000
          CPU: 1 PID: 20 Comm: kworker/1:1 Not tainted 5.1.0-rc2-koelsch+ #407
          Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
          Workqueue: events deferred_probe_work_func
          [<c020ec74>] (unwind_backtrace) from [<c020ae58>] (show_stack+0x10/0x14)
          [<c020ae58>] (show_stack) from [<c07c1224>] (dump_stack+0x7c/0x9c)
          [<c07c1224>] (dump_stack) from [<c07c5a80>] (kobject_put+0x94/0xbc)
          [<c07c5a80>] (kobject_put) from [<c0470420>] (gpiochip_add_data_with_key+0x8d8/0xa3c)
          [<c0470420>] (gpiochip_add_data_with_key) from [<c0473738>] (gpio_rcar_probe+0x1d4/0x314)
          [<c0473738>] (gpio_rcar_probe) from [<c052fca8>] (platform_drv_probe+0x48/0x94)
      
      and later, if a GPIO consumer tries to use a GPIO from a failed
      controller:
      
          WARNING: CPU: 0 PID: 1 at lib/refcount.c:156 kobject_get+0x38/0x4c
          refcount_t: increment on 0; use-after-free.
          Modules linked in:
          CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.1.0-rc2-koelsch+ #407
          Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
          [<c020ec74>] (unwind_backtrace) from [<c020ae58>] (show_stack+0x10/0x14)
          [<c020ae58>] (show_stack) from [<c07c1224>] (dump_stack+0x7c/0x9c)
          [<c07c1224>] (dump_stack) from [<c0221580>] (__warn+0xd0/0xec)
          [<c0221580>] (__warn) from [<c02215e0>] (warn_slowpath_fmt+0x44/0x6c)
          [<c02215e0>] (warn_slowpath_fmt) from [<c07c58fc>] (kobject_get+0x38/0x4c)
          [<c07c58fc>] (kobject_get) from [<c068b3ec>] (of_node_get+0x14/0x1c)
          [<c068b3ec>] (of_node_get) from [<c0686f24>] (of_find_node_by_phandle+0xc0/0xf0)
          [<c0686f24>] (of_find_node_by_phandle) from [<c0686fbc>] (of_phandle_iterator_next+0x68/0x154)
          [<c0686fbc>] (of_phandle_iterator_next) from [<c0687fe4>] (__of_parse_phandle_with_args+0x40/0xd0)
          [<c0687fe4>] (__of_parse_phandle_with_args) from [<c0688204>] (of_parse_phandle_with_args_map+0x100/0x3ac)
          [<c0688204>] (of_parse_phandle_with_args_map) from [<c0471240>] (of_get_named_gpiod_flags+0x38/0x380)
          [<c0471240>] (of_get_named_gpiod_flags) from [<c046f864>] (gpiod_get_from_of_node+0x24/0xd8)
          [<c046f864>] (gpiod_get_from_of_node) from [<c0470aa4>] (devm_fwnode_get_index_gpiod_from_child+0xa0/0x144)
          [<c0470aa4>] (devm_fwnode_get_index_gpiod_from_child) from [<c05f425c>] (gpio_keys_probe+0x418/0x7bc)
          [<c05f425c>] (gpio_keys_probe) from [<c052fca8>] (platform_drv_probe+0x48/0x94)
      
      Fix this by splitting the cleanup block, and adding a missing call to
      gpiochip_irqchip_remove().
      
      Fixes: 28355f81 ("gpio: defer probe if pinctrl cannot be found")
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: NMukesh Ojha <mojha@codeaurora.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      35779890
  29. 23 4月, 2019 3 次提交
  30. 05 4月, 2019 1 次提交
    • M
      gpio: Set proper argument value to set_config · 542f3615
      Maxime Ripard 提交于
      The gpio_set_config function creates a pinconf configuration for a given
      pinc_config_param.
      
      However, it always uses an arg of 0, which might not be a valid argument
      for a given param. A good example of that would be the bias parameters,
      where 0 means that the pull up or down resistor is null, and the pin is
      directly connected to VCC/GND.
      
      The framework uses in some other places the value 1 as a default argument
      to enable the pull resistor, so let's use the same one here.
      Signed-off-by: NMaxime Ripard <maxime.ripard@bootlin.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      542f3615