08 Jun, 2017

1 commit


23 Feb, 2017

1 commit

  • The pca953x type of devices, e.g. max7310, may have a reset which needs
    to be handled to get the device start working. Add a device_reset()
    call for that, and defer the probe if the reset controller for that is
    not ready yet.

    Signed-off-by: Shawn Guo
    Signed-off-by: Fugang Duan
    (cherry picked from commit: d3264091b30b777d94a18efda9823a06668d5b10)

    Shawn Guo
     

08 Nov, 2016

2 commits

  • Need to ensure that reg_output is not updated while setting multiple
    bits. This makes the mutex locking behaviour for the set_multiple call
    consistent with that of the set_value call.

    Cc: stable@vger.kernel.org
    Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple")
    Signed-off-by: Phil Reid
    Signed-off-by: Linus Walleij

    Phil Reid
     
  • gpiod_set_array_value_complex does not clear the bits field.
    Therefore when the drivers set_multiple funciton is called bits outside
    the mask are undefined and can be either set or not. So bank_val needs
    to be masked with bank_mask before or with the reg_val cache.

    Cc: stable@vger.kernel.org
    Fixes: b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple")
    Signed-off-by: Phil Reid
    Signed-off-by: Linus Walleij

    Phil Reid
     

12 Oct, 2016

1 commit


08 Oct, 2016

1 commit

  • Pull i2c updates from Wolfram Sang:
    "Here is the 4.9 pull request from I2C including:

    - centralized error messages when registering to the core
    - improved lockdep annotations to prevent false positives
    - DT support for muxes, gates, and arbitrators
    - bus speeds can now be obtained from ACPI
    - i2c-octeon got refactored and now supports ThunderX SoCs, too
    - i2c-tegra and i2c-designware got a bigger bunch of updates
    - a couple of standard driver fixes and improvements"

    * 'i2c/for-4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (71 commits)
    i2c: axxia: disable clks in case of failure in probe
    i2c: octeon: thunderx: Limit register access retries
    i2c: uniphier-f: fix misdetection of incomplete STOP condition
    gpio: pca953x: variable 'id' was used twice
    i2c: i801: Add support for Kaby Lake PCH-H
    gpio: pca953x: fix an incorrect lockdep warning
    i2c: add a warning to i2c_adapter_depth()
    lockdep: make MAX_LOCKDEP_SUBCLASSES unconditionally visible
    i2c: export i2c_adapter_depth()
    i2c: rk3x: Fix variable 'min_total_ns' unused warning
    i2c: rk3x: Fix sparse warning
    i2c / ACPI: Do not touch an I2C device if it belongs to another adapter
    i2c: octeon: Fix high-level controller status check
    i2c: octeon: Avoid sending STOP during recovery
    i2c: octeon: Fix set SCL recovery function
    i2c: rcar: add support for r8a7796 (R-Car M3-W)
    i2c: imx: make bus recovery through pinctrl optional
    i2c: meson: add gxbb compatible string
    i2c: uniphier-f: set the adapter to master mode when probing
    i2c: uniphier-f: avoid WARN_ON() of clk_disable() in failure path
    ...

    Linus Torvalds
     

24 Sep, 2016

2 commits

  • sparse rightfully said:

    drivers/gpio/gpio-pca953x.c:771:45: warning: symbol 'id' shadows an earlier one
    drivers/gpio/gpio-pca953x.c:742:36: originally declared here

    So, name them explicitly 'i2c_id' and 'acpi_id' to avoid any confusion.

    Signed-off-by: Wolfram Sang

    Wolfram Sang
     
  • If an I2C GPIO multiplexer is driven by a GPIO provided by an expander
    when there's a second expander using the same device driver on one of
    the I2C bus segments, lockdep prints a deadlock warning when trying to
    set the direction or the value of the GPIOs provided by the second
    expander.

    The below diagram presents the setup:

    - - - - -
    ------- --------- Bus segment 1 | |
    | | | |--------------- Devices
    | | SCL/SDA | | | |
    | Linux |-----------| I2C MUX | - - - - -
    | | | | | Bus segment 2
    | | | | |-------------------
    ------- | --------- |
    | | - - - - -
    ------------ | MUX GPIO | |
    | | | Devices
    | GPIO | | | |
    | Expander 1 |---- - - - - -
    | | |
    ------------ | SCL/SDA
    |
    ------------
    | |
    | GPIO |
    | Expander 2 |
    | |
    ------------

    The reason for lockdep warning is that we take the chip->i2c_lock in
    pca953x_gpio_set_value() or pca953x_gpio_direction_output() and then
    come right back to pca953x_gpio_set_value() when the GPIO mux kicks
    in. The locks actually protect different expanders, but for lockdep
    both are of the same class, so it says:

    Possible unsafe locking scenario:

    CPU0
    ----
    lock(&chip->i2c_lock);
    lock(&chip->i2c_lock);

    *** DEADLOCK ***

    May be due to missing lock nesting notation

    In order to get rid of the warning, retrieve the adapter nesting depth
    and use it as lockdep subclass for chip->i2c_lock.

    Signed-off-by: Bartosz Golaszewski
    Acked-by: Peter Rosin
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Linus Walleij
    Signed-off-by: Wolfram Sang

    Bartosz Golaszewski
     

13 Sep, 2016

1 commit


12 Sep, 2016

6 commits


07 Sep, 2016

1 commit

  • The recent addition of the regulator support has led to the pca953x_remove
    function returning uninitialized data when no platform data pointer is
    provided, as gcc warns when using -Wmaybe-uninitialized:

    drivers/gpio/gpio-pca953x.c: In function 'pca953x_remove':
    drivers/gpio/gpio-pca953x.c:860:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

    This restores the previous behavior, returning 0 on success.

    Signed-off-by: Arnd Bergmann
    Fixes: e23efa311110 ("gpio: pca954x: Add vcc regulator and enable it")
    Acked-by: Phil Reid
    Signed-off-by: Linus Walleij

    Arnd Bergmann
     

11 Aug, 2016

1 commit

  • Some i2c gpio devices are connected to a switchable power supply
    which needs to be enabled prior to probing the device. This patch
    allows the drive to enable the devices vcc regulator prior to probing.

    Signed-off-by: Phil Reid
    Signed-off-by: Linus Walleij

    Phil Reid
     

15 Jun, 2016

1 commit


13 Jun, 2016

1 commit

  • NBANK() macro assumes that ngpios is a multiple of 8(BANK_SZ) and
    hence results in 0 banks for PCA9536 which has just 4 gpios. This is
    wrong as PCA9356 has 1 bank with 4 gpios. This results in uninitialized
    PCA953X_INVERT register. Fix this by using DIV_ROUND_UP macro in
    NBANK().

    Cc: stable@vger.kernel.org
    Signed-off-by: Vignesh R
    Signed-off-by: Linus Walleij

    Vignesh R
     

08 Jun, 2016

