Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp491837ybt; Fri, 26 Jun 2020 04:37:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgU0l0XnGS5c+Fb6OdkfMfCmLxj7itho1HpXN76OFo+p1X5/dcSVjrykvieyS8gzideYUM X-Received: by 2002:a17:906:ca56:: with SMTP id jx22mr2090825ejb.494.1593171427344; Fri, 26 Jun 2020 04:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593171427; cv=none; d=google.com; s=arc-20160816; b=z1E7xz93772Y3QNhrNT6RirF0r6SMnVbwEpWvGihBwnoxZMrYyCDYdnFNkG42R4j3D fotrZtUxgcYrRSjdF5w/MhpD9Frq3Jd7QkQY/HUEIjTkap4ZnObsy0L2iBvQc3iIHIYm NlIo9t2FFZywPwY2mX/3E61Vpw5u2TlkhElYq81pyd2+a/Qe1a4vHgYb6vwSMVg9393t /1aLJmhvBnyjJSdnYZTecd9Bkk3jYi2rwntSOGJ6Wcs+crkMWN+K7zQvGiV4rDkMdq6W 6X052evfIjzUIjlrSrUcoZ6Rnoom/YoIxzudgHbJLY0qu9MRXpgYsNDtOKixS19DuGVv jaVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ZOnqFi5WYSNbwZpjxdZxQ0VbasnKYK8n6vIe4/B1ufM=; b=f9qDIRdjFKAetG1vaaI6dznvijWDZJ5CNsTLj11oOIFsjmzLENtwSpFz5bKpipmq9X y+/rbdc5Nbcow8g4DgSaI6/zWlmDU+V8Z2v0tfHrmldIg7xr0brYxoBXIxjHCuZ/2u+t lw+QpVoNVGnD3CM569wfpTcRFmCpwsk7j6vZfn9Jo1lWxzInPtOBXT6KQqCK5+OnhBO5 Iy2bEZentEKWVlzYWTRUm0JPUcLTqFEVCqJViYJZAxHRg2UhsagwIyevrHe+c86f2mkX lhczwTmBQklctqsCByurgty+OiHzTW//OFKlSYPthzZNGQ9ms4Ch3bQnn8aqDJyfndIa b/GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo24si7319515edb.536.2020.06.26.04.36.42; Fri, 26 Jun 2020 04:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726608AbgFZJcb (ORCPT + 99 others); Fri, 26 Jun 2020 05:32:31 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:24970 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726074AbgFZJca (ORCPT ); Fri, 26 Jun 2020 05:32:30 -0400 X-IronPort-AV: E=Sophos;i="5.75,283,1589209200"; d="scan'208";a="50446469" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 26 Jun 2020 18:32:28 +0900 Received: from localhost.localdomain (unknown [10.166.252.89]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6BEAD42034D1; Fri, 26 Jun 2020 18:32:28 +0900 (JST) From: Yoshihiro Shimoda To: ulf.hansson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH/RFC v4 2/4] regulator: fixed: add regulator_ops members for suspend/resume Date: Fri, 26 Jun 2020 18:32:20 +0900 Message-Id: <1593163942-5087-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593163942-5087-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1593163942-5087-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The regulator-fixed driver is possible to be off by firmware like PSCI while the system is suspended. If a consumer could get such a condition from regulator_is_enabled(), it's useful by consumers. So, add some regulator_ops members for it. And then, if regulator-fixed nodes have suitable sub-nodes and properties [1], regulator_is_enabled() will return false while suspend() of a consumer. [1] - The node has regulator-state-(standby|mem|disk) sub-nodes. - The node doesn't have regulator-always-on. - The sub-node has regulator-off-in-suspend property. Signed-off-by: Yoshihiro Shimoda --- drivers/regulator/fixed.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index d54830e..0bd4a1a 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -35,6 +35,7 @@ struct fixed_voltage_data { struct clk *enable_clock; unsigned int clk_enable_counter; + bool disabled_in_suspend; }; struct fixed_dev_type { @@ -49,6 +50,31 @@ static const struct fixed_dev_type fixed_clkenable_data = { .has_enable_clock = true, }; +static int reg_is_enabled(struct regulator_dev *rdev) +{ + struct fixed_voltage_data *priv = rdev_get_drvdata(rdev); + + return !priv->disabled_in_suspend; +} + +static int reg_prepare_disable(struct regulator_dev *rdev) +{ + struct fixed_voltage_data *priv = rdev_get_drvdata(rdev); + + priv->disabled_in_suspend = true; + + return 0; +} + +static int reg_resume_early_disable(struct regulator_dev *rdev) +{ + struct fixed_voltage_data *priv = rdev_get_drvdata(rdev); + + priv->disabled_in_suspend = false; + + return 0; +} + static int reg_clock_enable(struct regulator_dev *rdev) { struct fixed_voltage_data *priv = rdev_get_drvdata(rdev); @@ -132,6 +158,9 @@ of_get_fixed_voltage_config(struct device *dev, } static struct regulator_ops fixed_voltage_ops = { + .is_enabled = reg_is_enabled, + .set_prepare_disable = reg_prepare_disable, + .clear_resume_early_disable = reg_resume_early_disable, }; static struct regulator_ops fixed_voltage_clkenabled_ops = { -- 2.7.4