From patchwork Wed Jan 22 12:39:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 3522901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6F5AC02DC for ; Wed, 22 Jan 2014 12:43:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B813820155 for ; Wed, 22 Jan 2014 12:43:15 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B992920115 for ; Wed, 22 Jan 2014 12:43:14 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5x8s-00036S-3Q; Wed, 22 Jan 2014 12:42:50 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5x8l-0004cR-IY; Wed, 22 Jan 2014 12:42:43 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5x8Z-0004a8-LD for linux-arm-kernel@lists.infradead.org; Wed, 22 Jan 2014 12:42:32 +0000 Received: by mail-we0-f177.google.com with SMTP id x55so264112wes.8 for ; Wed, 22 Jan 2014 04:42:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WD0CzyGkse9a2nWZLc1V3JRYttbuijbtisz896uj+EI=; b=XE/6/kVq6szXpv3KUtIi8zJ8ak1Rw92iuQZpWjnB6Gov85i+tUZFwWDQ6ZAfH3VVJu lrZe9pZHTpYd0iTyQf6edE+iy3yfcP1Uu5Ko6S8D1ihz9UX+Q38MqmnrfEHQLsP10n2o bJ6cgH5giG+mo+1AoY06cbEH3FMhzh3YcaSxTYwiHt3PzmL1guFey22dKx1rSjFyn5/0 pU5rx7/gC3R7lAPWiwFIIvdUo+IMDQGq013Y1IQpNk9tiupT8NyorEwAWTctLFR020YS MfRzTY+JZ7HyhZiq/IrlnuJxGRuo2scvRKtKgvQUfp7/x6FkJcin39iJ/oURtrUJuB71 aqwA== X-Received: by 10.180.85.198 with SMTP id j6mr3062528wiz.40.1390394527314; Wed, 22 Jan 2014 04:42:07 -0800 (PST) Received: from stedf17-labo202.ds.jdsu.net. (4-161.80-90.static-ip.oleane.fr. [90.80.161.4]) by mx.google.com with ESMTPSA id f9sm18745851wib.3.2014.01.22.04.42.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jan 2014 04:42:06 -0800 (PST) From: Jean-Jacques Hiblot To: linus.walleij@linaro.org, nicolas.ferre@atmel.com, b.brezillon@overkiz.com, plagnioj@jcrosoft.com Subject: [PATCH 2/2] at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ Date: Wed, 22 Jan 2014 13:39:01 +0100 Message-Id: <1390394341-12548-2-git-send-email-jjhiblot@traphandler.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1390394341-12548-1-git-send-email-jjhiblot@traphandler.com> References: <1390394341-12548-1-git-send-email-jjhiblot@traphandler.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140122_074231_847173_D6414B8C X-CRM114-Status: GOOD ( 12.69 ) X-Spam-Score: -2.6 (--) Cc: Jean-Jacques Hiblot , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When an IRQ is started on a GPIO line, mark this GPIO as IRQ in the gpiolib so we can keep track of the usage centrally. Signed-off-by: Jean-Jacques Hiblot --- drivers/pinctrl/pinctrl-at91.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index e8c8301..fbedde2 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1299,6 +1299,28 @@ static int alt_gpio_irq_type(struct irq_data *d, unsigned type) return 0; } +static unsigned int gpio_irq_startup(struct irq_data *d) +{ + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); + unsigned pin = d->hwirq; + int ret; + + ret = gpio_lock_as_irq(&at91_gpio->chip, pin); + if (ret) { + dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n", + d->hwirq); + return ret; + } + return 0; +} +static void gpio_irq_shutdown(struct irq_data *d) +{ + struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); + unsigned pin = d->hwirq; + + gpio_unlock_as_irq(&at91_gpio->chip, pin); +} + #ifdef CONFIG_PM static u32 wakeups[MAX_GPIO_BANKS]; @@ -1377,6 +1399,8 @@ void at91_pinctrl_gpio_resume(void) static struct irq_chip gpio_irqchip = { .name = "GPIO", + .irq_startup = gpio_irq_startup, + .irq_shutdown = gpio_irq_shutdown, .irq_disable = gpio_irq_mask, .irq_mask = gpio_irq_mask, .irq_unmask = gpio_irq_unmask,