[PATCH 2/4] mci: sdhci: implement sdhci_reset()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SDHCI reset is common between many SDHCI variants. Add a library
function, so it can be reused.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux