Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3573667ybl; Mon, 3 Feb 2020 02:50:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxe/GmVbe2Xm60uT0Jvhmwcpt0eG5blNTtaLljMKKfPmIV8k23iysQqZC+09nwmnfkqHORl X-Received: by 2002:a9d:7f81:: with SMTP id t1mr16269584otp.95.1580727012880; Mon, 03 Feb 2020 02:50:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580727012; cv=none; d=google.com; s=arc-20160816; b=hfzVYLXEEsUYwQKarH7K+rWCejP4dC3XmBut1bvPBPTf7QKAVwk+5jGj7kT3/CwO2x pZWF52DCxuXBos+O0DvmacdJO8qHgsJC5HsbDRueywllFHU2m+Xs8AQbz6op3BYufwCR c4QSkgd/3CA8tFooXO+OyNmsR96UbE7XEp2wRn1QQ1r6cYDyxuZKuLPzBn9x21M+rMEY mVEvOYnByIAr0TOiuIPCyTPuZYLTsEv5ehrSAnyvLjn/IRy2pLB+7c9hWMDimz8RydWV uIpcZ6awem//hPEZMIuPw2SyAaWqXfp4Syh0KJtDKuc0100e6gJ6cFnyGfrwf2zGrQHs 9fZA== 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=PjSdqThfMBqN89hJKhdFpE8OgLWVWPGGj3rPbJUMbqQ=; b=pEv6LsVNXzIZnzvWn3YsDzgFl+KmqumN1Rx8jPIZ50VSCOQtrta3LYs/fYed4Rr1pR U8SPIbQ7/6Tfc8jtIWYvoSuCVoDI7cgjgKKnf3VcxEkSAplejPwpI73kiWBzirGDEPID 7euIPrUsewMXi4Q0IDyyNWz4PSCj8NemfXCUsGhcZgVRQKVqhYJA0D79/N+qqG+Enx/S XVx/Im+IkViIaZp4JFg9E4GjPK3pee+b0MP+PE/5w0OO+GsaUzh7HH/hh16UsPGUAIjQ bi4IiH6uL8pzBioyZI8Xa24cw5Uodx5ti7kAVM5cRmQnckt4BPllrj0wen7yYgdmHONG H+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=Y9rCgHo1; 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 a12si8338680oid.189.2020.02.03.02.49.59; Mon, 03 Feb 2020 02:50:12 -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=Y9rCgHo1; 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 S1727985AbgBCJSi (ORCPT + 99 others); Mon, 3 Feb 2020 04:18:38 -0500 Received: from mail25.static.mailgun.info ([104.130.122.25]:45948 "EHLO mail25.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727896AbgBCJSh (ORCPT ); Mon, 3 Feb 2020 04:18:37 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1580721517; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=PjSdqThfMBqN89hJKhdFpE8OgLWVWPGGj3rPbJUMbqQ=; b=Y9rCgHo1y0hhg2nR/wWkQ/1RUew7sw5xOnyWd3ZEWJSX0uzNpbL8P2/GdXzdPQicsw/LUlpn SgbOlGKVx0JOp8unqCUCrXYhVzYHOL6uz3vok7pCDTXazsf3hZdSVF35l9K2YluJiO9J/5gx Hl1AlDpZbNCiUMsurFpKh7ZmOLU= 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 5e37e567.7fa2593048b8-smtp-out-n01; Mon, 03 Feb 2020 09:18:31 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BF062C447B1; Mon, 3 Feb 2020 09:18: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 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 E81F0C447A3; Mon, 3 Feb 2020 09:18:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E81F0C447A3 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 v5 7/8] scsi: ufs-qcom: Delay specific time before gate ref clk Date: Mon, 3 Feb 2020 01:17:49 -0800 Message-Id: <1580721472-10784-8-git-send-email-cang@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1580721472-10784-1-git-send-email-cang@codeaurora.org> References: <1580721472-10784-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 --- drivers/scsi/ufs/ufs-qcom.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 85d7c17..3b5b2d9 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -833,6 +833,8 @@ static int ufs_qcom_bus_register(struct ufs_qcom_host *host) static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) { + unsigned long gating_wait; + if (host->dev_ref_clk_ctrl_mmio && (enable ^ host->is_dev_ref_clk_enabled)) { u32 temp = readl_relaxed(host->dev_ref_clk_ctrl_mmio); @@ -845,11 +847,16 @@ 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) { + gating_wait = host->hba->dev_info.clk_gating_wait_us; + if (!gating_wait) + udelay(1); + else + 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