From patchwork Thu Jul 8 12:06:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 471217 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp215379jao; Thu, 8 Jul 2021 05:07:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUYvN+g744L88NYKYKoFOxDsOqIt4IYKg7RuCYNW4Zh1upc2cfkUjTi/9WxU62noFfty6W X-Received: by 2002:a92:c56d:: with SMTP id b13mr21818954ilj.169.1625746025161; Thu, 08 Jul 2021 05:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625746025; cv=none; d=google.com; s=arc-20160816; b=0at4zH6FStf+f1gVYk8z237yej5OiP/tjMnTNeght5OrUmDEF3mCyjHjGbNFusFOCT A6gjsYeK4biRyRF13MjZQkYiP6oGB9t6XSKhAzZhlGOSGaqWmQVsmta3sX5i8z1jQYF9 pl0Ne8bFEiRDQiRe9gkA5rTBjxfl8iGOZuURNrGWBKFzeIumns/zlQS1Vvh1mANBoAa5 E6Utd6qolTjtYZjECweF2YST07eCdJoNc4Lz5Nv68HKD5zDi0CODfFB59dSFMAgwhCIP wAiIPxKJkN7EBSf3A7+DyIxWwG0YprSnYRKTL2QlJBKVguIP1ykllgInK5kn8f+SjEJw xMHA== 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=qQGpuidZdUasikHf00PLGKYSKqZHy4j8GAIbO90+W4o=; b=EA/dIzHY4nlpLCQM3vREsZw4i3FG/Dq0CAGKOimVtrUWlrODdzTCfZjii8jDvn/1Ts 7Ei6Qa7dmMx/9l/bUAMibgL6sL2X0s1kagOEdBUGNa2OjO95RWIYFCracy0kZgCrj1De AveqaNW1cM9j2iHWbTXj9bE03INRFObIlBQmZnybiwX6Tt2EeJonl9/Zv0lHm+aElQ2C fHdDtkeIpXeNi4F8CDjojmnzYfF4JZb753soXxdbTd1EPg44ePhVNNKzhVpP6HEnIrfN OFeKw2f1NegXRW5X1oUAoSVqxv8Uou/zAUO9WRH10pfZj5VvsRWmA+7HpvhT3/LKzIm+ 9IGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EeMhmCaA; 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 z16si2160661ilo.50.2021.07.08.05.07.04; Thu, 08 Jul 2021 05:07:05 -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=EeMhmCaA; 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 S231487AbhGHMJm (ORCPT + 17 others); Thu, 8 Jul 2021 08:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231382AbhGHMJl (ORCPT ); Thu, 8 Jul 2021 08:09:41 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B265C061764 for ; Thu, 8 Jul 2021 05:06:59 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id t19so5339979qkg.7 for ; Thu, 08 Jul 2021 05:06:59 -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=qQGpuidZdUasikHf00PLGKYSKqZHy4j8GAIbO90+W4o=; b=EeMhmCaAIr/9czG9mwQw1cX8BEIMJBOxtrklgp2vmLqHxW4WFjKaO5oRX2fRRIEvud 79yf35tz3xB6GP4dhgUchQBVtw8bB/nI2uYQHH+oBuMZNJZq430HHDc838VFCtL7tXhq dOOIC4pMAqltXmT3im6gG8hf+vxl54X1NDis/R30UKUyvZNlk3aTq26AkWhm3EXfRVft ZjhUcS5sasTc2omgpm09W2NA+qTLbkkvbRA4/icgT/TctYfQ6w1/7mYtZs5xw5ZZb+94 5IHRD3orgoNIzC5fxJj360M9TCKIkyLrdTbnRzpFF2M6Przi18H7PXSgUz+oqDP/4OwC k2sA== 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=qQGpuidZdUasikHf00PLGKYSKqZHy4j8GAIbO90+W4o=; b=NpTjUoEELS5GxSWnp5LFtB/AUNtL6r2ZUbJ96Ed7CbqbDSuwo64aIVe/yu0SdxOTJj sm4l5X2wkx+GmB3UJ+Sy0pFFyU+VdgBcBP6XUqdNW8MViDcBAdLDbGQoinsTzvXngGBv bNbTaybYB8wpqI5+u1exyU6SQcWMVsMqhl3yaPFR60sRYfUJsUVlNlm/126FVTGpqckc sqjx99Cz5WlgoKfqFeNElwiZlWi0mwPdGxA85Sz9VftXNKcxet2Rs4nzFRS/Q6su8sQj hLVjr9WeWuwH+CX05pFBU7HI+xZ8FD12pNGK+Z09WnQAgAymnZeT7icbqDFZgw5iQZMv rt7A== X-Gm-Message-State: AOAM530g8RE2QakeN+Vb1WQ8r1zl8C4xDQdtseoNiBOMz/TcWDOPCLGM M7lttRNwkZ5XtJyOAwMt0828FA== X-Received: by 2002:a05:620a:31aa:: with SMTP id bi42mr30811000qkb.425.1625746018642; Thu, 08 Jul 2021 05:06:58 -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 i2sm912541qko.43.2021.07.08.05.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 05:06:58 -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: 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 v3 1/6] firmware: qcom_scm: Introduce SCM calls to access LMh Date: Thu, 8 Jul 2021 08:06:51 -0400 Message-Id: <20210708120656.663851-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708120656.663851-1-thara.gopinath@linaro.org> References: <20210708120656.663851-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). 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 Reviewed-by: Bjorn Andersson diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index ee9cb545e73b..a8d236603e90 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