From patchwork Tue Apr 17 10:43:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 7889 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7590A23E00 for ; Tue, 17 Apr 2012 10:44:32 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3EE6AA181C2 for ; Tue, 17 Apr 2012 10:44:32 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so12004590iag.11 for ; Tue, 17 Apr 2012 03:44:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=fAkLgy7EeVS3vFuKpzVcuKqXWoBZL76VIqGcOwDnIr4=; b=kgY1bXzrQfqh0zcbawDu3vdGnpRqnQrQgAy2YiqSQua2GlVrM95GsjKe0PFjQI1ylV oveIqeHeY4C8P5BNJLD87Cqk7XAWayKXak7vRTNEIcpoOm5fifS+JH1ksEBhWzezDZqf K/CquecVt9x8OKp58hdNYiEEvGcWmur1D+ubGQLi2CovJ5A3XbN3rGsNpPveVQMTJu8Z diVoNBhcmq/pOIdq3b66EE1n90giWR8SqC6whpBakjJ80Y69hR7FS4NqXjpZG7ZbzULv Joy9SYmNOkoE3Ei/O/OeS0/1rosQ0SE3H47Nd8Td01gF1F4QDVnO+KUBikLLwS7OKHme ctMA== Received: by 10.50.154.167 with SMTP id vp7mr8765086igb.55.1334659472037; Tue, 17 Apr 2012 03:44:32 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp138668ibt; Tue, 17 Apr 2012 03:44:31 -0700 (PDT) Received: by 10.216.197.154 with SMTP id t26mr937155wen.56.1334659470763; Tue, 17 Apr 2012 03:44:30 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id bl2si11620333wib.27.2012.04.17.03.44.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Apr 2012 03:44:30 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f50.google.com with SMTP id ds12so6054977wgb.31 for ; Tue, 17 Apr 2012 03:44:30 -0700 (PDT) Received: by 10.180.85.69 with SMTP id f5mr27278908wiz.18.1334659470293; Tue, 17 Apr 2012 03:44:30 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id fn2sm42069492wib.0.2012.04.17.03.44.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Apr 2012 03:44:29 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, grant.likely@secretlab.ca, cjb@laptop.org, linux@arm.linux.org.uk, Lee Jones Subject: [PATCH 02/16] drivers/gpio: gpio-nomadik: Add support for irqdomains Date: Tue, 17 Apr 2012 11:43:54 +0100 Message-Id: <1334659448-11521-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1334659448-11521-1-git-send-email-lee.jones@linaro.org> References: <1334659448-11521-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkILghq3OmaXaywC455k91b9momCTAfxPH1NOdCDwP11OSCTLGPaDgXJIu4Ps2XLPeMmdpG 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 --- 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 #include #include +#include #include #include @@ -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);