Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9227834ybi; Wed, 24 Jul 2019 00:20:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJZFg3fJREYozOyU5Evo0gPpv+wq2uWhDjNcTL4Ka1VF9eWU6nh5r6s7bNbLeOKyXNBZ27 X-Received: by 2002:a63:2ec9:: with SMTP id u192mr78426581pgu.16.1563952856567; Wed, 24 Jul 2019 00:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563952856; cv=none; d=google.com; s=arc-20160816; b=UbIYa0ptfu+p8zld4j1fbfvyFHjAXVoubp9JkMQY6aTuFft7mAMHmcEYYMrVkQW6k4 6DO1Zd0VrNgBaVEJD1xFLMQds4w8Ef42sd6p24F0MmyYPEQA/pY4XVuXhuzFplYyGDsz 5eRcsYoJ2zFPghc+L3ZdxVrcF+Bw82Q8R/CyqgbPWm+CpNZqLNccdcH9SZhwD59tUch7 dNE6zqIDaU7FCDVqeXZcPZCEkas0301/mR3b+UGecJYsYtGrAGVON6nvk+UrEBkz7+UR MFh0FU25o3jWP72zPuVfD4tB68+oqua+amVMVkFZ7rmVemz454LPKZcZ5D1J3Gaul7kz R6hQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ZzXFeEn87A5vyKYJCjfJnKarDAqU0LIG7gGJcY5sqsg=; b=p17ThazbQjfw69+WtG2f/7O/D5XpwphL552OQpAIhJe5/PtRvSroDcwWs9ZMJOjbz7 bTPXdYlrEQq/Ze6Oy90PgnZ7rIsnAjllWDgw3esRhptVcsKK3XiJlfEremRQ/rVbcqoc ACV2nZD/m6wWj+woqHBbatYEuPnnh2zwzDAFh2BbK4fHR/3bvJvBz2IK5RDZncEgYOjD 8NTBAG2X805FbW1PxM90zi/tmp5SsKWsJZYpLG6ZLcywjkOGOyKuW2wW54C7TBoFvSwN ZP47BjL/3W0u3eSIYO9tT/KXWtmmu0VWbUPbzRP4litHVCHYMt3ECtXoY0GWg9wyyR2T YNEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jw04qDJb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si17212990pgm.327.2019.07.24.00.20.42; Wed, 24 Jul 2019 00:20:56 -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; dkim=pass header.i=@linaro.org header.s=google header.b=Jw04qDJb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726087AbfGXHUI (ORCPT + 99 others); Wed, 24 Jul 2019 03:20:08 -0400 Received: from mail-ua1-f67.google.com ([209.85.222.67]:41243 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfGXHUI (ORCPT ); Wed, 24 Jul 2019 03:20:08 -0400 Received: by mail-ua1-f67.google.com with SMTP id 34so18073364uar.8 for ; Wed, 24 Jul 2019 00:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZzXFeEn87A5vyKYJCjfJnKarDAqU0LIG7gGJcY5sqsg=; b=Jw04qDJbUduHDaQul0E7od3NeIWVX284jfuzm47kaW8A6J/Nnm5Ru1i0Xq/+mK6Det u2uKGf2FZ+RZEBpz4g/IQdHIB6bYME+9m/PynBS4EO0FOXuOVJtFS8oY8w0+lRzqjubv 0yZUoNouuzpBinqBD4/A+/Y4EZsff3UUko4zsIPtTlNqtVUnu/HXqkPzsdg+A1Y5TP7q K914bSyggrk1akIAGqOLQiBpXToAxaaxL8Ci70+cjFHb7CDZnEZOwAFmoOil6Wjg6xZ2 keD9WElSm/+VEaRG5C4Hmr/GXBzuuw83tn0hxXN2a4upjV+ayGEycRNSTcQkCe6Y34le 4j3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZzXFeEn87A5vyKYJCjfJnKarDAqU0LIG7gGJcY5sqsg=; b=GG4V4U2YWFdrt9WtfV6iu34HIGY1HHUNylNg0YCUrbS4kAZojQYFW5XV50VyTWpQHj 0PhDl2/6nPHqs9MKgoUxPIS5ikCZJnVklr/HY9dZbpoS0b9Hz7KopevM+QOWLicBn0s2 bIxnYJKDQZI3Ca7tq4nt/SLYe0jIQwVQmEHA7OLRzclRo55Af6RmwIQCeXc5DjkUjLR8 /0B1A7Ncpahppc4fj3+Y6TezfPzG63tIHZI7GDwJimvWN3vTRO+JEvnTtsy5ARiacLk0 g5CWvBs+xmlQHP5mhAUu/WpTeJp3TpgRYeygK5wvxgm7W+mewkf8EFqrjvKXxmusuuwt E4gw== X-Gm-Message-State: APjAAAX3SF6hGbsbJbiplifilj0KsJC54J7CFqOH+kkmbJguKwzYO9w7 FgUs/ilZpCAtvnQacf3HVVWPlM6nwEnpdGi99eBI3w== X-Received: by 2002:ab0:5973:: with SMTP id o48mr40276484uad.19.1563952807229; Wed, 24 Jul 2019 00:20:07 -0700 (PDT) MIME-Version: 1.0 References: <20190717023951.5064-1-ben.chuang@genesyslogic.com.tw> In-Reply-To: <20190717023951.5064-1-ben.chuang@genesyslogic.com.tw> From: Ulf Hansson Date: Wed, 24 Jul 2019 09:19:30 +0200 Message-ID: Subject: Re: [PATCH 1/2] mmc: sdhci: Add PLL Enable support to internal clock setup To: Ben Chuang Cc: Adrian Hunter , Linux Kernel Mailing List , "linux-mmc@vger.kernel.org" , johnsonm@danlj.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Jul 2019 at 04:39, Ben Chuang w= rote: > > 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 > --- > drivers/mmc/host/sdhci.c | 33 ++++++++++++++++++++++++--------- > 1 file changed, 24 insertions(+), 9 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index 59acf8e3331e..fd684d7a5f15 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -1636,15 +1636,11 @@ void sdhci_enable_clk(struct sdhci_host *host, u1= 6 clk) > clk |=3D SDHCI_CLOCK_INT_EN; > sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); > > - /* Wait max 20 ms */ > - timeout =3D ktime_add_ms(ktime_get(), 20); > - while (1) { > - bool timedout =3D ktime_after(ktime_get(), timeout); > - > - clk =3D sdhci_readw(host, SDHCI_CLOCK_CONTROL); > - if (clk & SDHCI_CLOCK_INT_STABLE) > - break; > - if (timedout) { > + /* Wait max 150 ms */ > + timeout =3D ktime_add_ms(ktime_get(), 150); > + while (!((clk =3D sdhci_readw(host, SDHCI_CLOCK_CONTROL)) > + & SDHCI_CLOCK_INT_STABLE)) { > + if (ktime_after(ktime_get(), timeout)) { > pr_err("%s: Internal clock never stabilised.\n", > mmc_hostname(host->mmc)); > sdhci_dumpregs(host); > @@ -1653,8 +1649,27 @@ void sdhci_enable_clk(struct sdhci_host *host, u16= clk) > udelay(10); This looks like it could be changed to an usleep_range(), perhaps an additional change on top? > } > > + clk |=3D SDHCI_CLOCK_PLL_EN; > + clk &=3D ~SDHCI_CLOCK_INT_STABLE; > + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); > + > + /* Wait max 150 ms */ > + timeout =3D ktime_add_ms(ktime_get(), 150); > + while (!((clk =3D sdhci_readw(host, SDHCI_CLOCK_CONTROL)) > + & SDHCI_CLOCK_INT_STABLE)) { > + if (ktime_after(ktime_get(), timeout)) { > + pr_err("%s: PLL clock never stabilised.\n", > + mmc_hostname(host->mmc)); > + sdhci_dumpregs(host); > + return; > + } > + udelay(10); Ditto. > + } > + > clk |=3D SDHCI_CLOCK_CARD_EN; > sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); > + > + mdelay(1); This is new, maybe add a comment and change to usleep_range(). > } > EXPORT_SYMBOL_GPL(sdhci_enable_clk); > > -- > 2.22.0 > > ________________________________ > > Genesys Logic Email Confidentiality Notice: > This mail and any attachments may contain information that is confidentia= l, proprietary, privileged or otherwise protected by law. The mail is inten= ded solely for the named addressee (or a person responsible for delivering = it to the addressee). If you are not the intended recipient of this mail, y= ou are not authorized to read, print, copy or disseminate this mail. > > If you have received this email in error, please notify us immediately by= reply email and immediately delete this message and any attachments from y= our system. Please be noted that any unauthorized use, dissemination, distr= ibution or copying of this email is strictly prohibited. > ________________________________ If you want me to apply the patch, you have to drop the above notice. Kind regards Uffe