aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-07 15:40:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-07 15:40:27 -0400
commitc7d28eca1d58d335ff8de6f33559b221bdd029f9 (patch)
tree3522cae5809d6912ccc307a4b0a7dea3ffeb8225 /drivers/gpio/gpiolib.c
parentdddd564dbb5934c9a0c401491cafb98ab1c82fc6 (diff)
parent413058df4331ce29f9934a5870d582c7e71fe15f (diff)
Merge tag 'gpio-v4.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v4.13 series. Some administrativa: I have a slew of 8250 serial patches and the new IOT2040 serial+GPIO driver coming in through this tree, along with a whole bunch of Exar 8250 fixes. These are ACKed by Greg and also hit drivers/platform/* where they are ACKed by Andy Shevchenko. Speaking about drivers/platform/* there is also a bunch of ACPI stuff coming through that route, again ACKed by Andy. The MCP23S08 changes are coming in here as well. You already have the commits in your tree, so this is just a result of sharing an immutable branch between pin control and GPIO. Core: - Export add/remove for lookup tables so that modules can export GPIO descriptor tables. - Handle GPIO sleep states: it is now possible to flag that a GPIO line may loose its state during suspend/resume of the system to save power. This is used in the Wolfson Micro Arizona driver. - ACPI-based GPIO was tightened up a lot around the edges. - Use bitmap_fill() to speed up a loop. New drivers: - Exar XRA1403 SPI-based GPIO. - MVEBU driver now supports Armada 7K and 8K. - LP87565 PMIC GPIO. - Renesas R-CAR R8A7743 (RZ/G1M). - The new IOT2040 8250 serial/GPIO also comes in through this changeset. Substantial driver changes: - Seriously fix the Exar 8250 GPIO portions to work. - The MCP23S08 was moved out to a pin control driver. - Convert MEVEBU to use regmap for register access. - Drop Vulcan support from the Broadcom driver. - Serious cleanup and improvement of the mockup driver, giving us a better test coverage. Misc: - Lots of janitorial clean up. - A bunch of documentation fixes" * tag 'gpio-v4.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (70 commits) serial: exar: Add support for IOT2040 device gpio-exar/8250-exar: Make set of exported GPIOs configurable platform: Accept const properties serial: exar: Factor out platform hooks gpio-exar/8250-exar: Rearrange gpiochip parenthood gpio: exar: Fix iomap request gpio-exar/8250-exar: Do not even instantiate a GPIO device for Commtech cards serial: uapi: Add support for bus termination gpio: rcar: Add R8A7743 (RZ/G1M) support gpio: gpio-wcove: Fix GPIO control register offset calculation gpio: lp87565: Add support for GPIO gpio: dwapb: fix missing first irq for edgeboth irq type MAINTAINERS: Take maintainership for GPIO ACPI support gpio: exar: Fix reading of directions and values gpio: exar: Allocate resources on behalf of the platform device gpio-exar/8250-exar: Fix passing in of parent PCI device gpio: mockup: use devm_kcalloc() where applicable gpio: mockup: add myself as author gpio: mockup: improve the error message gpio: mockup: don't return magic numbers from probe() ...
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a42a1eea5714..9568708a550b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1,4 +1,4 @@
1#include <linux/bitops.h> 1#include <linux/bitmap.h>
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/interrupt.h> 4#include <linux/interrupt.h>
@@ -1472,8 +1472,6 @@ static struct gpio_chip *find_chip_by_name(const char *name)
1472 1472
1473static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip) 1473static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip)
1474{ 1474{
1475 int i;
1476
1477 if (!gpiochip->irq_need_valid_mask) 1475 if (!gpiochip->irq_need_valid_mask)
1478 return 0; 1476 return 0;
1479 1477
@@ -1483,8 +1481,7 @@ static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip)
1483 return -ENOMEM; 1481 return -ENOMEM;
1484 1482
1485 /* Assume by default all GPIOs are valid */ 1483 /* Assume by default all GPIOs are valid */
1486 for (i = 0; i < gpiochip->ngpio; i++) 1484 bitmap_fill(gpiochip->irq_valid_mask, gpiochip->ngpio);
1487 set_bit(i, gpiochip->irq_valid_mask);
1488 1485
1489 return 0; 1486 return 0;
1490} 1487}
@@ -2870,6 +2867,16 @@ bool gpiochip_line_is_open_source(struct gpio_chip *chip, unsigned int offset)
2870} 2867}
2871EXPORT_SYMBOL_GPL(gpiochip_line_is_open_source); 2868EXPORT_SYMBOL_GPL(gpiochip_line_is_open_source);
2872 2869
2870bool gpiochip_line_is_persistent(struct gpio_chip *chip, unsigned int offset)
2871{
2872 if (offset >= chip->ngpio)
2873 return false;
2874
2875 return !test_bit(FLAG_SLEEP_MAY_LOOSE_VALUE,
2876 &chip->gpiodev->descs[offset].flags);
2877}
2878EXPORT_SYMBOL_GPL(gpiochip_line_is_persistent);
2879
2873/** 2880/**
2874 * gpiod_get_raw_value_cansleep() - return a gpio's raw value 2881 * gpiod_get_raw_value_cansleep() - return a gpio's raw value
2875 * @desc: gpio whose value will be returned 2882 * @desc: gpio whose value will be returned
@@ -3009,6 +3016,7 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
3009 3016
3010 mutex_unlock(&gpio_lookup_lock); 3017 mutex_unlock(&gpio_lookup_lock);
3011} 3018}
3019EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);
3012 3020
3013/** 3021/**
3014 * gpiod_remove_lookup_table() - unregister GPIO device consumers 3022 * gpiod_remove_lookup_table() - unregister GPIO device consumers
@@ -3022,6 +3030,7 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
3022 3030
3023 mutex_unlock(&gpio_lookup_lock); 3031 mutex_unlock(&gpio_lookup_lock);
3024} 3032}
3033EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table);
3025 3034
3026static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev) 3035static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev)
3027{ 3036{
@@ -3213,7 +3222,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional);
3213 * requested function and/or index, or another IS_ERR() code if an error 3222 * requested function and/or index, or another IS_ERR() code if an error
3214 * occurred while trying to acquire the GPIO. 3223 * occurred while trying to acquire the GPIO.
3215 */ 3224 */
3216static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, 3225int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
3217 unsigned long lflags, enum gpiod_flags dflags) 3226 unsigned long lflags, enum gpiod_flags dflags)
3218{ 3227{
3219 int status; 3228 int status;
@@ -3224,6 +3233,8 @@ static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
3224 set_bit(FLAG_OPEN_DRAIN, &desc->flags); 3233 set_bit(FLAG_OPEN_DRAIN, &desc->flags);
3225 if (lflags & GPIO_OPEN_SOURCE) 3234 if (lflags & GPIO_OPEN_SOURCE)
3226 set_bit(FLAG_OPEN_SOURCE, &desc->flags); 3235 set_bit(FLAG_OPEN_SOURCE, &desc->flags);
3236 if (lflags & GPIO_SLEEP_MAY_LOOSE_VALUE)
3237 set_bit(FLAG_SLEEP_MAY_LOOSE_VALUE, &desc->flags);
3227 3238
3228 /* No particular flag request, return here... */ 3239 /* No particular flag request, return here... */
3229 if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) { 3240 if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
@@ -3273,7 +3284,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
3273 desc = of_find_gpio(dev, con_id, idx, &lookupflags); 3284 desc = of_find_gpio(dev, con_id, idx, &lookupflags);
3274 } else if (ACPI_COMPANION(dev)) { 3285 } else if (ACPI_COMPANION(dev)) {
3275 dev_dbg(dev, "using ACPI for GPIO lookup\n"); 3286 dev_dbg(dev, "using ACPI for GPIO lookup\n");
3276 desc = acpi_find_gpio(dev, con_id, idx, flags, &lookupflags); 3287 desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags);
3277 } 3288 }
3278 } 3289 }
3279 3290
@@ -3354,8 +3365,12 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3354 struct acpi_gpio_info info; 3365 struct acpi_gpio_info info;
3355 3366
3356 desc = acpi_node_get_gpiod(fwnode, propname, index, &info); 3367 desc = acpi_node_get_gpiod(fwnode, propname, index, &info);
3357 if (!IS_ERR(desc)) 3368 if (!IS_ERR(desc)) {
3358 active_low = info.polarity == GPIO_ACTIVE_LOW; 3369 active_low = info.polarity == GPIO_ACTIVE_LOW;
3370 ret = acpi_gpio_update_gpiod_flags(&dflags, info.flags);
3371 if (ret)
3372 pr_debug("Override GPIO initialization flags\n");
3373 }
3359 } 3374 }
3360 3375
3361 if (IS_ERR(desc)) 3376 if (IS_ERR(desc))