From patchwork Tue Dec 22 10:16:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 58844 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3139544lbb; Tue, 22 Dec 2015 02:16:30 -0800 (PST) X-Received: by 10.98.75.10 with SMTP id y10mr34517848pfa.86.1450779390703; Tue, 22 Dec 2015 02:16:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sw10si3585212pab.55.2015.12.22.02.16.30; Tue, 22 Dec 2015 02:16:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932654AbbLVKQ3 (ORCPT + 11 others); Tue, 22 Dec 2015 05:16:29 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34900 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932652AbbLVKQ2 (ORCPT ); Tue, 22 Dec 2015 05:16:28 -0500 Received: by mail-pa0-f48.google.com with SMTP id jx14so87412048pad.2 for ; Tue, 22 Dec 2015 02:16:28 -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 :in-reply-to:references; bh=haQwt4Mk8z1lZEetgdtmM/Ja/bEuvUbE5oDTmNkRAgs=; b=gBxB16DML4lOkUPsyvBd8dRlNtP+wXL3zckQgz9Wn54Zq37iPligJ7lSMB/QK2l/jv p0Q6kNJHBKxUMwJUBBm96ZkdNt0CGdqk2+lw69Y2LqN6wc/FGEc+xoswS/Nzze7At3up eHx6t/NE1qXLM1eBBaxvwOiCTHXGV9JwAaLHE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=haQwt4Mk8z1lZEetgdtmM/Ja/bEuvUbE5oDTmNkRAgs=; b=VwOPnlgKWlL3WWW7VaTyL0wSL+tS6pvVPKJ2IdBfkAHElwEosdvvZaRVytBa7oedfd Qf1gKx6dwhVJizuyKA3+8epCp32hvJGkBMjdJajyaOqF0thbFq2zEWeqPerek1a6QNLW BD9axyqxQ3CqwNkz20gjYEX/R1lAV/CzQEXBmzyhE0cQt7t8VBbUqdjXy5sNCcgjl664 2Kzwb6I31A8cf+AvQ51QqFpLNkIzOr3D4FiOTJjYvqd1aZP1v6wF8kbcs4zWEWq94HWH PUIy+PZIADRByLTkadnRehPUVU/CmzkOtghNWY27qkkmINvbmH0ytOnzUdKicwFyoq9c XO3w== X-Gm-Message-State: ALoCoQnOgnBDPX73YUIleSn5VET+NpnHgVnA8xrC+o/C7b4tdDXY67kyoEY8531KaYBhUs1D4c5xGe/KIunQ5IwJiSSDLhFFKQ== X-Received: by 10.66.219.98 with SMTP id pn2mr34094130pac.113.1450779388400; Tue, 22 Dec 2015 02:16:28 -0800 (PST) Received: from localhost ([122.171.29.67]) by smtp.gmail.com with ESMTPSA id y27sm40224741pfa.29.2015.12.22.02.16.27 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 22 Dec 2015 02:16:27 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Stephen Boyd , nm@ti.com, Viresh Kumar Subject: [PATCH 01/17] PM / OPP: get/put regulators from OPP core Date: Tue, 22 Dec 2015 15:46:02 +0530 Message-Id: <8731ff871e0eedfb08b9428af8da21b25d1ad283.1450777582.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.0.rc1.186.g94414c4 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The allows the OPP core to request/free the regulator resource, attached to a device OPP. The regulator device is fetched using device node and name of the device. For example, a cpu0 device node needs to look like this: cpu0: cpu@900 { device_type = "cpu"; compatible = "arm,cortex-a9"; reg = <0x900>; cpu0-supply = <&varm>; ... }; This will work for both OPP-v1 and v2 bindings. This is a preliminary step in moving the OPP switching logic into the OPP core. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 8 ++++++++ drivers/base/power/opp/opp.h | 4 ++++ 2 files changed, 12 insertions(+) -- 2.7.0.rc1.186.g94414c4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index cd230c63aee6..2e49f5e9daa3 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -505,6 +505,7 @@ static struct device_opp *_add_device_opp(struct device *dev) { struct device_opp *dev_opp; struct device_list_opp *list_dev; + const char *name = dev_name(dev); /* Check for existing list for 'dev' first */ dev_opp = _find_device_opp(dev); @@ -527,6 +528,11 @@ static struct device_opp *_add_device_opp(struct device *dev) return NULL; } + dev_opp->regulator = regulator_get_optional(dev, name); + if (IS_ERR(dev_opp->regulator)) + dev_info(dev, "%s: no regulator (%s) found: %ld\n", __func__, + name, PTR_ERR(dev_opp->regulator)); + srcu_init_notifier_head(&dev_opp->srcu_head); INIT_LIST_HEAD(&dev_opp->opp_list); @@ -565,6 +571,8 @@ static void _remove_device_opp(struct device_opp *dev_opp) if (dev_opp->prop_name) return; + regulator_put(dev_opp->regulator); + list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp, node); diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index 690638ef36ee..c4a03ad34100 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -132,6 +133,8 @@ struct device_list_opp { * @supported_hw: Array of version number to support. * @supported_hw_count: Number of elements in supported_hw array. * @prop_name: A name to postfix to many DT properties, while parsing them. + * @regulator: Supply Regulator + * * @dentry: debugfs dentry pointer of the real device directory (not links). * @dentry_name: Name of the real dentry. * @@ -159,6 +162,7 @@ struct device_opp { unsigned int *supported_hw; unsigned int supported_hw_count; const char *prop_name; + struct regulator *regulator; #ifdef CONFIG_DEBUG_FS struct dentry *dentry;