Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1141685pxb; Thu, 28 Jan 2021 08:57:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNf28Wy6Sx3ddoBDLDawvYHUz1VqUFkHs33towgwt3NkzB9eIZveYRYy0caZJeNGy4GCwj X-Received: by 2002:aa7:cad5:: with SMTP id l21mr524922edt.96.1611853064982; Thu, 28 Jan 2021 08:57:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611853064; cv=none; d=google.com; s=arc-20160816; b=IO8HEyTDLSt/h2GJ+e5xIGSmJ5uVmRlu3yNWY8GjOHLE7Yyc187VAH8QN6bAHAk7l2 8yea5SpxKBHBm8m3FS7yafPsc92SSFmZ4a8hIG7c6+tuMR8dSsq8pFC6ZLc+bEjxhLIg OMoUklnGfxioUUqwnUVbA1J1IkDicUnNvBbPhhWasvF+ev9oYUh7XfkEgG9W3kdSmx5N 7SZRAw4U87YrSSUx+3Hq9r8qhMhnoFykxnY8uJ9rd7ZMdtGddw+SkooOkJ+dIJrdXIAW Kz3fWDpNtZPYJCnJ4DVty1FqDN7sYXytiB/6pnDKXH/WXC/HPlzw9l1RUfGQN40/OMQ9 0CEA== 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=J1O/s+i1w/QhJsMSf2xEBTBXvD+3z0ER0bMQvE9+6nk=; b=RxrgHus1MvwjbLGwMtFlawoJPfdLh44PfYnUZ9ixEzUwxo86Xtwtd3k4JIobJ8jSSd 4oK/DP83BMIre8OHwGRAuca8EXfiK8jxutGLaMdYLEmYJPY4vqo1M6Ubx6uYKJuGKjG+ VhWLqj/XpMkAUHdqxGJhOnsE4pQ81vLjMejBMC7kR2nShuVfuTr4J4133mATB1TchxGq 9VDOHsKtQdulJ0cSSn3tcv6L7qHdloqlgvgREiJyxEDQeS9V2wKvko42TtE3JAWJ3ETV UCQiFWve1ia3M4DH9H6psLb0A3ReP10JBPbsQYvrkyZAUq6jy5ZbQm3jj1RV+0nKyCRl t5Mw== 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 gx19si2844027ejb.371.2021.01.28.08.57.20; Thu, 28 Jan 2021 08:57:44 -0800 (PST) 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 S232683AbhA1Q4g (ORCPT + 99 others); Thu, 28 Jan 2021 11:56:36 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:62233 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232237AbhA1Q4e (ORCPT ); Thu, 28 Jan 2021 11:56:34 -0500 Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 28 Jan 2021 08:55:31 -0800 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/AES256-SHA; 28 Jan 2021 08:55:30 -0800 X-QCInternal: smtphost Received: from nitirawa-linux.qualcomm.com ([10.206.25.176]) by ironmsg02-blr.qualcomm.com with ESMTP; 28 Jan 2021 22:25:08 +0530 Received: by nitirawa-linux.qualcomm.com (Postfix, from userid 2342877) id 05A052A73; Thu, 28 Jan 2021 22:25:07 +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 Cc: bvanassche@acm.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Nitin Rawat , "Bao D . Nguyen" Subject: [PATCH V1 3/3] scsi: ufs-qcom: configure VCC voltage level in vendor file Date: Thu, 28 Jan 2021 22:24:59 +0530 Message-Id: <1611852899-2171-4-git-send-email-nitirawa@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611852899-2171-1-git-send-email-nitirawa@codeaurora.org> References: <1611852899-2171-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: Bao D. Nguyen 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