From patchwork Wed Aug 2 10:12:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 109206 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp2591184qge; Wed, 2 Aug 2017 03:13:37 -0700 (PDT) X-Received: by 10.98.144.135 with SMTP id q7mr7547727pfk.229.1501668817715; Wed, 02 Aug 2017 03:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501668817; cv=none; d=google.com; s=arc-20160816; b=DxIe+rxo/uhjhrpXpBfNNKs+q+GAsE5jnBukGkqDLxP4Jj9cS3czrpeKYO1wYCVQ/k mDrizE2b7kJ//Djo/TT964vRvy/q1jYa4IlxLR5Ok6ag67DhH1tB4FTdhogAXede2p+t hBWz91fQ8xSMyEJr5QZ5PJaGmLl9VeFFyh+NZ27/MrHj6mrFVgN8+fCycf0B4d0WDZfD Go53DeikyeaNxkRPhAJZ9Igj6+xrSZfNRvHWisTxhz1wvArtj+lKQeYsaKwW4EpLkIsm a7kaSJUkfuEOgoZ8Tf2ljb6bxyECQ3Mus8OiB30FvEDHtX1Tfq7HeoEy2awTva5FtpcP /Xnw== 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=7WVHJW/q7IWlyzxQF0UA+Z7F29XuErZmWFY/9A/KKBo=; b=jAvb4SNICaQmaBoZejQfo6DtYMGzAylUUUX2YJB/WmZVq2P+hnj/Y6oyv7tyr8YxIN u96hEyN8fbxeEIpgFn2fbIHMBQH0px+WYAbRq5hG0AHp5JXdhDnit23uFBWiO1E3bQCI pVVBtzlbqeEVj8Slydz8vVHiL4yP2SkbFp1N2RYg0kSPWGLp69tdlq2f+7mx6UpwCrNP VD7KA3JKeLqiSY/8od+h38eaJSfHvmt4XHo75y0MLGRJwQgQktKB+P6g6uopqqAAbwFc UmABX/0k2GDWYMesmNVMTURaXZ6e9kXHwVeTMbMabrYbirQ40rEHdcs60msTh5MKHRFS +6Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=DGUonGfU; 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 p190si11634707pga.102.2017.08.02.03.13.37; Wed, 02 Aug 2017 03:13:37 -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.b=DGUonGfU; 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 S1752991AbdHBKNf (ORCPT + 25 others); Wed, 2 Aug 2017 06:13:35 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:34203 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752846AbdHBKM7 (ORCPT ); Wed, 2 Aug 2017 06:12:59 -0400 Received: by mail-pf0-f174.google.com with SMTP id o86so15897389pfj.1 for ; Wed, 02 Aug 2017 03:12:59 -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=7WVHJW/q7IWlyzxQF0UA+Z7F29XuErZmWFY/9A/KKBo=; b=DGUonGfUTdtHht4JG749JDZb1zh2Wwr++Q/kP6RS5b3RsSuUdMkyXgsgvSoCgNf6be 6gf4NLSLP2Q3I7oFvP43KkXm3AXE6yVMQ9eLYLH6un1kiZ4woN+DExKnjkDRQ0cn6i8S wm1DKBefJwRBK5V8F4hNc9Ir0aIHSekkQpjdg= 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=7WVHJW/q7IWlyzxQF0UA+Z7F29XuErZmWFY/9A/KKBo=; b=TwVe1DCN4aM86voVUEyPkTF0uGfQi/L3YjBPfNR4IO+OlWQmRITo+G8Hdulq7L7tTs CM5rq+KGIlq8sOFk+GBofPOw+wIMPgChjDqCMoUNtIpXFMON1j093Wu3EK/wFFnT7p5S nykwwfkYE82xLiXo2be+041JY+6MFRJC8lehL0hOuZDdUw4OW1Lf2GDPvmMOBo3RrvGP a4EoVMZMusJnUkVq2ENCdbUdH2IDXSix1QIPfcbHBotdAoXd2tZ4S952lzZ0lcvdFCir rKtQUWO0+pn5qOsuCGhA+WPW2JOQ/NpN0KLTf+IHJp9sbsIH6GH4unfvwuYuIF4o0Nxw bLMw== X-Gm-Message-State: AIVw111dSFW/w6vLb165RZuJjIJD+k9dEp5pWwbelzj7jcQ/32DZOwv2 7/vwBomzzPfdljb+ X-Received: by 10.99.166.17 with SMTP id t17mr22214988pge.60.1501668779018; Wed, 02 Aug 2017 03:12:59 -0700 (PDT) Received: from localhost ([122.171.108.183]) by smtp.gmail.com with ESMTPSA id t24sm5852913pfe.45.2017.08.02.03.12.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Aug 2017 03:12:58 -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 V9 5/7] soc: qcom: rpmpd: Add support for get/set performance state Date: Wed, 2 Aug 2017 15:42:36 +0530 Message-Id: <2cc3c8fecf9bc135b136b176ae4ce73221ee4fb6.1501668354.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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.13.0.71.gd7076ec9c9cb 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;