* [PATCH v4 0/4] gpio / ACPI: convert users to gpiod_* and drop acpi_gpio.h
@ 2014-01-08 10:40 Mika Westerberg
2014-01-08 10:40 ` [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically Mika Westerberg
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Mika Westerberg @ 2014-01-08 10:40 UTC (permalink / raw)
To: linux-acpi
Cc: Rafael J. Wysocki, Linus Walleij, Chris Ball, Johannes Berg,
Rhyland Klein, Adrian Hunter, Heikki Krogerus, Mathias Nyman,
Alexandre Courbot, Rob Landley, Stephen Warren, Thierry Reding,
Mika Westerberg, linux-gpio, linux-kernel
Hi,
This is fourth revision of the patch series. The previous version can be
found here [1].
We convert the remaining user (sdhci-acpi) to use the GPIO descriptor API
and get rid for ACPI specific GPIO helpers in favor of the new GPIO
descriptor API.
Changes to v3:
* Dropped patches 1 and 2 as they got merged already.
* Rebased on top of latest linux-gpio.git devel -branch.
* Moved patch [4/4] in previous version to be the first in this version.
[1] https://lkml.org/lkml/2013/11/26/104
Mika Westerberg (4):
gpio / ACPI: register to ACPI events automatically
mmc: sdhci-acpi: convert to use GPIO descriptor API
gpio / ACPI: get rid of acpi_gpio.h
Documentation / ACPI: update to GPIO descriptor API
Documentation/acpi/enumeration.txt | 36 ++++++---------------------
drivers/gpio/gpiolib-acpi.c | 21 +++++++++++-----
drivers/gpio/gpiolib.c | 5 +++-
drivers/gpio/gpiolib.h | 46 ++++++++++++++++++++++++++++++++++
drivers/mmc/host/sdhci-acpi.c | 26 +++++++++----------
drivers/pinctrl/pinctrl-baytrail.c | 4 ---
include/linux/acpi_gpio.h | 51 --------------------------------------
7 files changed, 84 insertions(+), 105 deletions(-)
create mode 100644 drivers/gpio/gpiolib.h
delete mode 100644 include/linux/acpi_gpio.h
--
1.8.5.2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically
2014-01-08 10:40 [PATCH v4 0/4] gpio / ACPI: convert users to gpiod_* and drop acpi_gpio.h Mika Westerberg
@ 2014-01-08 10:40 ` Mika Westerberg
2014-01-08 11:55 ` Linus Walleij
2014-01-08 10:40 ` [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API Mika Westerberg
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2014-01-08 10:40 UTC (permalink / raw)
To: linux-acpi
Cc: Rafael J. Wysocki, Linus Walleij, Chris Ball, Johannes Berg,
Rhyland Klein, Adrian Hunter, Heikki Krogerus, Mathias Nyman,
Alexandre Courbot, Rob Landley, Stephen Warren, Thierry Reding,
Mika Westerberg, linux-gpio, linux-kernel
Instead of asking each driver to register to ACPI events we can just call
acpi_gpiochip_register_interrupts() for each chip that has an ACPI handle.
The function checks chip->to_irq and if it is set to NULL (a GPIO driver
that doesn't do interrupts) the function does nothing.
We also add the a new header drivers/gpio/gpiolib.h that is used for
functions internal to gpiolib and add ACPI GPIO chip registering functions
to that header.
Once that is done we can remove call to acpi_gpiochip_register_interrupts()
from its only user, pinctrl-baytrail.c
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/gpio/gpiolib-acpi.c | 16 ++++++++++++----
drivers/gpio/gpiolib.c | 4 ++++
drivers/gpio/gpiolib.h | 23 +++++++++++++++++++++++
drivers/pinctrl/pinctrl-baytrail.c | 4 ----
include/linux/acpi_gpio.h | 6 ------
5 files changed, 39 insertions(+), 14 deletions(-)
create mode 100644 drivers/gpio/gpiolib.h
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 137d20c70afe..739b72b6731a 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -94,7 +94,7 @@ static void acpi_gpio_evt_dh(acpi_handle handle, void *data)
* gpio pins have acpi event methods and assigns interrupt handlers that calls
* the acpi event methods for those pins.
*/
-void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
+static void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
{
struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_resource *res;
@@ -192,7 +192,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
irq);
}
}
-EXPORT_SYMBOL(acpi_gpiochip_request_interrupts);
/**
* acpi_gpiochip_free_interrupts() - Free GPIO _EVT ACPI event interrupts.
@@ -203,7 +202,7 @@ EXPORT_SYMBOL(acpi_gpiochip_request_interrupts);
* The remaining ACPI event interrupts associated with the chip are freed
* automatically.
*/
-void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
+static void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
{
acpi_handle handle;
acpi_status status;
@@ -230,7 +229,6 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
acpi_detach_data(handle, acpi_gpio_evt_dh);
kfree(evt_pins);
}
-EXPORT_SYMBOL(acpi_gpiochip_free_interrupts);
struct acpi_gpio_lookup {
struct acpi_gpio_info info;
@@ -310,3 +308,13 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT);
}
EXPORT_SYMBOL_GPL(acpi_get_gpiod_by_index);
+
+void acpi_gpiochip_add(struct gpio_chip *chip)
+{
+ acpi_gpiochip_request_interrupts(chip);
+}
+
+void acpi_gpiochip_remove(struct gpio_chip *chip)
+{
+ acpi_gpiochip_free_interrupts(chip);
+}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c0b06a9adad9..0de4069e33ab 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -16,6 +16,8 @@
#include <linux/acpi.h>
#include <linux/gpio/driver.h>
+#include "gpiolib.h"
+
#define CREATE_TRACE_POINTS
#include <trace/events/gpio.h>
@@ -1226,6 +1228,7 @@ int gpiochip_add(struct gpio_chip *chip)
#endif
of_gpiochip_add(chip);
+ acpi_gpiochip_add(chip);
if (status)
goto fail;
@@ -1267,6 +1270,7 @@ int gpiochip_remove(struct gpio_chip *chip)
gpiochip_remove_pin_ranges(chip);
of_gpiochip_remove(chip);
+ acpi_gpiochip_remove(chip);
for (id = 0; id < chip->ngpio; id++) {
if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) {
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
new file mode 100644
index 000000000000..2ed23ab8298c
--- /dev/null
+++ b/drivers/gpio/gpiolib.h
@@ -0,0 +1,23 @@
+/*
+ * Internal GPIO functions.
+ *
+ * Copyright (C) 2013, Intel Corporation
+ * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef GPIOLIB_H
+#define GPIOLIB_H
+
+#ifdef CONFIG_ACPI
+void acpi_gpiochip_add(struct gpio_chip *chip);
+void acpi_gpiochip_remove(struct gpio_chip *chip);
+#else
+static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
+static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
+#endif
+
+#endif /* GPIOLIB_H */
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index e15668ef17cd..e58e51e691e1 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -29,7 +29,6 @@
#include <linux/gpio.h>
#include <linux/irqdomain.h>
#include <linux/acpi.h>
-#include <linux/acpi_gpio.h>
#include <linux/platform_device.h>
#include <linux/seq_file.h>
#include <linux/io.h>
@@ -485,9 +484,6 @@ static int byt_gpio_probe(struct platform_device *pdev)
irq_set_handler_data(hwirq, vg);
irq_set_chained_handler(hwirq, byt_gpio_irq_handler);
-
- /* Register interrupt handlers for gpio signaled acpi events */
- acpi_gpiochip_request_interrupts(gc);
}
pm_runtime_enable(dev);
diff --git a/include/linux/acpi_gpio.h b/include/linux/acpi_gpio.h
index d875bc3dba3c..af96a0d452f6 100644
--- a/include/linux/acpi_gpio.h
+++ b/include/linux/acpi_gpio.h
@@ -21,9 +21,6 @@ struct acpi_gpio_info {
struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
struct acpi_gpio_info *info);
-void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
-void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
-
#else /* CONFIG_GPIO_ACPI */
static inline struct gpio_desc *
@@ -33,9 +30,6 @@ acpi_get_gpiod_by_index(struct device *dev, int index,
return ERR_PTR(-ENOSYS);
}
-static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
-static inline void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
-
#endif /* CONFIG_GPIO_ACPI */
static inline int acpi_get_gpio_by_index(struct device *dev, int index,
--
1.8.5.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API
2014-01-08 10:40 [PATCH v4 0/4] gpio / ACPI: convert users to gpiod_* and drop acpi_gpio.h Mika Westerberg
2014-01-08 10:40 ` [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically Mika Westerberg
@ 2014-01-08 10:40 ` Mika Westerberg
2014-01-08 11:54 ` Linus Walleij
2014-01-08 10:40 ` [PATCH v4 3/4] gpio / ACPI: get rid of acpi_gpio.h Mika Westerberg
2014-01-08 10:40 ` [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API Mika Westerberg
3 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2014-01-08 10:40 UTC (permalink / raw)
To: linux-acpi
Cc: Rafael J. Wysocki, Linus Walleij, Chris Ball, Johannes Berg,
Rhyland Klein, Adrian Hunter, Heikki Krogerus, Mathias Nyman,
Alexandre Courbot, Rob Landley, Stephen Warren, Thierry Reding,
Mika Westerberg, linux-gpio, linux-kernel
The new descriptor based GPIO interface is now the recommended and safer
way of using GPIOs from device drivers. Convert the ACPI SDHCI driver to
use that interface.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/mmc/host/sdhci-acpi.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index ef19874fcd1f..5c86550f83ad 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -31,10 +31,9 @@
#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/err.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/acpi.h>
-#include <linux/acpi_gpio.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/delay.h>
@@ -199,22 +198,23 @@ static irqreturn_t sdhci_acpi_sd_cd(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static int sdhci_acpi_add_own_cd(struct device *dev, int gpio,
- struct mmc_host *mmc)
+static int sdhci_acpi_add_own_cd(struct device *dev, struct mmc_host *mmc)
{
+ struct gpio_desc *desc;
unsigned long flags;
int err, irq;
- if (gpio < 0) {
- err = gpio;
+ desc = devm_gpiod_get_index(dev, "sd_cd", 0);
+ if (IS_ERR(desc)) {
+ err = PTR_ERR(desc);
goto out;
}
- err = devm_gpio_request_one(dev, gpio, GPIOF_DIR_IN, "sd_cd");
+ err = gpiod_direction_input(desc);
if (err)
- goto out;
+ goto out_free;
- irq = gpio_to_irq(gpio);
+ irq = gpiod_to_irq(desc);
if (irq < 0) {
err = irq;
goto out_free;
@@ -228,7 +228,7 @@ static int sdhci_acpi_add_own_cd(struct device *dev, int gpio,
return 0;
out_free:
- devm_gpio_free(dev, gpio);
+ devm_gpiod_put(dev, desc);
out:
dev_warn(dev, "failed to setup card detect wake up\n");
return err;
@@ -254,7 +254,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
struct resource *iomem;
resource_size_t len;
const char *hid;
- int err, gpio;
+ int err;
if (acpi_bus_get_device(handle, &device))
return -ENODEV;
@@ -279,8 +279,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
if (IS_ERR(host))
return PTR_ERR(host);
- gpio = acpi_get_gpio_by_index(dev, 0, NULL);
-
c = sdhci_priv(host);
c->host = host;
c->slot = sdhci_acpi_get_slot(handle, hid);
@@ -338,7 +336,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
goto err_free;
if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) {
- if (sdhci_acpi_add_own_cd(dev, gpio, host->mmc))
+ if (sdhci_acpi_add_own_cd(dev, host->mmc))
c->use_runtime_pm = false;
}
--
1.8.5.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 3/4] gpio / ACPI: get rid of acpi_gpio.h
2014-01-08 10:40 [PATCH v4 0/4] gpio / ACPI: convert users to gpiod_* and drop acpi_gpio.h Mika Westerberg
2014-01-08 10:40 ` [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically Mika Westerberg
2014-01-08 10:40 ` [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API Mika Westerberg
@ 2014-01-08 10:40 ` Mika Westerberg
2014-01-08 11:56 ` Linus Walleij
2014-01-08 10:40 ` [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API Mika Westerberg
3 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2014-01-08 10:40 UTC (permalink / raw)
To: linux-acpi
Cc: Rafael J. Wysocki, Linus Walleij, Chris Ball, Johannes Berg,
Rhyland Klein, Adrian Hunter, Heikki Krogerus, Mathias Nyman,
Alexandre Courbot, Rob Landley, Stephen Warren, Thierry Reding,
Mika Westerberg, linux-gpio, linux-kernel
Now that all users of acpi_gpio.h have been moved to use either the GPIO
descriptor interface or to the internal gpiolib.h we can get rid of
acpi_gpio.h entirely.
Once this is done the only interface to get GPIOs to drivers enumerated
from ACPI namespace is the descriptor based interface.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpio/gpiolib-acpi.c | 5 +++--
drivers/gpio/gpiolib.c | 1 -
drivers/gpio/gpiolib.h | 23 +++++++++++++++++++++++
include/linux/acpi_gpio.h | 45 ---------------------------------------------
4 files changed, 26 insertions(+), 48 deletions(-)
delete mode 100644 include/linux/acpi_gpio.h
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 739b72b6731a..716ee9843110 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -12,11 +12,13 @@
#include <linux/errno.h>
#include <linux/gpio/consumer.h>
+#include <linux/gpio/driver.h>
#include <linux/export.h>
-#include <linux/acpi_gpio.h>
#include <linux/acpi.h>
#include <linux/interrupt.h>
+#include "gpiolib.h"
+
struct acpi_gpio_evt_pin {
struct list_head node;
acpi_handle *evt_handle;
@@ -307,7 +309,6 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT);
}
-EXPORT_SYMBOL_GPL(acpi_get_gpiod_by_index);
void acpi_gpiochip_add(struct gpio_chip *chip)
{
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 0de4069e33ab..ea0eba572333 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -10,7 +10,6 @@
#include <linux/seq_file.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
-#include <linux/acpi_gpio.h>
#include <linux/idr.h>
#include <linux/slab.h>
#include <linux/acpi.h>
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 2ed23ab8298c..82be586c1f90 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -12,12 +12,35 @@
#ifndef GPIOLIB_H
#define GPIOLIB_H
+#include <linux/err.h>
+#include <linux/device.h>
+
+/**
+ * struct acpi_gpio_info - ACPI GPIO specific information
+ * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
+ * @active_low: in case of @gpioint, the pin is active low
+ */
+struct acpi_gpio_info {
+ bool gpioint;
+ bool active_low;
+};
+
#ifdef CONFIG_ACPI
void acpi_gpiochip_add(struct gpio_chip *chip);
void acpi_gpiochip_remove(struct gpio_chip *chip);
+
+struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
+ struct acpi_gpio_info *info);
#else
static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
+
+static inline struct gpio_desc *
+acpi_get_gpiod_by_index(struct device *dev, int index,
+ struct acpi_gpio_info *info)
+{
+ return ERR_PTR(-ENOSYS);
+}
#endif
#endif /* GPIOLIB_H */
diff --git a/include/linux/acpi_gpio.h b/include/linux/acpi_gpio.h
deleted file mode 100644
index af96a0d452f6..000000000000
--- a/include/linux/acpi_gpio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef _LINUX_ACPI_GPIO_H_
-#define _LINUX_ACPI_GPIO_H_
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/errno.h>
-#include <linux/gpio.h>
-#include <linux/gpio/consumer.h>
-
-/**
- * struct acpi_gpio_info - ACPI GPIO specific information
- * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
- * @active_low: in case of @gpioint, the pin is active low
- */
-struct acpi_gpio_info {
- bool gpioint;
- bool active_low;
-};
-
-#ifdef CONFIG_GPIO_ACPI
-
-struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
- struct acpi_gpio_info *info);
-#else /* CONFIG_GPIO_ACPI */
-
-static inline struct gpio_desc *
-acpi_get_gpiod_by_index(struct device *dev, int index,
- struct acpi_gpio_info *info)
-{
- return ERR_PTR(-ENOSYS);
-}
-
-#endif /* CONFIG_GPIO_ACPI */
-
-static inline int acpi_get_gpio_by_index(struct device *dev, int index,
- struct acpi_gpio_info *info)
-{
- struct gpio_desc *desc = acpi_get_gpiod_by_index(dev, index, info);
-
- if (IS_ERR(desc))
- return PTR_ERR(desc);
- return desc_to_gpio(desc);
-}
-
-#endif /* _LINUX_ACPI_GPIO_H_ */
--
1.8.5.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API
2014-01-08 10:40 [PATCH v4 0/4] gpio / ACPI: convert users to gpiod_* and drop acpi_gpio.h Mika Westerberg
` (2 preceding siblings ...)
2014-01-08 10:40 ` [PATCH v4 3/4] gpio / ACPI: get rid of acpi_gpio.h Mika Westerberg
@ 2014-01-08 10:40 ` Mika Westerberg
2014-01-08 11:57 ` Linus Walleij
3 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2014-01-08 10:40 UTC (permalink / raw)
To: linux-acpi
Cc: Rafael J. Wysocki, Linus Walleij, Chris Ball, Johannes Berg,
Rhyland Klein, Adrian Hunter, Heikki Krogerus, Mathias Nyman,
Alexandre Courbot, Rob Landley, Stephen Warren, Thierry Reding,
Mika Westerberg, linux-gpio, linux-kernel
Update the documentation also to reflect the fact that there are no ACPI
specific GPIO interfaces anymore but drivers should instead use the
descriptor based GPIO APIs.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Documentation/acpi/enumeration.txt | 36 +++++++-----------------------------
1 file changed, 7 insertions(+), 29 deletions(-)
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt
index b994bcb32b92..2a1519b87177 100644
--- a/Documentation/acpi/enumeration.txt
+++ b/Documentation/acpi/enumeration.txt
@@ -293,36 +293,13 @@ the device to the driver. For example:
These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
specifies the path to the controller. In order to use these GPIOs in Linux
-we need to translate them to the Linux GPIO numbers.
+we need to translate them to the corresponding Linux GPIO descriptors.
-In a simple case of just getting the Linux GPIO number from device
-resources one can use acpi_get_gpio_by_index() helper function. It takes
-pointer to the device and index of the GpioIo/GpioInt descriptor in the
-device resources list. For example:
+There is a standard GPIO API for that and is documented in
+Documentation/gpio.txt.
- int gpio_irq, gpio_power;
- int ret;
-
- gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL);
- if (gpio_irq < 0)
- /* handle error */
-
- gpio_power = acpi_get_gpio_by_index(dev, 0, NULL);
- if (gpio_power < 0)
- /* handle error */
-
- /* Now we can use the GPIO numbers */
-
-Other GpioIo parameters must be converted first by the driver to be
-suitable to the gpiolib before passing them.
-
-In case of GpioInt resource an additional call to gpio_to_irq() must be
-done before calling request_irq().
-
-Note that the above API is ACPI specific and not recommended for drivers
-that need to support non-ACPI systems. The recommended way is to use
-the descriptor based GPIO interfaces. The above example looks like this
-when converted to the GPIO desc:
+In the above example we can get the corresponding two GPIO descriptors with
+a code like this:
#include <linux/gpio/consumer.h>
...
@@ -339,4 +316,5 @@ when converted to the GPIO desc:
/* Now we can use the GPIO descriptors */
-See also Documentation/gpio.txt.
+There are also devm_* versions of these functions which release the
+descriptors once the device is released.
--
1.8.5.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API
2014-01-08 10:40 ` [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API Mika Westerberg
@ 2014-01-08 11:54 ` Linus Walleij
2014-01-08 12:34 ` Mika Westerberg
2014-01-13 18:32 ` Chris Ball
0 siblings, 2 replies; 11+ messages in thread
From: Linus Walleij @ 2014-01-08 11:54 UTC (permalink / raw)
To: Mika Westerberg
Cc: ACPI Devel Maling List, Rafael J. Wysocki, Chris Ball,
Johannes Berg, Rhyland Klein, Adrian Hunter, Heikki Krogerus,
Mathias Nyman, Alexandre Courbot, Rob Landley, Stephen Warren,
Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> The new descriptor based GPIO interface is now the recommended and safer
> way of using GPIOs from device drivers. Convert the ACPI SDHCI driver to
> use that interface.
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
I've tentatively applied this to the GPIO tree now, as it was acked by
Adrian who is a long time MMC subsystem contributor and we need
it to proceed with the rest of the refactorings.
Chris, beat me up if you're unhappy with this.
(If it explodes in linux-next I'll just back it all out.)
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically
2014-01-08 10:40 ` [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically Mika Westerberg
@ 2014-01-08 11:55 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2014-01-08 11:55 UTC (permalink / raw)
To: Mika Westerberg
Cc: ACPI Devel Maling List, Rafael J. Wysocki, Chris Ball,
Johannes Berg, Rhyland Klein, Adrian Hunter, Heikki Krogerus,
Mathias Nyman, Alexandre Courbot, Rob Landley, Stephen Warren,
Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> Instead of asking each driver to register to ACPI events we can just call
> acpi_gpiochip_register_interrupts() for each chip that has an ACPI handle.
> The function checks chip->to_irq and if it is set to NULL (a GPIO driver
> that doesn't do interrupts) the function does nothing.
>
> We also add the a new header drivers/gpio/gpiolib.h that is used for
> functions internal to gpiolib and add ACPI GPIO chip registering functions
> to that header.
>
> Once that is done we can remove call to acpi_gpiochip_register_interrupts()
> from its only user, pinctrl-baytrail.c
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 3/4] gpio / ACPI: get rid of acpi_gpio.h
2014-01-08 10:40 ` [PATCH v4 3/4] gpio / ACPI: get rid of acpi_gpio.h Mika Westerberg
@ 2014-01-08 11:56 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2014-01-08 11:56 UTC (permalink / raw)
To: Mika Westerberg
Cc: ACPI Devel Maling List, Rafael J. Wysocki, Chris Ball,
Johannes Berg, Rhyland Klein, Adrian Hunter, Heikki Krogerus,
Mathias Nyman, Alexandre Courbot, Rob Landley, Stephen Warren,
Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> Now that all users of acpi_gpio.h have been moved to use either the GPIO
> descriptor interface or to the internal gpiolib.h we can get rid of
> acpi_gpio.h entirely.
>
> Once this is done the only interface to get GPIOs to drivers enumerated
> from ACPI namespace is the descriptor based interface.
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API
2014-01-08 10:40 ` [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API Mika Westerberg
@ 2014-01-08 11:57 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2014-01-08 11:57 UTC (permalink / raw)
To: Mika Westerberg
Cc: ACPI Devel Maling List, Rafael J. Wysocki, Chris Ball,
Johannes Berg, Rhyland Klein, Adrian Hunter, Heikki Krogerus,
Mathias Nyman, Alexandre Courbot, Rob Landley, Stephen Warren,
Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> Update the documentation also to reflect the fact that there are no ACPI
> specific GPIO interfaces anymore but drivers should instead use the
> descriptor based GPIO APIs.
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API
2014-01-08 11:54 ` Linus Walleij
@ 2014-01-08 12:34 ` Mika Westerberg
2014-01-13 18:32 ` Chris Ball
1 sibling, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2014-01-08 12:34 UTC (permalink / raw)
To: Linus Walleij
Cc: ACPI Devel Maling List, Rafael J. Wysocki, Chris Ball,
Johannes Berg, Rhyland Klein, Adrian Hunter, Heikki Krogerus,
Mathias Nyman, Alexandre Courbot, Rob Landley, Stephen Warren,
Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Jan 08, 2014 at 12:54:13PM +0100, Linus Walleij wrote:
> On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>
> > The new descriptor based GPIO interface is now the recommended and safer
> > way of using GPIOs from device drivers. Convert the ACPI SDHCI driver to
> > use that interface.
> >
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> > Acked-by: Alexandre Courbot <acourbot@nvidia.com>
>
> I've tentatively applied this to the GPIO tree now, as it was acked by
> Adrian who is a long time MMC subsystem contributor and we need
> it to proceed with the rest of the refactorings.
Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API
2014-01-08 11:54 ` Linus Walleij
2014-01-08 12:34 ` Mika Westerberg
@ 2014-01-13 18:32 ` Chris Ball
1 sibling, 0 replies; 11+ messages in thread
From: Chris Ball @ 2014-01-13 18:32 UTC (permalink / raw)
To: Linus Walleij
Cc: Mika Westerberg, ACPI Devel Maling List, Rafael J. Wysocki,
Johannes Berg, Rhyland Klein, Adrian Hunter, Heikki Krogerus,
Mathias Nyman, Alexandre Courbot, Rob Landley, Stephen Warren,
Thierry Reding, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Hi Linus,
On Wed, Jan 08 2014, Linus Walleij wrote:
> On Wed, Jan 8, 2014 at 11:40 AM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>
>> The new descriptor based GPIO interface is now the recommended and safer
>> way of using GPIOs from device drivers. Convert the ACPI SDHCI driver to
>> use that interface.
>>
>> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
>
> I've tentatively applied this to the GPIO tree now, as it was acked by
> Adrian who is a long time MMC subsystem contributor and we need
> it to proceed with the rest of the refactorings.
>
> Chris, beat me up if you're unhappy with this.
>
> (If it explodes in linux-next I'll just back it all out.)
That's fine. Feel free to add:
Acked-by: Chris Ball <chris@printf.net>
Thanks,
- Chris.
--
Chris Ball <chris@printf.net> <http://printf.net/>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-01-13 18:32 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08 10:40 [PATCH v4 0/4] gpio / ACPI: convert users to gpiod_* and drop acpi_gpio.h Mika Westerberg
2014-01-08 10:40 ` [PATCH v4 1/4] gpio / ACPI: register to ACPI events automatically Mika Westerberg
2014-01-08 11:55 ` Linus Walleij
2014-01-08 10:40 ` [PATCH v4 2/4] mmc: sdhci-acpi: convert to use GPIO descriptor API Mika Westerberg
2014-01-08 11:54 ` Linus Walleij
2014-01-08 12:34 ` Mika Westerberg
2014-01-13 18:32 ` Chris Ball
2014-01-08 10:40 ` [PATCH v4 3/4] gpio / ACPI: get rid of acpi_gpio.h Mika Westerberg
2014-01-08 11:56 ` Linus Walleij
2014-01-08 10:40 ` [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API Mika Westerberg
2014-01-08 11:57 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).