From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/4] mci: sdhci: implement sdhci_reset()
Date: Wed, 15 Apr 2020 11:29:14 +0200 [thread overview]
Message-ID: <20200415092916.21285-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200415092916.21285-1-a.fatoum@pengutronix.de>
SDHCI reset is common between many SDHCI variants. Add a library
function, so it can be reused.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mci/sdhci.c | 11 +++++++++++
drivers/mci/sdhci.h | 3 +++
2 files changed, 14 insertions(+)
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index 172c8343a199..dba26b2665da 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -138,3 +138,14 @@ int sdhci_transfer_data(struct sdhci *sdhci, struct mci_data *data)
return 0;
}
+
+int sdhci_reset(struct sdhci *sdhci, u8 mask)
+{
+ u8 val;
+
+ sdhci_write8(sdhci, SDHCI_SOFTWARE_RESET, mask);
+
+ return sdhci_read8_poll_timeout(sdhci, SDHCI_SOFTWARE_RESET,
+ val, !(val & mask),
+ 100 * USEC_PER_MSEC);
+}
diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h
index 7ac32f1541b8..bf0c3e0f6c0c 100644
--- a/drivers/mci/sdhci.h
+++ b/drivers/mci/sdhci.h
@@ -70,6 +70,8 @@
#define SDHCI_TIMEOUT_CONTROL 0x2e
#define SDHCI_SOFTWARE_RESET 0x2f
#define SDHCI_RESET_ALL BIT(0)
+#define SDHCI_RESET_CMD BIT(1)
+#define SDHCI_RESET_DATA BIT(2)
#define SDHCI_INT_STATUS 0x30
#define SDHCI_INT_NORMAL_STATUS 0x30
#define SDHCI_INT_DATA_END_BIT BIT(22)
@@ -145,6 +147,7 @@ void sdhci_set_cmd_xfer_mode(struct sdhci *host, struct mci_cmd *cmd,
struct mci_data *data, bool dma, u32 *command,
u32 *xfer);
int sdhci_transfer_data(struct sdhci *sdhci, struct mci_data *data);
+int sdhci_reset(struct sdhci *sdhci, u8 mask);
/**
* sdhci_readx_poll_timeout - Periodically poll an sdhci register until
--
2.26.0.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-04-15 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-15 9:29 [PATCH 1/4] mci: sdhci: provide sdhci_readx_poll_timeout helpers Ahmad Fatoum
2020-04-15 9:29 ` Ahmad Fatoum [this message]
2020-04-15 9:29 ` [PATCH 3/4] ARM: at91: dts: specify aliases for sdmmc nodes Ahmad Fatoum
2020-04-15 9:29 ` [PATCH 4/4] mci: sdhci: add Atmel SDHCI (sama5d2, sam9x60) support Ahmad Fatoum
2020-04-20 6:22 ` [PATCH 1/4] mci: sdhci: provide sdhci_readx_poll_timeout helpers Sascha Hauer
2020-04-20 6:25 ` Ahmad Fatoum
2020-04-22 5:51 ` Sascha Hauer
2020-04-22 5:49 ` [PATCH 1/2] iopoll: Introduce read_poll_timeout Sascha Hauer
2020-04-22 5:49 ` [PATCH 2/2] mci: sdhci: provide sdhci_readx_poll_timeout helpers Sascha Hauer
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=20200415092916.21285-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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