From patchwork Mon Aug 9 19:15:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 493894 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp3207889jap; Mon, 9 Aug 2021 12:16:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRrRhPrnYxwl6AOmMydtE+D4XBwQmrD/NOH/Q/5FaU3O5pYniXs6THvOOQKyHk//Eq0Bnz X-Received: by 2002:a17:906:994b:: with SMTP id zm11mr23756646ejb.6.1628536572433; Mon, 09 Aug 2021 12:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628536572; cv=none; d=google.com; s=arc-20160816; b=nsqz9tmBh0kse+3ByAd8C6/3ooHY2SETnybSLwLUagUinX7gBLlmXzvYH5xggDs+SO HYUFIAuPqfzxEtylpLQCpNSiHSaNTDDJgB8mq7mB52/WS1fEgiIdhERTtq5QzSZ5Y3E8 rnfluJMREzLm75ClkDoOKYFDPR3vrIuGwk97pJQMqD7uKIYOR1WgDG7eC8u6SdkUSaX8 71rzBQayZ1tLdEfqEtoot7xDlmE1LhcwEh7usOjR5QTsm2O/UyA+ixPvBdCeYdYQ8KNM gFRVYzehVTOUYVwBag3HYpAXQjPtJDUio8igMJ3h6i2nUQsipzl5VekQ8WZt1zOCNCo/ TQwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jCUn04Uy/5nEhUoONzVloyladnaZ3tCplSZNJCiC434=; b=fg3attYddtApZ4xt9hB2Xay/DSwMfVAJA7KDDf/1Wx1qFXocTb9RcbsWG4OHeyymIN b4vN19exq64AYgQZNiHUZSJYZsQfMwpuNB1hdlw1Ac7uoDn9F2mH4O3UqB18s5tVbFU2 3r+2wEvfdUQo+TTY7iZ1ynvyYN4iNFHiCpVKW4AW2Fg3+hpZCwSEe2dULmwlSoohMi6j xFHxvlhRc38oMBiOc74hEM2BUVLe5ubT2abooBzMEbNsYu9aCrbN87JnGhhtharHUYQN NV85MGfrrmjAXkc+nSY/ge+FewUmvD5SwurXNdep6yHYwBGbC3oOUAZdb2jqEDyE50Tk YZtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PfKTTaJA; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id la20si20622160ejc.685.2021.08.09.12.16.12; Mon, 09 Aug 2021 12:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PfKTTaJA; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 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 S236006AbhHITQa (ORCPT + 16 others); Mon, 9 Aug 2021 15:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235993AbhHITQ3 (ORCPT ); Mon, 9 Aug 2021 15:16:29 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB08FC061799 for ; Mon, 9 Aug 2021 12:16:08 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id c6so9147588qtv.5 for ; Mon, 09 Aug 2021 12:16: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 :mime-version:content-transfer-encoding; bh=jCUn04Uy/5nEhUoONzVloyladnaZ3tCplSZNJCiC434=; b=PfKTTaJAJJZ2D4KXZhWvd4vKnqpucY/bQjwfimMNiABMITFlT+4h2MrxLamSOR/qc/ XDNtHmk8vjjCnsQAjr5vXmkdTw14nNEXrXQJE6qBlw+3AYcqtny3VZ7+AiCcXrYsdlBM WYBpCWRPMH7GBHCNGSfnJA6sISm25CnRFCniQSaMAOJWTyhin3/R1z2MR6Mb5HpADQZN rkKg2AnFkSTS/OKte9OOmdGAhdQy76cxs7QK5FygYcO1JmB3FzHis4bc0BuM7NQp9R9C MJKz5fRsZcX/6FeYk5f6YVL0gx7pDt5QyOEHIoOohs64dyfxaurKVDU4ZwPZvDDnHKYc 60ww== 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:mime-version:content-transfer-encoding; bh=jCUn04Uy/5nEhUoONzVloyladnaZ3tCplSZNJCiC434=; b=kLqt/RQ5dA/Ckq7e0w8BUEW7Y1fQ2H4wnHA4F3rGG7P+v3eEfJsRXNHmQ5w0qC/q9r GxQ3m6CaYsIucPxYTwNDGr7Xawq5ukImtWV1e94fn0NZkx+3Xa57NpICxFNxLVxwEXgw Fi7kLLweikfeALGyNp8QICbP2dzUCDtjHBwrtIAdHzclKAmA3bj4F9GvFVlCxrNsqSW1 wvwbvtVwoaTuaZWz0U2VFE93wJDsWSLeRvM9ipCpctgWVB+KEzg/0prWvuSVZc9mFyeB 2MmTGxEDl+N0fyE4cRHTZAOfHsBspUyYJF/dqv8ugJWp9i+iE9Qa9epxC+5S8qzUIqTB M2Lg== X-Gm-Message-State: AOAM5318JG3ktBzlwN4o75CwvjuH59hSoDA+kqw2wY373is1/AF4ILrf U7/rdEaqxDg0zgIcWu0vUmRAZQ== X-Received: by 2002:aed:279e:: with SMTP id a30mr21429912qtd.300.1628536567899; Mon, 09 Aug 2021 12:16:07 -0700 (PDT) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id n14sm7303398qti.47.2021.08.09.12.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 12:16:07 -0700 (PDT) From: Thara Gopinath To: agross@kernel.org, bjorn.andersson@linaro.org, rui.zhang@intel.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, rjw@rjwysocki.net, robh+dt@kernel.org Cc: steev@kali.org, tdas@codeaurora.org, mka@chromium.org, linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [Patch v5 1/6] firmware: qcom_scm: Introduce SCM calls to access LMh Date: Mon, 9 Aug 2021 15:15:59 -0400 Message-Id: <20210809191605.3742979-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210809191605.3742979-1-thara.gopinath@linaro.org> References: <20210809191605.3742979-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Introduce SCM calls to access/configure limits management hardware(LMH). Reviewed-by: Bjorn Andersson Signed-off-by: Thara Gopinath --- v2->v3: Added freeing of payload_buf after the scm call in qcom_scm_lmh_dcvsh as per Matthias review comments. v1->v2: Changed the input parameters in qcom_scm_lmh_dcvsh from payload_buf and payload_size to payload_fn, payload_reg, payload_val as per Bjorn's review comments. drivers/firmware/qcom_scm.c | 58 +++++++++++++++++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 4 +++ include/linux/qcom_scm.h | 14 +++++++++ 3 files changed, 76 insertions(+) -- 2.25.1 diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 47ea2bd42b10..8a503753fe2a 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1147,6 +1147,64 @@ int qcom_scm_qsmmu500_wait_safe_toggle(bool en) } EXPORT_SYMBOL(qcom_scm_qsmmu500_wait_safe_toggle); +bool qcom_scm_lmh_dcvsh_available(void) +{ + return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_LMH, QCOM_SCM_LMH_LIMIT_DCVSH); +} +EXPORT_SYMBOL(qcom_scm_lmh_dcvsh_available); + +int qcom_scm_lmh_profile_change(u32 profile_id) +{ + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_LMH, + .cmd = QCOM_SCM_LMH_LIMIT_PROFILE_CHANGE, + .arginfo = QCOM_SCM_ARGS(1, QCOM_SCM_VAL), + .args[0] = profile_id, + .owner = ARM_SMCCC_OWNER_SIP, + }; + + return qcom_scm_call(__scm->dev, &desc, NULL); +} +EXPORT_SYMBOL(qcom_scm_lmh_profile_change); + +int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, + u64 limit_node, u32 node_id, u64 version) +{ + dma_addr_t payload_phys; + u32 *payload_buf; + int ret, payload_size = 5 * sizeof(u32); + + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_LMH, + .cmd = QCOM_SCM_LMH_LIMIT_DCVSH, + .arginfo = QCOM_SCM_ARGS(5, QCOM_SCM_RO, QCOM_SCM_VAL, QCOM_SCM_VAL, + QCOM_SCM_VAL, QCOM_SCM_VAL), + .args[1] = payload_size, + .args[2] = limit_node, + .args[3] = node_id, + .args[4] = version, + .owner = ARM_SMCCC_OWNER_SIP, + }; + + payload_buf = dma_alloc_coherent(__scm->dev, payload_size, &payload_phys, GFP_KERNEL); + if (!payload_buf) + return -ENOMEM; + + payload_buf[0] = payload_fn; + payload_buf[1] = 0; + payload_buf[2] = payload_reg; + payload_buf[3] = 1; + payload_buf[4] = payload_val; + + desc.args[0] = payload_phys; + + ret = qcom_scm_call(__scm->dev, &desc, NULL); + + dma_free_coherent(__scm->dev, payload_size, payload_buf, payload_phys); + return ret; +} +EXPORT_SYMBOL(qcom_scm_lmh_dcvsh); + static int qcom_scm_find_dload_address(struct device *dev, u64 *addr) { struct device_node *tcsr; diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index 632fe3142462..d92156ceb3ac 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -114,6 +114,10 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, #define QCOM_SCM_SVC_HDCP 0x11 #define QCOM_SCM_HDCP_INVOKE 0x01 +#define QCOM_SCM_SVC_LMH 0x13 +#define QCOM_SCM_LMH_LIMIT_PROFILE_CHANGE 0x01 +#define QCOM_SCM_LMH_LIMIT_DCVSH 0x10 + #define QCOM_SCM_SVC_SMMU_PROGRAM 0x15 #define QCOM_SCM_SMMU_CONFIG_ERRATA1 0x03 #define QCOM_SCM_SMMU_CONFIG_ERRATA1_CLIENT_ALL 0x02 diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 0165824c5128..c0475d1c9885 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -109,6 +109,12 @@ extern int qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, u32 *resp); extern int qcom_scm_qsmmu500_wait_safe_toggle(bool en); + +extern int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, + u64 limit_node, u32 node_id, u64 version); +extern int qcom_scm_lmh_profile_change(u32 profile_id); +extern bool qcom_scm_lmh_dcvsh_available(void); + #else #include @@ -170,5 +176,13 @@ static inline int qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, static inline int qcom_scm_qsmmu500_wait_safe_toggle(bool en) { return -ENODEV; } + +static inline int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, + u64 limit_node, u32 node_id, u64 version) + { return -ENODEV; } + +static inline int qcom_scm_lmh_profile_change(u32 profile_id) { return -ENODEV; } + +static inline bool qcom_scm_lmh_dcvsh_available(void) { return -ENODEV; } #endif #endif