From patchwork Fri Dec 29 13:31:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 122933 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4693483qgn; Fri, 29 Dec 2017 05:31:57 -0800 (PST) X-Received: by 10.46.41.68 with SMTP id u65mr21066487lje.47.1514554317634; Fri, 29 Dec 2017 05:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514554317; cv=none; d=google.com; s=arc-20160816; b=KkulwxIu6ryM5yHi+oLvYQQXw//wPK0lPUX8kw/Q0T0+I+hhiekauPs6SVmJ7n4JKX JhjPG3EFdY76nuFXH6W8mfo7dpS0PM4Ok8RAaZbsbUbSK/SEJk8jnS+Gl8Odb0rtp0ym zu0RXBtPKh086ZLbnEiHJr6diIxcB+V2UF5KLksxXx03QUyiC3nurYVzq88cKNb7zjdj 9s2V0KEZXlL1oRdQOd0+QqyvFcKHxu4yNIDCekKM9Z6zXsxM9bL5+OgROKmsivE053Pq e/UmeV9ZqV+3WG220Zj2WL/grwDxFLEehcBQqBpoNmC3GJedT8/2ZfvO26qR1BZYU5cI YJgw== 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=LwXAnuGJ78+XbOZKC0valKzvmjWZjg9Ac88HF/6yWzo=; b=dSEwtgGffoL05L2hCgtEh3/DXRqmxW4OY6+t4yEseg46pWOE+Gzq9vTpmPLVUc9C/1 l5Xi1s3sVz34dtl2tMraKosfXMjbGM6gHXA8FWo0ZVw63sP6nyEoQ35mzGUUb8f34Wks qmMHshsldzNUqvSX3OrL5w3SgwFuNv1AX39e++4wDJaQUB7dCEimoUBgooFx/O9k0WTY 5mE/nooorAzVR63n0uz9hJFb2oRlgi583bkvYRce40UPcGTckhTo8W1Snd0zN2ydhxFu Ho2Qgzwwh/rA4sruhlNIEC3hupPh+j526/XLrLWht8oTvA6YgxwNnLCX4flT0Zdji1ND Jg7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i5CJp2XO; 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 p81sor6335128lje.113.2017.12.29.05.31.57 for (Google Transport Security); Fri, 29 Dec 2017 05:31:57 -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=i5CJp2XO; 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=LwXAnuGJ78+XbOZKC0valKzvmjWZjg9Ac88HF/6yWzo=; b=i5CJp2XO2/mXX0ZpkzNUAh3/qCUDEc8FyZQI1QpkmeFTEyLhVXoybiXTpB5u0ed9FF WJ0rWDiy1nmjfwRDa3Ea6qzp9AGAtf3pnHnMr1oiNZ+QwiX1w/lrKG39Tc7/Z/vRVoje yHd0ZGuWf7qPpeHayKiGp+vFxDzjMBhtuO/PE= 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=LwXAnuGJ78+XbOZKC0valKzvmjWZjg9Ac88HF/6yWzo=; b=nRrMVSPWZBbxOmTpdKYcnZPRpu9+v2TBiJNoCyNWk4wzE1nWuwB2Ku4NOufsCT3cbh doeujlH/8vQ4Wtro+qs7I44ejuqLItnjvLoGIFplnOV3qlZXVA+/cf+eVeI3sck32sRP w5Mfelqu+omHIC2kiBqzYikDx8dSiomZGL0mm/nhXMXXtA9a5tRh+nLWjn/WmH95Yx4q dV6XhYB2mdzN3TvhflGCWGPGiOBnp+vliygu+5T6nBb5nzaE3qpFiLSTQvUylk5EHW8v dOQQhKxeN9ktRI0amLwjbART1a3IKY7E0EsowXrIJzXVqLJAkXWnjyBLNkHUQ6zfyjGT icIQ== X-Gm-Message-State: AKGB3mJZ3cPi0DaabxBIhG4Ha+RlQbPsFloYyCeftgwTakUs9w6P01n+ io7uOuMfRkoJP8Sntq+kDs2ZVdJD X-Google-Smtp-Source: ACJfBotRIkud8MQBR33jmJQ0z/bhxdvB1gtmj+4/vZTKVUuaKB7yVUtFUR50DlnHb0J6u6Ky0RN19g== X-Received: by 10.46.21.13 with SMTP id s13mr17325658ljd.70.1514554317217; Fri, 29 Dec 2017 05:31:57 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 05:31:56 -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 2/3] irqchip/renesas-irqc: Use WAKEUP_PATH driver PM flag Date: Fri, 29 Dec 2017 14:31:43 +0100 Message-Id: <1514554304-18989-3-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 6f46aedb9c85873b ("irqchip: renesas-irqc: Add wake-up support"), when an IRQ is used for wakeup, the INTC block's module clock 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-irqc.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/drivers/irqchip/irq-renesas-irqc.c b/drivers/irqchip/irq-renesas-irqc.c index 52304b1..70d1409 100644 --- a/drivers/irqchip/irq-renesas-irqc.c +++ b/drivers/irqchip/irq-renesas-irqc.c @@ -17,7 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include #include @@ -64,7 +63,7 @@ struct irqc_priv { struct platform_device *pdev; struct irq_chip_generic *gc; struct irq_domain *irq_domain; - struct clk *clk; + unsigned wakeup_path:1; }; static struct irqc_priv *irq_data_to_priv(struct irq_data *data) @@ -111,15 +110,7 @@ static int irqc_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; } @@ -159,12 +150,6 @@ static int irqc_probe(struct platform_device *pdev) p->pdev = pdev; platform_set_drvdata(pdev, p); - p->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(p->clk)) { - dev_warn(&pdev->dev, "unable to get clock\n"); - p->clk = NULL; - } - pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); @@ -276,6 +261,18 @@ static int irqc_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int irqc_suspend(struct device *dev) +{ + struct irqc_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(irqc_pm_ops, irqc_suspend, NULL); + static const struct of_device_id irqc_dt_ids[] = { { .compatible = "renesas,irqc", }, {}, @@ -288,6 +285,7 @@ static struct platform_driver irqc_device_driver = { .driver = { .name = "renesas_irqc", .of_match_table = irqc_dt_ids, + .pm = &irqc_pm_ops, } };