Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3793763imu; Mon, 12 Nov 2018 00:04:09 -0800 (PST) X-Google-Smtp-Source: AJdET5fuATsJIa0ozhTbLxEM99KuEZ25mqTvcP2MofDjYPm/ztXN1KXoqyHjM3LfIjm883nCyPrm X-Received: by 2002:a63:554b:: with SMTP id f11mr7009121pgm.37.1542009849075; Mon, 12 Nov 2018 00:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542009849; cv=none; d=google.com; s=arc-20160816; b=YQedjiDPUExveX0U0CpqRoxQP1H6sWC8k6Fwk+QmPgVwwoqrf5Mu7AtEb0ADdKAJjS /leA0D3RcDU+EG+gIXgiKW76J+ddorHCesqLp4IVnJfrJPXO5+GoAtG+so7JVzk/4W9U Px9zt4UhayjpFd9cNoqxAIcvvi2paqo8mNqaPX8jD58bNZAUNUQ84bJavdgD286FGq0i VUlCKFqVkZWl9+n/RNhTgKeFF2/Bu82b6dSWrDCjJnVS1HAvZhaqizpsHxoWeDcjCeHC ks6l3Agzvaqh4XCGP53UzlRf2KO8q64ryUHUXbQVCNQc2/dUy5/2gyqAWXXMBqKQqbWk TZCw== 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=wvT2MV0cpdZ3I4k2m3tel+zZFqPKLYuEhJfBEnHZVEo=; b=qn8uLLkH04ehfSIzCRfIoTrkww/6hXZyOP9QDnfGgRjUeV2DrPQaKOAxsWd9uq1PfD fh8J2gU29iHsPz+IFrxHLH6v20TD5y0cDtANFcKeM4AXHcrTa6UdxhOM5gYXJ9dcpKc+ 5JoSWb81YOBhIj45DEKHFqY/1xOlcGRoXHMf8U6N5QKdDGEPHmmgAPvE/767UWySQ5gE E0zKMpeCvCCMsaXWaxx5isi6ERuklX2utkT0APn1otwVWYgh6fbKPG0o/bW1CS21myaq reK6wrB0A+NkN4B4tZUo7CR87awZwQLDT/+ezL1KoMgU/or5kqNdcsegRl7q1qyU6c8y lYCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PcIDnS4Y; 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 i1si16655021pgr.569.2018.11.12.00.03.53; Mon, 12 Nov 2018 00:04:09 -0800 (PST) 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=PcIDnS4Y; 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 S1729179AbeKLRyP (ORCPT + 99 others); Mon, 12 Nov 2018 12:54:15 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39238 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729158AbeKLRyO (ORCPT ); Mon, 12 Nov 2018 12:54:14 -0500 Received: by mail-pf1-f196.google.com with SMTP id n11-v6so3926973pfb.6 for ; Mon, 12 Nov 2018 00:02:10 -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=wvT2MV0cpdZ3I4k2m3tel+zZFqPKLYuEhJfBEnHZVEo=; b=PcIDnS4YOg2mmEqT5vkPQNSDhtzUaLrdG5VD9MHpQXC+J1fCSwTPr24UTdcMZI28GP z3jjdZLGP6dECqP7n5xUKx3TzzjD5jXVVIvDkFBjbcQbAX98BhpoGCvygQYbrnmWqZXQ iCBrAdmpUoYLqnJ1ZFFvSBk/Q7BKut22JGWgA= 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=wvT2MV0cpdZ3I4k2m3tel+zZFqPKLYuEhJfBEnHZVEo=; b=RBP2kJ6QDQoyupdH+nqXj2Oz1aw7sq4g/a84OkYY6CTrcHh+fIkBYHcVX3WcG297W5 IgVw0XCrxeSFxecNuZ9nMi/cznfUEJn/dIx3lnRdzcddOEnldZERb8QYDAHf7wfHcjAq 53B+UR12K7ELjECUKZyJA5MEGDSmUYH4GDP/ukhZ9e/iIQEWhLdKKy9gqe0HX+nxQd+m 92g+Jd+hWQ4TgggJXHt6OfLiNypFXxZLkmvloVf6MYqF56FyYwMMPyIHAqPcXrt5RVV+ sssxFB6/IpD33iIE4U4xCi5R7UEDiQM72MT0ccS6NGVr6grJ1rDh0Vjap/gxQmQhZPZJ kgbA== X-Gm-Message-State: AGRZ1gL7QvfmjyR82Qr/Frcn8rdwQQLdjmflTy2bPMyJPp2V5Me3fH4N ghwmylpUeY+P2W+S/aYGSJ07sA== X-Received: by 2002:a65:434d:: with SMTP id k13mr3800506pgq.269.1542009730225; Mon, 12 Nov 2018 00:02:10 -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 134sm13590085pgb.78.2018.11.12.00.02.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 00:02:09 -0800 (PST) From: Bjorn Andersson To: Andy Gross , David Brown Cc: Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] soc: qcom: Add AOSS QMP genpd provider Date: Mon, 12 Nov 2018 00:05:57 -0800 Message-Id: <20181112080557.22698-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181112080557.22698-1-bjorn.andersson@linaro.org> References: <20181112080557.22698-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- drivers/soc/qcom/Kconfig | 8 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/aoss-qmp-pd.c | 135 +++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 drivers/soc/qcom/aoss-qmp-pd.c diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index ba08fc00d7f5..e1eda3d59748 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -10,6 +10,14 @@ 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 + 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..467d0db4abfa --- /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 +#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]; + size_t n; + + n = snprintf(buf, sizeof(buf), "{class: clock, res: %s, val: %d}", + res->name, !!enable); + return qmp_send(res->qmp, buf, n); +} + +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]; + size_t n; + + n = 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 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(pdev->dev.of_node, data); +} + +static const struct of_device_id qmp_pd_dt_match[] = { + { .compatible = "qcom,sdm845-aoss-qmp-pd", }, + {} +}; +MODULE_DEVICE_TABLE(of, qmp_pd_dt_match); + +static struct platform_driver qmp_pd_driver = { + .driver = { + .name = "aoss_qmp_pd", + .of_match_table = qmp_pd_dt_match, + }, + .probe = qmp_pd_probe, +}; +module_platform_driver(qmp_pd_driver); + +MODULE_DESCRIPTION("Qualcomm AOSS QMP load-state driver"); +MODULE_LICENSE("GPL v2"); -- 2.18.0