From patchwork Thu Jan 23 10:37:57 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: 3527841 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 BDB779F2D6 for ; Thu, 23 Jan 2014 10:43:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AFFC201B6 for ; Thu, 23 Jan 2014 10:43:23 +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 DD2582018B for ; Thu, 23 Jan 2014 10:43:21 +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 1W6Hjb-0002lo-02; Thu, 23 Jan 2014 10:42:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6Hj8-0003za-MF; Thu, 23 Jan 2014 10:41:38 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6Hit-0003w4-A5 for linux-arm-kernel@lists.infradead.org; Thu, 23 Jan 2014 10:41:23 +0000 Received: by mail-wg0-f45.google.com with SMTP id n12so1261627wgh.0 for ; Thu, 23 Jan 2014 02:41:01 -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=OkdtuEPwg1Movj0lDOb2G4h3jaBKWhdujN9DaKHN96o=; b=Z9j3zsHaX2az3AfdWeiTt8Xy155FLrfhY4VpGLy8pGqPxoFp56etwsl5wAaPk7czoJ W4OHUaD3aqlek5QhhAJIQAU4CAs7991pLzCYjZ7JAGtgCrHipw9w5jt1Dk2NY2iVoiPw Yy24ZTH0EvXr3PnsF9Okc2yI8TAGzv3OMMdWHxcsfAWntbbNCmwNukEgLzsxGqj//Loc hjqvJvj5SI4f57gO/wNDqT0I9PIS0NwDOiT2E7zwJqPtO/I66rCPk+EctVOL3Z4dm4Fr 7VTtNhr089YoTJoYev+jgmU1WFRLgGiiHjCXTmsMw7HFvIqD8hV9RRsILS6kqERe0rFM va+g== X-Received: by 10.194.176.163 with SMTP id cj3mr6148336wjc.8.1390473661884; Thu, 23 Jan 2014 02:41:01 -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.40.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jan 2014 02:41:00 -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 1/2] at91: gpio: use gpiolib API to mark a GPIO used as an IRQ Date: Thu, 23 Jan 2014 11:37:57 +0100 Message-Id: <1390473478-5591-2-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_054123_463084_51625E85 X-CRM114-Status: GOOD ( 12.32 ) 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 Acked-by: Linus Walleij --- arch/arm/mach-at91/gpio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c index a5afcf7..a88ed12 100644 --- a/arch/arm/mach-at91/gpio.c +++ b/arch/arm/mach-at91/gpio.c @@ -577,8 +577,35 @@ 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); +} + static struct irq_chip gpio_irqchip = { .name = "GPIO", + .irq_shutdown = gpio_irq_shutdown, + .irq_startup = gpio_irq_startup, .irq_disable = gpio_irq_mask, .irq_mask = gpio_irq_mask, .irq_unmask = gpio_irq_unmask,