public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] MMC compatibility fix - OCR mask
@ 2004-09-18 10:00 Pierre Ossman
  2004-09-18 10:43 ` Russell King
  0 siblings, 1 reply; 5+ messages in thread
From: Pierre Ossman @ 2004-09-18 10:00 UTC (permalink / raw)
  To: linux-kernel, Russell King

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

This patch avoids using a emtpy OCR mask for the initial power up. Since 
some cards do not like a one bit-mask a routine has been added which 
grows the mask to three bits (one extra bit on each side) if necessary.


[-- Attachment #2: mmc-ocr.patch --]
[-- Type: text/x-patch, Size: 1072 bytes --]

Index: linux-wbsd/drivers/mmc/mmc.c
===================================================================
--- linux-wbsd/drivers/mmc/mmc.c	(revision 63)
+++ linux-wbsd/drivers/mmc/mmc.c	(revision 64)
@@ -300,6 +300,31 @@
 	return ocr;
 }
 
+/*
+ * Calculate a OCR mask to use for initial scanning.
+ * All zeroes and all ones cannot be used with some cards.
+ * Just on bit cannot be used either so extend the OCR
+ * if needed.
+ */
+
+static u32 mmc_select_scan_ocr(struct mmc_host *host)
+{
+	u32 ocr;
+
+	ocr = host->ocr_avail;
+
+	/* Check if we have more than one bit */
+	if (ocr & (ocr << 1))
+		return ocr;
+	if (ocr & (ocr >> 1))
+		return ocr;
+
+	/* Extend the mask to surrounding bits */
+	ocr |= (ocr << 1) | (ocr >> 1);
+
+	return ocr;
+}
+
 static void mmc_decode_cid(struct mmc_cid *cid, u32 *resp)
 {
 	memset(cid, 0, sizeof(struct mmc_cid));
@@ -589,7 +614,9 @@
 
 		mmc_power_up(host);
 
-		err = mmc_send_op_cond(host, 0, &ocr);
+		ocr = mmc_select_scan_ocr(host);
+
+		err = mmc_send_op_cond(host, ocr, &ocr);
 		if (err != MMC_ERR_NONE)
 			return;
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-09-18 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-18 10:00 [PATCH 3/3] MMC compatibility fix - OCR mask Pierre Ossman
2004-09-18 10:43 ` Russell King
2004-09-18 11:06   ` Pierre Ossman
2004-09-18 11:21     ` Russell King
2004-09-18 11:30       ` Pierre Ossman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox