Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4397269ybv; Mon, 10 Feb 2020 18:40:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyom2mZiZRFaqrwFZDhZUJ1dJ5UbAn9n+9qSJUEEaQDIcVKOXBVcLbVO/VBuBx8TbWCrRfo X-Received: by 2002:aca:ec15:: with SMTP id k21mr1518558oih.35.1581388850282; Mon, 10 Feb 2020 18:40:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581388850; cv=none; d=google.com; s=arc-20160816; b=oslJqivk/+tB+Mx1NEaf4CIrBos4V5iWgaP6aeLNpOuMv4wLPz+GNS3JB7bih+kpTq kAUlhZMy7EqET9Eo9Vj4it3KL2R3a/IHLpQFmGPno8tNl2ZSEyi/jThOLDGUBa7VolI8 c+ElCz6Dd6wrmAn713bNLgTEXpMf2Tj53cKOe80PCKsrYuTcYffjTu/fsv2JugDNcsiu P1BvIPlBIrhefxErj4UTxXp2TAk/i8nFCpa3WEsUUZq3CcAIHc6AnO6ORSDvQ0d9LVaT n2czJ4nSLZGKQTGUoy7llMUAVk3knG713CvU+8MiTrqsAs2I8ZoIXKiokuei9Z/u/YEP wNtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=rg1opKQLTdNNzqrI/QD9WhV6BPCDSJS8Wzd+RmEKMIM=; b=IzfmtSm8N/kd+XI0vwl8coYSgD1ptggqjGMh/p5LzShOeL5gSzRp3qtZYyq2Si2cxj WnI+LAPn+k54wUcyML5sUqtKCBuLKLFWXVwOuSjCCyP3jAPYm0NIH1qCQE0n9RKJrBMx CFBM+T3cM8eDXWyHMTLr3y7B9jzD90Ye4Bie4ABHcCbBQWJTe6SIrEhs0cr2G5Pcgt7U blFHz1pme62SXgCG7xPEzVE95Ych62b3Kd6/ptzPDwUG+f+mPXwSDB6yL1fZRg0ttq3a pzC+hKBKf2b1WhrPfebm4Y48bRnUNF3oC5k9yAxIuBWuTCRETPtCLwVVUWiEdet0SuJm Hnng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=xEBAEaBF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si1070098oii.249.2020.02.10.18.40.38; Mon, 10 Feb 2020 18:40:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=xEBAEaBF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbgBKCii (ORCPT + 99 others); Mon, 10 Feb 2020 21:38:38 -0500 Received: from mail25.static.mailgun.info ([104.130.122.25]:16787 "EHLO mail25.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727965AbgBKCie (ORCPT ); Mon, 10 Feb 2020 21:38:34 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1581388714; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=rg1opKQLTdNNzqrI/QD9WhV6BPCDSJS8Wzd+RmEKMIM=; b=xEBAEaBFE5IPOADA7oxEHXcVbcS5zHMEbJ7ul0HVXCYFK1iWJlVMLSkEN4Usd1amRAEdWGdO WPKqvBfe4O/okqdoO2/vyn6+734EH/kxctDigE1voT98cJhbZgCCatEhZ5rTCfx07AhLAYfN NrbtYoI8trixIdU9SJExclQbecU= X-Mailgun-Sending-Ip: 104.130.122.25 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e4213a8.7f99b9c37298-smtp-out-n03; Tue, 11 Feb 2020 02:38:32 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 4FD51C433A2; Tue, 11 Feb 2020 02:38:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 74EBDC447A2; Tue, 11 Feb 2020 02:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 74EBDC447A2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=cang@codeaurora.org From: Can Guo To: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, cang@codeaurora.org Cc: Andy Gross , Bjorn Andersson , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v9 7/7] scsi: ufs-qcom: Delay specific time before gate ref clk Date: Mon, 10 Feb 2020 18:37:49 -0800 Message-Id: <1581388671-18078-8-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1581388671-18078-1-git-send-email-cang@codeaurora.org> References: <1581388671-18078-1-git-send-email-cang@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After enter hibern8, as UFS JEDEC ver 3.0 requires, a specific gating wait time is required before disable the device reference clock. If it is not specified, use the old delay. Signed-off-by: Can Guo Reviewed-by: Asutosh Das Reviewed-by: Hongwu Su --- drivers/scsi/ufs/ufs-qcom.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index ded08fb..ae995f0 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -845,11 +845,27 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) /* * If we are here to disable this clock it might be immediately * after entering into hibern8 in which case we need to make - * sure that device ref_clk is active at least 1us after the + * sure that device ref_clk is active for specific time after * hibern8 enter. */ - if (!enable) - udelay(1); + if (!enable) { + unsigned long gating_wait; + + gating_wait = host->hba->dev_info.clk_gating_wait_us; + if (!gating_wait) { + udelay(1); + } else { + /* + * bRefClkGatingWaitTime defines the minimum + * time for which the reference clock is + * required by device during transition from + * HS-MODE to LS-MODE or HIBERN8 state. Give it + * more delay to be on the safe side. + */ + gating_wait += 10; + usleep_range(gating_wait, gating_wait + 10); + } + } writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project