Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5133083pxj; Wed, 9 Jun 2021 09:53:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkbG+b8ZJWTSvqeBsLm9JW3Aa8im5drfPVZR/LbhU9sViWuaP3mv19MB6V2KqBcYZx/9iJ X-Received: by 2002:aa7:da58:: with SMTP id w24mr371334eds.127.1623257591259; Wed, 09 Jun 2021 09:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623257591; cv=none; d=google.com; s=arc-20160816; b=Jd3c+SAvXFJkF7Bx7Zo+OeRJUIiP4lTFZcRUlGBuFzno4xFNa0oef+SjUwcOAs3hlV 4wu6TDQK3ffosgZzOLwNq8j20JK54nG1w3vNwPP+TfyL3zVo/30pcxVYW8uQc2+VDuHj SCFD4WIH7FIltTZcz1f05SJHYeNn5cBLixr1kgl8+xKSzuW40Hei/+RRDXB6FrWXFpkI rm2EESjVEbCV6gBGI94iTPxk4BLIeTV3LRAzUbad8F0PNz2uwlr5EUnaRuFyvUSZaan4 lDXJl5dHrkpHXRrXoO/qoxtbwIK8d37PFAUMPHAnpIYXeDbxWzJokV3N0aWTbN4C7/pt hOSQ== 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=GvNr0cURQ5TDqrTkg430MscO613gd9bfT50EURpL3BM=; b=q9Om9RambS4TR7e53Fcc3c27KYSNzGTRAuR3t2m722MIVTzwQhlBhymhzcLBhlms+B O/fl0Jlzm9xLxt++pj68tgiG+6KA41TP6a3EEHX3Mw4AdlSKLK2jVMSyrFiyz6T7qT2f mXjc39CpKV29mix+Q/n4afpf3eTh534K0R2CZj417LHij3tDFqcC0KalsrnCd5masRuE ETz4/J8mkxsIZx/Q6By6YbhhVcGgOSb76rwuXa2O1pZ7Mw9XOhwed6ynhjHMVjEnirct U7nk2NKkD8ElSvDMJH7nM+ZN5OQXTYH7zc1X8mIUk1GksaQ+U6BejXZQc3GjmSogG8ch qi2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iTRt/yLO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id k16si171453edo.475.2021.06.09.09.52.47; Wed, 09 Jun 2021 09:53:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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="iTRt/yLO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232404AbhFHWbX (ORCPT + 99 others); Tue, 8 Jun 2021 18:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbhFHWbX (ORCPT ); Tue, 8 Jun 2021 18:31:23 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7367C06178B for ; Tue, 8 Jun 2021 15:29:29 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id l17so12395731qtq.12 for ; Tue, 08 Jun 2021 15:29:29 -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=GvNr0cURQ5TDqrTkg430MscO613gd9bfT50EURpL3BM=; b=iTRt/yLOjwIyBZ7rxne4pyfDmF7fNCafhlPIXasBUEQuXQCkItKNdHMc3IaYElhipB h+Xu0qQWmi6dD9j5ozTpy2X9cOKh4QhMzmzHy+O2i8K0RwGSZ3l5apqh78guv6sApjHy NPBwBWFH9Ab3BTEWLOlWIhfNQGaR7PN1c5fYc1YJYfPIb1unFReehNP0x7vcgh7JFVsM 7Y6GvKRF48zjK38I/Q2bJeklbH7Uok8snL7VW2z3g+7vCLaAdixsYBtaK3/v0Ws/Ag0n 8Tg0oh/iA8VKoRxR3nJjY+N8JtuTXjGs8CSzankRaXFOXQta4UJl/dRp5bPrbJe97gJY Yalg== 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=GvNr0cURQ5TDqrTkg430MscO613gd9bfT50EURpL3BM=; b=swdpd4pRBQxWLcZfzFz1Tm9TZuTId+uZMM2Cb2IXybLONhJCRBDgviHQYT531itBDl 3iPVz9MmT+Oefa/mHlm6MOs/X+Lptw0v1oNU5OdtaZNOeDHdy+/C9SVtg31PhA0pe0L3 WbUoPBXfQRUWFYsxtA3rCyis/A+TWUDhX/Xyssw4GpgkhVJTgA4lpz7tjC9SXvLll2Z8 Rxc/roErcNndcOkcL9B0guT05i/k82w973r+7cdTOGFszD2KXnP0fP7HJRPt5cZLbvvr kJgAC+/ver1/RJslOVLGFvyuLL8VI+bAzPyzguhj47sM2CBXKszYRB5+Fe1Yydsq7S+l tpEA== X-Gm-Message-State: AOAM531nETHIbthvLOfu627acMewA4mMu2WCopiG5pFRYWWJT4fbmRTF iAlNMqtX1nOhKxixezKWe14OWA== X-Received: by 2002:ac8:5f4e:: with SMTP id y14mr5294678qta.253.1623191368819; Tue, 08 Jun 2021 15:29:28 -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 h19sm10450736qtq.5.2021.06.08.15.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 15:29:28 -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: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/5] firmware: qcom_scm: Introduce SCM calls to access LMh Date: Tue, 8 Jun 2021 18:29:22 -0400 Message-Id: <20210608222926.2707768-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608222926.2707768-1-thara.gopinath@linaro.org> References: <20210608222926.2707768-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce SCM calls to access/configure limits management hardware(LMh). Signed-off-by: Thara Gopinath --- drivers/firmware/qcom_scm.c | 47 +++++++++++++++++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 4 ++++ include/linux/qcom_scm.h | 13 ++++++++++ 3 files changed, 64 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index ee9cb545e73b..0259e9ffb8a1 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -1147,6 +1147,53 @@ 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, u32 payload_size, u64 limit_node, u32 node_id, u64 version) +{ + dma_addr_t payload_phys; + void *payload_buf; + + 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; + memcpy(payload_buf, payload, payload_size); + + desc.args[0] = payload_phys; + return qcom_scm_call(__scm->dev, &desc, NULL); +} +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..0c92197769e7 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, u32 payload_size, 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,12 @@ 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; } + +int qcom_scm_lmh_dcvsh(u32 *payload, u32 payload_size, u64 limit_node, + u32 node_id, u64 version) + { return -ENODEV; } +int qcom_scm_lmh_profile_change(u32 profile_id) { return -ENODEV; } + +bool qcom_scm_lmh_dcvsh_available(void) { return -ENODEV; } #endif #endif -- 2.25.1