From patchwork Tue Sep 19 22:32:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 113067 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp33930qgf; Tue, 19 Sep 2017 15:32:53 -0700 (PDT) X-Received: by 10.98.66.220 with SMTP id h89mr126311pfd.270.1505860372980; Tue, 19 Sep 2017 15:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505860372; cv=none; d=google.com; s=arc-20160816; b=OHbqCvAd7bSe54jfqd2x/lhKVZ9jwvC56Le3/OFQG5ixKn2qJPBhDZN5PBkRAW2Evd eJkkrnl9bNpR6Ym/BQMaat8iFMRIwx4+0JFGhpQEEzgMBTUpPNliSntzPdx6JDTJhwso se6al/o8z7OyOYYEZSVNZilWonwuM2oVEOkV408rkhZSwynZs6U1NYf6xwkKM791Zcij QRJ2xEJFSnMxMb9vHouYN02kbdgLfWukI2sZxawj1R/Oyqiy0u5Nms1/L8SySyj5ttLn VMk0wdThOu+kyzUc5yCbJXtaWvpoNx+HyM5OAleh91lSlZomSn8VmunXwR8/5lNo0i+e 3i2g== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=6PW0kyzPDmXgaloqMNG2aoKogf91kc/ifQlLjujXcbg=; b=pY8ZFqCEnE6NbZFvOdvCdr1N57p/O2Bj8KK36RSXE/tWfBUNCVYfWpJ0fjhSkEZTDz P4NXtglQf98pMpGIcsm2RvLVToVm95JB2YT4hxNElvi1sF65mYElqzQXVLM283YLFoL7 66iwv9KKHIP71qnhF/SBZvHMQcytCqhVB5Zcd3UBfmDVAntXbjd5m2cfRf42OAPujhf8 XrvBSwDsmKuV1GtF7XxfXd+Lorm7+WXW15OopmFce9xRFLZF8nFRa10o1k+mFdF3Qa6O JgrNln9NsOxAPGFVRkef2g9CcXyPQQTIL+C8W2+VejEuhzVHVWMFD1/LgcGOqZ+UHQrM cVow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jO28G81M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y7si231205plh.605.2017.09.19.15.32.52; Tue, 19 Sep 2017 15:32:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jO28G81M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797AbdISWct (ORCPT + 26 others); Tue, 19 Sep 2017 18:32:49 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:50477 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751747AbdISWcp (ORCPT ); Tue, 19 Sep 2017 18:32:45 -0400 Received: by mail-pg0-f44.google.com with SMTP id p5so606668pgn.7 for ; Tue, 19 Sep 2017 15:32:45 -0700 (PDT) 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=6PW0kyzPDmXgaloqMNG2aoKogf91kc/ifQlLjujXcbg=; b=jO28G81MAy4SwGqxtZrpc0eVeoFyG2awqNeI9umJ01a5gcWp6R1ePZK5LBc68nWx7l hIg3MXzKxc7x+WnZaUcko7nWclU+QHcxIXCXgcHdRzL1ho/hIFSo3detnkM8rEYDtlW1 wfveD4OAz6PRMF6fiaLD3tNFS8Qfz4wVl4BqY= 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:in-reply-to:references; bh=6PW0kyzPDmXgaloqMNG2aoKogf91kc/ifQlLjujXcbg=; b=GUCnRo0c2TxLVog9EKyHXuNMXZqL0IXALH/1Ns+kkl/5+Gq4gaWBPwqyfTk7T6RMNn p/4iyn7s5fxv0xJs8WhO0xB+3vX/fkcZIrnvdzrPnT8oWM88lr2sQqyv7NuPupMt7hO8 lC8mx36uAar8Y/jDUWzakfiKEiz99EGX8bc9ROjzdBz0OMtkCAXP+nGqR7QAra0UEplm viCdYVAcrm3O18Z1+4krWy8NbUlmCJb1aWh/gJPuP/bGNuPYitfA2CtCPRKx9zzX5sZD rCTJ/QzaYQdCZu6EqGhoSipYbXpug/MdWh5+WH5VnKOrz1vu/9vyGg2kfoHOorMTymxG qb2A== X-Gm-Message-State: AHPjjUi1+tKvnlDCTiRBuo9wJmetbmFdXfw4K8UWRLLnkeLRDKplkIVh KOemvbWh0iceAi/Q2QVf3a9kpw== X-Google-Smtp-Source: AOwi7QDoVb2Z/IxAFMzHIfkJfkFb9AL8RncRXEZhzEoGRqouIgl8Zb0Y2FtBBrnGLgdGFjd361hxUw== X-Received: by 10.101.80.1 with SMTP id f1mr137321pgo.80.1505860364866; Tue, 19 Sep 2017 15:32:44 -0700 (PDT) Received: from localhost (cpe-172-88-64-62.socal.res.rr.com. [172.88.64.62]) by smtp.gmail.com with ESMTPSA id u8sm5437504pgq.52.2017.09.19.15.32.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Sep 2017 15:32:44 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, sudeep.holla@arm.com, linux-kernel@vger.kernel.org, Len Brown , Pavel Machek , Andy Gross , David Brown Subject: [PATCH V10 5/7] soc: qcom: rpmpd: Add support for get/set performance state Date: Tue, 19 Sep 2017 15:32:21 -0700 Message-Id: <678142c5519947b9f51a652e22fd293ac6766838.1505859768.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rajendra Nayak THIS IS TEST CODE, SHOULDN'T BE MERGED. With genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver. Not-signed-off-by: Rajendra Nayak Not-signed-off-by: Viresh Kumar --- drivers/soc/qcom/rpmpd.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) -- 2.7.4 diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index d34d9c363815..4e4f5cda9ce2 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -101,6 +101,20 @@ struct rpmpd_desc { size_t num_pds; }; +enum rpmpd_levels { + NONE, + LOWER, /* SVS2 */ + LOW, /* SVS */ + NOMINAL, /* NOMINAL */ + HIGH, /* Turbo */ + MAX_LEVEL, +}; + +struct rpmpd_freq_map { + struct rpmpd *pd; + unsigned long freq[MAX_LEVEL]; +}; + static DEFINE_MUTEX(rpmpd_lock); /* msm8996 RPM powerdomains */ @@ -126,6 +140,47 @@ static const struct rpmpd_desc msm8996_desc = { .num_pds = ARRAY_SIZE(msm8996_rpmpds), }; +enum msm8996_devices { + SDHCI, + UFS, + PCIE, + USB3, +}; + +static struct rpmpd_freq_map msm8996_rpmpd_freq_map[] = { + [SDHCI] = { + .pd = &msm8996_vddcx, + .freq[LOWER] = 19200000, + .freq[LOW] = 200000000, + .freq[NOMINAL] = 400000000, + }, + [UFS] = { + .pd = &msm8996_vddcx, + .freq[LOWER] = 19200000, + .freq[LOW] = 100000000, + .freq[NOMINAL] = 200000000, + .freq[HIGH] = 240000000, + }, + [PCIE] = { + .pd = &msm8996_vddcx, + .freq[LOWER] = 1011000, + }, + [USB3] = { + .pd = &msm8996_vddcx, + .freq[LOWER] = 60000000, + .freq[LOW] = 120000000, + .freq[NOMINAL] = 150000000, + }, +}; + +static const struct of_device_id rpmpd_performance_table[] = { + { .compatible = "qcom,sdhci-msm-v4", .data = (void *)SDHCI }, + { .compatible = "qcom,ufshc", .data = (void *)UFS }, + { .compatible = "qcom,pcie-msm8996", .data = (void *)PCIE }, + { .compatible = "qcom,dwc3", .data = (void *)USB3 }, + { } +}; + static const struct of_device_id rpmpd_match_table[] = { { .compatible = "qcom,rpmpd-msm8996", .data = &msm8996_desc }, { } @@ -230,6 +285,49 @@ static int rpmpd_power_off(struct generic_pm_domain *domain) return ret; } +static int rpmpd_set_performance(struct generic_pm_domain *domain, + unsigned int state) +{ + int ret = 0; + struct rpmpd *pd = domain_to_rpmpd(domain); + + mutex_lock(&rpmpd_lock); + + pd->corner = state; + + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) + goto out; + + ret = rpmpd_aggregate_corner(pd); + +out: + mutex_unlock(&rpmpd_lock); + + return ret; +} + + +static int rpmpd_get_performance(struct device *dev, unsigned long rate) +{ + int i; + unsigned long index; + const struct of_device_id *id; + + if (!rate) + return 0; + + id = of_match_device(rpmpd_performance_table, dev); + if (!id) + return -EINVAL; + + index = (unsigned long)id->data; + for (i = 0; i < MAX_LEVEL; i++) + if (msm8996_rpmpd_freq_map[index].freq[i] >= rate) + return i; + + return MAX_LEVEL; +} + static int rpmpd_probe(struct platform_device *pdev) { int i; @@ -267,6 +365,8 @@ static int rpmpd_probe(struct platform_device *pdev) rpmpds[i]->rpm = rpm; rpmpds[i]->pd.power_off = rpmpd_power_off; rpmpds[i]->pd.power_on = rpmpd_power_on; + rpmpds[i]->pd.genpd_set_performance_state = rpmpd_set_performance; + rpmpds[i]->pd.dev_get_performance_state = rpmpd_get_performance; pm_genpd_init(&rpmpds[i]->pd, NULL, true); data->domains[i] = &rpmpds[i]->pd;