From: t.figa@samsung.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 14/15] pinctrl: samsung: Add GPIO to IRQ translation
Date: Thu, 11 Oct 2012 10:11:20 +0200 [thread overview]
Message-ID: <1349943081-27939-15-git-send-email-t.figa@samsung.com> (raw)
In-Reply-To: <1349943081-27939-1-git-send-email-t.figa@samsung.com>
Some drivers require a way to translate GPIO pins to their IRQ numbers.
This patch adds the .to_irq() gpiolib callback to pinctrl-samsung
driver, which creates (if not present yet) and returns an IRQ mapping
for given GPIO pin.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
---
drivers/pinctrl/pinctrl-samsung.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c
index 0a38368..0db88bb 100644
--- a/drivers/pinctrl/pinctrl-samsung.c
+++ b/drivers/pinctrl/pinctrl-samsung.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/gpio.h>
+#include <linux/irqdomain.h>
#include "core.h"
#include "pinctrl-samsung.h"
@@ -528,6 +529,23 @@ static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
}
/*
+ * gpiolib gpio_to_irq callback function. Creates a mapping between a GPIO pin
+ * and a virtual IRQ, if not already present.
+ */
+static int samsung_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
+{
+ struct samsung_pin_bank *bank = gc_to_pin_bank(gc);
+ unsigned int virq;
+
+ if (!bank->irq_domain)
+ return -ENXIO;
+
+ virq = irq_create_mapping(bank->irq_domain, offset);
+
+ return (virq) ? : -ENXIO;
+}
+
+/*
* Parse the pin names listed in the 'samsung,pins' property and convert it
* into a list of gpio numbers are create a pin group from it.
*/
@@ -755,6 +773,7 @@ static const struct gpio_chip samsung_gpiolib_chip = {
.get = samsung_gpio_get,
.direction_input = samsung_gpio_direction_input,
.direction_output = samsung_gpio_direction_output,
+ .to_irq = samsung_gpio_to_irq,
.owner = THIS_MODULE,
};
--
1.7.12
next prev parent reply other threads:[~2012-10-11 8:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 8:11 [PATCH v2 00/15] pinctrl: samsung: Usability and extensibiltiy improvements Tomasz Figa
2012-10-11 8:11 ` [PATCH 01/15] pinctrl: samsung: Detect and handle unsupported configuration types Tomasz Figa
2012-10-11 13:57 ` Linus Walleij
2012-10-11 14:00 ` Kyungmin Park
2012-10-11 14:06 ` Linus Walleij
2012-10-11 8:11 ` [PATCH 02/15] pinctrl: samsung: Do not pass gpio_chip to pin_to_reg_bank Tomasz Figa
2012-10-11 8:11 ` [PATCH 03/15] pinctrl: samsung: Assing pin numbers dynamically Tomasz Figa
2012-10-11 8:11 ` [PATCH 04/15] pinctrl: samsung: Remove static pin enumerations Tomasz Figa
2012-10-11 8:11 ` [PATCH 05/15] pinctrl: samsung: Distinguish between pin group and bank nodes Tomasz Figa
2012-10-11 8:11 ` [PATCH 06/15] ARM: dts: exynos4210-pinctrl: Add nodes for pin banks Tomasz Figa
2012-10-11 8:11 ` [PATCH 07/15] pinctrl: samsung: Match pin banks with their device nodes Tomasz Figa
2012-10-11 8:11 ` [PATCH 08/15] pinctrl: samsung: Hold pointer to driver data in bank struct Tomasz Figa
2012-10-11 8:11 ` [PATCH 09/15] pinctrl: samsung: Include bank-specific eint offset " Tomasz Figa
2012-10-11 8:11 ` [PATCH 10/15] pinctrl: exynos: Use one IRQ domain per pin bank Tomasz Figa
2012-10-11 8:11 ` [PATCH 11/15] pinctrl: samsung: Use one GPIO chip " Tomasz Figa
2012-10-11 8:11 ` [PATCH 12/15] pinctrl: samsung: Use per-bank IRQ domain for wake-up interrupts Tomasz Figa
2012-10-11 8:11 ` [PATCH 13/15] pinctrl: exynos: Set pin function to EINT in irq_set_type of wake-up EINT Tomasz Figa
2012-10-11 8:11 ` Tomasz Figa [this message]
2012-10-11 8:11 ` [PATCH 15/15] Documentation: Update samsung-pinctrl device tree bindings documentation Tomasz Figa
2012-10-11 9:01 ` [PATCH v2 00/15] pinctrl: samsung: Usability and extensibiltiy improvements Kyungmin Park
2012-10-11 12:50 ` Thomas Abraham
2012-10-11 14:05 ` Linus Walleij
2012-10-11 14:20 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349943081-27939-15-git-send-email-t.figa@samsung.com \
--to=t.figa@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox