From patchwork Fri Nov 6 02:27:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 320702 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp948704ilc; Thu, 5 Nov 2020 18:28:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGxRaSipS5IbyJHyiGOcmeR2rFtSo5Sp7E5V5ccs5ReVd6dMEUK/fp4hYWznZ84p6NlBQY X-Received: by 2002:a05:6402:8cc:: with SMTP id d12mr5897914edz.134.1604629718681; Thu, 05 Nov 2020 18:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604629718; cv=none; d=google.com; s=arc-20160816; b=o0evBHxpZrth1rOUAmB3B+enb64DhOBBetLLi4Vsc8TvxS2LuICunM4ZxK7VcF9oQJ yk/pf8UH4BVAgWL63vLjPlhnjpdSTTMkZj17CIO+NeWnwkDz+nCweha4lyVIuXFB1OcZ /z6Ia6o66RaeuVBxF5yjy+c2cGHSt50RWrgPbdq6CE+kLmf495KCP7Brl8d1FAJZsAp9 p9LjXYbbNBu5WDCn3A5M4mZmGWK00+AnIFmHfRUyF4weYVh8NvV11G2y9WhIGSoxZSBj Ui9z9i83tgxdqdB/FY6vO7WlV+VcWZzEUIGtSt4oIhDBeLzTvdGSLK/1rkt0S7bSDDWN ms1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HuB4tj6YcDY9jEmweGp+8BpnRDVzUuLPeDdIKG/BTQk=; b=Tljcx3GBsdPfBnxqD9ljVhtOCwupIjoyefHewUDLQ7OUY6eVZXpyxF3s7zhph1diyK zLJ/OU1i9bacSdnm31z1mx09hdiscAxbBL6FmJinZVUWo+One3ww5uh95uA7dhDPgsXY ujnET/lFf8eyRsxnJImwG6Ty2yIW2DZzUJkB2Gljr4G+fGTXYgZdugUZWuor9KOGaS1D n22t5+yyq/awvso+XgHwAFpQO5IyDME4+H7Zbe1+RPEYfcqmPeDj1MkeTQ30wgl/UQxm BM+hMDVRhtXch5rM4TybVWpaZOPtJY0ODXV9BigiFHjjbxgRfVEDAe6A9CZtXfEdXfWI 2n2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i4mOZOo8; spf=pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-mmc-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. [23.128.96.18]) by mx.google.com with ESMTP id bl4si2877254ejb.79.2020.11.05.18.28.38; Thu, 05 Nov 2020 18:28:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i4mOZOo8; spf=pass (google.com: domain of linux-mmc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-mmc-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 S1726157AbgKFC2f (ORCPT + 4 others); Thu, 5 Nov 2020 21:28:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbgKFC2e (ORCPT ); Thu, 5 Nov 2020 21:28:34 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C5B6C0613D3 for ; Thu, 5 Nov 2020 18:28:34 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id e21so2760889pgr.11 for ; Thu, 05 Nov 2020 18:28:34 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=HuB4tj6YcDY9jEmweGp+8BpnRDVzUuLPeDdIKG/BTQk=; b=i4mOZOo8wwAaOXT1SCNtxjLC04KiRx/Vh6I3a3QcmdZaU/4hqnXCzWSdJFrYAnpR+A NXOR+3+9cimiGzvPrS2Cm0jgDd9llZBxVYEy40VUinPbGEO7OZbwUDgj6lHO9vrTOfe9 Z+os9yIerR6Y25p1Phiyr1kqCbsspCpm0+ymXoYZIth1mrY+hk49bCAC3JqXvWmmlO7H Me4Lji9r/hbEZGuhDDVkO+4TEi6LzDvXi+3yBhioRcNSVGeN0kmuESZTAcT4hz7AszXQ UzhZnrd/2Ib+hZ7DiWj4r+9QdVREpYWvKUysk8d4DnoTwKI34kNs6CHwOw9BhUITL0nB nyMQ== 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:mime-version:content-transfer-encoding; bh=HuB4tj6YcDY9jEmweGp+8BpnRDVzUuLPeDdIKG/BTQk=; b=i0Fp8d5PXLpfuo3FN+R0krnZNQhoN+3Y38d/RMtLtHW7fvJ+66KoCdn2reVrxnvvqs t8O6fwBNaABnHb2p6mXX+eJbyyj4QVuXF/2kmS1X6VR2TRmJ5gJFJK9TJj/dHhsmGwE8 x5OHVzXF0eyqyPN6VxTpGt5bdFFEN0dAX+o7JOW3X+oLZlQ4TcA/9dxBHQyWTfHAyGVB r2yRP41yf2iZJ5PW4SJOw4OhZp5nm9C1otkvDA2oZGn/XlNxF2uTqUXIKZzF43MPNuJh nOdJ+k/iUMFcpfumxvQngIStBP2igiEwJfQrgJx2M2Afg7PHr2To3AJhhhqNXCdXBUNb c7QA== X-Gm-Message-State: AOAM530N64luSuFmBqSBYCUrgnPG3BaGp3BuZNB/XhOf5G16rX4mS0rq iTgzAT2TtZewjsciKS8I68H+ig== X-Received: by 2002:a17:90a:c7c4:: with SMTP id gf4mr26662pjb.18.1604629713965; Thu, 05 Nov 2020 18:28:33 -0800 (PST) Received: from localhost.localdomain (p784a66b9.tkyea130.ap.so-net.ne.jp. [120.74.102.185]) by smtp.gmail.com with ESMTPSA id m13sm3703040pjr.30.2020.11.05.18.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 18:28:33 -0800 (PST) From: AKASHI Takahiro To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, ben.chuang@genesyslogic.com.tw, greg.tu@genesyslogic.com.tw, AKASHI Takahiro Subject: [RFC PATCH v3.1 12/27] mmc: sdhci-uhs2: add reset function Date: Fri, 6 Nov 2020 11:27:11 +0900 Message-Id: <20201106022726.19831-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201106022726.19831-1-takahiro.akashi@linaro.org> References: <20201106022726.19831-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Sdhci_uhs2_reset() does a UHS-II specific reset operation. Signed-off-by: Ben Chuang Signed-off-by: AKASHI Takahiro --- drivers/mmc/host/sdhci-uhs2.c | 49 +++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci-uhs2.h | 1 + drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) -- 2.28.0 diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c index 08905ed081fb..e2b9743fe17d 100644 --- a/drivers/mmc/host/sdhci-uhs2.c +++ b/drivers/mmc/host/sdhci-uhs2.c @@ -10,6 +10,7 @@ * Author: AKASHI Takahiro */ +#include #include #include "sdhci.h" @@ -49,6 +50,54 @@ void sdhci_uhs2_dump_regs(struct sdhci_host *host) } EXPORT_SYMBOL_GPL(sdhci_uhs2_dump_regs); +/*****************************************************************************\ + * * + * Low level functions * + * * +\*****************************************************************************/ + +/** + * sdhci_uhs2_reset - invoke SW reset + * @host: SDHCI host + * @mask: Control mask + * + * Invoke SW reset, depending on a bit in @mask and wait for completion. + */ +void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask) +{ + unsigned long timeout; + + if (!(host->mmc->caps & MMC_CAP_UHS2)) + return; + + sdhci_writew(host, mask, SDHCI_UHS2_SW_RESET); + + if (mask & SDHCI_UHS2_SW_RESET_FULL) { + host->clock = 0; + /* Reset-all turns off SD Bus Power */ + if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON) + sdhci_runtime_pm_bus_off(host); + } + + /* Wait max 100 ms */ + timeout = 10000; + + /* hw clears the bit when it's done */ + while (sdhci_readw(host, SDHCI_UHS2_SW_RESET) & mask) { + if (timeout == 0) { + pr_err("%s: %s: Reset 0x%x never completed.\n", + __func__, mmc_hostname(host->mmc), (int)mask); + pr_err("%s: clean reset bit\n", + mmc_hostname(host->mmc)); + sdhci_writeb(host, 0, SDHCI_UHS2_SW_RESET); + return; + } + timeout--; + udelay(10); + } +} +EXPORT_SYMBOL_GPL(sdhci_uhs2_reset); + /*****************************************************************************\ * * * Driver init/exit * diff --git a/drivers/mmc/host/sdhci-uhs2.h b/drivers/mmc/host/sdhci-uhs2.h index b9529d32b58d..7bb7a0d67109 100644 --- a/drivers/mmc/host/sdhci-uhs2.h +++ b/drivers/mmc/host/sdhci-uhs2.h @@ -210,5 +210,6 @@ struct sdhci_host; void sdhci_uhs2_dump_regs(struct sdhci_host *host); +void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask); #endif /* __SDHCI_UHS2_H */ diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d4a57e8c9bb8..af336bdb4305 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -195,13 +195,14 @@ static void sdhci_runtime_pm_bus_on(struct sdhci_host *host) pm_runtime_get_noresume(host->mmc->parent); } -static void sdhci_runtime_pm_bus_off(struct sdhci_host *host) +void sdhci_runtime_pm_bus_off(struct sdhci_host *host) { if (!host->bus_on) return; host->bus_on = false; pm_runtime_put_noidle(host->mmc->parent); } +EXPORT_SYMBOL_GPL(sdhci_runtime_pm_bus_off); void sdhci_reset(struct sdhci_host *host, u8 mask) { diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index d9d7a76cedc1..b9932423db08 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -831,6 +831,7 @@ static inline void sdhci_read_caps(struct sdhci_host *host) __sdhci_read_caps(host, NULL, NULL, NULL); } +void sdhci_runtime_pm_bus_off(struct sdhci_host *host); u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock, unsigned int *actual_clock); void sdhci_set_clock(struct sdhci_host *host, unsigned int clock);