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: 853915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PPDl7NXi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z7SFH3yrhz9s7v for ; Sat, 30 Dec 2017 00:32:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266AbdL2Ncd (ORCPT ); Fri, 29 Dec 2017 08:32:33 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:38584 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750857AbdL2Nb5 (ORCPT ); Fri, 29 Dec 2017 08:31:57 -0500 Received: by mail-lf0-f66.google.com with SMTP id w196so30185048lff.5 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=cwxX6whnikVkFftVFxjrIhzvry9qyLu9ZawmxaOG2zpEXNc9I5BKzTUx3rf+0Ar8Nq ZadLJfu1L93rKwLy4/b4SS4QrGxcw7w0siECq50ncn5kJ4LxSMvxFvgw/PIow99oJ+OP +FZ6lXa+DraRTQRQ1QjWeo2BrPJGi5TVAIfevBrYinml1+pY/LwA1EiZxlH/5nHwg73E Q2yrgrd094ml+nc/a28bUWypIkBSfuCebaOZjjZfDDESbWdrpeYUGX2VIMOwX3orJI6R XBAh2UlUE0HZzxAS3UkyH+VDI9Nm4JI+/VOdqkKD/ztn1Z5sazwxMKgJlzf8VNIJRtJ5 N3Lw== X-Gm-Message-State: AKGB3mKd2AWatSF/mv38GcGRxTtO8cEXTMWliOzlhNO4VhUKTbum8vzQ gWdVnimZgGKC33++Qe4bKbJfPg== 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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, } };