Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11093493ybi; Thu, 25 Jul 2019 09:52:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjnubrmMikSp+JciG2MwfAsY3GDSbg8B8+mDf1w0s2yhEzJ/Umulp/pNx/7crvfvkYysSB X-Received: by 2002:a63:f50d:: with SMTP id w13mr86976086pgh.411.1564073552853; Thu, 25 Jul 2019 09:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564073552; cv=none; d=google.com; s=arc-20160816; b=DAMK1XWVuexZZSW06s8Xj7wqXvcjFFdhqGBe7uOnrKRStPo0URmTktQ9EHMuIsaY+i un5J2qYQbCaMkaL83hv8tyT49j8QH5l5TSyIy9al8jAZ9bnwYtc7tMTnOkqD1tiKVCW5 HRCRpR0bxJMa8Q02m0rl0x+M9/Z5dHEi2+lpc9krVWu8jjRTaOncWbOHMWGuCjfJ9xTn DuPtL7opAVeBYGHJYrD/TRuFUbW4bTg0UX6CPf1oh+LQQFsWrjehgO2SGox54Bg6U9Eh C4g6RfrWoudhRkvq15P7bKhkWa1QUYAMHhfesBVDPpx2Qb71hKk6gfgoMv7SZesprIEF NCRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=fCjdsKzF8pOsBG48OWRbRYu5JcG3meHQOT2q9XaPkJo=; b=xR6ZjS8NIXiS6QnAnReJFmaxLa/HsSfgUa4JWUSgZvRgiVxZXIEM+NvNTiw+w91Ef1 NKo+wCsALDQwEaUifUxtIos67CjrufL0cp5QJw5LpjGbDWq3Th9SdAJeeYKDjaqNatXA klNahHMQH1gbCDMu5U+UKxFiDZT3+eKEGyx2lN9njYUiUDxvIgXtJNMpDaPw3sUpUPmO X7sC6ry8XPJyhaAuVTZOMLOfobnDAC1xJoxDvUBOtM3f1Z6iZqUG6B0xtBR3q8b4dwQ4 3oHimITWkIHiiHuhhoDPHzJ95uSJM72NKd20oPmbdhyNr9qC3l6ECa4KUaX2zcrsu99t CYWg== ARC-Authentication-Results: i=1; mx.google.com; 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 j62si17583223pgd.170.2019.07.25.09.52.17; Thu, 25 Jul 2019 09:52:32 -0700 (PDT) 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; 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 S2391674AbfGYLPI (ORCPT + 99 others); Thu, 25 Jul 2019 07:15:08 -0400 Received: from esa01.kjsl.com ([198.137.202.87]:30969 "EHLO esa01.kjsl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388791AbfGYLPH (ORCPT ); Thu, 25 Jul 2019 07:15:07 -0400 Received: from unknown (HELO people.danlj.org) ([IPv6:2607:7c80:54:5:7609:68e3:940d:b47c]) by esa01.kjsl.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2019 11:15:06 +0000 Received: from people.danlj.org (localhost [127.0.0.1]) by people.danlj.org (8.14.7/8.14.7) with ESMTP id x6PBF5PJ008672 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 25 Jul 2019 07:15:05 -0400 Received: (from johnsonm@localhost) by people.danlj.org (8.14.7/8.15.2/Submit) id x6PBF4XX008671; Thu, 25 Jul 2019 07:15:04 -0400 Date: Thu, 25 Jul 2019 07:15:04 -0400 From: "Michael K. Johnson" To: Ulf Hansson Cc: Ben Chuang , Adrian Hunter , Linux Kernel Mailing List , "linux-mmc@vger.kernel.org" Subject: Re: [PATCH 1/2] mmc: sdhci: Add PLL Enable support to internal clock setup Message-ID: <20190725111504.GA8647@people.danlj.org> References: <20190717023951.5064-1-ben.chuang@genesyslogic.com.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (Working around Ben's SMTP server noise, responding on his behalf...) On Wed, Jul 24, 2019 at 09:19:30AM +0200, Ulf Hansson wrote: > This looks like it could be changed to an usleep_range(), perhaps an > additional change on top? ... > Ditto. In both cases yes, changed. > > + mdelay(1); > > This is new, maybe add a comment and change to usleep_range(). Entirely removed. New patch attached for any further review, I can re-send the patchset properly without the notice for merge when you're happy with it. The GL9750 and GL9755 chipsets, and possibly others, require PLL Enable setup as part of the internal clock setup as described in 3.2.1 Internal Clock Setup Sequence of SD Host Controller Simplified Specification Version 4.20. This changes the timeouts to the new specification of 150ms for each step and is documented as safe for "prior versions which do not support PLL Enable." Signed-off-by: Ben Chuang Co-developed-by: Michael K Johnson Signed-off-by: Michael K Johnson diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 59acf8e3331e..14957578bf2e 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1636,8 +1636,8 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) clk |= SDHCI_CLOCK_INT_EN; sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); - /* Wait max 20 ms */ - timeout = ktime_add_ms(ktime_get(), 20); + /* Wait max 150 ms */ + timeout = ktime_add_ms(ktime_get(), 150); while (1) { bool timedout = ktime_after(ktime_get(), timeout); @@ -1650,7 +1650,28 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) sdhci_dumpregs(host); return; } - udelay(10); + usleep_range(10,15); + } + + clk |= SDHCI_CLOCK_PLL_EN; + clk &= ~SDHCI_CLOCK_INT_STABLE; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + /* Wait max 150 ms */ + timeout = ktime_add_ms(ktime_get(), 150); + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + if (clk & SDHCI_CLOCK_INT_STABLE) + break; + if (timedout) { + pr_err("%s: PLL clock never stabilised.\n", + mmc_hostname(host->mmc)); + sdhci_dumpregs(host); + return; + } + usleep_range(10,15); } clk |= SDHCI_CLOCK_CARD_EN; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 199712e7adbb..72601a4d2e95 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -114,6 +114,7 @@ #define SDHCI_DIV_HI_MASK 0x300 #define SDHCI_PROG_CLOCK_MODE 0x0020 #define SDHCI_CLOCK_CARD_EN 0x0004 +#define SDHCI_CLOCK_PLL_EN 0x0008 #define SDHCI_CLOCK_INT_STABLE 0x0002 #define SDHCI_CLOCK_INT_EN 0x0001