From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 02/16] drivers/gpio: gpio-nomadik: Add support for irqdomains
Date: Tue, 17 Apr 2012 11:43:54 +0100 [thread overview]
Message-ID: <1334659448-11521-3-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1334659448-11521-1-git-send-email-lee.jones@linaro.org>
Add irq domain support to the gpio-nomadik GPIO driver. This
enables its users to support dynamic IRQ assignment, which is
requried by Device Tree.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/mach-ux500/cpu.c | 1 +
drivers/gpio/gpio-nomadik.c | 40 +++++++++++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index d11f389..af12139 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -30,6 +30,7 @@
void __iomem *_PRCMU_BASE;
+/* FIXME: should we set up the GPIO domain here? */
static const struct of_device_id ux500_dt_irq_match[] = {
{ .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
{},
diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
index 2c2b53c..1322ca8 100644
--- a/drivers/gpio/gpio-nomadik.c
+++ b/drivers/gpio/gpio-nomadik.c
@@ -22,6 +22,7 @@
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
+#include <linux/irqdomain.h>
#include <linux/slab.h>
#include <asm/mach/irq.h>
@@ -677,7 +678,6 @@ static int nmk_gpio_irq_set_type(struct irq_data *d, unsigned int type)
bitmask = nmk_gpio_get_bitmask(gpio);
if (!nmk_chip)
return -EINVAL;
-
if (type & IRQ_TYPE_LEVEL_HIGH)
return -EINVAL;
if (type & IRQ_TYPE_LEVEL_LOW)
@@ -782,6 +782,33 @@ static void nmk_gpio_secondary_irq_handler(unsigned int irq,
__nmk_gpio_irq_handler(irq, desc, status);
}
+#ifdef CONFIG_IRQ_DOMAIN
+int nmk_gpio_irq_map(struct irq_domain *d, unsigned int irq,
+ irq_hw_number_t hwirq)
+{
+ return 0;
+}
+
+const struct irq_domain_ops nmk_gpio_irq_simple_ops = {
+ .map = nmk_gpio_irq_map,
+ .xlate = irq_domain_xlate_twocell,
+};
+
+struct irq_domain *nmk_gpio_irq_domain_add(struct device_node *np,
+ struct nmk_gpio_platform_data *pdata)
+{
+ return irq_domain_add_legacy(np, NMK_GPIO_PER_CHIP,
+ NOMADIK_GPIO_TO_IRQ(pdata->first_gpio),
+ 0, &nmk_gpio_irq_simple_ops, NULL);
+}
+#else
+struct irq_domain *nmk_gpio_irq_domain_add(struct device_node *np,
+ struct nmk_gpio_platform_data *pdata)
+{
+ return NULL;
+}
+#endif
+
static int nmk_gpio_init_irq(struct nmk_gpio_chip *nmk_chip)
{
unsigned int first_irq;
@@ -1072,6 +1099,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
{
struct nmk_gpio_platform_data *pdata = dev->dev.platform_data;
struct device_node *np = dev->dev.of_node;
+ struct irq_domain *domain = NULL;
struct nmk_gpio_chip *nmk_chip;
struct gpio_chip *chip;
struct resource *res;
@@ -1096,13 +1124,20 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
if (of_property_read_u32(np, "gpio-bank", &dev->id)) {
dev_err(&dev->dev, "gpio-bank property not found\n");
ret = -EINVAL;
- goto out_dt;
+ goto out;
}
pdata->first_gpio = dev->id * NMK_GPIO_PER_CHIP;
pdata->num_gpio = NMK_GPIO_PER_CHIP;
}
+ domain = nmk_gpio_irq_domain_add(np, pdata);
+ if (!domain) {
+ pr_err("%s: Failed to create irqdomain - required for DT\n",
+ np->full_name);
+ return -ENOSYS;
+ }
+
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!res) {
ret = -ENOENT;
@@ -1189,7 +1224,6 @@ out_release:
out:
dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret,
pdata->first_gpio, pdata->first_gpio+31);
-out_dt:
if (np)
kfree(pdata);
--
1.7.9.1
next prev parent reply other threads:[~2012-04-17 10:43 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-17 10:43 [PATCH 0/16] Another round of Device Tree enablement for Snowball Lee Jones
2012-04-17 10:43 ` [PATCH 01/16] ARM: ux500: Enable the external bus with Device Tree Lee Jones
2012-04-18 15:54 ` Linus Walleij
2012-04-17 10:43 ` Lee Jones [this message]
2012-04-18 16:09 ` [PATCH 02/16] drivers/gpio: gpio-nomadik: Add support for irqdomains Linus Walleij
2012-04-18 16:22 ` Arnd Bergmann
2012-04-18 16:26 ` Linus Walleij
2012-04-19 16:23 ` Arnd Bergmann
2012-04-20 3:01 ` Rob Herring
2012-05-17 21:49 ` Grant Likely
2012-04-20 6:47 ` Linus Walleij
2012-04-17 10:43 ` [PATCH 03/16] ARM: ux500: Use correct format for dynamic IRQ assignment Lee Jones
2012-04-18 16:11 ` Linus Walleij
2012-04-17 10:43 ` [PATCH 04/16] drivers/net: Do not free an IRQ if its request failed Lee Jones
2012-04-18 16:12 ` Linus Walleij
2012-04-17 10:43 ` [PATCH 05/16] ARM: ux500: New DT:ed snowball_platform_devs for one-by-one device enablement Lee Jones
2012-04-17 10:43 ` [PATCH 06/16] ARM: ux500: New DT:ed u8500_init_devices " Lee Jones
2012-04-17 10:43 ` [PATCH 07/16] ARM: ux500: Enable the SMSC9115 on Snowball via Device Tree Lee Jones
2012-04-18 16:16 ` Linus Walleij
2012-04-17 10:44 ` [PATCH 08/16] drivers/mmc: MMCI: Use correct GPIO binding for IRQ requests Lee Jones
2012-04-18 16:18 ` Linus Walleij
2012-04-17 10:44 ` [PATCH 09/16] ARM: ux500: Correctly describe SMSC9115 for Snowball in DT Lee Jones
2012-04-17 10:44 ` [PATCH 10/16] drivers/gpio: represent gpio-nomadik as an IRQ controller in DT documentation Lee Jones
2012-04-17 14:38 ` Arnd Bergmann
2012-04-17 15:32 ` Lee Jones
2012-04-17 15:45 ` [PATCH 10/16 v2] " Lee Jones
2012-04-17 15:58 ` Lee Jones
2012-04-17 10:44 ` [PATCH 11/16] ARM: ux500: Do not attempt to register non-existent i2c devices on Snowball Lee Jones
2012-04-17 14:42 ` Arnd Bergmann
2012-04-17 15:28 ` Lee Jones
2012-04-17 15:44 ` [PATCH 11/16 v2] " Lee Jones
2012-04-17 16:02 ` Arnd Bergmann
2012-04-17 10:44 ` [PATCH 12/16] mfd/db8500-prcmu: Register as a platform driver instead of only probing Lee Jones
2012-04-18 16:19 ` Linus Walleij
2012-04-17 10:44 ` [PATCH 13/16] mfd/db8500-prcmu: Add Device Tree support Lee Jones
2012-04-18 16:35 ` Linus Walleij
2012-04-17 10:44 ` [PATCH 14/16] ARM: ux500: Fork cpu-db8500 platform_devs for sequential DT enablement Lee Jones
2012-04-17 10:44 ` [PATCH 15/16] ARM: ux500: Apply Device Tree settings for the DB8500 PRCMU Lee Jones
2012-04-17 14:47 ` Arnd Bergmann
2012-04-17 15:30 ` Lee Jones
2012-04-17 15:38 ` Arnd Bergmann
2012-04-17 15:46 ` Lee Jones
2012-04-17 15:56 ` [PATCH 13&15/16 v2] " Lee Jones
2012-04-18 16:21 ` Linus Walleij
2012-04-17 10:44 ` [PATCH 16/16] ARM: ux500: Enable PRCMU Timer 4 (clocksource) via Device Tree Lee Jones
2012-04-17 14:49 ` [PATCH 0/16] Another round of Device Tree enablement for Snowball Arnd Bergmann
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=1334659448-11521-3-git-send-email-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--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;
as well as URLs for NNTP newsgroup(s).