From patchwork Thu Jan 23 10:37:58 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: 3527861 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 02A869F2D6 for ; Thu, 23 Jan 2014 10:43:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EA2A201BA for ; Thu, 23 Jan 2014 10:43:43 +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 43B0B201B6 for ; Thu, 23 Jan 2014 10:43:42 +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 1W6Hjj-0002tS-QU; Thu, 23 Jan 2014 10:42:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6HjH-00040I-KJ; Thu, 23 Jan 2014 10:41:47 +0000 Received: from mail-we0-f181.google.com ([74.125.82.181]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6Hiy-0003x5-AV for linux-arm-kernel@lists.infradead.org; Thu, 23 Jan 2014 10:41:29 +0000 Received: by mail-we0-f181.google.com with SMTP id u56so936524wes.40 for ; Thu, 23 Jan 2014 02:41: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=vqRtdZwlY4fqR9Y98SJtSSD/Y+96S2keZ4nv7dB4Mls=; b=OwNAed/MrSvn4tgSLNbhhrCv7N/SCYL99MKCShNy76AaOCVVa/hejLqUZR0WS+44Dv DY9FOTwdrMMyFn/yVYNTRvP/O1x/kVPD5WQ9XAKOgEn9nRUY1bquTN2uemXV1rkXn2Db exSTcB14gGwYkaWpi8yUHI8xHMysS3BXqIB5gFosZuet95h8N11Nk/7Aik8LOrHKqGDG 3TcvR6L6Q7TAJqrKhbDAvuJQJJh/QknB7ikfVWAgTG6iMgoYhv2wn+Pp6dn9kUVzptV1 3n0ak8w2RnQjzoSMjSvg+I9Si8+zISQVDCrpBa4M79CuLGU5WXwrYfMxwD/2VqYAP7NN XcCQ== X-Received: by 10.180.81.38 with SMTP id w6mr7111835wix.27.1390473663775; Thu, 23 Jan 2014 02:41:03 -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 y13sm21295930wjr.8.2014.01.23.02.41.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jan 2014 02:41:03 -0800 (PST) From: Jean-Jacques Hiblot To: linus.walleij@linaro.org, nicolas.ferre@atmel.com, b.brezillon@overkiz.com, plagnioj@jcrosoft.com, gregory.clement@free-electrons.com Subject: [PATCH v2 2/2] at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ Date: Thu, 23 Jan 2014 11:37:58 +0100 Message-Id: <1390473478-5591-3-git-send-email-jjhiblot@traphandler.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1390473478-5591-1-git-send-email-jjhiblot@traphandler.com> References: <1390473478-5591-1-git-send-email-jjhiblot@traphandler.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140123_054128_504618_ECD4C836 X-CRM114-Status: GOOD ( 12.53 ) 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index e8c8301..e00a4bb 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1299,6 +1299,31 @@ 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; + } + gpio_irq_unmask(d); + 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_irq_mask(d); + gpio_unlock_as_irq(&at91_gpio->chip, pin); +} + #ifdef CONFIG_PM static u32 wakeups[MAX_GPIO_BANKS]; @@ -1377,6 +1402,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,