From patchwork Fri Dec 29 13:31:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10137113 X-Patchwork-Delegate: geert@linux-m68k.org 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 C2503603FA for ; Fri, 29 Dec 2017 13:32:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2CC92DE56 for ; Fri, 29 Dec 2017 13:32:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BA182DE69; Fri, 29 Dec 2017 13:32:34 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43B152DE57 for ; Fri, 29 Dec 2017 13:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750869AbdL2Ncd (ORCPT ); Fri, 29 Dec 2017 08:32:33 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33247 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860AbdL2Nb5 (ORCPT ); Fri, 29 Dec 2017 08:31:57 -0500 Received: by mail-lf0-f68.google.com with SMTP id j143so2880993lfg.0 for ; Fri, 29 Dec 2017 05:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=53ewk0r+AdY7BK1DbDd+MJ480myn9KOg462PcKg4ENQ=; b=PPDl7NXiXGnzoL+2UhnM8i+6WIt81bDw76YXQh3/ovtCDREz8JxPOqHEqtS/tiMsZI P1Dgx8KoTIIvUbxDUPvF+qaYaHsj6dzzhpMaE8ixwkxcOepuGunCWKwYrJhMbs6fk5fY +0j6+1Uk58aCVA8gyZAXIshTV7U1HYXjNUauk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=53ewk0r+AdY7BK1DbDd+MJ480myn9KOg462PcKg4ENQ=; b=WaS/CCKf9No8Nv/fgwSnyGYytfSHHI4jL0blAsBbWqxWSYwNWHGA3nuSJNDiyVzXG0 oi+fS3wMj+0SAbW7PprLHccJZczP4rxocP9jCenzBRbNJW9JfGczrNIBqeB0C1gz33nI /8eLaYm9rQ9VDgIHBB+baBU2Eg4MhOxaddkh0X2BYGco4FipPT80u1csWW0YmJEXtY63 gaDtZ17BivtwEEyoo4zBut9CU88GrLxvNwXoUz2qn1TuoPJY85pV5E3ZyK+Jyje8azOK WFVuckOHdskRvGZgbT2c1W2IKgSV5klezGpVUAGW4x3W3FgvyA7IJ5uTbYPNBtrdA1gj x91Q== X-Gm-Message-State: AKGB3mIcD2vWSm+r+nM5ikidRNbLzDMZ06Knbs3jclxoBF0KA7mr2BcX 4oBpRzdOVrOnCUSXdG5rpnXxgQ== X-Google-Smtp-Source: ACJfBotbDx63Sq2OKIwfRHprHvp03DwQRLPxQYkPShsDqYMmtwooxOHb3M/z9CRaiRiZkRcpDB5JGQ== X-Received: by 10.46.117.28 with SMTP id q28mr19906102ljc.14.1514554315933; Fri, 29 Dec 2017 05:31:55 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id e72sm7521063lji.63.2017.12.29.05.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 05:31:55 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Thomas Gleixner , Jason Cooper , Marc Zyngier , Linus Walleij , Simon Horman , Niklas Soderlund , Geert Uytterhoeven , Ulf Hansson , linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] irqchip/renesas-intc-irqpin: Use WAKEUP_PATH driver PM flag Date: Fri, 29 Dec 2017 14:31:42 +0100 Message-Id: <1514554304-18989-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514554304-18989-1-git-send-email-ulf.hansson@linaro.org> References: <1514554304-18989-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Geert Uytterhoeven Since commit 705bc96c2c15313c ("irqchip: renesas-intc-irqpin: Add minimal runtime PM support"), when an IRQ is used for wakeup, the INTC block's module clock (if exists) is manually kept running during system suspend, to make sure the device stays active. However, this explicit clock handling is merely a workaround for a failure to properly communicate wakeup information to the PM core. Instead, set the WAKEUP_PATH driver PM flag to indicate that the device is part of the wakeup path, which further also enables middle-layers and PM domains (like genpd) to act on this. In case the device is attached to genpd and depending on if it has an active wakeup configuration, genpd will keep the device active (the clock running) during system suspend when needed. This enables us to remove all explicit clock handling code from the driver, so let's do that as well. Signed-off-by: Geert Uytterhoeven [Ulf: Converted to use the WAKEUP_PATH driver PM flag] Signed-off-by: Ulf Hansson --- drivers/irqchip/irq-renesas-intc-irqpin.c | 42 +++++++++++-------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c index 06f29cf..bfc2c5c 100644 --- a/drivers/irqchip/irq-renesas-intc-irqpin.c +++ b/drivers/irqchip/irq-renesas-intc-irqpin.c @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include #include @@ -78,16 +77,14 @@ struct intc_irqpin_priv { struct platform_device *pdev; struct irq_chip irq_chip; struct irq_domain *irq_domain; - struct clk *clk; unsigned shared_irqs:1; - unsigned needs_clk:1; + unsigned wakeup_path:1; u8 shared_irq_mask; }; struct intc_irqpin_config { unsigned int irlm_bit; unsigned needs_irlm:1; - unsigned needs_clk:1; }; static unsigned long intc_irqpin_read32(void __iomem *iomem) @@ -287,15 +284,7 @@ static int intc_irqpin_irq_set_wake(struct irq_data *d, unsigned int on) int hw_irq = irqd_to_hwirq(d); irq_set_irq_wake(p->irq[hw_irq].requested_irq, on); - - if (!p->clk) - return 0; - - if (on) - clk_enable(p->clk); - else - clk_disable(p->clk); - + p->wakeup_path = on; return 0; } @@ -365,12 +354,10 @@ static const struct irq_domain_ops intc_irqpin_irq_domain_ops = { static const struct intc_irqpin_config intc_irqpin_irlm_r8a777x = { .irlm_bit = 23, /* ICR0.IRLM0 */ .needs_irlm = 1, - .needs_clk = 0, }; static const struct intc_irqpin_config intc_irqpin_rmobile = { .needs_irlm = 0, - .needs_clk = 1, }; static const struct of_device_id intc_irqpin_dt_ids[] = { @@ -422,18 +409,6 @@ static int intc_irqpin_probe(struct platform_device *pdev) platform_set_drvdata(pdev, p); config = of_device_get_match_data(dev); - if (config) - p->needs_clk = config->needs_clk; - - p->clk = devm_clk_get(dev, NULL); - if (IS_ERR(p->clk)) { - if (p->needs_clk) { - dev_err(dev, "unable to get clock\n"); - ret = PTR_ERR(p->clk); - goto err0; - } - p->clk = NULL; - } pm_runtime_enable(dev); pm_runtime_get_sync(dev); @@ -602,12 +577,25 @@ static int intc_irqpin_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int intc_irqpin_suspend(struct device *dev) +{ + struct intc_irqpin_priv *p = dev_get_drvdata(dev); + + dev_pm_set_driver_flags(dev, p->wakeup_path ? DPM_FLAG_WAKEUP_PATH : 0); + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(intc_irqpin_pm_ops, intc_irqpin_suspend, NULL); + static struct platform_driver intc_irqpin_device_driver = { .probe = intc_irqpin_probe, .remove = intc_irqpin_remove, .driver = { .name = "renesas_intc_irqpin", .of_match_table = intc_irqpin_dt_ids, + .pm = &intc_irqpin_pm_ops, } };