1 commit

  • The commit 9b8e3ec34318 ("gpio: pca953x: Use correct u16 value for register
    word write") fixed regression in pca953x_write_regs(). At the same time the
    solution introduced a sparse warning:

    drivers/gpio/gpio-pca953x.c:168:39: warning: incorrect type in argument 3 (different base types)
    drivers/gpio/gpio-pca953x.c:168:39: expected unsigned short [unsigned] [usertype] value
    drivers/gpio/gpio-pca953x.c:168:39: got restricted __le16 [usertype]

    Fix the code by enforcing the type of i2c_smbus_write_word_data() parameter.

    Cc: Yong Li
    Cc: Phil Reid
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Linus Walleij

    Andy Shevchenko
     

07 Jun, 2016

2 commits


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
     

10 Apr, 2016

1 commit

  • Galileo Gen2 board uses the PCAL9535 as the GPIO expansion,
    it is different from PCA9535 and includes interrupt mask/status registers,
    The current driver does not support the interrupt registers configuration,
    it causes some gpio pins cannot trigger interrupt events,
    this patch fix this issue.

    The original patch was submitted by
    Josef Ahmad
    http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-quark/tree/recipes-kernel/linux/files/0015-Quark-GPIO-1-2-quark.patch

    Signed-off-by: Yong Li
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Linus Walleij

    Yong Li
     

08 Apr, 2016

1 commit


16 Mar, 2016

1 commit

  • pca953x_gpio_set_multiple() divides by 4 to convert from longs to bytes,
    which assumes a 32-bit platform, and is not correct on 64-bit platforms.
    Use "sizeof(...)" instead to fix this.

    Cc: stable@vger.kernel.org
    Fixes: b4818afeacbd8182 ("gpio: pca953x: Add set_multiple to allow multiple bits to be set in one write.")
    Signed-off-by: Geert Uytterhoeven
    Acked-by: Phil Reid
    Signed-off-by: Linus Walleij

    Geert Uytterhoeven
     

23 Feb, 2016

1 commit


05 Jan, 2016

1 commit


11 Dec, 2015

1 commit


09 Dec, 2015

3 commits

  • After adding the DT matching in
    commit 6f29c9afbe636fc0e35c82a11eaf45c3b85eb07a
    "gpio: pca935x: fix of-only probed devices"
    compilation fails like this:

    CC [M] drivers/gpio/gpio-pca953x.o
    gpio-pca953x.c: In function ‘pca953x_probe’:
    gpio-pca953x.c:693:11: error: implicit declaration of
    function ‘of_match_device’ [-Werror=implicit-function-declaration]
    match = of_match_device(pca953x_dt_ids, &client->dev);
    ^
    gpio-pca953x.c:693:9: warning: assignment makes pointer from
    integer without a cast [-Wint-conversion]
    match = of_match_device(pca953x_dt_ids, &client->dev);
    ^
    cc1: some warnings being treated as errors
    ../scripts/Makefile.build:264: recipe for target
    'drivers/gpio/gpio-pca953x.o' failed

    After removing the conditional inclusion guards compilation
    works fine again. Might be a module problem so that
    fix.

    Cc: Ben Dooks
    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • If the pca953x device is probed from OF using the proper OF probing then
    the i2c-client will be NULL and the device probe will fail as id is NULL
    and it isn't an ACPI device (previous drivers would simply OOPS out).

    Add support for the of_device_id table having the same data as the others
    so that the correct paths will be taken when registering a device.

    An example of current valid of node which did not work:

    gpio@38 {
    compatible = "onsemi,pca9654", "nxp,pca9534";
    reg = ;
    interrupt-parent = ;
    interrupts = ;
    };

    Signed-off-by: Ben Dooks
    Signed-off-by: Linus Walleij

    Ben Dooks
     
  • Add onsemi,pca9654 which is also compatible with the nxp,pca9524 as it
    is an 8bit expander with an interrupt output.

    Signed-off-by: Ben Dooks
    Signed-off-by: Linus Walleij

    Ben Dooks
     

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
     

05 Oct, 2015

2 commits


03 Oct, 2015

1 commit


02 Oct, 2015

1 commit

  • This fixes error checking in the function device_pca957x_init
    to properly check and return error code values from the calls
    to the function pca953x_write_regs if they fail as to properly
    signal callers when a error occurs due a failure when writing
    registers for this gpio based device.

    Signed-off-by: Nicholas Krause
    Reviewed-by: Alexandre Courbot
    Signed-off-by: Linus Walleij

    Nicholas Krause
     

16 Jul, 2015

1 commit

  • pca953x interrupt controller functionality is implemented using
    nested threaded IRQs which require parent_irq to be configured
    properly otherwise below warning can be seen if IRQ core
    will try re-schedule nested IRQ:

    ------------[ cut here ]------------
    WARNING: CPU: 1 PID: 12 at kernel/irq/manage.c:696 irq_nested_primary_handler+0x30/0x38()
    Primary handler called for nested irq 301
    Modules linked in: uinput ipv6 smsc95xx usbnet mii imx2_wdt etnaviv(C) matrix_keypad matrix_keymap ar1021_i2c
    CPU: 1 PID: 12 Comm: ksoftirqd/1 Tainted: G WC 4.1.1 #9
    Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
    Backtrace:
    [] (dump_backtrace) from [] (show_stack+0x20/0x24)
    [] (show_stack) from [] (dump_stack+0x70/0xc0)
    [] (dump_stack) from [] (warn_slowpath_common+0x88/0xc0)
    [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x40/0x48)
    [] (warn_slowpath_fmt) from [] (irq_nested_primary_handler+0x30/0x38)
    [] (irq_nested_primary_handler) from [] (handle_irq_event_percpu+0x70/0x2d0)
    [] (handle_irq_event_percpu) from [] (handle_irq_event+0x4c/0x6c)
    [] (handle_irq_event) from [] (handle_simple_irq+0xa4/0xc8)
    [] (handle_simple_irq) from [] (resend_irqs+0x50/0x7c)
    [] (resend_irqs) from [] (tasklet_action+0x94/0x140)
    [] (tasklet_action) from [] (__do_softirq+0xa0/0x3c8)
    [] (__do_softirq) from [] (run_ksoftirqd+0x38/0x54)
    [] (run_ksoftirqd) from [] (smpboot_thread_fn+0x1f8/0x2f0)
    [] (smpboot_thread_fn) from [] (kthread+0xe8/0x104)
    [] (kthread) from [] (ret_from_fork+0x14/0x2c)
    ---[ end trace 96052cda48865769 ]---

    The issue was reported and described in details by Lothar Waßmann and
    Christian Gmeiner in https://lkml.org/lkml/2014/9/9/123.

    Fix it by adding missed call of gpiochip_set_chained_irqchip()
    so GPIO IRQ chip helpers will set parent_irq for nested IRQs
    properly.

    Reported-by: Lothar Waßmann
    Tested-by: Christian Gmeiner
    Signed-off-by: Grygorii Strashko
    Signed-off-by: Linus Walleij

    Grygorii Strashko
     

01 Jun, 2015

1 commit

  • Interrupts were missed if an 8-bit integer overflow occurred. This was
    observed when bank0,pin7 and bank1,pin7 changed simultaniously.

    As the 8-bit totals were only checked against zero, replace them with
    booleans. Name the booleans so that their purpose is clear.

    Signed-off-by: Joshua Scott
    Reviewed-by: Alexandre Courbot
    Signed-off-by: Linus Walleij

    Joshua Scott
     

19 May, 2015

1 commit