23 Sep, 2016

1 commit


08 Jun, 2016

1 commit

  • When the PM initialization was moved in the commit referenced below, the
    code enabling the clock was removed from the probe function. On
    CONFIG_PM=y kernels, this is not a problem as the pm resume hook enables
    the clock, but when power management is disabled, all those pm_*
    functions are noops and the clock is never enabled resulting in a
    dysfunctional gpio controller.

    Put the clock initialization back to support CONFIG_PM=n.

    Cc: stable@vger.kernel.org
    Signed-off-by: Helmut Grohne
    Fixes: 3773c195d387 ("gpio: zynq: Do PM initialization earlier to support gpio hogs")
    Signed-off-by: Linus Walleij

    Helmut Grohne
     

10 Apr, 2016

1 commit


05 Jan, 2016

1 commit


14 Dec, 2015

1 commit

  • GPIO hogs registration is call at the end of gpiochip_add() function.
    Calling sequence is:
    gpiochip_add -> of_gpiochip_add -> of_gpiochip_scan_hogs ->
    gpiod_hog -> gpiochip_request_own_desc -> __gpiod_request ->
    chip->request -> zynq_gpio_request which calls pm_runtime_get_sync()
    which returns -13 because PM is not initialized yet.

    Initialize PM before gpiochip_add is called to fix this issue.

    Signed-off-by: Michal Simek
    Signed-off-by: Soren Brinkmann
    Signed-off-by: Linus Walleij

    Michal Simek
     

19 Nov, 2015

1 commit

  • The name .dev in a struct is normally reserved for a struct device
    that is let us say a superclass to the thing described by the struct.
    struct gpio_chip stands out by confusingly using a struct device *dev
    to point to the parent device (such as a platform_device) that
    represents the hardware. As we want to give gpio_chip:s real devices,
    this is not working. We need to rename this member to parent.

    This was done by two coccinelle scripts, I guess it is possible to
    combine them into one, but I don't know such stuff. They look like
    this:

    @@
    struct gpio_chip *var;
    @@
    -var->dev
    +var->parent

    and:

    @@
    struct gpio_chip var;
    @@
    -var.dev
    +var.parent

    and:

    @@
    struct bgpio_chip *var;
    @@
    -var->gc.dev
    +var->gc.parent

    Plus a few instances of bgpio that I couldn't figure out how
    to teach Coccinelle to rewrite.

    This patch hits all over the place, but I *strongly* prefer this
    solution to any piecemal approaches that just exercise patch
    mechanics all over the place. It mainly hits drivers/gpio and
    drivers/pinctrl which is my own backyard anyway.

    Cc: Haavard Skinnemoen
    Cc: Rafał Miłecki
    Cc: Richard Purdie
    Cc: Mauro Carvalho Chehab
    Cc: Alek Du
    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    Acked-by: Dmitry Torokhov
    Acked-by: Greg Kroah-Hartman
    Acked-by: Lee Jones
    Acked-by: Jiri Kosina
    Acked-by: Hans-Christian Egtvedt
    Acked-by: Jacek Anaszewski
    Signed-off-by: Linus Walleij

    Linus Walleij
     

02 Oct, 2015

1 commit

  • The state container of the Zynq GPIO driver is sometimes
    extracted from the gpio_chip exploiting the fact that offsetof()
    the struct gpio_chip inside the struct zynq_gpio is 0, so
    the container_of() is in practice a noop. However if a member
    is added to struct zynq_gpio in front of struct gpio_chip,
    things will break. Using proper container_of() avoids this
    problem.

    Semantically this is a noop, the compiler will optimize it away,
    but syntactically it makes me happier.

    Also replace some explicit container_of() calls with the helper
    function.

    Cc: Lars-Peter Clausen
    Cc: Ezra Savard
    Cc: Michal Simek
    Acked-by: Harini Katakam
    Signed-off-by: Linus Walleij

    Linus Walleij
     

16 Sep, 2015

1 commit

  • Most interrupt flow handlers do not use the irq argument. Those few
    which use it can retrieve the irq number from the irq descriptor.

    Remove the argument.

    Search and replace was done with coccinelle and some extra helper
    scripts around it. Thanks to Julia for her help!

    Signed-off-by: Thomas Gleixner
    Cc: Julia Lawall
    Cc: Jiang Liu

    Thomas Gleixner
     

