Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp234511ybi; Tue, 16 Jul 2019 19:45:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7vADsaoXWkUOqq+D9ZAZ7xGydb9/jao2VmPzN0Ob7oyMQdJ7EAEx0HSnO8Tig1rJdwecq X-Received: by 2002:a63:2ec9:: with SMTP id u192mr37073906pgu.16.1563331557130; Tue, 16 Jul 2019 19:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563331557; cv=none; d=google.com; s=arc-20160816; b=ruQKc2JTYRDSw6sAuOqxiNCKbnXWvcq1AxWKIucKahSjl3eZgo8WJHV9tTLm1E10LS 2qzZGLXuKVLruu7LQLbfv2GWmoQ+WKvvRkygc+I8Rvjmx3wjbCK9+iF9nyqr/jIthzRb 0MPEO7RfyKp5n3YMnc+ZXLqqr+Y3nleqD+vooeC15GtJxTvF6JhahDIudzfsPgv2HETz TpLO2NcSkZjxL/vXGt48N/hysViopzCnyw1B1XDHmtrMIl1eMMNQK4t15YpQJ2hYZ06y iGGWhhtvJ+HgcON8+zzpLoo0UjUkx380yYo0yo5WMRF81vXRhYL9bMBOjv8Zk8lq56AP iVSA== 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:mime-version :message-id:date:subject:cc:to:from; bh=UGdoxqeIprUO05JvMQEMpo5HfWyD/2qX92dd65YtodE=; b=CFcQI9/M4h5U7uyJ+pzJtaWM4mS0SSAUz4KtaW2P5+sxSBG0jB3be/g55qqE9AUhsn p12cpkXNOWxTYp9RqB8ylU2B1VnA2sBpFnel64q7XKzKcdhcCD/jV1uJoypqLoT9Q0FJ 5AlQajZ+7t7E2nnjPYNs61ZBTdQvvDLXUDOkPfyXh0p7ng+AbzvXd1OTKLUXWwllpjDG Ivcn98yI01VvFVre2FdBRtUqtMoidz+6PtmcdzI/gfrQ1rQWEX251/YlpP2J6s2cA0Gn rlRgAM1yMWkXeyHcQIR2d6qarK37edSJroofMX6VLu2IEEYqRptGcFKg/dPHEFkrDQpY L7mA== 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 u15si21238347pgn.178.2019.07.16.19.45.40; Tue, 16 Jul 2019 19:45:57 -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 S1727966AbfGQCpS convert rfc822-to-8bit (ORCPT + 99 others); Tue, 16 Jul 2019 22:45:18 -0400 Received: from gli-ex.genesyslogic.com.tw ([60.251.58.171]:42091 "EHLO gli-ex.genesyslogic.com.tw" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725892AbfGQCpS (ORCPT ); Tue, 16 Jul 2019 22:45:18 -0400 X-Greylist: delayed 329 seconds by postgrey-1.27 at vger.kernel.org; Tue, 16 Jul 2019 22:45:17 EDT Received: from localhost (172.17.104.60) by Gli-CASHT02.genesyslogic.com.tw (172.17.50.60) with Microsoft SMTP Server id 14.2.347.0; Wed, 17 Jul 2019 10:39:46 +0800 From: Ben Chuang To: , CC: , , , Ben Chuang Subject: [PATCH 1/2] mmc: sdhci: Add PLL Enable support to internal clock setup Date: Wed, 17 Jul 2019 10:39:51 +0800 Message-ID: <20190717023951.5064-1-ben.chuang@genesyslogic.com.tw> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain X-Originating-IP: [172.17.104.60] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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); - 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) { + /* Wait max 150 ms */ + timeout = ktime_add_ms(ktime_get(), 150); + while (!((clk = 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); } + 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 (!((clk = 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); + } + clk |= SDHCI_CLOCK_CARD_EN; sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + mdelay(1); } EXPORT_SYMBOL_GPL(sdhci_enable_clk); -- 2.22.0 ________________________________ Genesys Logic Email Confidentiality Notice: This mail and any attachments may contain information that is confidential, proprietary, privileged or otherwise protected by law. The mail is intended 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, you 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 your system. Please be noted that any unauthorized use, dissemination, distribution or copying of this email is strictly prohibited. ________________________________