Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4876178imm; Mon, 11 Jun 2018 21:44:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL8UjwAcwAvnr0RSIOWTTHRsOnVPsbF5X4FZ0XP9jrmLUMYkf7U5HozdZouOPv7ijfUAC7F X-Received: by 2002:a65:52c3:: with SMTP id z3-v6mr1811415pgp.69.1528778662744; Mon, 11 Jun 2018 21:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528778662; cv=none; d=google.com; s=arc-20160816; b=luZaAw8N9LzSYJe0inoIQsAzfflms0dEKtNQ4xnQxjLYCKk/LihzBnzouBb3D0Kv+P k/DXM3Fwsfp5jCzG2JrO6iO78gG3xcx7+U3VjL9hIO7DnKVSVNWoBpVRryXWY1swEcoW +0wQmiCWMjDEstJUvxSh36h0C1ECTD5Pu1dM0AppvKl9GELNg7fY9XPQvcoa/ZyUOeVp 8EqAqWAfL+qmr0VMeMY8e0StB0aMW+GMse5RPRrrK0kvYEiZ/wCsUlYWdB8ByeFxIjBp p6K80drkMz2FezKXSVOfYHrZM6aeBb3Z5OsBZwKNwcsah/vtuiBoKcBqy7Ngon4dgZ1P 6eLA== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=Sl23GkArLENmqoZW/rnwm1H728zu6b4aKzRanchrN4o=; b=iq8Vp52YDbWnQGkmRCCOvhf1TAAN5SXpeR2ZiNDl+hoYip5PYGbOuMyaBMUYEIrEvT m4TW085gYUOLlKYIWviSN5VtvoxQNaD81/mHUoC4MZuBxDNxEACDc08nwG4KkABWluKj gUgGEFmocZMVozcgD0lsDlLR1qqg6jzuoudqrUznd1yge1ywjZLlO8roGK8vOX/P8lcO EZX8kxGCc24u8St7TB8rs7XIZk9zAeXgLPkJyTpM5EVUVHAB/O0aigtR1lKw2baxOapf In/jBSle5k2kMuq2dnrTRFABNQ+y+nZbkzbdpjneY8qfkuHJXZj1KSoIpuutJIDEAjLi 1Lqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=f4Vctgdb; dkim=pass header.i=@codeaurora.org header.s=default header.b=f4Vctgdb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h190-v6si11572034pfc.206.2018.06.11.21.44.08; Mon, 11 Jun 2018 21:44:22 -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=@codeaurora.org header.s=default header.b=f4Vctgdb; dkim=pass header.i=@codeaurora.org header.s=default header.b=f4Vctgdb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932748AbeFLElU (ORCPT + 99 others); Tue, 12 Jun 2018 00:41:20 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35578 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932592AbeFLElQ (ORCPT ); Tue, 12 Jun 2018 00:41:16 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A3BB9606DB; Tue, 12 Jun 2018 04:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528778475; bh=2PsLQXkbj8YhPi/iL6JYwQqestRqLcAiGDq6PNpE6+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4VctgdbGBIk3D6CpYwG3cY9YWpt0myTgGsK1Euz+fpJlZSlXjLgBVa5OEHl0MXy0 MK5gc41/0GbhhIU6FBVkzttq/JI14hjcmA+1pUvUvpUchh/52MeaZL4tF6YbnmiUUz evtePBem51ivTLGUPwJuVK1Tk2icSqUL1cXxd8KU= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-173.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rnayak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id EFF4E602BD; Tue, 12 Jun 2018 04:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528778475; bh=2PsLQXkbj8YhPi/iL6JYwQqestRqLcAiGDq6PNpE6+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4VctgdbGBIk3D6CpYwG3cY9YWpt0myTgGsK1Euz+fpJlZSlXjLgBVa5OEHl0MXy0 MK5gc41/0GbhhIU6FBVkzttq/JI14hjcmA+1pUvUvpUchh/52MeaZL4tF6YbnmiUUz evtePBem51ivTLGUPwJuVK1Tk2icSqUL1cXxd8KU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EFF4E602BD Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rnayak@codeaurora.org From: Rajendra Nayak To: viresh.kumar@linaro.org, sboyd@kernel.org, andy.gross@linaro.org, ulf.hansson@linaro.org, collinsd@codeaurora.org Cc: devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Rajendra Nayak Subject: [PATCH v3 3/7] soc: qcom: rpmpd: Add support for get/set performance state Date: Tue, 12 Jun 2018 10:10:48 +0530 Message-Id: <20180612044052.4402-4-rnayak@codeaurora.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180612044052.4402-1-rnayak@codeaurora.org> References: <20180612044052.4402-1-rnayak@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for the .set_performace_state() and .opp_to_performance_state() callbacks in the rpmpd driver. Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/soc/qcom/rpmpd.c | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index c5e7a91f278c..53209454c1f3 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -28,6 +29,8 @@ #define KEY_ENABLE 0x6e657773 /* swen */ #define KEY_FLOOR_CORNER 0x636676 /* vfc */ +#define MAX_RPMPD_STATE 6 + #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ static struct rpmpd _platform##_##_active; \ static struct rpmpd _platform##_##_name = { \ @@ -221,6 +224,47 @@ 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); + + if (state > MAX_RPMPD_STATE) + goto out; + + 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 unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, + struct dev_pm_opp *opp) +{ + struct device_node *np; + unsigned int corner = 0; + + np = dev_pm_opp_get_of_node(opp); + if (of_property_read_u32(np, "qcom,level", &corner)) { + pr_err("%s: missing 'qcom,level' property\n", __func__); + return 0; + } + + of_node_put(np); + + return corner; +} + static int rpmpd_probe(struct platform_device *pdev) { int i; @@ -261,6 +305,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.set_performance_state = rpmpd_set_performance; + rpmpds[i]->pd.opp_to_performance_state = rpmpd_get_performance; pm_genpd_init(&rpmpds[i]->pd, NULL, true); data->domains[i] = &rpmpds[i]->pd; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation