Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5186836ybh; Wed, 7 Aug 2019 02:08:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHd55QyFwoD3D3dWdwuSgA08PfoJm9GcnBAYNS8CmyN/trJj5otTiDoHmqMKiQTRgjELbA X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr7177114plm.306.1565168902079; Wed, 07 Aug 2019 02:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565168902; cv=none; d=google.com; s=arc-20160816; b=emAopzwAPbva51d6x56ZMLNYi1E97VzJN926397AUp1B74xysg41yOnE0N5ZbLPfRr Bu5hs6tNouFHAT9bJbCkY13E4JjTtMhWn/Pmaw7QFbi08W1m++ozNTLo7eS9GzPOWTz3 MpZzJtSgFXd9+n8cVoOSefdQbff0du2zstNPPqHd9w48wPbu4JCmSsyFi3cWx8UbW7WZ lPnH3mNUk9h7Afrw7W0YFrYViyjEIxs7ZhTkyMfxBgMfGxsJzxKfH3ay50B6QYIADNAi aUgO1qMZ02fALicmxp92t3oqV0gt0DJwxJqyPSX2Y1M4H/HNop1z1Vsqxrsguhn5Dzd4 1g+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=QwZM+I//k3CaKR8cnjXx2HxcK1Wyp9hvgsek+V9Yyrg=; b=f9Fhwqoo+10b20WBOe6qS3oihVEo2wMM9ZZpeoCJoxvcTEbSD0zvvA2RCn49MPSVYv SW+WIteuLKjIw84fjic83tqxWi7TG/pltkWti564OpxJw0OXatagQmb+Pm2IdsqMbFDM JyjcK1xFaXOho0QVkrVYqKPTgOsi1HSh/QBQ+BaqJkmACWJYLyLtaCxlUTB3sNNC22dg e8yGuTyCjfUUjjftVT6NrLEMOi3gdHnKVQW3q5Ydd5gIQnPuy6Ia5p2DjhU0pKyqwNZ3 4KLLhbGqPSpgBONaD3XIVy/+QF2H8I8jLfmIakBoQEh39TwJWFFu+x3M8c5lQX0DrCc9 MshA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n128si49278285pgn.82.2019.08.07.02.08.06; Wed, 07 Aug 2019 02:08:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728360AbfHGJHJ (ORCPT + 99 others); Wed, 7 Aug 2019 05:07:09 -0400 Received: from mga18.intel.com ([134.134.136.126]:26308 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbfHGJHJ (ORCPT ); Wed, 7 Aug 2019 05:07:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 02:07:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,357,1559545200"; d="scan'208";a="176131076" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.122]) ([10.237.72.122]) by fmsmga007.fm.intel.com with ESMTP; 07 Aug 2019 02:07:05 -0700 Subject: Re: [PATCH v2 1/2] mmc: sdhci: Add PLL Enable support to internal clock setup To: "Michael K. Johnson" , ulf.hansson@linaro.org Cc: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, Ben Chuang References: <20190726020746.GB12042@people.danlj.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Wed, 7 Aug 2019 12:05:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190726020746.GB12042@people.danlj.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/07/19 5:07 AM, Michael K. Johnson wrote: > 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); There is still one place that calls ->set_clock() under spinlock, so that needs to stay udelay(10) for now. > + } > + PLL Enable is only valid from v4.1 i.e. if (host->version >= SDHCI_SPEC_410 && host->v4_mode) > + 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 > >