From patchwork Mon Aug 7 11:01:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9885031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFA4660363 for ; Mon, 7 Aug 2017 11:03:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3B16285E3 for ; Mon, 7 Aug 2017 11:03:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98B862860D; Mon, 7 Aug 2017 11:03:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D88D285E3 for ; Mon, 7 Aug 2017 11:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=877B/hvcyt0qqSURIl+aPsXNVUfF3o3TRb4gJzybY9c=; b=Md8m/FXNga3gTyjhDyjbttPdwF gkFjT8VhOwexodkuemzdlSUi0C92cWjjWc6bGbIx3xIdsKclz5LFNCAafGc430C3RRUEo77/2A/nL TE5Oqmg2Lcq+DDRxdeiO4g2vntPG4DWdrqsxO7+hkzNyYlcKwGMKS2J52HZFPrScMOzr2wEv85oJm 647CGGhTkHTzuOs7YA+6+x7i0CGrASpFg2Dlc6Z7j3DaRLwVaMbsrLn/iHDiIwkdliMJ63spZoVX/ 7mgZAn4Ozr1Azzgn3jn313tdaVauwv4XVxWavRVkVkLEz2OsvNwsz22ZenLy20ZAJHqD5MRaaMfp7 4T/c5Z3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1defof-0002Aw-MS; Mon, 07 Aug 2017 11:03:21 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1defnn-00011T-VK for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2017 11:02:30 +0000 Received: by mail-wm0-x244.google.com with SMTP id y206so589508wmd.5 for ; Mon, 07 Aug 2017 04:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ocdqCG+eL/JERO077yYKq1DAlsxoQv3z3orbcNI/9fA=; b=pQZ+mXsyR0/gufVsW4SfDb8Jvgrrgh5iaJTQ9fpdtuP0oc7TkEgZOf2wefDkFF6MLE 3q73OCfdgNSsSeOTpi9H0hBHoZwu0OCAECRxmyGG+Cm1SPqsgCAUyZorXMTsrHFe3dxx mqrB6c4kb1GPA+9OzBrf732RwnNdsg2k2mIWKs7csZtA+7d7HKj4odrWDQP7U2RWrNEk QaTlX7pxa4Bpizz/95ioKTx5SYY/K5Ztpz0IC8VDAZQ2f0PkaHFrAYUlSuxeBof9wTis 5qwl/W+96PUiS9BJzzdfGvOzL1nACsyE9NkAqnHrOPcsrAi4gh0xcN0CKw/y8d/1ujGY O65A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=ocdqCG+eL/JERO077yYKq1DAlsxoQv3z3orbcNI/9fA=; b=NQ+17Rauqar9I/o1lxGN4tNM5e099uoqebxWYUD98mjigmgI/gs6QxSE7A08XxL01g 4mg++0D/PKKGN3hmVHzI8y/udX1DB1vtiW39Jl98XBW4CCsHEz1g8TKUTsL+ciBYupVL hnyNEmimFfmQ44vHbnRnuIMLTvxCky3EXFmBP9yoB5Fu0KPCvuisynhy46q+2virCn6b fdmB1wVNCADeJ+IvWgfZ9zO/ywoRFwM+Lv20y6r8mqPHbGvVjYyhxOpOZCA98CfIP13d qJus/12uBIkXKj9KMq4/pt4rV6pJDb32nk5j2Kcs86OzvCeR/J2EyO3sO611MG5Vbt7E UmOw== X-Gm-Message-State: AHYfb5hHTdw9O0RglHTCdakCko8HR1fYeNzyBe3797iE5xxj7kWrzlSM 2x4wLY+EvVcxiDAj X-Received: by 10.28.58.138 with SMTP id h132mr385562wma.64.1502103726211; Mon, 07 Aug 2017 04:02:06 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 13sm13925951wrw.72.2017.08.07.04.02.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 07 Aug 2017 04:02:05 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH 2/8] gpio: zynq: Wakeup gpio controller when it is used as IRQ controller Date: Mon, 7 Aug 2017 13:01:55 +0200 Message-Id: <72d3cd83bed792a23ab60cf9b6d51b618f5aa084.1502103715.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170807_040228_356273_5DCEFC16 X-CRM114-Status: GOOD ( 15.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Josh Cartwright , Peter Crosthwaite , Linus Walleij , Borsodi Petr , linux-gpio@vger.kernel.org, Rob Herring , linux-arm-kernel@lists.infradead.org, Steffen Trumtrar , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Borsodi Petr There is a problem with GPIO driver when used as IRQ controller. It is not working because the module is sleeping (clock is disabled). The patch enables clocks when IP is used as IRQ controller. Signed-off-by: Borsodi Petr Signed-off-by: Michal Simek --- drivers/gpio/gpio-zynq.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index 064033803449..5198fa6e016a 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,8 @@ #include #include +#include "gpiolib.h" + #define DRIVER_NAME "zynq-gpio" /* Maximum banks */ @@ -498,6 +501,38 @@ static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) return 0; } +static int zynq_gpio_irq_request_resources(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + int ret; + + if (!try_module_get(chip->gpiodev->owner)) + return -ENODEV; + + ret = pm_runtime_get_sync(chip->parent); + if (ret < 0) { + module_put(chip->gpiodev->owner); + return ret; + } + + if (gpiochip_lock_as_irq(chip, d->hwirq)) { + chip_err(chip, "unable to lock HW IRQ %lu for IRQ\n", d->hwirq); + pm_runtime_put(chip->parent); + module_put(chip->gpiodev->owner); + return -EINVAL; + } + return 0; +} + +static void zynq_gpio_irq_release_resources(struct irq_data *d) +{ + struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + + gpiochip_unlock_as_irq(chip, d->hwirq); + pm_runtime_put(chip->parent); + module_put(chip->gpiodev->owner); +} + /* irq chip descriptor */ static struct irq_chip zynq_gpio_level_irqchip = { .name = DRIVER_NAME, @@ -507,6 +542,8 @@ static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) .irq_unmask = zynq_gpio_irq_unmask, .irq_set_type = zynq_gpio_set_irq_type, .irq_set_wake = zynq_gpio_set_wake, + .irq_request_resources = zynq_gpio_irq_request_resources, + .irq_release_resources = zynq_gpio_irq_release_resources, .flags = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED | IRQCHIP_MASK_ON_SUSPEND, }; @@ -519,6 +556,8 @@ static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) .irq_unmask = zynq_gpio_irq_unmask, .irq_set_type = zynq_gpio_set_irq_type, .irq_set_wake = zynq_gpio_set_wake, + .irq_request_resources = zynq_gpio_irq_request_resources, + .irq_release_resources = zynq_gpio_irq_release_resources, .flags = IRQCHIP_MASK_ON_SUSPEND, };