aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio
AgeCommit message (Collapse)AuthorFilesLines
2016-01-05gpio: generic: factor into gpio_chip structLinus Walleij14-463/+379
The separate struct bgpio_chip has been a pain to handle, both by being confusingly similar in name to struct gpio_chip and for being contained inside a struct so that struct gpio_chip is contained in a struct contained in a struct, making several steps of dereferencing necessary. Make things simpler: include the fields directly into <linux/gpio/driver.h>, #ifdef:ed for CONFIG_GENERIC_GPIO, and get rid of the <linux/basic_mmio_gpio.h> altogether. Prefix some of the member variables with bgpio_* and add proper kerneldoc while we're at it. Modify all users to handle the change and use a struct gpio_chip directly. And while we're at it: replace all container_of() dereferencing by gpiochip_get_data() and registering the gpio_chip with gpiochip_add_data(). Cc: [email protected] Cc: Alexander Shiyan <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Kukjin Kim <[email protected]> Cc: Alexandre Courbot <[email protected]> Cc: Brian Norris <[email protected]> Cc: Florian Fainelli <[email protected]> Cc: Sudeep Holla <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Vladimir Zapolskiy <[email protected]> Cc: Rabin Vincent <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Acked-by: Gregory Fong <[email protected]> Acked-by: Liviu Dudau <[email protected]> Acked-by: H Hartley Sweeten <[email protected]> Acked-by: Tony Lindgren <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Acked-by: Lee Jones <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-01-05gpio: of: provide optional of_mm_gpiochip_add_data() functionLinus Walleij1-5/+7
In the same spirit as we add an optional void *data argument to the gpiochip_add_data() call, we need this also for of_mm_gpiochip_add(). Signed-off-by: Linus Walleij <[email protected]>
2016-01-05gpio: add a data pointer to gpio_chipLinus Walleij1-4/+6
This adds a void * pointer to gpio_chip so that driver can assign and retrieve some states. This is done to get rid of container_of() calls for gpio_chips embedded inside state containers, so we can remove the need to have the gpio_chip or later (planned) struct gpio_device be dynamically allocated at registration time, so that its struct device can be properly reference counted and not bound to its parent device (e.g. a platform_device) but instead live on after unregistration if it is opened by e.g. a char device or sysfs. The data is added with the new function gpiochip_add_data() and for compatibility we add static inline wrapper function gpiochip_add() that will call gpiochip_add_data() with NULL as argument. The latter will be removed once we have exorcised gpiochip_add() from the kernel. gpiochip_get_data() is added as a static inline accessor for drivers to quickly get their data out. Signed-off-by: Linus Walleij <[email protected]>
2016-01-05gpio: pxa: checking IS_ERR() instead of NULLDan Carpenter1-2/+2
irq_domain_add_legacy() returns NULL on error, it doesn't return error pointers. Fixes: 384ca3c6a28d ('gpio: pxa: change the interrupt management') Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-01-05gpio: generic: fix signedness bug found by cppcheckLinus Walleij1-2/+3
cppcheck reports this: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. This can be fixed with (1UL << pin) but that is the same as using <linux/bitops.h> that already use 1UL so take this approach. Reported-by: David Binderman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2016-01-01ACPI / gpio: Add irq_type when a GPIO is used as an interruptChristophe RICARD3-9/+31
When a GPIO is used as an interrupt in ACPI, the irq_type was not available for device driver. Make available polarity and triggering information in acpi_find_gpio by renaming acpi_gpio_info field active_low to polarity and adding triggering field (edge/level). For sanity, in gpiolib.c replace info.active_low by "info.polarity == GPIO_ACTIVE_LOW". Set the irq_type if necessary in acpi_dev_gpio_irq_get. Signed-off-by: Christophe Ricard <[email protected]> Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
2015-12-27gpio: fix warning about iteratorSudip Mukherjee1-8/+12
We were getting build warning about "iterator" being used uninitialized. Use iterator properly to fix the build warning and in the process remove the variable "pos" which is not required now. Signed-off-by: Sudip Mukherjee <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26Revert "gpio: revert get() to non-errorprogating behaviour"Linus Walleij1-7/+1
This reverts commit 45ad7db90b42555c8107f18ec6d6a1e9bce34860. We have fixed all the drivers that were returning ambious values not clamped to [0,1] or an error code, so return the error propagating behaviour of the API. Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: viperboard: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Lars Poeschel <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: ucb1400: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: tz1090-pdc: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: James Hogan <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: tz1090: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: James Hogan <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: twl4030: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. This also makes the driver start to return the error code, as the end of the series make this work. Cc: Roger Quadros <[email protected]> Cc: Tony Lindgren <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: tc3589x: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: sx150x: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. This also starts to propagate the error code from the I2C transaction as the end of the series adds support for that. Cc: Wei Chen <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: sta2x11: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Alessandro Rubini <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: sa1100: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Russell King <[email protected]> Cc: Dmitry Eremin-Solenikov <[email protected]> Cc: Kristoffer Ericson <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: pch: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Thierry Reding <[email protected]> Cc: Daniel Krueger <[email protected]> Cc: Jean Delvare <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: pcf857x: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Also start returning the error code if something fails, as the end of the series augment the core to support this. Cc: Grygorii Strashko <[email protected]> Cc: George Cherian <[email protected]> Cc: Laurent Pinchart <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: msic: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: Mathias Nyman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: mpc8xxx: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Uwe Kleine-König <[email protected]> Cc: Alexander Stein <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: ml-ioh: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Feng Tang <[email protected]> Cc: Tomoya MORINAGA <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: max732x: Be sure to clamp return valueLinus Walleij1-2/+2
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Also start to propagate the error code here as the end of the series fixes this to work for all drivers. Cc: Semen Protsenko <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Reviewed-by:Nicholas Krause <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: lpc32xx: Be sure to clamp return valueLinus Walleij1-4/+4
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Roland Stigge <[email protected]> Cc: Vladimir Zapolskiy <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: kempld: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Brunner Michael <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: janz-ttl: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Ira W. Snyder <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: intel-mid: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Acked-by: David Cohen <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: em: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Magnus Damm <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: davinci: Be sure to clamp return valueLinus Walleij1-1/+1
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Sekhar Nori <[email protected]> Cc: Santosh Shilimkar <[email protected]> Reviewed-by: Grygorii Strashko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-26gpio: da9052: Be sure to clamp return valueLinus Walleij1-6/+3
As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. Cc: Ashish Jangam <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-22gpio: sx150x: Add support for sx1502Peter Rosin1-4/+49
Signed-off-by: Peter Rosin <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-22gpio: 104-idi-48: Clear pending interrupt once in IRQ handlerWilliam Breathitt Gray1-10/+9
Performing a read operation on the IRQ Status register will clear the IRQ latch. Since a read operation on the IRQ Status register must be performed in the IRQ handler in order to determine if the IRQ was in fact generated by the device, the IRQ latch is consequently cleared by the IRQ handler. A spinlock is used to guarantee that each IRQ is serviced in the order it was received. Signed-off-by: William Breathitt Gray <[email protected]>
2015-12-22gpio: pxa: fixes non devicetree buildsRobert Jarzmik1-13/+13
The commit "gpio: pxa: change the interrupt management" should have taken care of moving an ifdef to not englobe irqdomain related structures anymore, as they are used now for all builds. This repairs the broken builds where CONFIG_OF=n. Signed-off-by: Robert Jarzmik <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-21Merge tag 'v4.4-rc6' into develLinus Walleij8-59/+79
Linux 4.4-rc6
2015-12-17gpio: revert get() to non-errorprogating behaviourLinus Walleij1-1/+7
commit e20538b82f1f ("gpio: Propagate errors from chip->get()") started to propagate errors from the .get() functions since we can get errors from the infrastructure of e.g. slowbus GPIO expanders. However it turns out a bunch of drivers relied on the core to clamp the value, so we need to revert to the old behaviour and go over all drivers and fix them to conform to the expectations of the core before we go back to propagating the error code. Cc: [email protected] # 4.3+ Cc: Bjorn Andersson <[email protected]> Cc: Vladimir Zapolskiy <[email protected]> Fixes: e20538b82f1f ("gpio: Propagate errors from chip->get()") Reported-by: Michael Trimarchi <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-17gpio: generic: clamp values from bgpio_get_set()Linus Walleij1-2/+2
The bgpio_get_set() call should return a value clamped to [0,1], the current code will return a negative value if reading bit 31, which turns the value negative as this is a signed value and thus gets interpreted as an error by the gpiolib core. Found on the gpio-mxc but applies to any MMIO driver. Cc: [email protected] # 4.3+ Cc: [email protected] Cc: Vladimir Zapolskiy <[email protected]> Fixes: e20538b82f1f ("gpio: Propagate errors from chip->get()") Reported-by: Clemens Gruber <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-15Merge branch 'for-dmitry' of ↵Dmitry Torokhov3-0/+54
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio into goodix Bring in changes to ACPI GPIOLIB to better handle legacy ACPI mappings needed for subsequent Goodix driver changes.
2015-12-15gpio: pch: fix non-DT buildLinus Walleij1-0/+2
commit 1cfadea8f395e3fb6a15ea548e3e86c8b6d64f98 "gpio: pch: allow use from device tree" makes the driver not compile unless CONFIG_OF_GPIO is set. Fix it. Cc: Paul Burton <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-15gpio: pxa: add pin control gpio direction and requestRobert Jarzmik1-0/+23
If a pin control driver is available, use it to change the gpio direction. If not fallback to directly manipulating the gpio direction register. The reason to use the pin control driver first is that pin control in pxa2xx architecture implies changing the gpio direction, even for non gpio functions. In order to do it atomically, only one driver should control the gpio direction, and if a pin controller is available, it has to be him. There is a small catch : if CONFIG_PINCTRL is selected, then a pinctrl driver has to be probed. If not, gpio_request() will return -EPROBE_DEFER as pinctrl_request_gpio() returns it in that case. Signed-off-by: Robert Jarzmik <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-14gpio: pl061: add support for wakeup configurationSudeep Holla1-0/+9
The PL061 supports interrupts and those can be wakeup interrupts. We need to provide support for configuring those interrupts as wakeup sources. This patch adds irq_set_wake callback for PL061 so that GPIO interrupts can be configured as wakeup. Cc: Linus Walleij <[email protected]> Cc: Alexandre Courbot <[email protected]> Signed-off-by: Sudeep Holla <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-14gpio: zynq: Do PM initialization earlier to support gpio hogsMichal Simek1-10/+9
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 <[email protected]> Signed-off-by: Soren Brinkmann <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-13gpiolib: tighten up ACPI legacy gpio lookupsDmitry Torokhov3-0/+54
We should not fall back to the legacy unnamed gpio lookup style if the driver requests gpios with different names, because we'll give out the same gpio twice. Let's keep track of the names that were used for the device and only do the fallback for the first name used. Signed-off-by: Dmitry Torokhov <[email protected]> Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-11gpio: forward-declare enum gpiod_flagsLinus Walleij1-1/+1
This enum is used in the gpiolib.h header file, yet <linux/gpio/consumer.h> is not included so plainly including this file (and some drivers do) will raise compile problems. Signed-off-by: Linus Walleij <[email protected]>
2015-12-11gpio: ath79: Fix the logic to clear offset bit of AR71XX_GPIO_REG_OE registerAxel Lin1-1/+1
Signed-off-by: Axel Lin <[email protected]> Acked-by: Alban Bedel <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-11gpio: rcar: Improve clock error handling and reportingGeert Uytterhoeven1-1/+10
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 <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> Acked-by: Simon Horman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-11gpio: rcar: Remove obsolete platform data supportGeert Uytterhoeven1-51/+26
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 <[email protected]> Acked-by: Simon Horman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-11gpio: Restore indentation of parent device setupGeert Uytterhoeven3-3/+3
Fixes: 58383c78425e4ee1 ("gpio: change member .dev to .parent") Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-10gpio: pca953x: Add set_multiple to allow multiple bits to be set in one write.Phil Reid1-0/+38
Tested with TCA6408 / TCA6416 devices. Signed-off-by: Phil Reid <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-10gpio: mpc5200: Use platform_register/unregister_drivers()Thierry Reding1-10/+7
These new helpers simplify implementing multi-driver modules and properly handle failure to register one driver by unregistering all previously registered drivers. Signed-off-by: Thierry Reding <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
2015-12-10gpio: 104-idio-16: Clear pending interrupt in IRQ handlerWilliam Breathitt Gray1-10/+7
The ACCES 104-IDIO-16 uses a single interrupt to indicate a possible change-of-state in any of the digital input lines. As such, only a single write to the device's "Clear Interrupt" register is necessary to acknowledge the IRQ for all respective GPIO. This patch moves the "Clear Interrupt" register write operation from the irq_ack callback to the IRQ handler function, wherefore each interrupt may be cleared respectively by executing a single outb call at the end of the idio_16_irq_handler function, rather than multiple redundant outb calls as a result of the generic_handle_irq call for each masked GPIO. Signed-off-by: William Breathitt Gray <[email protected]> Signed-off-by: Linus Walleij <[email protected]>