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: 122932 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4693468qgn; Fri, 29 Dec 2017 05:31:56 -0800 (PST) X-Received: by 10.46.69.67 with SMTP id s64mr21094027lja.94.1514554316313; Fri, 29 Dec 2017 05:31:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514554316; cv=none; d=google.com; s=arc-20160816; b=g/aGXT1Mwthh0oLak8K0Q3Wbm1feb635uh7+oDPkyfArCd5JwlKmJtmh8GdZeN+vUI vKMRk0pjIL/qq9g1wOumgXuV9AhPxrRezesSkTzGS3M50Z8hY8az/3knDFFT//aXQKuJ Rvi1dq2OaqrrmQ3pRR4PhwrLq0QMKqdSpVs7V5wQ6MqM0yF/bdnO7rsVT65VG6aVggXq /qn59NwTrXebHcAE1Wg8s9cREj6gi2/Eg5SkveaXtO5GJvFnTeXqqV9a2fLC9+TLQq+L Gv8vFhM0AYTv2/CSIk4oUH4eXgjnjuCzItQn07HkUAvkx9ivfqpT435+q3TIwgtxlRha QTXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=53ewk0r+AdY7BK1DbDd+MJ480myn9KOg462PcKg4ENQ=; b=DtmYXCT4jHsWvMHyveG6aqiYHzsY+kVW7HLvVleqBtSBy5JUqs1Rk4YhEROGkSbMWd u6yeJ7JKTgSNF2JzJ/OdZgT5hfkJ6wS4s5ByEtQwUjBQk/0urkhfa/c3DQsxwCpzNFPB zBhcbjzpJsSuLcWlb2ioX28GXy0DUOTVxOX50XB2CZSz0AY2X6S1K/aTwNHkxomf4ZvW UrzyEE24CZead3hpW7wSxuEoRovVCFgQY5X6X8hSsephmjtw46j6KcgOwl06djvp4pDw Ru6d/YD2qdTG+nBUygc8KPDNFphc+RL4d0cF6daJI3wI7tBe0Yyw7DC7PlV2r4Cn/r/G 95Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PPDl7NXi; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l29sor6299354lje.16.2017.12.29.05.31.56 for (Google Transport Security); Fri, 29 Dec 2017 05:31:56 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PPDl7NXi; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=qWCqbzXmeLXFPvWd6x75MoiGNez2U3bCoJ+CZfRugwLoF4EPIVTZSq+2un2g1xNs/i TWZ+J46vvamaZJUTGrqx6cnyS7y85laC+BTOo6FTk8bk9osGv99PxvvDCZTAVo1nKzBB nT6sAjG8bMuxxAs0gazrR2PQgcAe7KwE7luh5jDm2c9XpU/gVpNxs7sZlBhUeNw5i9sh eZPNGZQ81JUQPCidQbIc4Z3ybmkqkKiexh5B7DjTAQJgmhH4Vd0l6bMuGkaTBSQYVxGF EGohmml+2jKDFiCo4ZoZBTf2OBWAdD4vfFr5VfGfCFeKbZbL3S9fvMIh74quaJcAl+8I pM2g== X-Gm-Message-State: AKGB3mLL7xBzrpqUO75zBZPstki2nZ97K+9d7L0AvNqblYvOsB0ssFtL 2VUWKYokSVqLHxoobWSV0Cx0HTuQ 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) Return-Path: 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> 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(-) -- 2.7.4 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, } };