13 Aug, 2015

1 commit


17 Jul, 2015

1 commit


16 Jul, 2015

2 commits

  • Add missing pm_runtime_disabled to remove().

    Error log:
    root@zynqmp:~# modprobe gpio_zynq
    root@zynqmp:~# lsmod
    Not tainted
    gpio_zynq 7086 0 - Live 0xffffffbffc00a000
    root@zynqmp:~# rmmod gpio_zynq
    root@zynqmp:~# lsmod
    Not tainted
    root@zynqmp:~# modprobe gpio_zynq
    [ 246.924438] zynq-gpio ff0a0000.gpio: Unbalanced pm_runtime_enable!
    root@zynqmp:~# rmmod gpio_zynq
    root@zynqmp:~# lsmod
    Not tainted

    Signed-off-by: Michal Simek
    Reviewed-by: Alexandre Courbot
    Signed-off-by: Linus Walleij

    Michal Simek
     
  • This driver is tristate, so it should be cleanable.

    Signed-off-by: Masahiro Yamada
    Tested-by: Michal Simek
    Signed-off-by: Linus Walleij

    Masahiro Yamada
     

14 Jul, 2015

2 commits


10 Jun, 2015

1 commit


19 May, 2015

1 commit


04 Dec, 2014

1 commit

  • The SET_PM_RUNTIME_PM_OPS() and SET_RUNTIME_PM_OPS() macros are
    identical except that one of them is not empty for CONFIG_PM set,
    while the other one is not empty for CONFIG_PM_RUNTIME set,
    respectively.

    However, after commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if
    PM_SLEEP is selected) PM_RUNTIME is always set if PM is set, so one
    of these macros is now redundant.

    For this reason, replace SET_PM_RUNTIME_PM_OPS() with
    SET_RUNTIME_PM_OPS() everywhere and redefine the SET_PM_RUNTIME_PM_OPS
    symbol as SET_RUNTIME_PM_OPS in case new code is starting to use the
    macro being removed here.

    Reviewed-by: Ulf Hansson
    Acked-by: Kevin Hilman
    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

23 Sep, 2014

1 commit


19 Sep, 2014

1 commit


05 Sep, 2014

2 commits


03 Sep, 2014

1 commit


29 Aug, 2014

2 commits


17 Aug, 2014

