Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1928308rdb; Tue, 5 Sep 2023 09:04:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7oi8oVQjNKV9P28JdnBWfgBPBi1hZ3Ps1fn/U23C06ZPzBX8iG3DFulcmk+hwy39uvtkz X-Received: by 2002:a17:907:3d86:b0:9a5:ae8a:6e0b with SMTP id he6-20020a1709073d8600b009a5ae8a6e0bmr259931ejc.24.1693929853686; Tue, 05 Sep 2023 09:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929853; cv=none; d=google.com; s=arc-20160816; b=z62Mja4vwdcTF5kJCR4D1oLRpfUwgXsKW1+00UYk5irC8F/lmFUrDsH4PAuFetpG5p I7tHu/HXsqTgeyl3aNToMc8MST5PID/ArvDdKL7NAlp6TLxlby/A0QsFe3SnO62DXco2 eKIFJeCmOJx3jU6Ob1wni19Eo0nztp6YzYvT2kZwf0J6PEfAYzfLKpQXtZsOsVWNkvl3 nYmnP70jqWxuDvGu+YUU8Oh4cUsynE8JscVVLz/Zz8wJzgri4P+dRGmSyQMtFSL5Qb4D Mbp8C+LZE5X68wa+b5ClasD+bjA7m7F6Y5eZx4nA0BuxC6yicBBjzQIVxRfS0Ps2J14o IrFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=IPdEplR1fA97t+2tm9I9JuniHz5TEiMiIVvWm/BaUPE=; fh=2dt3Kp+l4XBRp1RD+gVhd9yuJjH8khlqjCqbR7yesQk=; b=BYQqJKIEV6JQ4poJ+j+KZTBNvQ82ITqVIDC0cjIdOOrSSiuiFnCkha6GxepH2jmRgz ZRPY9xz22Y7rCjpmSrfzYcOXP7+NGCAWAh6DTtEbyTccDC/MwRDvK22opD6EUvPfj5Oi 5//oX9TYmoTOAb0YjT5aGs9TwGoeH6obMinQo2r46BYzTSO6i6NXtKt1L3aOjka5mAqn 40aElQu3acjSrhmF9b0qN2LJvzCC5T5TFjRLnpFhEUT63sG0Kq8XgIupc9PPRh3SG8wD TUgzyrULPcO7eu2q0fd+0qsMhdcWw0SAT/fgANVk0W2+8cgSxT79eaBQXn5L/SOftptD 29Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cn1fmYC0; 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 x17-20020a170906659100b0099d98888808si7919243ejn.815.2023.09.05.09.04.09; Tue, 05 Sep 2023 09:04:13 -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=cn1fmYC0; 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 S1349220AbjIALnQ (ORCPT + 10 others); Fri, 1 Sep 2023 07:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349212AbjIALnH (ORCPT ); Fri, 1 Sep 2023 07:43:07 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B07410D5; Fri, 1 Sep 2023 04:43:03 -0700 (PDT) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 381A0Cit009800; Fri, 1 Sep 2023 11:42:53 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; s=qcppdkim1; bh=IPdEplR1fA97t+2tm9I9JuniHz5TEiMiIVvWm/BaUPE=; b=cn1fmYC0+lNylkMm0e7DU8aWWIue4JK6rqzQuM+hKlyNvsDFnRtQjOp9g+7x0TE/8SZu 43Qx1+u3JgCrT8zG1763DjBBvrgFXfxuNJxz27oQalrT1NHB/efk+WBTIJotOQklaE6k shPUi3Kj5GY/S1d8BNNMaiyap4Qusi40Mw++OFJiMnqZQWvBJHMryyElNVC9w3gC6K5e ciloFCivNaUAgNfHEahblR6XznkXdBl6XmmHJLhTqSyVKerSAkcmTSK7cDEcdUbus2TG +SaUwxYPRKibBLDfRykd4Aa5Y59eSWfEqi0RzU4ovzqVXzIzNZQsE/JFSoaLNJK5D3L4 Cg== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3stub8b3a8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Sep 2023 11:42:52 +0000 Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 381Bgm9H013931; Fri, 1 Sep 2023 11:42:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 3sqafmj03v-1; Fri, 01 Sep 2023 11:42:48 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 381Bgmws013924; Fri, 1 Sep 2023 11:42:48 GMT Received: from hu-maiyas-hyd.qualcomm.com (hu-nitirawa-hyd.qualcomm.com [10.213.109.152]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 381BgmcW013923; Fri, 01 Sep 2023 11:42:48 +0000 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2342877) id DBD335006A8; Fri, 1 Sep 2023 17:12:47 +0530 (+0530) From: Nitin Rawat To: mani@kernel.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: quic_cang@quicinc.com, quic_nguyenb@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Nitin Rawat , Naveen Kumar Goud Arepalli Subject: [PATCH V6 1/6] scsi: ufs: qcom: Align mask for core_clk_1us_cycles Date: Fri, 1 Sep 2023 17:12:37 +0530 Message-Id: <20230901114242.31219-2-quic_nitirawa@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230901114242.31219-1-quic_nitirawa@quicinc.com> References: <20230901114242.31219-1-quic_nitirawa@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: P5PS0SifPxXz9hF08BDiHQI1X225CNGx X-Proofpoint-ORIG-GUID: P5PS0SifPxXz9hF08BDiHQI1X225CNGx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-01_09,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=979 phishscore=0 priorityscore=1501 adultscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 bulkscore=0 impostorscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309010109 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE 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 Align core_clk_1us_cycles mask for Qualcomm UFS Controller V4.0.0 onwards as per Hardware Specification. Co-developed-by: Naveen Kumar Goud Arepalli Signed-off-by: Naveen Kumar Goud Arepalli Signed-off-by: Nitin Rawat --- drivers/ufs/host/ufs-qcom.c | 28 ++++++++++++++++++---------- drivers/ufs/host/ufs-qcom.h | 5 +++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index f88febb23123..fe36003faaa8 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1297,22 +1297,30 @@ static void ufs_qcom_exit(struct ufs_hba *hba) } static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba, - u32 clk_cycles) + u32 cycles_in_1us) { - int err; + struct ufs_qcom_host *host = ufshcd_get_variant(hba); u32 core_clk_ctrl_reg; + int ret; - if (clk_cycles > DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK) - return -EINVAL; - - err = ufshcd_dme_get(hba, + ret = ufshcd_dme_get(hba, UIC_ARG_MIB(DME_VS_CORE_CLK_CTRL), &core_clk_ctrl_reg); - if (err) - return err; + if (ret) + return ret; - core_clk_ctrl_reg &= ~DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK; - core_clk_ctrl_reg |= clk_cycles; + /* Bit mask is different for UFS host controller V4.0.0 onwards */ + if (host->hw_ver.major >= 4) { + if (!FIELD_FIT(CLK_1US_CYCLES_MASK_V4, cycles_in_1us)) + return -ERANGE; + core_clk_ctrl_reg &= ~CLK_1US_CYCLES_MASK_V4; + core_clk_ctrl_reg |= FIELD_PREP(CLK_1US_CYCLES_MASK_V4, cycles_in_1us); + } else { + if (!FIELD_FIT(CLK_1US_CYCLES_MASK, cycles_in_1us)) + return -ERANGE; + core_clk_ctrl_reg &= ~CLK_1US_CYCLES_MASK; + core_clk_ctrl_reg |= FIELD_PREP(CLK_1US_CYCLES_MASK, cycles_in_1us); + } /* Clear CORE_CLK_DIV_EN */ core_clk_ctrl_reg &= ~DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT; diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index d6f8e74bd538..8a9d3dbec297 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -129,8 +129,9 @@ enum { #define PA_VS_CONFIG_REG1 0x9000 #define DME_VS_CORE_CLK_CTRL 0xD002 /* bit and mask definitions for DME_VS_CORE_CLK_CTRL attribute */ -#define DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT BIT(8) -#define DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK 0xFF +#define CLK_1US_CYCLES_MASK_V4 GENMASK(27, 16) +#define CLK_1US_CYCLES_MASK GENMASK(7, 0) +#define DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT BIT(8) static inline void ufs_qcom_get_controller_revision(struct ufs_hba *hba, -- 2.17.1