From patchwork Tue Jul 27 15:25:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 486731 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp319396jas; Tue, 27 Jul 2021 08:26:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJDfQWjUKF3XwsVUKNajlCHmBvEtMUZGNRBvn2lwbaGppsn/QvEGv7TXPdJeFwmUDDkO0C X-Received: by 2002:a17:906:8248:: with SMTP id f8mr10134830ejx.229.1627399570254; Tue, 27 Jul 2021 08:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627399570; cv=none; d=google.com; s=arc-20160816; b=jB+lttg/LmTOg9mKzYHLC/MOB1aCuAPNLAqUYZ2hYTHt2mR/+pp0CYMp2cCX9tWWMa dqMgAHc55D3KPKshgNaTKNXT+1J+iaja/Nxc9CpPdZnuVsBzR7Qo6a2q0ISvMDjdQX/e Dvfptr/6RPKXf3UwegEDVr20PqPwuMP/nH1HCRVEFtqszfJKvLe1ZeVOEOl7ZQTyxV2W +oEZp3Avux0lJJc6RxdpNh7egV58FSq0rFmMybTRVnCBC+bGF5Ws+DKL9zRCgJGoPfJU Kq4DSPzQ4Ju0rcJTzLzX9X213HdF9yV0t6ugofE+iXR/dvYEkfQ8R4+tka5Gvl7LubNX Ql5w== 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=8WOrNxoMZRaE3XcZqAlR+PM8cMsZjto7dFuOpUUbU8E=; b=ZXmsXxoJBiaf1fENQS+Q0JyZPcd77GJ30OibNa0YwPHA3H0LumlQVrshaNNEm6yi8a rJld8t0+eshnbfimR9ZVo806Ea900Grr1/IrBdKa/NRiHDAUcYT0lQUQ6o4Lh/Or/znL ag064A4dZ4w/M23ChkbYrw+XDIoiJvHN8LaUQsRep3/Mq5ON2K2q9BUrP8k7dc8TzlNV LTPAsjfDVKrqiM3zpPm6FhT28WrFgYFZ0f93SeCc0T5fGLWT+N3vWRm/OP5mciyDCa7c +K3lxAysaB+Ltbmm7hixQybHlYj7VUZyefvYFZaOwlSG/bThi1t3SK08D836nAb4UV3P 8PNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iJrM9+IW; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 q9si3389954edw.143.2021.07.27.08.26.10; Tue, 27 Jul 2021 08:26:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-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=iJrM9+IW; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S232710AbhG0PZ5 (ORCPT + 8 others); Tue, 27 Jul 2021 11:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237062AbhG0PZp (ORCPT ); Tue, 27 Jul 2021 11:25:45 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7012AC061796 for ; Tue, 27 Jul 2021 08:25:15 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id 129so12707349qkg.4 for ; Tue, 27 Jul 2021 08:25:15 -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=8WOrNxoMZRaE3XcZqAlR+PM8cMsZjto7dFuOpUUbU8E=; b=iJrM9+IWurMTIUIVmIMribDjFzHvbbx8lNhN7/IHkIcAZdFUF0Bjwm5NtYKKwV89Gq aCWNDtTHuw6+EHdKi18+lz6ypSUDDRHYEuIE+tXMNVet7G0oLClf6L0UGomPq1UqMwKx Yxg/t0I0lFJAWMnxT/EYFO6NvlsbUXl/o6qn6yev/Sysx0E3UxaO6L3jyIMCMbCC6t/e cnMEod/hTeKiiyzcGs39xpSPpPayL+vql5Qh6C6byHih2FYsdemZ2vImE60OdOJLRjow teYVzp1cMbl+nPR8tQ0Gn2kS0KpbF2eSxjHzptUE6ZYz6uXun4gq0I2rPxJzTBj9Lhfz pa+w== 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=8WOrNxoMZRaE3XcZqAlR+PM8cMsZjto7dFuOpUUbU8E=; b=h+QXG5k8WB7veiTu7+BGCynLKTY750tOzlyLvn7NqeriTkrJ5lG1U5epfXnbH+yrdH xHDCfeakvkSMnCg2WdKYz6lbzXZ7gOlAUpB/Q5qjkgRit3dkCDg46NmPxGdeb/Ah/KF1 Y5Iz7EoKIOjVuY4yPk3GrlzoEc1qERk4efa4ABHkfT+E1U8+KzlDFweqSQKW2z1MlWup jwDquCWcugevPJli+jZHafwVkqSQgLwB29I5CB+4nWCqGHhQd8xqRwD59f2LqETS72vz dEVx3kncAAGk28pjWlCGdUjaLqYHQ9K6y3LAXpQ2CaMUIHIEPecjI77YA3G2uswGGZtM 4Z0w== X-Gm-Message-State: AOAM530W8gNbnoyJZWd4jO+bImcbOpItPq/DD/bU47+U4RVfnNlCN90i C/Ll7QEVyO32Lvi2bQPUhZIhew== X-Received: by 2002:a37:6753:: with SMTP id b80mr22986817qkc.140.1627399514533; Tue, 27 Jul 2021 08:25:14 -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 q4sm1539663qtr.20.2021.07.27.08.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 08:25:14 -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, linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [Patch v4 1/6] firmware: qcom_scm: Introduce SCM calls to access LMh Date: Tue, 27 Jul 2021 11:25:07 -0400 Message-Id: <20210727152512.1098329-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210727152512.1098329-1-thara.gopinath@linaro.org> References: <20210727152512.1098329-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Introduce SCM calls to access/configure limits management hardware(LMH). Signed-off-by: Thara Gopinath Reviewed-by: Bjorn Andersson --- 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