Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1097765rwr; Wed, 3 May 2023 10:07:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6mVmDuKAT+qt/FtNmqVYVyQuSsD/+yAL93ZwCKSmrhB3ku9ee9QXnyNXdRMmTjyXv8oSK1 X-Received: by 2002:a05:6a20:c581:b0:f1:8f7:eeb5 with SMTP id gn1-20020a056a20c58100b000f108f7eeb5mr17859860pzb.60.1683133629828; Wed, 03 May 2023 10:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683133629; cv=none; d=google.com; s=arc-20160816; b=LfiTOvAPoOzHi7frLuzrODL9rmjJqKPWh7lPSOX5WaVNXBeW4YKR0yviEHeKN2FMyb n9nWGOfTOjrnykUyvwCzFGlts3wvwmykjy3Iq1yK0uGL1E071FJdRLJScBMvy616aELH CjscupAlNNCpy87NWRvzWLhvOvrdXLEOIPoNZniJ6FO7FiR39kpn23lMLpV4kyGM+WtD h0r1/7dYEY0uWrtoiSk4c6s83sI3SZpVvJ19SDX0g80lIPXwhQqAiOGxPBnZ9hTv1M/i s60Hwz09n0PYwKumuYvRVmlTzl+7TpQJG5rB6tLfCRMENvo7zS61s953nxCvSsXLqgRA I75g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cTrb6AAL5Z/powfWWwL2O6iKbdcDlmyn8nzgAhqIzDw=; b=dAkfvzhu7ucjUTayQa9YD/XP3RVIasmoyvybZC38+OMlTYk1+OZAl0xF1L51mTAGjS x6guRFolTnkijtN1MEeZoiQ57Yo3pgYF8ZIFbljp73Y2YxJQ/IKQZeAvfEpUX8Ez0Wic u/VZzmfqN7PgJvGI9wnFDchws4nl7HNf0NsnxrBRMIXr5zP5krWRrselTbBW3LzTWWOH +w4pF4wfPMcjPkWbpPjM58Pygt6SoH0WvwJxhLUIh3MCFm5W993tWmzmAYycWBxMub7f a2JB/dJaFlQGAkG+XjVTCzZ+Iy0ecasUdMET1JHugMkbtDpR8BUx0UYDNhXTE3fGFC5X NQnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JkkXzoQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14-20020a63d94e000000b00527d158ec6dsi23974327pgj.406.2023.05.03.10.06.57; Wed, 03 May 2023 10:07:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=JkkXzoQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbjECRG2 (ORCPT + 99 others); Wed, 3 May 2023 13:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbjECRGN (ORCPT ); Wed, 3 May 2023 13:06:13 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97BD276B7; Wed, 3 May 2023 10:05:41 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 343FYptl010763; Wed, 3 May 2023 17:04:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=cTrb6AAL5Z/powfWWwL2O6iKbdcDlmyn8nzgAhqIzDw=; b=JkkXzoQvkg28ypNVYqpmwwpId05r/+tasVhqbg/jaJJ4/jvFDqOYsqv30BokzadsB5gs hAseGeTfvxUJNtkTH8hem2j4MSbNAx3+CPJLfZSyyOyQ2Pd1xI6s0gWNKRN1Tc2+Q+IQ i702lbrCaIedldd9S4hVBCjYriI01Ik6UG5GqKEhSvm4Dbwk9fiksHZir6YuFJf61kki Bm0oGSYwPv0QjgMSui7GxjcnS1knyHjR6JEIsCCY+pX5oQsIiPoXNHs2hQEe65vZ372l Xwk6f+pc+s8jDxvq9n71HKNiBEFVRdO/XjKa6xugqXCnQth8aJhkqXZsHCqEuOWA97zJ WQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qbn0a8yhk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 17:04:17 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 343H4GSg005221 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 3 May 2023 17:04:16 GMT Received: from hu-mojha-hyd.qualcomm.com (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 3 May 2023 10:04:11 -0700 From: Mukesh Ojha To: , , , , , , , , , , , , , CC: , , , , , , "Mukesh Ojha" Subject: [PATCH v3 14/18] firmware: qcom_scm: provide a read-modify-write function Date: Wed, 3 May 2023 22:32:28 +0530 Message-ID: <1683133352-10046-15-git-send-email-quic_mojha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1683133352-10046-1-git-send-email-quic_mojha@quicinc.com> References: <1683133352-10046-1-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: NT5Jp7dFkvyRw3WTO3FQ2yqq9b54g_IO X-Proofpoint-ORIG-GUID: NT5Jp7dFkvyRw3WTO3FQ2yqq9b54g_IO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-03_12,2023-05-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 mlxlogscore=852 mlxscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 clxscore=1015 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305030146 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It was realized by Srinivas K. that there is a need of read-modify-write scm exported function so that it can be used by multiple clients. Let's introduce qcom_scm_io_update_field() which masks out the bits and write the passed value to that bit-offset. Subsequent patch will use this function. Suggested-by: Srinivas Kandagatla Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom_scm.c | 15 +++++++++++++++ include/linux/firmware/qcom/qcom_scm.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index fde33acd..003cbcb 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id) } EXPORT_SYMBOL(qcom_scm_set_remote_state); +int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val) +{ + unsigned int old, new; + int ret; + + ret = qcom_scm_io_readl(addr, &old); + if (ret) + return ret; + + new = (old & ~mask) | val << (ffs(mask) - 1); + + return qcom_scm_io_writel(addr, new); +} +EXPORT_SYMBOL(qcom_scm_io_update_field); + static int __qcom_scm_set_dload_mode(struct device *dev, bool enable) { struct qcom_scm_desc desc = { diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h index 250ea4e..ca41e4e 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -84,6 +84,8 @@ extern bool qcom_scm_pas_supported(u32 peripheral); extern int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val); extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val); +extern int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, + unsigned int val); extern bool qcom_scm_restore_sec_cfg_available(void); extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare); -- 2.7.4