diff mbox

mmc: check if mmc cards < 2GB do sector addressing

Message ID F2990CF4-0E5C-40AF-9BF8-80345C28FF2E@marvell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Philip Rakity Jan. 27, 2011, 9 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index c139a5e..9303a57 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -378,6 +378,7 @@  static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	int err, ddr = 0;
 	u32 cid[4];
 	unsigned int max_dtr;
+	u32 rocr;
 
 	BUG_ON(!host);
 	WARN_ON(!host->claimed);
@@ -391,7 +392,7 @@  static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	mmc_go_idle(host);
 
 	/* The extra bit indicates that we support high capacity */
-	err = mmc_send_op_cond(host, ocr | (1 << 30), NULL);
+	err = mmc_send_op_cond(host, ocr | (1 << 30), &rocr);
 	if (err)
 		goto err;
 
@@ -479,6 +480,13 @@  static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		err = mmc_read_ext_csd(card);
 		if (err)
 			goto free_card;
+
+		/* if doing byte addressing check if required to do sector */
+		/* addressing.  Handle case of cards < 2GB needing sector */
+		/* addressing.  See section 8.1 JEDEC Standard JED84-A441 */
+		/* ocr register has bit 30 set for sector addressing */
+		if (!(mmc_card_blockaddr(card)) && (rocr & (1<<30)))
+			mmc_card_set_blockaddr(card);
 		/* Erase size depends on CSD and Extended CSD */
 		mmc_set_erase_size(card);
 	}