From patchwork Wed Jun 21 07:10:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106049 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1786117qgd; Wed, 21 Jun 2017 00:11:19 -0700 (PDT) X-Received: by 10.84.174.129 with SMTP id r1mr40800112plb.122.1498029079663; Wed, 21 Jun 2017 00:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498029079; cv=none; d=google.com; s=arc-20160816; b=z09XErG2GHQ3xQgx8/nt1RfVSpNLzZzUjRgA0RRjM2MEA8PfokIoPNvmL4PZ1f7HPU ZKUsMnRnE/ZRC6x8+IXzT8tZPxAI9ERMKpencsbCZeBPbALk4zPfHTrsMgfTUvZI+XUj a+Aqkb7TVShUVOE+PxXEb+bvHE+pvOvbM1pJtV/zOTDYEHt47ePnKtICSkibKqnnJP8V VbKfmxF+KBKOnXWxQSrqgUprdDYcXCD4YxZKzeC2P6zfo1hHsL7w5Hic2DrjiA6HFd8M d/sJVWQLJ7Mj5yDzgtt81NNcaFRV2O3RtbNXCTopIqmozfHQBikwLEc6Yxis/TJJ/Zp1 QH+Q== 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=Sj8jzy2PZMohsW/dn1vigltmrRKjDBEOiRLPE/Mbd1w=; b=Ii2XEZsopBtsYQ+QxFA0guiyTXKWvel571mU+7KTQlQgS/YXdV3XTx5/RdUBYWgd8U ZkXo/jUt+69yTzVxbmUidOr1M2LGwWENIhHgvdYc52VexceP18wnhQqIr+X5EbSbUjQu DQIFc7L0c8Ejqb8uQBxtfFeNx0PByJacugrX66f62Lx9G0eZOq3wmT+biML2OiQGzq2F HvTwkeEpwNmuxk+c2a1v08wc97nLBtrxXkCQvtGCNS7WlCQBuuzSSdG7vYD4jMXiGpFB F59GRHXxJ+bbmSOebgYYRkDA1GzbyNkGHbs+TaogBpc8Ucyc9VkgRauPwe6TeSsrGOuU kEfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=MvtDnVVj; 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; 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 5si12692859pgc.577.2017.06.21.00.11.19; Wed, 21 Jun 2017 00:11:19 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.b=MvtDnVVj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752420AbdFUHLM (ORCPT + 14 others); Wed, 21 Jun 2017 03:11:12 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:36857 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752403AbdFUHLJ (ORCPT ); Wed, 21 Jun 2017 03:11:09 -0400 Received: by mail-pf0-f169.google.com with SMTP id x63so80877682pff.3 for ; Wed, 21 Jun 2017 00:11:08 -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=Sj8jzy2PZMohsW/dn1vigltmrRKjDBEOiRLPE/Mbd1w=; b=MvtDnVVjIoE5HMqvfsHeqQ3Ilw+6qnVifznocDBDKwZRgyoN/qtb0damvQ0PTrmozC 8Y8Mht5Uv8FydKSarA5x3yF0FarWjOziaVuJoxi/rOtEoUa3s7NXLsRRITgkJF10FkkL UpGwwstGvydkrP8+JgZI63IgckN2edrSnTL68= 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=Sj8jzy2PZMohsW/dn1vigltmrRKjDBEOiRLPE/Mbd1w=; b=uoOFu/jv57T2Y0MRnOUlOQurufbxu/YghTqOavWeEyK1PZAKKJMjYO8kxu2omrchhT sD4Q1y5AiJ58t2uyph9CMDxblc+ZIA+qaf0G3FRWHqDfJ0EpxHJVRwOeq7S7Hy9hhY8k TmO5kGsEg8pFNqYZyQhk+YLat4+yHIUeQYSgQKk/q4aGWosSrLndcBC0zI/2jpqlldtE 5KiL/uB8L7ajJdEcFnwBYoYRPv8a5DlKoeo4IakBsP4nVJ+dFyEzOpd5jGHUX7iZ2GpX 4FMXL17yHGdzowI2ItUq7EYgnL/Zu4T4QviCG1JF4CNb2NzVEUsx4IdPOWUdel2wg4ke 5fqw== X-Gm-Message-State: AKS2vOyiAYHCpezg3L5IzdsvHuQtBvt+ueb90dUZbh9WSs5N3feyrheU d4jj+V3PJrUr0hjr X-Received: by 10.99.171.66 with SMTP id k2mr7477235pgp.248.1498029068260; Wed, 21 Jun 2017 00:11:08 -0700 (PDT) Received: from localhost ([122.172.59.234]) by smtp.gmail.com with ESMTPSA id p4sm31135986pgf.21.2017.06.21.00.11.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 00:11:07 -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: [NOT-FOR-MERGE V8 3/6] soc: qcom: rpmpd: Add a powerdomain driver to model cx/mx powerdomains Date: Wed, 21 Jun 2017 12:40:50 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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 From: Rajendra Nayak THIS IS TEST CODE, SHOULDN'T BE MERGED. The cx/mx powerdomains just pass the performance state set by the consumers to the RPM (Remote Power manager) which then takes care of setting the appropriate voltage on the corresponding rails to meet the performance needs. Add data for all powerdomains on msm8996. NOT-signed-off-by: Rajendra Nayak NOT-signed-off-by: Viresh Kumar --- .../devicetree/bindings/power/qcom,rpmpd.txt | 10 + arch/arm64/boot/dts/qcom/msm8996.dtsi | 5 + drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 307 +++++++++++++++++++++ 5 files changed, 332 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c -- 2.13.0.71.gd7076ec9c9cb diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.txt b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file mode 100644 index 000000000000..8b48ce57a563 --- /dev/null +++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt @@ -0,0 +1,10 @@ +Qualcomm RPM Powerdomains + +* For RPM powerdomains, we communicate a performance state to RPM +which then translates it into a corresponding voltage on a rail + +Required Properties: + - compatible: Should be one of the following + * qcom,rpmpd-msm8996: RPM Powerdomain for the msm8996 family of SoC + - power-domain-cells: number of cells in power domain specifier + must be 1. diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 9bc9c857a000..1fec06285f38 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -412,6 +412,11 @@ status = "disabled"; }; + rpmpd: qcom,rpmpd { + compatible = "qcom,rpmpd-msm8996", "qcom,rpmpd"; + #power-domain-cells = <1>; + }; + sdhc2: sdhci@74a4900 { status = "disabled"; compatible = "qcom,sdhci-msm-v4"; diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 9fca977ef18d..3892148be3c3 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -24,6 +24,15 @@ config QCOM_PM modes. It interface with various system drivers to put the cores in low power modes. +config QCOM_RPMPD + tristate "Qualcomm RPM Powerdomain driver" + depends on MFD_QCOM_RPM && QCOM_SMD_RPM + help + QCOM RPM powerdomain driver to support powerdomain with + performance states. The driver communicates a performance state + value to RPM which then translates it into corresponding voltage + for the voltage rail. + config QCOM_SMEM tristate "Qualcomm Shared Memory Manager (SMEM)" depends on ARCH_QCOM diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index 414f0de274fa..f7c3edfa6de8 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM) += smsm.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o +obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c new file mode 100644 index 000000000000..d34d9c363815 --- /dev/null +++ b/drivers/soc/qcom/rpmpd.c @@ -0,0 +1,307 @@ +/* + * Copyright (c) 2017, The Linux Foundation. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define domain_to_rpmpd(domain) container_of(domain, struct rpmpd, pd) + +/* Resource types */ +#define RPMPD_SMPA 0x61706d73 +#define RPMPD_LDOA 0x616f646c + +/* Operation Keys */ +#define KEY_CORNER 0x6e726f63 /* corn */ +#define KEY_ENABLE 0x6e657773 /* swen */ +#define KEY_FLOOR_CORNER 0x636676 /* vfc */ + +#define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ + static struct rpmpd _platform##_##_active; \ + static struct rpmpd _platform##_##_name = { \ + .pd = { .name = #_name, }, \ + .peer = &_platform##_##_active, \ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + }; \ + static struct rpmpd _platform##_##_active = { \ + .pd = { .name = #_active, }, \ + .peer = &_platform##_##_name, \ + .active_only = true, \ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + } + +#define DEFINE_RPMPD_CORN_LDOA(_platform, _name, r_id) \ + static struct rpmpd _platform##_##_name = { \ + .pd = { .name = #_name, }, \ + .res_type = RPMPD_LDOA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + } + +#define DEFINE_RPMPD_VFC(_platform, _name, r_id, r_type) \ + static struct rpmpd _platform##_##_name = { \ + .pd = { .name = #_name, }, \ + .res_type = r_type, \ + .res_id = r_id, \ + .key = KEY_FLOOR_CORNER, \ + } + +#define DEFINE_RPMPD_VFC_SMPA(_platform, _name, r_id) \ + DEFINE_RPMPD_VFC(_platform, _name, r_id, RPMPD_SMPA) + +#define DEFINE_RPMPD_VFC_LDOA(_platform, _name, r_id) \ + DEFINE_RPMPD_VFC(_platform, _name, r_id, RPMPD_LDOA) + +struct rpmpd_req { + __le32 key; + __le32 nbytes; + __le32 value; +}; + +struct rpmpd { + struct generic_pm_domain pd; + struct rpmpd *peer; + const bool active_only; + unsigned long corner; + bool enabled; + const char *res_name; + const int res_type; + const int res_id; + struct qcom_smd_rpm *rpm; + __le32 key; +}; + +struct rpmpd_desc { + struct rpmpd **rpmpds; + size_t num_pds; +}; + +static DEFINE_MUTEX(rpmpd_lock); + +/* msm8996 RPM powerdomains */ +DEFINE_RPMPD_CORN_SMPA(msm8996, vddcx, vddcx_ao, 1); +DEFINE_RPMPD_CORN_SMPA(msm8996, vddmx, vddmx_ao, 2); +DEFINE_RPMPD_CORN_LDOA(msm8996, vddsscx, 26); + +DEFINE_RPMPD_VFC_SMPA(msm8996, vddcx_vfc, 1); +DEFINE_RPMPD_VFC_LDOA(msm8996, vddsscx_vfc, 26); + +static struct rpmpd *msm8996_rpmpds[] = { + [0] = &msm8996_vddcx, + [1] = &msm8996_vddcx_ao, + [2] = &msm8996_vddcx_vfc, + [3] = &msm8996_vddmx, + [4] = &msm8996_vddmx_ao, + [5] = &msm8996_vddsscx, + [6] = &msm8996_vddsscx_vfc, +}; + +static const struct rpmpd_desc msm8996_desc = { + .rpmpds = msm8996_rpmpds, + .num_pds = ARRAY_SIZE(msm8996_rpmpds), +}; + +static const struct of_device_id rpmpd_match_table[] = { + { .compatible = "qcom,rpmpd-msm8996", .data = &msm8996_desc }, + { } +}; +MODULE_DEVICE_TABLE(of, rpmpd_match_table); + +static int rpmpd_send_enable(struct rpmpd *pd, bool enable) +{ + struct rpmpd_req req = { + .key = KEY_ENABLE, + .nbytes = cpu_to_le32(sizeof(u32)), + .value = cpu_to_le32(enable), + }; + + return qcom_rpm_smd_write(pd->rpm, QCOM_RPM_ACTIVE_STATE, pd->res_type, + pd->res_id, &req, sizeof(req)); +} + +static int rpmpd_send_corner(struct rpmpd *pd, int state, unsigned int corner) +{ + struct rpmpd_req req = { + .key = pd->key, + .nbytes = cpu_to_le32(sizeof(u32)), + .value = cpu_to_le32(corner), + }; + + return qcom_rpm_smd_write(pd->rpm, state, pd->res_type, pd->res_id, + &req, sizeof(req)); +}; + +static void to_active_sleep(struct rpmpd *pd, unsigned long corner, + unsigned long *active, unsigned long *sleep) +{ + *active = corner; + + if (pd->active_only) + *sleep = 0; + else + *sleep = *active; +} + +static int rpmpd_aggregate_corner(struct rpmpd *pd) +{ + int ret; + struct rpmpd *peer = pd->peer; + unsigned long active_corner, sleep_corner; + unsigned long this_corner = 0, this_sleep_corner = 0; + unsigned long peer_corner = 0, peer_sleep_corner = 0; + + to_active_sleep(pd, pd->corner, &this_corner, &this_sleep_corner); + + if (peer && peer->enabled) + to_active_sleep(peer, peer->corner, &peer_corner, + &peer_sleep_corner); + + active_corner = max(this_corner, peer_corner); + + ret = rpmpd_send_corner(pd, QCOM_RPM_ACTIVE_STATE, active_corner); + if (ret) + return ret; + + sleep_corner = max(this_sleep_corner, peer_sleep_corner); + + return rpmpd_send_corner(pd, QCOM_RPM_SLEEP_STATE, sleep_corner); +} + +static int rpmpd_power_on(struct generic_pm_domain *domain) +{ + int ret; + struct rpmpd *pd = domain_to_rpmpd(domain); + + mutex_lock(&rpmpd_lock); + + ret = rpmpd_send_enable(pd, true); + if (ret) + goto out; + + pd->enabled = true; + + if (pd->corner) + ret = rpmpd_aggregate_corner(pd); + +out: + mutex_unlock(&rpmpd_lock); + + return ret; +} + +static int rpmpd_power_off(struct generic_pm_domain *domain) +{ + int ret; + struct rpmpd *pd = domain_to_rpmpd(domain); + + mutex_lock(&rpmpd_lock); + + ret = rpmpd_send_enable(pd, false); + if (!ret) + pd->enabled = false; + + mutex_unlock(&rpmpd_lock); + + return ret; +} + +static int rpmpd_probe(struct platform_device *pdev) +{ + int i; + size_t num; + struct genpd_onecell_data *data; + struct qcom_smd_rpm *rpm; + struct rpmpd **rpmpds; + const struct rpmpd_desc *desc; + + rpm = dev_get_drvdata(pdev->dev.parent); + if (!rpm) { + dev_err(&pdev->dev, "Unable to retrieve handle to RPM\n"); + return -ENODEV; + } + + desc = of_device_get_match_data(&pdev->dev); + if (!desc) + return -EINVAL; + + rpmpds = desc->rpmpds; + num = desc->num_pds; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains), + GFP_KERNEL); + data->num_domains = num; + + for (i = 0; i < num; i++) { + if (!rpmpds[i]) + continue; + + rpmpds[i]->rpm = rpm; + rpmpds[i]->pd.power_off = rpmpd_power_off; + rpmpds[i]->pd.power_on = rpmpd_power_on; + pm_genpd_init(&rpmpds[i]->pd, NULL, true); + + data->domains[i] = &rpmpds[i]->pd; + } + + return of_genpd_add_provider_onecell(pdev->dev.of_node, data); +} + +static int rpmpd_remove(struct platform_device *pdev) +{ + of_genpd_del_provider(pdev->dev.of_node); + return 0; +} + +static struct platform_driver rpmpd_driver = { + .driver = { + .name = "qcom-rpmpd", + .of_match_table = rpmpd_match_table, + }, + .probe = rpmpd_probe, + .remove = rpmpd_remove, +}; + +static int __init rpmpd_init(void) +{ + return platform_driver_register(&rpmpd_driver); +} +core_initcall(rpmpd_init); + +static void __exit rpmpd_exit(void) +{ + platform_driver_unregister(&rpmpd_driver); +} +module_exit(rpmpd_exit); + +MODULE_DESCRIPTION("Qualcomm RPM Power Domain Driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:qcom-rpmpd"); From patchwork Wed Jun 21 07:10:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106052 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1786217qgd; Wed, 21 Jun 2017 00:11:36 -0700 (PDT) X-Received: by 10.99.160.109 with SMTP id u45mr33000862pgn.138.1498029096739; Wed, 21 Jun 2017 00:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498029096; cv=none; d=google.com; s=arc-20160816; b=PAXbMGd4KHtVfD9daIxwyxREXnYyB6emQA+ZdOyNfLUvvh/j0/0cuvQ2hJV8Mgk9D3 8/MW4JD2Y7fc2uqXSUNKDuKqby0zHAbP3HpFMN/X3IGPpo3zbbUyACYxBzf4pjl4rcSO VsobN2FCgXUJgpCuzuTDVrwSH5kXpXuRhBIGtVVRus9GH9S6Ilezo++8W9Nl11rGnn0t 5JZpFk6RepCfmtje1f4j5dQpJE487+TzD67wOFYrKkEhCvsRsCTrAhRjogDvoJg/FNtX fCWdFQ8ALAYL7coZFRvum1Q4p0qu30fbG6B8Zw9Tp8aWII8vi8r9Qvbyg0L0AIY0Wmv3 xUcw== 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=Va45FFe3q25p0n3J83uGpcY0QWH+SpRIZBs03F9vbEM=; b=VgDv0gMVnGRcGEO9S9HlY43gGzXdvhSNPsszgW/6nyntEDEIng1T2bI/PQGfE526pC nYkGvy8ruFBftzTgwzgeZ2BhUnl3B0NP4T7+xhNTZIO/GawFSJJQ7ndb7Mj03Zqtqrts yff+fx1VOQX6NY8+edDpTpGm4CIQVtUAMOhrJ+od7Fn46AS34YxDkPYXKRX+Q4GQt0gO 9vu1Fl6kr6nuqDXzhA6VpTZhGrRgzEu3Xbz/B8H82aui9a2HZHw3t2sBPiu7EnAI8uWv 0qy5rEwj8VLJu6VXZmHNDI2eJ5rg6B8iGBF/T4UFOPjB/1Ef0iNg6yhS1P3bLWLucfOh Q2Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Ok5r/iGy; 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; 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 h66si12330513pfa.285.2017.06.21.00.11.36; Wed, 21 Jun 2017 00:11:36 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.b=Ok5r/iGy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590AbdFUHLY (ORCPT + 14 others); Wed, 21 Jun 2017 03:11:24 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:34902 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbdFUHLW (ORCPT ); Wed, 21 Jun 2017 03:11:22 -0400 Received: by mail-pg0-f44.google.com with SMTP id 132so39875696pgb.2 for ; Wed, 21 Jun 2017 00:11:22 -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=Va45FFe3q25p0n3J83uGpcY0QWH+SpRIZBs03F9vbEM=; b=Ok5r/iGyFrkZRGE7psyfuuxnnZMbptPhzhNx9Q1DPOVZHDf8KRhTCCIs3/3UQM9XR1 KGhMAq/oSJffyYnGfXAflLXRpMLL72CrsaUtnloPQi7PZFhqHN5gZD4DuUB9tQVCTd6d +r4YiEObH4pZQ0F/YZKG2UNeu7HyTItwo6ieo= 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=Va45FFe3q25p0n3J83uGpcY0QWH+SpRIZBs03F9vbEM=; b=PNbHxI925AiRIp8WvQY/RGjsIzoD9od5OIAxWCNy7TPpeN721Z22aX5A2feCHwyzMr DVpS/7UInz8zI9AO4cpMwhVhfDTLh2SvLKKll8ekd4WjvFVwxe6wejQyQEaNaurSuil3 RxfEB6Kba31PvtbQChGx9jdECTuil5mvQXRT2NiB8pqiiex1w5mALpGpc53yC4sYWW2W NplMh8PWiQ7TO61C+JQFojsy4NSwuCAyTOtVlLja53nG9SvfD8GoT6XR1D3nDq1y2j9R +9P7HYVP6iGb+ukmNP3IoikTgQXkVCGWF8/fJERPzoH6aVVM07org632t2dre7cTwwxx FsKw== X-Gm-Message-State: AKS2vOzaq5jWTXrGa0qA0MpbOSFsGd5RNGbXsQxwtoYwx/9Q8cNz7H4Q Mgd9C9j3OhNmiU5U X-Received: by 10.99.113.65 with SMTP id b1mr35582012pgn.275.1498029076567; Wed, 21 Jun 2017 00:11:16 -0700 (PDT) Received: from localhost ([122.172.59.234]) by smtp.gmail.com with ESMTPSA id m11sm31341284pfg.85.2017.06.21.00.11.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Jun 2017 00:11:16 -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: [NOT-FOR-MERGE V8 6/6] remoteproc: qcom: q6v5: Vote for proxy powerdomain performance state Date: Wed, 21 Jun 2017 12:40:53 +0530 Message-Id: <3bc9ead29ae0171d2f099c2c060645597107c990.1498026827.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Rajendra Nayak THIS IS TEST CODE, SHOULDN'T BE MERGED. This patch just demonstrates the usage of pm_genpd_update_performance_state() api in cases where users need to set performance state of a powerdomain without having to do it via the OPP framework. q6v5 remoteproc driver needs to proxy vote for performance states of multiple powerdomains (but we currently only demonstate how it can be done for one powerdomain, as there is no way to associate multiple powerdomains to a device at this time) while it loads the firmware, and then releases the vote, once the firmware is up and can vote for itself. This is not a functional patch since rpmpd driver only supports msm8996 and there is no msm8996 support in the q6v5 remoteproc driver at this point in mainline. This patch is not tested as well. NOT-signed-off-by: Rajendra Nayak NOT-signed-off-by: Viresh Kumar --- drivers/remoteproc/qcom_q6v5_pil.c | 20 +++++++++++++------- drivers/soc/qcom/rpmpd.c | 5 +++++ 2 files changed, 18 insertions(+), 7 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 8fd697a3cf8f..47c9dad98ee8 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -152,6 +153,8 @@ struct q6v5 { void *mpss_region; size_t mpss_size; + bool has_perf_state; + struct qcom_rproc_subdev smd_subdev; }; @@ -603,11 +606,12 @@ static int q6v5_start(struct rproc *rproc) struct q6v5 *qproc = (struct q6v5 *)rproc->priv; int ret; - ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, - qproc->proxy_reg_count); - if (ret) { - dev_err(qproc->dev, "failed to enable proxy supplies\n"); - return ret; + if (qproc->has_perf_state) { + ret = pm_genpd_update_performance_state(qproc->dev, INT_MAX); + if (ret) { + dev_err(qproc->dev, "Failed to set performance state.\n"); + return ret; + } } ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks, @@ -671,8 +675,8 @@ static int q6v5_start(struct rproc *rproc) q6v5_clk_disable(qproc->dev, qproc->proxy_clks, qproc->proxy_clk_count); - q6v5_regulator_disable(qproc, qproc->proxy_regs, - qproc->proxy_reg_count); + if (qproc->has_perf_state) + pm_genpd_update_performance_state(qproc->dev, 0); return 0; @@ -1043,6 +1047,8 @@ static int q6v5_probe(struct platform_device *pdev) if (ret) goto free_rproc; + qproc->has_perf_state = pm_genpd_has_performance_state(&qproc->dev); + return 0; free_rproc: diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index 7ef81429c5c5..b1af1442ebe9 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -145,6 +145,7 @@ enum msm8996_devices { UFS, PCIE, USB3, + Q6V5_PIL, }; static struct rpmpd_freq_map msm8996_rpmpd_freq_map[] = { @@ -171,6 +172,10 @@ static struct rpmpd_freq_map msm8996_rpmpd_freq_map[] = { .freq[LOW] = 120000000, .freq[NOMINAL] = 150000000, }, + [Q6V5_PIL] = { + .pd = &msm8996_vddcx, + .freq[HIGH] = INT_MAX, + }, }; static const struct of_device_id rpmpd_performance_table[] = {