30 Jul, 2020

1 commit

  • This makes the driver use the irqchip template to assign
    properties to the gpio_irq_chip instead of using the
    explicit call to gpiochip_irqchip_add().

    The irqchip is instead added while adding the gpiochip.

    Signed-off-by: Linus Walleij
    Cc: Biju Das
    Cc: Geert Uytterhoeven
    Link: https://lore.kernel.org/r/20200722113141.243163-1-linus.walleij@linaro.org

    Linus Walleij
     

25 May, 2020

1 commit

  • pm_runtime_get_sync() increments the runtime PM usage counter even
    when it returns an error code. Thus a pairing decrement is needed on
    the error handling path to keep the counter balanced.

    Signed-off-by: Dinghao Liu
    Link: https://lore.kernel.org/r/20200522080839.32612-1-dinghao.liu@zju.edu.cn
    Signed-off-by: Linus Walleij

    Dinghao Liu
     

20 Feb, 2020

1 commit


12 Nov, 2019

1 commit


07 Nov, 2019

1 commit

  • It's hard for occasional GPIO code reader/writer to know if values 0/1
    equal to IN or OUT. Use defined GPIO_LINE_DIRECTION_IN and
    GPIO_LINE_DIRECTION_OUT to help them out.

    NOTE - for gpio-amd-fch and gpio-bd9571mwv:
    This commit also changes the return value for direction get to equal 1
    for direction INPUT. Prior this commit these drivers might have
    returned some other positive value but 1 for INPUT.

    Signed-off-by: Matti Vaittinen
    Acked-by: Scott Branden
    Reviewed-by: Grygorii Strashko
    Reviewed-by: Michal Simek
    Reviewed-by: Geert Uytterhoeven
    Acked-by: Andy Shevchenko
    Acked-by: William Breathitt Gray
    Acked-by: Kuppuswamy Sathyanarayanan
    Signed-off-by: Linus Walleij

    Matti Vaittinen
     

27 Jun, 2019

1 commit


05 Apr, 2019

1 commit


21 Jan, 2019

1 commit

  • R-Car GPIO controller provides two interfaces to set GPIO line output
    signal state, and for a particular GPIO line the selected interface is
    determined by OUTDTSEL bit value.

    At the moment the driver supports only one of two interfaces, namely
    OUTDT General Output Register is used to control the output signal.

    While this selection is the default one on reset, it is not explicitly
    configured on probe, thus it might be possible that kernel and userspace
    consumers of a GPIO won't be able to set the wanted GPIO output signal.

    Below is a simple test case to reproduce the described problem and
    verify this fix in the kernel on H3 ULCB by setting non-default OUTDTSEL
    configuration from a bootloader:

    u-boot > mw.l 0xe6055440 0x3000 1
    ...
    userspace > echo default-on > /sys/devices/platform/leds/leds/led5/trigger
    userspace > echo default-on > /sys/devices/platform/leds/leds/led6/trigger

    Signed-off-by: Vladimir Zapolskiy
    Signed-off-by: Linus Walleij

    Vladimir Zapolskiy
     

06 Dec, 2018

1 commit


15 Nov, 2018

1 commit


29 Aug, 2018

1 commit

  • GPIO hole is present in RZ/G1C SoC. Valid GPIO pins on bank3 are in the
    range GP3_0 to GP3_16 and GP3_27 to GP3_29. The GPIO pins between GP3_17
    to GP3_26 are unused. Add support for handling unused GPIO's.

    Signed-off-by: Biju Das
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Biju Das
     

13 Jul, 2018

1 commit


02 Jul, 2018

1 commit


19 Mar, 2018

1 commit


05 Mar, 2018

1 commit

  • Since commit ab82fa7da4dce5c7 ("gpio: rcar: Prevent module clock disable
    when wake-up is enabled"), when a GPIO is used for wakeup, the GPIO
    block's module clock (if exists) is manually kept running during system
    suspend, to make sure the device stays active.

    However, this explicit clock handling is merely a workaround for a
    failure to properly communicate wakeup information to the device core.

    Instead, set the device's power.wakeup_path field, to indicate this
    device is part of the wakeup path. Depending on the PM Domain's
    active_wakeup configuration, the genpd core code will keep the device
    enabled (and the clock running) during system suspend when needed.
    This allows for the removal of all explicit clock handling code from the
    driver.

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     

22 Feb, 2018

1 commit

  • This patch adds an implementation that saves and restores the state of
    GPIO configuration on suspend and resume.

    Signed-off-by: Hien Dang
    Signed-off-by: Takeshi Kihara
    [Modify structure of the bank info to simplify a saving registers]
    [Remove DEV_PM_OPS macro]
    Signed-off-by: Yoshihiro Kaneko
    Tested-by: Nguyen Viet Dung
    Reviewed-by: Simon Horman
    Signed-off-by: Linus Walleij

    Hien Dang
     

09 Nov, 2017

1 commit


08 Nov, 2017

1 commit


31 Oct, 2017

1 commit

  • Using devm_ioremap_resource() has several advantages over devm_ioremap():
    - it checks the passed resource's validity;
    - it calls devm_request_mem_region() to check for the resource overlap;
    - it prints an error message in case of error.

    We can call devm_ioremap_resource() instead of devm_ioremap_nocache()
    as ioremap() and ioremap_nocache() are implemented identically on ARM.
    Doing this saves 2 LoCs and 80 bytes (AArch64 gcc 4.8.5).

    Signed-off-by: Sergei Shtylyov
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Sergei Shtylyov
     

08 Oct, 2017

1 commit


22 Sep, 2017

1 commit


14 Aug, 2017

1 commit

  • Add fallback compatibility string for R-Car Gen 1, 2 and 3.

    In the case of Renesas R-Car hardware we know that there are generations of
    SoCs, f.e. Gen 1 and 2. But beyond that its not clear what the relationship
    between IP blocks might be. For example, I believe that r8a7790 is older
    than r8a7791 but that doesn't imply that the latter is a descendant of the
    former or vice versa.

    We can, however, by examining the documentation and behaviour of the
    hardware at run-time observe that the current driver implementation appears
    to be compatible with the IP blocks on SoCs within a given generation.

    For the above reasons and convenience when enabling new SoCs a
    per-generation fallback compatibility string scheme being adopted for
    drivers for Renesas SoCs.

    Also deprecate renesas,gpio-rcar as its name is more generic than its
    implementation.

    Signed-off-by: Simon Horman
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Simon Horman
     

29 Jun, 2017

1 commit

  • Renesas RZ/G1M (R8A7743) SoC GPIO blocks are identical to the R-Car Gen2
    family. Add support for its GPIO controllers.

    Signed-off-by: Biju Das
    Reviewed-by: Chris Paterson
    Acked-by: Geert Uytterhoeven
    Acked-by: Rob Herring
    Signed-off-by: Linus Walleij

    Biju Das
     

28 Dec, 2016

2 commits

  • Currently gpio modules are runtime-resumed at probe time. This means the
    gpio module will be active all the time (except during system suspend,
    if not configured as a wake-up source).

    While an R-Car Gen2 gpio module retains pins configured for output at
    the requested level while put in standby mode, gpio register cannot be
    accessed while suspended. Unfortunately pm_runtime_get_sync() cannot be
    called from all contexts where gpio register access is needed. Hence
    move the Runtime PM handling from probe/remove time to gpio request/free
    time, which is probably the best we can do.

    On r8a7791/koelsch, gpio modules 0, 1, 3, and 4 are now suspended during
    normal use (gpio2 is used for LEDs and regulators, gpio5 for keys, gpio6
    for SD-Card CD & WP, gpio7 for keys and regulators).

    Signed-off-by: Geert Uytterhoeven
    [Niklas: s/gpio_to_priv(chip)/gpiochip_get_data(chip)/]
    Signed-off-by: Niklas Söderlund
    Reviewed-by: Laurent Pinchart
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     
  • This enables Runtime PM handling for interrupts.

    By setting the parent_device in struct irq_chip genirq will call the
    pm_runtime_get/put APIs when an IRQ is requested/freed.

    Signed-off-by: Niklas Söderlund
    Reviewed-by: Laurent Pinchart
    Reviewed-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Niklas Söderlund
     

08 Sep, 2016

1 commit

  • R-Car Gen3's GPIO blocks are identical to Gen2's in every respect.

    Based on work for the r8a7795 (R-Car H3) by Ulrich Hecht.

    Cc: Ulrich Hecht
    Signed-off-by: Simon Horman
    Reviewed-by: Geert Uytterhoeven
    Reviewed-by: Laurent Pinchart
    Tested-by: Laurent Pinchart
    Signed-off-by: Linus Walleij

    Simon Horman
     

22 Jul, 2016

1 commit


18 May, 2016

1 commit

  • Pull GPIO updates from Linus Walleij:
    "This is the bulk of GPIO changes for kernel cycle v4.7:

    Core infrastructural changes:

    - Support for natively single-ended GPIO driver stages.

    This means that if the hardware has registers to configure open
    drain or open source configuration, we use that rather than (as we
    did before) try to emulate it by switching the line to an input to
    get high impedance.

    This is also documented throughly in Documentation/gpio/driver.txt
    for those of you who did not understand one word of what I just
    wrote.

    - Start to do away with the unnecessarily complex and unitelligible
    ARCH_REQUIRE_GPIOLIB and ARCH_WANT_OPTIONAL_GPIOLIB, another
    evolutional artifact from the time when the GPIO subsystem was
    unmaintained.

    Archs can now just select GPIOLIB and be done with it, cleanups to
    arches will trickle in for the next kernel. Some minor archs ACKed
    the changes immediately so these are included in this pull request.

    - Advancing the use of the data pointer inside the GPIO device for
    storing driver data by switching the PowerPC, Super-H Unicore and
    a few other subarches or subsystem drivers in ALSA SoC, Input,
    serial, SSB, staging etc to use it.

    - The initialization now reads the input/output state of the GPIO
    lines, so that each GPIO descriptor knows - if this callback is
    implemented - whether the line is input or output. This also
    reflects nicely in userspace "lsgpio".

    - It is now possible to name GPIO producer names, line names, from
    the device tree. (Platform data has been supported for a while).
    I bet we will get a similar mechanism for ACPI one of those days.
    This makes is possible to get sensible producer names for e.g.
    GPIO rails in "lsgpio" in userspace.

    New drivers:

    - New driver for the Loongson1.

    - The XLP driver now supports Broadcom Vulcan ARM64.

    - The IT87 driver now supports IT8620 and IT8628.

    - The PCA953X driver now supports Galileo Gen2.

    Driver improvements:

    - MCP23S08 was switched to use the gpiolib irqchip helpers and now
    also suppors level-triggered interrupts.

    - 74x164 and RCAR now supports the .set_multiple() callback

    - AMDPT was converted to use generic GPIO.

    - TC3589x, TPS65218, SX150X, F7188X, MENZ127, VX855, WM831X, WM8994
    support the new single ended callback for open drain and in some
    cases open source.

    - Implement the .get_direction() callback for a few more drivers like
    PL061, Xgene.

    Cleanups:

    - Paul Gortmaker combed through the drivers and de-modularized those
    who are not really modules.

    - Move the GPIO poweroff DT bindings to the power subdir where they
    belong.

    - Rename gpio-generic.c to gpio-mmio.c, which is much more to the
    point. That's what it is handling, nothing more, nothing less"

    * tag 'gpio-v4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (126 commits)
    MIPS: do away with ARCH_[WANT_OPTIONAL|REQUIRE]_GPIOLIB
    gpio: zevio: make it explicitly non-modular
    gpio: timberdale: make it explicitly non-modular
    gpio: stmpe: make it explicitly non-modular
    gpio: sodaville: make it explicitly non-modular
    pinctrl: sh-pfc: Let gpio_chip.to_irq() return zero on error
    gpio: dwapb: Add ACPI device ID for DWAPB GPIO controller on X-Gene platforms
    gpio: dt-bindings: add wd,mbl-gpio bindings
    gpio: of: make it possible to name GPIO lines
    gpio: make gpiod_to_irq() return negative for NO_IRQ
    gpio: xgene: implement .get_direction()
    gpio: xgene: Enable ACPI support for X-Gene GFC GPIO driver
    gpio: tegra: Implement gpio_get_direction callback
    gpio: set up initial state from .get_direction()
    gpio: rename gpio-generic.c into gpio-mmio.c
    gpio: generic: fix GPIO_GENERIC_PLATFORM is set to module case
    gpio: dwapb: add gpio-signaled acpi event support
    gpio: dwapb: convert device node to fwnode
    gpio: dwapb: remove name from dwapb_port_property
    gpio/qoriq: select IRQ_DOMAIN
    ...

    Linus Torvalds
     

12 Apr, 2016

2 commits


30 Mar, 2016

1 commit


25 Feb, 2016

1 commit

  • The R-Car GPIO driver handles Runtime PM for requested GPIOs only.

    When using a GPIO purely as an interrupt source, no Runtime PM handling
    is done, and the GPIO module's clock may not be enabled.

    To fix this:
    - Add .irq_request_resources() and .irq_release_resources() callbacks
    to handle Runtime PM when an interrupt is requested,
    - Add irq_bus_lock() and sync_unlock() callbacks to handle Runtime PM
    when e.g. disabling/enabling an interrupt, or configuring the
    interrupt type.

    Fixes: d5c3d84657db57bd "net: phy: Avoid polling PHY with PHY_IGNORE_INTERRUPTS"
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     

05 Jan, 2016

1 commit

  • This makes the driver use the data pointer added to the gpio_chip
    to store a pointer to the state container instead of relying on
    container_of().

    Cc: Ulrich Hecht
    Cc: Geert Uytterhoeven
    Cc: Hisashi Nakamura
    Signed-off-by: Linus Walleij

    Linus Walleij
     

11 Dec, 2015

2 commits

  • If the Renesas R-Car GPIO driver cannot find a functional clock, it
    prints a warning, .e.g.

    gpio_rcar ffc40000.gpio: unable to get clock

    and continues, as the clock is optional, depending on the SoC type.
    This warning may confuse users.

    To fix this, add a flag to indicate that the clock is mandatory or
    optional:
    - If the clock is mandatory (on R-Car Gen2 and Gen3), a missing clock
    is now treated as a fatal error,
    - If the clock is optional (on R-Car Gen1), the warning is no longer
    printed.

    Suggested-by: Magnus Damm
    Signed-off-by: Geert Uytterhoeven
    Acked-by: Simon Horman
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     
  • Since commit 4baadb9e05c68962 ("ARM: shmobile: r8a7778: remove obsolete
    setup code"), Renesas R-Car SoCs are only supported in generic DT-only
    ARM multi-platform builds. The driver doesn't need to use platform data
    anymore, hence remove platform data configuration.

    Make gpio_rcar_priv.has_both_edge_trigger a boolean for consistency with
    gpio_rcar_info.has_both_edge_trigger.
    Move gpio_rcar_priv.irq_parent down while we're at it, to prevent gaps
    on 64-bit.

    Signed-off-by: Geert Uytterhoeven
    Acked-by: Simon Horman
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     

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
     

27 Jul, 2015

1 commit


16 Jul, 2015

1 commit

  • Currently gpio modules are runtime-resumed at probe time. This means the
    gpio module will be active all the time (except during system suspend,
    if not configured as a wake-up source).

    While an R-Car Gen2 gpio module retains pins configured for output at
    the requested level while put in standby mode, gpio registercannot be
    accessed while suspended. Unfortunately pm_runtime_get_sync() cannot be
    called from all contexts where gpio register access is needed. Hence
    move the Runtime PM handling from probe/remove time to gpio request/free
    time, which is probably the best we can do.

    On r8a7791/koelsch, gpio modules 0, 1, 3, and 4 are now suspended during
    normal use (gpio2 is used for LEDs and regulators, gpio5 for keys, gpio6
    for SD-Card CD & WP, gpio7 for keys and regulators).

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     

01 Jun, 2015

1 commit

  • If an interrupt controller doesn't support wake-up configuration,
    irq_set_irq_wake() returns an error code. Then any subsequent call
    trying to deconfigure wake-up will cause an imbalance, and a warning
    will be printed:

    WARNING: CPU: 1 PID: 1341 at kernel/irq/manage.c:540 irq_set_irq_wake+0x9c/0xf8()
    Unbalanced IRQ 26 wake disable

    To fix this, refrain from any further parent interrupt controller
    (de)configuration if irq_set_irq_wake() failed.

    Alternative fixes would be:
    - calling "gic_set_irqchip_flags(IRQCHIP_SKIP_SET_WAKE)" from the
    platform code,
    - setting "gic_chip.flags = IRQCHIP_SKIP_SET_WAKE" in the GIC driver
    code,
    but these were withheld as the GIC hardware doesn't really support
    wake-up interrupts.

    Fixes: ab82fa7da4dce5c7 ("gpio: rcar: Prevent module clock disable when wake-up is enabled")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     

26 Mar, 2015

1 commit

  • When the GPIO module is needed for wake-up, it's module clock must not
    be disabled. Hence implement irq_chip.irq_set_wake(), which
    increments/decrements the clock's enable_count when needed, and forwards
    the wake-up state to the upstream interrupt controller.

    This fixes wake-up from s2ram using gpio-keys when using a PM Domain to
    manage the module clock.

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven