Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp99583ybl; Thu, 29 Aug 2019 19:26:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSEazsu0zrHuB17IO7jQPz2gXnuJde2MXuhDDF4i9yc2qZtY1Iawd9hHLi1odrpZ7wTfm/ X-Received: by 2002:a17:902:bd4a:: with SMTP id b10mr13086163plx.219.1567131977332; Thu, 29 Aug 2019 19:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567131977; cv=none; d=google.com; s=arc-20160816; b=lZXgVZJ0b0NF7E9QM71FXMA5h0LDLK/wBARwqxNjWHqNpVUVKwJIEmVZ+dcOmNYVtL YVrQ+uQGaeosJ03SpZyCaValmuqOcmH9djLwSsM7KIed7sqyDwUmWWGoK4RLCZ4xXu35 ExyNn31QavxTYwkEEJb7azyP0UX6WHB6VOcGUKH7i5KD5tC28nVQKfNOpiBY1DhNJYSD OFTkBDO5t2SbjQy9B5OEIAzWAU23Y/P2yVZ2SGCHx6pcSqym5TJvK1f1jA3mVg39Zo5o oBpHXhI81w+7i5cZNQ7S6ultjI76TK7+kGHW9yXij9/JbCVZlaKfhBjApoxqsDIF1/4n jmhA== 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:dkim-signature; bh=189g0JP68z9u+Ep1GWrcVIMocc6+TBCdAX4Yd+2DXKM=; b=hbh5e4akxzwocdOxRiJWt6ky9/P5shDh0ibPhH25sD2YuHdxDXxOV4Fh1nA1PiOht4 zDAyOJGEAeVryPO70LfPcynmbwfu+4qarAlfZNt+X/zHrOuFDycXHKfyufxYHvo0GFin b1o1Dkbl3QRh37ux2KdAm8o1T89eJFEOOPUeqc1EfKt0NbVYKcXqGtjduA4/iaqlGNUj c5XYJrceEAR5a2qflm4aGGXqWYfdiIQ0Yve+n0kMwPJFURf+f2QuIqgZPZAT2IARX3b7 Y+3/plBGTzBYqxbVnBV/k0jRpq98k7nHaaLg0wb51WFMXvr+skPrlkiIugMiGPFT8g2S p8EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KZkZXYNn; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si3629282pjq.46.2019.08.29.19.26.01; Thu, 29 Aug 2019 19:26:17 -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=@gmail.com header.s=20161025 header.b=KZkZXYNn; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727728AbfH3CX2 (ORCPT + 99 others); Thu, 29 Aug 2019 22:23:28 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37063 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727344AbfH3CX1 (ORCPT ); Thu, 29 Aug 2019 22:23:27 -0400 Received: by mail-pf1-f196.google.com with SMTP id y9so3512312pfl.4; Thu, 29 Aug 2019 19:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=189g0JP68z9u+Ep1GWrcVIMocc6+TBCdAX4Yd+2DXKM=; b=KZkZXYNnsSOYG4pBmr3NpVOqOvf7VPO/THlxI88gRD31nCWIDvzbA3wEhdyF6CqeMx s4YmBLm2aN+FmjsRvg8q8i15zKSxJclUqrgQTVy+tiZWOuvEG46tp6993lhhpl+kG//i 7uVazj0a2Pzzs5r6VD3ZDCgAZjYbiVlRAKzZbgsGO1Lj6A3fTtKCLuXlwfjD37lPa2CV EYWMgalEtjy5moP21SSxY9J/ZnwWmGPuGlgEoHm5tXjhUfmIUTvEKFY6RDau1nxan1xY tEq4JVUrPHtznWP+gHW7k181+zOT/TVBHJ6ZTkRtdCbqz/6OrP+KLH0MT9Oen5K3qp4S ikKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=189g0JP68z9u+Ep1GWrcVIMocc6+TBCdAX4Yd+2DXKM=; b=ThmgKEAkisuS63sKy0C5oxkZaHzcev/2aTpdwMbFm6nd3+USchIb/GBsVbEQLG2cJL ugfk/4uCxFrzPhjZFWXPFh14Fqloi9ZevoOyzmqCJIOOOafrIxTeK8wZBOrbOKStSal1 GH7/cTYSB6tJ0ZBQaBuAQbTGLuyAWqcwnvlif6jFGLPtyfEy+4cyZHLeR+fHOzcZ44ju LNGCawi/Q6osPPX0TIDB2rOBcVMNs0Udu26HjKCQJisw/9glOcuzmgurhuH46Ge8QIU5 MWLPGjjoSUdTdyJ/SxEqSzIzj8aUa8RJjQjEHNFnZQGHTx9x4qhXOFUWd1muy7Muny2T WRJw== X-Gm-Message-State: APjAAAUI/zfBQZ6CA2g4ZdD3+T+jS0N6irMwX7qfe6w+HSVjwyPgQQrL D9QmgwgpMnyXytbbywkcybA= X-Received: by 2002:a63:2c8:: with SMTP id 191mr10828976pgc.139.1567131807077; Thu, 29 Aug 2019 19:23:27 -0700 (PDT) Received: from gli-arch.genesyslogic.com.tw (60-251-58-169.HINET-IP.hinet.net. [60.251.58.169]) by smtp.gmail.com with ESMTPSA id l124sm8652379pgl.54.2019.08.29.19.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 19:23:26 -0700 (PDT) From: Ben Chuang To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, johnsonm@danlj.org, ben.chuang@genesyslogic.com.tw, Ben Chuang Subject: [PATCH V7 2/5] mmc: sdhci: Add PLL Enable support to internal clock setup Date: Fri, 30 Aug 2019 10:23:25 +0800 Message-Id: <20190830022325.8348-1-benchuanggli@gmail.com> X-Mailer: git-send-email 2.22.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ben Chuang 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. Signed-off-by: Ben Chuang Co-developed-by: Michael K Johnson Signed-off-by: Michael K Johnson Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 23 +++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index bed0760a6c2a..9106ebc7a422 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1653,6 +1653,29 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) udelay(10); } + 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; + } + udelay(10); + } + } + clk |= SDHCI_CLOCK_CARD_EN; sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); } 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 -- 2.22.1