Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3042313pxf; Sun, 21 Mar 2021 16:44:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd2AlJZd9kHKnnFsG4Fvezh5KkCRwN3SNXmkuQMM/L1rQd5wWFnsKMkORcidzUmz+4uYYD X-Received: by 2002:a05:6402:5255:: with SMTP id t21mr22822299edd.91.1616370293945; Sun, 21 Mar 2021 16:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616370293; cv=none; d=google.com; s=arc-20160816; b=HmMS2TVFHwAxLYC7I8SUDMQpxtFLm336zy7EQI9v+oZ/DiwZD9IZlgISirtcJktBaL zK+P9ZxbxI8dWe7EZeF7d/eoAIQ4JGtJnRWMoeZG4H+zzkQYy3s+vf8mfehyR5gVLQ2K tt7MIZeKuGGsPaviH5ht+FS+ea9WBO01mXBmybCGfLMkLZdbGBvf55ubyXgjZ3WbsrMD scXDLZiXf0R53eGy06nyeJoFgpEmqrz8063jnCcHWxONWJzOlr98GoERSRuLliX8B658 49e+PNUEe8BWqfhqGqeSRtGCB1DY7r09i4dsYXVsKH5oPAYERHE9Iy+2Kc2UaPR6QcWF wLyg== 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; bh=K6rCJioBcRxjKrCHIKq5BkQNfgovaA70x4yukkcNPi8=; b=rqfsTerhaLgdqhUwGD0MMPN2OoMiQWzVNXEK82fJlVx2wf7B438nqj5oqj3n5aqFzZ 7VvMoC3trcTxyOBqcOgFrloHEpLMgrgkgHbjCN4tz0MkO46x7WJMg4Yq6J2ml6xSzc2L mqv2kJC2qEc0jxBDJEqTeX7yCg9QUXN6l+olhr+EnIKarPomf+ri+qaY9t0tbd+cq3sz V79dDlBB92j3BXqvfWwjjUcDBvfeaPQ8tVpt9RzsprShlbQ+3xvYNa3tVliqyykzP/Uu r0tNhimH//iZWDN+WsUdMlaunUeMaWhCCLCuN5q9B9rUcUpmRrihsX7Mr9SLt2tRIwLm KuOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt17si9802009edb.424.2021.03.21.16.44.31; Sun, 21 Mar 2021 16:44:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231652AbhCUV6v (ORCPT + 99 others); Sun, 21 Mar 2021 17:58:51 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:40323 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbhCUV6Y (ORCPT ); Sun, 21 Mar 2021 17:58:24 -0400 Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 21 Mar 2021 14:58:24 -0700 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 21 Mar 2021 14:58:22 -0700 X-QCInternal: smtphost Received: from maggarwa.ap.qualcomm.com (HELO nitirawa-linux.qualcomm.com) ([10.206.25.176]) by ironmsg01-blr.qualcomm.com with ESMTP; 22 Mar 2021 03:27:48 +0530 Received: by nitirawa-linux.qualcomm.com (Postfix, from userid 2342877) id 8ECCB2E19; Mon, 22 Mar 2021 03:27:47 +0530 (IST) From: Nitin Rawat To: asutoshd@codeaurora.org, cang@codeaurora.org, stummala@codeaurora.org, vbadigan@codeaurora.org, alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, beanhuo@micron.com, bjorn.andersson@linaro.org, adrian.hunter@intel.com, bvanassche@acm.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Nitin Rawat Subject: [PATCH V2 3/3] scsi: ufs-qcom: configure VCC voltage level in vendor file Date: Mon, 22 Mar 2021 03:27:37 +0530 Message-Id: <1616363857-26760-4-git-send-email-nitirawa@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1616363857-26760-1-git-send-email-nitirawa@codeaurora.org> References: <1616363857-26760-1-git-send-email-nitirawa@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a part of vops handler, VCC voltage is updated as per the ufs device probed after reading the device descriptor. We follow below steps to configure voltage level. 1. Set the device to SLEEP state. 2. Disable the Vcc Regulator. 3. Set the vcc voltage according to the device type and reenable the regulator. 4. Set the device mode back to ACTIVE. Signed-off-by: Nitin Rawat Signed-off-by: Veerabhadrarao Badiganti --- drivers/scsi/ufs/ufs-qcom.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index f97d7b0..ca35f5c 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -21,6 +21,17 @@ #define UFS_QCOM_DEFAULT_DBG_PRINT_EN \ (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN) +#define ANDROID_BOOT_DEV_MAX 30 +static char android_boot_dev[ANDROID_BOOT_DEV_MAX]; + +/* Min and Max VCC voltage values for ufs 2.x and + * ufs 3.x devices + */ +#define UFS_3X_VREG_VCC_MIN_UV 2540000 /* uV */ +#define UFS_3X_VREG_VCC_MAX_UV 2700000 /* uV */ +#define UFS_2X_VREG_VCC_MIN_UV 2950000 /* uV */ +#define UFS_2X_VREG_VCC_MAX_UV 2960000 /* uV */ + enum { TSTBUS_UAWM, TSTBUS_UARM, @@ -1293,6 +1304,45 @@ static void ufs_qcom_print_hw_debug_reg_all(struct ufs_hba *hba, print_fn(hba, reg, 9, "UFS_DBG_RD_REG_TMRLUT ", priv); } + /** + * ufs_qcom_setup_vcc_regulators - Update VCC voltage + * @hba: host controller instance + * Update VCC voltage based on UFS device(ufs 2.x or + * ufs 3.x probed) + */ +static int ufs_qcom_setup_vcc_regulators(struct ufs_hba *hba) +{ + struct ufs_dev_info *dev_info = &hba->dev_info; + struct ufs_vreg *vreg = hba->vreg_info.vcc; + int ret; + + /* Put the device in sleep before lowering VCC level */ + ret = ufshcd_set_dev_pwr_mode(hba, UFS_SLEEP_PWR_MODE); + + /* Switch off VCC before switching it ON at 2.5v or 2.96v */ + ret = ufshcd_disable_vreg(hba->dev, vreg); + + /* add ~2ms delay before renabling VCC at lower voltage */ + usleep_range(2000, 2100); + + /* set VCC min and max voltage according to ufs device type */ + if (dev_info->wspecversion >= 0x300) { + vreg->min_uV = UFS_3X_VREG_VCC_MIN_UV; + vreg->max_uV = UFS_3X_VREG_VCC_MAX_UV; + } + + else { + vreg->min_uV = UFS_2X_VREG_VCC_MIN_UV; + vreg->max_uV = UFS_2X_VREG_VCC_MAX_UV; + } + + ret = ufshcd_enable_vreg(hba->dev, vreg); + + /* Bring the device in active now */ + ret = ufshcd_set_dev_pwr_mode(hba, UFS_ACTIVE_PWR_MODE); + return ret; +} + static void ufs_qcom_enable_test_bus(struct ufs_qcom_host *host) { if (host->dbg_print_en & UFS_QCOM_DBG_PRINT_TEST_BUS_EN) { @@ -1490,6 +1540,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = { .device_reset = ufs_qcom_device_reset, .config_scaling_param = ufs_qcom_config_scaling_param, .program_key = ufs_qcom_ice_program_key, + .setup_vcc_regulators = ufs_qcom_setup_vcc_regulators, }; /** -- 2.7.4