1 commit

  • The Zynq GPIO interrupt handling code as two main issues:
    1) It does not support IRQF_ONESHOT interrupt since it uses handle_simple_irq()
    for the interrupt handler. handle_simple_irq() does not do masking and unmasking
    of the IRQ that is required for this chip to be able to support IRQF_ONESHOT
    IRQs, causing the CPU to lock up in a interrupt storm if such a interrupt is
    requested.
    2) Interrupts are acked after the primary interrupt handlers for all asserted
    interrupts in a bank have been called. For edge triggered interrupt this is to
    late and may cause a interrupt to be missed. For level triggered oneshot
    interrupts this is to early and causes the interrupt handler to run twice per
    interrupt.

    This patch addresses the issue by updating the driver to use the correct IRQ
    chip handler functions that are appropriate for this kind of IRQ controller.

    The following diagram gives an overview of how the interrupt detection circuit
    works, it is not necessarily a accurate depiction of the real hardware though.

    INT_POL/INT_ON_ANY
    |
    | +---+ INT_STATUS
    `-| | |
    | E |-. |
    ,---| | \ |\ +----+ | +---+
    | +---+ `----| | ,-------|S | ,*--| |
    GPIO_IN -* | |- | Q|- | & |-- IRQ_OUT
    | +---+ ,-----| | ,-|R | ,o| |
    `---| | / |/ | +----+ | +---+
    | = |- | | |
    ,-| | INT_TYPE ACK INT_MASK
    | +---+
    |
    INT_POL

    GPIO_IN is the raw signal level connected to the hardware pin. This signal is
    routed to a edge detector and to a level detector. The edge detector can be
    configured to either detect a rising or falling edge or both edges. The level
    detector can detect either a level high or level low event. Depending on the
    setting of the INT_TYPE register either the edge or level event will be
    propagated to the INT_STATUS register. As long as a interrupt condition is
    detected the INT_STATUS register will be set to 1. It can be cleared to 0 if
    (and only if) the interrupt condition is no longer detected and software
    acknowledges the interrupt by writing a 1 to the address of the INT_STATUS
    register. There is also the INT_MASK register which can be used to disable the
    propagation of the INT_STATUS signal to the upstream IRQ controller. What is
    important to note is that the interrupt detection logic itself can not be
    disabled, only the propagation of the INT_STATUS register can be delayed. This
    means that for level type interrupts the interrupt must only be acknowledged
    after the interrupt source has been cleared otherwise it will stay asserted and
    the interrupt handler will be run a second time. For IRQF_ONESHOT interrupts
    this means that the IRQ must only be acknowledged after the threaded interrupt
    has finished running. If a second interrupt comes in between handling the first
    interrupt and acknowledging it the external interrupt will be asserted, which
    means trying to acknowledge the first interrupt will not clear the INT_STATUS
    register and the interrupt handler will be run a second time when the IRQ is
    unmasked, so no interrupts will be lost. The handle_fasteoi_irq() handler in
    combination with the IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED flags will
    have the desired behavior. For edge triggered interrupts a slightly different
    strategy is necessary. For edge triggered interrupts the interrupt condition is
    only true when the edge itself is detected, this means this is the only time the
    INT_STATUS register is set, acknowledging the interrupt any time after that will
    clear the INT_STATUS register until the next interrupt happens. This means in
    order to not loose any interrupts the interrupt needs to be acknowledged before
    running the interrupt handler. If a second interrupt occurs after the first
    interrupt handler has finished but before the interrupt is unmasked the
    INT_STATUS register will be re-asserted and the interrupt handler runs a second
    time once the interrupt is unmasked. This means with this flow handling strategy
    no interrupts are lost for edge triggered interrupts. The handle_level_irq()
    handler will have the desired behavior. (Note: The handle_edge_irq() only needs
    to be used for edge triggered interrupts where the controller stops detecting
    the interrupt event when the interrupt is masked, for this controller the
    detection logic still works, while only the propagation is delayed when the
    interrupt is masked.)

    Signed-off-by: Lars-Peter Clausen
    Acked-by: Soren Brinkmann
    Signed-off-by: Linus Walleij

    Lars-Peter Clausen
     

23 Jul, 2014

1 commit

  • The Zynq GPIO controller does not disable the interrupt detection when the
    interrupt is masked and only disables the propagation of the interrupt. This
    means when the controller detects an interrupt condition while the interrupt is
    logically disabled (and masked) it will propagate the recorded interrupt event
    once the interrupt is enabled. This will cause the interrupt consumer to see
    spurious interrupts to prevent this first make sure that the interrupt is not
    asserted and then enable it.

    E.g. when a interrupt is requested with request_irq() it will be configured
    according to the requested type (edge/level triggered, etc.) after that it will
    be enabled. But the detection circuit might have already registered a false
    interrupt before the interrupt type was correctly configured and once the
    interrupt is unmasked this false interrupt will be propagated and the interrupt
    handler for the just request interrupt will called.

    Signed-off-by: Lars-Peter Clausen
    Signed-off-by: Linus Walleij

    Lars-Peter Clausen
     

10 Jul, 2014

1 commit

  • Add support for GPIO controller used by Xilinx Zynq.

    v3 changes:
    - Use linux/gpio/driver.h instead of linux/gpio.h
    - Make irq a local variable in probe

    v2 changes:
    - convert to pm_runtime_force_(suspend|resume)
    - add pm_runtime_set_active in probe()
    - also (un)prepare clocks when they are dis-/enabled
    - add some missing calls to pm_runtime_get()
    - use pm_runtime_put() instead of sync variant
    - remove gpio chip in driver remove()
    - remove redundant type casts
    - directly use IO helpers
    - use BIT macro to set/clear bits
    - migrate to GPIOLIB_IRQCHIP

    Signed-off-by: Harini Katakam
    Signed-off-by: Soren Brinkmann
    Signed-off-by: Linus Walleij

    Harini Katakam