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, } }; 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, } }; From patchwork Fri Dec 29 13:31:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 122934 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4693506qgn; Fri, 29 Dec 2017 05:31:59 -0800 (PST) X-Received: by 10.25.78.139 with SMTP id u11mr16026834lfk.74.1514554319025; Fri, 29 Dec 2017 05:31:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514554319; cv=none; d=google.com; s=arc-20160816; b=YBbslqKV/kRRJYUECj45XwJjq7CMyjMqJtBu67wsDb7zZIyis/HEViQmWZ5y2NsRzs Dl6xwploK5S59i7Fe1QTgjUd/ru14yVMdnDENev7if03RBx6XLBpe0rxEsJOYbgK9ZRj PN7M5c5z7JEx5Ofv9Bsnb0hOvsGGR4Nr62DKagvNqGInQkSj8kgg81TVwngnOHjSRttD 6eqy5I6Ss1/T8vC1CdfI4pvyTI1vcspEkzE1iTrm8wCSSJ7ZqUhb8l6OSxpQIctgVRcW S2xX19i4WtcgGMXZv9rFHmKXM2FTelB8i4ShzMPXbNDWbtRlTtzOBg5LmdlvWz0a1l+u v4rg== 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=sulh0w5+N8RScC/fQuBW5bA6oAD6C6mJc4v69Maq8ag=; b=siNtESbQlEg0jar7Il8uxN1Z2WlwCSto7+sjQrWvHO+6pLMIY2nU9NBt9L3EBK++ye hfrTYfv1FTggZW62K7AqbhnTIdxFbbGorWwG7YSIwVM2Z39Ohk8d0mZOihX8OKguv8uC hh8z/fRvpe4mwp3jPfyRmxX7ZLejH6AFjqHk6fE9PHhTWkJvgRABE2tqizHysNINNwFd +6gohIqfsjpH0MLLnBCaAeRtmtG9GB/SWzbzKLHiQoXZnCNZd0MNKjBkLQ4wpD5svmkb wtGiYyJ3EYptLKUkkHIgxZPVqd6DYuxlEac5oTIoOTaMuFPblD//oNaIdPZGr2PuLg+u hFRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OGji4OjD; 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 e81sor6428812ljf.78.2017.12.29.05.31.58 for (Google Transport Security); Fri, 29 Dec 2017 05:31:59 -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=OGji4OjD; 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=sulh0w5+N8RScC/fQuBW5bA6oAD6C6mJc4v69Maq8ag=; b=OGji4OjDz3svCxUNF7MU7EYbmRKFb5NnOPmgJWll3hEYhqpYImg/Oyfg714CE36DK9 fY1q6d5BHiK8uxrThFua7fu8NrS0y9KQq71WJCJXSBxNYFZI3hT62uE7MWBhqiSPLwA4 fvHQKS7IiR6Er2h6YiSrfMO6aQapnAfKYfAao= 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=sulh0w5+N8RScC/fQuBW5bA6oAD6C6mJc4v69Maq8ag=; b=Yf6n5D64vUpyA3O1Wu1SD8nwUI0RGF5m0RMCmsvEjK/3l5/XmIWgfxTTFiVaMQxb08 aZWflkrD/yWrC5ADamU5WKtkncY8WOZymoO+gmgBd55tNBuDxYp9c+NFhUYwvkKOoRR2 Z0Vb5epYhJSnvs//MmOw0hrLE8zbh6DYHqpXAiz8S1loGQ24NmmlW1dUvimKQLYfqsLq 5phsLs9JnDXlRtat0HSu3Zvds6Y5VL4pZlfEgW9H+/McMkiMRCOK9MfnWgDFmG0G8QJt LDT3cUHSkjeihYwnuV8UsXw0FdDPMG996PzezUtar7XtFDeUB9kbgQgDh3jLoBPAdPyC 1Hyg== X-Gm-Message-State: AKGB3mJ5wtedW2jpbobCJ2Zf50MWkBbbBmaUcM+XuH75MhEeXt3IChlM Uyw5pRxHjHKIeSBxjZPOmYpErdKP X-Google-Smtp-Source: ACJfBouE9jgitUzaiD9DOOzljLX/NYyIWUN0aAv3NUCaPM1+ohfCtZCKqA0sbvQuqHkSErQ22r2Xkg== X-Received: by 10.46.99.131 with SMTP id s3mr19247981lje.143.1514554318650; Fri, 29 Dec 2017 05:31:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 05:31:57 -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 3/3] gpio: rcar: Use WAKEUP_PATH driver PM flag Date: Fri, 29 Dec 2017 14:31:44 +0100 Message-Id: <1514554304-18989-4-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 ab82fa7da4dce5c7 ("gpio: rcar: Prevent module clock disable when wake-up is enabled"), when a GPIO is used for wakeup, the GPIO 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/gpio/gpio-rcar.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) -- 2.7.4 Acked-by: Linus Walleij diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index e76de57..d414511 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -14,7 +14,6 @@ * GNU General Public License for more details. */ -#include #include #include #include @@ -37,10 +36,9 @@ struct gpio_rcar_priv { struct platform_device *pdev; struct gpio_chip gpio_chip; struct irq_chip irq_chip; - struct clk *clk; unsigned int irq_parent; bool has_both_edge_trigger; - bool needs_clk; + bool wakeup_path; }; #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ @@ -186,14 +184,7 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on) } } - if (!p->clk) - return 0; - - if (on) - clk_enable(p->clk); - else - clk_disable(p->clk); - + p->wakeup_path = on; return 0; } @@ -330,17 +321,14 @@ static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset, struct gpio_rcar_info { bool has_both_edge_trigger; - bool needs_clk; }; static const struct gpio_rcar_info gpio_rcar_info_gen1 = { .has_both_edge_trigger = false, - .needs_clk = false, }; static const struct gpio_rcar_info gpio_rcar_info_gen2 = { .has_both_edge_trigger = true, - .needs_clk = true, }; static const struct of_device_id gpio_rcar_of_table[] = { @@ -403,7 +391,6 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args); *npins = ret == 0 ? args.args[2] : RCAR_MAX_GPIO_PER_BANK; p->has_both_edge_trigger = info->has_both_edge_trigger; - p->needs_clk = info->needs_clk; if (*npins == 0 || *npins > RCAR_MAX_GPIO_PER_BANK) { dev_warn(&p->pdev->dev, @@ -415,6 +402,18 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) return 0; } +#ifdef CONFIG_PM_SLEEP +static int gpio_rcar_suspend(struct device *dev) +{ + struct gpio_rcar_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(gpio_rcar_pm_ops, gpio_rcar_suspend, NULL); + static int gpio_rcar_probe(struct platform_device *pdev) { struct gpio_rcar_priv *p; @@ -440,16 +439,6 @@ static int gpio_rcar_probe(struct platform_device *pdev) platform_set_drvdata(pdev, p); - 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); irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); @@ -536,6 +525,7 @@ static struct platform_driver gpio_rcar_device_driver = { .remove = gpio_rcar_remove, .driver = { .name = "gpio_rcar", + .pm = &gpio_rcar_pm_ops, .of_match_table = of_match_ptr(gpio_rcar_of_table), } };