1. 04 9月, 2019 1 次提交
  2. 23 8月, 2019 1 次提交
  3. 20 8月, 2019 2 次提交
  4. 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
  5. 14 8月, 2019 1 次提交
  6. 03 8月, 2019 1 次提交
  7. 01 8月, 2019 1 次提交
  8. 31 7月, 2019 1 次提交
  9. 29 7月, 2019 2 次提交
  10. 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
  11. 04 7月, 2019 2 次提交
  12. 27 6月, 2019 1 次提交
  13. 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
  14. 14 6月, 2019 1 次提交
  15. 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
  16. 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
  17. 23 4月, 2019 3 次提交
  18. 05 4月, 2019 2 次提交
  19. 04 4月, 2019 1 次提交
  20. 27 3月, 2019 1 次提交
    • A
      Revert "gpio: use new gpio_set_config() helper in more places" · fa59dd23
      Andrew Jeffery 提交于
      gpio-aspeed implements support for PIN_CONFIG_INPUT_DEBOUNCE. As of
      v5.1-rc1 we're seeing the following when booting a Romulus BMC kernel:
      
      > [   21.373137] ------------[ cut here ]------------
      > [   21.374545] WARNING: CPU: 0 PID: 1 at drivers/gpio/gpio-aspeed.c:834 unregister_allocated_timer+0x38/0x94
      > [   21.376181] No timer allocated to offset 74
      > [   21.377672] CPU: 0 PID: 1 Comm: swapper Not tainted 5.1.0-rc1-dirty #6
      > [   21.378800] Hardware name: Generic DT based system
      > [   21.379965] Backtrace:
      > [   21.381024] [<80107d44>] (dump_backtrace) from [<80107f78>] (show_stack+0x20/0x24)
      > [   21.382713]  r7:8038b720 r6:00000009 r5:00000000 r4:87897c64
      > [   21.383815] [<80107f58>] (show_stack) from [<80656398>] (dump_stack+0x20/0x28)
      > [   21.385042] [<80656378>] (dump_stack) from [<80115f1c>] (__warn.part.3+0xb4/0xdc)
      > [   21.386253] [<80115e68>] (__warn.part.3) from [<80115fb0>] (warn_slowpath_fmt+0x6c/0x90)
      > [   21.387471]  r6:00000342 r5:807f8758 r4:80a07008
      > [   21.388278] [<80115f48>] (warn_slowpath_fmt) from [<8038b720>] (unregister_allocated_timer+0x38/0x94)
      > [   21.389809]  r3:0000004a r2:807f8774
      > [   21.390526]  r7:00000000 r6:0000000a r5:60000153 r4:0000004a
      > [   21.391601] [<8038b6e8>] (unregister_allocated_timer) from [<8038baac>] (aspeed_gpio_set_config+0x330/0x48c)
      > [   21.393248] [<8038b77c>] (aspeed_gpio_set_config) from [<803840b0>] (gpiod_set_debounce+0xe8/0x114)
      > [   21.394745]  r10:82ee2248 r9:00000000 r8:87b63a00 r7:00001388 r6:87947320 r5:80729310
      > [   21.396030]  r4:879f64a0
      > [   21.396499] [<80383fc8>] (gpiod_set_debounce) from [<804b4350>] (gpio_keys_probe+0x69c/0x8e0)
      > [   21.397715]  r7:845d94b8 r6:00000001 r5:00000000 r4:87b63a1c
      > [   21.398618] [<804b3cb4>] (gpio_keys_probe) from [<8040eeec>] (platform_dev_probe+0x44/0x80)
      > [   21.399834]  r10:00000003 r9:80a3a8b0 r8:00000000 r7:00000000 r6:80a7f9dc r5:80a3a8b0
      > [   21.401163]  r4:8796bc10
      > [   21.401634] [<8040eea8>] (platform_drv_probe) from [<8040d0d4>] (really_probe+0x208/0x3dc)
      > [   21.402786]  r5:80a7f8d0 r4:8796bc10
      > [   21.403547] [<8040cecc>] (really_probe) from [<8040d7a4>] (driver_probe_device+0x130/0x170)
      > [   21.404744]  r10:0000007b r9:8093683c r8:00000000 r7:80a07008 r6:80a3a8b0 r5:8796bc10
      > [   21.405854]  r4:80a3a8b0
      > [   21.406324] [<8040d674>] (driver_probe_device) from [<8040da8c>] (device_driver_attach+0x68/0x70)
      > [   21.407568]  r9:8093683c r8:00000000 r7:80a07008 r6:80a3a8b0 r5:00000000 r4:8796bc10
      > [   21.408877] [<8040da24>] (device_driver_attach) from [<8040db14>] (__driver_attach+0x80/0x150)
      > [   21.410327]  r7:80a07008 r6:8796bc10 r5:00000001 r4:80a3a8b0
      > [   21.411294] [<8040da94>] (__driver_attach) from [<8040b20c>] (bus_for_each_dev+0x80/0xc4)
      > [   21.412641]  r7:80a07008 r6:8040da94 r5:80a3a8b0 r4:87966f30
      > [   21.413580] [<8040b18c>] (bus_for_each_dev) from [<8040dc0c>] (driver_attach+0x28/0x30)
      > [   21.414943]  r7:00000000 r6:87b411e0 r5:80a33fc8 r4:80a3a8b0
      > [   21.415927] [<8040dbe4>] (driver_attach) from [<8040bbf0>] (bus_add_driver+0x14c/0x200)
      > [   21.417289] [<8040baa4>] (bus_add_driver) from [<8040e2b4>] (driver_register+0x84/0x118)
      > [   21.418652]  r7:80a60ae0 r6:809226b8 r5:80a07008 r4:80a3a8b0
      > [   21.419652] [<8040e230>] (driver_register) from [<8040fc28>] (__platform_driver_register+0x3c/0x50)
      > [   21.421193]  r5:80a07008 r4:809525f8
      > [   21.421990] [<8040fbec>] (__platform_driver_register) from [<809226d8>] (gpio_keys_init+0x20/0x28)
      > [   21.423447] [<809226b8>] (gpio_keys_init) from [<8090128c>] (do_one_initcall+0x80/0x180)
      > [   21.424886] [<8090120c>] (do_one_initcall) from [<80901538>] (kernel_init_freeable+0x1ac/0x26c)
      > [   21.426354]  r8:80a60ae0 r7:80a60ae0 r6:8093685c r5:00000008 r4:809525f8
      > [   21.427579] [<8090138c>] (kernel_init_freeable) from [<8066d9a0>] (kernel_init+0x18/0x11c)
      > [   21.428819]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:8066d988
      > [   21.429947]  r4:00000000
      > [   21.430415] [<8066d988>] (kernel_init) from [<801010e8>] (ret_from_fork+0x14/0x2c)
      > [   21.431666] Exception stack(0x87897fb0 to 0x87897ff8)
      > [   21.432877] 7fa0:                                     00000000 00000000 00000000 00000000
      > [   21.434446] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      > [   21.436052] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000
      > [   21.437308]  r5:8066d988 r4:00000000
      > [   21.438102] ---[ end trace d7d7ac3a80567d0e ]---
      
      We only hit unregister_allocated_timer() if the argument to
      aspeed_gpio_set_config() is 0, but we can't be calling through
      gpiod_set_debounce() from gpio_keys_probe() unless the gpio-keys button has a
      non-zero debounce interval.
      
      Commit 6581eaf0 ("gpio: use new gpio_set_config() helper in more places")
      spreads the use of gpio_set_config() to the debounce and transitory
      state configuration paths. The implementation of gpio_set_config() is:
      
      > static int gpio_set_config(struct gpio_chip *gc, unsigned offset,
      > 			   enum pin_config_param mode)
      > {
      > 	unsigned long config = { PIN_CONF_PACKED(mode, 0) };
      >
      > 	return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
      > }
      
      Here it packs its own config value with a fixed argument of 0; this is
      incorrect behaviour for implementing the debounce and transitory functions, and
      the debounce and transitory gpio_set_config() call-sites now have an undetected
      type mismatch as they both already pack their own config parameter (i.e. what
      gets passed is not an `enum pin_config_param`). Indeed this can be seen in the
      small diff for 6581eaf0:
      
      > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
      > index de595fa31a1a..1f239aac43df 100644
      > --- a/drivers/gpio/gpiolib.c
      > +++ b/drivers/gpio/gpiolib.c
      > @@ -2725,7 +2725,7 @@ int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
      >         }
      >
      >         config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce);
      > -       return chip->set_config(chip, gpio_chip_hwgpio(desc), config);
      > +       return gpio_set_config(chip, gpio_chip_hwgpio(desc), config);
      >  }
      >  EXPORT_SYMBOL_GPL(gpiod_set_debounce);
      >
      > @@ -2762,7 +2762,7 @@ int gpiod_set_transitory(struct gpio_desc *desc, bool transitory)
      >         packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE,
      >                                           !transitory);
      >         gpio = gpio_chip_hwgpio(desc);
      > -       rc = chip->set_config(chip, gpio, packed);
      > +       rc = gpio_set_config(chip, gpio, packed);
      >         if (rc == -ENOTSUPP) {
      >                 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n",
      >                                 gpio);
      
      Revert commit 6581eaf0 ("gpio: use new gpio_set_config() helper in
      more places") to restore correct behaviour for gpiod_set_debounce() and
      gpiod_set_transitory().
      
      Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
      Signed-off-by: NAndrew Jeffery <andrew@aj.id.au>
      Signed-off-by: NBartosz Golaszewski <bgolaszewski@baylibre.com>
      fa59dd23
  21. 13 2月, 2019 3 次提交
  22. 24 1月, 2019 2 次提交
  23. 14 12月, 2018 1 次提交
  24. 11 12月, 2018 1 次提交
  25. 15 11月, 2018 1 次提交
  26. 09 11月, 2018 1 次提交
  27. 05 11月, 2018 2 次提交
  28. 16 10月, 2018 3 次提交