From patchwork Tue Jun 4 08:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 165713 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5523290ili; Tue, 4 Jun 2019 01:15:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUWcbQw+RQMqvTQ4gASz03LtPRKYixHP5Y9Ui6Nb7+SR6PVKWmrnaydIUdt/PicB6az4c/ X-Received: by 2002:aa7:8dd6:: with SMTP id j22mr37765723pfr.192.1559636115412; Tue, 04 Jun 2019 01:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559636115; cv=none; d=google.com; s=arc-20160816; b=c/4+H7pr4QjknQi1Guya1YDo71Nn1cxwefpiY8jGG6oyMdX5ftio/VZ+HEpP8bV//T ylgR+t4Tow78OHm82gADC/bS/5LBGSQwxunu9x19gaHv2vr4Wxlid3w1Cro5n7vj5omM 6z4rlMdjLyLyC1gxzFatpw5fIyeyFrQJfZHl1Vl3bT8iIHtAkZE+MHKDobzBMeyQ2Q29 IkevclgYjcjN53DgNxz3EI7Xu1nXXmp/+y6pFlSEM8uzzSioUZKZr57QOMAscUxAhKKn oOlteyDOm/7pc1HT5DaLVEEcK40sY5J5lOg9Vpe4UUTn7WwAsy9zjpH4arIkEMOcjKNj UzrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=1vxV7xw/5L8i8m4bOyu5pRBcqwZ6n7yFKBRMfko8eAg=; b=uPaBIUhan446MuusKS+w2DpPQGP62FLVlERJV6RAHHimpy8Rolywb/JubVVXwQq54r Jr7jywKOiR7BW4SC6QGoYJTf++kUc1uo762dltSLCudLQQKZjOIWfEZa2+4Dvpi6JACl JfnSvnTTEmtnuPX1/cpcfUP625DWrrM6Ttgbms9OI572+r3zmRBYoGR4zaWE7oW/N8uB Nf25GXATM+QPXiF43N17d6XwuM31Adqek+KPuzRD2j3DpnfPBF5ZZBktdkymBqCPEBxP hjhtiBPSsaU0udawDBFekON5kJDFTF5YowaSTre/Hn/rqr5Fv2U4YGZEINxYTlDyEYtI HHIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="yF/IS8w7"; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 g12si19304023pla.322.2019.06.04.01.15.15; Tue, 04 Jun 2019 01:15:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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="yF/IS8w7"; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1727083AbfFDIPO (ORCPT + 7 others); Tue, 4 Jun 2019 04:15:14 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43608 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727091AbfFDIPM (ORCPT ); Tue, 4 Jun 2019 04:15:12 -0400 Received: by mail-pl1-f193.google.com with SMTP id cl9so2929905plb.10 for ; Tue, 04 Jun 2019 01:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=1vxV7xw/5L8i8m4bOyu5pRBcqwZ6n7yFKBRMfko8eAg=; b=yF/IS8w7PJss7KY8M0Wgdbhr4VXw0eZdXylHTkYXpnzppT6cn89MSsaQKKrjC+DtQN 1GtV+NlutX5shDQlf1LrHQXLzThmo4n0NLbMGxqY8RmRnIiR6hfvu8BJoPrg/+oUZHxB +S7jPtfHSDhI+jm1xYZlszQMW6y3F3wkCVj1Hun96siKj9lKc/AhwLiKhSEEM/la8VKX /dexH7LLGORAMf8idnkuxH74+l9ygl2Kvoz/7surXaj1r61Kubiw+dqSgEGF2t3/gI7E zvccHnVXEs90BwkkWUltHssENapZM1r1qHYnT69sGzuHWmyUp9oo0FJhRwKFmJ0zJhcL 3ifQ== 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:in-reply-to :references:in-reply-to:references; bh=1vxV7xw/5L8i8m4bOyu5pRBcqwZ6n7yFKBRMfko8eAg=; b=IBkvHv/4KPcvzJ3V+Gc2fpamd27gRGblTsf4naqKGXvQrGEOVUv5ejUEAFfwRGmiu2 1f71Yixx3HemBsH2Z3w/CKqWfliixuMMzs7N+zrRxAQW0dWNwQjvD//SqqK4dHpfpNOF pLzDbwhoWuSk1X4llPxwGbNEGSLk+usDOxMMJXSDYPd7SnSEmqj8w+YPz64iFzm/xQ5E mBfshwahjJ+Abr+NkaqpEmgFASFKrQPeqFUJK7Ag0e8wlJEzY600QJY48mYADiALOYtG zfRTF2nI0pa2zE4gJd6M7nZw6+cb3cTEwLVSgGopafsgcxGYpgKWDby0N7sKoXJrFd5D d7fQ== X-Gm-Message-State: APjAAAV4xUQbHKDzjE9PqYri3XBFKgkMeszeLqb9cu4YKE9BIsNslQa5 s3WyHjpTWJkVSP7F2lXhNNd+sg== X-Received: by 2002:a17:902:aa0a:: with SMTP id be10mr27683709plb.27.1559636112034; Tue, 04 Jun 2019 01:15:12 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id j4sm14818804pgc.56.2019.06.04.01.15.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jun 2019 01:15:11 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, zhang.lyra@gmail.com, orsonzhai@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, arnd@arndb.de, olof@lixom.net Cc: baolin.wang@linaro.org, vincent.guittot@linaro.org, arm@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 5/9] mmc: sdhci-sprd: Add HS400 enhanced strobe mode Date: Tue, 4 Jun 2019 16:14:25 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add HS400 enhanced strobe mode support for Spreadtrum SD host controller. Signed-off-by: Baolin Wang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-sprd.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) -- 1.7.9.5 diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index d91281d..edec197 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -41,6 +41,7 @@ /* SDHCI_HOST_CONTROL2 */ #define SDHCI_SPRD_CTRL_HS200 0x0005 #define SDHCI_SPRD_CTRL_HS400 0x0006 +#define SDHCI_SPRD_CTRL_HS400ES 0x0007 /* * According to the standard specification, BIT(3) of SDHCI_SOFTWARE_RESET is @@ -132,6 +133,15 @@ static inline void sdhci_sprd_sd_clk_off(struct sdhci_host *host) sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL); } +static inline void sdhci_sprd_sd_clk_on(struct sdhci_host *host) +{ + u16 ctrl; + + ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + ctrl |= SDHCI_CLOCK_CARD_EN; + sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL); +} + static inline void sdhci_sprd_set_dll_invert(struct sdhci_host *host, u32 mask, bool en) { @@ -325,6 +335,26 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) sdhci_request(mmc, mrq); } +static void sdhci_sprd_hs400_enhanced_strobe(struct mmc_host *mmc, + struct mmc_ios *ios) +{ + struct sdhci_host *host = mmc_priv(mmc); + u16 ctrl_2; + + if (!ios->enhanced_strobe) + return; + + sdhci_sprd_sd_clk_off(host); + + /* Set HS400 enhanced strobe mode */ + ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); + ctrl_2 &= ~SDHCI_CTRL_UHS_MASK; + ctrl_2 |= SDHCI_SPRD_CTRL_HS400ES; + sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); + + sdhci_sprd_sd_clk_on(host); +} + static const struct sdhci_pltfm_data sdhci_sprd_pdata = { .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK, .quirks2 = SDHCI_QUIRK2_BROKEN_HS200 | @@ -346,6 +376,8 @@ static int sdhci_sprd_probe(struct platform_device *pdev) host->dma_mask = DMA_BIT_MASK(64); pdev->dev.dma_mask = &host->dma_mask; host->mmc_host_ops.request = sdhci_sprd_request; + host->mmc_host_ops.hs400_enhanced_strobe = + sdhci_sprd_hs400_enhanced_strobe; host->mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | MMC_CAP_ERASE | MMC_CAP_CMD23;