From: Wenchao Chen <wenchao.chen@unisoc.com>
To: <ulf.hansson@linaro.org>, <zhang.lyra@gmail.com>,
<orsonzhai@gmail.com>, <baolin.wang@linux.alibaba.com>
Cc: <linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<wenchao.chen666@gmail.com>, <zhenxiong.lai@unisoc.com>,
<yuelin.tang@unisoc.com>, Wenchao Chen <wenchao.chen@unisoc.com>
Subject: [PATCH] mmc: sprd: Fix eMMC init failure after hw reset
Date: Mon, 4 Dec 2023 14:49:34 +0800 [thread overview]
Message-ID: <20231204064934.21236-1-wenchao.chen@unisoc.com> (raw)
Some eMMC devices that do not close the auto clk gate
after hw reset will cause eMMC initialization to fail.
Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
---
drivers/mmc/host/sdhci-sprd.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 6b8a57e2d20f..bed57a1c64b5 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -239,15 +239,19 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
sdhci_enable_clk(host, div);
+ val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
+ mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN | SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
/* Enable CLK_AUTO when the clock is greater than 400K. */
if (clk > 400000) {
- val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
- mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
- SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
if (mask != (val & mask)) {
val |= mask;
sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
}
+ } else {
+ if (val & mask) {
+ val &= ~mask;
+ sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+ }
}
}
--
2.17.1
next reply other threads:[~2023-12-04 6:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 6:49 Wenchao Chen [this message]
2023-12-07 13:58 ` Ulf Hansson
2023-12-08 11:52 ` Wenchao Chen
2023-12-12 2:57 ` Baolin Wang
2024-01-03 1:40 ` Wenchao Chen
2024-01-03 10:27 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231204064934.21236-1-wenchao.chen@unisoc.com \
--to=wenchao.chen@unisoc.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=ulf.hansson@linaro.org \
--cc=wenchao.chen666@gmail.com \
--cc=yuelin.tang@unisoc.com \
--cc=zhang.lyra@gmail.com \
--cc=zhenxiong.lai@unisoc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®