From patchwork Sun Jan 6 08:09:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 154832 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2339979ljp; Sun, 6 Jan 2019 00:10:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xa8orS4m0hO9qZi07InemG0Zq6rd3dep2IsMLal53LAHJ2CYMXxgHVJywHlikxrN0mm3JF X-Received: by 2002:a62:e30d:: with SMTP id g13mr58237915pfh.151.1546762257240; Sun, 06 Jan 2019 00:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546762257; cv=none; d=google.com; s=arc-20160816; b=Yb0Z/4jPwK97bYhe0MFjjdhLcUd1H+6u6csbLQb125Pdqk8ALp9psbvCvGXY/qsLGA NbrI21dofYxjwEYnIHXPaTGdu1ZEene+hWWLlO6ITcb0puCO/vXRkI3KzLIfKYmBkas2 OAF2pQ2VPRveqdm3cRCWsAs62rOauY+bkn2n++hKuKPFHWQH8owW4yArRSYM2ZxECIdQ XelNI6WIwSyZTWH6UiDMmxr0qINxKqo8w01ic7VejzVe6HELSDaKoB3kTqdyShJRJcfu 2Z/LFnCSQHmmpkGHFlbz1Hhly4C/HtLR1LvMYUlsLNoCyyWl2LqonhYhmd0lTqkFvA2z LZOA== 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:dkim-signature; bh=U2mWbfqgvCD++AwZWAP5IK4c0zurpr6P40PRh9Mgpmc=; b=LRM7mBf5o8X5B4V4Kt1oS/0Yj6OsYOwYFUh79CrT9oSNrc6rPzNCHj54K+mtFWeRic P0vtO9/MzncPSMqKj4iPlLQMQFZD3/Q3jnhNSGkB4qUZnpzN38OnK0QEooRohEe6FUkB MRKhXhYW5Ruz2kiTHwDFdNDVvv87utrGi5u0tYuX9Nk4fl0zWd+maU+P5INMq6S8HIYQ hG4Roa96D4u1oTV0MWVBfsBxH6L6HyiJFkJRHk6Er6wwbI9MkBGy+GV2BoCSuy9+ysYF x5/5nCCDGaMwkszsi1LkLwNiMUSQ/NC4Uit1CyT0shwdeUcWqzjRVFu9Q1ROA+ta7q5+ Z3DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dvms9i2l; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 f13si41528737pln.368.2019.01.06.00.10.56; Sun, 06 Jan 2019 00:10:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=dvms9i2l; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726474AbfAFIKV (ORCPT + 15 others); Sun, 6 Jan 2019 03:10:21 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36837 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfAFIKV (ORCPT ); Sun, 6 Jan 2019 03:10:21 -0500 Received: by mail-pl1-f196.google.com with SMTP id g9so19389302plo.3 for ; Sun, 06 Jan 2019 00:10:20 -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; bh=U2mWbfqgvCD++AwZWAP5IK4c0zurpr6P40PRh9Mgpmc=; b=dvms9i2lcY8Kt6+m+QsTkPLi9bJwcfnw08Rxuw2SkFaZ/IMi6JZf+ckzcocbaJjuJN h7G+UommVYw4WKmgYNzaEhASynaSZeyrSd2KaZr4wlEHiP+dErLawgmdNkZP8o/ypxlL YP753bq8cQVI6kVK8dj/n4+OwFg+y6WqbwfaQ= 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; bh=U2mWbfqgvCD++AwZWAP5IK4c0zurpr6P40PRh9Mgpmc=; b=B6t81YU+v89NVisICia3WczMdIyEmofU42Pbxa390zNjzn7VufvX0feMWZXuX7Ry5B GBGnZz6VosfZGjxL4H83dgpY5lvwW+orTj/gXSFw47WIhiE9T2CBP2jhPGJlS/x3IqCl 3CYSoIHz51JWW3Vz6ijIvfsPBcz82/HoLZNeDRUAeLRchrGVVdli341spL8xLdAXtp5g zamzPeDaTbBti3XBEPGk0KYiQ+MXisGJRAScHDgAEuHoGAC01J52fPQOmNs095c/1hRT tqhhB3YSW5angQwWn3njyG3yCtrktM0Y6CET4J7fdUbU0Pe4IJGDNJ0fi+GSp4+/7SOJ 56vw== X-Gm-Message-State: AJcUukeFqCN98nmhU9tni602R+UB0eJ1Uam50jk56LMQke5Wcnb1uLwV iig2cFokmiSdnDX33S2zNQzYZg== X-Received: by 2002:a17:902:4:: with SMTP id 4mr57329602pla.20.1546762220470; Sun, 06 Jan 2019 00:10:20 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id v190sm90763364pfv.26.2019.01.06.00.10.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Jan 2019 00:10:19 -0800 (PST) From: Bjorn Andersson To: Andy Gross , David Brown , Rob Herring , Mark Rutland Cc: Russell King , Ulf Hansson , Arun Kumar Neelakantam , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] soc: qcom: Add AOSS QMP genpd provider Date: Sun, 6 Jan 2019 00:09:11 -0800 Message-Id: <20190106080915.4493-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190106080915.4493-1-bjorn.andersson@linaro.org> References: <20190106080915.4493-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The AOSS QMP genpd provider implements control over power-related resources related to low-power state associated with the remoteprocs in the system as well as control over a set of clocks related to debug hardware in the SoC. Signed-off-by: Bjorn Andersson --- Changes since v1: - Drop compatible, as the QMP DT node is flattened - Correct size of send drivers/soc/qcom/Kconfig | 9 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/aoss-qmp-pd.c | 135 +++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 drivers/soc/qcom/aoss-qmp-pd.c -- 2.18.0 diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index dda19471057f..d81256ef5055 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -12,6 +12,15 @@ config QCOM_AOSS_QMP micro-controller in the AOSS, using QMP, to control certain resource that are not exposed through RPMh. +config QCOM_AOSS_QMP_PD + tristate "Qualcomm AOSS Messaging Power Domain driver" + depends on QCOM_AOSS_QMP + select PM_GENERIC_DOMAINS + help + This driver provides the means of controlling the AOSSs handling of + low-power state for resources related to the remoteproc subsystems as + well as controlling the debug clocks. + config QCOM_COMMAND_DB bool "Qualcomm Command DB" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index d0d7fdc94d9a..ebfa414a5b77 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS_rpmh-rsc.o := -I$(src) obj-$(CONFIG_QCOM_AOSS_QMP) += aoss-qmp.o +obj-$(CONFIG_QCOM_AOSS_QMP_PD) += aoss-qmp-pd.o obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o diff --git a/drivers/soc/qcom/aoss-qmp-pd.c b/drivers/soc/qcom/aoss-qmp-pd.c new file mode 100644 index 000000000000..62b8fcb9d09e --- /dev/null +++ b/drivers/soc/qcom/aoss-qmp-pd.c @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018, Linaro Ltd + */ +#include +#include +#include +#include +#include + +struct qmp_pd { + struct qmp *qmp; + + struct generic_pm_domain pd; + + const char *name; +}; + +#define to_qmp_pd_resource(res) container_of(res, struct qmp_pd, pd) + +struct qmp_pd_resource { + const char *name; + int (*on)(struct generic_pm_domain *domain); + int (*off)(struct generic_pm_domain *domain); +}; + +static int qmp_pd_clock_toggle(struct qmp_pd *res, bool enable) +{ + char buf[96]; + + snprintf(buf, sizeof(buf), "{class: clock, res: %s, val: %d}", + res->name, !!enable); + return qmp_send(res->qmp, buf, sizeof(buf)); +} + +static int qmp_pd_clock_on(struct generic_pm_domain *domain) +{ + return qmp_pd_clock_toggle(to_qmp_pd_resource(domain), true); +} + +static int qmp_pd_clock_off(struct generic_pm_domain *domain) +{ + return qmp_pd_clock_toggle(to_qmp_pd_resource(domain), false); +} + +static int qmp_pd_image_toggle(struct qmp_pd *res, bool enable) +{ + char buf[96]; + + snprintf(buf, sizeof(buf), + "{class: image, res: load_state, name: %s, val: %s}", + res->name, enable ? "on" : "off"); + return qmp_send(res->qmp, buf, sizeof(buf)); +} + +static int qmp_pd_image_on(struct generic_pm_domain *domain) +{ + return qmp_pd_image_toggle(to_qmp_pd_resource(domain), true); +} + +static int qmp_pd_image_off(struct generic_pm_domain *domain) +{ + return qmp_pd_image_toggle(to_qmp_pd_resource(domain), false); +} + +static const struct qmp_pd_resource sdm845_resources[] = { + [AOSS_QMP_QDSS_CLK] = { "qdss", qmp_pd_clock_on, qmp_pd_clock_off }, + [AOSS_QMP_LS_CDSP] = { "cdsp", qmp_pd_image_on, qmp_pd_image_off }, + [AOSS_QMP_LS_LPASS] = { "adsp", qmp_pd_image_on, qmp_pd_image_off }, + [AOSS_QMP_LS_MODEM] = { "modem", qmp_pd_image_on, qmp_pd_image_off }, + [AOSS_QMP_LS_SLPI] = { "slpi", qmp_pd_image_on, qmp_pd_image_off }, + [AOSS_QMP_LS_SPSS] = { "spss", qmp_pd_image_on, qmp_pd_image_off }, + [AOSS_QMP_LS_VENUS] = { "venus", qmp_pd_image_on, qmp_pd_image_off }, +}; + +static int qmp_pd_probe(struct platform_device *pdev) +{ + struct genpd_onecell_data *data; + struct device *parent = pdev->dev.parent; + struct qmp_pd *res; + struct qmp *qmp; + size_t num = ARRAY_SIZE(sdm845_resources); + int i; + + qmp = dev_get_drvdata(pdev->dev.parent); + if (!qmp) + return -EINVAL; + + res = devm_kcalloc(&pdev->dev, num, sizeof(*res), GFP_KERNEL); + if (!res) + return -ENOMEM; + + 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); + + for (i = 0; i < num; i++) { + pm_genpd_init(&res[i].pd, NULL, true); + res[i].qmp = qmp; + res[i].name = sdm845_resources[i].name; + + res[i].pd.name = sdm845_resources[i].name; + res[i].pd.power_on = sdm845_resources[i].on; + res[i].pd.power_off = sdm845_resources[i].off; + + data->domains[data->num_domains++] = &res[i].pd; + } + + return of_genpd_add_provider_onecell(parent->of_node, data); +} + +static int qmp_pd_remove(struct platform_device *pdev) +{ + struct device *parent = pdev->dev.parent; + + of_genpd_del_provider(parent->of_node); + + return 0; +} + +static struct platform_driver qmp_pd_driver = { + .driver = { + .name = "aoss_qmp_pd", + }, + .probe = qmp_pd_probe, + .remove = qmp_pd_remove, +}; +module_platform_driver(qmp_pd_driver); + +MODULE_ALIAS("platform:aoss_qmp_pd"); +MODULE_DESCRIPTION("Qualcomm AOSS QMP load-state driver"); +MODULE_LICENSE("GPL v2"); From patchwork Sun Jan 6 08:09:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 154827 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2339633ljp; Sun, 6 Jan 2019 00:10:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN5yvCoT16lcyhbj3JDJWh2gxm8PQX6dTSAR0fkZ0ZYJzEumuws2ZMUb3CX4dYgbrUZA6PSx X-Received: by 2002:aa7:84d3:: with SMTP id x19mr58357592pfn.220.1546762225997; Sun, 06 Jan 2019 00:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546762225; cv=none; d=google.com; s=arc-20160816; b=nD+Yi+NuYwTDrSKY/3ZztLY6zpG35TR9MWTjNCShlanu/+J3KGR5ZHgYCVQ4kTJ3RJ wPdn8z4fiGrJJFekg+yzs6ymyikCh2tkNzMGllZCidZclPI1YGGUEGl0XCYe/6L27xnQ PX9z4Qyx05BOchl0m3JfYtHC5mfuvdLcftTfLqG3rsP/mHmLmVe3l5rC4sQ49HbaBzns BvjXd9B7I+YyX1yZQ7RpfQjTzPwSkNcKqOyMFnWLMl3kb55VZG/NcijdZqlK+ubd1oWW jBBohCW2JM4rOWHtXBGptUUFXbqANkW2zhaUQAdRE+UZhra8PRGlFeAeOCMRDchLLihy RmwA== 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:dkim-signature; bh=8nMYeQKIt4Dh3nFqXbC/17ExZVSNvJ/SwmQaru91kF4=; b=XUEacJbYT9bgr94ML+Q9IFEn20QCVQUBBI2eDSF4vjeAvBCv7qo3l17l6A/tv6wj8T 3VzUMIqesiABrJYw9UxvHAHYh8iZW/tfIm0JSyTFQAMUNUJ3qWT8IGc9hIGnGGSdhk8P SNqW18e/ghcgMAjJU1DJfs0taFFiaykH1/qJRxBHdZRKVYzLBJT6M0x66esOVh9bstkC qNzaUPSA2GEGp5tPSRZGfluJARpqQBkxqMY2s1ldMsq5RGv1USLnqnUuN6cbcmtZ8NC0 a3ivSUR7xiItzk0XyWzLMsfPjWsBd7npsijAurMiTGEy5xNDLXes2lTAFyh8ikDE2d6H NtVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nx1Q3727; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 n3si17132972plk.328.2019.01.06.00.10.25; Sun, 06 Jan 2019 00:10:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=Nx1Q3727; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726495AbfAFIKX (ORCPT + 15 others); Sun, 6 Jan 2019 03:10:23 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39550 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbfAFIKX (ORCPT ); Sun, 6 Jan 2019 03:10:23 -0500 Received: by mail-pl1-f193.google.com with SMTP id 101so19394888pld.6 for ; Sun, 06 Jan 2019 00:10:22 -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; bh=8nMYeQKIt4Dh3nFqXbC/17ExZVSNvJ/SwmQaru91kF4=; b=Nx1Q3727XfLnhlPBImy+XV/d6pA+sDqBG+veFVjCXOVI2iQZFgmyIOIS0o8kxXitxU fNss2ThOjnKmEQm2GYoqpvTe7N689pbTvAmRDnnM+1Ptye0hMqfbfg6wk1+p2Mbpt6rp FcqjJA5G8mF15WGHU8hoTgybFsAq2THSaoLNw= 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; bh=8nMYeQKIt4Dh3nFqXbC/17ExZVSNvJ/SwmQaru91kF4=; b=AHPYHzulPBGpoB58xz+ZghJPap2BdO5Vq1v1yHSmF0T2rE3axA4ob7RJEc+CAs/pNC oceIHcl7lKQ7O0iEQjw8Qk0+2d9Y9KIRmKGVXP6uIJmaJkdQn1NRLl8bhmwrxhTVXF1E ljYXb4l+ZPcoTAdeVH+x6rrpZwYDJ4N5Xmc9tbGzp+WmKN6HpJ4thuAvRA5gcMe2/4xI 06l0j3msQLTEIrTALnIdEz7SwVLrLEaz09B3dPrOZzViIgHIb2oK+ZpBx0/3q4n4Mku3 f4IE0S+BDWMUh07Dn5OCfkOwbAW7uQiELHDgnJjF4Evy6T/rIDC3VguPPqo0rXzJFpCo RTPA== X-Gm-Message-State: AJcUukf5tbcZtvJ77/LvpItED6ElUzbobsNLAisKgZwhIv8hKlGpW0zK nyA+vwT2bP/QDuheS1V1FwGrDQ== X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr56153855pla.216.1546762221656; Sun, 06 Jan 2019 00:10:21 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id v190sm90763364pfv.26.2019.01.06.00.10.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Jan 2019 00:10:21 -0800 (PST) From: Bjorn Andersson To: Andy Gross , David Brown , Rob Herring , Mark Rutland Cc: Russell King , Ulf Hansson , Arun Kumar Neelakantam , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] remoteproc: q6v5-mss: Vote for rpmh power domains Date: Sun, 6 Jan 2019 00:09:12 -0800 Message-Id: <20190106080915.4493-5-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190106080915.4493-1-bjorn.andersson@linaro.org> References: <20190106080915.4493-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rajendra Nayak With rpmh ARC resources being modelled as power domains with performance state, we need to proxy vote on these for SDM845. Add support to vote on multiple of them, now that genpd supports associating mutliple power domains to a device. Signed-off-by: Rajendra Nayak [bjorn: Drop device link, improve error handling, name things "proxy"] Signed-off-by: Bjorn Andersson --- This is v3 of this patch, but updated to cover "loadstate". v2 can be found here: https://lore.kernel.org/lkml/20180904071046.8152-1-rnayak@codeaurora.org/ Changes since v2: - Drop device links, as we can do active and proxy votes using device links - Improved error handling, by unrolling some votes on failure - Rename things proxy, to follow naming of "proxy" and "active" drivers/remoteproc/qcom_q6v5_mss.c | 115 ++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 4 deletions(-) -- 2.18.0 diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 01be7314e176..62cf16ddb7af 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -131,6 +133,7 @@ struct rproc_hexagon_res { char **proxy_clk_names; char **reset_clk_names; char **active_clk_names; + char **proxy_pd_names; int version; bool need_mem_protection; bool has_alt_reset; @@ -156,9 +159,11 @@ struct q6v5 { struct clk *active_clks[8]; struct clk *reset_clks[4]; struct clk *proxy_clks[4]; + struct device *proxy_pds[3]; int active_clk_count; int reset_clk_count; int proxy_clk_count; + int proxy_pd_count; struct reg_info active_regs[1]; struct reg_info proxy_regs[3]; @@ -321,6 +326,41 @@ static void q6v5_clk_disable(struct device *dev, clk_disable_unprepare(clks[i]); } +static int q6v5_pds_enable(struct q6v5 *qproc, struct device **pds, + size_t pd_count) +{ + int ret; + int i; + + for (i = 0; i < pd_count; i++) { + dev_pm_genpd_set_performance_state(pds[i], INT_MAX); + ret = pm_runtime_get_sync(pds[i]); + if (ret < 0) + goto unroll_pd_votes; + } + + return 0; + +unroll_pd_votes: + for (i--; i >= 0; i--) { + dev_pm_genpd_set_performance_state(pds[i], 0); + pm_runtime_put(pds[i]); + } + + return ret; +}; + +static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds, + size_t pd_count) +{ + int i; + + for (i = 0; i < pd_count; i++) { + dev_pm_genpd_set_performance_state(pds[i], 0); + pm_runtime_put(pds[i]); + } +} + static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm, bool remote_owner, phys_addr_t addr, size_t size) @@ -690,11 +730,17 @@ static int q6v5_mba_load(struct q6v5 *qproc) qcom_q6v5_prepare(&qproc->q6v5); + ret = q6v5_pds_enable(qproc, qproc->proxy_pds, qproc->proxy_pd_count); + if (ret < 0) { + dev_err(qproc->dev, "failed to enable proxy power domains\n"); + goto disable_irqs; + } + ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); if (ret) { dev_err(qproc->dev, "failed to enable proxy supplies\n"); - goto disable_irqs; + goto disable_proxy_pds; } ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks, @@ -791,6 +837,8 @@ static int q6v5_mba_load(struct q6v5 *qproc) disable_proxy_reg: q6v5_regulator_disable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); +disable_proxy_pds: + q6v5_pds_disable(qproc, qproc->proxy_pds, qproc->proxy_pd_count); disable_irqs: qcom_q6v5_unprepare(&qproc->q6v5); @@ -1121,6 +1169,7 @@ static void qcom_msa_handover(struct qcom_q6v5 *q6v5) qproc->proxy_clk_count); q6v5_regulator_disable(qproc, qproc->proxy_regs, qproc->proxy_reg_count); + q6v5_pds_disable(qproc, qproc->proxy_pds, qproc->proxy_pd_count); } static int q6v5_init_mem(struct q6v5 *qproc, struct platform_device *pdev) @@ -1181,6 +1230,45 @@ static int q6v5_init_clocks(struct device *dev, struct clk **clks, return i; } +static int q6v5_pds_attach(struct device *dev, struct device **devs, + char **pd_names) +{ + size_t num_pds = 0; + int ret; + int i; + + if (!pd_names) + return 0; + + while (pd_names[num_pds]) + num_pds++; + + for (i = 0; i < num_pds; i++) { + devs[i] = dev_pm_domain_attach_by_name(dev, pd_names[i]); + if (IS_ERR(devs[i])) { + ret = PTR_ERR(devs[i]); + goto unroll_attach; + } + } + + return num_pds; + +unroll_attach: + for (i--; i >= 0; i--) + dev_pm_domain_detach(devs[i], false); + + return ret; +}; + +static void q6v5_pds_detach(struct q6v5 *qproc, struct device **pds, + size_t pd_count) +{ + int i; + + for (i = 0; i < pd_count; i++) + dev_pm_domain_detach(pds[i], false); +} + static int q6v5_init_reset(struct q6v5 *qproc) { qproc->mss_restart = devm_reset_control_get_exclusive(qproc->dev, @@ -1322,10 +1410,18 @@ static int q6v5_probe(struct platform_device *pdev) } qproc->active_reg_count = ret; + ret = q6v5_pds_attach(&pdev->dev, qproc->proxy_pds, + desc->proxy_pd_names); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to init power domains\n"); + goto free_rproc; + } + qproc->proxy_pd_count = ret; + qproc->has_alt_reset = desc->has_alt_reset; ret = q6v5_init_reset(qproc); if (ret) - goto free_rproc; + goto detach_proxy_pds; qproc->version = desc->version; qproc->need_mem_protection = desc->need_mem_protection; @@ -1333,7 +1429,7 @@ static int q6v5_probe(struct platform_device *pdev) ret = qcom_q6v5_init(&qproc->q6v5, pdev, rproc, MPSS_CRASH_REASON_SMEM, qcom_msa_handover); if (ret) - goto free_rproc; + goto detach_proxy_pds; qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS); qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS); @@ -1344,10 +1440,12 @@ static int q6v5_probe(struct platform_device *pdev) ret = rproc_add(rproc); if (ret) - goto free_rproc; + goto detach_proxy_pds; return 0; +detach_proxy_pds: + q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); free_rproc: rproc_free(rproc); @@ -1364,6 +1462,9 @@ static int q6v5_remove(struct platform_device *pdev) qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev); qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); + + q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); + rproc_free(qproc->rproc); return 0; @@ -1388,6 +1489,12 @@ static const struct rproc_hexagon_res sdm845_mss = { "mnoc_axi", NULL }, + .proxy_pd_names = (char*[]){ + "cx", + "mx", + "mss", + NULL + }, .need_mem_protection = true, .has_alt_reset = true, .version = MSS_SDM845, From patchwork Sun Jan 6 08:09:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 154831 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2339829ljp; Sun, 6 Jan 2019 00:10:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/X6CyW/EiODeHoCQmWA0vqqsf7tnnJU4Rx8/BnmpI7ZpQQ8jlZo7HBQ++7xkTffkVY1ZTcG X-Received: by 2002:a62:1c86:: with SMTP id c128mr61124383pfc.54.1546762243568; Sun, 06 Jan 2019 00:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546762243; cv=none; d=google.com; s=arc-20160816; b=wIy57nC3wJyBXFUk8G1pK3QByxj570+IOR5TUNbi/KQ5SCi5BVXKzTdiMzvFszBdYc yu9/NUcPjHyndw/k39nv8/rjfJ990BlBLa/rlELIM8cyBNpGKOa7Lhzm4eM15EpLmOcn mn4ZD10Ximf2zPMbVSIMpDv9tMZ51hTvbQr5YYJ6L8OUWLHswvd166WzB0nizs01njed dP7fVlN3PyjS3434eHXXH0SKN9r1Yufx25UuTE54ao6AH254riLyj3Uy7ys0k7AP88oX qQhB7ItMxAXF3OgzF9xbLlb9Z34fxpfUEbYCB74Als+iDTPkR3EHrSKPJjQVSULoBz4j T7mg== 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:dkim-signature; bh=Eykwn78UBt1QHUenCjEDKqDsuRhugMZbWizZ48+FyMg=; b=SCn60XYJXhOi4dSBzibYkNAEd3hPRrsv2EwFu3+Ast8hF3z6Zqw5VqmGALGIG8Tsh9 Aasg/Zw0E8oIpszOQOyREfxyY8GO1MrTT/Y17XvaPKR8FR3EyUckWJlz+p0W4yn/nHQz Zpm/JVp9FDd2IYn2XhcJ8CUwz4uioOVORrbn9dcheJ8+oPGySMOMHuYrQHY9Q9orblfa q8N/oT70yChRgFL2B8FShDEEy5511ljzQuO8qXEpYh+nRKDBDzUgpMIv7QIYb1f0Eikt Gx4Tna/LtvFNiADXwTj/CvPCKM9khlEg/D/v7AiB8DxaqpY1tQ2UosgFeaEK65lBwB3w 6wLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=auAGKjun; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 n125si5946286pga.179.2019.01.06.00.10.43; Sun, 06 Jan 2019 00:10:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=auAGKjun; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1726504AbfAFIKY (ORCPT + 15 others); Sun, 6 Jan 2019 03:10:24 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36838 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726491AbfAFIKY (ORCPT ); Sun, 6 Jan 2019 03:10:24 -0500 Received: by mail-pl1-f193.google.com with SMTP id g9so19389330plo.3 for ; Sun, 06 Jan 2019 00:10:23 -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; bh=Eykwn78UBt1QHUenCjEDKqDsuRhugMZbWizZ48+FyMg=; b=auAGKjun5gdTF6rkH5KplLjZ4gxXOfdr+8dFHbA+ENRXJgU/jDZQ0vFciuMaJoAijs Z2aW4MHZyFjkpt4NDM5cux8Ckjn3vME/0dLTZaAcgKComYyuxOLN9V4tByI1eN3KZX6f up+vc2EPqBzRrEBhZzh/i9fUYvJp0QESbc2Tw= 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; bh=Eykwn78UBt1QHUenCjEDKqDsuRhugMZbWizZ48+FyMg=; b=RXpfXOvsbkzLJFKwOkRVqtpeJiiteXsDolzxU9ZbXeBvWcLmC9Ihfb7JId6yHY0C4L J79YRktYBrN5XgO2wX4XbRhDbZpW+aKduscsIt2QN+IGJLsy9vCUJxZfLRHZ9lJKv8qC 8DWtBWc8Tn94u6J6po/0Fzydb72VZCs7aAbwWd3YNwMQmf0n2bT1FP8qj/WgAgB2EZ1F HSH90BPvlxldfdDak1quXz6f7qBEatTvvPggcggmCT+9qT0LA5ulpe3wi2IFV5s4Lyn0 TckAhHjFniEJKUnKax2X2qtxu0LDY9TV3h12W3YdyWfWX6UH68QofZHANcNVdPOKgSGi jbHQ== X-Gm-Message-State: AJcUukfvR+H9tKuH88PPEKIp6O2nxE76TtNhoFG1B3MGusPYwo/It4Pp IoFb2HdxVS/CpttG07P4jwJjnA== X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr55746557plp.247.1546762222820; Sun, 06 Jan 2019 00:10:22 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id v190sm90763364pfv.26.2019.01.06.00.10.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Jan 2019 00:10:22 -0800 (PST) From: Bjorn Andersson To: Andy Gross , David Brown , Rob Herring , Mark Rutland Cc: Russell King , Ulf Hansson , Arun Kumar Neelakantam , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] remoteproc: q6v5-mss: Active powerdomain for SDM845 Date: Sun, 6 Jan 2019 00:09:13 -0800 Message-Id: <20190106080915.4493-6-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190106080915.4493-1-bjorn.andersson@linaro.org> References: <20190106080915.4493-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The SDM845 MSS needs the load_state powerdomain voted for during the duration of the MSS being powered on, to let the AOSS know that it may not perform certain power save measures. So vote for this. Signed-off-by: Bjorn Andersson --- Changes since v1: - New patch drivers/remoteproc/qcom_q6v5_mss.c | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) -- 2.18.0 diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 62cf16ddb7af..7f86d9c551c4 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -133,6 +133,7 @@ struct rproc_hexagon_res { char **proxy_clk_names; char **reset_clk_names; char **active_clk_names; + char **active_pd_names; char **proxy_pd_names; int version; bool need_mem_protection; @@ -159,10 +160,12 @@ struct q6v5 { struct clk *active_clks[8]; struct clk *reset_clks[4]; struct clk *proxy_clks[4]; + struct device *active_pds[1]; struct device *proxy_pds[3]; int active_clk_count; int reset_clk_count; int proxy_clk_count; + int active_pd_count; int proxy_pd_count; struct reg_info active_regs[1]; @@ -730,10 +733,16 @@ static int q6v5_mba_load(struct q6v5 *qproc) qcom_q6v5_prepare(&qproc->q6v5); + ret = q6v5_pds_enable(qproc, qproc->active_pds, qproc->active_pd_count); + if (ret < 0) { + dev_err(qproc->dev, "failed to enable active power domains\n"); + goto disable_irqs; + } + ret = q6v5_pds_enable(qproc, qproc->proxy_pds, qproc->proxy_pd_count); if (ret < 0) { dev_err(qproc->dev, "failed to enable proxy power domains\n"); - goto disable_irqs; + goto disable_active_pds; } ret = q6v5_regulator_enable(qproc, qproc->proxy_regs, @@ -839,6 +848,8 @@ static int q6v5_mba_load(struct q6v5 *qproc) qproc->proxy_reg_count); disable_proxy_pds: q6v5_pds_disable(qproc, qproc->proxy_pds, qproc->proxy_pd_count); +disable_active_pds: + q6v5_pds_disable(qproc, qproc->active_pds, qproc->active_pd_count); disable_irqs: qcom_q6v5_unprepare(&qproc->q6v5); @@ -878,6 +889,7 @@ static void q6v5_mba_reclaim(struct q6v5 *qproc) qproc->active_clk_count); q6v5_regulator_disable(qproc, qproc->active_regs, qproc->active_reg_count); + q6v5_pds_disable(qproc, qproc->active_pds, qproc->active_pd_count); /* In case of failure or coredump scenario where reclaiming MBA memory * could not happen reclaim it here. @@ -1410,11 +1422,19 @@ static int q6v5_probe(struct platform_device *pdev) } qproc->active_reg_count = ret; + ret = q6v5_pds_attach(&pdev->dev, qproc->active_pds, + desc->active_pd_names); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to attach active power domains\n"); + goto free_rproc; + } + qproc->active_pd_count = ret; + ret = q6v5_pds_attach(&pdev->dev, qproc->proxy_pds, desc->proxy_pd_names); if (ret < 0) { dev_err(&pdev->dev, "Failed to init power domains\n"); - goto free_rproc; + goto detach_active_pds; } qproc->proxy_pd_count = ret; @@ -1446,6 +1466,8 @@ static int q6v5_probe(struct platform_device *pdev) detach_proxy_pds: q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); +detach_active_pds: + q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); free_rproc: rproc_free(rproc); @@ -1463,6 +1485,7 @@ static int q6v5_remove(struct platform_device *pdev) qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev); qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev); + q6v5_pds_detach(qproc, qproc->active_pds, qproc->active_pd_count); q6v5_pds_detach(qproc, qproc->proxy_pds, qproc->proxy_pd_count); rproc_free(qproc->rproc); @@ -1489,6 +1512,10 @@ static const struct rproc_hexagon_res sdm845_mss = { "mnoc_axi", NULL }, + .active_pd_names = (char*[]){ + "load_state", + NULL + }, .proxy_pd_names = (char*[]){ "cx", "mx",