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: 853912 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="OGji4OjD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z7SDk2BRsz9s1h for ; Sat, 30 Dec 2017 00:32:05 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751125AbdL2NcE (ORCPT ); Fri, 29 Dec 2017 08:32:04 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:40545 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbdL2NcA (ORCPT ); Fri, 29 Dec 2017 08:32:00 -0500 Received: by mail-lf0-f65.google.com with SMTP id u84so28178718lff.7 for ; Fri, 29 Dec 2017 05:31:59 -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=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=B427TTlERGNAw/MxWAEDxENr5dvUQezk5zfj3rysBBldAZG7gJK6bagMSkjVzg0C51 cy83bz2/x/mudS0e/OM/42wZE6MqU3XIowk8gvajQozQE7Tnm6c7KAzreWPVtrrzNdV2 ys6Oq6JSxBtuwB2oGJYpoDjzJlSfpe0MMq+bJwYsidl/5dXNHsf0rqxmVSjumEifWQ36 HWj7BGWZoWQst2iWLdZF35g5fnkXZwWFXHbvB/0/mf7pUM1oMNOb2mIdk6nrQLUmpnnf S5z/CFqzcyPG98Vp6QCmZdWfuv/kclx/7WwbleLB2ay6zeQqG036Jr+XKCmYMmiaYz86 GrOA== X-Gm-Message-State: AKGB3mK8FIDfH5T20a/ZNyhbMJs/M8dKRfYnTWO20Sv6JTeHd53jUlUI 8AIuA648EfyA23YCYEJ1EqX0vuHZ8EQ= 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) 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> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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 Acked-by: Linus Walleij --- drivers/gpio/gpio-rcar.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) 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), } };